protected void grdLcoPartyLedger_PageIndexChanging(object sender, GridViewPageEventArgs e) { grdLcoPartyLedger.PageIndex = e.NewPageIndex; Hashtable htAddPlanParams = getLedgerParamsData(); 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_RptINVLedger objTran = new Cls_Business_RptINVLedger(); Hashtable htResponse = objTran.GetTransations(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) { btn_genExl.Visible = false; grdLcoPartyLedger.Visible = false; lblSearchMsg.Text = "No data found"; } else { btn_genExl.Visible = true; grdLcoPartyLedger.Visible = true; lblSearchMsg.Text = ""; grdLcoPartyLedger.DataSource = dt; grdLcoPartyLedger.DataBind(); } }
protected void btn_genExl_Click(object sender, EventArgs e) { Hashtable htAddPlanParams = getLedgerParamsData(); 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_RptINVLedger objTran = new Cls_Business_RptINVLedger(); Hashtable htResponse = objTran.GetTransations(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/") + "PartyLedgerLCO_" + datetime + ".xls"); try { int j = 0; String strheader = "SrNo." + Convert.ToChar(9) + "LCO Name" + Convert.ToChar(9) + "LCO Code" + Convert.ToChar(9) + "Opening Balance" + Convert.ToChar(9) + "Debit" + Convert.ToChar(9) + "Credit" + Convert.ToChar(9) + "Closing Balance" + Convert.ToChar(9) + "Company Name" + Convert.ToChar(9) + "Distributor" + Convert.ToChar(9) + "Sub Distributor" + Convert.ToChar(9) + "State" + Convert.ToChar(9) + "City" + 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]["lcocode"].ToString() + Convert.ToChar(9) + dt.Rows[i]["openinbal"].ToString() + Convert.ToChar(9) + dt.Rows[i]["drlimit"].ToString() + Convert.ToChar(9) + dt.Rows[i]["crlimit"].ToString() + Convert.ToChar(9) + dt.Rows[i]["closingbal"].ToString() + Convert.ToChar(9) + dt.Rows[i]["companyname"].ToString() + Convert.ToChar(9) + dt.Rows[i]["distributor"].ToString() + Convert.ToChar(9) + dt.Rows[i]["subdistributor"].ToString() + Convert.ToChar(9) + dt.Rows[i]["statename"].ToString() + Convert.ToChar(9) + dt.Rows[i]["cityname"].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/" + "PartyLedgerLCO_" + datetime + ".xls"); } if (dt == null) { Response.Redirect("~/ErrorPage.aspx"); return; } }
protected void btnSubmit_Click(object sender, EventArgs e) { string from = txtFrom.Text; string to = txtTo.Text; DateTime fromDt; DateTime toDt; if (!String.IsNullOrEmpty(from) && !String.IsNullOrEmpty(to)) { fromDt = new DateTime(); toDt = new DateTime(); fromDt = DateTime.ParseExact(from, "dd-MMM-yyyy", null); toDt = DateTime.ParseExact(to, "dd-MMM-yyyy", null); if (toDt.CompareTo(fromDt) < 0) { lblSearchMsg.Text = "To date must be later than From date"; grdLcoPartyLedger.Visible = false; lblSearchMsg.ForeColor = System.Drawing.Color.Red; return; } else if (Convert.ToDateTime(txtFrom.Text.ToString()) > DateTime.Now.Date) { lblSearchMsg.Text = "You can not select date greater than current date!"; return; } else if (Convert.ToDateTime(txtTo.Text.ToString()) > DateTime.Now.Date) { lblSearchMsg.Text = "You can not select date greater than current date!"; return; } else { lblSearchMsg.Text = ""; grdLcoPartyLedger.Visible = true; } } Hashtable htAddPlanParams = getLedgerParamsData(); string username, catid, operator_id; if (Session["username"] != null || Session["operator_id"] != null) { username = Session["username"].ToString(); catid = Convert.ToString(Session["category"]); operator_id = ddlLco.SelectedValue; //Convert.ToString(Session["operator_id"]); } else { Session.Abandon(); Response.Redirect("~/Login.aspx"); return; } if (catid == "11") { Session["Soperatorid"] = operator_id; } Cls_Business_RptINVLedger objTran = new Cls_Business_RptINVLedger(); Hashtable htResponse = objTran.GetTransations(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;'>LCO Party Ledger Parameters : </b>" + strParams); lblSearchParams.Text = Server.HtmlDecode("<b style='color:#094791;'></b>" + strParams); } if (catid == "3") { if (dt.Rows.Count > 0) { Session["lconame"] = dt.Rows[0]["lconame"].ToString(); } else { Session["lconame"] = ""; } Response.Redirect("../Reports/rptINVPrePartyLedgerDET.aspx?showall=1"); } if (dt.Rows.Count == 0) { btn_genExl.Visible = false; grdLcoPartyLedger.Visible = false; lblSearchMsg.Text = "No data found"; } else { btn_genExl.Visible = true; grdLcoPartyLedger.Visible = true; lblSearchMsg.Text = ""; ViewState["searched_trans"] = dt; grdLcoPartyLedger.DataSource = dt; grdLcoPartyLedger.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 } }