void btnAdd_Click(object sender, RoutedEventArgs e) { try { if (balTransaction == null) { return; } BmsTransaction transaction = FetchData(); bool state = balTransaction.Add(transaction); if (state) { // Change Inventory value BmsBloodInventory oldValue = balInventory.GetAll(). FirstOrDefault(c => c.BloodInventoryID == transaction.BloodInventoryID); // Make transaction oldValue.NumberofBottles += transaction.NumberofBottles; BmsBloodInventory newValue = oldValue; state = balInventory.Modify(oldValue); } if (state) { applicationStatus.Text = "Blood Transaction Information Added Successfully."; applicationStatusMessage.Text = "Blood Transaction Information Added Successfully."; } else { applicationStatus.Text = "Failed Adding Blood Transaction Information."; applicationStatusMessage.Text = "Blood Transaction Information Added Successfully."; } clock.Start(); EditableFields(false); btnAdd.Visibility = System.Windows.Visibility.Hidden; btnReset.Visibility = System.Windows.Visibility.Hidden; //ClearFields(); txtTransactionID.Text = "-1"; } catch (ValidationException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (ConnectedDalException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (Exception ex) { MessageHandler.ShowErrorMessage(ex.Message); } }
void btnAdd_Click(object sender, RoutedEventArgs e) { try { if (bal == null) { return; } BmsBloodInventory value = FetchData(); value.CreationDate = DateTime.Now; bool state = bal.Add(value); if (state) { applicationStatus.Text = "Inventory Information Added Successfully."; applicationStatusMessage.Text = "Inventory Information Added Successfully."; } else { applicationStatus.Text = "Failed Adding Inventory Information."; applicationStatusMessage.Text = "Inventory Information Added Successfully."; } clock.Start(); ClearFields(); txtBloodInventoryID.Text = "-1"; } catch (ValidationException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (ConnectedDalException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (Exception ex) { MessageHandler.ShowErrorMessage(ex.Message); } }
void btnAdd_Click(object sender, RoutedEventArgs e) { try { if (bal == null) { return; } bool state = bal.Add(FetchData()); if (state) { applicationStatus.Text = "Blood Donor Information Added Successfully."; applicationStatusMessage.Text = "Blood Donor Information Added Successfully."; } else { applicationStatus.Text = "Failed Adding Blood Donor Information."; applicationStatusMessage.Text = "Blood Donor Information Added Successfully."; } clock.Start(); ClearFields(); txtBloodDonorID.Text = "-1"; } catch (ValidationException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (ConnectedDalException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (Exception ex) { MessageHandler.ShowErrorMessage(ex.Message); } }
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; }