protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.UrlReferrer == null)
            {
                base.AutoRedirect();
            }
            txtRcptNo.Attributes.Add("onkeypress", "return allowAlphabetAndNumer(event);");
            txtInvcDatefrom.Attributes.Add("onkeypress", "return notAllowAnything(event);");
            txtInvcDateto.Attributes.Add("onkeypress", "return notAllowAnything(event);");
            if (!Page.IsPostBack)
            {
                if (base.CheckUserRights(intFormId) == false)
                {
                    Response.Redirect("PermissionDenied.aspx");
                }
                if (base.Print == false)
                {
                    imgBtnExcel.Visible = false;
                }
                this.BindDateRange();
                ddldateRange.SelectedIndex = 0;
                ddldateRange_SelectedIndexChanged(null, null);

                RcvdAmntAgnstHireInvcDAL obj = new RcvdAmntAgnstHireInvcDAL();
                var lstGridData = obj.search(Convert.ToInt32(ddldateRange.SelectedValue), txtRcptNo.Text, Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtInvcDatefrom.Text)), Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtInvcDateto.Text)));
                if (lstGridData != null && lstGridData.Count > 0)
                {
                    lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count;
                }
                ddldateRange.Focus();
            }
        }
        private void BindGrid()
        {
            RcvdAmntAgnstHireInvcDAL obj = new RcvdAmntAgnstHireInvcDAL();
            DateTime?dtfrom    = null;
            DateTime?dtto      = null;
            String   InvoiceNo = txtRcptNo.Text;

            if (string.IsNullOrEmpty(Convert.ToString(txtInvcDatefrom.Text)) == false)
            {
                dtfrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtInvcDatefrom.Text));
            }
            if (string.IsNullOrEmpty(Convert.ToString(txtInvcDatefrom.Text)) == false)
            {
                dtto = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtInvcDateto.Text));
            }

            var lstGridData = obj.search(Convert.ToInt32(ddldateRange.SelectedValue), InvoiceNo, dtfrom, dtto);

            obj = null;
            if (lstGridData != null && lstGridData.Count > 0)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("SrNo", typeof(string));
                dt.Columns.Add("InvoiceNo", typeof(string));
                dt.Columns.Add("Date", typeof(string));
                //dt.Columns.Add("FromCity", typeof(string));
                dt.Columns.Add("Sender", typeof(string));
                dt.Columns.Add("NetAmount", typeof(string));

                double TNet = 0; double TAmnt = 0;
                for (int i = 0; i < lstGridData.Count; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr["SrNo"]      = Convert.ToString(i + 1);
                    dr["InvoiceNo"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "Inv_No"));
                    dr["Date"]      = Convert.ToDateTime(DataBinder.Eval(lstGridData[i], "Inv_Date")).ToString("dd-MM-yyyy");
                    //dr["FromCity"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "FromCity"));
                    dr["Sender"]    = Convert.ToString(DataBinder.Eval(lstGridData[i], "SenderName"));
                    dr["NetAmount"] = Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Net_Amnt")).ToString("N2");
                    dt.Rows.Add(dr);

                    TNet += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Net_Amnt"));
                    if (i == lstGridData.Count - 1)
                    {
                        DataRow drr = dt.NewRow();
                        drr["Sender"]    = "Total";
                        drr["NetAmount"] = (TNet).ToString("N2");
                        dt.Rows.Add(drr);
                    }
                }
                if (dt != null && dt.Rows.Count > 0)
                {
                    ViewState["Dt"] = dt;
                }


                //
                Double TotalNetAmount = 0;

                for (int i = 0; i < lstGridData.Count; i++)
                {
                    TotalNetAmount += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "Net_Amnt"));
                }
                lblNetTotalAmount.Text = TotalNetAmount.ToString("N2");

                grdMain.DataSource = lstGridData;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count;


                int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1;
                int lastRowOnPage  = startRowOnPage + grdMain.Rows.Count - 1;
                lblcontant.Text     = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + lstGridData.Count.ToString();
                lblcontant.Visible  = true;
                imgBtnExcel.Visible = true;
                divpaging.Visible   = true;
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record (s): 0 ";


                imgBtnExcel.Visible = false;
                lblcontant.Visible  = false;
                divpaging.Visible   = false;
            }
        }