private void ButtonSignUP_Click(object sender, RoutedEventArgs e) { using (var writer = new StreamWriter("emails/emails", true)) writer.WriteLine(registerMViewModel.RegisterModel.Email); User user = new User(registerMViewModel.RegisterModel.Login, registerMViewModel.RegisterModel.Email, registerMViewModel.RegisterModel.ConfirmPasswd); user.Serialize(); RentalServiceMenu rentalSerivce = new RentalServiceMenu(user); LOGIN.Visibility = Visibility.Visible; SignUP.Visibility = Visibility.Hidden; this.Hide(); if (rentalSerivce.ShowDialog() == true) { this.Show(); } else { this.Close(); } }
private void ButtonLogin_Click(object sender, RoutedEventArgs e) { bool is_admin_try = false; if (chb_alogin.IsChecked == true) { is_admin_try = true; if (File.Exists(admins_path + logTxtBox_login.Text)) { Admin admin = new Admin(); admin.Deserialize(admins_path + logTxtBox_login.Text); if (admin.Passwd == passwdbox.Password) { chb_alogin.IsChecked = false; AdminMenu rentalSerivce = new AdminMenu(admin); this.Hide(); if (rentalSerivce.ShowDialog() == true) { this.Show(); } else { this.Close(); } } else { MsgBox msgBox = new MsgBox("Authorization error", "Wrong password!"); msgBox.Owner = this; msgBox.ShowDialog(); } } else { chb_alogin.IsChecked = false; MsgBox msgBox = new MsgBox("Authorization error", "No user with this login was found!"); msgBox.Owner = this; msgBox.ShowDialog(); } } if (!is_admin_try) { if (!File.Exists(users_path + logTxtBox_login.Text)) { MsgBox msgBox = new MsgBox("Authorization error", "No user with this login was found!"); msgBox.Owner = this; msgBox.ShowDialog(); } else { User user = new User(); user.Deserialize(users_path + logTxtBox_login.Text); if (user.Passwd == passwdbox.Password) { RentalServiceMenu rentalSerivce = new RentalServiceMenu(user); this.Hide(); if (rentalSerivce.ShowDialog() == true) { this.Show(); } else { this.Close(); } } else { MsgBox msgBox = new MsgBox("Authorization error", "Wrong password!"); msgBox.Owner = this; msgBox.ShowDialog(); } } } }