public bool PassChanged(TextBox tb1, TextBox tb2, WorkerMfc f) { WorkerMfc worker = DB2.WorkerMfc.Where(c => c.Login == f.Login).SingleOrDefault(); if (tb1.Text != tb2.Text) { MessageBox.Show("Пароли не совпадает в полях"); return(false); } else if (tb2.Text == "qwe") { MessageBox.Show("Пароль не может быть -qwe "); return(false); } else if (tb1.Text.Length < 8) { MessageBox.Show("Ваш пороль меньше 8 символов"); return(false); } else { worker.Password = Hash.HashPassword(tb2.Text); DB2.SaveChanges(); return(true); } }
public void Dell(DataGrid DGWorker) { WorkerMfc worker = DGWorker.SelectedItem as WorkerMfc; if (worker == null) { return; } MessageBoxResult msbr = MessageBox.Show("Вы уверены?", "Вопрос", MessageBoxButton.YesNo, MessageBoxImage.Question); if (msbr == MessageBoxResult.Yes) { DB2.WorkerMfc.Remove(worker); } }
public void Edit(TextBox TBLast, TextBox TBLog, TextBox TBName, TextBox TBPass, TextBox TBSur, TextBox TBTel, ComboBox cBPost, DataGrid DGWorker) { WorkerMfc worker = DGWorker.SelectedItem as WorkerMfc; if (worker == null) { return; } worker.Lastname = TBLast.Text; worker.Firstname = TBName.Text; worker.PassportWorker = TBPass.Text; worker.Surname = TBSur.Text; worker.Telephone = TBTel.Text; worker.PostWorker = cBPost.Text; DB2.SaveChanges(); }
public void Fill(TextBox TBLast, TextBox TBLog, TextBox TBName, TextBox TBPass, TextBox TBSur, TextBox TBTel, ComboBox cBPost, DataGrid DGWorker) { WorkerMfc worker = DGWorker.SelectedItem as WorkerMfc; if (worker == null) { return; } TBLast.Text = worker.Lastname; TBLog.Text = worker.Login; TBName.Text = worker.Firstname; TBPass.Text = worker.PassportWorker; TBSur.Text = worker.Surname; TBTel.Text = worker.Telephone; cBPost.Text = worker.PostWorker; }
public void Add(TextBox TBLast, TextBox TBLog, TextBox TBName, TextBox TBPass, TextBox TBSur, TextBox TBTel, ComboBox cBPost) { WorkerMfc worker = new WorkerMfc { Lastname = TBLast.Text, Firstname = TBName.Text, Surname = TBSur.Text, Telephone = TBTel.Text, Login = TBLog.Text, Password = Hash.HashPassword("qwe"), PostWorker = cBPost.Text, PassportWorker = TBPass.Text }; DB2.WorkerMfc.Add(worker); DB2.SaveChanges(); }
public PassChange(WorkerMfc m) { InitializeComponent(); this.m = m; }
public bool Proverka(TextBox TBlog, PasswordBox PBPass) { if (CheckEmpty(TBlog) && CheckEmpty1(PBPass)) { MessageBox.Show("Ошибка! Поля пусты!!!"); return(false); } else if (String.IsNullOrEmpty(TBlog.Text)) { MessageBox.Show("Ошибка! Поле логина пустое!!!"); return(false); } else if (String.IsNullOrEmpty(PBPass.Password)) { MessageBox.Show("Ошибка! Поле пароля пустое!!!"); return(false); } WorkerMfc m = DB1.WorkerMfc.Where(c => c.Login == TBlog.Text).SingleOrDefault(); if (m == null) { MessageBox.Show("Пользователя с таким логином не существует!"); PBPass.Clear(); return(false); } else { if (Hash.VerifyHashedPassword(m.Password, PBPass.Password)) { if (Hash.VerifyHashedPassword(Hash.HashPassword("qwe"), PBPass.Password)) { MessageBoxResult msbr = MessageBox.Show("Хотите сменить пароль?", "Вопрос", MessageBoxButton.YesNo, MessageBoxImage.Question); if (msbr == MessageBoxResult.Yes) { Windows.PassChange passChange = new Windows.PassChange(m); passChange.ShowDialog(); System.Diagnostics.Process.Start(Application.ResourceAssembly.Location); Application.Current.Shutdown(); } else { Application.Current.Shutdown(); } return(false); } else if (m.PostWorker == "Сотрудник ") { Windows.Main main = new Windows.Main(); main.Show(); return(true); } else if (m.PostWorker == "Админ") { Windows.Admin admin = new Windows.Admin(); admin.Show(); return(true); } else { return(true); } } else { MessageBox.Show("Пароль неверный!"); PBPass.Clear(); return(false); } } }