Ver Mensaje Individual
  #5 (permalink)  
Antiguo 01/11/2010, 16:02
ariel_stura4
 
Fecha de Ingreso: noviembre-2010
Ubicación: Devoto
Mensajes: 5
Antigüedad: 13 años, 5 meses
Puntos: 0
Respuesta: Bool a una clase

A ver si te lo muestro mejor.


Código ASP:
Ver original
  1. public partial class _Default : System.Web.UI.Page
  2. {
  3.     bool login = false;
  4.    
  5.    
  6.     protected void Page_Load(object sender, EventArgs e)
  7.     {
  8.         Label3.Visible = false;
  9.         Label3.Text = "Usuario o contraseñas incorrectas";
  10.     }
  11.     protected void Button1_Click(object sender, EventArgs e)
  12.     {
  13.         if (Validar1(TextBox1.Text.ToString(),TextBox2.Text.ToString()) == true)
  14.         {
  15.             string conectionstring = @"Data Source =.\SQLEXPRESS;AttachDBFilename=C:\Documents and Settings\Administrador\Mis documentos\Visual Studio 2005\WebSites\WebSite4\App_Data\Base1.mdf;Integrated Security=True;User Instance=True;";
  16.             SqlConnection myConnection = new SqlConnection(conectionstring);
  17.  
  18.             myConnection.Open();
  19.  
  20.             SqlDataAdapter myCommand = new SqlDataAdapter("SELECT * FROM Users where Usuario = '" +
  21.                      this.TextBox1.Text +
  22.                      "' and password = '" +
  23.                      this.TextBox2.Text + "'", myConnection);
  24.             DataSet ds = new DataSet();
  25.             myCommand.Fill(ds);
  26.             if (ds.Tables[0].Rows.Count > 0)
  27.             {
  28.                 Response.Redirect("usuarioingresado.aspx");
  29.                          
  30.  
  31.             }
  32.             else
  33.             {
  34.                 Response.Redirect("default.aspx");
  35.                 Label3.Visible = true;
  36.                 Label3.Text = ("Usuario o nombres incorrectos");
  37.             }
  38.             myConnection.Close();
  39.         }
  40.         else
  41.         {
  42.             Label3.Visible = true;
  43.             Label3.Text = ("Usuario o nombres incorrectos (no concuerdan con los parametros)");
  44.         }
  45.     }
  46.  
  47.     private void Class1()
  48.     {
  49.         throw new Exception("The method or operation is not implemented.");
  50.     }
  51.     protected Boolean Validar1(string usuario, string password)
  52.     {
  53.  
  54.         string valnombre = "^[^@ ]+@[^@ ]+.[^@ .]";
  55.         string valpass = "[0-9A-Za-z]";
  56.         if (Regex.IsMatch(TextBox1.Text.ToString(), valnombre))
  57.         {
  58.             if (Regex.IsMatch(TextBox2.Text.ToString(), valpass))
  59.             {
  60.                 if (TextBox2.Text.Length > 6)
  61.                 {
  62.                     return false;
  63.                 }
  64.                 else
  65.                 {
  66.                     return true;
  67.                 }
  68.             }
  69.             else
  70.             {
  71.                 return false;
  72.             }
  73.         }
  74.         else
  75.         {
  76.             return false;
  77.         }
  78.  
  79.  
  80.     }
  81.     protected void Button2_Click(object sender, EventArgs e)
  82.     {
  83.         Response.Redirect("newuser.aspx");
  84.     }

Ese es el cuerpo del default si? ahi verifica y logea.
Lo que quiero hacer es mandar la variable bool login y la de textbox1 para despeus llamarla desde usuarioingresado.aspx que seria la parte para los usuarios.

Es bastante basico pero es lo que mas o menos vi en la secundaria, ahora intento perfeccionarme mas.