public ActionResult DowndZip(string corr_planificacion) { Int64 nroTarja = 0; string planDescJson = new PlanificacionDescBLL().sp_selPlanDescIDBLL(corr_planificacion); PlanificacionDescBO planDesc = new PlanificacionDescBO(); planDesc = JsonConvert.DeserializeObject <PlanificacionDescBO>(planDescJson); TarjaDescDetBO tarja = new TarjaDescDetBLL().sp_sel_tarjaDescDetBLL(corr_planificacion); nroTarja = tarja.Nro_tarja; string contenedor = planDesc.Cod_contenedor; var memoryStream = new ZipFotos().crearZip(nroTarja, planDesc.Fecha); byte[] byteInfo = memoryStream.ToArray(); memoryStream.Write(byteInfo, 0, byteInfo.Length); memoryStream.Position = 0; Response.Buffer = true; string base64string = Convert.ToBase64String(byteInfo); return(File(byteInfo, "application/gzip", contenedor + ".zip")); }
public ActionResult CrearPdf(string corr_planificacion) { Int64 nroTarja = 0; string planDescJson = new PlanificacionDescBLL().sp_selPlanDescIDBLL(corr_planificacion); PlanificacionDescBO planDesc = new PlanificacionDescBO(); planDesc = JsonConvert.DeserializeObject <PlanificacionDescBO>(planDescJson); TarjaDescDetBO tarja = new TarjaDescDetBLL().sp_sel_tarjaDescDetBLL(corr_planificacion); nroTarja = tarja.Nro_tarja; Document doc = new Document(PageSize.A4.Rotate()); MemoryStream outstreem = new MemoryStream(); string fileName = null; PdfWriter.GetInstance(doc, outstreem).CloseStream = false; doc.Open(); doc = new PdfDesco().BindingData(doc, planDesc, tarja); fileName = "reporte-" + nroTarja; doc.Close(); byte[] byteInfo = outstreem.ToArray(); outstreem.Write(byteInfo, 0, byteInfo.Length); outstreem.Position = 0; Response.Buffer = true; string base64string = Convert.ToBase64String(byteInfo); return(File(byteInfo, "application/pdf")); }
protected void btnGuardar_Click(object sender, EventArgs e) { if (!ValidarCamposBusqueda()) { llenarGrilla(); return; } DateTime date = DateTime.Today; Random rnd = new Random(); CorrelativoPlan = date.Year.ToString() + date.Month.ToString() + date.Day.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + "-" + date.Millisecond.ToString() + rnd.Next(0, 99999); DataTable dt = new DataTable(); PlanificacionDescBO plan = new PlanificacionDescBO(); plan.Bl = txtBL.Text; plan.Mddt = txtMddt.Text; plan.Cod_manifiesto = CorrelativoPlan; plan.Cod_agencia = Convert.ToInt32(ddlTerminal.SelectedValue); plan.Cod_nave = ddlNaves.SelectedValue; plan.Cod_viaje = Convert.ToInt32(txtViaje.Text); plan.Pue_codO = ddlOrigen.SelectedValue; plan.Pue_codD = ddlDestino.SelectedValue; plan.Rut_cliente = Convert.ToInt32(ddlCliente.SelectedValue); plan.Cod_iso = ddlISO.SelectedValue; plan.Estado_tarja = 1; plan.Cod_contenedor = txtContenedor.Text + txtContenedorNum.Text + txtContenedorDV.Text; plan.Sello1 = txtSello1.Text; plan.Sello2 = txtSello2.Text; plan.Sello3 = txtSello3.Text; plan.Fecha = DateTime.ParseExact(txtFecha.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); plan.HoraI = TimeSpan.ParseExact(txtHoraI.Text, @"h\:mm", CultureInfo.InvariantCulture); plan.HoraT = TimeSpan.ParseExact(txtHoraT.Text, @"h\:mm", CultureInfo.InvariantCulture); if (ddlTarjador.SelectedValue != "") { plan.Rut_tarjador = Convert.ToInt32(ddlTarjador.SelectedValue); } else { plan.Rut_tarjador = 0; } DateTime pass = DateTime.Today; plan.Desbloqueo_sello = pass.Month.ToString() + pass.Day.ToString(); try { dt = new PlanificacionDescBLL().sp_ins_planDescBLL(plan); } catch (Exception ex) { throw new Exception("Ha ocurrido el siguiente error: " + ex.ToString()); } llenarGrilla(); limpiarFormulario(); }
protected void btnModificar_Click(object sender, EventArgs e) { if (!ValidarCamposMod()) { return; } DateTime date = DateTime.Today; Random rnd = new Random(); CorrelativoPlan = date.Year.ToString() + date.Month.ToString() + date.Day.ToString() + date.Hour.ToString() + date.Minute.ToString() + date.Second.ToString() + "-" + date.Millisecond.ToString() + rnd.Next(0, 99999); DataTable dt = new DataTable(); PlanificacionDescBO plan = new PlanificacionDescBO(); plan.Bl = txtBlMod.Text; plan.Mddt = txtManoMod.Text; plan.Cod_manifiesto = corrPlan.Text; plan.Cod_agencia = Convert.ToInt32(ddlTermMod.SelectedValue); plan.Cod_nave = ddlNaveMod.SelectedValue; plan.Cod_viaje = Convert.ToInt32(txtViajeMod.Text); plan.Pue_codO = ddlPueOrMod.SelectedValue; plan.Pue_codD = ddlPueDesMod.SelectedValue; plan.Rut_cliente = Convert.ToInt32(ddlClienteMod.SelectedValue); plan.Cod_iso = ddlIsoMod.SelectedValue; plan.Estado_tarja = 1; plan.Cod_contenedor = txtNumContMod.Text + txtSiglaContMod.Text + txtDvContMod.Text; plan.Sello1 = txtSello1Mod.Text; plan.Sello2 = txtSello2Mod.Text; plan.Sello3 = txtSello3Mod.Text; plan.Fecha = DateTime.ParseExact(txtFechaMod.Text, "dd/MM/yyyy", CultureInfo.InvariantCulture); plan.HoraI = TimeSpan.ParseExact(txtHoraIMod.Text, @"h\:mm", CultureInfo.InvariantCulture); plan.HoraT = TimeSpan.ParseExact(txtHoraTMod.Text, @"h\:mm", CultureInfo.InvariantCulture); if (ddlTarjador.SelectedValue != "") { plan.Rut_tarjador = Convert.ToInt32(ddlTarjadorMod.SelectedValue); } else { plan.Rut_tarjador = 0; } DateTime pass = DateTime.Today; plan.Desbloqueo_sello = pass.Month.ToString() + pass.Day.ToString(); try { dt = new PlanificacionDescBLL().sp_updt_planDescBLL(plan); } catch (Exception ex) { throw new Exception("Ha ocurrido el siguiente error: " + ex.ToString()); } llenarGrilla(); }
public DataTable sp_ins_planDescDAL(PlanificacionDescBO planDesc) { DataTable dt = new DataTable(); try { parametros = new SqlParameter[20]; parametros[numParam] = new SqlParameter("@corr_planificacion", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Cod_manifiesto; parametros[numParam] = new SqlParameter("@gls_bl", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Bl; parametros[numParam] = new SqlParameter("@cod_puerto_or", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Pue_codO; parametros[numParam] = new SqlParameter("@cod_puerto_dest", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Pue_codD; parametros[numParam] = new SqlParameter("@gls_contenedor", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Cod_contenedor; parametros[numParam] = new SqlParameter("@cod_iso", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Cod_iso; parametros[numParam] = new SqlParameter("@gls_sello1", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Sello1; parametros[numParam] = new SqlParameter("@gls_sello2", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Sello2; parametros[numParam] = new SqlParameter("@gls_sello3", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Sello3; parametros[numParam] = new SqlParameter("@rut_cliente", SqlDbType.Int); parametros[numParam++].Value = planDesc.Rut_cliente; parametros[numParam] = new SqlParameter("@fecha", SqlDbType.Date); parametros[numParam++].Value = planDesc.Fecha; parametros[numParam] = new SqlParameter("@hora_in", SqlDbType.Time); parametros[numParam++].Value = planDesc.HoraI; parametros[numParam] = new SqlParameter("@hora_term", SqlDbType.Time); parametros[numParam++].Value = planDesc.HoraT; parametros[numParam] = new SqlParameter("@gls_mano_trabajo", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Mddt; parametros[numParam] = new SqlParameter("@cod_nave", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Cod_nave; parametros[numParam] = new SqlParameter("@n_viaje", SqlDbType.Int); parametros[numParam++].Value = planDesc.Cod_viaje; parametros[numParam] = new SqlParameter("@cod_terminal", SqlDbType.Int); parametros[numParam++].Value = planDesc.Cod_agencia; parametros[numParam] = new SqlParameter("@n_estado", SqlDbType.Int); parametros[numParam++].Value = planDesc.Estado_tarja; parametros[numParam] = new SqlParameter("@gls_desbloqueo_sello", SqlDbType.VarChar); parametros[numParam++].Value = planDesc.Desbloqueo_sello; parametros[numParam] = new SqlParameter("@rut_tarjador", SqlDbType.Int); parametros[numParam++].Value = planDesc.Rut_tarjador; dt = new AccesoBDDAL().mtdEjecutaProcedimientoAlmacenadoSel("sp_add_planDesco", parametros); } catch (Exception ex) { throw ex; } return(dt); }
public DataTable sp_updt_planDescBLL(PlanificacionDescBO planDesc) { DataTable dt = new DataTable(); try { dt = new PlanificacionDescDAL().sp_updt_planDescDAL(planDesc); } catch (Exception ex) { throw ex; } return(dt); }
public static void GuardarPlan(ref GlobalResponse globalResponse, string manifiesto, string bl, string mddt, string terminal, string contenedor, string nave, string viaje, string puertOr, string puerDest, string cliente, string iso, string sello, string fecha, string hInicio, string hTermino, string tarjador) { PlanificacionDescBO planDesc = new PlanificacionDescBO(); planDesc.Cod_manifiesto = manifiesto; planDesc.Bl = bl; planDesc.Mddt = mddt; planDesc.Cod_agencia = Convert.ToInt32(terminal); planDesc.Cod_nave = nave; planDesc.Cod_viaje = Convert.ToInt32(viaje); planDesc.Pue_codO = puertOr; planDesc.Pue_codD = puerDest; planDesc.Rut_cliente = Convert.ToInt32(cliente); planDesc.Cod_contenedor = contenedor; planDesc.Cod_iso = iso; planDesc.Sello1 = sello; DateTime fch = DateTime.ParseExact(fecha, "dd/MM/yyyy", CultureInfo.InvariantCulture); planDesc.Fecha = fch; TimeSpan horaIn = TimeSpan.ParseExact(hInicio, @"h\:mm", CultureInfo.InvariantCulture); TimeSpan horaTer = TimeSpan.ParseExact(hTermino, @"h\:mm", CultureInfo.InvariantCulture); planDesc.HoraI = horaIn; planDesc.HoraT = horaTer; planDesc.Desbloqueo_sello = fch.Month.ToString() + "" + fch.Day.ToString(); planDesc.Cod_manifiesto = manifiesto; planDesc.Estado_tarja = 1; planDesc.Rut_tarjador = Convert.ToInt32(tarjador); DataTable dt; try { dt = new PlanificacionDescBLL().sp_ins_planDescBLL(planDesc); } catch (Exception ex) { globalResponse.Message = ex.Message; globalResponse.HasError = true; } }
public Document BindingData(Document doc, PlanificacionDescBO planDesc, TarjaDescDetBO tarja) { string jsonCliente = JsonConvert.SerializeObject(new ForwardersBLL().sp_selPlanDesc_forwarderBLL(planDesc.Rut_cliente)); ForwardersBO cliente = JsonConvert.DeserializeObject <ForwardersBO>(jsonCliente.Trim(new char[] { '[', ']' })); string jsonNave = JsonConvert.SerializeObject(new NavesBLL().sp_sel_naveIDBLL(planDesc.Cod_nave)); NavesBO nave = JsonConvert.DeserializeObject <NavesBO>(jsonNave.Trim(new char[] { '[', ']' })); string jsonPuertoO = JsonConvert.SerializeObject(new PuertoBLL().sp_sel_puertoIDBLL(planDesc.Pue_codO)); PuertosBO puerto_or = JsonConvert.DeserializeObject <PuertosBO>(jsonPuertoO.Trim(new char[] { '[', ']' })); string jsonPuertoD = JsonConvert.SerializeObject(new PuertoBLL().sp_sel_puertoIDBLL(planDesc.Pue_codD)); PuertosBO puerto_dest = JsonConvert.DeserializeObject <PuertosBO>(jsonPuertoD.Trim(new char[] { '[', ']' })); string jsonTarjador = JsonConvert.SerializeObject(new PersonasBLL().sp_sel_personasIDBLL(planDesc.Rut_tarjador)); PersonasBO tarjador = JsonConvert.DeserializeObject <PersonasBO>(jsonTarjador.Trim(new char[] { '[', ']' })); DataTable personasT = new PersonasBLL().sp_sel_personasTarjaBLL(tarja.Nro_tarja); string movilizadores = string.Empty; string horquillero = string.Empty; foreach (DataRow row in personasT.Rows) { if (row["FUNCION"].ToString() == "Movilizador") { movilizadores += row["nom_persona"].ToString() + "\n"; } else { horquillero = row["nom_persona"].ToString(); } } var settings = new BarCodeSettings { Type = BarCodeType.Code128, Data = tarja.Nro_tarja.ToString() }; var generator = new BarCodeGenerator(settings); Image imgbarcode; using (var barcodeImage = generator.GenerateImage()) { ImageFormat format = ImageFormat.Bmp; imgbarcode = Image.GetInstance(barcodeImage, format); imgbarcode.ScalePercent(100f); } Font arialHeading = FontFactory.GetFont("Arial", 15, 1); Font arialText = FontFactory.GetFont("Arial", 10, 1); string logoPath = HostingEnvironment.MapPath("~/assets/custom/images"); //Añadir encabezado PdfPTable tableHeader = new PdfPTable(3); PdfPCell subheader = new PdfPCell(imgbarcode); subheader.HorizontalAlignment = 1; subheader.VerticalAlignment = 5; subheader.Border = 0; tableHeader.WidthPercentage = 100; tableHeader.DefaultCell.Border = 0; tableHeader.DefaultCell.HorizontalAlignment = 1; tableHeader.DefaultCell.VerticalAlignment = 5; Image logo = Image.GetInstance(logoPath + "/logo.png"); tableHeader.AddCell(logo); Paragraph titulo = new Paragraph("Documento de Desconsolidado", arialHeading); tableHeader.AddCell(titulo); tableHeader.AddCell(subheader); //Añadir Tabla de detalles PdfPTable detailTable = new PdfPTable(6); detailTable.WidthPercentage = 100; detailTable.DefaultCell.Padding = 4.5f; detailTable.DefaultCell.Border = 15; detailTable.DefaultCell.HorizontalAlignment = 1; detailTable.DefaultCell.VerticalAlignment = 5; //row1 inicializacion PdfPCell TitleCliente = new PdfPCell(new Paragraph("Cliente", arialText)); TitleCliente.BackgroundColor = BaseColor.LIGHT_GRAY; TitleCliente.HorizontalAlignment = 1; TitleCliente.VerticalAlignment = 5; PdfPCell cellrutCliente = new PdfPCell(new Paragraph(cliente.Rut_cliente + "-" + cliente.Dv_cliente, arialText)); cellrutCliente.HorizontalAlignment = 1; cellrutCliente.VerticalAlignment = 5; PdfPCell cellcliente = new PdfPCell(new Paragraph(cliente.Nombre_cliente, arialText)); cellcliente.HorizontalAlignment = 1; cellcliente.VerticalAlignment = 5; PdfPCell vacio1 = new PdfPCell(new Paragraph("")); PdfPCell celltitlecontainer = new PdfPCell(new Paragraph("Contenedor", arialText)); celltitlecontainer.HorizontalAlignment = 1; celltitlecontainer.VerticalAlignment = 5; celltitlecontainer.BackgroundColor = BaseColor.LIGHT_GRAY; PdfPCell cellcontainer = new PdfPCell(new Paragraph(planDesc.Cod_contenedor.Substring(0, 4) + "-" + planDesc.Cod_contenedor.Substring(4, 6) + "-" + planDesc.Cod_contenedor.Substring(10, 1), arialText)); cellcontainer.HorizontalAlignment = 1; cellcontainer.VerticalAlignment = 5; //row2 inicializacion PdfPCell celltitlenave = new PdfPCell(new Paragraph("Nave", arialText)); celltitlenave.BackgroundColor = BaseColor.LIGHT_GRAY; celltitlenave.HorizontalAlignment = 1; celltitlenave.VerticalAlignment = 5; PdfPCell cellnave = new PdfPCell(new Paragraph(nave.Nav_nom, arialText)); cellnave.HorizontalAlignment = 1; cellnave.VerticalAlignment = 5; PdfPCell celltitleFechaI = new PdfPCell(new Paragraph("Fecha Inicio", arialText)); celltitleFechaI.BackgroundColor = BaseColor.LIGHT_GRAY; celltitleFechaI.HorizontalAlignment = 1; celltitleFechaI.VerticalAlignment = 5; PdfPCell cellFechaI = new PdfPCell(new Paragraph(planDesc.Fecha.ToString("dd-MM-yyyy").Substring(0, 10), arialText)); cellFechaI.HorizontalAlignment = 1; cellFechaI.VerticalAlignment = 5; PdfPCell celltitleiso = new PdfPCell(new Paragraph("Codigo Iso", arialText)); celltitleiso.BackgroundColor = BaseColor.LIGHT_GRAY; celltitleiso.HorizontalAlignment = 1; celltitleiso.VerticalAlignment = 5; PdfPCell celliso = new PdfPCell(new Paragraph(planDesc.Cod_iso, arialText)); celliso.HorizontalAlignment = 1; celliso.VerticalAlignment = 5; //row3 inicializacion PdfPCell titleviaje = new PdfPCell(new Paragraph("Viaje/Etapa", arialText)); titleviaje.BackgroundColor = BaseColor.LIGHT_GRAY; titleviaje.HorizontalAlignment = 1; titleviaje.VerticalAlignment = 5; PdfPCell cellviaje = new PdfPCell(new Paragraph(planDesc.Cod_viaje.ToString(), arialText)); cellviaje.HorizontalAlignment = 1; cellviaje.VerticalAlignment = 5; PdfPCell celltitlefecha = new PdfPCell(new Paragraph("Fecha Termino", arialText)); celltitlefecha.BackgroundColor = BaseColor.LIGHT_GRAY; celltitlefecha.HorizontalAlignment = 1; celltitlefecha.VerticalAlignment = 5; PdfPCell cellfecha = new PdfPCell(new Paragraph(planDesc.FechaT.ToString("dd-MM-yyyy").Substring(0, 10), arialText)); cellfecha.HorizontalAlignment = 1; cellfecha.VerticalAlignment = 5; PdfPCell celltitletara = new PdfPCell(new Paragraph("Tara (Kg.)", arialText)); celltitletara.HorizontalAlignment = 1; celltitletara.VerticalAlignment = 5; celltitletara.BackgroundColor = BaseColor.LIGHT_GRAY; PdfPCell celltara = new PdfPCell(new Paragraph(planDesc.Tara.ToString(), arialText)); celltara.HorizontalAlignment = 1; celltara.VerticalAlignment = 5; //row4 inicializacion PdfPCell titlemanifiesto = new PdfPCell(new Paragraph("Duración Faena", arialText)); titlemanifiesto.BackgroundColor = BaseColor.LIGHT_GRAY; titlemanifiesto.HorizontalAlignment = 1; titlemanifiesto.VerticalAlignment = 5; PdfPCell cellmanifiesto = new PdfPCell(new Paragraph(Convert.ToInt32(planDesc.Duracion * 60) + " Min.", arialText)); cellmanifiesto.HorizontalAlignment = 1; cellmanifiesto.VerticalAlignment = 5; PdfPCell titleturno = new PdfPCell(new Paragraph("Mano de Trabajo", arialText)); titleturno.BackgroundColor = BaseColor.LIGHT_GRAY; titleturno.HorizontalAlignment = 1; celltitlefecha.VerticalAlignment = 5; PdfPCell cellturno = new PdfPCell(new Paragraph(planDesc.Mddt, arialText)); cellturno.HorizontalAlignment = 1; cellturno.VerticalAlignment = 5; PdfPCell titlesello1 = new PdfPCell(new Paragraph("Sello 1 (Manifestado/Fisico)", arialText)); titlesello1.HorizontalAlignment = 1; titlesello1.VerticalAlignment = 5; titlesello1.BackgroundColor = BaseColor.LIGHT_GRAY; PdfPCell cellsello1 = new PdfPCell(new Paragraph(planDesc.Sello1 + " / " + planDesc.SelloFis1, arialText)); cellsello1.HorizontalAlignment = 1; cellsello1.VerticalAlignment = 5; //row5 inicializacion PdfPCell titleorigen = new PdfPCell(new Paragraph("Origen", arialText)); titleorigen.BackgroundColor = BaseColor.LIGHT_GRAY; titleorigen.HorizontalAlignment = 1; titleorigen.VerticalAlignment = 5; PdfPCell cellorigen = new PdfPCell(new Paragraph(puerto_or.Gls_nombre_puerto, arialText)); cellorigen.HorizontalAlignment = 1; cellorigen.VerticalAlignment = 5; PdfPCell titlehorai = new PdfPCell(new Paragraph("Hora Inicio", arialText)); titlehorai.BackgroundColor = BaseColor.LIGHT_GRAY; titlehorai.HorizontalAlignment = 1; titlehorai.VerticalAlignment = 5; PdfPCell cellhorai = new PdfPCell(new Paragraph(planDesc.HoraIR.ToString(), arialText)); cellhorai.HorizontalAlignment = 1; cellhorai.VerticalAlignment = 5; PdfPCell titlesello2 = new PdfPCell(new Paragraph("Sello 2 (Manifestado/Fisico)", arialText)); titlesello2.HorizontalAlignment = 1; titlesello2.VerticalAlignment = 5; titlesello2.BackgroundColor = BaseColor.LIGHT_GRAY; PdfPCell cellsello2 = new PdfPCell(new Paragraph(planDesc.Sello2 + " / " + planDesc.SelloFis2, arialText)); cellsello2.HorizontalAlignment = 1; cellsello2.VerticalAlignment = 5; //row6 inicializacion PdfPCell titledestino = new PdfPCell(new Paragraph("Destino", arialText)); titledestino.BackgroundColor = BaseColor.LIGHT_GRAY; titledestino.HorizontalAlignment = 1; titledestino.VerticalAlignment = 5; PdfPCell celldestino = new PdfPCell(new Paragraph(puerto_dest.Gls_nombre_puerto, arialText)); celldestino.HorizontalAlignment = 1; celldestino.VerticalAlignment = 5; PdfPCell titlehorat = new PdfPCell(new Paragraph("Hora Termino", arialText)); titlehorat.BackgroundColor = BaseColor.LIGHT_GRAY; titlehorat.HorizontalAlignment = 1; titlehorat.VerticalAlignment = 5; PdfPCell cellhorat = new PdfPCell(new Paragraph(planDesc.HoraTR.ToString(), arialText)); cellhorat.HorizontalAlignment = 1; cellhorat.VerticalAlignment = 5; PdfPCell titlesello3 = new PdfPCell(new Paragraph("Sello 3 (Manifestado/Fisico)", arialText)); titlesello3.HorizontalAlignment = 1; titlesello3.VerticalAlignment = 5; titlesello3.BackgroundColor = BaseColor.LIGHT_GRAY; PdfPCell cellsello3 = new PdfPCell(new Paragraph(planDesc.Sello3 + " / " + planDesc.SelloFis3, arialText)); cellsello3.HorizontalAlignment = 1; cellsello3.VerticalAlignment = 5; //row1 detailTable.AddCell(TitleCliente); detailTable.AddCell(cellrutCliente); detailTable.AddCell(cellcliente); detailTable.AddCell(vacio1); detailTable.AddCell(celltitlecontainer); detailTable.AddCell(cellcontainer); //row2 detailTable.AddCell(celltitlenave); detailTable.AddCell(cellnave); detailTable.AddCell(celltitleFechaI); detailTable.AddCell(cellFechaI); detailTable.AddCell(celltitleiso); detailTable.AddCell(celliso); //row3 detailTable.AddCell(titleviaje); detailTable.AddCell(cellviaje); detailTable.AddCell(celltitlefecha); detailTable.AddCell(cellfecha); detailTable.AddCell(celltitletara); detailTable.AddCell(celltara); //row4 detailTable.AddCell(titlemanifiesto); detailTable.AddCell(cellmanifiesto); detailTable.AddCell(titleturno); detailTable.AddCell(cellturno); detailTable.AddCell(titlesello1); detailTable.AddCell(cellsello1); //row5 detailTable.AddCell(titleorigen); detailTable.AddCell(cellorigen); detailTable.AddCell(titlehorai); detailTable.AddCell(cellhorai); detailTable.AddCell(titlesello2); detailTable.AddCell(cellsello2); //row6 detailTable.AddCell(titledestino); detailTable.AddCell(celldestino); detailTable.AddCell(titlehorat); detailTable.AddCell(cellhorat); detailTable.AddCell(titlesello3); detailTable.AddCell(cellsello3); ////tabla contenedor PdfPTable detailConte = new PdfPTable(3); detailConte.WidthPercentage = 100; detailConte.DefaultCell.HorizontalAlignment = 1; detailConte.DefaultCell.VerticalAlignment = 5; ////row 1 Image vector = Image.GetInstance(logoPath + "/vector.png"); vector.ScalePercent(52f); PdfPCell cellFotoCont = new PdfPCell(vector); cellFotoCont.HorizontalAlignment = 1; cellFotoCont.VerticalAlignment = 5; PdfPTable tableSecVec = new PdfPTable(2); List <SectorVectorBO> listSector = JsonConvert.DeserializeObject <List <SectorVectorBO> >(new SectorVectorBLL().sp_sel_sectorVectorIDDAL(tarja.Nro_tarja)); string codEstado, nroSector, estado; #pragma warning disable CS0219 // La variable 'j' está asignada pero su valor nunca se usa int j = 1; #pragma warning restore CS0219 // La variable 'j' está asignada pero su valor nunca se usa foreach (SectorVectorBO sector in listSector) { codEstado = sector.Cod_estado.ToString(); nroSector = sector.Nro_sector.ToString(); PdfPCell estadoSec = new PdfPCell(); estado = sector.Gls_nombre_estado.ToString(); estadoSec.AddElement(new Paragraph(nroSector + " " + estado, arialText)); estadoSec.BackgroundColor = BaseColor.YELLOW; estadoSec.HorizontalAlignment = 1; estadoSec.VerticalAlignment = 5; if (codEstado.Equals("S")) { estadoSec.BackgroundColor = BaseColor.WHITE; } tableSecVec.AddCell(estadoSec); } tableSecVec.AddCell(""); PdfPCell cellEstadosSec = new PdfPCell(tableSecVec); PdfPTable tableObs = new PdfPTable(1); PdfPCell titleObs = new PdfPCell(new Paragraph("OBSERVACIONES GENERALES", arialText)); titleObs.HorizontalAlignment = 1; titleObs.VerticalAlignment = 5; titleObs.BackgroundColor = BaseColor.LIGHT_GRAY; PdfPCell cellObs = new PdfPCell(new Paragraph(tarja.Observacion, arialText)); tableObs.AddCell(titleObs); tableObs.AddCell(cellObs); PdfPCell obs = new PdfPCell(tableObs); detailConte.AddCell(cellFotoCont); detailConte.AddCell(cellEstadosSec); detailConte.AddCell(obs); //tabla detalles personas PdfPTable tablapersonas = new PdfPTable(4); tablapersonas.WidthPercentage = 100; //row1 PdfPCell titlegrua = new PdfPCell(new Paragraph("GRUA", arialText)); titlegrua.BackgroundColor = BaseColor.LIGHT_GRAY; titlegrua.HorizontalAlignment = 1; titlegrua.VerticalAlignment = 5; PdfPCell cellgrua = new PdfPCell(new Paragraph(tarja.Grua_cod, arialText)); cellgrua.HorizontalAlignment = 1; cellgrua.VerticalAlignment = 5; PdfPCell titlemovilizadores = new PdfPCell(new Paragraph("MOVILIZADORES", arialText)); titlemovilizadores.BackgroundColor = BaseColor.LIGHT_GRAY; titlemovilizadores.HorizontalAlignment = 1; titlemovilizadores.VerticalAlignment = 5; PdfPCell titletarjador = new PdfPCell(new Paragraph("TARJADOR", arialText)); titletarjador.HorizontalAlignment = 1; titletarjador.VerticalAlignment = 5; titletarjador.BackgroundColor = BaseColor.LIGHT_GRAY; //row2 PdfPCell titlehorquillero = new PdfPCell(new Paragraph("HORQUILLERO", arialText)); titlehorquillero.BackgroundColor = BaseColor.LIGHT_GRAY; titlehorquillero.HorizontalAlignment = 1; titlehorquillero.VerticalAlignment = 5; PdfPCell cellhorquillero = new PdfPCell(new Paragraph(horquillero, arialText)); cellhorquillero.HorizontalAlignment = 1; cellhorquillero.VerticalAlignment = 5; PdfPCell cellmovilizadeores = new PdfPCell(new Paragraph(movilizadores, arialText)); titlemovilizadores.HorizontalAlignment = 1; titlemovilizadores.VerticalAlignment = 5; PdfPCell celltarjador = new PdfPCell(new Paragraph(tarjador.Nom_persona, arialText)); titletarjador.HorizontalAlignment = 1; titletarjador.VerticalAlignment = 5; tablapersonas.AddCell(titlegrua); tablapersonas.AddCell(cellgrua); tablapersonas.AddCell(titlemovilizadores); tablapersonas.AddCell(titletarjador); tablapersonas.AddCell(titlehorquillero); tablapersonas.AddCell(cellhorquillero); tablapersonas.AddCell(cellmovilizadeores); tablapersonas.AddCell(celltarjador); ////Tabla Merc Int64[] codigosMerc = null; string[] marcas = null; List <MercanciasDescBO> listMerc = null; PdfPTable detalleMerc = new PdfPTable(6); detalleMerc.WidthPercentage = 100; PdfPCell titlemarca = new PdfPCell(new Paragraph("MARCAS/NUMEROS", arialText)); titlemarca.HorizontalAlignment = 1; titlemarca.VerticalAlignment = 5; titlemarca.BackgroundColor = BaseColor.LIGHT_GRAY; titlemarca.Border = 15; detalleMerc.AddCell(titlemarca); PdfPCell titlebulto = new PdfPCell(new Paragraph("TIPO BULTO", arialText)); titlebulto.HorizontalAlignment = 1; titlebulto.VerticalAlignment = 5; titlebulto.Border = 15; titlebulto.BackgroundColor = BaseColor.LIGHT_GRAY; detalleMerc.AddCell(titlebulto); PdfPCell titleretiro = new PdfPCell(new Paragraph("TIPO DE RETIRO", arialText)); titleretiro.HorizontalAlignment = 1; titleretiro.VerticalAlignment = 5; titleretiro.BackgroundColor = BaseColor.LIGHT_GRAY; titlebulto.Border = 15; detalleMerc.AddCell(titleretiro); PdfPCell titlecantidad = new PdfPCell(new Paragraph("CANTIDAD", arialText)); titlecantidad.HorizontalAlignment = 1; titlecantidad.VerticalAlignment = 5; titlecantidad.BackgroundColor = BaseColor.LIGHT_GRAY; titlecantidad.Border = 15; detalleMerc.AddCell(titlecantidad); PdfPCell titleTotalmarca = new PdfPCell(new Paragraph("TOTAL", arialText)); titleTotalmarca.HorizontalAlignment = 1; titleTotalmarca.VerticalAlignment = 5; titleTotalmarca.BackgroundColor = BaseColor.LIGHT_GRAY; titleTotalmarca.Border = 15; detalleMerc.AddCell(titleTotalmarca); PdfPCell titleobs = new PdfPCell(new Paragraph("OBSERVACIONES", arialText)); titleobs.HorizontalAlignment = 1; titleobs.VerticalAlignment = 5; titleobs.BackgroundColor = BaseColor.LIGHT_GRAY; titleobs.Border = 15; detalleMerc.AddCell(titleobs); PdfPCell cellmarca, cellbultos, cellretiro, cellcantidad, celltotalM, cellobs, celltotal; string nomBulto = ""; int suma = 0; try { listMerc = new MercanciasDescBll().sp_sel_mercDescBLL(tarja.Nro_tarja); int i = 0; codigosMerc = new Int64[listMerc.Count]; marcas = new string[listMerc.Count]; foreach (MercanciasDescBO mercs in listMerc) { int cantidadB = 0; string cantidad = string.Empty; string observacioMerc = string.Empty; codigosMerc[i] = mercs.Cod_mercancia; if (!verificarMarca(marcas, mercs.Gls_marca)) { marcas[i] = mercs.Gls_marca; foreach (MercanciasDescBO mercAux in listMerc) { if (mercAux.Gls_marca.Equals(mercs.Gls_marca)) { cantidad += mercAux.N_cantidad.ToString() + " + "; observacioMerc += " " + mercAux.Observacion; cantidadB += mercAux.N_cantidad; nomBulto = mercAux.Desc_bulto; } } cantidad = cantidad.Substring(0, cantidad.Length - 2); suma += cantidadB; cellmarca = new PdfPCell(new Paragraph(mercs.Gls_marca, arialText)); cellmarca.HorizontalAlignment = 1; cellmarca.VerticalAlignment = 5; cellmarca.Border = 15; detalleMerc.AddCell(cellmarca); cellbultos = new PdfPCell(new Paragraph(nomBulto, arialText)); cellbultos.HorizontalAlignment = 1; cellbultos.VerticalAlignment = 5; cellbultos.Border = 15; detalleMerc.AddCell(cellbultos); cellretiro = new PdfPCell(new Paragraph(mercs.Gls_retiro, arialText)); cellretiro.HorizontalAlignment = 1; cellretiro.VerticalAlignment = 5; cellretiro.Border = 15; detalleMerc.AddCell(cellretiro); cellcantidad = new PdfPCell(new Paragraph(cantidad.ToString(), arialText)); cellcantidad.HorizontalAlignment = 1; cellcantidad.VerticalAlignment = 5; cellcantidad.Border = 15; detalleMerc.AddCell(cellcantidad); celltotalM = new PdfPCell(new Paragraph(cantidadB.ToString(), arialText)); celltotalM.HorizontalAlignment = 1; celltotalM.VerticalAlignment = 5; celltotalM.Border = 15; detalleMerc.AddCell(celltotalM); cellobs = new PdfPCell(new Paragraph(observacioMerc, arialText)); cellobs.HorizontalAlignment = 1; cellobs.VerticalAlignment = 5; cellobs.Border = 15; detalleMerc.AddCell(cellobs); } i++; } } catch (Exception ex) { Console.WriteLine("Ha ocurrido un error: " + ex.ToString()); } PdfPCell titletotal = new PdfPCell(new Paragraph("TOTAL", arialText)); titletotal.Border = 15; titletotal.HorizontalAlignment = 1; titletotal.VerticalAlignment = 5; titletotal.BackgroundColor = BaseColor.LIGHT_GRAY; detalleMerc.AddCell(titletotal); celltotal = new PdfPCell(new Paragraph(suma.ToString(), arialText)); celltotal.HorizontalAlignment = 1; celltotal.VerticalAlignment = 5; celltotal.Border = 15; detalleMerc.AddCell(celltotal); PdfPCell cellnada = new PdfPCell(new Paragraph("")); cellnada.Border = 0; detalleMerc.AddCell(cellnada); detalleMerc.AddCell(cellnada); detalleMerc.AddCell(cellnada); detalleMerc.AddCell(cellnada); PdfPTable tablefotos = new PdfPTable(3); tablefotos.WidthPercentage = 100; PdfPCell titletable = new PdfPCell(new Paragraph("FOTOGRAFIAS DESCONSOLIDADO", arialText)); titletable.Border = 15; titletable.HorizontalAlignment = 1; titletable.VerticalAlignment = 5; titletable.BackgroundColor = BaseColor.LIGHT_GRAY; PdfPCell cellnombrefoto; PdfPTable subtabla = new PdfPTable(1); PdfPCell cellfotografias; #pragma warning disable CS0168 // La variable 'cellfoto' se ha declarado pero nunca se usa PdfPCell cellfoto; #pragma warning restore CS0168 // La variable 'cellfoto' se ha declarado pero nunca se usa String base64Img = ""; var doctypeDesCnt = ConfigurationManager.AppSettings["FDM:DocTypeDescCnt"].ToString(); var fechaLimiteStr = ConfigurationManager.AppSettings["FechaLimite"].ToString().Split('-'); DateTime fechaLimite = new DateTime(Convert.ToInt32(fechaLimiteStr[0]), Convert.ToInt32(fechaLimiteStr[1]), Convert.ToInt32(fechaLimiteStr[2])); if (planDesc.Fecha < fechaLimite) { try { byte[] imageBytes; List <FotoContenedorBO> listFotos = new FotoContenedorBLL().sp_sel_fotoContDescBLL(tarja.Nro_tarja); string nombreImagen = string.Empty; foreach (FotoContenedorBO fotoCl in listFotos) { if (!nombreImagen.Equals(fotoCl.Gls_nombreImg)) { if (string.IsNullOrEmpty(nombreImagen)) { nombreImagen = fotoCl.Gls_nombreImg; base64Img = fotoCl.Gls_imagen; } else { if (base64Img.Length % 4 != 0) { string len = (base64Img.Length % 4).ToString(); } else { imageBytes = Convert.FromBase64String(base64Img); Image foto = Image.GetInstance(imageBytes); foto.ScaleAbsolute(159f, 235f); cellnombrefoto = new PdfPCell(new Paragraph(nombreImagen, arialText)); cellnombrefoto.HorizontalAlignment = 1; cellnombrefoto.VerticalAlignment = 5; subtabla = new PdfPTable(1); subtabla.AddCell(new PdfPCell(foto) { HorizontalAlignment = 1, VerticalAlignment = 5 }); subtabla.AddCell(cellnombrefoto); cellfotografias = new PdfPCell(subtabla); cellfotografias.HorizontalAlignment = 1; cellfotografias.VerticalAlignment = 5; tablefotos.AddCell(cellfotografias); } nombreImagen = fotoCl.Gls_nombreImg; base64Img = fotoCl.Gls_imagen; } } else { if (!string.IsNullOrEmpty(nombreImagen)) { var parte = fotoCl.Gls_imagen; var largo = parte.Length; base64Img += "" + parte; } } } if (!string.IsNullOrEmpty(base64Img)) { imageBytes = Convert.FromBase64String(base64Img); Image foto2 = Image.GetInstance(imageBytes); foto2.ScaleAbsolute(159f, 235f); cellnombrefoto = new PdfPCell(new Paragraph(nombreImagen, arialText)); cellnombrefoto.HorizontalAlignment = 1; cellnombrefoto.VerticalAlignment = 5; subtabla = new PdfPTable(1); subtabla.AddCell(new PdfPCell(foto2) { HorizontalAlignment = 1, VerticalAlignment = 5 }); subtabla.AddCell(cellnombrefoto); cellfotografias = new PdfPCell(subtabla); cellfotografias.HorizontalAlignment = 1; cellfotografias.VerticalAlignment = 5; tablefotos.AddCell(cellfotografias); } base64Img = ""; nombreImagen = ""; } catch (Exception ex) { Console.WriteLine("Ha ocurrido un error: " + ex.ToString()); } foreach (Int64 codigo in codigosMerc) { try { byte[] imageBytes; string marcaMerc = ""; string nombreImagen = string.Empty; List <FotoMercanciaBO> listFotoMerc = new FotoMercanciaBLL().sp_sel_fotoMercDescBLL(codigo); marcaMerc = new MercanciasDescBll().sp_sel_marcaMercBLL(codigo); foreach (FotoMercanciaBO fotoMerc in listFotoMerc) { if (!nombreImagen.Equals(fotoMerc.Gls_nombreImg)) { if (string.IsNullOrEmpty(nombreImagen)) { nombreImagen = fotoMerc.Gls_nombreImg; base64Img = fotoMerc.Gls_imagen; } else { if (base64Img.Length % 4 != 0) { string len = (base64Img.Length % 4).ToString(); } else { imageBytes = Convert.FromBase64String(base64Img); Image foto = Image.GetInstance(imageBytes); foto.ScaleAbsolute(159f, 235f); cellnombrefoto = new PdfPCell(new Paragraph(marcaMerc, arialText)); cellnombrefoto.HorizontalAlignment = 1; cellnombrefoto.VerticalAlignment = 5; subtabla = new PdfPTable(1); subtabla.AddCell(new PdfPCell(foto) { HorizontalAlignment = 1, VerticalAlignment = 5 }); subtabla.AddCell(cellnombrefoto); cellfotografias = new PdfPCell(subtabla); cellfotografias.HorizontalAlignment = 1; cellfotografias.VerticalAlignment = 5; tablefotos.AddCell(cellfotografias); } nombreImagen = fotoMerc.Gls_nombreImg; base64Img = fotoMerc.Gls_imagen; } } else { if (!string.IsNullOrEmpty(nombreImagen)) { var parte = fotoMerc.Gls_imagen; var largo = parte.Length; base64Img += "" + parte; } } } if (!string.IsNullOrEmpty(nombreImagen)) { imageBytes = Convert.FromBase64String(base64Img); Image foto2 = Image.GetInstance(imageBytes); foto2.ScaleAbsolute(159f, 235f); cellnombrefoto = new PdfPCell(new Paragraph(marcaMerc, arialText)); cellnombrefoto.HorizontalAlignment = 1; cellnombrefoto.VerticalAlignment = 5; subtabla = new PdfPTable(1); subtabla.AddCell(new PdfPCell(foto2) { HorizontalAlignment = 1, VerticalAlignment = 5 }); subtabla.AddCell(cellnombrefoto); cellfotografias = new PdfPCell(subtabla); cellfotografias.HorizontalAlignment = 1; cellfotografias.VerticalAlignment = 5; tablefotos.AddCell(cellfotografias); nombreImagen = ""; base64Img = ""; } } catch (Exception ex) { Console.WriteLine("Ha ocurrido un error: " + ex.ToString()); } } try { byte[] imageBytes; string nombreImagen = string.Empty; List <FotoContenedorBO> listFotosFin = new FotoContenedorBLL().sp_sel_fotoContFinBLL(tarja.Nro_tarja); foreach (FotoContenedorBO fotoFin in listFotosFin) { if (!nombreImagen.Equals(fotoFin.Gls_nombreImg)) { if (string.IsNullOrEmpty(nombreImagen)) { nombreImagen = fotoFin.Gls_nombreImg; base64Img = fotoFin.Gls_imagen; } else { if (base64Img.Length % 4 != 0) { string len = (base64Img.Length % 4).ToString(); } else { imageBytes = Convert.FromBase64String(base64Img); Image foto = Image.GetInstance(imageBytes); foto.ScaleAbsolute(159f, 235f); cellnombrefoto = new PdfPCell(new Paragraph(nombreImagen, arialText)); cellnombrefoto.HorizontalAlignment = 1; cellnombrefoto.VerticalAlignment = 5; subtabla = new PdfPTable(1); subtabla.AddCell(new PdfPCell(foto) { HorizontalAlignment = 1, VerticalAlignment = 5 }); subtabla.AddCell(cellnombrefoto); cellfotografias = new PdfPCell(subtabla); cellfotografias.HorizontalAlignment = 1; cellfotografias.VerticalAlignment = 5; tablefotos.AddCell(cellfotografias); } nombreImagen = fotoFin.Gls_nombreImg; base64Img = fotoFin.Gls_imagen; } } else { if (!string.IsNullOrEmpty(nombreImagen)) { var parte = fotoFin.Gls_imagen; var largo = parte.Length; base64Img += "" + parte; } } } if (!string.IsNullOrEmpty(nombreImagen)) { imageBytes = Convert.FromBase64String(base64Img); base64Img = Convert.ToBase64String(imageBytes); Image foto2 = Image.GetInstance(imageBytes); foto2.ScaleAbsolute(159f, 235f); cellnombrefoto = new PdfPCell(new Paragraph(nombreImagen, arialText)); cellnombrefoto.HorizontalAlignment = 1; cellnombrefoto.VerticalAlignment = 5; subtabla = new PdfPTable(1); subtabla.AddCell(new PdfPCell(foto2) { HorizontalAlignment = 1, VerticalAlignment = 5 }); subtabla.AddCell(cellnombrefoto); cellfotografias = new PdfPCell(subtabla); cellfotografias.HorizontalAlignment = 1; cellfotografias.VerticalAlignment = 5; tablefotos.AddCell(cellfotografias); } nombreImagen = ""; base64Img = ""; } catch (Exception ex) { Console.WriteLine("Ha ocurrido un error: " + ex.ToString()); } } else { try { List <FotografiasFDM> listFotos = new FotografiasFDM().obtenerFotografias(doctypeDesCnt, tarja.Nro_tarja.ToString()); string nombreImagen = string.Empty; foreach (FotografiasFDM fotoCl in listFotos) { Image foto = Image.GetInstance(new Uri(fotoCl.url_foto)); foto.ScaleAbsolute(159f, 235f); cellnombrefoto = new PdfPCell(new Paragraph(fotoCl.nombre_foto, arialText)); cellnombrefoto.HorizontalAlignment = 1; cellnombrefoto.VerticalAlignment = 5; subtabla = new PdfPTable(1); subtabla.AddCell(new PdfPCell(foto) { HorizontalAlignment = 1, VerticalAlignment = 5 }); subtabla.AddCell(cellnombrefoto); cellfotografias = new PdfPCell(subtabla); cellfotografias.HorizontalAlignment = 1; cellfotografias.VerticalAlignment = 5; tablefotos.AddCell(cellfotografias); } } catch (Exception ex) { Console.WriteLine("Ha ocurrido un error: " + ex.ToString()); } var docTypeMercDes = ConfigurationManager.AppSettings["FDM:DocTypeMercDesc"].ToString(); foreach (Int64 codigo in codigosMerc) { try { string marcaMerc = ""; string nombreImagen = string.Empty; List <FotografiasFDM> listFotoMerc = new FotografiasFDM().obtenerFotografias(docTypeMercDes, codigo.ToString()); marcaMerc = new MercanciasDescBll().sp_sel_marcaMercBLL(codigo); foreach (FotografiasFDM fotoMerc in listFotoMerc) { Image foto2 = Image.GetInstance(new Uri(fotoMerc.url_foto)); foto2.ScaleAbsolute(159f, 235f); cellnombrefoto = new PdfPCell(new Paragraph(marcaMerc, arialText)); cellnombrefoto.HorizontalAlignment = 1; cellnombrefoto.VerticalAlignment = 5; subtabla = new PdfPTable(1); subtabla.AddCell(new PdfPCell(foto2) { HorizontalAlignment = 1, VerticalAlignment = 5 }); subtabla.AddCell(cellnombrefoto); cellfotografias = new PdfPCell(subtabla); cellfotografias.HorizontalAlignment = 1; cellfotografias.VerticalAlignment = 5; tablefotos.AddCell(cellfotografias); } } catch (Exception ex) { Console.WriteLine("Ha ocurrido un error: " + ex.ToString()); } } } tablefotos.AddCell(vacio1); tablefotos.AddCell(vacio1); Paragraph vacio = new Paragraph(); vacio.Add("\n"); Paragraph p1 = new Paragraph(); p1.Add(tableHeader); Paragraph p2 = new Paragraph(); p2.Add(detailTable); Paragraph p3 = new Paragraph(); p3.Add(detailConte); Paragraph p4 = new Paragraph(); p4.Add(tablapersonas); Paragraph p5 = new Paragraph(); p5.Add(detalleMerc); Paragraph p6 = new Paragraph(); p6.Add(tablefotos); doc.Add(p1); doc.Add(vacio); doc.Add(p2); doc.Add(p3); doc.Add(p4); doc.NewPage(); doc.Add(p5); doc.NewPage(); doc.Add(p6); return(doc); }