Exemple #1
0
    protected void btnRep_Click(object sender, EventArgs e)
    {
        try
        {
            ReportsBL.ReportClass rpt = new ReportsBL.ReportClass();
            divPrint.Visible = true;
            DateTime startDate, endDate;
            int      iExecID = 0;
            if (drpIncharge.SelectedItem != null)
            {
                iExecID = Convert.ToInt32(drpIncharge.SelectedItem.Value);
            }
            startDate = Convert.ToDateTime(txtStartDate.Text);
            endDate   = Convert.ToDateTime(txtEndDate.Text);
            DataSet ds = new DataSet();
            if (iExecID != 0)
            {
                ds = rpt.GenerateExecutiveSales(sDataSource, iExecID, startDate, endDate);
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('No Executives Found')", true);
                return;
            }
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                gvSales.DataSource = ds;
                gvSales.DataBind();
            }
            else
            {
                lblSales.Text      = "0.00";
                gvSales.DataSource = null;
                gvSales.DataBind();
            }
            //ds = rpt.GenerateExecutiveSalesReturn(sDataSource, iExecID,startDate, endDate);
            // if (ds != null && ds.Tables[0].Rows.Count > 0)
            //{
            //gvSalesReturn.DataSource = ds;
            //gvSalesReturn.DataBind();
            //}
            // else
            // {
            //     lblSalesReturn.Text = "0.00";
            //     gvSalesReturn.DataSource = null;
            //     gvSalesReturn.DataBind();
            // }
            lblSalesReturn.Text = "0.00";
            Double bal = 0.0d;
            bal             = Convert.ToDouble(lblSales.Text) - Convert.ToDouble(lblSalesReturn.Text);
            lblBalance.Text = bal.ToString("#0.00");

            DataSet dsMain = rpt.GetLedgerExecutive(sDataSource, iExecID);
            DataSet dsItem = new DataSet();

            dsItem = rpt.GenerateSalesExecutiveItemwise(sDataSource, startDate, endDate, Convert.ToString(iExecID));
            gvSalesItemwise.DataSource = dsItem;
            gvSalesItemwise.DataBind();

            //string ledgerID = string.Empty;
            //if (dsMain != null)
            //{
            //    if (dsMain.Tables[0].Rows.Count > 0)
            //    {
            //        foreach (DataRow maindr in dsMain.Tables[0].Rows)
            //        {
            //            if (maindr["LedgerID"] != null && maindr["LedgerID"].ToString() != "")
            //            {
            //                ledgerID = ledgerID + Convert.ToString(maindr["LedgerID"]) + ",";

            //            }

            //        }


            //        if (ledgerID != string.Empty)
            //        {
            //            ledgerID = ledgerID.Remove(ledgerID.LastIndexOf(',', ledgerID.Length - 1));
            //            dsItem = rpt.GenerateSalesExecutiveItemwise(sDataSource, startDate, endDate, ledgerID);
            //            gvSalesItemwise.DataSource = dsItem;
            //            gvSalesItemwise.DataBind();

            //            //dsItem = rpt.GenerateSalesReturnExecutiveItemwise(sDataSource, startDate, endDate, ledgerID);

            //            //gvSalesReturnItemwise.DataSource = dsItem;
            //            //gvSalesReturnItemwise.DataBind();

            //            double commision = 0;
            //            commision = Convert.ToDouble(lblTotalSalesComm.Text);//- Convert.ToDouble(hdSalesReturn.Value);

            //            lblTotalSalesComm.Text = commision.ToString("f2");
            //        }
            //    }
            //    else
            //    {
            //        gvSalesItemwise.DataSource = null;
            //        gvSalesItemwise.DataBind();
            //        gvSalesReturnItemwise.DataSource = null;
            //        gvSalesReturnItemwise.DataBind();
            //    }
            //}
            //else
            //{

            //    gvSalesItemwise.DataSource = null;
            //    gvSalesItemwise.DataBind();
            //    gvSalesReturnItemwise.DataSource = null;
            //    gvSalesReturnItemwise.DataBind();
            //}

            div1.Visible = false;
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }
Exemple #2
0
    protected void Page_Load(object sender, EventArgs e)
    {
        try
        {
            sDataSource       = ConfigurationManager.ConnectionStrings[Request.Cookies["Company"].Value].ToString();
            txtStartDate.Text = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1).ToShortDateString();

            DateTime indianStd = TimeZoneInfo.ConvertTimeBySystemTimeZoneId(DateTime.Now, "India Standard Time");
            string   dtaa      = Convert.ToDateTime(indianStd).ToString("dd/MM/yyyy");
            txtEndDate.Text = dtaa;

            //txtEndDate.Text = DateTime.Now.ToShortDateString();



            ReportsBL.ReportClass rpt = new ReportsBL.ReportClass();
            divPrint.Visible = true;
            DateTime startDate, endDate;
            int      iExecID = 0;
            if (drpIncharge.SelectedItem != null)
            {
                iExecID = Convert.ToInt32(drpIncharge.SelectedItem.Value);
            }

            DateTime stdt = Convert.ToDateTime(txtStartDate.Text);
            DateTime etdt = Convert.ToDateTime(txtEndDate.Text);

            if (Request.QueryString["startDate"] != null)
            {
                stdt = Convert.ToDateTime(Request.QueryString["startDate"].ToString());
            }
            if (Request.QueryString["endDate"] != null)
            {
                etdt = Convert.ToDateTime(Request.QueryString["endDate"].ToString());
            }

            startDate = Convert.ToDateTime(stdt);
            endDate   = Convert.ToDateTime(etdt);

            if (Request.QueryString["iExecID"] != null)
            {
                iExecID = Convert.ToInt32(Request.QueryString["iExecID"].ToString());
            }

            DataSet ds = new DataSet();
            if (iExecID != 0)
            {
                ds = rpt.GenerateExecutiveSales(sDataSource, iExecID, startDate, endDate);
            }
            else
            {
                ScriptManager.RegisterStartupScript(Page, Page.GetType(), Guid.NewGuid().ToString(), "alert('No Executives Found')", true);
                return;
            }
            if (ds != null && ds.Tables[0].Rows.Count > 0)
            {
                gvSales.DataSource = ds;
                gvSales.DataBind();
            }
            else
            {
                lblSales.Text      = "0.00";
                gvSales.DataSource = null;
                gvSales.DataBind();
            }
            //ds = rpt.GenerateExecutiveSalesReturn(sDataSource, iExecID,startDate, endDate);
            // if (ds != null && ds.Tables[0].Rows.Count > 0)
            //{
            //gvSalesReturn.DataSource = ds;
            //gvSalesReturn.DataBind();
            //}
            // else
            // {
            //     lblSalesReturn.Text = "0.00";
            //     gvSalesReturn.DataSource = null;
            //     gvSalesReturn.DataBind();
            // }
            lblSalesReturn.Text = "0.00";
            Double bal = 0.0d;
            bal             = Convert.ToDouble(lblSales.Text) - Convert.ToDouble(lblSalesReturn.Text);
            lblBalance.Text = bal.ToString("#0.00");

            DataSet dsMain = rpt.GetLedgerExecutive(sDataSource, iExecID);
            DataSet dsItem = new DataSet();

            dsItem = rpt.GenerateSalesExecutiveItemwise(sDataSource, startDate, endDate, Convert.ToString(iExecID));
            gvSalesItemwise.DataSource = dsItem;
            gvSalesItemwise.DataBind();

            //string ledgerID = string.Empty;
            //if (dsMain != null)
            //{
            //    if (dsMain.Tables[0].Rows.Count > 0)
            //    {
            //        foreach (DataRow maindr in dsMain.Tables[0].Rows)
            //        {
            //            if (maindr["LedgerID"] != null && maindr["LedgerID"].ToString() != "")
            //            {
            //                ledgerID = ledgerID + Convert.ToString(maindr["LedgerID"]) + ",";

            //            }

            //        }


            //        if (ledgerID != string.Empty)
            //        {
            //            ledgerID = ledgerID.Remove(ledgerID.LastIndexOf(',', ledgerID.Length - 1));
            //            dsItem = rpt.GenerateSalesExecutiveItemwise(sDataSource, startDate, endDate, ledgerID);
            //            gvSalesItemwise.DataSource = dsItem;
            //            gvSalesItemwise.DataBind();

            //            //dsItem = rpt.GenerateSalesReturnExecutiveItemwise(sDataSource, startDate, endDate, ledgerID);

            //            //gvSalesReturnItemwise.DataSource = dsItem;
            //            //gvSalesReturnItemwise.DataBind();

            //            double commision = 0;
            //            commision = Convert.ToDouble(lblTotalSalesComm.Text);//- Convert.ToDouble(hdSalesReturn.Value);

            //            lblTotalSalesComm.Text = commision.ToString("f2");
            //        }
            //    }
            //    else
            //    {
            //        gvSalesItemwise.DataSource = null;
            //        gvSalesItemwise.DataBind();
            //        gvSalesReturnItemwise.DataSource = null;
            //        gvSalesReturnItemwise.DataBind();
            //    }
            //}
            //else
            //{

            //    gvSalesItemwise.DataSource = null;
            //    gvSalesItemwise.DataBind();
            //    gvSalesReturnItemwise.DataSource = null;
            //    gvSalesReturnItemwise.DataBind();
            //}

            div1.Visible = false;
        }
        catch (Exception ex)
        {
            TroyLiteExceptionManager.HandleException(ex);
        }
    }