Exemplo n.º 1
0
 private void TotalRecords()
 {
     using (TransportMandiEntities db = new TransportMandiEntities(MultipleDBDAL.strDynamicConString()))
     {
         string UserClass = Convert.ToString(Session["Userclass"]);
         Int64  UserIdno  = 0;
         if (UserClass != "Admin")
         {
             UserIdno = Convert.ToInt64(Session["UserIdno"]);
         }
         ShortageRepDAL obj   = new ShortageRepDAL();
         DataTable      list1 = obj.SelectRep("SelectRepWithoutParty", Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFrom.Text)), Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text)), 0, 0, UserIdno, ApplicationFunction.ConnectionString());
         lblTotalRecord.Text = "T. Record (s): " + Convert.ToString(list1.Rows.Count);
     }
 }
Exemplo n.º 2
0
        private void BindGrid()
        {
            try
            {
                ShortageRepDAL obj       = new ShortageRepDAL();
                string         userclass = Convert.ToString(Session["Userclass"]);
                Int64          UserIdno  = 0;
                if (userclass != "Admin")
                {
                    UserIdno = Convert.ToInt64(Session["UserIdno"]);
                }
                Int64     iFromCityIDNO = (Convert.ToString(drpBaseCity.SelectedValue) == "" ? 0 : Convert.ToInt64(drpBaseCity.SelectedValue));
                Int64     iSenderIDNO   = (Convert.ToString(drpPartyName.SelectedValue) == "" ? 0 : Convert.ToInt64(drpPartyName.SelectedValue));
                DataTable DsGrdetail    = null;
                if (iSenderIDNO == 0)
                {
                    DsGrdetail = obj.SelectRep("SelectRepWithoutParty", Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFrom.Text)), Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text)), iFromCityIDNO, iSenderIDNO, UserIdno, ApplicationFunction.ConnectionString());
                }
                else
                {
                    DsGrdetail = obj.SelectRep("SelectRepWithParty", Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFrom.Text)), Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text)), iFromCityIDNO, iSenderIDNO, UserIdno, ApplicationFunction.ConnectionString());
                }
                if ((DsGrdetail != null) && (DsGrdetail.Rows.Count > 0))
                {
                    ViewState["dtCSV"] = DsGrdetail;
                    grdMain.DataSource = DsGrdetail;
                    grdMain.DataBind();
                    Double TotalNetAmount = 0, TotWeight = 0, TotAmount = 0, TotShortageQty = 0, TotShortageAmnt = 0;

                    for (int i = 0; i < DsGrdetail.Rows.Count; i++)
                    {
                        TotWeight       += Convert.ToDouble(DsGrdetail.Rows[i]["TOT_WEGHT"]);
                        TotAmount       += Convert.ToDouble(DsGrdetail.Rows[i]["AMOUNT"]);
                        TotShortageQty  += Convert.ToDouble(DsGrdetail.Rows[i]["SHORTAGE_QTY"]);
                        TotShortageAmnt += Convert.ToDouble(DsGrdetail.Rows[i]["SHORTAGE_AMOUNT"]);
                        TotalNetAmount  += Convert.ToDouble(DsGrdetail.Rows[i]["INV_NETAMNT"]);
                    }
                    lblNetTotalAmount.Text = TotalNetAmount.ToString("N2");
                    lblWeight.Text         = TotWeight.ToString("N2");
                    lblAmount.Text         = TotAmount.ToString("N2");
                    lblshrtgQty.Text       = TotShortageQty.ToString("N2");
                    lblshrtgAmnt.Text      = TotShortageAmnt.ToString("N2");

                    int startRowOnPage = (grdMain.PageIndex * grdMain.PageSize) + 1;
                    int lastRowOnPage  = startRowOnPage + grdMain.Rows.Count - 1;
                    lblcontant.Text    = "Showing " + startRowOnPage.ToString() + " - " + lastRowOnPage.ToString() + " of " + DsGrdetail.Rows.Count.ToString();
                    lblcontant.Visible = true;
                    divpaging.Visible  = true;

                    imgBtnExcel.Visible = true;
                    lblTotalRecord.Text = "T. Record(s) :" + Convert.ToString(DsGrdetail.Rows.Count);
                }
                else
                {
                    ViewState["dtCSV"] = null;
                    grdMain.DataSource = null;
                    grdMain.DataBind();
                    lblTotalRecord.Text = "T. Record (s): 0 ";
                    lblcontant.Visible  = false;
                    divpaging.Visible   = false;
                    imgBtnExcel.Visible = false;
                }
            }
            catch (Exception Ex)
            {
                throw (Ex);
            }
        }