private string ExportarPDF() { try { DsPlanillaRedespacho ds = (DsPlanillaRedespacho)Session["DsPlanillaRedespacho"]; ReportDocument oRD = new ReportDocument(); ExportOptions oExO; DiskFileDestinationOptions oExDo = new DiskFileDestinationOptions(); string nombArchi = "PlanillaRedespacho_" + this.txtPlanillaRedespachoID.Text + "_" + this.AgenciaConectadaID + ".pdf"; string sNombrePDF = Server.MapPath(".") + "/ReportesPDF/" + nombArchi; if (System.IO.File.Exists(sNombrePDF)) { System.IO.File.Delete(sNombrePDF); } oRD.Load(Server.MapPath("." + "/Reportes/PlanillaRedespacho.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(""); } }
public void GuardarPlanilla(DsPlanillaRedespacho ds) { System.Data.SqlClient.SqlConnection conexion = new System.Data.SqlClient.SqlConnection(); System.Data.SqlClient.SqlTransaction transaccion; conexion.ConnectionString = Config.ConnectionString; conexion.Open(); transaccion = conexion.BeginTransaction(); try { SqlParameter pAgenciaID = new SqlParameter("@AgenciaID", Utiles.BaseDatos.IntToSql(AgenciaID)); SqlParameter pUsuarioID = new SqlParameter("@UsuarioID", Utiles.BaseDatos.IntToSql(UsuarioID)); PlanillaRedespachoID = Convert.ToInt32(Config.Conexion.EjecutarResultadoUnico("PlanillaRedespachoCabeceraINS", AgenciaID, UsuarioID)); if (PlanillaRedespachoID > 0) { GuardarDetallePlanilla(transaccion, ds); transaccion.Commit(); } else { transaccion.Rollback(); Exception ex = new Exception("No se pudo guardar la planilla"); throw ex; } } catch (Exception ex) { transaccion.Rollback(); throw ex; } }
public DsPlanillaRedespacho GetDataSetPlanillaRedespacho() { try { DsPlanillaRedespacho ds = new DsPlanillaRedespacho(); if (PlanillaRedespachoID > 0) { SqlParameter pPlanillaRedespachoID = new SqlParameter("@PlanillaRedespachoID", PlanillaRedespachoID); Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "RedespachosPlanillaRedespachoCabeceraONE", pPlanillaRedespachoID); Config.Conexion.LlenarTypeDataSet(ds.Detalle, System.Data.CommandType.StoredProcedure, "RedespachosPlanillaRedespachoDetalleONE", pPlanillaRedespachoID); return(ds); } else { SqlParameter pAgenciaID = new SqlParameter("@AgenciaID", Utiles.BaseDatos.IntToSql(AgenciaID)); Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "RedespachosPlanillaRedespachoCabeceraSEL", pAgenciaID); Config.Conexion.LlenarTypeDataSet(ds.Detalle, System.Data.CommandType.StoredProcedure, "RedespachosPlanillaRedespachoDetalleSEL", pAgenciaID); return(ds); } } catch (Exception ex) { throw ex; } }
private void BindGrid() { IRecepcionRedespacho redespacho = RecepcionRedespachoFactory.GetRecepcionRedespacho(); redespacho.AgenciaID = AgenciaConectadaID; AdministrarGrillas.Configurar(dtgPlanilla, "RedespachoID", CantidadOpciones); dtgPlanilla.CurrentPageIndex = Utiles.Validaciones.obtieneEntero(txtPagina.Text); DsPlanillaRedespacho ds = redespacho.GetDataSetPlanillaRedespacho(); dtgPlanilla.DataSource = ds.Detalle; Session["DsPlanillaRedespacho"] = ds; dtgPlanilla.DataBind(); }
public DsPlanillaRedespacho GetDataSetPlanillaConsul(DateTime fechaDesde, DateTime fechaHasta, int nroPlanilla) { try { DsPlanillaRedespacho ds = new DsPlanillaRedespacho(); SqlParameter pAgenciaID = new SqlParameter("@AgenciaID", Utiles.BaseDatos.IntToSql(AgenciaID)); SqlParameter pFechaDesde = new SqlParameter("@FechaDesde", Utiles.BaseDatos.FechaToSql(fechaDesde)); SqlParameter pFechaHasta = new SqlParameter("@FechaHasta", Utiles.BaseDatos.FechaToSql(fechaHasta)); SqlParameter pNroPlanilla = new SqlParameter("@NroPlanilla", Utiles.BaseDatos.IntToSql(nroPlanilla)); Config.Conexion.LlenarTypeDataSet(ds.Datos, System.Data.CommandType.StoredProcedure, "RedespachosPlanillaRedespachoCabeceraSEL", pAgenciaID, pFechaDesde, pFechaHasta, pNroPlanilla); return(ds); } catch (Exception ex) { throw ex; } }
private void BindGridGenerada() { DsPlanillaRedespacho ds = new DsPlanillaRedespacho(); ds = (DsPlanillaRedespacho)Session["DsPlanillaRedespacho"]; IRecepcionRedespacho redespacho = RecepcionRedespachoFactory.GetRecepcionRedespacho(); if (ds == null) { redespacho.PlanillaRedespachoID = Utiles.Validaciones.obtieneEntero(txtPlanillaRedespachoID.Text); ds = redespacho.GetDataSetPlanillaRedespacho(); } AdministrarGrillas.Configurar(dtgPlanillaGenerada, "RedespachoID", CantidadOpciones); dtgPlanillaGenerada.CurrentPageIndex = Utiles.Validaciones.obtieneEntero(txtPagina.Text); dtgPlanillaGenerada.DataSource = ds.Detalle; Session["DsPlanillaRedespacho"] = ds; dtgPlanillaGenerada.DataBind(); }
private void butGenerar_Click(object sender, System.EventArgs e) { try { IRecepcionRedespacho redespacho = RecepcionRedespachoFactory.GetRecepcionRedespacho(); redespacho.AgenciaID = AgenciaConectadaID; redespacho.UsuarioID = usuario.UsuarioID; DsPlanillaRedespacho ds = (DsPlanillaRedespacho)Session["DsPlanillaRedespacho"]; redespacho.GuardarPlanilla(ds); txtPlanillaRedespachoID.Text = redespacho.PlanillaRedespachoID.ToString(); butGenerar.Visible = false; butImprimir.Visible = true; } catch (Exception ex) { ((ErrorWeb)phErrores.Controls[0]).setMensaje(ex.Message); } }
private void GuardarDetallePlanilla(System.Data.SqlClient.SqlTransaction transaccion, DsPlanillaRedespacho ds) { try { SqlParameter pPlanillaRedespachoID = new SqlParameter("@PlanillaRedespachoID", PlanillaRedespachoID); foreach (DsPlanillaRedespacho.DetalleRow dr in ds.Detalle) { Config.Conexion.EjecutarSinResultados(transaccion, "PlanillaRedespachoDetalleINS", PlanillaRedespachoID, dr.RedespachoID); } } catch (Exception ex) { transaccion.Rollback(); throw ex; } }