private void SaveExecute(object obj) { try { string content = null; currentPassword = (obj as PasswordBox).Password; if (Model.Person.ValidPassword(currentPassword)) { newUser.password = currentPassword; tblUser u = Service.Service.AddUser(newUser); newAdministrator.userId = u.userId; tblClinicAdministrator a = Service.Service.AddAdministrator(newAdministrator); if (u != null && a != null) { content = "Administrator with username " + newUser.username + " has been registered."; Login login = new Login(); MessageBox.Show("Administrator has been registered."); master.Close(); login.Show(); } } else { content = "Administrator registration failed due to weak password"; MessageBox.Show("Pasword must contain at least 6charc including one upper, one lower, one numeric and one special char. Try again"); } LogIntoFile.getInstance().PrintActionIntoFile(content); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public MasterViewModel(Master open) { master = open; newUser = new tblUser(); newAdministrator = new tblClinicAdministrator(); currentPassword = null; }
private void LoginExecute(object obj) { try { string content = null; person.password = (obj as PasswordBox).Password; tblUser user = Service.Service.GetUser(person.username, person.password); if (user == null) { if (person.isMaster()) { content = "Master has logged in"; Master master = new Master(); login.Close(); master.Show(); } else { content = "Unsuccessful login with username " + person.username + " and password " + person.password; MessageBox.Show("Invalid username or password.Try again"); } } else { if (Service.Service.isPatient(user) != null) { content = "Patient with username " + person.username + " has logged in."; tblClinicPatient patient = Service.Service.isPatient(user); Patient p = new Patient(); p.Show(); } else if (Service.Service.isDoctor(user) != null) { content = "Doctor with username " + person.username + " has logged in."; tblClinicDoctor doctor = Service.Service.isDoctor(user); Doctor d = new Doctor(); d.Show(); } else if (Service.Service.isManager(user) != null) { content = "Manager with username " + person.username + " has logged in."; tblClinicManager manager = Service.Service.isManager(user); Manager m = new Manager(); m.Show(); } else { tblClinicAdministrator admin = Service.Service.isAdministrator(user); Administrator a = new Administrator(); content = "Administrator has logged in."; if (Service.Service.InstituteExist()) { login.Close(); a.Show(); } else { CreateClinic create = new CreateClinic(admin); login.Close(); create.Show(); } } } LogIntoFile.getInstance().PrintActionIntoFile(content); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
public CreateClinic(tblClinicAdministrator admin) { InitializeComponent(); this.DataContext = new CreateClinicViewModel(this, admin); }
public CreateClinicViewModel(CreateClinic open, tblClinicAdministrator admin) { clinic = open; newClinic = new tblInstitute(); admininstrator = admin; }