Пример #1
0
 private void btnLogin_Click(object sender, EventArgs e)
 {
     if (txtUsername.Text == "" || txtPassword.Text == "")
     {
         MessageBox.Show("Porfavor escribe un nombre de usuario y contraseña");
         return;
     }
     try
     {
         //Create SqlConnection
         SqlConnection con = new SqlConnection(cs);
         SqlCommand    cmd = new SqlCommand("Select * from tbl_Login where UserName=@username and Password=@password", con);
         cmd.Parameters.AddWithValue("@username", txtUsername.Text);
         cmd.Parameters.AddWithValue("@password", txtPassword.Text);
         con.Open();
         SqlDataAdapter adapt = new SqlDataAdapter(cmd);
         DataSet        ds    = new DataSet();
         adapt.Fill(ds);
         con.Close();
         int count = ds.Tables[0].Rows.Count;
         //If count is equal to 1, than show frmMain form
         if (count == 1)
         {
             MessageBox.Show("Login Successful!");
             this.Hide();
             PaginaPrincipal fm = new PaginaPrincipal();
             fm.Show();
         }
         else
         {
             MessageBox.Show("Login Failed!");
         }
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.Message);
     }
 }
Пример #2
0
        private void ListadoPersonasPerdidas_FormClosed(object sender, FormClosedEventArgs e)
        {
            PaginaPrincipal pgP = new PaginaPrincipal();

            pgP.Show();
        }
        private void Registro_de_personas_FormClosed(object sender, FormClosingEventArgs e)
        {
            PaginaPrincipal pgP = new PaginaPrincipal();

            pgP.Show();
        }