Ejemplo n.º 1
0
        private void TotalRecordCount()
        {
            SaleRegDAL obj           = new SaleRegDAL();
            DateTime?  datefromValue = null;
            DateTime?  dateToValue   = null;

            if (string.IsNullOrEmpty(Convert.ToString(Datefrom.Text)) == false)
            {
                datefromValue = Convert.ToDateTime(ApplicationFunction.mmddyyyy(Datefrom.Text));
            }
            if (string.IsNullOrEmpty(Convert.ToString(txtDateTo.Text)) == false)
            {
                dateToValue = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text));
            }
            Int32 intYearIdno = string.IsNullOrEmpty(Convert.ToString(ddlDateRange.SelectedValue)) ? 0 : Convert.ToInt32(ddlDateRange.SelectedValue);
            Int32 intLoc      = string.IsNullOrEmpty(Convert.ToString(drpCityFrom.SelectedValue))?0:Convert.ToInt32(drpCityFrom.SelectedValue);
            Int32 intSaletype = string.IsNullOrEmpty(Convert.ToString(ddlSaleType.SelectedValue))?0:Convert.ToInt32(ddlSaleType.SelectedValue);

            int    intBillNo    = string.IsNullOrEmpty(Convert.ToString(txtBillNo.Text.Trim()))?0:Convert.ToInt32(txtBillNo.Text.Trim());
            Int32  intPartyIdno = string.IsNullOrEmpty(Convert.ToString(ddlPartyName.SelectedValue))?0:Convert.ToInt32(ddlPartyName.SelectedValue);
            string strPerfNo    = string.IsNullOrEmpty(Convert.ToString(txtPerfNo.Text.Trim()))?"":Convert.ToString(txtPerfNo.Text.Trim());
            Int32  intAgainst   = string.IsNullOrEmpty(Convert.ToString(ddlAgainst.SelectedValue))?0:Convert.ToInt32(ddlAgainst.SelectedValue);

            var lstGridData = obj.SelectSBillReg(intYearIdno, datefromValue, dateToValue, intLoc, intSaletype, strPerfNo, intBillNo, intPartyIdno, intAgainst);

            obj = null;
            if (lstGridData != null && lstGridData.Count > 0)
            {
                lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count.ToString();
            }
            else
            {
                lblTotalRecord.Text = "T. Record (s): 0 ";
            }
        }
