public void SaveData()
        {
            try
            {

                if (checkvalid() == false)
                {
                    txtPaidAttendance.Focus();
                    return;
                }
                bool expflg = false;
                if (hdninitial_paidattn.Value.AutoformatInt() != txtPaidAttendance.Text.AutoformatInt() || hdninitial_dropcount.Value.AutoformatInt() != txtDropcount.Text.AutoformatInt())
                {
                    expflg = true;
                }
                if (expflg == true)
                {
                    string alertmsg = "Expense insurance actual or ticket printing actual updated due to Attendance or Drop Count change. Please check";

                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "Subscriptioncalc();JQalertbox('" + alertmsg + "');", true);
                }
                else
                {
                    ScriptManager.RegisterStartupScript(this, this.GetType(), "", "Subscriptioncalc();", true);
                }

                //if (hidfval.Value.Length > 0)
                //{
                //    lbl_msg.Text = "Negative value not allowed";
                //    lbl_msg.ForeColor = System.Drawing.Color.Red;
                //    return;
                //}

                char[] chDlr = { '$', '%', ',', ' ' };
                EngagementMaster EngmtMaster = (EngagementMaster)Page.Master;

                if (hdn_engagementid.Value != "0" && hdn_engagementid.Value != "")
                {
                    if (hdn_schedulecount.Value != "0" && hdn_schedulecount.Value != "")
                    {
                        Nullable<decimal> bo_drop_count = null, bo_gross_sales = null, bo_facility_fee = null, bo_tax1 = null, bo_tax_amount_over = null,
                            bo_tax_facility_comm = null, bo_sub_gross_rcpt = null, bo_sub_comm_ptg = null, bo_ph_gross_rcpt = null, bo_ph_comm_ptg = null, bo_web_gross_rcpt = null,
                            bo_web_comm_ptg = null, bo_cc_gross_rcpt = null, bo_cc_comm_ptg = null, bo_outlet_gross_rcpt = null, bo_outlet_comm_ptg = null, bo_single_tix_gross_rcpt = null,
                            bo_single_tix_comm_ptg = null, bo_small_group_gross_rcpt = null, bo_small_group_comm_ptg = null, bo_large_group_gross_rcpt = null,
                            bo_large_group_comm_ptg = null, bo_other_per_gross_rcpt = null, bo_other_per_comm_ptg = null, bo_other_usd_gross_rcpt = null, bo_other_usd_comm_ptg = null;
                        Nullable<decimal> bo_paid_attendance = null, bo_comps = null, bo_sub_t_sold = null, bo_ph_t_sold = null, bo_web_t_sold = null, bo_cc_t_sold = null,
                            bo_outlet_t_sold = null, bo_single_tix_t_sold = null, bo_small_group_t_sold = null, bo_large_group_t_sold = null,
                            bo_other_per_t_sold = null, bo_other_usd_t_sold = null, bo_other_3_t_sold = null, bo_other_3_gross_rcpt = null
                            , bo_other_4_t_sold = null, bo_other_4_gross_rcpt = null, bo_other_5_t_sold = null, bo_other_5_gross_rcpt = null,
                            bo_other_3_comm_ptg = null, bo_other_4_comm_ptg = null, bo_other_5_comm_ptg = null;

                        bo_gross_sales = txtgrossales.Text.AutoformatDecimal();
                        bo_facility_fee = txtFacilityfeeoneachticket.Text.AutoformatDecimal();
                        bo_tax1 = decimal.Parse(txtTax1.Text, CultureInfo.InvariantCulture);
                        bo_tax_amount_over = txtTaxAmountOver.Text.AutoformatDecimal();
                        bo_tax_facility_comm = txtTaxFacilityfeecoms.Text.AutoformatDecimal();
                        bo_sub_gross_rcpt = txtSubscriptionreceipts.Text.AutoformatDecimal();
                        bo_sub_comm_ptg = txtSubsSalesPerc.Text.AutoformatDecimal();

                        bo_ph_gross_rcpt = txtPhoneGrossReceipts.Text.AutoformatDecimal();
                        bo_ph_comm_ptg = txtPhonePerc.Text.AutoformatDecimal();

                        bo_web_gross_rcpt = txtInternetGrossRecpt.Text.AutoformatDecimal();
                        bo_web_comm_ptg = txtInternetPerc.Text.AutoformatDecimal();

                        bo_cc_gross_rcpt = txtCreditGrossReceipts.Text.AutoformatDecimal();
                        bo_cc_comm_ptg = txtCreditPerc.Text.AutoformatDecimal();

                        bo_outlet_gross_rcpt = txtRemoteGrossReceipts.Text.AutoformatDecimal();
                        bo_outlet_comm_ptg = txtRemotePerc.Text.AutoformatDecimal();

                        bo_single_tix_gross_rcpt = txtSingletixtGrossReceipts.Text.AutoformatDecimal();
                        bo_single_tix_comm_ptg = txtSingletixPerc.Text.AutoformatDecimal();

                        bo_small_group_gross_rcpt = txtGroupGrossReceipts.Text.AutoformatDecimal();
                        bo_small_group_comm_ptg = txtGroupPerc.Text.AutoformatDecimal();

                        bo_large_group_gross_rcpt = txtGroup1grossReceipts.Text.AutoformatDecimal();
                        bo_large_group_comm_ptg = txtGroup1Perc.Text.AutoformatDecimal();

                        bo_other_per_gross_rcpt = txtOtherPercGrossReceipts.Text.AutoformatDecimal();
                        bo_other_per_comm_ptg = txtOtherPercPerc.Text.AutoformatDecimal();

                        bo_other_usd_gross_rcpt = txtOtherDollGrossReceipts.Text.AutoformatDecimal();
                        bo_other_usd_comm_ptg = txtOtherDollPerc.Text.AutoformatDecimal();

                        bo_drop_count = txtDropcount.Text.AutoformatDecimal();
                        bo_paid_attendance = txtPaidAttendance.Text.AutoformatDecimal();
                        bo_comps = txtComps.Text.AutoformatDecimal();
                        bo_sub_t_sold = txtSubscriptionsold.Text.AutoformatDecimal();
                        bo_ph_t_sold = txtPhoneTcktSold.Text.AutoformatDecimal();
                        bo_web_t_sold = txtInternetTcktSold.Text.AutoformatDecimal();
                        bo_cc_t_sold = txtCreditcrdTcktSold.Text.AutoformatDecimal();
                        bo_outlet_t_sold = txtRemoteoutletTcktSold.Text.AutoformatDecimal();
                        bo_single_tix_t_sold = txtSingletixtcktSold.Text.AutoformatDecimal();
                        bo_small_group_t_sold = txtGroupTicktSold.Text.AutoformatDecimal();
                        bo_large_group_t_sold = txtGroup1TicktSold.Text.AutoformatDecimal();
                        bo_other_per_t_sold = txtOtherPercTcktSold.Text.AutoformatDecimal();
                        bo_other_usd_t_sold = txtOtherDollTcktSold.Text.AutoformatDecimal();

                        bo_other_3_t_sold = txtOther3TcktSold.Text.AutoformatDecimal();
                        bo_other_3_gross_rcpt = txtOther3GrossReceipts.Text.AutoformatDecimal();
                        bo_other_3_comm_ptg = txtOther3Perc.Text.AutoformatDecimal();
                        bo_other_4_t_sold = txtOther4TcktSold.Text.AutoformatDecimal();
                        bo_other_4_gross_rcpt = txtOther4GrossReceipts.Text.AutoformatDecimal();
                        bo_other_4_comm_ptg = txtOther4Perc.Text.AutoformatDecimal();
                        bo_other_5_t_sold = txtOther5TcktSold.Text.AutoformatDecimal();
                        bo_other_5_gross_rcpt = txtOther5GrossReceipts.Text.AutoformatDecimal();
                        bo_other_5_comm_ptg = txtOther5Perc.Text.AutoformatDecimal();

                        ofcobj = new BoxOfficeData();
                        int output;
                        if (ddlPerformance.Visible == true)
                        {
                            output = ofcobj.BoxOffice_Insert(out boid,Convert.ToInt32(hdn_engagementid.Value),
                            Convert.ToInt32(ddlPerformance.SelectedItem.Value),
                            bo_gross_sales, bo_drop_count, bo_paid_attendance, bo_comps, bo_sub_t_sold,
                            bo_sub_gross_rcpt, bo_ph_t_sold, bo_ph_gross_rcpt, bo_web_t_sold, bo_web_gross_rcpt,
                             bo_cc_t_sold, bo_cc_gross_rcpt, bo_outlet_t_sold, bo_outlet_gross_rcpt,
                             bo_single_tix_t_sold, bo_single_tix_gross_rcpt, bo_small_group_t_sold,
                             bo_small_group_gross_rcpt, bo_large_group_t_sold, bo_large_group_gross_rcpt,
                             bo_other_per_t_sold, bo_other_per_gross_rcpt, bo_other_usd_t_sold,
                            bo_other_usd_gross_rcpt,bo_other_3_t_sold, bo_other_3_gross_rcpt,
                            bo_other_4_t_sold, bo_other_4_gross_rcpt,
                            bo_other_5_t_sold, bo_other_5_gross_rcpt
                            );
                            if (output == 1001)
                            {
                                lbl_msg.Text = "Engagement Box Office created successfully";
                                lbl_msg.ForeColor = System.Drawing.Color.Green;
                            }
                            else if (output == 1002)
                            {
                                lbl_msg.Text = "Engagement Box Office updated successfully";
                                lbl_msg.ForeColor = System.Drawing.Color.Green;
                            }
                        }
                        else
                        {
                            foreach (ListItem list in chklstPerformance.Items)
                            {
                                if (list.Selected == true && list.Value != "0")
                                {
                                    output = ofcobj.BoxOffice_Insert(out boid,Convert.ToInt32(hdn_engagementid.Value),
                                        Convert.ToInt32(list.Value),
                                        bo_gross_sales, bo_drop_count, bo_paid_attendance, bo_comps, bo_sub_t_sold,
                                        bo_sub_gross_rcpt, bo_ph_t_sold, bo_ph_gross_rcpt, bo_web_t_sold, bo_web_gross_rcpt,
                                         bo_cc_t_sold, bo_cc_gross_rcpt, bo_outlet_t_sold, bo_outlet_gross_rcpt,
                                         bo_single_tix_t_sold, bo_single_tix_gross_rcpt, bo_small_group_t_sold,
                                         bo_small_group_gross_rcpt, bo_large_group_t_sold, bo_large_group_gross_rcpt,
                                         bo_other_per_t_sold, bo_other_per_gross_rcpt, bo_other_usd_t_sold,
                                        bo_other_usd_gross_rcpt);
                                    if (output == 1001)
                                    {
                                        lbl_msg.Text = "Engagement Box Office created successfully";
                                        lbl_msg.ForeColor = System.Drawing.Color.Green;
                                    }
                                    else if (output == 1002)
                                    {
                                        lbl_msg.Text = "Engagement Box Office updated successfully";
                                        lbl_msg.ForeColor = System.Drawing.Color.Green;
                                    }
                                }
                            }
                        }

                        if (chkboxOverride.Checked)
                        {
                            SaveOverride(boid);
                        }

                        ddlPerformancesload(Convert.ToInt32(hdn_engagementid.Value));
                        //ddlPerformancesload(Convert.ToInt32(hdn_engagementid.Value));
                        ScriptManager.RegisterStartupScript(this, this.GetType(), "", "Subscriptioncalc();", true);

                    }
                    else
                    {
                        lbl_msg.Text = "Please create Engagement Schedule first";
                        lbl_msg.ForeColor = System.Drawing.Color.Red;
                    }
                }
            }
            catch (Exception ex)
            {

                throw ex;
            }
            finally
            {
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "Subscriptioncalc();", true);
                ScriptManager.RegisterStartupScript(this, this.GetType(), "", "JQalertbox('actual!');", true);
            }
        }