public void SaveExecute() { if (String.IsNullOrEmpty(ClinicDoctor.NameAndSurname) || String.IsNullOrEmpty(ClinicDoctor.IdentityCardNumber) || String.IsNullOrEmpty(ClinicDoctor.DateOfBirth.ToString()) || String.IsNullOrEmpty(ClinicDoctor.Gender) || String.IsNullOrEmpty(ClinicDoctor.Citizenship) || String.IsNullOrEmpty(ClinicDoctor.Username) || String.IsNullOrEmpty(ClinicDoctor.Password) || String.IsNullOrEmpty(ClinicDoctor.UniqueNumber) || String.IsNullOrEmpty(ClinicDoctor.BankAccountNumber) || String.IsNullOrEmpty(ClinicDoctor.Department) || String.IsNullOrEmpty(ClinicDoctor.Shift)) { MessageBox.Show("Please fill all fields.", "Notification"); } else { try { MessageBoxResult result = MessageBox.Show("Are you sure you want to save the doctor?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { if (Manager != null) { ClinicDoctor.SuperiorManager = Convert.ToInt32(Manager.ManagerId); } bool isCreated = doctors.CreateDoctor(ClinicDoctor); if (isCreated) { MessageBox.Show("Doctor is created.", "Notification", MessageBoxButton.OK); doctorView.Close(); } else { MessageBox.Show("Doctor cannot be created.", "Notification", MessageBoxButton.OK); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } } }
private void AddDoctorCommandExecute(object obj) { try { if (EntryValidation.ValidateName(Doctor.FirstName) == false) { MessageBox.Show("First Name can only contain letters. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateName(Doctor.LastName) == false) { MessageBox.Show("Last Name can only contain letters. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateJmbg(Doctor.JMBG) == false) { MessageBox.Show("JMBG you entered is not valid. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateBankAccountNumber(Doctor.BankAccountNumber) == false) { MessageBox.Show("Bank account nubmer you entered is not valid, must contain exactly 18 numbers. Please try again", "Invalid input"); return; } string password = (obj as PasswordBox).Password; string encryptPassword = EncryptionHelper.Encrypt(password); doctor.Password = encryptPassword; dataBaseService.AddDoctor(doctor); MessageBox.Show("New doctor registered successfully!", "Info"); addDoctor.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public void SaveExecute(object parametar) { var passwordBox = parametar as PasswordBox; var password = passwordBox.Password; User.Password = password; User.GenderId = selectedGender.GenderId; User.RoleId = 4; try { if (User.ClinicUserId == 0) { bool uniqueNumber = service.CheckUniqueNumber(UserDoctor.UniqueNumber); bool uniqueBancAccount = service.CheckBancAccount(UserDoctor.BancAccount); if (uniqueNumber && uniqueBancAccount) { int userId = service.AddClinicUser(User); if (userId != 0) { UserDoctor.ClinicUserId = userId; UserDoctor.DepartmentId = selectedDepartment.DepartmentId; UserDoctor.WorkShiftId = selectedWorkShift.WorkShiftId; UserDoctor.ClinicManagerId = selectedManager.ClinicManagerId; if (service.AddNewDoctor(UserDoctor) != 0) { MessageBox.Show("You have successfully added new doctor"); Logging.LoggAction("AddDoctorViewModel", "Info", "Succesfull added new doctor"); DoctorView doctorView = new DoctorView(UserAdmin); doctorView.Show(); addDoctorView.Close(); } } } } else { int userId = service.AddClinicUser(User); if (userId != 0) { UserDoctor.ClinicUserId = userId; UserDoctor.DepartmentId = selectedDepartment.DepartmentId; UserDoctor.WorkShiftId = selectedWorkShift.WorkShiftId; UserDoctor.ClinicManagerId = selectedManager.ClinicManagerId; if (service.AddNewDoctor(UserDoctor) != 0) { MessageBox.Show("You have successfully added new doctor"); Logging.LoggAction("AddDoctorViewModel", "Info", "Succesfull added new doctor"); DoctorView doctorView = new DoctorView(UserAdmin); doctorView.Show(); addDoctorView.Close(); } } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Logging.LoggAction("AddDoctorViewModel", "Error", ex.ToString()); } }