Example #1
0
        public bool logearse(Form frm, Label lblUser, Label lblPass, Label lblLogearse, TextBox user, TextBox pass)
        {
            SqlDataReader Loguear;

            if (Usuario == string.Empty)
            {
                lblUser.Text = "Llene el campo usuario";
                return(false);
            }
            else
            {
                lblUser.Text = string.Empty;
            }
            if (Contraseña == string.Empty)
            {
                lblPass.Text = "Llene el campo de contraseña";
                return(false);
            }
            else
            {
                lblPass.Text = string.Empty;
            }
            Loguear = Usuario_D.logearse(Usuario, Contraseña);
            if (Loguear.Read() == true)
            {
                frm.Show();
                return(true);
            }
            else
            {
                pass.Text        = string.Empty;
                lblLogearse.Text = "Usuario o contraseña invalidas, intente de nuevo";
                return(false);
            }
        }
Example #2
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            leer = null;
            string error = "Datos erroneos. Vuelva a intentarlo";
            string nombre;

            user = new CDUsuario(txtEmail.Text, txtPass.Text);

            leer = user.logearse();

            //MessageBox.Show(leer.Read() == true ? "Se encontro el usuario" : "No se encontro el usuario");
            //Mensaje de error:
            if (leer.Read() == true)
            {
                nombre = leer[0].ToString();
                CPMain frm = new CPMain(nombre);
                frm.Show();
                this.Hide();
            }
            else
            {
                lblError.Text = error;
                limpiar();
            }
        }