private void LoginButton_Click(object sender, RoutedEventArgs e) { var login = _employeeService.Login(UsernameBox.Text, PasswordBox.Password); if (login == null) { MessageBox.Show("Username or Password Wrong"); } else { Settings.Default.Id = login.Id; Settings.Default.Position = login.Position.name; Settings.Default.Username = UsernameBox.Text; Settings.Default.Password = PasswordBox.Password; Settings.Default.Answer = login.answer; Settings.Default.Question = login.question; Settings.Default.Save(); overtimeParam.employee_id = login.Id; overtimeParam.check_in = DateTimeOffset.Now.LocalDateTime; overtimeParam.createDate = DateTime.Now.ToLocalTime(); _overtimeService.Insert(overtimeParam); if (login.password == "bootcamp" && login.question == null) { PasswordDefault pass = new PasswordDefault(); pass.Show(); this.Close(); } else if (login.password != "bootcamp" && login.question == null) { PopUpInsertQuestionAnswer popup = new PopUpInsertQuestionAnswer(); popup.Show(); this.Close(); } else { if (Settings.Default.Position == "Admin") { MainWindow main = new MainWindow(); main.Show(); this.Close(); } else { EmployeePage emp = new EmployeePage(); emp.Show(); this.Close(); } } } }
private void SaveButton_Click(object sender, RoutedEventArgs e) { if (PassTextBox.Password.Length < 8 || PassConfirm.Password.Length < 8 || PassConfirm.Password.Length > 16 || PassTextBox.Password.Length > 16) { MessageBox.Show("At Least 8 - 16 Character"); } else { if (string.IsNullOrWhiteSpace(OldCombobox.Text) == true || string.IsNullOrWhiteSpace(OldTextbox.Text) == true) { MessageBox.Show("Answer Field must not be empty or whitespace"); } else { if (PassTextBox.Password == PassConfirm.Password) { int id = Settings.Default.Id; param.password = PassTextBox.Password; param.question = OldCombobox.Text; param.answer = OldTextbox.Text; _employeeService.UpdateBootcamp(id, param); Settings.Default.Password = PassTextBox.Password; Settings.Default.Question = OldCombobox.Text; Settings.Default.Answer = OldTextbox.Text; Settings.Default.Save(); MessageBox.Show("Successfully change"); if (Settings.Default.Position == "Admin") { MainWindow main = new MainWindow(); main.Show(); this.Close(); } else { EmployeePage emp = new EmployeePage(); emp.Show(); this.Close(); } } else { MessageBox.Show("Password and Confirm not match"); } } } }