private void Cargar_nuevo_concepto(Decimal idClausula) { Label_ID_CLAUSULA_RELACIONADA.Text = idClausula.ToString(); Decimal ID_REQUERIMIENTO = Convert.ToDecimal(HiddenField_ID_REQUERIMIENTO.Value); Decimal ID_SOLICITUD = Convert.ToDecimal(TextBox_ID_SOLICITUD.Text); Decimal ID_EMPLEADO = Convert.ToDecimal(Label_ID_EMPLEADO.Text); registroContrato _registroContrato = new registroContrato(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString()); DataTable tablaInfoContrato = _registroContrato.obtenerInfoNomEmpleadoPorIdSolicitudIdRequerimiento(ID_SOLICITUD, ID_REQUERIMIENTO, ID_EMPLEADO); DataRow filaInfoContrato = tablaInfoContrato.Rows[0]; cargar_DropDownList_PERIODO_PAGO(DropDownList_FORMA_PAGO_NOMINA); DropDownList_FORMA_PAGO_NOMINA.SelectedValue = filaInfoContrato["PERIODO_PAGO"].ToString().Trim(); cargar_check_periodos(filaInfoContrato["PERIODO_PAGO"].ToString().Trim()); cargar_DropDownList_CONCEPTOS_FIJOS(); TextBox_CAN_PRE.Text = ""; TextBox_VAL_PRE.Text = ""; }
/// <summary> /// HECHO POR CESAR PULIDO /// EL DIA 19 DE DICIEMBRE DE 2012 /// PARA OBTENER EL ARCHIVO CON LA INFORMACION DE LAS AFICLIACIONES DEL EMPLEADO /// </summary> /// <param name="ID_SOLICITUD"></param> /// <param name="ID_REQUERIMIENTO"></param> /// <param name="ID_EMPLEADO"></param> /// <returns></returns> public byte[] GenerarPDFAfiliaciones(Decimal ID_SOLICITUD, Decimal ID_REQUERIMIENTO, Decimal ID_EMPLEADO, Decimal ID_CONTRATO) { tools _tools = new tools(); registroContrato _registroContrato = new registroContrato(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString()); DataTable tablaInfoContrato = _registroContrato.obtenerInfoNomEmpleadoPorIdSolicitudIdRequerimiento(ID_SOLICITUD, ID_REQUERIMIENTO, ID_EMPLEADO); DataRow filaInfoContrato = tablaInfoContrato.Rows[0]; Decimal ID_AFILIACION_ARP = Convert.ToDecimal(filaInfoContrato["ID_ARP"]); Decimal ID_AFILIACION_CAJA_C = Convert.ToDecimal(filaInfoContrato["ID_CAJA_C"]); Decimal ID_AFILIACION_EPS = Convert.ToDecimal(filaInfoContrato["ID_EPS"]); Decimal ID_AFILIACION_F_PENSIONES = Convert.ToDecimal(filaInfoContrato["ID_F_PENSIONES"]); radicacionHojasDeVida _radicacionHojasDeVida = new radicacionHojasDeVida(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString()); DataTable tablaSolicitud = _radicacionHojasDeVida.ObtenerRegSolicitudesingresoPorIdSolicitud(Convert.ToInt32(ID_SOLICITUD)); DataRow filaSolicitud = tablaSolicitud.Rows[0]; String NOMBRE_ASPIRANTE = filaSolicitud["NOMBRES"].ToString().Trim() + " " + filaSolicitud["APELLIDOS"].ToString().Trim(); String DOC_IDENTIDAD_ASPIRANTE = filaSolicitud["TIP_DOC_IDENTIDAD"].ToString().Trim() + " " + filaSolicitud["NUM_DOC_IDENTIDAD"].ToString().Trim(); String DIRECCION_ASPIRANTE = filaSolicitud["DIR_ASPIRANTE"].ToString().Trim(); String CIUDAD_ASPIRANTE = filaSolicitud["NOMBRE_CIUDAD"].ToString().Trim(); String SECTOR_ASPIRANTE = filaSolicitud["SECTOR"].ToString(); String TELEFONOS_ASPIRANTE = filaSolicitud["TEL_ASPIRANTE"].ToString(); String ASPIRACION_SALARIAL_ASPIRANTE; try { ASPIRACION_SALARIAL_ASPIRANTE = Convert.ToInt32(filaSolicitud["ASPIRACION_SALARIAL"]).ToString(); } catch { ASPIRACION_SALARIAL_ASPIRANTE = "Desconocido."; } String EMAIL_ASPIRANTE = filaSolicitud["E_MAIL"].ToString().Trim(); int EDAD_ASPIRANTE = 0; if (DBNull.Value.Equals(filaSolicitud["FCH_NACIMIENTO"]) == false) { try { EDAD_ASPIRANTE = _tools.ObtenerEdadDesdeFechaNacimiento(Convert.ToDateTime(filaSolicitud["FCH_NACIMIENTO"])); } catch { EDAD_ASPIRANTE = 0; } } //FEMENINO, MASCULINO String SEXO = "Desconocido."; String LIBRETA_MILITAR = "Desconocida."; if (DBNull.Value.Equals(filaSolicitud["SEXO"]) == false) { if (filaSolicitud["SEXO"].ToString().ToUpper() == "F") { SEXO = "Femenino"; LIBRETA_MILITAR = "No Aplica"; } else { if (filaSolicitud["SEXO"].ToString().ToUpper() == "M") { SEXO = "Masculino"; LIBRETA_MILITAR = filaSolicitud["LIB_MILITAR"].ToString(); } } } //cargo al que aspira el candidato (cargo generico) cargo _cargo = new cargo(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString()); DataTable tablaOcupacionAspira = _cargo.ObtenerOcupacionPorIdOcupacion(ID_SOLICITUD); String CARGO_APLICA = "Desconocido"; if (tablaOcupacionAspira.Rows.Count > 0) { DataRow filaOcupacionAspira = tablaOcupacionAspira.Rows[0]; CARGO_APLICA = filaOcupacionAspira["NOM_OCUPACION"].ToString().Trim(); } //En esta variable cargamos el documento plantilla StreamReader archivo_original = new StreamReader(Server.MapPath(@"~\plantillas_reportes\informeAfiliaciones.htm")); String html_formato_afilicaciones = archivo_original.ReadToEnd(); archivo_original.Dispose(); archivo_original.Close(); String html_encabezado = "<html>"; html_encabezado += "<body>"; String html_pie = "</body>"; html_pie += "</html>"; html_formato_afilicaciones = html_encabezado + html_formato_afilicaciones; html_formato_afilicaciones = html_formato_afilicaciones.Replace("[NOMBRE_TRABAJADOR]", NOMBRE_ASPIRANTE); html_formato_afilicaciones = html_formato_afilicaciones.Replace("[DOC_IDENTIDAD_TRABAJADOR]", DOC_IDENTIDAD_ASPIRANTE); if (EDAD_ASPIRANTE > 0) { html_formato_afilicaciones = html_formato_afilicaciones.Replace("[EDAD_TRABAJADOR]", EDAD_ASPIRANTE.ToString() + " Años."); } else { html_formato_afilicaciones = html_formato_afilicaciones.Replace("[EDAD_ASPIRANTE]", "Desconocida."); } html_formato_afilicaciones = html_formato_afilicaciones.Replace("[DIRECCION_TRABAJADOR]", DIRECCION_ASPIRANTE); html_formato_afilicaciones = html_formato_afilicaciones.Replace("[CIUDAD_TRABAJADOR]", CIUDAD_ASPIRANTE); html_formato_afilicaciones = html_formato_afilicaciones.Replace("[SECTOR_TRABAJADOR]", SECTOR_ASPIRANTE); html_formato_afilicaciones = html_formato_afilicaciones.Replace("[TELEFONOS_TRABAJADOR]", TELEFONOS_ASPIRANTE); html_formato_afilicaciones = html_formato_afilicaciones.Replace("[ASPIRACION_SALARIAL_TRABAJADOR]", ASPIRACION_SALARIAL_ASPIRANTE); html_formato_afilicaciones = html_formato_afilicaciones.Replace("[EMAIL_TRABAJADOR]", EMAIL_ASPIRANTE); html_formato_afilicaciones = html_formato_afilicaciones.Replace("[LIBRETA_MILITAR_TRABAJADOR]", LIBRETA_MILITAR); //reemplazamos tag de arp String TABLA_AFILIACION_ARP = cargar_arp(ID_AFILIACION_ARP, ID_SOLICITUD, ID_EMPLEADO, ID_CONTRATO); if (TABLA_AFILIACION_ARP != null) { html_formato_afilicaciones = html_formato_afilicaciones.Replace("[TABLA_AFILIACION_ARP]", TABLA_AFILIACION_ARP); } else { html_formato_afilicaciones = html_formato_afilicaciones.Replace("[TABLA_AFILIACION_ARP]", ""); } //reemplazamos tag de eps String TABLA_AFILIACION_EPS = cargar_eps(ID_AFILIACION_EPS, ID_SOLICITUD, ID_EMPLEADO, ID_CONTRATO); if (TABLA_AFILIACION_EPS != null) { html_formato_afilicaciones = html_formato_afilicaciones.Replace("[TABLA_AFILIACION_EPS]", TABLA_AFILIACION_EPS); } else { html_formato_afilicaciones = html_formato_afilicaciones.Replace("[TABLA_AFILIACION_EPS]", ""); } //reemplazamos tag de caja de compensacion String TABLA_AFILIACION_CCF = cargar_caja(ID_AFILIACION_CAJA_C, ID_SOLICITUD, ID_EMPLEADO); if (TABLA_AFILIACION_CCF != null) { html_formato_afilicaciones = html_formato_afilicaciones.Replace("[TABLA_AFILIACION_CCF]", TABLA_AFILIACION_CCF); } else { html_formato_afilicaciones = html_formato_afilicaciones.Replace("[TABLA_AFILIACION_CCF]", ""); } //reemplazamos tag de FONDO DE PENSIONES String TABLA_AFILIACION_AFP = cargar_afp(ID_AFILIACION_F_PENSIONES, ID_SOLICITUD, ID_EMPLEADO); if (TABLA_AFILIACION_AFP != null) { html_formato_afilicaciones = html_formato_afilicaciones.Replace("[TABLA_AFILIACION_AFP]", TABLA_AFILIACION_AFP); } else { html_formato_afilicaciones = html_formato_afilicaciones.Replace("[TABLA_AFILIACION_AFP]", ""); } html_formato_afilicaciones += html_pie; //creamos un configuramos el documento de pdf //(tamaño de la hoja,margen izq, margen der, margin arriba margen abajo) iTextSharp.text.Document document = new iTextSharp.text.Document(new Rectangle(595, 842), 40, 40, 80, 40); using (MemoryStream streamArchivo = new MemoryStream()) { iTextSharp.text.pdf.PdfWriter writer = PdfWriter.GetInstance(document, streamArchivo); // Our custom Header and Footer is done using Event Handler pdfEvents PageEventHandler = new pdfEvents(); writer.PageEvent = PageEventHandler; // Define the page header // Define the page header if (Session["idEmpresa"].ToString() == "1") { PageEventHandler.dirImagenHeader = Server.MapPath("~/imagenes/reportes/logo_sertempo.png"); } else { PageEventHandler.dirImagenHeader = Server.MapPath("~/imagenes/reportes/logo_eficiencia.png"); } PageEventHandler.fechaImpresion = DateTime.Now; PageEventHandler.tipoDocumento = "afiliaciones"; document.Open(); //capturamos el archivo temporal del response String tempFile = Path.GetTempFileName(); //y lo llenamos con el html de la plantilla using (StreamWriter tempwriter = new StreamWriter(tempFile, false)) { tempwriter.Write(html_formato_afilicaciones); } //leeemos el archivo temporal y lo colocamos en el documento de pdf List<IElement> htmlarraylist = HTMLWorker.ParseToList(new StreamReader(tempFile), new StyleSheet()); foreach (IElement element in htmlarraylist) { if (element.Chunks.Count > 0) { if (element.Chunks[0].Content == "linea para paginacion de pdf") { document.NewPage(); } else { document.Add(element); } } else { document.Add(element); } } //limpiamos todo document.Close(); writer.Close(); return streamArchivo.ToArray(); } }
private void carar_seccion_afiliaciones(Decimal ID_SOLICITUD, Decimal ID_REQUERIMIENTO, Decimal ID_EMPLEADO) { registroContrato _registroContrato = new registroContrato(Session["idEmpresa"].ToString(), Session["USU_LOG"].ToString()); DataTable tablaInfoContrato = _registroContrato.obtenerInfoNomEmpleadoPorIdSolicitudIdRequerimiento(ID_SOLICITUD, ID_REQUERIMIENTO, ID_EMPLEADO); DataRow filaInfoContrato = tablaInfoContrato.Rows[0]; Decimal ID_AFILIACION_ARP = Convert.ToDecimal(filaInfoContrato["ID_ARP"]); Decimal ID_AFILIACION_CAJA_C = 0; try { ID_AFILIACION_CAJA_C = Convert.ToDecimal(filaInfoContrato["ID_CAJA_C"]); } catch { ID_AFILIACION_CAJA_C = 0; } Decimal ID_AFILIACION_EPS = Convert.ToDecimal(filaInfoContrato["ID_EPS"]); Decimal ID_AFILIACION_F_PENSIONES = Convert.ToDecimal(filaInfoContrato["ID_F_PENSIONES"]); cargar_arp(ID_AFILIACION_ARP, ID_SOLICITUD, ID_EMPLEADO); cargar_eps(ID_AFILIACION_EPS, ID_SOLICITUD, ID_EMPLEADO); cargar_caja(ID_AFILIACION_CAJA_C, ID_SOLICITUD, ID_EMPLEADO); cargar_afp(ID_AFILIACION_F_PENSIONES, ID_SOLICITUD, ID_EMPLEADO); }