protected void btn_genExl_Click(object sender, EventArgs e) { Hashtable htLcoAllParams = getLcoAllParamsData(); 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_RptLcoAll objTran = new Cls_Business_RptLcoAll(); Hashtable htResponse = objTran.GetTransationsLcoDet(htLcoAllParams, username, catid, operator_id); 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/") + "LcoAllDet_" + datetime + ".xls"); try { DataTable dt = null; //check for exception if (htResponse["htResponse"] != null) { dt = (DataTable)htResponse["htResponse"]; //-----------------------------------------------------LCO Details :------------------------------------------------------- int i = 0; String strheader0 = "LCO Details :"; String strheader = "Sr.No." + Convert.ToChar(9) + "LCO Code" + Convert.ToChar(9) + "LCO Name" + Convert.ToChar(9) + "Awailable Balance" + Convert.ToChar(9); while (i < dt.Rows.Count) { sw.WriteLine(strheader0); sw.WriteLine(strheader); for (int ii = 0; ii < dt.Rows.Count; ii++) { i = i + 1; string strrow = i.ToString() + Convert.ToChar(9) + dt.Rows[ii]["lcocode"].ToString() + Convert.ToChar(9) + dt.Rows[ii]["lconame"].ToString() + Convert.ToChar(9); strrow += dt.Rows[ii]["awailbal"].ToString() + Convert.ToChar(9); sw.WriteLine(strrow); } } } if (dt == null) { } //} /*if (dt == null) * { * Response.Redirect("~/ErrorPage.aspx"); * return; * }*/ //-----------------------------------------------------Customer Last Five Transaction :------------------------------------------------------- DataTable dt1 = null; //check for exception Cls_Business_RptLcoAll objTran1 = new Cls_Business_RptLcoAll(); Hashtable htResponse1 = objTran1.GetTransationsLastF(htLcoAllParams, username, catid, operator_id); if (htResponse1["htResponse1"] != null) { dt1 = (DataTable)htResponse1["htResponse1"]; int j = 0; String strheader011 = "Customer Last Five Transaction :"; String strheader1 = "Sr.No." + Convert.ToChar(9) + "Customer ID" + Convert.ToChar(9) + "Customer Name" + Convert.ToChar(9) + "Customer Address" + Convert.ToChar(9) + "VC" + Convert.ToChar(9) + "Plan Name" + Convert.ToChar(9) + "Plan Type" + Convert.ToChar(9); strheader1 += "User ID" + Convert.ToChar(9) + "User Name" + Convert.ToChar(9) + "'" + "Transaction Date & Time" + Convert.ToChar(9) + "Amount deducted" + Convert.ToChar(9) + "'" + "Expiry date" + Convert.ToChar(9); strheader1 += "Pay Term" + Convert.ToChar(9) + "Balance" + Convert.ToChar(9) + "LCO Code" + Convert.ToChar(9) + "LCO Name" + Convert.ToChar(9) + "JV Name" + Convert.ToChar(9); strheader1 += "ERP LCO A/C" + Convert.ToChar(9) + "Distributor" + Convert.ToChar(9) + "Sub distributor" + Convert.ToChar(9); strheader1 += "City" + Convert.ToChar(9) + "State" + Convert.ToChar(9); while (j < dt1.Rows.Count) { sw.WriteLine(); sw.WriteLine(strheader011); sw.WriteLine(strheader1); for (int jj = 0; jj < dt1.Rows.Count; jj++) { j = j + 1; string strrow1 = j.ToString() + Convert.ToChar(9) + "'" + dt1.Rows[jj]["custid"].ToString() + Convert.ToChar(9) + dt1.Rows[jj]["custname"].ToString() + Convert.ToChar(9) + dt1.Rows[jj]["custaddr"].ToString() + Convert.ToChar(9) + dt1.Rows[jj]["vc"].ToString() + Convert.ToChar(9); strrow1 += dt1.Rows[jj]["plnname"].ToString() + Convert.ToChar(9) + dt1.Rows[jj]["plntyp"].ToString() + Convert.ToChar(9); strrow1 += dt1.Rows[jj]["uname"].ToString() + Convert.ToChar(9) + dt1.Rows[jj]["userowner"].ToString() + Convert.ToChar(9) + "'" + dt1.Rows[jj]["tdt"].ToString() + Convert.ToChar(9); strrow1 += dt1.Rows[jj]["amtdd"].ToString() + Convert.ToChar(9) + "'" + dt1.Rows[jj]["expdt"].ToString() + Convert.ToChar(9); strrow1 += dt1.Rows[jj]["payterm"].ToString() + Convert.ToChar(9) + dt1.Rows[jj]["bal"].ToString() + Convert.ToChar(9); strrow1 += dt1.Rows[jj]["lcocode"].ToString() + Convert.ToChar(9) + dt1.Rows[jj]["lconame"].ToString() + Convert.ToChar(9); strrow1 += dt1.Rows[jj]["jvname"].ToString() + Convert.ToChar(9) + dt1.Rows[jj]["erplco_ac"].ToString() + Convert.ToChar(9); strrow1 += dt1.Rows[jj]["distname"].ToString() + Convert.ToChar(9) + dt1.Rows[jj]["subdist"].ToString() + Convert.ToChar(9); strrow1 += dt1.Rows[jj]["city"].ToString() + Convert.ToChar(9) + dt1.Rows[jj]["state"].ToString() + Convert.ToChar(9); sw.WriteLine(strrow1); } } //} } if (dt == null) { } /*if (dt1 == null) * { * Response.Redirect("~/ErrorPage.aspx"); * return; * }*/ //-----------------------------------------------------Receipt Entry Details :------------------------------------------------------- DataTable dt2 = null; //check for exception //if (htResponse2["htResponse2"] != null) //{ Cls_Business_RptLcoAll objTran2 = new Cls_Business_RptLcoAll(); Hashtable htResponse2 = objTran2.GetTransationsTop(htLcoAllParams, username, catid, operator_id); if (htResponse2["htResponse2"] != null) { dt2 = (DataTable)htResponse2["htResponse2"]; int k = 0; String strheader022 = "Receipt Entry Details :"; String strheader2 = "Sr.No." + Convert.ToChar(9) + "Date & Time" + Convert.ToChar(9) + "Amount" + Convert.ToChar(9) + "Mode of payment" + Convert.ToChar(9) + "ERP Receipt No." + Convert.ToChar(9); strheader2 += "UPASS Transaction ID" + Convert.ToChar(9) + "Finance user id" + Convert.ToChar(9) + "Finance user name" + Convert.ToChar(9) + "Action" + Convert.ToChar(9); strheader2 += "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); strheader2 += "Sub distributor" + Convert.ToChar(9) + "City" + Convert.ToChar(9) + "State" + Convert.ToChar(9); while (k < dt2.Rows.Count) { sw.WriteLine(); sw.WriteLine(strheader022); sw.WriteLine(strheader2); for (int kk = 0; kk < dt2.Rows.Count; kk++) { k = k + 1; string strrow2 = k.ToString() + Convert.ToChar(9) + "'" + dt2.Rows[kk]["dtttime"].ToString() + Convert.ToChar(9) + dt2.Rows[kk]["amt"].ToString() + Convert.ToChar(9); strrow2 += dt2.Rows[kk]["paymode"].ToString() + Convert.ToChar(9) + dt2.Rows[kk]["erprcptno"].ToString() + Convert.ToChar(9); strrow2 += dt2.Rows[kk]["rcptno"].ToString() + Convert.ToChar(9) + dt2.Rows[kk]["finuid"].ToString() + Convert.ToChar(9); strrow2 += dt2.Rows[kk]["fiuname"].ToString() + Convert.ToChar(9) + dt2.Rows[kk]["action"].ToString() + Convert.ToChar(9); strrow2 += dt2.Rows[kk]["lcocode"].ToString() + Convert.ToChar(9) + dt2.Rows[kk]["lconame"].ToString() + Convert.ToChar(9); strrow2 += dt2.Rows[kk]["jvname"].ToString() + Convert.ToChar(9) + dt2.Rows[kk]["erplco_ac"].ToString() + Convert.ToChar(9); strrow2 += dt2.Rows[kk]["distname"].ToString() + Convert.ToChar(9) + dt2.Rows[kk]["subdist"].ToString() + Convert.ToChar(9); strrow2 += dt2.Rows[kk]["city"].ToString() + Convert.ToChar(9) + dt2.Rows[kk]["state"].ToString() + Convert.ToChar(9); sw.WriteLine(strrow2); } } } if (dt2 == null) { } //} /*if (dt2 == null) * { * Response.Redirect("~/ErrorPage.aspx"); * return; * }*/ //-----------------------------------------------------Receipt Entry Reversal :------------------------------------------------------- DataTable dt3 = null; //check for exception //if (htResponse3["htResponse3"] != null) //{ Cls_Business_RptLcoAll objTran3 = new Cls_Business_RptLcoAll(); Hashtable htResponse3 = objTran3.GetTransationsRevrs(htLcoAllParams, username, catid, operator_id); if (htResponse3["htResponse3"] != null) { dt3 = (DataTable)htResponse3["htResponse3"]; int l = 0; String strheader033 = "Receipt Entry Reversal :"; String strheader3 = "Sr.No." + Convert.ToChar(9) + "LCO Code" + Convert.ToChar(9) + "Company Code" + Convert.ToChar(9) + "Voucher NO." + Convert.ToChar(9) + "Amount" + Convert.ToChar(9); strheader3 += "Reason" + Convert.ToChar(9) + "Remark" + Convert.ToChar(9) + "Inserted By" + Convert.ToChar(9) + "Inserted Date"; while (l < dt3.Rows.Count) { sw.WriteLine(); sw.WriteLine(strheader033); sw.WriteLine(strheader3); for (int ll = 0; ll < dt3.Rows.Count; ll++) { l = l + 1; string strrow4 = l.ToString() + Convert.ToChar(9) + "'" + dt3.Rows[ll]["lcocode"].ToString() + Convert.ToChar(9) + dt3.Rows[ll]["companycode"].ToString() + Convert.ToChar(9); strrow4 += dt3.Rows[ll]["voucherno"].ToString() + Convert.ToChar(9) + dt3.Rows[ll]["amount"].ToString() + Convert.ToChar(9); strrow4 += dt3.Rows[ll]["reasonname"].ToString() + Convert.ToChar(9) + dt3.Rows[ll]["lcopayremark"].ToString() + Convert.ToChar(9); strrow4 += dt3.Rows[ll]["insby"].ToString() + Convert.ToChar(9) + dt3.Rows[ll]["date1"].ToString() + Convert.ToChar(9); sw.WriteLine(strrow4); } } } if (dt3 == null) { } //} //} //} //} /*if (dt3 == null) * { * Response.Redirect("~/ErrorPage.aspx"); * return; * }*/ sw.Flush(); sw.Close(); } catch (Exception ex) { sw.Flush(); sw.Close(); Response.Write("Error : " + ex.Message.Trim()); return; } Response.Redirect("../MyExcelFile/" + "LcoAllDet_" + datetime + ".xls"); }
public void BindDataLast() { Hashtable htLcoAllParams = getLcoAllParamsData(); 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_RptLcoAll objTran = new Cls_Business_RptLcoAll(); Hashtable htResponse = objTran.GetTransationsLastF(htLcoAllParams, username, catid, Session["operatorid"].ToString()); DataTable dt = null; //check for exception if (htResponse["htResponse1"] != null) { dt = (DataTable)htResponse["htResponse1"]; } if (dt == null) { Response.Redirect("~/ErrorPage.aspx"); return; } //showing parameters string strParams = htResponse["ParamStr1"].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) { //btngrnExel.Visible = true; grdLastFive.Visible = false; //LastFiveAccordion.Visible = false; lbllastfive.Text = "No data found"; } else { //btngrnExel.Visible = true; grdLastFive.Visible = true; //LastFiveAccordion.Visible = true; //LastFiveAccordion.SelectedIndex = -1; lbllastfive.Text = ""; ViewState["searched_trans1"] = dt; grdLastFive.DataSource = dt; grdLastFive.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 } }