private void button_BackToMenu_Click(object sender, EventArgs e) { StaffUnPriv Form = new StaffUnPriv(f); this.Hide(); Form.Show(); }
private void button1_Click(object sender, EventArgs e) { int id2; id2 = 1; bool isStaff = true; bool isManager = true; /* * * DbConnection db = new DbConnection();// * string conString = db.GetConnectionString();// * SqlConnection sq = new SqlConnection(conString);// * SqlCommand command = new SqlCommand();// * command.Connection = sq; * //string sql = "Select ; * //command.CommandText = sql; * sq.Open(); * SqlDataReader reader = command.ExecuteReader(); */ // we will put a check after connecting forms to database //on click we will check whether the login id and password exists in databse StaffName = comboBox1.SelectedItem.ToString(); DbConnection db = new DbConnection(); // string conString = db.GetConnectionString(); // SqlConnection sq = new SqlConnection(conString); // SqlCommand command = new SqlCommand(); // command.Connection = sq; string sql = "select Jobs_idJob from Staff where FirstName + ' ' + LastName = '" + StaffName + "'"; command.CommandText = sql; sq.Open(); SqlDataReader reader = command.ExecuteReader(); while (reader.Read()) { id2 = int.Parse(reader.GetValue(0).ToString()); } if (isStaff == true & textbox_Password.Text.ToString() == "iamstaff") { MessageBox.Show("Successful login by " + StaffName); StaffUnPriv Form = new StaffUnPriv(StaffName); this.Hide(); Form.Show(); } else if (id2 == 1 && isManager == true && textbox_Password.Text.ToString() == "iammanager") { MessageBox.Show("Successful login by " + StaffName); Menu Form = new Menu(StaffName); this.Hide(); Form.Show(); } else { MessageBox.Show("Access Denied. Use your correct password to login."); } }