private void backButton_Click(object sender, EventArgs e) { this.Hide(); Admin_Dashboard h = new Admin_Dashboard(); h.Show(); }
private void LoginButton_Click(object sender, EventArgs e) { if (UserNameTextBox.Text == "") { MessageBox.Show("Enter Your User Name!"); } else if (PasswordTextBox.Text == "") { MessageBox.Show("Enter Your Password!"); } else { string query = "select * from Employees where EmployeeName = '" + this.UserNameTextBox.Text + "' and EmployeePassword = '******';"; SqlConnection connection = new SqlConnection(ConfigurationManager.ConnectionStrings["HungerGamesDb"].ConnectionString); connection.Open(); SqlCommand sqlcom = new SqlCommand(query, connection); SqlDataAdapter sda = new SqlDataAdapter(sqlcom); DataTable dt = new DataTable(); sda.Fill(dt); if (dt.Rows.Count == 1) { da = new DataAccess(); string sql = "SELECT EmployeeStatus FROM Employees WHERE EmployeeName='" + UserNameTextBox.Text + "'"; SqlDataReader reader1 = da.GetData(sql); Employee em = new Employee(); while (reader1.Read()) { em.EmployeeStatus = reader1["EmployeeStatus"].ToString(); } if (em.EmployeeStatus == "Admin") { Admin_Dashboard admin_Dashbord = new Admin_Dashboard(); admin_Dashbord.Show(); this.Hide(); } else if (em.EmployeeStatus == "Manager") { Manager_Dashboard manager_Dashbord = new Manager_Dashboard(); manager_Dashbord.Show(); this.Hide(); } else if (em.EmployeeStatus == "Waiter") { Employee_Dashboard employee_Dashbord = new Employee_Dashboard(); employee_Dashbord.Show(); this.Hide(); } else { MessageBox.Show("Error! Input is Invalid"); } } else { MessageBox.Show("Wrong ID or, Invalid Password!"); } } }