public bool ConsultarById() { DsGuiasPlanillaRemitoCliente ds = new DsGuiasPlanillaRemitoCliente(); SqlParameter pPlanillaRemitoClienteID = new SqlParameter("@PlanillaRemitoClienteID", this.PlanillaRemitoClienteID); Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "PlanillaRemitoClienteByIDSel", pPlanillaRemitoClienteID); if (ds.Datos.Rows.Count > 0) { DsGuiasPlanillaRemitoCliente.DatosRow dr = (DsGuiasPlanillaRemitoCliente.DatosRow)ds.Datos.Rows[0]; this.PlanillaRemitoClienteID = dr.PlanillaRemitoClienteID; this.Nombre = dr.IsNombreNull() ? "" : dr.Nombre; this.Apellido = dr.IsApellidoNull()?"": dr.Apellido; this.TipoDocumentoID = dr.IsTipoDocumentoIDNull()? 0:(SisPack.TipoDocumento)dr.TipoDocumentoID; this.NroDocumento = dr.IsNroDocumentoNull() ? 0: dr.NroDocumento; this.FechaRecepcionCliente = dr.IsFechaRecepcionClienteNull() ? Utiles.Fechas.FormatFechaYYYYMMDD("19000101"): dr.FechaRecepcionCliente; this.NroCajaArchivo = dr.IsNroCajaArchivoNull()? "" : dr.NroCajaArchivo; this.NroPlanillaRemito = dr.NroPlanillaRemito; return(true); } else { return(false); } }
private string ExportarPDF() { DataSet GenDS = new DataSet(); ReportDocument oRD = new ReportDocument(); ExportOptions oExO; DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions(); DsGuiasPlanillaRemitoCliente dsGuias = (DsGuiasPlanillaRemitoCliente)Session["DsGuiasPlanillaRemitoCliente"]; DsGuiasPlanillaRemitoCliente dsag = new DsGuiasPlanillaRemitoCliente(); //IUnidadVenta unidadVenta = UnidadVentaFactory.GetUnidadVenta(); //DsUnidadVentaTEntregaProductoServicio dsUVProductosServicios =unidadVenta.GetUnidadesProductosServicios(); int nroPlanilla = Convert.ToInt32(this.lblNroPlanillaRemitoCliente.Text); try { string sNombrePDF = Server.MapPath(".") + "/ReportesPDF/" + "PlanReCliente_" + nroPlanilla + "_" + this.AgenciaConectadaID + ".pdf"; string nombrePDf = "PlanReCliente_" + nroPlanilla + "_" + this.AgenciaConectadaID + ".pdf"; //Load report oRD.Load(Server.MapPath("." + "/Reportes/PlanillaRemCliente.rpt")); DsGuiasPlanillaRemitoCliente.GuiasRow[] dv = (DsGuiasPlanillaRemitoCliente.GuiasRow[])dsGuias.Guias.Select(""); DsGuiasPlanillaRemitoCliente.ComprobantesRow[] dw = (DsGuiasPlanillaRemitoCliente.ComprobantesRow[])dsGuias.Comprobantes.Select(""); //Creo un nuevo registro Datos DsGuiasPlanillaRemitoCliente.DatosRow db = (DsGuiasPlanillaRemitoCliente.DatosRow)dsag.Datos.NewDatosRow(); db.PlanillaRemitoClienteID = this.planillaRemitoClienteID; db.NroPlanillaRemito = nroPlanilla; db.RazonSocial = this.lblRazonSocial.Text; db.Fecha = Convert.ToDateTime(this.lblFecha.Text); dsag.Datos.AddDatosRow(db); foreach (DsGuiasPlanillaRemitoCliente.GuiasRow dr in dv) { dsag.Guias.ImportRow(dr); } foreach (DsGuiasPlanillaRemitoCliente.ComprobantesRow dr in dw) { dsag.Comprobantes.ImportRow(dr); } //dsag.Datos.ImportRow(db); oRD.SetDataSource(dsag); //Export to PDF oExDo.DiskFileName = sNombrePDF; oExO = oRD.ExportOptions; oExO.ExportDestinationType = ExportDestinationType.DiskFile; oExO.ExportFormatType = ExportFormatType.PortableDocFormat; oExO.DestinationOptions = oExDo; oRD.Export(); oRD.Close(); oRD.Dispose(); return(nombrePDf); } catch (Exception ex) { string mensaje = "Error al exportar a PDF: " + ex.Message; ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(mensaje); return(""); } finally { oRD.Close(); oRD.Dispose(); } }