public JsonResult InitializeMonthlyRFCReport(IenumerableReportResult model, string param) { if (string.IsNullOrEmpty(param)) { return(Json(new { status = false, resCode = "0", msg = "Something went wrong with report parameters. Please re-generate report or contact support. Thank you." }, JsonRequestBehavior.AllowGet)); } string[] values = User.Identity.Name.Split('|'); ReportClass rptH = new ReportClass(); rptH.FileName = Server.MapPath("~/CrystalReport/rptDailyReport.rpt"); rptH.Load(); Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); rptH.Close(); rptH.Dispose(); rptH = null; Session["MonthlyRFCRptSession"] = stream; string pdfname = "daily-report" + DateTime.Now; return(Json(new { status = true, resCode = "1", msg = "Success", pdfName = pdfname }, JsonRequestBehavior.AllowGet)); }
public ActionResult DescargarReporteProyectos() { try { var proyectos = ProyectoCN.ListarProyectos(); var rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reportes/ProyectosListas.rpt"); rptH.Load(); rptH.SetDataSource(proyectos); Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); //En PDF Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); rptH.Dispose(); rptH.Close(); return(new FileStreamResult(stream, "application/pdf")); } catch (Exception ex) { throw; } }
public ActionResult DescargarVentaProductos() { try { var rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reportes/ReportesProductos/VentaProductos.rpt"); rptH.Load(); var connInfo = CrystalReportCnn.GetConnectionInfo(); TableLogOnInfo logOnInfo = new TableLogOnInfo(); Tables tables; tables = rptH.Database.Tables; foreach (Table table in tables) { logOnInfo = table.LogOnInfo; logOnInfo.ConnectionInfo = connInfo; table.ApplyLogOnInfo(logOnInfo); } Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); rptH.Dispose(); rptH.Close(); return(new FileStreamResult(stream, "application/pdf")); } catch (Exception) { throw; } }
public ActionResult DescargarReporteAsignaciones(int?id) { try { //var asignaciones = ProyectoCN.ListarAsignaciones(); var rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reportes/AsignacionReport.rpt"); rptH.Load(); if (id == null) { rptH.SetDataSource(ProyectoCN.ListarAsignaciones()); } else { rptH.SetDataSource(ProyectoCN.ListarAsignaciones(id.Value)); } Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); //En PDF Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); rptH.Dispose(); rptH.Close(); return(new FileStreamResult(stream, "application/pdf")); } catch (Exception ex) { throw; } }
public void PrintDocuments(IEnumerable <tblDocumentCommon> documents) { // сортируем по фио и приоритету печати // для пациента // 2 договора на продажу // товарный чек // 2 договора на услугу var xSortedDocs = (from doc in documents let docOrdPriority = (doc is tblDocumentProduct) ? 0 : ((doc is tblDocumentSalesReceipt) ? 1 : 2) orderby doc.ShortName, docOrdPriority select doc).ToList(); List <DocumentAdapter> xSource = new List <DocumentAdapter>(1); xSource.Add(null); foreach (tblDocumentCommon doc in xSortedDocs) { DocumentAdapter xPrintAdapter = new DocumentAdapter(doc); xSource[0] = xPrintAdapter; PrinterSettings xPrintsettings = (doc is tblDocumentSalesReceipt) ? SalesReceiptPrinterSettings : DefaultDocPrinterSettings; xPrintsettings.Copies = doc.CopiesCount; ReportClass xReport = GetReport(doc, xSource); try { xReport.PrintToPrinter(xPrintsettings, xPrintsettings.DefaultPageSettings, false); doc.Printed = true; doc.IsSelected = false; } finally { xReport.Dispose(); } } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { stop = true; if (rpt != null) { rpt.Close(); rpt.Dispose(); } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { if (rpt != null) { rpt.Close(); rpt.Dispose(); } if (thread != null) { thread.Abort(); } }
private void Page_Unload(object sender, EventArgs e) { if (cr != null) { cr.Close(); cr.Dispose(); GC.Collect(); } queryEncrypt = null; query = null; filtros = null; rpt = null; tipo = null; }
public JsonResult InitializeHistoryReport(IenumerableReportResult model, string param) { if (string.IsNullOrEmpty(param)) { return(Json(new { status = false, resCode = "0", msg = "Something went wrong with report parameters. Please re-generate report or contact support. Thank you." }, JsonRequestBehavior.AllowGet)); } string[] values = User.Identity.Name.Split('|'); string[] paramValue = param.Split('|'); ReportClass rptH = new ReportClass(); dsTransHistory ds = new dsTransHistory(); try { DataTable dt = ListToDataTable.ToDataTable(model.HistoryReport); rptH.FileName = Server.MapPath("~/CrystalReport/rptTransHistory.rpt"); rptH.Load(); ds.Tables[0].Merge(dt); rptH.SetDataSource(ds); rptH.SetParameterValue("@date", paramValue[0].Trim().ToUpper()); rptH.SetParameterValue("@printBy", paramValue[2].Trim()); rptH.SetParameterValue("@runDate", paramValue[1].Trim().ToUpper()); rptH.SetParameterValue("@TotalCredit", Convert.ToDecimal(paramValue[6].Trim())); rptH.SetParameterValue("@TotalDebit", Convert.ToDecimal(paramValue[4].Trim())); rptH.SetParameterValue("@EndingBalance", Convert.ToDecimal(paramValue[7].Trim())); rptH.SetParameterValue("@CreditCount", Convert.ToInt32(paramValue[5].Trim())); rptH.SetParameterValue("@DebitCount", Convert.ToInt32(paramValue[3].Trim())); } catch (Exception ex) { return(Json(new { status = false, resCode = "0", msg = ex.Message }, JsonRequestBehavior.AllowGet)); } Stream stream = rptH.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); rptH.Close(); rptH.Dispose(); rptH = null; Session["HistorySession"] = stream; string pdfname = "history-report" + DateTime.Now; return(Json(new { status = true, resCode = "1", msg = "Success", pdfName = pdfname }, JsonRequestBehavior.AllowGet)); }
void Report_Unload(object sender, EventArgs e) { try { ReportClass rc = source as ReportClass; if (rc != null) { rc.Dispose(); } this.OVSReportViewer.Dispose(); } catch (Exception ex) { ExceptionHelper.HandleException(ex); } }
public void imprimir(ReportClass reporte) { PrintDialog dialog1 = new PrintDialog(); if (dialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int copies = dialog1.PrinterSettings.Copies; int fromPage = dialog1.PrinterSettings.FromPage; int toPage = dialog1.PrinterSettings.ToPage; bool collate = dialog1.PrinterSettings.Collate; reporte.PrintOptions.PrinterName = dialog1.PrinterSettings.PrinterName; reporte.PrintToPrinter(copies, collate, fromPage, toPage); } reporte.Dispose(); dialog1.Dispose(); }
public void imprimir(ReportClass reporte)//recibe un objeto repor,abre el dilogo impresora y si da si va a sacar las opciones,llama al metodo impri repor de donde a donde { PrintDialog dialog1 = new PrintDialog(); if (dialog1.ShowDialog() == System.Windows.Forms.DialogResult.OK) { int copies = dialog1.PrinterSettings.Copies; int fromPage = dialog1.PrinterSettings.FromPage; int toPage = dialog1.PrinterSettings.ToPage; bool collate = dialog1.PrinterSettings.Collate; reporte.PrintOptions.PrinterName = dialog1.PrinterSettings.PrinterName; reporte.PrintToPrinter(copies, collate, fromPage, toPage); } reporte.Dispose(); dialog1.Dispose(); }
public ActionResult DescargarReporteEmpleado(int codigo, string algo) //public ActionResult DescargarReporteEmpleado(int codigo) { try { var rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reportes/EmpleadoReporte1.rpt"); rptH.Load(); // por parametro rptH.SetParameterValue("DptoId", codigo); //rptH.SetParameterValue("ParamAlgo", algo); // Report connection var connInfo = CrystalReportsCnn.GetConnectionInfo(); TableLogOnInfo logonInfo = new TableLogOnInfo(); Tables tables; tables = rptH.Database.Tables; foreach (Table table in tables) { logonInfo = table.LogOnInfo; logonInfo.ConnectionInfo = connInfo; table.ApplyLogOnInfo(logonInfo); } Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); // Descargar en PDF Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); rptH.Dispose(); rptH.Close(); return(new FileStreamResult(stream, "application/pdf")); // Descargar en Excel //Stream stream = rptH.ExportToStream(ExportFormatType.Excel); //stream.Seek(0, SeekOrigin.Begin); //return File(stream, "application/vnd.ms-excel", "empleadoRpt.xls"); } catch (Exception ex) { return(Json(new { ok = false, msg = ex.Message }, JsonRequestBehavior.AllowGet)); } }
public byte[] readRPT() { ReportClass rptH = new ReportClass(); try { ParameterDiscreteValue par; rptH.FileName = file; rptH.Load(); rptH.SetDataSource(listData["table"]); foreach (ReportDocument subreport in rptH.Subreports) { if (listData.ContainsKey(subreport.Name.Trim().ToLower())) { subreport.SetDataSource(listData[subreport.Name.Trim().ToLower()]); } } parameters = insencitiveParameter(); foreach (ParameterField field in rptH.ParameterFields) { if (parameters != null) { if (parameters.ContainsKey(field.Name.Trim().ToLower())) { par = new ParameterDiscreteValue(); par.Value = parameters[field.Name.Trim().ToLower()]; field.CurrentValues.Add(par); } } } System.IO.Stream stream = rptH.ExportToStream(this.type); byte[] buffer = new byte[stream.Length]; stream.Read(buffer, 0, (int)stream.Length); return buffer; } finally { rptH.Close(); rptH.Dispose(); } }
/* * sin parametro * public ActionResult DescargarReporte_empleado() * { * try * { * var rptH = new ReportClass(); * rptH.FileName = Server.MapPath("/Reportes/EmpleadoReporte.rpt"); * rptH.Load(); * * // Report connection * var conInfo = CrystalReportCn.GetConnectionInfo(); * TableLogOnInfo logonInfo = new TableLogOnInfo(); * Tables tables; * tables = rptH.Database.Tables; * foreach (Table table in tables) * { * logonInfo = table.LogOnInfo; * logonInfo.ConnectionInfo = conInfo; * table.ApplyLogOnInfo(logonInfo); * } * * Response.Buffer = false; * Response.ClearContent(); * Response.ClearHeaders(); * * Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); * rptH.Dispose(); * rptH.Close(); * return new FileStreamResult(stream, "application/pdf"); * * //Stream stream = rptH.ExportToStream(ExportFormatType.Excel); * //stream.Seek(0,SeekOrigin.Begin); * //return File(stream, "application/vnd.ms-excel","EmpleadoRpt.xls"); * } * catch (Exception ep) * { * * throw; * } * } */ //con parametro public ActionResult DescargarReporte_empleado(int Codigo, string algo) { try { var rptH = new ReportClass(); rptH.FileName = Server.MapPath("/Reportes/EmpleadoReporte.rpt"); rptH.Load(); rptH.SetParameterValue("IdDpto", Codigo); //rptH.SetParameterValue("Nuevo_Parametro", algo); // Report connection var conInfo = CrystalReportCn.GetConnectionInfo(); TableLogOnInfo logonInfo = new TableLogOnInfo(); Tables tables; tables = rptH.Database.Tables; foreach (Table table in tables) { logonInfo = table.LogOnInfo; logonInfo.ConnectionInfo = conInfo; table.ApplyLogOnInfo(logonInfo); } Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); Stream stream = rptH.ExportToStream(ExportFormatType.PortableDocFormat); rptH.Dispose(); rptH.Close(); return(new FileStreamResult(stream, "application/pdf")); //Stream stream = rptH.ExportToStream(ExportFormatType.Excel); //stream.Seek(0,SeekOrigin.Begin); //return File(stream, "application/vnd.ms-excel","EmpleadoRpt.xls"); } catch (Exception ep) { throw; } }
public ActionResult OutStationDuty() { var User = (User)Session["UserName"]; //return View(); ReportClass rpt = new ReportClass(); rpt.FileName = Server.MapPath("~/WebReport/Reports/rptOutStationDuty.rpt"); rpt.Load(); Dictionary <string, object> param = new Dictionary <string, object>(); param.Add("@ID", User.EmpCode); DataTable DT = Models.DAL.storedProc2(HRStoredProcedureName.usp_rpt_LeaveApplicationForm, param, DBName.HR); //string path = @"~\\WebReport\\DataSets\\dsLeaveApplicationFrom.xsd"; //DT.WriteXmlSchema(Server.MapPath(path)); rpt.SetDataSource(DT); Stream stream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat); //CLOSE REPORT OBJECT rpt.Close(); rpt.Dispose(); return(File(stream, "application/pdf")); }
public ActionResult DescargarReporteEmpleado() { try { var reportE = new ReportClass(); reportE.FileName = Server.MapPath("/Reports/EmpleadoOLE_DBReport.rpt"); reportE.Load(); //report connection var connInfo = CrystalReportsCnn.GetConnectionInfo(); TableLogOnInfo logonInfo = new TableLogOnInfo(); Tables tables; tables = reportE.Database.Tables; foreach (Table table in tables) { logonInfo = table.LogOnInfo; logonInfo.ConnectionInfo = connInfo; table.ApplyLogOnInfo(logonInfo); } Response.Buffer = false; Response.ClearContent(); Response.ClearHeaders(); //pdf Stream reportStream = reportE.ExportToStream(ExportFormatType.PortableDocFormat); reportE.Dispose(); reportE.Close(); return(new FileStreamResult(reportStream, "application/pdf ")); //Exel //Stream reportStream = reportE.ExportToStream(ExportFormatType.Excel); //reportStream.Seek(0, SeekOrigin.Begin); //return File(reportStream, "application/vnd.ms-exel","Empleados.xls"); } catch (Exception ex) { throw; } }
public static dynamic getReport(string reportType, System.Data.DataSet ds, DocumentDownloadSection param) { string mimeType = "", extension = ""; Stream stream = new MemoryStream(); ReportClass report = new ReportClass(); bool isValid = true; var rptSource = ds; if (string.IsNullOrEmpty(param.OperationName)) { isValid = false; } if (isValid) { string strRptPath = string.Empty; //if (param.OperationName.Equals("rptCostCenterWiseIncomeTaxYearly") || param.OperationName.Equals("rptCostCenterWiseIncomeNonTaxYearly")) //{ // strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/WebReport/Reports/") + param.OperationName + ".rpt"; //} //else //{ //} strRptPath = System.Web.HttpContext.Current.Server.MapPath("~/WebReport/Reports/") + param.OperationName + ".rpt"; //dsReport = rptSource.Copy(); report.FileName = strRptPath; //===========Data set===== //var path = "~//WebReport//DataSet//dsLeaveForm.xsd"; //ds.WriteXmlSchema(HostingEnvironment.MapPath(path)); report.Load(strRptPath); if (ds != null && ds.GetType().ToString() != "System.String") { report.SetDataSource(ds); if (param.OperationName.Equals("rptCostCenterWiseIncomeTaxYearly") || param.OperationName.Equals("rptCostCenterWiseIncomeNonTaxYearly")) { report.SetParameterValue("Option", param.IncomeTaxYear); report.SetParameterValue("Option1", param.FromMonth); report.SetParameterValue("Option2", param.ToMonth); report.SetParameterValue("Option3", param.AYear); } } if (reportType == "pdf") { mimeType = "application/pdf"; extension = ".pdf"; stream = report.ExportToStream(ExportFormatType.PortableDocFormat); } else if (reportType == "excel") { mimeType = "application/vnd.ms-excel"; extension = ".xls"; stream = report.ExportToStream(ExportFormatType.Excel); } else if (reportType == "word") { mimeType = "application/msword"; extension = ".doc"; stream = report.ExportToStream(ExportFormatType.WordForWindows); } else if (reportType == "RichText") { mimeType = "application/rtf"; extension = ".rtf"; stream = report.ExportToStream(ExportFormatType.RichText); } report.Close(); report.Dispose(); return(new { mimeType = mimeType, stream = stream, extension = extension }); } else { return("<H2>Nothing Found; </H2>"); } }