Beispiel #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"]);
         }
         Int64 iFromCityIDNO        = (Convert.ToString(drpBaseCity.SelectedValue) == "" ? 0 : Convert.ToInt64(drpBaseCity.SelectedValue));
         Int64 iTruckIDNO           = (Convert.ToString(ddlTruckNo.SelectedValue) == "" ? 0 : Convert.ToInt64(ddlTruckNo.SelectedValue));
         Int32 ichlnType            = (Convert.ToString(ddlChlnType.SelectedValue) == "" ? 0 : Convert.ToInt32(ddlChlnType.SelectedValue));
         ChlnConfirmationRepDAL obj = new ChlnConfirmationRepDAL();
         DataTable list1            = obj.SelectRep(Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFrom.Text)), Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text)), iFromCityIDNO, iTruckIDNO, ichlnType, UserIdno, conString);
         lblTotalRecord.Text = "T. Record (s): " + Convert.ToString(list1.Rows.Count);
     }
 }
Beispiel #2
0
        private void BindGrid()
        {
            try
            {
                ChlnConfirmationRepDAL obj = new ChlnConfirmationRepDAL();
                Int64    iFromCityIDNO     = (Convert.ToString(drpBaseCity.SelectedValue) == "" ? 0 : Convert.ToInt64(drpBaseCity.SelectedValue));
                Int64    iTruckIDNO        = (Convert.ToString(ddlTruckNo.SelectedValue) == "" ? 0 : Convert.ToInt64(ddlTruckNo.SelectedValue));
                Int32    ichlnType         = (Convert.ToString(ddlChlnType.SelectedValue) == "" ? 0 : Convert.ToInt32(ddlChlnType.SelectedValue));
                DateTime?DtFrom;
                DateTime?DtTo;
                if (txtDateFrom.Text == "")
                {
                    DtFrom = null;
                }
                else
                {
                    DtFrom = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateFrom.Text));
                }
                if (txtDateTo.Text == "")
                {
                    DtTo = null;
                }
                else
                {
                    DtTo = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text));
                }
                if (txtDateFrom.Text == "")
                {
                    DtFrom = null;
                }
                string UserClass = Convert.ToString(Session["Userclass"]);
                Int64  UserIdno  = 0;
                if (UserClass != "Admin")
                {
                    UserIdno = Convert.ToInt64(Session["UserIdno"]);
                }
                DataTable lst = obj.SelectRep(DtFrom, DtTo, iFromCityIDNO, iTruckIDNO, ichlnType, UserIdno, conString);
                if ((lst != null) && (lst.Rows.Count > 0))
                {
                    ViewState["CSV"]   = lst;
                    grdMain.DataSource = lst;
                    grdMain.DataBind();
                    Double TotalNetAmount = 0, TotalQty = 0, TotAdvAmount = 0;

                    for (int i = 0; i < lst.Rows.Count; i++)
                    {
                        TotalQty       += Convert.ToDouble(lst.Rows[i]["Qty"]);
                        TotalNetAmount += Convert.ToDouble(lst.Rows[i]["Amount"]);
                        TotAdvAmount   += Convert.ToDouble(lst.Rows[i]["Adv_Amnt"]);
                    }
                    lblNetTotalAmount.Text = TotalNetAmount.ToString("N2");
                    lblQty.Text            = TotalQty.ToString("N2");
                    lblAdvAmnt.Text        = TotAdvAmount.ToString("N2");

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

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