void clock_Tick(object sender, EventArgs e) { try { int tick = (int)psbProgramStartup.Value; tick += random.Next(20); psbProgramStartup.Value = tick; if (tick >= 95 && CheckBal()) { BmsBloodBank currentAdminSystem = balBank.GetAll().FirstOrDefault(item => item.SysId.Trim() == HelperMethods.SystemId()); if (currentAdminSystem == null) { // Show Admin Registration Forms WindowRegisterAdmin regWindow = new WindowRegisterAdmin(); regWindow.Attach(balBank); IsSuccessAdminRegisterLogin = regWindow.ShowDialog(); if (IsSuccessAdminRegisterLogin == false) { AccessDeny(); } currentAdminSystem = balBank.GetAll().FirstOrDefault(item => item.SysId == HelperMethods.SystemId()); } MainWindow mainWindow = new MainWindow(); MainWindow.CurrentAdminSystem = currentAdminSystem; mainWindow.InitBal(balBank, balCamp, balDonor, balDonation, balInventory, balHospital, balTransaction); mainWindow.Show(); clock.Stop(); this.Close(); } } catch (System.Data.SqlClient.SqlException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (ValidationException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (ConnectedDalException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (Exception ex) { MessageHandler.ShowErrorMessage(ex.Message); } }
bool ValidUser() { bool valid = false; var list = balBank.GetAll(); foreach (var item in list) { if (txtUserName.Text == item.UserID && txtPassword.Password == item.Password) { valid = true; MainWindow.CurrentAdminSystem = item; break; } } return(valid); }