private void btnReturn_Click(object sender, EventArgs e) { WaiterForm waitForm = new WaiterForm(); waitForm.Show(); this.Hide(); }
// This will receive input (employeeID and password) from LoginForm and pass it into the below SQL statement public void LogIn(int employeeID, string password) { try { // This will look up employeeID and password based on input from LoginForm. If both match // the database entries, then based on the role associated with that employee, // the required form will open for the employee to perform their job. SqlConnection con = new SqlConnection(); con.ConnectionString = "Server=cis1.actx.edu;Database=project2;User Id=db2;Password = db20;"; con.Open(); using (SqlCommand readEmployeeRecords = con.CreateCommand()) { readEmployeeRecords.CommandText = "select * from dbo.Employee where employeeID = @employeeID and password = @password;"; var empID = new SqlParameter("employeeID", employeeID); var pass = new SqlParameter("password", password); readEmployeeRecords.Parameters.Add(empID); readEmployeeRecords.Parameters.Add(pass); using (SqlDataReader reader = readEmployeeRecords.ExecuteReader()) { string rec = ""; string status = ""; while (reader.Read()) { rec = reader.GetString(5); status = reader.GetString(6); } if (status == "Active") { switch (rec) { case "Busboy": BusboyForm bus = new BusboyForm(); bus.Show(); break; case "Waiter": WaiterForm wait = new WaiterForm(); wait.Show(); break; case "Manager": RandomChallenge(employeeID); break; case "Host": HostForm host = new HostForm(); host.Show(); break; case "Cook": CookForm cookie = new CookForm(); cookie.Show(); break; } } else { MessageBox.Show("Bounce, fool."); Application.Exit(); } } } con.Close(); } catch (Exception err) { MessageBox.Show(err.Message); } }