Exemple #1
0
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            try
            {
                CNUsuario     objUsuario = new CNUsuario();
                SqlDataReader Loguear;
                objUsuario.Expediente = txtUsuario.Text;
                objUsuario.Contraseña = txtContraseña.Text;


                if (objUsuario.Expediente == txtUsuario.Text)
                {
                    labelErrorUsuario.Visible = false;

                    if (objUsuario.Contraseña == txtContraseña.Text)
                    {
                        labelErrorContraseña.Visible = false;
                        Loguear = objUsuario.IniciarSesion();

                        if (Loguear.Read() == true)
                        {
                            this.Hide();

                            Form_MenuPrincipal objFP = new Form_MenuPrincipal();

                            //Carga los campos guardados en datareader para usarlos en los forms
                            Program.tipoUsuario = Loguear["tipoUsuario"].ToString();
                            Program.nombre      = Loguear["nombre"].ToString();
                            Program.expediente  = Loguear["expediente"].ToString();
                            Program.idUsuario   = Loguear["idUsuario"].ToString();
                            objFP.Show();
                        }

                        else
                        {
                            labelErrorLogin.Visible = true;
                            labelErrorLogin.Text    = "Usuario o contraseña invalidos. intente de nuevo";
                            txtUsuario.Text         = "";
                            txtUsuario_Leave(null, e);
                            txtUsuario.Focus();
                        }
                    }
                    else
                    {
                        labelErrorContraseña.Visible = true;
                        labelErrorContraseña.Text    = objUsuario.Contraseña;
                    }
                }
                else
                {
                    labelErrorUsuario.Visible = true;
                    labelErrorUsuario.Text    = objUsuario.Expediente;
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Error con la conexion al servidor. " +
                                "Verifique que la cadena de conexion y la ruta esten correctas!!!");
            }
        }
Exemple #2
0
        private void gridPrestamos_CellClick(object sender, DataGridViewCellEventArgs e)
        {
            FormRegistrarPrestamoDevolucion FormPrestamo = new FormRegistrarPrestamoDevolucion();
            Form_MenuPrincipal Fierro = new Form_MenuPrincipal();

            try
            {
                DataGridViewRow fila = gridPrestamos.Rows[e.RowIndex];

                enviado(Convert.ToString(fila.Cells[0].Value),
                        Convert.ToDateTime(fila.Cells[2].Value),
                        Convert.ToDateTime(fila.Cells[3].Value)
                        );

                this.Close();
            }
            catch (Exception) {}
        }