Exemplo n.º 1
0
        public void binddata()
        {
            Hashtable htLedgerParams = getLedgerParamsData();

            string username;

            if (Session["username"] != 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_RptINVLedger objTran = new Cls_Business_RptINVLedger();
            Hashtable htResponse = objTran.GetTransationsDet(htLedgerParams, 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;'>LCO Party Ledger Parameters : </b>" + strParams);
                lblSearchParams.Text = Server.HtmlDecode("<b style='color:#094791;'> </b>" + strParams);
            }

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

            string username;

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

            if (Session["username"] != null || Session["operator_id"] != null)
            {
                username1 = 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_RptINVLedger objTran = new Cls_Business_RptINVLedger();
            Hashtable htResponse = objTran.GetTransationsDet(htLedgerParams, username, catid, operator_id);



            Cls_Business_RptINVLedger objTran1 = new Cls_Business_RptINVLedger();
            Hashtable htResponse1 = objTran.GetTransationsDetLCO(htLedgerParams, username1, catid, operator_id);

            DataTable dt = null; //check for exception

            if (htResponse1["htResponse"] != null)
            {
                dt = (DataTable)htResponse1["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/") + "PartyLedger_" + datetime + ".xls");
                try
                {
                    /*int j = 0;
                     *
                     * String strheader = "LCO Code" + Convert.ToChar(9) + "LCO Name" + Convert.ToChar(9) + "Opening Balance" + Convert.ToChar(9);
                     * strheader += "Debit" + Convert.ToChar(9) + "Credit" + Convert.ToChar(9) + "Closing Balance" + 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]["lcocode"].ToString() + Convert.ToChar(9) + dt.Rows[i]["lconame"].ToString() + Convert.ToChar(9);
                     *      strrow += dt.Rows[i]["openinbal"].ToString() + Convert.ToChar(9) + dt.Rows[i]["drlimit"].ToString() + Convert.ToChar(9);
                     *      strrow += dt.Rows[i]["crlimit"].ToString() + Convert.ToChar(9) + dt.Rows[i]["closingbal"].ToString() + Convert.ToChar(9);
                     *      sw.WriteLine(strrow);
                     *  }
                     * }*/

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

                    if (dt1 == null)
                    {
                        Response.Redirect("~/ErrorPage.aspx");
                        return;
                    }
                    String strheader1 = "Sr.No." + Convert.ToChar(9)
                                        + "Ledger Date" + Convert.ToChar(9)
                                        + "Ledger Type" + Convert.ToChar(9)
                                        + "Remark" + Convert.ToChar(9);
                    strheader1 += "Debit" + Convert.ToChar(9)
                                  + "Credit" + Convert.ToChar(9)
                                  + "Balance" + Convert.ToChar(9)
                    ;
                    sw.WriteLine(strheader1);
                    int k = 0;


                    while (k < dt1.Rows.Count)
                    {
                        for (int i = 0; i < dt1.Rows.Count; i++)
                        {
                            k = k + 1;
                            string strrow = k.ToString() + Convert.ToChar(9) + "'"
                                            + dt1.Rows[i]["dt1"].ToString() + Convert.ToChar(9)
                                            + dt1.Rows[i]["ltype"].ToString() + Convert.ToChar(9)
                                            + dt1.Rows[i]["premark"].ToString() + Convert.ToChar(9);
                            strrow += dt1.Rows[i]["drlimit"].ToString() + Convert.ToChar(9)
                                      + dt1.Rows[i]["crlimit"].ToString() + Convert.ToChar(9);
                            strrow += dt1.Rows[i]["balance"].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/" + "PartyLedger_" + datetime + ".xls");
            }

            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;'>LCO Party Ledger Parameters : </b>" + strParams);
                lblSearchParams.Text = Server.HtmlDecode("<b style='color:#094791;'> </b>" + strParams);
            }

            /*if (dt.Rows.Count == 0)
             * {
             *  btn_genExl.Visible = false;
             *  grdPartyLedger.Visible = false;
             *  lblSearchMsg.Text = "No data found";
             * }
             * else
             * {
             *  btn_genExl.Visible = true;
             *  grdPartyLedger.Visible = true;
             *  lblSearchMsg.Text = "";
             * }*/
        }