--Exportar excel
This commit is contained in:
@@ -1,23 +1,13 @@
|
||||
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 Extensiones;
|
||||
using Microsoft.Reporting.WebForms;
|
||||
using System.Activities.Expressions;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.IO;
|
||||
using CrystalDecisions.CrystalReports.Engine;
|
||||
using CrystalDecisions.Shared;
|
||||
using System.Diagnostics;
|
||||
using DocumentFormat.OpenXml.Drawing;
|
||||
using DocumentFormat.OpenXml.ExtendedProperties;
|
||||
using static Stimulsoft.Report.StiOptions;
|
||||
using System.Web.Services.Description;
|
||||
using System.Drawing;
|
||||
using System.Web.UI;
|
||||
using System.Web.UI.WebControls;
|
||||
using static Extensiones.ModExtensiones;
|
||||
|
||||
public partial class Contabilidad_RepIVA : ClsPaginas
|
||||
{
|
||||
@@ -75,7 +65,7 @@ public partial class Contabilidad_RepIVA : ClsPaginas
|
||||
LnkTxtDIOT.Visible = true;
|
||||
LnkExcelDIOT.Visible = true;
|
||||
|
||||
DdlCuenta.DataSource = get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa:UsuarioActual.CveEmpresa, CveTipoCuenta:2);
|
||||
DdlCuenta.DataSource = get_GlobalDTBancosCuentas(UsuarioActual.CveUsuario, CveEmpresa: UsuarioActual.CveEmpresa, CveTipoCuenta: 2);
|
||||
DdlCuenta.DataBind();
|
||||
DdlCuenta.Items.Insert(0, new ListItem("Todos", "-1"));
|
||||
}
|
||||
@@ -182,13 +172,13 @@ public partial class Contabilidad_RepIVA : ClsPaginas
|
||||
}
|
||||
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 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(e.Row.DBCampo("SubTotal16").ToDecimal() * 0.16M, 2) + Math.Round(e.Row.DBCampo("SubTotal8").ToDecimal() * 0.08M , 2) - Math.Round(e.Row.DBCampo("IVA").ToDecimal(), 2);
|
||||
Decimal dif = Math.Round(e.Row.DBCampo("SubTotal16").ToDecimal() * 0.16M, 2) + Math.Round(e.Row.DBCampo("SubTotal8").ToDecimal() * 0.08M, 2) - Math.Round(e.Row.DBCampo("IVA").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.ForeColor = System.Drawing.Color.Red;
|
||||
e.Row.Cells[0].Text = e.Row.Cells[0].Text + "Err";
|
||||
|
||||
e.Row.ToolTip = "Dif:" + dif.ToString() + " - IVA:" + e.Row.DBCampo("IVA");
|
||||
}
|
||||
@@ -202,19 +192,37 @@ public partial class Contabilidad_RepIVA : ClsPaginas
|
||||
|
||||
protected void LnkPdf_Click(object sender, EventArgs e)
|
||||
{
|
||||
Imprimir("PDF");
|
||||
ImprimirCrystal("PDF");
|
||||
}
|
||||
|
||||
protected void LnkExcel_Click(object sender, EventArgs e)
|
||||
{
|
||||
Imprimir("EXCEL");
|
||||
ImprimirGembox();
|
||||
}
|
||||
protected void LnkExcel2_Click(object sender, EventArgs e)
|
||||
{
|
||||
Imprimir("EXCEL2");
|
||||
ImprimirCrystal("EXCEL2");
|
||||
}
|
||||
|
||||
public void Imprimir(String Opcion)
|
||||
private void ImprimirGembox()
|
||||
{
|
||||
String FechaF;
|
||||
if (txtFechaF.Text == "" || txtFechaF.Text == "__/__/____") { FechaF = "-1"; } else { FechaF = $"Fecha Final: {txtFechaF.Text}"; }
|
||||
String FechaI;
|
||||
if (txtFechaI.Text == "" || txtFechaI.Text == "__/__/____") { FechaI = "-1"; } else { FechaI = $"Fecha Inicial: {txtFechaI.Text}"; }
|
||||
String TipoMov;
|
||||
if (DdlTipoMovto.SelectedItem.Text == "Todos") { TipoMov = ""; } else { TipoMov = $"Tipo Movimiento: {DdlTipoMovto.SelectedItem.Text}"; }
|
||||
|
||||
var filtros = $"Filtros: {FechaI} {FechaF} {TipoMov}";
|
||||
|
||||
GvA.ExportToExcelGembox("ReporteIVA", UsuarioActual, "Reporte de IVA", DatosFiltros: filtros);
|
||||
}
|
||||
public override void VerifyRenderingInServerForm(Control control)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void ImprimirStimulsoft()
|
||||
{
|
||||
String FechaF;
|
||||
if (txtFechaF.Text == "" || txtFechaF.Text == "__/__/____") { FechaF = "-1"; } else { FechaF = $" <b>Fecha Final:</b> {txtFechaF.Text}"; }
|
||||
@@ -226,7 +234,90 @@ public partial class Contabilidad_RepIVA : ClsPaginas
|
||||
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));
|
||||
}
|
||||
else
|
||||
{
|
||||
Imagen = new System.IO.FileInfo($"{UsuarioActual.Empresa.Ruta}/Logo.png");
|
||||
}
|
||||
|
||||
List<ReportParameter> para = new List<ReportParameter>();
|
||||
para.Add(new ReportParameter("Empresa", UsuarioActual.Empresa.Empresa));
|
||||
para.Add(new ReportParameter("UsuarioImprimio", UsuarioActual.Nombre));
|
||||
para.Add(new ReportParameter("Filtros", $"<b>Filtros:</b> {FechaI}{FechaF}{TipoMov}"));
|
||||
|
||||
if (Imagen.Exists)
|
||||
{
|
||||
para.Add(new ReportParameter("LogoPath", Imagen.FullName));
|
||||
}
|
||||
else
|
||||
{
|
||||
para.Add(new ReportParameter("LogoPath", ""));
|
||||
}
|
||||
|
||||
DataTable Dt = DtIVAAcreditable.Copy();
|
||||
string Formato = "RepIVAAcreditable.mrt";
|
||||
|
||||
|
||||
para.Add(new ReportParameter("Formato", "PDF"));
|
||||
|
||||
System.IO.FileInfo Archivo = new System.IO.FileInfo(string.Format("{0}/Formatos/{1}", UsuarioActual.Empresa.Ruta, Formato));
|
||||
string Ruta = ModExtensiones.DirectorioBaseEmpresas + $@"Empresas\Grales\Formatos\{Formato}";
|
||||
|
||||
List<ReportDataSource> lrds = new List<ReportDataSource>();
|
||||
|
||||
ReportDataSource rds = new ReportDataSource();
|
||||
rds.Name = "RepIVAAcreditable";
|
||||
rds.Value = Dt;
|
||||
lrds.Add(rds);
|
||||
|
||||
if (DtIEPSA != null)
|
||||
{
|
||||
ReportDataSource rds2 = new ReportDataSource();
|
||||
rds2.Name = "IEPSPorcentaje";
|
||||
rds2.Value = DtIEPSA;
|
||||
lrds.Add(rds2);
|
||||
}
|
||||
|
||||
if (DtIVAA != null)
|
||||
{
|
||||
ReportDataSource rds3 = new ReportDataSource();
|
||||
rds3.Name = "IVAPorcentaje";
|
||||
rds3.Value = DtIVAA;
|
||||
lrds.Add(rds3);
|
||||
}
|
||||
|
||||
string Extension = "pdf";
|
||||
|
||||
var bytes = StreamBytesStimul("Facturas", Ruta, lrds, para, NombreArchivo: "Reporte de IVA", Formato: "PDF", NombreDataSource: "DtDatos");
|
||||
|
||||
ImprimirbytesPDF(bytes, "Reporte de IVA", Formato, Content_Disposition: "attachment", Extension: Extension);
|
||||
|
||||
Ruta.GuardaLogAD();
|
||||
}
|
||||
else
|
||||
{
|
||||
Alert("No hay datos consultados", TipoMensaje.MsgAdvertencia);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void ImprimirCrystal(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))
|
||||
{
|
||||
@@ -277,7 +368,8 @@ public partial class Contabilidad_RepIVA : ClsPaginas
|
||||
//ImprimirbytesPDF(ImprimirPDFCrystal(Ruta, Dt, para, "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
|
||||
ImprimirbytesPDF(ImprimirSubRepPDFCrystal(Ruta, Dt, para, new DataTable(), new DataTable(), "RepIEPSPorcentaje.rpt", "RepIVAPorcentaje.rpt", "Reporte de IVA", Opcion), "Reporte de IVA", Opcion);
|
||||
}
|
||||
}else
|
||||
}
|
||||
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);
|
||||
@@ -582,7 +674,7 @@ public partial class Contabilidad_RepIVA : ClsPaginas
|
||||
|
||||
int Conciliado = DdlTipoMovto.SelectedValue.ToEntero();
|
||||
|
||||
if (Objconta.GetRepIVAComparativo(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), UsuarioActual.CveUsuario, -1, Conciliado, UsuarioActual.CveEmpresa ))
|
||||
if (Objconta.GetRepIVAComparativo(txtFechaI.Text.ToDate(), txtFechaF.Text.ToDate(), UsuarioActual.CveUsuario, -1, Conciliado, UsuarioActual.CveEmpresa))
|
||||
{
|
||||
GvCompara.DataSource = Objconta.DtResultados;
|
||||
}
|
||||
@@ -744,7 +836,7 @@ public partial class Contabilidad_RepIVA : ClsPaginas
|
||||
|
||||
protected void GvIEPSA_RowDataBound(object sender, GridViewRowEventArgs e)
|
||||
{
|
||||
if(e.Row.RowType == DataControlRowType.DataRow && e.Row.DataKey("PorcentajeIEPS").Trim() == "")
|
||||
if (e.Row.RowType == DataControlRowType.DataRow && e.Row.DataKey("PorcentajeIEPS").Trim() == "")
|
||||
{
|
||||
e.Row.Cells[0].Text = "Total";
|
||||
e.Row.Font.Bold = true;
|
||||
@@ -921,7 +1013,7 @@ public partial class Contabilidad_RepIVA : ClsPaginas
|
||||
TmpDIOT.Columns[50].ColumnName = "51 - Valor de actos o actividades 0%\r\n"; TmpDIOT.Columns[51].ColumnName = "52 -Valor de actos o actividades no objeto en territorio nacional\r\n";
|
||||
TmpDIOT.Columns[52].ColumnName = "53 - Valor de actos o actividades no objeto sin establecimiento en territorio nacional\r\n"; TmpDIOT.Columns[53].ColumnName = "54 - Efectos fiscales a los comprobantes de operaciones realizadas con el proveedor\r\n";
|
||||
|
||||
TmpDIOT.ExportToExcelG("DIOT_"+ txtFechaI.Text,"Reporte DIOT");
|
||||
TmpDIOT.ExportToExcelG("DIOT_" + txtFechaI.Text, "Reporte DIOT");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user