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 PopulateFields(BmsBloodInventory value)
 {
     try
     {
         txtBloodBankID.Text      = value.BloodBankID.ToString();
         txtBloodGroup.Text       = value.BloodGroup;
         txtBloodInventoryID.Text = value.BloodInventoryID.ToString();
         txtExpiryDate.Text       = value.ExpiryDate.ToShortDateString();
         txtNumberofBottles.Text  = value.NumberofBottles.ToString();
     }
     catch (Exception ex)
     {
         MessageHandler.ShowErrorMessage(ex.Message);
     }
 }
        private void btnControl_Click(object sender, RoutedEventArgs e)
        {
            object            selected = dataGridPrimary.SelectedItem;
            BmsBloodInventory value    = dataGridPrimary.SelectedItem as BmsBloodInventory;

            try
            {
                if (bal == null)
                {
                    return;
                }
                bool state = bal.Remove(value);
                if (state)
                {
                    applicationStatus.Text = "Blood Inventory Information Deleted Successfully.";
                    list.Remove(value);
                    dataGridPrimary.Items.Refresh();
                }
                else
                {
                    applicationStatus.Text = "Failed Deleting Blood Inventory 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<BmsBloodInventory>)bal.GetAll();

            //MessageBox.Show(value.BloodBankName);
        }
        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);
            }
        }
        BmsBloodInventory FetchData()
        {
            try
            {
                BmsBloodInventory value = new BmsBloodInventory();

                value.BloodGroup       = txtBloodGroup.Text;
                value.BloodBankID      = int.Parse(txtBloodBankID.Text);
                value.BloodInventoryID = int.Parse(txtBloodInventoryID.Text);
                value.NumberofBottles  = int.Parse(txtNumberofBottles.Text);

                value.ExpiryDate   = Convert.ToDateTime(txtExpiryDate.Text);
                value.CreationDate = DateTime.Now;

                return(value);
            }
            catch (Exception ex)
            {
                MessageHandler.ShowErrorMessage(ex.Message);
            }
            return(null);
        }