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

            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(Session["operator_id"]);
            }
            else
            {
                Session.Abandon();
                Response.Redirect("~/Login.aspx");
                return;
            }

            Cls_Business_RptAddPlan_JV objTran = new Cls_Business_RptAddPlan_JV();
            Hashtable htResponse = objTran.GetTransationsU(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;
            }

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

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

            if (dt.Rows.Count == 0)
            {
                btn_genExl.Visible      = false;
                grdTransUserDet.Visible = false;
                lblSearchMsg.Text       = "No data found";
                btnAll.Visible          = false;
            }
            else
            {
                btn_genExl.Visible          = true;
                grdTransUserDet.Visible     = true;
                lblSearchMsg.Text           = "";
                btnAll.Visible              = true;
                ViewState["searched_trans"] = dt;
                grdTransUserDet.DataSource  = dt;
                grdTransUserDet.DataBind();
                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
            }
        }
Esempio n. 2
0
        protected void btn_genExl_Click(object sender, EventArgs e)
        {
            Hashtable htAddPlanParams = getAddPlanParamsData();

            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(Session["operator_id"]);
            }
            else
            {
                Session.Abandon();
                Response.Redirect("~/Login.aspx");
                return;
            }

            Cls_Business_RptAddPlan_JV objTran = new Cls_Business_RptAddPlan_JV();
            Hashtable htResponse = objTran.GetTransationsU(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/") + "PlanAddUser_" + datetime + ".xls");
                try
                {
                    int    j         = 0;
                    String strheader = "SrNo" + Convert.ToChar(9)
                                       + "LCO Name" + Convert.ToChar(9)
                                       + "User Id" + Convert.ToChar(9)
                                       + "User Name" + Convert.ToChar(9)
                                       //    + "Balance" + Convert.ToChar(9)
                                       + "Amount Deducted" + Convert.ToChar(9)
                                       + "Count" + 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]["lconame"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["uname"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["userowner"].ToString() + Convert.ToChar(9)
                                            //+ dt.Rows[i]["amt"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["amtdd"].ToString() + Convert.ToChar(9)
                                            + dt.Rows[i]["cnt"].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/" + "PlanAddUser_" + datetime + ".xls");
            }

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