private void BackButton_Click(object sender, RoutedEventArgs e) { AdminWindow main_window = new AdminWindow(admin); this.Close(); main_window.ShowDialog(); }
//login button //checks user's username & pass from users list private void LoginButton_Click(object sender, RoutedEventArgs e) { LabelPassed.Content = ""; string UserName = txt_Usuario.Text; string Password = txt_Password.Password.ToString(); ReadWriteJson file = new ReadWriteJson(); try { User userDetails = file.searchUser(UserName); if (Password == userDetails.Password && userDetails.Role == "Manager") { AdminWindow main = new AdminWindow(userDetails); this.Close(); main.ShowDialog(); } else if (Password != userDetails.Password && userDetails.Role == "Manager") { LabelPassed.Content = "Wrong password"; txt_Password.BorderBrush = Brushes.Red; } else { LabelPassed.Content = "Students can't login!"; } } catch (FormatException) { LabelPassed.Content = "Wrong Input,please check national code!"; txt_Password.BorderBrush = Brushes.Red; } catch (FileNotFoundException) { LabelPassed.Content = "User not found!"; txt_Usuario.BorderBrush = Brushes.Red; } catch (Exception ex) { MessageBox.Show(ex.Message); } }