private void TotalRecords()
 {
     using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
     {
         string UserClass = Convert.ToString(Session["Userclass"]);
         Int64  UserIdno  = 0;
         Int64  YearIdno  = Convert.ToInt64(ddlDateRange.SelectedValue);
         if (UserClass != "Admin")
         {
             UserIdno = Convert.ToInt64(Session["UserIdno"]);
         }
         CurrentStockRpt obj   = new CurrentStockRpt();
         DataTable       list1 = obj.SelectCurrentStockSummary(ApplicationFunction.ConnectionString(), YearIdno, Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text)), Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTO.Text)), 0, 0);
         lblTotalRecord.Text = "T. Record (s): " + Convert.ToString(list1.Rows.Count);
     }
 }
        private void BindGrid()
        {
            CurrentStockRpt obj      = new CurrentStockRpt();
            Int64           YearIdno = Convert.ToInt64(ddlDateRange.SelectedValue);
            Int64           ItemIdno = Convert.ToInt64(ddlItemName.SelectedValue);
            Int64           LocIdno  = Convert.ToInt64(ddlFromCity.SelectedValue);
            DateTime?       dtfrom   = null;
            DateTime?       dtto     = null;


            if (string.IsNullOrEmpty(Convert.ToString(txtDate.Text)) == false)
            {
                dtfrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDate.Text));
            }
            if (string.IsNullOrEmpty(Convert.ToString(txtDateTO.Text)) == false)
            {
                dtto = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTO.Text));
            }
            dt  = obj.SelectCurrentStockSummary(ApplicationFunction.ConnectionString(), YearIdno, dtfrom, dtto, LocIdno, ItemIdno);
            obj = null;
            if (dt != null && dt.Rows.Count > 0)
            {
                DataTable DTT = dt.Clone();
                DTT = dt.Copy();
                Int64 OS = 0; Int64 CL = 0;
                for (int i = 0; i < dt.Rows.Count; i++)
                {
                    OS += Convert.ToInt64(DTT.Rows[i]["OS"]);
                    CL += Convert.ToInt64(DTT.Rows[i]["CL"]);
                    if (i == dt.Rows.Count - 1)
                    {
                        DataRow drr = DTT.NewRow();
                        drr["Item_Name"] = "Total";
                        drr["OS"]        = Convert.ToString(OS);
                        drr["CL"]        = Convert.ToString(CL);
                        lblOpenTot.Text  = Convert.ToString(OS);
                        lblClosTot.Text  = Convert.ToString(CL);
                        DTT.Rows.Add(drr);
                        break;
                    }
                }
                if (DTT != null && DTT.Rows.Count > 0)
                {
                    DTT.Columns[0].Caption = "Item Name";
                    DTT.Columns[1].Caption = "Opening";
                    DTT.Columns[2].Caption = "Closing";
                    DTT.AcceptChanges();
                    ViewState["Dt"] = DTT;
                }


                grdMain.DataSource = dt;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record : " + (dt.Rows.Count).ToString();
                imgBtnExcel.Visible = true;
                divpaging.Visible   = true;


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