protected void gridFacturaciones_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = gridFacturaciones.SelectedRow; string ruc = row.Cells[2].Text; string tipoMovimiento = row.Cells[3].Text == "Factura" ? "01" : "02"; int serie = 0; int nroLiquidacion = int.Parse(row.Cells[6].Text); DateTime fechaQuince = new DateTime(2017, 11, 15); if (DateTime.Parse(row.Cells[7].Text) < fechaQuince) { serie = int.Parse((row.Cells[4].Text) == "E001" ? "101" : row.Cells[4].Text); } DataTable _dtCabecera = _facturacionBll.ListarCabecera(ruc, tipoMovimiento, serie, nroLiquidacion); DataTable _dtDetalle = _facturacionBll.ListarDetalle(ruc, tipoMovimiento, serie, nroLiquidacion); DataTable _dtTotalPorContrato = _facturacionBll.ListarTotalesPorContrato(ruc, tipoMovimiento, serie, nroLiquidacion); if (_dtCabecera.Rows.Count == 0) { rptViewFactura.LocalReport.DataSources.Clear(); } else { ReportDataSource rdsCabecera = new ReportDataSource(); rdsCabecera.Name = "dsCabeceraFactura"; rdsCabecera.Value = _dtCabecera; ReportDataSource rdsDetalle = new ReportDataSource(); rdsDetalle.Name = "dsDetalleFactura"; rdsDetalle.Value = _dtDetalle; ReportDataSource rdsTotalPorContrato = new ReportDataSource(); rdsTotalPorContrato.Name = "dsTotalPorContratoFactura"; rdsTotalPorContrato.Value = _dtTotalPorContrato; ReportParameter[] parametros = new ReportParameter[1]; parametros[0] = new ReportParameter("Factura", (tipoMovimiento == "01").ToString()); rptViewFactura.LocalReport.DataSources.Clear(); rptViewFactura.LocalReport.DataSources.Add(rdsCabecera); rptViewFactura.LocalReport.DataSources.Add(rdsDetalle); rptViewFactura.LocalReport.DataSources.Add(rdsTotalPorContrato); rptViewFactura.LocalReport.SetParameters(parametros); rptViewFactura.LocalReport.Refresh(); } }
protected void gridLiquidaciones_SelectedIndexChanged(object sender, EventArgs e) { GridViewRow row = gridLiquidaciones.SelectedRow; string tipoMovimiento = row.Cells[2].Text == "Factura" ? "01" : "02"; int serie = int.Parse(row.Cells[3].Text); int nroLiquidacion = int.Parse(row.Cells[4].Text); //Crear y mostrar PDF DataTable _dtCabecera = _facturacionBll.ListarCabecera(txtCodProveedor.Text, tipoMovimiento, serie, nroLiquidacion); DataTable _dtDetalle = _facturacionBll.ListarDetalle(txtCodProveedor.Text, tipoMovimiento, serie, nroLiquidacion); DataTable _dtTotalPorContrato = _facturacionBll.ListarTotalesPorContrato( txtCodProveedor.Text, tipoMovimiento, serie, nroLiquidacion); if (_dtCabecera.Rows.Count == 0) { rptViewFactura.LocalReport.DataSources.Clear(); } else { ReportDataSource rdsCabecera = new ReportDataSource(); rdsCabecera.Name = "dsCabeceraFactura"; rdsCabecera.Value = _dtCabecera; ReportDataSource rdsDetalle = new ReportDataSource(); rdsDetalle.Name = "dsDetalleFactura"; rdsDetalle.Value = _dtDetalle; ReportDataSource rdsTotalPorContrato = new ReportDataSource(); rdsTotalPorContrato.Name = "dsTotalPorContratoFactura"; rdsTotalPorContrato.Value = _dtTotalPorContrato; ReportParameter[] parametros = new ReportParameter[1]; parametros[0] = new ReportParameter("Factura", (tipoMovimiento == "01").ToString()); rptViewFactura.LocalReport.DataSources.Clear(); rptViewFactura.LocalReport.DataSources.Add(rdsCabecera); rptViewFactura.LocalReport.DataSources.Add(rdsDetalle); rptViewFactura.LocalReport.DataSources.Add(rdsTotalPorContrato); rptViewFactura.LocalReport.SetParameters(parametros); rptViewFactura.LocalReport.Refresh(); } string archivo = "T" + txtCodProveedor.Text + "_" + usuarioActual; //Si no existe, creamos el documento string nombrepdf = ExportReportToPDF(archivo); if (nombrepdf != string.Empty) { //Cargamos el PDFViewer string server = ConfigurationManager.AppSettings["servidor"]; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "CargarDocumento('" + nombrepdf + "', '" + server + "');", true); } else { //lblMensajeError.Visible = true; ScriptManager.RegisterStartupScript(this, typeof(Page), "invocarfuncion", "CargarDocumento();", true); } }