public void showKitchenForm() { disposeForms(); kitchenForm = new KitchenForm(); kitchenForm.Show(); kitchenForm.addController(this); }
private void btn_login_Click(object sender, EventArgs e) { User lastUser = userList.UserList.Last(); lblErrorInput.Hide(); String decryptedPass; String encryptedPass = Encrypt(txtBoxPassword.Text, GenerateEncryptionKey()); if (!txtBoxUsername.Text.Equals("") || !txtBoxPassword.Text.Equals("")) { foreach (User user in userList.UserList) { decryptedPass = Decrypt(user.Password, GenerateEncryptionKey()); //add pass and name of user to string nameList.Add(user.Name); passList.Add(user.Password); if (txtBoxUsername.Text.Equals(user.Name) && txtBoxPassword.Text.Equals(decryptedPass)) { switch (user.Position) { case "Cashier": { CashierMenuForm menuPage = new CashierMenuForm(user); this.Hide(); menuPage.ShowDialog(); this.Close(); //close previous form break; } case "Kitchen": { KitchenForm kitchenPage = new KitchenForm(); this.Hide(); kitchenPage.ShowDialog(); this.Close(); //close previous form break; } case "Admin": { ProductViewForm productPage = new ProductViewForm(); this.Hide(); productPage.ShowDialog(); this.Close(); //close previous form break; } default: { lblErrorInput.Text = "User doesnt have a position. Please contact the admin."; lblErrorInput.Show(); break; } } //end switch } //end if if (user.Equals(lastUser)) { //check in list if name or pass exists if (!nameList.Contains(txtBoxUsername.Text)) { loginCounter -= 1; lblErrorInput.Text = "Please enter valid username . " + loginCounter + " tries left."; lblErrorInput.Show(); break; }//end if else if (!passList.Contains(encryptedPass)) { loginCounter -= 1; lblErrorInput.Text = "Please enter valid password. " + loginCounter + " tries left."; lblErrorInput.Show(); break; }//end if else //if both name and pass exists among users, check if both entered name and password are from different users or not if (nameList.IndexOf(txtBoxUsername.Text) != passList.IndexOf(txtBoxPassword.Text)) { loginCounter -= 1; lblErrorInput.Text = "Wrong password for account. " + loginCounter + " tries left."; lblErrorInput.Show(); break; } } } //end foreach } //end if else { loginCounter -= 1; lblErrorInput.Text = "Please enter username or password. " + loginCounter + " tries left."; lblErrorInput.Show(); }//end else //if 5 tries of logins failed if (loginCounter == 0) { MessageBox.Show("Invalid user. Closing application now."); this.Close(); } }
private void button2_Click(object sender, EventArgs e) { int id = int.Parse(staffIdTxt.Text); var search = (from x in db.Staff where x.StaffId == id && x.StaffPassword.Equals(passTxt.Text) select x.StaffPosition).FirstOrDefault(); if (search != null) { if (search.Equals("Receptionist")) { rForm = new ReceptionistForm(); rForm.Show(); } else if (search.Equals("HouseKeeping")) { hkForm = new HouseKeepingForm(); hkForm.Show(); } else if (search.Equals("DiningRoom")) { drForm = new DiningRoomForm(); drForm.Show(); } else if (search.Equals("RoomService")) { rsForm = new RoomServiceForm(); rsForm.Show(); } else if (search.Equals("Kitchen")) { kForm = new KitchenForm(); kForm.Show(); } else if (search.Equals("Purchasing")) { pForm = new PurchasingForm(); pForm.Show(); } else if (search.Equals("AccountingAndFinance")) { aafForm = new AccountingAndFinanceForm(); aafForm.Show(); } else if (search.Equals("SalesAndMarketing")) { samForm = new SalesAndMarketingForm(); samForm.Show(); } else if (search.Equals("HumanCapital")) { hcForm = new HumanCapitalForm(); hcForm.Show(); } else if (search.Equals("HotelManager")) { hmForm = new HotelManagerForm(); hmForm.Show(); } } else { MessageBox.Show("Invalid Id or Password"); } }