private void btnDeleteBenefit_Click(object sender, RoutedEventArgs e)
        {
            Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
            DataRowView row = (DataRowView)((Button)e.Source).DataContext;

            //MessageBox.Show(row.Row.ItemArray[1].ToString());
            decimal totalPremiumAmt = Convert.ToDecimal(App.Current.Properties["TotalPremiumAmt"].ToString());
            decimal premiumAmt      = Convert.ToDecimal(row.Row.ItemArray[10]);

            BusinessLogicLayer.BenefitQuote bq = new BenefitQuote();
            bq.DeleteBenefitQuote(Convert.ToInt16(row.Row.ItemArray[0]));


            DataTable dt = new DataTable("BenefitQuote");

            bq.FillBenefitQuoteDataGrid(ref dt, Convert.ToInt16(App.Current.Properties["QuoteID"]));

            totalPremiumAmt = totalPremiumAmt - premiumAmt;

            App.Current.Properties["TotalPremiumAmt"] = totalPremiumAmt.ToString();
            lblTotalPremiumAmt.Content   = totalPremiumAmt.ToString("C");
            lblTotalRemainingAmt.Content = (Convert.ToDecimal(txtBudgetAmt.Value) - totalPremiumAmt - 750.0m).ToString("C");

            dgBenefits.ItemsSource = dt.DefaultView;

            Mouse.OverrideCursor = System.Windows.Input.Cursors.Arrow;
        }
        private void AddBenefitQuote(int benefitQuoteID, Boolean persist, Boolean editExisting)
        {
            DateTime tmpDate;

            if (!DateTime.TryParse(txtFirstPayment.Text, out tmpDate))
            {
                MessageBox.Show("Please add a valid date for the First Payment.", "Incomplete fields", MessageBoxButton.OK, MessageBoxImage.Information);
            }
            else
            {
                DateTime tmpEndDate;

                if (txtEnds.Text.ToString().Length == 0)
                {
                    tmpEndDate = Convert.ToDateTime("1/1/0001");
                }
                else
                {
                    tmpEndDate = Convert.ToDateTime(txtEnds.Text);
                }

                int     tmpYears;
                int     tmpMonths;
                decimal tmpIncrPct;
                char    tmpMode;

                switch (cmbType.Text)
                {
                case "Life":
                    if (txtYears.Text.Length == 0)
                    {
                        tmpYears = 0;
                    }
                    else
                    {
                        tmpYears = Convert.ToInt16(txtYears.Text);
                    }
                    if (txtMonths.Text.Length == 0)
                    {
                        tmpMonths = 0;
                    }
                    else
                    {
                        tmpMonths = Convert.ToInt16(txtMonths.Text);
                    }
                    if (txtIncrPct.Text.Length == 0)
                    {
                        tmpIncrPct = 0.0m;
                    }
                    else
                    {
                        tmpIncrPct = Convert.ToDecimal(txtIncrPct.Text);
                    }
                    tmpMode = Convert.ToChar(((ComboBoxItem)cmbMode.SelectedValue).Content.ToString().Substring(0, 1));
                    break;

                case "Period Certain":
                case "Temporary Life":
                    if (txtYears.Text.Length == 0)
                    {
                        tmpYears = 0;
                    }
                    else
                    {
                        tmpYears = Convert.ToInt16(txtYears.Text);
                    }
                    if (txtMonths.Text.Length == 0)
                    {
                        tmpMonths = 0;
                    }
                    else
                    {
                        tmpMonths = Convert.ToInt16(txtMonths.Text);
                    }
                    if (txtIncrPct.Text.Length == 0)
                    {
                        tmpIncrPct = 0.0m;
                    }
                    else
                    {
                        tmpIncrPct = Convert.ToDecimal(txtIncrPct.Text);
                    }
                    tmpMode = Convert.ToChar(((ComboBoxItem)cmbMode.SelectedValue).Content.ToString().Substring(0, 1));
                    break;

                case "Lump Sum":
                    tmpYears   = 0;
                    tmpMonths  = 0;
                    tmpIncrPct = 0.0m;
                    tmpMode    = 'x';
                    break;

                default:
                    tmpYears   = 0;
                    tmpMonths  = 0;
                    tmpIncrPct = 0.0m;
                    tmpMode    = 'x';
                    break;
                }

                //Tmp fix
                //tmpIncrPct = 0.0m;

                BusinessLogicLayer.BenefitQuote bq = new BenefitQuote();

                bq.SaveBenefitQuote(benefitQuoteID, Convert.ToInt16(App.Current.Properties["QuoteID"]), Convert.ToInt16(cmbType.SelectedValue)
                                    , Convert.ToInt16(cmbAnnuitant.SelectedValue), Convert.ToInt16(cmbAnnuitant.SelectedValue), tmpMode
//                    , Convert.ToDecimal((txtBenefitAmt.Text == "" ? "0" : txtBenefitAmt.Text))
                                    , Convert.ToDecimal(txtBenefitAmt.Value)
//                    , Convert.ToDecimal((txtPremiumAmt.Text == "" ? "0" : txtPremiumAmt.Text))
                                    , Convert.ToDecimal(txtPremiumAmt.Value)
                                    , Convert.ToDateTime(txtFirstPayment.Text), tmpYears, tmpMonths, tmpIncrPct, tmpEndDate, persist);

                DataTable dt = new DataTable("BenefitQuote");
                bq.FillBenefitQuoteDataGrid(ref dt, Convert.ToInt16(App.Current.Properties["QuoteID"]));

                if (persist)
                {
                    decimal _totalPremiumAmt = Convert.ToDecimal(App.Current.Properties["TotalPremiumAmt"].ToString());
                    if (!editExisting)
                    {
                        _totalPremiumAmt = bq.PremiumAmt + _totalPremiumAmt;
                    }
                    else
                    {
                        _totalPremiumAmt = bq.PremiumAmt + _totalPremiumAmt - Convert.ToDecimal(App.Current.Properties["OrigPremiumAmt"].ToString());
                    }
                    App.Current.Properties["TotalPremiumAmt"] = _totalPremiumAmt.ToString();
                    lblTotalPremiumAmt.Content   = _totalPremiumAmt.ToString("C");
                    lblTotalRemainingAmt.Content = (Convert.ToDecimal(txtBudgetAmt.Value) - _totalPremiumAmt - 750.0m).ToString("C");
                }
                App.Current.Properties["PaymentValueAmt"] = bq.PaymentValueAmt.ToString();
                App.Current.Properties["BenefitAmt"]      = bq.BenefitAmt.ToString();
                App.Current.Properties["PremiumAmt"]      = bq.PremiumAmt.ToString();

                ClearBenefitQuoteInputFields();
                dgBenefits.ItemsSource = dt.DefaultView;
            }
        }