Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Master.PageHeading = "Last Five Transaction Report";
            if (!IsPostBack)
            {
                Session["RightsKey"] = null;

                Session["pagenos"] = "1";


                operid   = Convert.ToString(Session["operator_id"]);
                username = Convert.ToString(Session["username"]);
                catid    = Convert.ToString(Session["category"]);

                btn_genExl.Visible = false;

                if (catid == "3")
                {
                    tbldet.Visible = false;


                    Hashtable htAddPlanParams = getUserPara();

                    Cls_Business_RptLastFiveGridBind cls = new Cls_Business_RptLastFiveGridBind();
                    Hashtable htResponse = cls.GetLastFiveTransaction(htAddPlanParams, username, catid, operid);

                    DataTable dt = null; //check for exception
                    if (htResponse["htResponse"] != null)
                    {
                        dt = (DataTable)htResponse["htResponse"];
                    }

                    if (dt == null)
                    {
                        Response.Redirect("~/ErrorPage.aspx");
                        return;
                    }



                    if (dt.Rows.Count == 0)
                    {
                        grdTransDet.Visible = false;
                        lblSearchMsg.Text   = "No data found";
                        btn_genExl.Visible  = false;
                    }

                    else
                    {
                        btn_genExl.Visible          = true;
                        grdTransDet.Visible         = true;
                        lblSearchMsg.Text           = "";
                        ViewState["searched_trans"] = dt;
                        grdTransDet.DataSource      = dt;
                        grdTransDet.DataBind();
                    }
                }
                else
                {
                    tbldet.Visible = true;
                    FillLcoDetails();
                    //  FillLco();
                }
            }
        }
Beispiel #2
0
        protected void btn_genExl_Click(object sender, EventArgs e)
        {
            string username;
            string catid, operator_id;

            if (Session["username"] != null || Session["operator_id"] != null)
            {
                username    = Session["username"].ToString();
                catid       = Convert.ToString(Session["category"]);
                operator_id = Convert.ToString(Session["operator_id"]);
            }
            else
            {
                Session.Abandon();
                Response.Redirect("~/Login.aspx");
                return;
            }


            Hashtable htAddPlanParams = getUserPara();

            Cls_Business_RptLastFiveGridBind cls = new Cls_Business_RptLastFiveGridBind();
            Hashtable htResponse = cls.GetLastFiveTransaction(htAddPlanParams, username, catid, operator_id);

            DataTable dt = null; //check for exception

            if (htResponse["htResponse"] != null)
            {
                dt = (DataTable)htResponse["htResponse"];

                DateTime dd       = DateTime.Now;
                string   datetime = dd.Day + "" + dd.Month + "" + dd.Year + "" + dd.Hour + "" + dd.Minute + "" + dd.Second;

                StreamWriter sw = new StreamWriter(Server.MapPath("../MyExcelFile/") + "LastFiveTrans_" + datetime + ".xls");
                try
                {
                    int    j         = 0;
                    String strheader = "Customer ID" + Convert.ToChar(9) + "VC" + Convert.ToChar(9) + "Plan Name" + Convert.ToChar(9) + "Plan Type" + Convert.ToChar(9);
                    strheader += " Transaction Type" + Convert.ToChar(9) + "Reason" + Convert.ToChar(9);
                    strheader += "User ID" + Convert.ToChar(9) + "User Name" + Convert.ToChar(9)
                                 + "'" + "Transaction Date & Time" + Convert.ToChar(9)
                                 + "MRP" + Convert.ToChar(9)
                                 + "Amount deducted" + Convert.ToChar(9) + "'" + "Expiry date" + Convert.ToChar(9);
                    strheader += "Pay Term" + Convert.ToChar(9) + "Balance" + Convert.ToChar(9) + "LCO Code" + Convert.ToChar(9) + "LCO Name" + Convert.ToChar(9) + "JV Name" + Convert.ToChar(9);
                    strheader += "ERP LCO A/C" + Convert.ToChar(9) + "Distributor" + Convert.ToChar(9) + "Sub distributor" + Convert.ToChar(9);
                    strheader += "City" + Convert.ToChar(9) + "State" + Convert.ToChar(9);

                    while (j < dt.Rows.Count)
                    {
                        sw.WriteLine(strheader);
                        for (int i = 0; i < dt.Rows.Count; i++)
                        {
                            j = j + 1;
                            string strrow = j.ToString() + dt.Rows[i]["custid"].ToString() + Convert.ToChar(9) + dt.Rows[i]["vc"].ToString() + Convert.ToChar(9);
                            strrow += dt.Rows[i]["plnname"].ToString() + Convert.ToChar(9) + dt.Rows[i]["plntyp"].ToString() + Convert.ToChar(9);
                            strrow += dt.Rows[i]["flag"].ToString() + Convert.ToChar(9) + dt.Rows[i]["reason"].ToString() + Convert.ToChar(9);
                            strrow += dt.Rows[i]["uname"].ToString() + Convert.ToChar(9) + dt.Rows[i]["userowner"].ToString() + Convert.ToChar(9) + "'" + dt.Rows[i]["tdt"].ToString() + Convert.ToChar(9);
                            strrow += dt.Rows[i]["custprice"].ToString() + Convert.ToChar(9);
                            strrow += dt.Rows[i]["amtdd"].ToString() + Convert.ToChar(9) + "'" + dt.Rows[i]["expdt"].ToString() + Convert.ToChar(9);
                            strrow += dt.Rows[i]["payterm"].ToString() + Convert.ToChar(9) + dt.Rows[i]["bal"].ToString() + Convert.ToChar(9);
                            strrow += dt.Rows[i]["lcocode"].ToString() + Convert.ToChar(9) + dt.Rows[i]["lconame"].ToString() + Convert.ToChar(9);
                            strrow += dt.Rows[i]["jvname"].ToString() + Convert.ToChar(9) + dt.Rows[i]["erplco_ac"].ToString() + Convert.ToChar(9);
                            strrow += dt.Rows[i]["distname"].ToString() + Convert.ToChar(9) + dt.Rows[i]["subdist"].ToString() + Convert.ToChar(9);
                            strrow += dt.Rows[i]["city"].ToString() + Convert.ToChar(9) + dt.Rows[i]["state"].ToString() + Convert.ToChar(9);


                            sw.WriteLine(strrow);
                        }
                    }
                    sw.Flush();
                    sw.Close();
                }
                catch (Exception ex)
                {
                    sw.Flush();
                    sw.Close();
                    Response.Write("Error : " + ex.Message.Trim());
                    return;
                }
                Response.Redirect("../MyExcelFile/" + "LastFiveTrans_" + datetime + ".xls");
            }

            if (dt == null)
            {
                Response.Redirect("~/ErrorPage.aspx");
                return;
            }

            if (dt.Rows.Count == 0)
            {
                btn_genExl.Visible  = false;
                grdTransDet.Visible = false;
                lblSearchMsg.Text   = "No data found";
            }
            else
            {
                btn_genExl.Visible  = true;
                grdTransDet.Visible = true;
            }
        }
