public CreateManagerViewModel(CreateManager open, tblClinicManager man, tblUser user) { register = open; newUser = user; newManager = man; isEditingWindow = true; }
private void EditManagerExecute() { try { int managerId = manager.managerId; int userId = manager.userId; tblUser user = Service.Service.UserById(userId); tblClinicManager man = Service.Service.ManagerById(managerId); CreateManager create = new CreateManager(man, user); create.ShowDialog(); if ((create.DataContext as CreateManagerViewModel).isUpdated == true) { managerList = Service.Service.GetManagersList(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void SaveExecute(object obj) { try { string message = null; currentPassword = (obj as PasswordBox).Password; if (Model.Person.ValidPassword(currentPassword)) { newUser.password = currentPassword; tblUser u = Service.Service.AddUser(newUser); newManager.userId = u.userId; tblClinicManager m = Service.Service.AddManager(newManager); if (u != null && m != null) { if (isEditingWindow) { message = "Manager with id:" + m.managerId + " has been upated"; } else { message = "Manager with id:" + m.managerId + " has been registered."; } MessageBox.Show(message); isUpdated = true; register.Close(); } } else { message = "Manager 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(message); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
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 CreateManager(tblClinicManager man, tblUser user) { InitializeComponent(); this.DataContext = new CreateManagerViewModel(this, man, user); }
public CreateManagerViewModel(CreateManager open) { register = open; newUser = new tblUser(); newManager = new tblClinicManager(); }