private void BackAdmin_Click(object sender, EventArgs e) { Hide(); AdminViewForm adminViewForm = new AdminViewForm(); adminViewForm.ShowDialog(); }
private void EditLawyerBtn_Click(object sender, EventArgs e) { int id = int.Parse(LawyerIdHidden.Text); var lawyer = _repository.Of <Lawyer>() .Search(x => x.Id == id) .FirstOrDefault(); if (lawyer != null) { lawyer.FirstName = FirstNameEditText.Text; lawyer.LastName = LastNameEditText.Text; lawyer.Email = LawyerEmailTxt.Text; lawyer.Password = LawyerPasswordTxt.Text.Sha256(); lawyer.DateOfBirth = DateOfBirthEditPicker.Value; _repository.SaveChanges(); MessageBox.Show("The lawyer was successfully edited.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Hide(); AdminViewForm adminViewForm = new AdminViewForm(); adminViewForm.ShowDialog(); } else { MessageBox.Show("Could not edit this lawyer.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
private void LawyerEditorBtn_Click(object sender, EventArgs e) { Hide(); AdminViewForm adminViewForm = new AdminViewForm(); adminViewForm.ShowDialog(); }
private void LogInButton_Click(object sender, EventArgs e) { var adminUserName = ConfigurationManager.AppSettings["admin:userName"]; var adminUserPassword = ConfigurationManager.AppSettings["admin:password"]; string username = UsrNameTxt.Text; string password = UsrPasswordTxt.Text; if (username == adminUserName && password.Sha256() == adminUserPassword) { AdminViewForm adminViewForm = new AdminViewForm(); adminViewForm.ShowDialog(); } else { password = password.Sha256(); var lawyer = _repository.Of <Lawyer>() .Search(x => x.Email == username && x.Password == password) .SingleOrDefault(); if (lawyer != null) { LawyerForm lawyerForm = new LawyerForm(lawyer); lawyerForm.ShowDialog(); } else { MessageBox.Show("Invalid user. Please, try again.", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void AddLawyerBtn_Click(object sender, EventArgs e) { var FirstName = FirstNameText.Text; var LastName = LastNameText.Text; var Email = LawyerEmailTxt.Text; var Password = LawyerPasswordTxt.Text; var DateOfBirth = DateOfBirthPicker.Value; if (String.IsNullOrWhiteSpace(FirstName)) { MessageBox.Show("First name required!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (String.IsNullOrWhiteSpace(LastName)) { MessageBox.Show("Last name required!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (String.IsNullOrWhiteSpace(Email)) { MessageBox.Show("Email required!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } if (String.IsNullOrWhiteSpace(Password)) { MessageBox.Show("Password required!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } var lawyer = new Lawyer { FirstName = FirstName, LastName = LastName, Email = Email, Password = Password.Sha256(), DateOfBirth = DateOfBirth }; _repository.Of <Lawyer>().Insert(lawyer); _repository.SaveChanges(); MessageBox.Show("Lawyer successfull add!", "OK!", MessageBoxButtons.OK, MessageBoxIcon.Information); Hide(); AdminViewForm adminView = new AdminViewForm(); adminView.ShowDialog(); }
private void LawyerDelete_Click(object sender, EventArgs e) { int id = int.Parse(LawyerIdHidden.Text); var lawyer = _repository.Of <Lawyer>().GetById(id); var @case = _repository.Of <Case>() .Search(x => x.Lawyers.Any(y => y.Id == id)) .Count(); if (@case > 0) { MessageBox.Show("Lawyer busy!", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } _repository.Of <Lawyer>().Delete(lawyer); _repository.SaveChanges(); MessageBox.Show("The lawyer was successfully deleted.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information); Hide(); AdminViewForm adminViewForm = new AdminViewForm(); adminViewForm.ShowDialog(); }