Beispiel #1
0
        private void Logear()
        {
            string usuario  = txtUsuario.Text.Trim();
            string password = txtPassword.Text.Trim();

            if (string.IsNullOrEmpty(txtUsuario.Text.Trim()))
            {
                txtUsuario.Focus();
                txtError.Text = "Campo requerido - Ingrese nombre usuario/Email";
            }
            else if (string.IsNullOrEmpty(txtPassword.Text.Trim()))
            {
                txtPassword.Focus();
                txtError.Text = "Campo requerido - Ingrese password. si se ha olvidado pulse He olvidado mi contraseña";
            }
            else
            {
                DataTable tabla    = NAcceso.Acceso(usuario, password);
                int       numFilas = tabla.Rows.Count;
                if (numFilas > 0)
                {
                    frmHome frm = new frmHome();
                    Program.idUsuario  = Convert.ToInt32(tabla.Rows[0]["idusuario"].ToString());
                    Program.tipo       = tabla.Rows[0]["tipo"].ToString();
                    Program.idEmpleado = Convert.ToInt32(tabla.Rows[0]["idempleado"].ToString());
                    Program.nombres    = tabla.Rows[0]["nombres"].ToString();
                    Program.apellidos  = tabla.Rows[0]["apellidos"].ToString();
                    Program.correo     = tabla.Rows[0]["correo"].ToString();
                    frm.Show();
                    this.Hide();
                }
                else
                {
                    MessageBox.Show("Error cuenta usuario incorrecto ..... !!??", "Error al iniciar sesiòn", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
 private void frmHome_FormClosed(object sender, FormClosedEventArgs e)
 {
     MyForm = null;
 }