539 lines
22 KiB
C#
539 lines
22 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.UI.WebControls;
|
|
using Extensiones;
|
|
using System.Data;
|
|
using static Extensiones.ModExtensiones;
|
|
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
|
|
{
|
|
#region PROPIEDADES
|
|
|
|
private DataTable DtIVATrasladado
|
|
{
|
|
get { return DtIVATrasladado = (DataTable)ViewState["DtIVATrasladado"]; }
|
|
set { ViewState["DtIVATrasladado"] = value; }
|
|
}
|
|
private DataTable DtIVAAcreditable
|
|
{
|
|
get { return DtIVAAcreditable = (DataTable)ViewState["DtIVAAcreditable"]; }
|
|
set { ViewState["DtIVAAcreditable"] = value; }
|
|
}
|
|
private DataTable DtIEPSA
|
|
{
|
|
get { return DtIVAAcreditable = (DataTable)ViewState["DtIEPSA"]; }
|
|
set { ViewState["DtIEPSA"] = value; }
|
|
}
|
|
private DataTable DtIVAA
|
|
{
|
|
get { return DtIVAAcreditable = (DataTable)ViewState["DtIVAA"]; }
|
|
set { ViewState["DtIVAA"] = value; }
|
|
}
|
|
private double TCEspecifico
|
|
{
|
|
get { return TCEspecifico = (double)ViewState["TCEspecifico"]; }
|
|
set { ViewState["TCEspecifico"] = value; }
|
|
}
|
|
|
|
private int TipoCambio
|
|
{
|
|
get { return TipoCambio = (int)ViewState["TipoCambio"]; }
|
|
set { ViewState["TipoCambio"] = value; }
|
|
}
|
|
|
|
#endregion
|
|
protected void Page_Load(object sender, EventArgs e)
|
|
{
|
|
if (!IsPostBack)
|
|
{
|
|
InicializaValores();
|
|
}
|
|
}
|
|
|
|
public void InicializaValores()
|
|
{
|
|
TipoCambio = 1;
|
|
TCEspecifico = -1;
|
|
DateTime FF = DateTime.Now.AddMonths(-1);
|
|
txtFechaI.Text = $"01/{FF.Month}/{FF.Year}";
|
|
txtFechaF.Text = FF.ToShortDateString();
|
|
|
|
LnkAccionesDIOT.Visible = true;
|
|
|
|
DdlCuenta.DataSource = get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:UsuarioActual.CveEmpresa, CveTipoCuenta:2);
|
|
DdlCuenta.DataBind();
|
|
DdlCuenta.Items.Insert(0, new ListItem("Todos", "-1"));
|
|
}
|
|
|
|
public void Consulta()
|
|
{
|
|
if (TipoCambio == 3 && TxtEspecifico.Text != "") { TCEspecifico = TxtEspecifico.Text.ToDouble(); } else { TCEspecifico = -1; }
|
|
int Conciliado = DdlTipoMovto.SelectedValue.ToEntero();
|
|
LblMsgAcreditable.Text = ""; // lbl de mensajes de negativos
|
|
|
|
ClsContabilidad ObjCont = new ClsContabilidad();
|
|
if (ObjCont.GetRepIVA(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), 1, UsuarioActual.CveUsuario, DdlCuenta.SelectedValue.ToEntero(), Conciliado, UsuarioActual.CveEmpresa, TipoCambio, TCEspecifico))
|
|
{
|
|
GvT.DataSource = ObjCont.DtResultados;
|
|
DtIVATrasladado = ObjCont.DtResultados;
|
|
if (ObjCont.GetRepIVAAcumulado(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), Conciliado, 1, DdlCuenta.SelectedValue.ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
GvIEPSA.DataSource = ObjCont.DtResultados;
|
|
DtIEPSA = ObjCont.DtResultados;
|
|
}
|
|
|
|
if (ObjCont.GetRepIVAAcumulado(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), Conciliado, 2, DdlCuenta.SelectedValue.ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
GvIVAA.DataSource = ObjCont.DtResultados;
|
|
DtIVAA = ObjCont.DtResultados;
|
|
}
|
|
|
|
}
|
|
if (ObjCont.GetRepIVA(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), 2, UsuarioActual.CveUsuario, DdlCuenta.SelectedValue.ToEntero(), Conciliado, UsuarioActual.CveEmpresa, TipoCambio, TCEspecifico))
|
|
{
|
|
GvA.DataSource = ObjCont.DtResultados;
|
|
DtIVAAcreditable = ObjCont.DtResultados;
|
|
if (DtIVAAcreditable.FiltraParametros("IVA < 0 OR IEPS < 0 ").Rows.Count > 0)
|
|
{
|
|
LblMsgAcreditable.Text = "La información presenta importes en negativo, estos no se incluirán en el archivo generado para DIOT";
|
|
}
|
|
|
|
GvA.Columns[11].Visible = DtIVAAcreditable.SUM("valorActosImp1516") > 0; // sino tiene valor la columna de importación de oculta
|
|
|
|
|
|
if (ObjCont.GetRepIVAAcumulado(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), Conciliado, 3, DdlCuenta.SelectedValue.ToEntero(), UsuarioActual.CveUsuario, UsuarioActual.CveEmpresa))
|
|
{
|
|
GvIVA2.DataSource = ObjCont.DtResultados;
|
|
}
|
|
|
|
|
|
}
|
|
ObjCont.Dispose();
|
|
GvT.DataBind();
|
|
GvA.DataBind();
|
|
GvIEPSA.DataBind();
|
|
GvIVAA.DataBind();
|
|
GvIVA2.DataBind();
|
|
UpDatos.Update();
|
|
|
|
String Str = "Se Consultó el Reporte de IVA. - " + UsuarioActual.Usuario;
|
|
Str.GuardaLog();
|
|
|
|
}
|
|
|
|
protected void BtnConsultar_Click(object sender, EventArgs e)
|
|
{
|
|
Consulta();
|
|
}
|
|
|
|
protected void GvIVATrasladado_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DBCampo("CveVenta").ToEntero() < 1)
|
|
{
|
|
e.Row.CssClass = "Totales";
|
|
e.Row.FCLabel("LblFechaDocumento").Visible = false;
|
|
e.Row.FCLabel("LblFecha").Visible = false;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void GvIVAAcreditable_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DBCampo("CveCompra").ToEntero() < 1)
|
|
{
|
|
e.Row.CssClass = "Totales";
|
|
|
|
|
|
}
|
|
if (e.Row.DBCampo("PorcentajeIVA").ToDecimal() > 0)
|
|
{
|
|
Decimal SubTotal = (e.Row.DBCampo("SubTotal16").ToDecimal() != 0 ? e.Row.DBCampo("SubTotal16").ToDecimal() : (e.Row.DBCampo("SubTotal8").ToDecimal() != 0 ? e.Row.DBCampo("SubTotal8").ToDecimal() : (Decimal)0.0));
|
|
|
|
Decimal dif = Math.Round(SubTotal * e.Row.DBCampo("PorcentajeIVA").ToDecimal(), 2) - Math.Round(e.Row.DBCampo("IVA").ToDecimal() + Math.Round(e.Row.DBCampo("IVANoDeducible").ToDecimal()), 2);
|
|
if (Math.Abs(dif) > 1)
|
|
{
|
|
e.Row.ForeColor = System.Drawing.Color.Red;
|
|
e.Row.Cells[0].Text = e.Row.Cells[0].Text + "Err";
|
|
|
|
e.Row.ToolTip = "Dif:" + dif.ToString() + "- Sub:" + SubTotal + " - IVA:" + e.Row.DBCampo("IVA");
|
|
}
|
|
}
|
|
if (e.Row.DBCampo("IVA").ToDecimal() < 0 || e.Row.DBCampo("IEPS").ToDecimal() < 0 || e.Row.DBCampo("SubTotal16").ToDecimal() < 0 || e.Row.DBCampo("SubTotal8").ToDecimal() < 0 || e.Row.DBCampo("valorActosImp0").ToDecimal() < 0)
|
|
{
|
|
e.Row.ForeColor = System.Drawing.Color.Red;
|
|
}
|
|
}
|
|
}
|
|
|
|
protected void LnkPdf_Click(object sender, EventArgs e)
|
|
{
|
|
Imprimir("PDF");
|
|
}
|
|
|
|
protected void LnkExcel_Click(object sender, EventArgs e)
|
|
{
|
|
Imprimir("EXCEL");
|
|
}
|
|
protected void LnkExcel2_Click(object sender, EventArgs e)
|
|
{
|
|
Imprimir("EXCEL2");
|
|
}
|
|
|
|
public void Imprimir(String Opcion)
|
|
{
|
|
String FechaF;
|
|
if (txtFechaF.Text == "" || txtFechaF.Text == "__/__/____") { FechaF = "-1"; } else { FechaF = $" <b>Fecha Final:</b> {txtFechaF.Text}"; }
|
|
String FechaI;
|
|
if (txtFechaI.Text == "" || txtFechaI.Text == "__/__/____") { FechaI = "-1"; } else { FechaI = $" <b>Fecha Inicial:</b> {txtFechaI.Text}"; }
|
|
String TipoMov;
|
|
if (DdlTipoMovto.SelectedItem.Text == "Todos") { TipoMov = ""; } else { TipoMov = $" <b>Tipo Movimiento:</b> {DdlTipoMovto.SelectedItem.Text}"; }
|
|
|
|
if (GvT.Rows.Count > 0 || GvA.Rows.Count > 0)
|
|
{
|
|
System.IO.FileInfo Imagen;
|
|
// String logouri = "";
|
|
|
|
if (UsuarioActual.CveEmpresa.Contiene(119))
|
|
{
|
|
Imagen = new System.IO.FileInfo(String.Format("{0}/Logo.jpg", UsuarioActual.Empresa.Ruta));
|
|
//logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.jpg", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa);
|
|
}
|
|
else
|
|
{
|
|
Imagen = new System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png");
|
|
//logouri = String.Format("{0}://{1}:{2}/Empresas/{3}/Logo.png", Request.Url.Scheme, Request.Url.Host, Request.Url.Port, UsuarioActual.CveEmpresa);
|
|
}
|
|
|
|
List<CrystalParametro> para = new List<CrystalParametro>();
|
|
para.Add(new CrystalParametro("Empresa", UsuarioActual.Empresa.Empresa));
|
|
para.Add(new CrystalParametro("UsuarioImprimio", UsuarioActual.Nombre));
|
|
para.Add(new CrystalParametro("Filtros", $"<b>Filtros:</b> {FechaI}{FechaF}{TipoMov}"));
|
|
if (Imagen.Exists)
|
|
{
|
|
para.Add(new CrystalParametro("LogoPath", Imagen.FullName));
|
|
}
|
|
else
|
|
{
|
|
para.Add(new CrystalParametro("LogoPath", ""));
|
|
}
|
|
GvT.DataSource = DtIVATrasladado;
|
|
GvT.DataBind();
|
|
UpDatos.Update();
|
|
DataTable Dt = TT.ActiveTabIndex == 0 ? DtIVATrasladado.Copy() : DtIVAAcreditable.Copy();
|
|
string Formato = TT.ActiveTabIndex == 0 ? "RepIVA.rpt" : (Opcion == "EXCEL2" ? "RepIVAAcreditable2.rpt" : "RepIVAAcreditable.rpt");
|
|
Opcion = (Opcion == "EXCEL2" ? "EXCEL" : Opcion);
|
|
para.Add(new CrystalParametro("Excel", Formato));
|
|
para.Add(new CrystalParametro("Formato", Opcion));
|
|
System.IO.FileInfo Archivo = new System.IO.FileInfo(string.Format("{0}/Formatos/{1}", UsuarioActual.Empresa.Ruta, Formato));
|
|
string Ruta;// = (Archivo.Exists ? string.Format("{0}/{1}", UsuarioActual.Empresa.Ruta, Formato ): ModExtensiones.DirectorioBaseEmpresas + $@"Empresas\Grales\Formatos\{Formato}");
|
|
|
|
//Alert(string.Format("{0}Formatos\\{1}", UsuarioActual.Empresa.Ruta, Formato));
|
|
if (Archivo.Exists)
|
|
{
|
|
Ruta = string.Format("{0}Formatos\\{1}", UsuarioActual.Empresa.Ruta, Formato);
|
|
ImprimirbytesPDF(ImprimirPDFCrystal(Ruta, Dt, para, "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
|
|
}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);
|
|
|
|
|
|
}
|
|
Ruta.GuardaLogAD();
|
|
//ImprimirbytesPDF(ImprimirPDFCrystal(Ruta, Dt, para, "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
|
|
}
|
|
else
|
|
{
|
|
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia);
|
|
}
|
|
}
|
|
|
|
protected void BtnTipoCambio_Click(object sender, EventArgs e)
|
|
{
|
|
Consulta();
|
|
RegistraScript(String.Format("$('#{0}').modal('hide');", "DivTipoCambio"));
|
|
}
|
|
|
|
protected void RblTipoCambio_SelectedIndexChanged(object sender, EventArgs e)
|
|
{
|
|
TipoCambio = RblTipoCambio.SelectedValue.ToEntero();
|
|
if (TipoCambio == 3)
|
|
{
|
|
LiEspecifico.Visible = true;
|
|
TCEspecifico = get_GlobalTipoCambio(DateTime.Now).ToString().ToDouble();
|
|
TxtEspecifico.Text = TCEspecifico.ToString();
|
|
}
|
|
else
|
|
{
|
|
LiEspecifico.Visible = false;
|
|
}
|
|
UpBodyTipoCambio.Update();
|
|
}
|
|
|
|
|
|
protected string GenerarDIOT()
|
|
{
|
|
System.Text.StringBuilder Respuesta = new System.Text.StringBuilder();
|
|
|
|
|
|
|
|
return Respuesta.ToString();
|
|
}
|
|
|
|
protected void LnkAccionesDIOT_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
ClsContabilidad Objconta = new ClsContabilidad();
|
|
StringBuilder SBDIOT = new StringBuilder();
|
|
int Conciliado = DdlTipoMovto.SelectedValue.ToEntero();
|
|
|
|
if (Objconta.GetRepIVA(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), 2, UsuarioActual.CveUsuario, -1, Conciliado, UsuarioActual.CveEmpresa, TipoCambio, TCEspecifico))
|
|
{
|
|
|
|
foreach (DataRow Drow in Objconta.DtResultados.FiltraParametros("CveCompra is null and CveProveedor > 0 and SubTotal >= 1 ").Rows) // and(IVA > 1 OR IEPS > 0)
|
|
{
|
|
SBDIOT.AppendLine(
|
|
Drow["TipoTercero"].ToString() + "|" +
|
|
Drow["TipoOperacion"].ToString() + "|" +
|
|
Drow["RFC"].ToString() + "|" +
|
|
Drow["NumeroIDFiscal"].ToString() + "|" +
|
|
Drow["NombreExtranjero"].ToString() + "|" +
|
|
Drow["PaisResidencia"].ToString() + "|" +
|
|
Drow["Nacionalidad"].ToString() + "|" +
|
|
LV(Drow["valorActos1516"].ToString()) + "|" +
|
|
LV(Drow["valorActos15"].ToString()) + "|" +
|
|
LV(Drow["ValorIvaNo1516"].ToString()) + "|" +
|
|
|
|
LV(Drow["valorActos1011"].ToString()) + "|" +
|
|
LV(Drow["valorActos10"].ToString()) + "|" +
|
|
LV(Drow["valorActosImp8"].ToString()) + "|" +
|
|
LV(Drow["ValorIvaNo10"].ToString()) + "|" +
|
|
LV(Drow["ValorIvaNo08"].ToString()) + "|" +
|
|
|
|
LV(Drow["valorActosImp1516"].ToString()) + "|" +
|
|
LV(Drow["ValorIvaNoImp16"].ToString()) + "|" +
|
|
|
|
LV(Drow["valorActosImp10"].ToString()) + "|" +
|
|
LV(Drow["ValorIvaNoImp10"].ToString()) + "|" +
|
|
|
|
LV(Drow["IvaExentoImpo"].ToString()) + "|" +
|
|
LV(Drow["IVACero"].ToString()) + "|" +
|
|
LV(Drow["IvaExento"].ToString()) + "|" +
|
|
LV(Drow["IvaRetenido"].ToString()) + "|" +
|
|
LV(Drow["IvaDevoluciones"].ToString()) + "|");
|
|
}
|
|
}
|
|
|
|
Objconta.Dispose();
|
|
|
|
//MemoryStream ms = new MemoryStream();
|
|
//TextWriter tw = new StreamWriter(ms, System.Text.Encoding.UTF8);
|
|
|
|
//tw.Write(SBDIOT.ToString());
|
|
|
|
//tw.Flush();
|
|
|
|
//byte[] bytes = ms.ToArray();
|
|
//ms.Close();
|
|
|
|
//Response.Clear();
|
|
//Response.AppendHeader("Content-Length", text.Length.ToString());
|
|
//Response.ContentType = "text/plain";
|
|
//Response.AddHeader("content-disposition", $"attachment; filename=DIOT_{ txtFechaI.Text.ToDate().ToString("ddMMyyyy") }_{txtFechaI.Text.ToDate().ToString("ddMMyyyy") }.txt");
|
|
//Response.BinaryWrite(bytes);
|
|
//Response.End();
|
|
|
|
Response.Clear();
|
|
Response.ClearHeaders();
|
|
|
|
Response.AppendHeader("Content-Length", SBDIOT.ToString().Length.ToString());
|
|
Response.ContentType = "text/plain";
|
|
Response.AppendHeader("Content-Disposition", $"attachment;filename=DIOT_{ txtFechaI.Text.ToDate().ToString("ddMMyyyy") }_{txtFechaI.Text.ToDate().ToString("ddMMyyyy") }.txt");
|
|
|
|
Response.Write(SBDIOT.ToString());
|
|
Response.End();
|
|
}
|
|
|
|
|
|
|
|
protected void LnkModalCompara_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
ClsContabilidad Objconta = new ClsContabilidad();
|
|
|
|
int Conciliado = DdlTipoMovto.SelectedValue.ToEntero();
|
|
|
|
if (Objconta.GetRepIVAComparativo(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), UsuarioActual.CveUsuario, -1, Conciliado, UsuarioActual.CveEmpresa ))
|
|
{
|
|
GvCompara.DataSource = Objconta.DtResultados;
|
|
}
|
|
|
|
Objconta.Dispose();
|
|
GvCompara.DataBind();
|
|
RegistraScript("$('#ModalCompara').modal('show')");
|
|
UpCompara.Update();
|
|
}
|
|
|
|
|
|
protected string LV(string Valor)
|
|
{
|
|
return (Valor.ToDecimal() > 0) ? Valor.ToDecimal().ToString().FormatoNumero(0).Replace(",", string.Empty) : "";
|
|
}
|
|
|
|
protected void GvCompara_RowDataBound(object sender, GridViewRowEventArgs e)
|
|
{
|
|
if (e.Row.RowType == DataControlRowType.DataRow)
|
|
{
|
|
if (e.Row.DBCampo("FueConciliado") == "")
|
|
{
|
|
e.Row.CssClass = "SubTotales";
|
|
}
|
|
}
|
|
}
|
|
|
|
//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;
|
|
//}
|
|
|
|
|
|
} |