private void SubmitCommandExecute(object obj) { try { string password = (obj as PasswordBox).Password; if (UserName.Equals("Zaposleni") && password.Equals("Zaposleni")) { ViewEmployeeView employeeView = new ViewEmployeeView(); view.Close(); employeeView.Show(); return; } else if (EntryValidation.ValidateJmbg(UserName) && password.Equals("Gost")) { ViewGuestView guestView = new ViewGuestView(); view.Close(); guestView.Show(); return; } else { MessageBox.Show("Wrong usename or password"); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void SaveExecute() { try { if (EntryValidation.ValidateName(Worker.FirstName) == false) { MessageBox.Show("First Name can only contain letters. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateName(Worker.LastName) == false) { MessageBox.Show("Last Name can only contain letters. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateDate(Worker.DateOfBirth) == false) { MessageBox.Show("Person Must be at least 16 years of age. Please try again", "Invalid input"); return; } if (EntryValidation.ValidatePersonalIDNumber(Worker.PersonalIDNumber) == false) { MessageBox.Show("Personal ID nubmer you entered is not valid. Please try again", "Invalid input"); return; } if (EntryValidation.ValidateJmbg(Worker.JMBG) == false) { MessageBox.Show("JMBG you entered is not valid. Please try again", "Invalid input"); return; } if (EntryValidation.ValidatePhone(Worker.PhoneNumber) == false) { MessageBox.Show("Phone number you entered is not in correct format. Please try again", "Invalid input"); return; } Worker.GenderID = Gender.GenderID; Worker.SectorID = Sector.SectorID; if (Manager != null) { Worker.ManagerID = Manager.WorkerID; } Worker.LocationID = Location.LocationID; _dbService.AddWorker(Worker); IsUpdateWorker = true; string logMessage = string.Format("Worker {0} {1} - JMBG:{2}, was added to database.", _worker.FirstName, _worker.LastName, _worker.JMBG); actionEventObject.OnActionPerformed(logMessage); MessageBox.Show("New Worker Added Successfully!", "Info"); _addWorker.Close(); } 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()); } }
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()); } }