Beispiel #1
0
 public void SaveExecute()
 {
     if (String.IsNullOrEmpty(ClinicPatient.NameAndSurname) || String.IsNullOrEmpty(ClinicPatient.IdentityCardNumber) || String.IsNullOrEmpty(ClinicPatient.DateOfBirth.ToString()) || String.IsNullOrEmpty(ClinicPatient.Gender) ||
         String.IsNullOrEmpty(ClinicPatient.Citizenship) || String.IsNullOrEmpty(ClinicPatient.Username) || String.IsNullOrEmpty(ClinicPatient.Password) || String.IsNullOrEmpty(ClinicPatient.HealthInsuranceCardNumber) ||
         String.IsNullOrEmpty(ClinicPatient.ExpirationDateOfHealthInsurance.ToString()) || String.IsNullOrEmpty(ClinicPatient.UniqueNumberOfSelectedDoctor) || ClinicPatient.ExpirationDateOfHealthInsurance != default(DateTime).Date)
     {
         MessageBox.Show("Please fill all fields.", "Notification");
     }
     else
     {
         try
         {
             MessageBoxResult result = MessageBox.Show("Are you sure you want to save the patient?", "Confirmation", MessageBoxButton.YesNo, MessageBoxImage.Question);
             if (result == MessageBoxResult.Yes)
             {
                 bool isCreated = patients.CreatePatient(ClinicPatient);
                 if (isCreated)
                 {
                     MessageBox.Show("Patient is created.", "Notification", MessageBoxButton.OK);
                     patientView.Close();
                 }
                 else
                 {
                     MessageBox.Show("Patient cannot be created.", "Notification", MessageBoxButton.OK);
                 }
             }
         }
         catch (Exception ex)
         {
             MessageBox.Show(ex.ToString());
         }
     }
 }
        private void SaveExecute(object parametar)
        {
            var passwordBox = parametar as PasswordBox;
            var password    = passwordBox.Password;

            Patient.PatientPassword = password;
            try
            {
                if (service.AddPatient(Patient) != null)
                {
                    isUpdatePatient = true;

                    PatientWindow window = new PatientWindow(Patient);
                    window.Show();
                    addPatientWindow.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   = 5;
            try
            {
                bool uniqueInsuranceNumber = service.CheckInsuranceNumber(UserPatient.InsuranceNumber);
                int  drUniqueNumber        = service.GetDoctorUniqueNumberByDoctorId(selectDoctor.ClinicUserId);
                if (uniqueInsuranceNumber)
                {
                    int userId = service.AddClinicUser(User);
                    if (userId != 0)
                    {
                        UserPatient.ClinicUserId       = userId;
                        UserPatient.UniqueDoctorNumber = drUniqueNumber;

                        if (service.AddNewPatient(UserPatient) != 0)
                        {
                            MessageBox.Show("You have successfully added new patient");
                            Logging.LoggAction("AddPatientViewModel", "Info", "Succesfull added new doctor");

                            PatientView patientView = new PatientView(UserAdmin);
                            patientView.Show();
                            addPatientView.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
                Logging.LoggAction("AddDoctorViewModel", "Error", ex.ToString());
            }
        }
 private void AddPatientCommandExecute(object obj)
 {
     try
     {
         if (EntryValidation.ValidateName(Patient.FirstName) == false)
         {
             MessageBox.Show("First Name can only contain letters. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateName(Patient.LastName) == false)
         {
             MessageBox.Show("Last Name can only contain letters. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateJmbg(Patient.JMBG) == false)
         {
             MessageBox.Show("JMBG you entered is not valid. Please try again", "Invalid input");
             return;
         }
         if (EntryValidation.ValidateMedicalInsuranceNumber(Patient.MedicalInsuranceNumber) == false)
         {
             MessageBox.Show("Medical insurance number entered is not valid, must contain exactly 11 numbers. Please try again", "Invalid input");
             return;
         }
         string password        = (obj as PasswordBox).Password;
         string encryptPassword = EncryptionHelper.Encrypt(password);
         patient.Password = encryptPassword;
         dataBaseService.AddPatient(patient);
         MessageBox.Show("New patient registered successfully!", "Info");
         addPatient.Close();
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }