Ejemplo n.º 1
0
        public void binddata()
        {
            Hashtable htAddPlanParams = getAddPlanParamsData();

            string username;

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

            Cls_Business_RptAddPlan_JV objTran = new Cls_Business_RptAddPlan_JV();
            Hashtable htResponse = objTran.GetTransationsDet(htAddPlanParams, username);

            DataTable dt = null; //check for exception

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

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

            //showing parameters
            string strParams = htResponse["ParamStr"].ToString();

            if (!String.IsNullOrEmpty(strParams))
            {
                lblSearchParams.Text = Server.HtmlDecode("<b style='color:#094791;'>Transaction Parameters : </b>" + strParams);
            }

            if (dt.Rows.Count == 0)
            {
                grdTransDet.Visible  = false;
                lblSearchMsg.Text    = "No data found";
                btn_genExl.Visible   = false;
                btn_genExcel.Visible = false;
            }
            else
            {
                grdTransDet.Visible         = true;
                btn_genExl.Visible          = true;
                btn_genExcel.Visible        = true;
                lblSearchMsg.Text           = "";
                ViewState["searched_trans"] = dt;
                grdTransDet.DataSource      = dt;
                grdTransDet.DataBind();
                ScriptManager.RegisterStartupScript(Page, this.GetType(), "Key", "<script>MakeStaticHeader('" + grdTransDet.ClientID + "', 400, 1200 , 46 ,false); </script>", false);
                DivRoot.Style.Add("display", "block");

                htResponse["htResponse"] = null;
                dt.Dispose();

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

                //to get transaction type on frmSerTransDetails.aspx
            }
        }
Ejemplo n.º 2
0
        protected void ExportExcel(string from, string to)
        {
            //Response.Redirect("../Reports/rptAddPlanTransDET.aspx?showall=0");
            Hashtable ht = getExcelParamsData();
            string    username;

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

            Cls_Business_RptAddPlan_JV objTran = new Cls_Business_RptAddPlan_JV();
            Hashtable htResponse = objTran.GetTransationsDet(ht, username);

            DataTable dt = null; //check for exception

            dt = (DataTable)htResponse["htResponse"];
            if (dt == null)
            {
                Response.Redirect("~/ErrorPage.aspx");
                return;
            }
            else
            {
                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/") + "PlanAdd_" + datetime + ".xls");
                try
                {
                    int    j         = 0;
                    String strheader = "Sr. No." + Convert.ToChar(9)
                                       + "Customer ID" + Convert.ToChar(9)
                                       + "Customer Name" + Convert.ToChar(9)
                                       + "Customer Address" + Convert.ToChar(9)
                                       + "VC ID" + Convert.ToChar(9)
                                       + "Plan Name" + Convert.ToChar(9)
                                       + "Plan Type" + Convert.ToChar(9)
                                       + "Transaction Type" + Convert.ToChar(9)
                                       + "Reason" + Convert.ToChar(9)
                                       + "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)
                                       + "Pay Term" + Convert.ToChar(9)
                                       + "Balance" + Convert.ToChar(9)
                                       + "LCO Code" + Convert.ToChar(9)
                                       + "LCO Name" + Convert.ToChar(9)
                                       + "JV Name" + Convert.ToChar(9)
                                       + "ERP LCO A/C" + Convert.ToChar(9)
                                       + "Distributor" + Convert.ToChar(9)
                                       + "Sub distributor" + Convert.ToChar(9)
                                       + "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() + Convert.ToChar(9)
                                            + dt.Rows[i]["custid"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["custname"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["custaddr"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["vc"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["plnname"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["plntyp"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["flag"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["reason"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["uname"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["userowner"].ToString() + Convert.ToChar(9)
                                            + "'" + dt.Rows[i]["tdt"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["custprice"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["amtdd"].ToString() + Convert.ToChar(9)
                                            + "'" + dt.Rows[i]["expdt"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["payterm"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["bal"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["lcocode"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["lconame"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["jvname"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["erplco_ac"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["distname"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["subdist"].ToString() + Convert.ToChar(9)
                                            + 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;
                }
                htResponse["htResponse"] = null;
                dt.Dispose();
                Response.Redirect("../MyExcelFile/" + "PlanAdd_" + datetime + ".xls");
                ScriptManager.RegisterStartupScript(this, GetType(), "onComplete", "onComplete();", true);
            }
        }