public void SaveExecute(object parametar) { int currentAccessPointAmbulance = service.GetAccesPointAmbulance(); int currentAccesspointHandicaps = service.GetAccesPointHandicaps(); if (currentAccessPointAmbulance > Institution.AccessPointsForAmbulances || currentAccesspointHandicaps > Institution.AccessPointsForhandicaps) { MessageBox.Show("The number of access points cannot be less than the current one"); } else { try { Institution.ClinicUserId = user.ClinicUserId; if (service.AddInstitution(Institution) != 0) { MessageBox.Show("You have successfully added Institution"); Logging.LoggAction("AddInstitutionViewModel", "Info", "Succesfull added new Institution"); AdministratorView adminView = new AdministratorView(user); adminView.Show(); addInstitutionView.Close(); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); Logging.LoggAction("AddInstitutionViewModel", "Error", ex.ToString()); } } }
public void BackToAdminViewExecute() { try { AdministratorView adminView = new AdministratorView(user); adminView.Show(); maintainancView.Close(); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
private void LoginExecute(object parametar) { var passwordBox = parametar as PasswordBox; var password = passwordBox.Password; try { if (MasterLogin.Login(username, password) == true) { MessageBox.Show("Successful login"); MasterAdminView window = new MasterAdminView(); window.Show(); main.Close(); } else if (MasterLogin.Login(username, password) == false) { ClinicUser user = service.LoginUser(username, password); if (user != null) { if (user.RoleId == 1) { if (service.FindeInstitutionByUser(user.ClinicUserId) == false) { MessageBox.Show("Successful login"); AddInstitutionView window = new AddInstitutionView(user, new Institution(), false); window.Show(); main.Close(); } else { MessageBox.Show("Successful login"); AdministratorView window = new AdministratorView(user); window.Show(); main.Close(); } } else if (user.RoleId == 2) { MessageBox.Show("Successful login maintainanc"); } else if (user.RoleId == 3) { MessageBox.Show("Successful login manager"); } else if (user.RoleId == 4) { MessageBox.Show("Successful login doctor"); } else if (user.RoleId == 5) { MessageBox.Show("Successful login patient"); } } else { MessageBox.Show("Wrong user or password credentials"); } } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
void Submit(object obj) { string password = (obj as PasswordBox).Password; var validate = new DataValidations.DataValidation(); var constants = new Constants(); var validateCompanyData = new CompanyValidations(); if (UserName == Constants.usernamedMaster && SecurePasswordHasher.Verify(password, constants.passwordEmployeeHashed)) { MasterView masterView = new MasterView(); loginView.Close(); masterView.Show(); return; } else if (validateCompanyData.IsCorrectUser(userName, password)) { var db = new CompanyDBRepository(); int userDataId = db.GetUserDataId(userName); if (userDataId != 0) { var typeOfUser = validateCompanyData.GetUserType(userDataId); if (typeOfUser == nameof(tblManager)) { var notImplemented = new NotImplemntedView(); notImplemented.Show(); loginView.Close(); return; } if (typeOfUser == nameof(tblAdministrator)) { var typeOfAdministrator = validateCompanyData.GetAdministratorType(userDataId); if (typeOfAdministrator == "System") { AdministratorView administrator = new AdministratorView(typeOfAdministrator); administrator.Show(); loginView.Close(); return; } else { var notImplemented = new NotImplemntedView(); notImplemented.Show(); loginView.Close(); return; } } if (typeOfUser == nameof(tblEmployee)) { var notImplemented = new NotImplemntedView(); notImplemented.Show(); loginView.Close(); return; } } } else { WarningView warning = new WarningView(loginView); warning.Show("User name or password are not correct!"); return; } }