void PopulateFields(BmsBloodBank value) { try{ txtBloodBankName.Text = value.BloodBankName; txtAddress.Text = value.Address; txtCity.Text = value.City; txtContactNumber.Text = value.ContactNumber; txtUserID.Text = value.UserID; txtPassword.Password = value.SysId; } 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); } }
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); } }
private void btnControl_Click(object sender, RoutedEventArgs e) { object selected = dataGridPrimary.SelectedItem; BmsBloodBank value = dataGridPrimary.SelectedItem as BmsBloodBank; try { if (bal == null) { return; } bool state = bal.Remove(value); if (state) { applicationStatus.Text = "Blood Bank Information Deleted Successfully."; list.Remove(value); dataGridPrimary.Items.Refresh(); } else { applicationStatus.Text = "Failed Deleting Blood Bank Information."; } //clock.Start(); applicationStatus.Text = "Ready"; } 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); } //dataGridPrimary.ItemsSource = (List<BmsBloodBank>)bal.GetAll(); //MessageBox.Show(value.BloodBankName); }
void PopulateFields(BmsBloodBank value) { try { txtBloodBankID.Text = value.BloodBankID.ToString(); txtBloodBankName.Text = value.BloodBankName; txtAddress.Text = value.Address; txtCity.Text = value.City; txtContactNumber.Text = value.ContactNumber; txtUserID.Text = value.UserID; txtPassword.Password = value.SysId; } catch (Exception ex) { MessageHandler.ShowErrorMessage(ex.Message); } }
BmsBloodBank FetchData() { BmsBloodBank value = new BmsBloodBank(); try { value.BloodBankID = int.Parse(txtBloodBankID.Text); value.Address = txtAddress.Text; value.BloodBankName = txtBloodBankName.Text; value.City = txtCity.Text; value.ContactNumber = txtContactNumber.Text; value.CreationDate = DateTime.Now; value.Password = txtPassword.Password; value.SysId = txtSysIdValue.Text; value.UserID = txtUserID.Text; } catch (Exception ex) { MessageHandler.ShowErrorMessage(ex.Message); } return(value); }
BmsBloodBank FetchData() { BmsBloodBank value = new BmsBloodBank(); try { value.BloodBankID = -1; value.Address = txtAddress.Text; value.BloodBankName = txtBloodBankName.Text; value.City = txtCity.Text; value.ContactNumber = txtContactNumber.Text; value.CreationDate = DateTime.Now; value.Password = txtPassword.Password; value.SysId = txtSysIdValue.Text; value.UserID = txtUserID.Text; } 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); } return(value); }
private void btnRegister_Click(object sender, RoutedEventArgs e) { try { if (bal == null) { return; } BmsBloodBank newAdminSystem = FetchData(); BmsBloodBank currentAdminSystem = null; string ConfigSecurityMode = ConfigSecurityMode = ConfigurationManager.AppSettings.Get("security"); ConfigSecurityMode = string.IsNullOrEmpty(ConfigSecurityMode) ? "low" : ConfigSecurityMode; if (ConfigSecurityMode.Trim().ToLower() == "high") { currentAdminSystem = bal.GetAll().FirstOrDefault(item => item.SysId == HelperMethods.SystemId() && item.UserID == newAdminSystem.UserID); } else { currentAdminSystem = bal.GetAll().FirstOrDefault(item => item.UserID == newAdminSystem.UserID); } if (currentAdminSystem != null) { // this user Id already exists MessageHandler.ShowInfoMessage("User Id [ " + currentAdminSystem.UserID + " ] alrady exists." + Environment.NewLine + "Please provide different User Id"); return; } bool state = bal.Add(newAdminSystem); if (state) { MessageHandler.ShowInfoMessage("Successfully Added to the System"); } else { MessageHandler.ShowErrorMessage("Failed to Add you to the System"); } } 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); } this.DialogResult = true; }