private void LawyerSaveData_Click(object sender, EventArgs e)
        {
            int Id = int.Parse(LawyerId.Text);

            var lawyer = _repository.Of <Lawyer>()
                         .Search(x => x.Id == Id)
                         .FirstOrDefault();

            if (lawyer != null)
            {
                lawyer.FirstName = FirstNameEditTxt.Text;
                lawyer.LastName  = LastNameEditTxt.Text;

                _repository.SaveChanges();

                MessageBox.Show("The lawyer was successfully edited.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                Hide();
                LawyerForm lawyerForm = new LawyerForm(lawyer);
                lawyerForm.ShowDialog();
            }
            else
            {
                MessageBox.Show("Could not edit this lawyer.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
示例#2
0
        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 BackAdmin_Click(object sender, EventArgs e)
        {
            int Id = int.Parse(LawyerId.Text);

            var lawyer = _repository.Of <Lawyer>().GetById(Id);

            Hide();
            LawyerForm lawyerForm = new LawyerForm(lawyer);

            lawyerForm.ShowDialog();
        }