Ejemplo n.º 2
0
        private void BindGrid()
        {
            SaleRegDAL obj           = new SaleRegDAL();
            DateTime?  datefromValue = null;
            DateTime?  dateToValue   = null;

            if (string.IsNullOrEmpty(Convert.ToString(Datefrom.Text)) == false)
            {
                datefromValue = Convert.ToDateTime(ApplicationFunction.mmddyyyy(Datefrom.Text));
            }
            if (string.IsNullOrEmpty(Convert.ToString(txtDateTo.Text)) == false)
            {
                dateToValue = Convert.ToDateTime(ApplicationFunction.mmddyyyy(txtDateTo.Text));
            }
            Int32 intYearIdno = string.IsNullOrEmpty(Convert.ToString(ddlDateRange.SelectedValue)) ? 0 : Convert.ToInt32(ddlDateRange.SelectedValue);
            Int32 intLoc      = string.IsNullOrEmpty(Convert.ToString(drpCityFrom.SelectedValue)) ? 0 : Convert.ToInt32(drpCityFrom.SelectedValue);
            Int32 intSaletype = string.IsNullOrEmpty(Convert.ToString(ddlSaleType.SelectedValue)) ? 0 : Convert.ToInt32(ddlSaleType.SelectedValue);

            int    intBillNo    = string.IsNullOrEmpty(Convert.ToString(txtBillNo.Text.Trim())) ? 0 : Convert.ToInt32(txtBillNo.Text.Trim());
            Int32  intPartyIdno = string.IsNullOrEmpty(Convert.ToString(ddlPartyName.SelectedValue)) ? 0 : Convert.ToInt32(ddlPartyName.SelectedValue);
            string strPerfNo    = string.IsNullOrEmpty(Convert.ToString(txtPerfNo.Text.Trim())) ? "" : Convert.ToString(txtPerfNo.Text.Trim());
            Int32  intAgainst   = string.IsNullOrEmpty(Convert.ToString(ddlAgainst.SelectedValue)) ? 0 : Convert.ToInt32(ddlAgainst.SelectedValue);

            var lstGridData = obj.SelectSBillReg(intYearIdno, datefromValue, dateToValue, intLoc, intSaletype, strPerfNo, intBillNo, intPartyIdno, intAgainst);

            obj = null;
            if (lstGridData != null && lstGridData.Count > 0)
            {
                DataTable dt = new DataTable();
                dt.Columns.Add("SrNo", typeof(string));
                dt.Columns.Add("PerfNo", typeof(string));
                dt.Columns.Add("BillNo", typeof(string));
                dt.Columns.Add("Date", typeof(string));
                dt.Columns.Add("BillType", typeof(string));
                dt.Columns.Add("Against", typeof(string));
                dt.Columns.Add("Party", typeof(string));
                dt.Columns.Add("Location", typeof(string));
                dt.Columns.Add("TotTaxable", typeof(string));
                dt.Columns.Add("TotTax", typeof(string));
                dt.Columns.Add("DiscAmnt", typeof(string));
                dt.Columns.Add("OtherAmnt", typeof(string));
                dt.Columns.Add("NetAmnt", typeof(string));

                double TNet = 0; double TTax = 0; double TTaxable = 0; double TDisc = 0; double TOther = 0;
                for (int i = 0; i < lstGridData.Count; i++)
                {
                    DataRow dr = dt.NewRow();
                    dr["SrNo"]       = Convert.ToString(i + 1);
                    dr["PerfNo"]     = Convert.ToString(DataBinder.Eval(lstGridData[i], "PrefNo"));
                    dr["BillNo"]     = Convert.ToString(DataBinder.Eval(lstGridData[i], "SbillNo"));
                    dr["Date"]       = Convert.ToDateTime(DataBinder.Eval(lstGridData[i], "Date")).ToString("dd-MM-yyyy");
                    dr["BillType"]   = Convert.ToString(DataBinder.Eval(lstGridData[i], "SbillType"));
                    dr["Against"]    = Convert.ToString(DataBinder.Eval(lstGridData[i], "Against"));
                    dr["Party"]      = Convert.ToString(DataBinder.Eval(lstGridData[i], "PartyName"));
                    dr["Location"]   = Convert.ToString(DataBinder.Eval(lstGridData[i], "FromLocation"));
                    dr["TotTaxable"] = Convert.ToString(DataBinder.Eval(lstGridData[i], "TotTaxableAmnt"));
                    dr["TotTax"]     = Convert.ToString(DataBinder.Eval(lstGridData[i], "TotTax"));
                    dr["DiscAmnt"]   = Convert.ToString(DataBinder.Eval(lstGridData[i], "DiscAmnt"));
                    dr["OtherAmnt"]  = Convert.ToString(DataBinder.Eval(lstGridData[i], "OtherAmnt"));
                    dr["NetAmnt"]    = Convert.ToString(DataBinder.Eval(lstGridData[i], "NetAmnt"));
                    dt.Rows.Add(dr);

                    TTaxable += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "TotTax"));
                    TTax     += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "TotTax"));
                    TDisc    += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "DiscAmnt"));
                    TOther   += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "OtherAmnt"));
                    TNet     += Convert.ToDouble(DataBinder.Eval(lstGridData[i], "NetAmnt"));

                    if (i == lstGridData.Count - 1)
                    {
                        DataRow drr = dt.NewRow();
                        drr["Party"]      = "Total";
                        drr["TotTaxable"] = (TTaxable).ToString("N2");
                        drr["TotTax"]     = (TTax).ToString("N2");
                        drr["DiscAmnt"]   = (TDisc).ToString("N2");
                        drr["OtherAmnt"]  = (TOther).ToString("N2");
                        drr["NetAmnt"]    = (TNet).ToString("N2");
                        dt.Rows.Add(drr);
                    }
                }
                if (dt != null && dt.Rows.Count > 0)
                {
                    ViewState["Dt"] = dt;
                }

                grdMain.DataSource = lstGridData;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record (s): " + lstGridData.Count;
                imgBtnExcel.Visible = true;
            }
            else
            {
                grdMain.DataSource = null;
                grdMain.DataBind();
                lblTotalRecord.Text = "T. Record (s): 0 ";
                imgBtnExcel.Visible = false;
            }
        }