//protected void btnSave_Click(object sender, EventArgs e)
    //{
    //    try
    //    {
    //        for (int i = 0; i < _arraylist.Count; i++)
    //        {
    //            int getdiff = GetDifference(_arraylist[i].ToString());
    //            if (getdiff > 0 && getdiff != 1 )
    //            {
    //                ArrayList arrParam = new ArrayList();
    //                arrParam.Add(_arraylist[i].ToString());
    //                arrParam.Add(txtChequeNumber.Text.ToString());
    //                arrParam.Add(txtChequeDate.Text.ToString());
    //                if (getdiff < Convert.ToInt32(txtChequeAmount.Text.ToString()))
    //                {
    //                    arrParam.Add(getdiff);
    //                }
    //                else
    //                {
    //                    arrParam.Add(Convert.ToInt32(txtChequeAmount.Text));
    //                }

    //                arrParam.Add(txtPaymentType.Text.ToString());
    //                arrParam.Add(txtCompanyID.Text.ToString());
    //                _bill_Sys_BillingCompanyDetails_BO.SaveData(arrParam);
    //                txtChequeAmount.Text =Convert.ToString(Convert.ToInt32(txtChequeAmount.Text.ToString()) - getdiff);
    //            }
    //        }

    //    }
    //    catch (Exception ex)
    //    {
    //        string strError = ex.Message.ToString();
    //        strError = strError.Replace("\n", " ");
    //        Response.Redirect("Bill_Sys_ErrorPage.aspx?ErrMsg=" + strError);
    //    }
    //}

    private Int32 GetDifference(string billid)
    {
        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());
        }
        ArrayList arrayDiff;

        _bill_Sys_BillingCompanyDetails_BO = new Bill_Sys_BillingCompanyDetails_BO();
        Int32 idiff = 0;

        try
        {
            arrayDiff = new ArrayList();
            arrayDiff = _bill_Sys_BillingCompanyDetails_BO.GetDifference(billid);
            if (arrayDiff.Count > 0)
            {
                if (Convert.ToInt32(arrayDiff[1]) > Convert.ToInt32(arrayDiff[2]))
                {
                    idiff = Convert.ToInt32(arrayDiff[1]) - Convert.ToInt32(arrayDiff[2]);
                }
                else
                {
                    idiff = 0;
                }
            }
            else
            {
                idiff = 1;
            }
        }
        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);
        }

        return(idiff);

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