public DsEntidadByEjecutivoImprimir GetEntidadesByEjecutivo(int tipo, DateTime fechaDesde, DateTime fechaHasta) { try { DsEjecutivoCtaMasivo ds = new DsEjecutivoCtaMasivo(); DsEntidadByEjecutivoImprimir dsn = new DsEntidadByEjecutivoImprimir(); SqlParameter pEntidadID = new SqlParameter("@EntidadID", Utiles.BaseDatos.IntToSql(EntidadID)); SqlParameter pPersonalID = new SqlParameter("@PersonalID", Utiles.BaseDatos.IntToSql(PersonalID)); SqlParameter pFechaDesde = new SqlParameter("@FechaDesde", Utiles.BaseDatos.FechaToSql(fechaDesde)); SqlParameter pFechaHasta = new SqlParameter("@FechaHasta", Utiles.BaseDatos.FechaToSql(fechaHasta)); SqlParameter pCategoriaID = new SqlParameter("@CategoriaID", Utiles.BaseDatos.IntToSql(Categoria.CategoriaID)); if (tipo == 1) { Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "AgenciasByEjecutivoCuentaONE", pPersonalID, pEntidadID, pFechaDesde, pFechaHasta, pCategoriaID); } else { Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "ClientesByEjecutivoCuentaONE", pPersonalID, pEntidadID, pFechaDesde, pFechaHasta, pCategoriaID); } foreach (DsEjecutivoCtaMasivo.DatosRow dr in ds.Datos) { DsEntidadByEjecutivoImprimir.DatosRow drnc = dsn.Datos.NewDatosRow(); DsEntidadByEjecutivoImprimir.DetalleRow drnd = dsn.Detalle.NewDetalleRow(); if (dsn.Datos.Select("PersonalID = " + dr.PersonalID.ToString()).Length == 0) { drnc.Nombre = dr.Nombre; drnc.Legajo = dr.Legajo; drnc.PersonalID = dr.PersonalID; } drnd.EntidadID = dr.EntidadID; drnd.Codigo = dr.Codigo; drnd.RazonSocial = dr.RazonSocial; drnd.Categoria = dr.Categoria; drnd.PersonalID = dr.PersonalID; dsn.Datos.AddDatosRow(drnc); dsn.Detalle.AddDetalleRow(drnd); } return(dsn); } catch (Exception ex) { throw ex; } }
private string ExportarPDF() { try { //DsEjecutivoCtaMasivo ds = new DsEjecutivoCtaMasivo(); /* * if(Session["DataSet"] != null) * ds = (DsEjecutivoCtaMasivo)Session["DataSet"]; * if(ds.Datos.Count == 0) * { * Exception ex = new Exception("No existen datos para imprimir"); * throw ex; * } */ IPersonal personal = PersonalFactory.GetPersonalFactory(); AdministrarGrillas.Configurar(dtgAgencia, "EntidadID", CantidadOpciones, true, false); DsEntidadByEjecutivoImprimir ds = new DsEntidadByEjecutivoImprimir(); if (rbtInterno.Checked) { personal.EntidadID = Utiles.Validaciones.obtieneEntero(Agencia1.AgenciaID); personal.PersonalID = Utiles.Validaciones.obtieneEntero(Interno1.PersonalID); personal.Categoria.CategoriaID = Utiles.Validaciones.obtieneEntero(ddlCategoriaA.SelectedValue); ds = personal.GetEntidadesByEjecutivo(1, Convert.ToDateTime(txtFechaDesde.Text), Convert.ToDateTime(txtFechaHasta.Text)); } else { personal.EntidadID = Utiles.Validaciones.obtieneEntero(Cliente1.ClienteID); personal.PersonalID = Utiles.Validaciones.obtieneEntero(Externo1.PersonalID); personal.Categoria.CategoriaID = Utiles.Validaciones.obtieneEntero(ddlCategoriaC.SelectedValue); ds = personal.GetEntidadesByEjecutivo(2, Convert.ToDateTime(txtFechaDesde.Text), Convert.ToDateTime(txtFechaHasta.Text)); } ReportDocument oRD = new ReportDocument(); ExportOptions oExO; DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions(); string nombArchi = "Ejecutivos_de_Cuenta.pdf"; string sNombrePDF = Server.MapPath(".") + "/ReportesPDF/" + nombArchi; if (System.IO.File.Exists(sNombrePDF)) { System.IO.File.Delete(sNombrePDF); } oRD.Load(Server.MapPath("." + "/Reportes/AsigancionMasivaEjecutivoCuenta.rpt")); oRD.SetDataSource(ds); oExDo.DiskFileName = sNombrePDF; oExO = oRD.ExportOptions; oExO.ExportDestinationType = ExportDestinationType.DiskFile; oExO.ExportFormatType = ExportFormatType.PortableDocFormat; oExO.DestinationOptions = oExDo; oRD.Export(); oRD.Close(); oRD.Dispose(); return(nombArchi); } catch (Exception ex) { string mensaje = "Error al exportar a PDF: " + ex.Message; ((ErrorWeb)this.phErrores.Controls[0]).setMensaje(mensaje); return(""); } }