예제 #1
0
        public byte[] DescargarPlantillaCargue(string Nit)
        {
            ExcelPackage excel = new ExcelPackage();

            excel.Workbook.Worksheets.Add("Plantilla de cargue");

            ExcelWorksheet hoja1 = excel.Workbook.Worksheets[1];

            hoja1.Cells["A1"].Value = "Consecutivo";
            hoja1.Cells["B1"].Value = "ConsecutivoPadre";
            hoja1.Cells["C1"].Value = "Cod_Tipo_Documento";
            hoja1.Cells["D1"].Value = "Nit_Empresa";
            hoja1.Cells["E1"].Value = "Cod_Departamento";
            hoja1.Cells["F1"].Value = "Cod_Minicipio";
            hoja1.Cells["G1"].Value = "Cod_Sede";
            hoja1.Cells["H1"].Value = "Cod_Tipo_Documento";
            hoja1.Cells["I1"].Value = "Num_Documento";
            hoja1.Cells["J1"].Value = "Nombre_Trabajador";
            hoja1.Cells["K1"].Value = "Edad";
            hoja1.Cells["L1"].Value = "Genero";
            hoja1.Cells["M1"].Value = "Cod_Ocupacion";
            hoja1.Cells["N1"].Value = "Nombre_EPS";
            hoja1.Cells["O1"].Value = "Tipo_Vinculacion";
            hoja1.Cells["P1"].Value = "Salario_Base";
            hoja1.Cells["Q1"].Value = "Cod_Contingencia";
            hoja1.Cells["R1"].Value = "Cod_Area";
            hoja1.Cells["S1"].Value = "Fecha_Inicio";
            hoja1.Cells["T1"].Value = "Fecha_Fin";
            hoja1.Cells["U1"].Value = "Cod_Diagnostico";
            hoja1.Cells["V1"].Value = "Factor_Prestacional";
            hoja1.Cells["W1"].Value = "Observacion";

            int col = 1;

            foreach (var cel in hoja1.Cells["A1:W1"])
            {
                cel.Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
                cel.Style.Border.BorderAround(OfficeOpenXml.Style.ExcelBorderStyle.Thin);
                cel.Style.VerticalAlignment   = OfficeOpenXml.Style.ExcelVerticalAlignment.Center;
                cel.Style.HorizontalAlignment = OfficeOpenXml.Style.ExcelHorizontalAlignment.Center;
                cel.Style.Font.Bold           = true;
                cel.Style.WrapText            = true;
                hoja1.Column(col).Width       = 25;
                col++;
            }

            //Cargar datos de hoja dos tipo documento
            excel.Workbook.Worksheets.Add("TipoDocumento");
            ExcelWorksheet hoja2 = excel.Workbook.Worksheets[2];

            List <EDTipoDocumento> tiposDocumento = em.ObtenerTiposDocumento();
            int nunInicial = 1;

            foreach (var tipoDocumento in tiposDocumento)
            {
                hoja2.Cells[string.Format("A{0}", nunInicial)].Value = tipoDocumento.Id_Tipo_Documento;
                hoja2.Cells[string.Format("B{0}", nunInicial)].Value = tipoDocumento.Descripcion;
                nunInicial++;
            }

            //Cargar datos de hoja tres con los departamentos
            excel.Workbook.Worksheets.Add("Departamentos");
            ExcelWorksheet hoja3 = excel.Workbook.Worksheets[3];

            List <SG_SST.EntidadesDominio.Ausentismo.EDDepartamento> departamentos = dpto.ObtenerDepartamento().ToList();

            nunInicial = 1;
            foreach (var dpt in departamentos)
            {
                hoja3.Cells[string.Format("A{0}", nunInicial)].Value = dpt.IdDepartamento;
                hoja3.Cells[string.Format("B{0}", nunInicial)].Value = dpt.Nombre;
                nunInicial++;
            }

            //Cargar datos de hoja tres con los departamentos
            excel.Workbook.Worksheets.Add("Minicipios");
            ExcelWorksheet hoja4 = excel.Workbook.Worksheets[4];

            List <SG_SST.EntidadesDominio.Ausentismo.EDMunicipio> miicipios = mp.ObtenerMunicipiosConDetps();

            nunInicial = 1;
            foreach (var m in miicipios)
            {
                hoja4.Cells[string.Format("A{0}", nunInicial)].Value = m.IdMunicipio;
                hoja4.Cells[string.Format("B{0}", nunInicial)].Value = m.Nombre;
                hoja4.Cells[string.Format("C{0}", nunInicial)].Value = m.NombreDepartamento;
                nunInicial++;
            }

            //Cargar datos de hoja cuatro con los sedes de la empresa
            excel.Workbook.Worksheets.Add("Sedes");
            ExcelWorksheet hoja5 = excel.Workbook.Worksheets[5];

            List <EDSede> sedes = em.ObtenernerSedesPorEmpresa(Nit);

            nunInicial = 1;
            foreach (var sede in sedes)
            {
                hoja5.Cells[string.Format("A{0}", nunInicial)].Value = sede.IdSede;
                hoja5.Cells[string.Format("B{0}", nunInicial)].Value = sede.NombreSede;
                nunInicial++;
            }


            ////Cargar datos de hoja cinco con los Empresas Asociadas
            //excel.Workbook.Worksheets.Add("Empresa Asociada");
            //ExcelWorksheet hoja5 = excel.Workbook.Worksheets[5];

            //List<EDEmpresa_Usuaria> EmpresaAsociadas = em.ObtenerEmpresasUsuariasPorEmpresa(Nit);
            //nunInicial = 1;
            //foreach (var asociada in EmpresaAsociadas)
            //{
            //    hoja5.Cells[string.Format("A{0}", nunInicial)].Value = asociada.IdEmpresaUsuaria;
            //    hoja5.Cells[string.Format("B{0}", nunInicial)].Value = asociada.RazonSocial;
            //    nunInicial++;
            //}

            //Cargar datos de hoja seis Genero del trabajador
            excel.Workbook.Worksheets.Add("Genero");
            ExcelWorksheet hoja6 = excel.Workbook.Worksheets[6];

            hoja6.Cells["A1"].Value = "M";
            hoja6.Cells["A2"].Value = "F";


            //Cargar datos de hoja siete con las ocupaciones
            excel.Workbook.Worksheets.Add("Ocuapciones");
            ExcelWorksheet hoja7 = excel.Workbook.Worksheets[7];

            List <EDOcupacion> Ocupaciones = em.ObtenerOpucaciones();

            nunInicial = 1;
            foreach (var ocupacion in Ocupaciones)
            {
                hoja7.Cells[string.Format("A{0}", nunInicial)].Value = ocupacion.Id_Ocupacion;
                hoja7.Cells[string.Format("B{0}", nunInicial)].Value = ocupacion.Descripcion;
                nunInicial++;
            }

            //Cargar datos de hoja ocho tipo vinculacion
            excel.Workbook.Worksheets.Add("Tipo viculacion");
            ExcelWorksheet hoja8 = excel.Workbook.Worksheets[8];

            hoja8.Cells["A1"].Value = "Dependiente";
            hoja8.Cells["A2"].Value = "Independiente";

            //Cargar datos de hoja nueve con las contigencias
            excel.Workbook.Worksheets.Add("Contigencias");
            ExcelWorksheet hoja9 = excel.Workbook.Worksheets[9];

            List <EDContingencia> Contigencias = cg.ObtenerContingencia().ToList();

            nunInicial = 1;
            foreach (var cng in Contigencias)
            {
                hoja9.Cells[string.Format("A{0}", nunInicial)].Value = cng.IdContingencia;
                hoja9.Cells[string.Format("B{0}", nunInicial)].Value = cng.Detalle;
                nunInicial++;
            }

            //Cargar datos de hoja diez con los proceso de la empresa o areas
            excel.Workbook.Worksheets.Add("Procesos o Areas");
            ExcelWorksheet hoja10 = excel.Workbook.Worksheets[10];

            List <EDProceso> Procesos = em.ObtenerProcesosPorEmpres(Nit);

            nunInicial = 1;
            foreach (var p in Procesos)
            {
                hoja10.Cells[string.Format("A{0}", nunInicial)].Value = p.Id_Proceso;
                hoja10.Cells[string.Format("B{0}", nunInicial)].Value = p.Descripcion;
                nunInicial++;
            }

            //Cargar datos de hoja once con los diagnosticos
            excel.Workbook.Worksheets.Add("Diagnosticos");
            ExcelWorksheet hoja11 = excel.Workbook.Worksheets[11];

            List <EDDiagnostico> Diagnosticos = dg.ObtenerDiagnostico().ToList();

            nunInicial = 1;
            foreach (var diag in Diagnosticos)
            {
                hoja11.Cells[string.Format("A{0}", nunInicial)].Value = diag.Codigo;
                hoja11.Cells[string.Format("B{0}", nunInicial)].Value = diag.Descripcion;
                nunInicial++;
            }

            return(excel.GetAsByteArray());
        }
예제 #2
0
        public IEnumerable <EDDepartamento> ObtenerListadoDepartamento()
        {
            var resultado = departamentoMG.ObtenerDepartamento();

            return(resultado);
        }