Quantcast
Channel: Ayuda con login en WinForms
Viewing all articles
Browse latest Browse all 10

Ayuda con login en WinForms

0
0
Hola a todos.

Estoy realizando un login en Winforms y pues hasta el momento todo va bien, este es el código que estoy utilizando:

 private void btnIniciar_Click(object sender, EventArgs e)
        {


            try
            {
                
                SqlConnection conexion = new SqlConnection(@"Data Source=AKATSUKI-PC;Initial Catalog=ProyectoSIRIA;Integrated Security=True");
                conexion.Open();

                             
                SqlCommand comando = new SqlCommand("select nombres_admin, identificacion_admin from tbl_cuenta where nombres_admin = '"+ txtUsuario.Text + " 'and identificacion_admin = '" + txtContrasenia.Text + "'"  , conexion);

                
               
                comando.ExecuteNonQuery();
                DataSet ds = new DataSet();
                SqlDataAdapter da = new SqlDataAdapter(comando);

                

                da.Fill(ds, "tbl_cuenta");

                DataRow DR;
                DR = ds.Tables["tbl_cuenta"].Rows[0];

                
                
                
                if ((txtUsuario.Text == DR["nombres_admin"].ToString()) || (txtContrasenia.Text == DR["identificacion_admin"].ToString()))
                {
                    //Acá
                    Principal Principal = new Principal();
                    Principal.Show();
                    this.Hide();
                    
                }
            }
            catch
            {
                
                MessageBox.Show("Error! Su usuario y/o contraseña son invalidos", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            

        }
Mi pregunta es: ¿Como valido que después de que el usuario se conecte, cuando le hace clic al botón de iniciar si el id_rol es igual a 1 lo lleve al form que en este caso se llama "Principal" y si el id_rol es 2 lo lleve a otro form?

Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images