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 btnUpdate_Click(object sender, RoutedEventArgs e) { try { if (btnUpdate == null) { return; } if ((string)btnUpdate.Content.ToString() == "Edit") { EditableFields(true); btnUpdate.Content = "Update"; } else { //EditableFields(); //btnUpdate.Content = "Edit"; if (bal == null) { return; } bool state = bal.Modify(FetchData()); if (state) { applicationStatus.Text = "Blood Donor Information Updated Successfully."; applicationStatusMessage.Text = "Blood Donor Information Updated Successfully."; } else { applicationStatus.Text = "Failed updating Blood Donor Information."; applicationStatusMessage.Text = "Failed updating Blood Donor Information."; } clock.Start(); //ClearFields(); } } catch (ValidationException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (ConnectedDalException ex) { MessageHandler.ShowErrorMessage(ex.Message); } catch (Exception ex) { MessageHandler.ShowErrorMessage(ex.Message); } }