formatos Rep iva generales recorregidos, GlobalDTTipoPeriodo

This commit is contained in:
Oscar Irigoyen
2023-03-17 18:33:23 -07:00
parent c0b827bd51
commit 50e09adb17
7 changed files with 186 additions and 24 deletions

View File

@@ -10,6 +10,9 @@ using Microsoft.Reporting.WebForms;
using System.Activities.Expressions;
using System.Text;
using System.IO;
using CrystalDecisions.CrystalReports.Engine;
using CrystalDecisions.Shared;
using System.Diagnostics;
public partial class Contabilidad_RepIVA : ClsPaginas
{
@@ -245,7 +248,11 @@ public partial class Contabilidad_RepIVA : ClsPaginas
}else
{
Ruta = ModExtensiones.DirectorioBaseEmpresas + $@"Empresas\Grales\Formatos\{Formato}";
ImprimirbytesPDF(ImprimirSubRepPDFCrystal(Ruta,Dt,para, DtIEPSA,DtIVAA,"RepIEPSPorcentaje.rpt","RepIVAPorcentaje.rpt", "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
ImprimirbytesPDF(ImprimirSubRepPDFCrystal(Ruta, Dt, para, DtIEPSA, DtIVAA, "RepIEPSPorcentaje.rpt", "RepIVAPorcentaje.rpt", "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
}
Ruta.GuardaLogAD();
//ImprimirbytesPDF(ImprimirPDFCrystal(Ruta, Dt, para, "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
@@ -398,4 +405,135 @@ public partial class Contabilidad_RepIVA : ClsPaginas
}
}
}
//public void IImprimirbytesPDF(byte[] bytes, string NombreArchivo = "Reporte", string Formato = "PDF", bool Descarga = false, string Content_Disposition = "attachment", string Extension = "")
//{
// // limpio ReportViwer
// string mimeType = null;
// // If Descarga Then
// // Try
// // bytes = bytes
// // File.WriteAllBytes(String.Format("{0}PDF/whatever.gif", UsuarioActual.Empresa.Ruta), img)
// // Catch ex As Exception
// // If UsuarioActual.CveRol = 1 Then
// // Alert(ex.Message, TipoMensaje.MsgAdvertencia)
// // Else
// // Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod'IMPDFclspag'", TipoMensaje.MsgAdvertencia)
// // End If
// // End Try
// // End If
// try
// {
// bytes = bytes;
// //Response.Buffer = true;
// //Response.Clear();
// //if (Formato == "PDF")
// // Response.ContentType = "application/pdf";
// //else
// // Response.ContentType = mimeType;
// //Response.ClearHeaders();
// //string fileExtension = "";
// //if (!string.IsNullOrEmpty(Extension))
// // fileExtension = Extension;
// //else
// // fileExtension = Formato == "PDF" ? "pdf" : "xls";
// //Response.AddHeader("content-disposition", string.Format("{0}; filename=\"{1}.{2}\"", Content_Disposition, NombreArchivo, fileExtension));
// //Response.BinaryWrite(bytes); // create the file
// //Response.Flush(); // send it to the client to download
// //bytes = null;
// //HttpContext.Current.Response.SuppressContent = true;
// //HttpContext.Current.ApplicationInstance.CompleteRequest();
// Alert("ok");
// }
// // HttpContext.Current.Response.End()
// catch (Exception ex)
// {
// if (UsuarioActual.CveRol == 1) {
// }
// else
// Alert("Ocurrió un error al generar la descarga. Favor de contactar a soporte tecnico cod:'IMPDFclspag'", TipoMensaje.MsgAdvertencia);
// }
//}
//public byte[] IImprimirSubRepPDFCrystal(string RutaReporte, DataTable DataSource, List<CrystalParametro> Parametros, DataTable DataSource1, DataTable DataSource2, string SubRep1, string SubRep2, string NombreArchivo = "Reporte", string Formato = "PDF", ReportDocument MR = null/* TODO Change to default(_) if this is not a reference type */)
//{
// // limpio ReportViwer
// Stopwatch sw = Stopwatch.StartNew();
// if (MR == null)
// MR = new ReportDocument();
// ReportDocument SR1 = new ReportDocument();
// ReportDocument SR2 = new ReportDocument();
// byte[] Bytes = null;
// ExportFormatType formatType = ExportFormatType.NoFormat;
// try
// {
// MR.Load(RutaReporte);
// SR1 = MR.OpenSubreport(SubRep1);
// SR2 = MR.OpenSubreport(SubRep2);
// MR.SetDataSource(DataSource);
// SR1.SetDataSource(DataSource1);
// SR2.SetDataSource(DataSource2);
// foreach (CrystalParametro item in Parametros)
// MR.SetParameterValue(item.Nombre, item.Valor);
// switch (Formato)
// {
// case "PDF":
// {
// formatType = ExportFormatType.PortableDocFormat;
// break;
// }
// case "EXCEL":
// {
// formatType = ExportFormatType.Excel;
// break;
// }
// }
// System.IO.Stream Stream = MR.ExportToStream(formatType);
// BinaryReader BD = new BinaryReader(MR.ExportToStream(formatType));
// Bytes = BD.ReadBytes(System.Convert.ToInt32(MR.ExportToStream(formatType).Length));
// BD.Dispose();
// Stream.Dispose();
// }
// // Dim Buffer(CInt(Stream.Length)) As Byte
// // Bytes = Buffer
// // MR.ExportToHttpResponse(formatType, Response, True, NombreArchivo)
// catch (CrystalReportsException ex)
// {
// if(ex.Message != null)
// {
// Alert(ex.Message);
// }
// if (ex.InnerException != null)
// {
// Alert(ex.InnerException.Message);
// }
// }
// // HAY QUE VALIDAR QUE LOS OBJETOS QUE SE USAN PARA GUARDAR LOG EXISTEN!!! IPP 14 AGOSTO 2017
// // GuardaLog($"Error: {ex.InnerException.Message} | Descripcion: {If(ex.InnerException.InnerException IsNot Nothing, ex.InnerException.InnerException.Message, "Sin descripcion")} - Ruta {RutaReporte}")
// catch (Exception ex)
// {
// //GuardaLog(ex.InnerException != null && ex.Message != null ? $"Error: {ex.InnerException.Message ?? ex.Message} | Descripcion: {ex.InnerException != null && ex.InnerException.InnerException != null && ex.InnerException.InnerException.Message != null ? ex.InnerException.InnerException.Message : ex.InnerException != null && ex.InnerException.Message != null ? ex.InnerException.Message : "Sin descripcion"} Ruta {RutaReporte}" : $"Sin descripción - Ruta {RutaReporte}");
// if (ex.Message != null)
// {
// Alert(ex.Message);
// }
// if (ex.InnerException != null)
// {
// Alert(ex.InnerException.Message);
// }
// }
// sw.Stop();
// if (sw.Elapsed.TotalSeconds > 10)
// // GuardaLog($"Reporte:{RutaReporte} | Tiempo Renderizado Milisegundos: {sw.ElapsedMilliseconds},Total Segundos: {sw.Elapsed.TotalSeconds} ");
// if (MR != null)
// MR.Dispose();
// return Bytes;
//}
}