private void LoadReport() { rsm = new ReportSourceManager(); DataColumn col = null; string[] str = new string[10]; str[0] = Session["Accounting_sPeriod"].ToString(); str[1] = Request.Cookies["CurrentUserInfo"]["login_name"]; str[2] = Session["PNLkey"].ToString(); string rsType = Request.QueryString["rs"]; string elt_num = Request.Cookies["CurrentUserInfo"]["elt_account_number"]; try { rsm.LoadDataSet(ds); rsm.LoadCompanyInfo(elt_num, Server.MapPath("../../../ClientLogos/" + elt_num + ".jpg")); rsm.LoadOtherInfo(str); rsm.WriteXSD(Server.MapPath("../../../CrystalReportResources/xsd/pnl.xsd")); rsm.TableRename("Invoice", "cTmp"); if (!rsm.BindNow(Server.MapPath("../../../CrystalReportResources/rpt/pnl_" + rsType + ".rpt"))) { Response.Write("failed to bind"); Response.End(); } } catch (Exception e) { Response.Write(e.ToString()); Response.End(); } }
protected void btnPDFExport_Click(object sender, EventArgs e) { FreightEasy.Accounting.APDispute myDs = new FreightEasy.Accounting.APDispute(); myDs.GetAllRecords(elt_account_number, Session["VENDOR"].ToString(), Session["SDATE"].ToString(), Session["EDATE"].ToString()); DataSet ds = myDs; ReportSourceManager rsm = null; try { rsm = new ReportSourceManager(); rsm.LoadDataSet(ds); rsm.LoadCompanyInfo(elt_account_number, Server.MapPath("../../../ClientLogos/" + elt_account_number + ".jpg")); rsm.WriteXSD(Server.MapPath("../../../CrystalReportResources/xsd/APDispute.xsd")); rsm.BindNow(Server.MapPath("../../../CrystalReportResources/rpt/APDispute.rpt")); Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("Content-disposition", "attachment;filename=APDispute_" + System.DateTime.Today.ToString("yyyy-MM-dd") + ".pdf"); MemoryStream oStream; oStream = (MemoryStream)rsm.getReportDocument().ExportToStream(ExportFormatType.PortableDocFormat); Response.BinaryWrite(oStream.ToArray()); } catch { } finally { rsm.CloseReportDocumnet(); Response.Flush(); Response.End(); } }
protected void PDFPrintButton_Click(object sender, EventArgs e) { PerformSearch(); try { rsm = new ReportSourceManager(); rsm.LoadDataSet(ds); rsm.LoadCompanyInfo(elt_account_number, Server.MapPath("../../ClientLogos/" + elt_account_number + ".jpg")); rsm.LoadOtherInfo(AddFilter()); rsm.WriteXSD(Server.MapPath("../../CrystalReportResources/xsd/customer_recap.xsd")); rsm.BindNow(Server.MapPath("../../CrystalReportResources/rpt/customer_recap.rpt")); Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("Content-disposition", "attachment;filename=customer_recap_" + System.DateTime.Today.ToString("yyyy-MM-dd") + ".pdf"); MemoryStream oStream; oStream = (MemoryStream)rsm.getReportDocument().ExportToStream(ExportFormatType.PortableDocFormat); Response.BinaryWrite(oStream.ToArray()); } catch { } finally { rsm.CloseReportDocumnet(); Response.Flush(); Response.End(); } }
protected void SENDMAIL(object sender, EventArgs e) { PerformSearch(); string fileLocation = "C://temp//Customer_daily_Recap_" + System.DateTime.Today.ToString("yyyy-MM-dd") + ".pdf"; string orgNum = hCustomerAcct.Value.ToString(); if (orgNum != "" && orgNum != "0") { try { File.Delete(fileLocation); rsm = new ReportSourceManager(); rsm.LoadDataSet(ds); rsm.LoadCompanyInfo(elt_account_number, Server.MapPath("../../ClientLogos/" + elt_account_number + ".jpg")); rsm.LoadOtherInfo(AddFilter()); rsm.WriteXSD(Server.MapPath("../../CrystalReportResources/xsd/customer_recap.xsd")); rsm.BindNow(Server.MapPath("../../CrystalReportResources/rpt/customer_recap.rpt")); Response.Clear(); MemoryStream oStream; oStream = (MemoryStream)rsm.getReportDocument().ExportToStream(ExportFormatType.PortableDocFormat); FileStream fs = new FileStream(fileLocation, FileMode.CreateNew, FileAccess.Write); fs.Write(oStream.ToArray(), 0, oStream.ToArray().Length); fs.Close(); oStream.Close(); } catch { } finally { //rsm.CloseReportDocumnet(); Response.Flush(); } reload.Value = "Y"; } }
protected void PDFPrintButton_Click(object sender, EventArgs e) { MakeDataSet("SOList", Session["currentSQL"].ToString()); try { rsm = new ReportSourceManager(); rsm.LoadDataSet(ds); rsm.LoadCompanyInfo(elt_account_number, Server.MapPath("../../ClientLogos/" + elt_account_number + ".jpg")); // XSD file is automatically gerated rsm.WriteXSD(Server.MapPath("../../CrystalReportResources/xsd/OnhandReport.xsd")); // This file needs to be created if (check1.Checked == true) { rsm.BindNow(Server.MapPath("../../CrystalReportResources/rpt/OnhandReport_customer.rpt")); } else { rsm.BindNow(Server.MapPath("../../CrystalReportResources/rpt/OnhandReport1.rpt")); } Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("Content-disposition", "attachment;filename=onhand_report.pdf"); //MemoryStream oStream; // using System.IO //oStream = (MemoryStream)rsm.getReportDocument().ExportToStream(ExportFormatType.PortableDocFormat); //Response.BinaryWrite(oStream.ToArray()); var rpt = rsm.getReportDocument(); System.IO.Stream oStream = null; byte[] byteArray = null; oStream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); Response.End(); rpt.Close(); rpt.Dispose(); } catch { } finally { rsm.CloseReportDocumnet(); Response.Flush(); Response.End(); } }
private void LoadReport() { rsm = new ReportSourceManager(); try { rsm.LoadDataSet(ds); rsm.WriteXSD(Server.MapPath("../../../CrystalReportResources/xsd/CompanySearch.xsd")); rsm.BindNow(Server.MapPath("../../../CrystalReportResources/rpt/CompanySearch.rpt")); } catch (Exception e) { Response.Write("Failed to Load"); Response.End(); } }
protected void ExcelPrintButton_Click(object sender, EventArgs e) { MakeDataSet("WrOutTable", Session["WrOutSQL"].ToString()); MakeDataSet("WrInTable", Session["WrInSQL"].ToString()); MakeDataSet("WrInOutTable", Session["WrInOutSQL"].ToString()); try { rsm = new ReportSourceManager(); rsm.LoadDataSet(ds); rsm.LoadCompanyInfo(elt_account_number, Server.MapPath("../../../ClientLogos/" + elt_account_number + ".jpg")); rsm.WriteXSD(Server.MapPath("../../CrystalReportResources/xsd/WrInOut.xsd")); if (check1.Checked == true) { if (listResultSelect.SelectedIndex == 1) { rsm.BindNow(Server.MapPath("../../CrystalReportResources/rpt/WarehouseINReport_customer.rpt")); } else if (listResultSelect.SelectedIndex == 2) { rsm.BindNow(Server.MapPath("../../CrystalReportResources/rpt/WarehouseOUTReport_customer.rpt")); } else { rsm.BindNow(Server.MapPath("../../CrystalReportResources/rpt/WRInOut_customer.rpt")); } } else { if (listResultSelect.SelectedIndex == 1) { rsm.BindNow(Server.MapPath("../../CrystalReportResources/rpt/WarehouseINReport.rpt")); } else if (listResultSelect.SelectedIndex == 2) { rsm.BindNow(Server.MapPath("../../CrystalReportResources/rpt/WarehouseOUTReport.rpt")); } else { rsm.BindNow(Server.MapPath("../../CrystalReportResources/rpt/WRInOut.rpt")); } } Response.Clear(); Response.Buffer = true; Response.ContentType = "application/pdf"; Response.AddHeader("Content-Type", "application/pdf"); Response.AddHeader("Content-disposition", "attachment;filename=In_and_Out.xls"); //MemoryStream oStream; // using System.IO //oStream = (MemoryStream)rsm.getReportDocument().ExportToStream(ExportFormatType.Excel); //Response.BinaryWrite(oStream.ToArray()); var rpt = rsm.getReportDocument(); System.IO.Stream oStream = null; byte[] byteArray = null; oStream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); byteArray = new byte[oStream.Length]; oStream.Read(byteArray, 0, Convert.ToInt32(oStream.Length - 1)); Response.ClearContent(); Response.ClearHeaders(); Response.ContentType = "application/pdf"; Response.BinaryWrite(byteArray); Response.Flush(); Response.Close(); Response.End(); rpt.Close(); rpt.Dispose(); } catch { } finally { rsm.CloseReportDocumnet(); Response.Flush(); Response.End(); } }