Beispiel #3
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            //if (ddlUser.SelectedIndex == 0)
            //{
            //    msgbox("Please Select User", ddlUser);
            //    return;

            //}

            string username, catid, operator_id;

            if (Session["username"] != null || Session["operator_id"] != null)
            {
                username    = Session["username"].ToString();
                catid       = Convert.ToString(Session["category"]);
                operator_id = Convert.ToString(ddlLco.SelectedValue); //Convert.ToString(Session["operator_id"]);
            }
            else
            {
                Session.Abandon();
                Response.Redirect("~/Login.aspx");
                return;
            }

            Hashtable htAddPlanParams = getUserPara();

            Cls_Business_RptLastFiveGridBind cls = new Cls_Business_RptLastFiveGridBind();
            Hashtable htResponse = cls.GetLastFiveTransaction(htAddPlanParams, username, catid, operator_id);

            DataTable dt = null; //check for exception

            if (htResponse["htResponse"] != null)
            {
                dt = (DataTable)htResponse["htResponse"];
            }

            if (dt == null)
            {
                Response.Redirect("~/ErrorPage.aspx");
                return;
            }



            if (dt.Rows.Count == 0)
            {
                grdTransDet.Visible = false;
                lblSearchMsg.Text   = "No data found";
                btn_genExl.Visible  = false;
            }

            else
            {
                btn_genExl.Visible          = true;
                grdTransDet.Visible         = true;
                lblSearchMsg.Text           = "";
                ViewState["searched_trans"] = dt;
                grdTransDet.DataSource      = dt;
                grdTransDet.DataBind();

                //showing result count
                ////lblResultCount.Text = Server.HtmlDecode("<b>Showing Top " + dt.Rows.Count.ToString() + " Matching Results</b>");

                //to get transaction type on frmSerTransDetails.aspx
            }
        }