private async void Button_Click(object sender, RoutedEventArgs e) { string name = txt_Name_Registration.Text.Trim(); string surname = txt_Surname_Registration.Text.Trim(); string patronymic = txt_Patronymic_Registration.Text.Trim(); string email = txt_Email_Registration.Text.Trim(); string password = txt_Password_Registration.Password.Trim(); string confirm_password = txt_Confirm_Password_Registration.Password.Trim(); bool Email_is_Db = _libdb.Sellers.Any(s => s.Seller_Email == email); if (Email_is_Db) { MessageBox.Show("Этот эмэил пользуется другим пользователем!!!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return; } Sellers seller = new Sellers(); seller.Seller_Name = name; seller.Seller_Surname = surname; seller.Seller_Patronymic = patronymic; seller.Seller_Email = email; seller.Seller_Password = password.HashPassword(); _libdb.Sellers.Add(seller); await _libdb.SaveChangesAsync(); if (Is_Valid(name, surname, patronymic, email, password, confirm_password)) { MessageBox.Show("Ваша решистрация прошла успешно!!!", "Success", MessageBoxButton.OK, MessageBoxImage.Information); this.Close(); return; } }
private bool Is_Valid(Sellers seller, string password) { if (seller == null) { MessageBox.Show("This email is not exists!!!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } if (seller.Is_Deleted) { MessageBox.Show("You don`t have account!!!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } if (!seller.Is_Activated) { MessageBox.Show("Please vait!!!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } if (seller.Seller_Password == password.HashPassword()) { MessageBox.Show("This password is incorrect!!!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return(false); } return(true); }
private async void Button_Click(object sender, RoutedEventArgs e) { Sellers seller = _libdb.Sellers.First(s => s.Seller_Name == txt_User_Name.Text.Trim()); int Selected_Case = cb_Case.SelectedIndex; switch (Selected_Case) { case (int)Case.Activated: seller.Is_Activated = true; seller.Is_Admin = false; seller.Is_Deleted = false; break; case (int)Case.Admin: seller.Is_Activated = true; seller.Is_Admin = true; seller.Is_Deleted = false; break; case (int)Case.Deleted: seller.Is_Activated = false; seller.Is_Admin = false; seller.Is_Deleted = true; break; default: break; } await _libdb.SaveChangesAsync(); txt_User_Name.Text = " "; cb_Case.Text = ""; }
private void btn_Login_LoginList_Click(object sender, RoutedEventArgs e) { string User_Name = txt_Login_UserName.Text.Trim(); string password = txt_Login_Password.Password.Trim(); if (User_Name == "" || password == "") { MessageBox.Show("Пожалуйста заполните эти поля !!!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning); return; } Sellers seller = _libdb.Sellers.FirstOrDefault(s => s.Seller_Email == User_Name); if (!Is_Valid(seller, password)) { return; } if (seller.Is_Admin) { Admin_Panel admin = new Admin_Panel(this); admin.Show(); return; } if (seller.Is_Activated) { Menu_List menu = new Menu_List(); menu.Show(); return; } }