private void btnclose_Click(object sender, EventArgs e) { PrincipleMainForm obj = new PrincipleMainForm(); this.Hide(); obj.Close(); }
private void btnLogin_Click(object sender, EventArgs e) { try { if (validate()) { string username = "", password = "", roleID = ""; objcon.Open(); string query = "select User_Username,User_Password,User_Role_Id from tbl_User where User_Username='******' and User_Password='******' "; objcon.cmd.CommandText = query; objcon.reader = objcon.cmd.ExecuteReader(); if (objcon.reader.Read()) { username = objcon.reader.GetValue(0).ToString(); password = objcon.reader.GetValue(1).ToString(); roleID = objcon.reader.GetValue(2).ToString(); } objcon.reader.Close(); objcon.Close(); if (username == txtUsername.Text && password == txtPassword.Text) { switch (roleID) { case "1": PrincipleMainForm obj = new PrincipleMainForm(); this.Hide(); obj.Show(); break; case "2": StaffMainForm obj2 = new StaffMainForm(); this.Hide(); obj2.Show(); break; case "3": Operator_main_form obj1 = new Operator_main_form(); this.Hide(); obj1.Show(); break; } } else { MessageBox.Show("Username or Password are incorrect"); } } else { MessageBox.Show("Enter Values"); } } catch (Exception ex) { MessageBox.Show(ex.Message); } }