Beispiel #1
0
        public void Ingresar()
        {
            try
            {
                string Conexion = ConfigurationManager.ConnectionStrings["Conexion"].ConnectionString;
                using (SqlConnection ConexionBD = new SqlConnection(Conexion))
                {
                    ConexionBD.Open();
                    using (SqlCommand cmd = new SqlCommand("SELECT Usuario, Contraseña FROM Ingreso WHERE Usuario ='" + txtUsuario.Text + "' AND Contraseña ='" + txtContraseña.Text + "'", ConexionBD))
                    {
                        SqlDataReader dr = cmd.ExecuteReader();

                        if (dr.Read())
                        {
                            this.Hide();
                            MDIPaciente p = new MDIPaciente();
                            p.Show();
                        }

                        else
                        {
                            MessageBox.Show("Error de autenticacion, verifique usuario y/o contraseña ó es posible que su cuenta este inhabilitada", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            txtContraseña.Text = "";
                            txtUsuario.Text    = "";
                        }

                        ConexionBD.Close();
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
Beispiel #2
0
        private void btnIngresar_Click(object sender, EventArgs e)
        {
            string[,] arreglo = { { "wortiz" }, { "1234" } };

            if (txtUsuario.Text == arreglo[0, 0] && txtContraseña.Text == arreglo[1, 0])
            {
                this.Hide();
                MDIPaciente p = new MDIPaciente();
                p.Show();
            }

            else

            {
                MessageBox.Show("Error de autenticacion, verifique usuario y/o contraseña ó es posible que su cuenta este inhabilitada", "Mensaje del sistema", MessageBoxButtons.OK, MessageBoxIcon.Information);
                txtContraseña.Text = "";
                txtUsuario.Text    = "";
            }
        }