protected void btnUpdate_Click(object sender, EventArgs e)
    {
        Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();

        _Bill_Sys_invoice.Updatestorageinvoicepaymnettransaction(txtChequeAmount.Text, txtpaymentdate.Text, txtChequeNumber.Text, txtDescription.Text, txtstoragepaymnetid.Text);

        string szStorageinvoiceid = "";
        string ids = txtTranstorageId.Text;

        string[] arrrStorageInvoiceId = ids.Split(',');
        for (int i = 0; i < arrrStorageInvoiceId.Length; i++)
        {
            if (szStorageinvoiceid == "")
            {
                szStorageinvoiceid = "'" + arrrStorageInvoiceId[i].ToString() + "'";
            }
            else
            {
                szStorageinvoiceid = szStorageinvoiceid + "," + "'" + arrrStorageInvoiceId[i].ToString() + "'";
            }
        }
        DataSet dspaymentamount = new DataSet();

        dspaymentamount = _Bill_Sys_invoice.GetStorageInvoicepaymnetDetails(szStorageinvoiceid);
        grdPaymentTransaction.DataSource = dspaymentamount;
        grdPaymentTransaction.DataBind();
        txtChequeNumber.Text = "";
        txtpaymentdate.Text  = "";
        txtChequeAmount.Text = "";
        txtDescription.Text  = "";
        ModalPopupExtender1.Show();
    }
    protected void btninvoice_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            double           blTotalInvoiceAmount = 0;
            string           szstorageinvoiceid   = "";;
            Bill_Sys_invoice _Bill_Sys_invoice    = new Bill_Sys_invoice();
            for (int i = 0; i < grdStoragegenerate.Rows.Count; i++)
            {
                CheckBox chk = (CheckBox)grdStoragegenerate.Rows[i].FindControl("ChkDelete");
                if (chk.Checked == true)
                {
                    if (szstorageinvoiceid == "")
                    {
                        szstorageinvoiceid = grdStoragegenerate.DataKeys[i]["storage_invoice_id"].ToString();
                    }
                    else
                    {
                        szstorageinvoiceid = szstorageinvoiceid + "," + grdStoragegenerate.DataKeys[i]["storage_invoice_id"].ToString();
                    }
                    blTotalInvoiceAmount = blTotalInvoiceAmount + (Convert.ToDouble(grdStoragegenerate.DataKeys[i]["MN_STORAGE_INVOICE_AMOUNT"].ToString()));
                }
            }

            if (ddlsoftwarefee.SelectedItem.Text == "Paid")
            {
                DataSet dspaymentamount = new DataSet();
                dspaymentamount = _Bill_Sys_invoice.GetStorageInvoicepaymnetDetails(szstorageinvoiceid);
                grdPaymentTransaction.DataSource = dspaymentamount;
                grdPaymentTransaction.DataBind();
                btnSave.Enabled      = true;
                btnUpdate.Enabled    = false;
                txtChequeNumber.Text = "";
                txtpaymentdate.Text  = "";
                txtChequeAmount.Text = "";
                txtDescription.Text  = "";
            }
            else
            {
                txtChequeNumber.Text             = "";
                txtpaymentdate.Text              = "";
                txtChequeAmount.Text             = "";
                txtDescription.Text              = "";
                grdPaymentTransaction.DataSource = null;
                grdPaymentTransaction.DataBind();
                btnUpdate.Enabled = false;
                btnSave.Enabled   = true;
            }
            txtTranstorageId.Text = szstorageinvoiceid;
            lblBalance.Text       = blTotalInvoiceAmount.ToString("0.00");
            //sztotalamount.Text = lblBalance.Text;

            ModalPopupExtender1.Show();
            grdStoragegenerate.XGridBindSearch();
            //usrMessage.PutMessage("Payment Status Update successfully");
            //usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
            //usrMessage.Show();
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            string           sztotalpaymnetamount;
            string           szStorageinvoiceid = "";
            Bill_Sys_invoice _Bill_Sys_invoice  = new Bill_Sys_invoice();
            string           ids = txtTranstorageId.Text;
            string[]         arrrStorageInvoiceId = ids.Split(',');
            ArrayList        arrIds = new ArrayList();
            for (int i = 0; i < arrrStorageInvoiceId.Length; i++)
            {
                arrIds.Add(arrrStorageInvoiceId[i].ToString());
                if (szStorageinvoiceid == "")
                {
                    szStorageinvoiceid = "'" + arrrStorageInvoiceId[i].ToString() + "'";
                }
                else
                {
                    szStorageinvoiceid = szStorageinvoiceid + "," + "'" + arrrStorageInvoiceId[i].ToString() + "'";
                }
            }

            szbalance.Text       = lblBalance.Text;
            sztotalpaymnetamount = _Bill_Sys_invoice.Savestoragepaymenttransaction(txtChequeAmount.Text, txtChequeNumber.Text, txtDescription.Text, txtpaymentdate.Text, utxtUserId.Text, arrIds, txtCompanyID.Text, lblBalance.Text);
            string[] values             = sztotalpaymnetamount.Split(',');
            string   returnvalue        = values[0];
            string   szstoragepaymentid = values[1];
            txtstoragepaymnetid.Text = szstoragepaymentid;
            DataSet dspaymentamount = new DataSet();
            dspaymentamount = _Bill_Sys_invoice.GetStorageInvoicepaymnetDetails(szStorageinvoiceid);
            grdPaymentTransaction.DataSource = dspaymentamount;
            grdPaymentTransaction.DataBind();
            usrMessage.PutMessage("Your payment saved");
            usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
            usrMessage.Show();
            txtChequeNumber.Text = "";
            txtpaymentdate.Text  = "";
            txtChequeAmount.Text = "";
            txtDescription.Text  = "";

            ModalPopupExtender1.Show();
            grdStoragegenerate.XGridBindSearch();
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }
    protected void btnPaymentDelete_Click(object sender, EventArgs e)
    {
        string id = string.Format("Id: {0} Uri: {1}", Guid.NewGuid(), HttpContext.Current.Request.Url);

        using (Utils utility = new Utils())
        {
            utility.MethodStart(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
        try
        {
            Bill_Sys_invoice _Bill_Sys_invoice = new Bill_Sys_invoice();
            for (int i = 0; i < grdPaymentTransaction.Items.Count; i++)
            {
                CheckBox chkDelete1 = (CheckBox)grdPaymentTransaction.Items[i].FindControl("chkDelete");
                if (chkDelete1.Checked)
                {
                    _Bill_Sys_invoice.deletestoragepaymentTransaction(grdPaymentTransaction.Items[i].Cells[1].Text, txtCompanyID.Text);
                }
            }
            usrMessage.PutMessage("Payment deleted successfully ...");
            usrMessage.SetMessageType(UserControl_ErrorMessageControl.DisplayType.Type_UserMessage);
            usrMessage.Show();
            string    szStorageinvoiceid = "";
            string    ids = txtTranstorageId.Text;
            string[]  arrrStorageInvoiceId = ids.Split(',');
            ArrayList arrIds = new ArrayList();
            for (int i = 0; i < arrrStorageInvoiceId.Length; i++)
            {
                if (szStorageinvoiceid == "")
                {
                    szStorageinvoiceid = "'" + arrrStorageInvoiceId[i].ToString() + "'";
                }
                else
                {
                    szStorageinvoiceid = szStorageinvoiceid + "," + "'" + arrrStorageInvoiceId[i].ToString() + "'";
                }
            }
            DataSet dspaymentamount = new DataSet();
            dspaymentamount = _Bill_Sys_invoice.GetStorageInvoicepaymnetDetails(szStorageinvoiceid);
            grdPaymentTransaction.DataSource = dspaymentamount;
            grdPaymentTransaction.DataBind();
            txtChequeNumber.Text = "";
            txtpaymentdate.Text  = "";
            txtChequeAmount.Text = "";
            txtDescription.Text  = "";
            ModalPopupExtender1.Show();
            grdStoragegenerate.XGridBindSearch();
        }
        catch (Exception ex)
        {
            Elmah.ErrorSignal.FromCurrentContext().Raise(ex);
            using (Utils utility = new Utils())
            {
                utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
            }
            string str2 = "Error Request=" + id + ".Please share with Technical support.";
            base.Response.Redirect("../Bill_Sys_ErrorPage.aspx?ErrMsg=" + str2);
        }

        //Method End
        using (Utils utility = new Utils())
        {
            utility.MethodEnd(id, System.Reflection.MethodBase.GetCurrentMethod());
        }
    }