예제 #1
0
        public List <EAprobacionCarga> listApruebaCarga(CONTRATO_SYS contrato, int jtStartIndex, int jtPageSize, string sorting, object[] filters, out int total)
        {
            var listAprueba = new List <EAprobacionCarga>();

            try
            {
                #region VARIABLES
                var fecha_inicio = Convert.ToDateTime(filters[1]);
                var fecha_fin    = Convert.ToDateTime(filters[2]);
                var sorter       = sorting.Split(' ');
                if (sorter[0].ToUpper().Equals("MONEDA"))
                {
                    sorter[0] = "Moneda";
                }
                else if (sorter[0].ToUpper().Equals("TOTALIMPORTE"))
                {
                    sorter[0] = "ImporteTotal";
                }
                var propertyInfo = typeof(pa_sel_pagoNominaAprueba_Result).GetProperty(sorter[0].Trim());
                #endregion VARIABLES

                using (var db = new DISEntities())
                {
                    var query = db.pa_sel_pagoNominaAprueba(contrato.IDE_CONTRATO, filters[0].ToString(), fecha_inicio, fecha_fin).ToList();
                    total = query.Count();
                    if (sorter[1].Trim().ToUpper().Equals("ASC"))
                    {
                        query = query.OrderBy(x => propertyInfo.GetValue(x, null)).Skip(jtStartIndex).Take(jtPageSize).ToList();
                    }
                    else
                    {
                        query = query.OrderByDescending(x => propertyInfo.GetValue(x, null)).Skip(jtStartIndex).Take(jtPageSize).ToList();
                    }
                    foreach (var item in query.Skip(jtStartIndex).Take(jtPageSize))
                    {
                        var eApruebaCarga = new EAprobacionCarga()
                        {
                            IdLinCab       = item.IdLinCab,
                            IdArchivo      = item.ArchivoId,
                            NombreArchivo  = item.NombreArchivo,
                            FechaCarga     = Convert.ToDateTime(item.FechaCarga),
                            moneda         = item.Moneda,
                            TotalRegistros = Convert.ToInt64(item.TotalRegistros),
                            TotalImporte   = string.Format(filters[3].ToString(), item.ImporteTotal),
                            PagoVc         = string.Format(filters[3].ToString(), item.PagoVC),
                            FechaInfo      = item.FechaInfo,
                            UsuReg         = item.UsuReg,
                            Aprobar        = item.Aprobar,
                            Eliminar       = item.Eliminar
                        };
                        listAprueba.Add(eApruebaCarga);
                    }
                }
                return(listAprueba);
            }
            catch (System.Exception ex)
            {
                throw;
            }
        }
예제 #2
0
 internal CONTRATO_SYS listByNroContrato(CONTRATO_SYS contrato)
 {
     try
     {
         using (var db = new DISEntities())
         {
             return(db.CONTRATO_SYSs.Where(x => x.NRO_CONTRATO == contrato.NRO_CONTRATO && x.ESTADO == "A").FirstOrDefault());
         }
     }
     catch (Exception ex)
     {
         throw;
     }
 }
예제 #3
0
 public string copiarUltimaReglaArchivo(CONTRATO_SYS contrato)
 {
     try
     {
         using (var db = new DISEntities())
         {
             return(db.pa_copia_reglaArchivo(Convert.ToInt32(contrato.NRO_CONTRATO)).FirstOrDefault().Value.ToString());
         }
     }
     catch (Exception ex)
     {
         throw(new Exception(ex.Message));
     }
 }
예제 #4
0
 //INVOCAR STORE PROCEDURE
 //var date1 = DateTime.Now;
 //var date2 = DateTime.Now;
 //
 public CONTRATO_SYS listContratoByID(CONTRATO_SYS contrato)
 {
     try
     {
         using (var db = new DISEntities())
         {
             return(db.CONTRATO_SYSs.OrderBy(a => a.IDE_CONTRATO).Where(a => a.IDE_CONTRATO == contrato.IDE_CONTRATO).FirstOrDefault());
         }
     }
     catch (System.Exception ex)
     {
         throw;
     }
 }
예제 #5
0
 public int validarExisteReglaByContrato(CONTRATO_SYS contratoSisEF)
 {
     try
     {
         using (var db = new DISEntities())
         {
             var numeroContrato = Convert.ToInt32(contratoSisEF.NRO_CONTRATO);
             return(db.ReglaArchivos.Where(r => r.NUM_CONT_LIC == numeroContrato).Count());
         }
     }
     catch (Exception ex)
     {
         throw(new Exception(ex.Message));
     }
 }
        protected void btn_exportar_Click(object sender, System.Web.UI.ImageClickEventArgs e)
        {
            var contratoSis = new CONTRATO_SYS()
            {
                IDE_CONTRATO = Convert.ToInt32(ddl_contrato.SelectedItem.Value)
            };
            var filtersNow = new object[4] {
                ddl_tipo_archivo.SelectedItem.Value, txt_fecha_inicio.Text, txt_fecha_inicio.Text, filters[0].ToString()
            };
            var filePath = new nAprobacionCarga().descargarExcelAprueba(contratoSis, filtersNow);

            Response.Clear();
            Response.ContentType = "application/vnd.ms-excel";
            Response.AddHeader("Content-Disposition", string.Format("attachment;filename={0}", Path.GetFileName(filePath)));
            Response.TransmitFile(filePath);
            Response.End();
        }
예제 #7
0
 public int existeFecha(CONTRATO_SYS contratoSis, int paso)
 {
     try
     {
         using (var db = new DISEntities())
         {
             if (paso == 0)
             {
                 return(int.Parse(db.pa_Valida_RangoFechaXContrato(contratoSis.FEC_INI_VIG, contratoSis.FEC_FIN_VIG).FirstOrDefault().Value.ToString()));
             }
             else
             {
                 return(int.Parse(db.pa_Valida_RangoFechaXContratoV2(contratoSis.FEC_INI_VIG, contratoSis.FEC_FIN_VIG).FirstOrDefault().Value.ToString()));
             }
         }
     }
     catch (System.Exception ex)
     {
         throw;
     }
 }
예제 #8
0
        private int validaNumeroMaximoEmpresa(CONTRATO_SIS_DET ContratoSisDetalle)
        {
            var filterOptions = new Object[3] {
                0, 10000, "IDE_CONTRATO ASC"
            };
            var contratosis = new CONTRATO_SYS()
            {
                IDE_CONTRATO = Convert.ToInt32(ContratoSisDetalle.IDE_CONTRATO)
            };
            var nContratoSis     = new nContratoSis().listContratoByID(contratosis);
            var nContratoDetalle = new nContratoSisDetalle().getlistContratoDetalle(ContratoSisDetalle, filterOptions, out total);

            numero_empresa = Convert.ToInt32(nContratoSis.NRO_EMPRESAS);
            if (nContratoDetalle.Count == nContratoSis.NRO_EMPRESAS)
            {
                return(1);
            }
            else
            {
                return(0);
            }
        }
예제 #9
0
        public List <ESegDescarga> listSegDescarga(CONTRATO_SYS contrato, object[] filters, int jtStartIndex, int jtPageSize, string jtSorting, out int total)
        {
            var listDescarag = new List <ESegDescarga>();

            try
            {
                #region VARIABLES
                Nullable <DateTime> fechaInicioCreacion = null, fechaFinCreacion = null, fechaInicioAprobacion = null, fechaFinAprobacion = null;
                if (!string.IsNullOrEmpty(filters[1].ToString()))
                {
                    fechaInicioCreacion = Convert.ToDateTime(filters[1]);
                }
                if (!string.IsNullOrEmpty(filters[2].ToString()))
                {
                    fechaFinCreacion = Convert.ToDateTime(filters[2]);
                }
                if (!string.IsNullOrEmpty(filters[3].ToString()))
                {
                    fechaInicioAprobacion = Convert.ToDateTime(filters[3]);
                }
                if (!string.IsNullOrEmpty(filters[3].ToString()))
                {
                    fechaFinAprobacion = Convert.ToDateTime(filters[4]);
                }
                //sorter
                var sorter = jtSorting.Split(' ');
                if (sorter[0].ToString().ToUpper().Equals("FECHACARGA"))
                {
                    sorter[0] = "FecReg";
                }
                else if (sorter[0].ToString().ToUpper().Equals("IMPORTE"))
                {
                    sorter[0] = "ImporteTotalSoles";
                }
                else if (sorter[0].ToString().ToUpper().Equals("NROLINEAS"))
                {
                    sorter[0] = "TotalRegistros";
                }
                else if (sorter[0].ToString().ToUpper().Equals("USUREG"))
                {
                    sorter[0] = "Usuario";
                }
                var propertyInfo = typeof(pa_sel_SegDescarga_Result).GetProperty(sorter[0].Trim());

                #endregion VARIABLES
                using (var db = new DISEntities())
                {
                    var query = db.pa_sel_SegDescarga(contrato.IDE_CONTRATO, filters[0].ToString(), fechaInicioCreacion, fechaFinCreacion, fechaInicioAprobacion, fechaFinAprobacion).ToList();
                    total = query.Count;
                    if (sorter[1].Trim().ToUpper().Equals("ASC"))
                    {
                        query = query.OrderBy(x => propertyInfo.GetValue(x, null)).Skip(jtStartIndex).Take(jtPageSize).ToList();
                    }
                    else
                    {
                        query = query.OrderByDescending(x => propertyInfo.GetValue(x, null)).Skip(jtStartIndex).Take(jtPageSize).ToList();
                    }
                    foreach (var item in query)
                    {
                        var eSegDescarga = new ESegDescarga()
                        {
                            Estado          = item.Estado,
                            FechaCarga      = item.FecReg,
                            FechaAprobacion = item.FechaAprobacion,
                            Importe         = string.Format(ConfigurationManager.AppSettings.Get("Float"), item.ImporteTotalSoles),
                            NombreArchivo   = item.NombreArchivo,
                            NroLineas       = Convert.ToInt32(item.TotalRegistros),
                            Moneda          = item.Moneda,
                            Usuario         = item.UsuReg
                        };
                        listDescarag.Add(eSegDescarga);
                    }
                }
                return(listDescarag);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #10
0
 public CONTRATO_SYS listByNroContrato(CONTRATO_SYS contrato)
 {
     return(new dContratoSis().listByNroContrato(contrato));
 }
예제 #11
0
 public int existeFecha(CONTRATO_SYS contratoSis, int paso)
 {
     return(new dContratoSis().existeFecha(contratoSis, paso));
 }
예제 #12
0
 /// <summary>
 /// Lista los contratos por id
 /// </summary>
 /// <param name="contrato"></param>
 /// <returns></returns>
 public CONTRATO_SYS listContratoByID(CONTRATO_SYS contrato)
 {
     return(new dContratoSis().listContratoByID(contrato));
 }
예제 #13
0
 public string copiarUltimaReglaArchivo(CONTRATO_SYS contratoSisEF)
 {
     return(new dReglaArchivo().copiarUltimaReglaArchivo(contratoSisEF));
 }
예제 #14
0
 public int validarExisteReglaByContrato(CONTRATO_SYS contratoSisEF)
 {
     return(new dReglaArchivo().validarExisteReglaByContrato(contratoSisEF));
 }
        public string descargarExcelAprueba(CONTRATO_SYS contratoSis, object[] filtersNow)
        {
            var helperStyle = new Helpers.excelStyle();

            try
            {
                int total;
                var listDescarga = new dAprobacionCarga().listApruebaCarga(contratoSis, 0, 100000, "IdLinCab ASC", filtersNow, out total);
                //atributos del file
                var      nombreArchivo = string.Format("Aprueba {0}_{1}_{2}", filtersNow[0].ToString(), DateTime.Now.ToString("yyyyMMdd"), contratoSis.IDE_CONTRATO.ToString());
                var      rutaTemporal  = @HttpContext.Current.Server.MapPath(string.Format("~/Temp/Descargas/{0}.xlsx", nombreArchivo));
                var      book          = new XSSFWorkbook();
                string[] columns       = { "NombreArchivo", "Fecha Carga", "Mondeda", "TotalRegistros", "TotalImporte", "FechaCreacción", "Usuario" };
                var      sheet         = book.CreateSheet(nombreArchivo);
                var      rowBook       = sheet.CreateRow(1);
                var      headerStyle   = helperStyle.setFontText(12, true, book);
                var      bodyStyle     = helperStyle.setFontText(11, false, book);
                ICell    cellBook;
                for (int i = 0; i < columns.Length; i++)
                {
                    cellBook = rowBook.CreateCell(i + 1);
                    cellBook.SetCellValue(columns[i]);
                    cellBook.CellStyle = headerStyle;
                }
                for (int i = 0; i < listDescarga.Count; i++)
                {
                    var rowBody = sheet.CreateRow(2 + i);

                    ICell cellArchivo = rowBody.CreateCell(1);
                    cellArchivo.SetCellValue(listDescarga[i].NombreArchivo);
                    cellArchivo.CellStyle = bodyStyle;

                    ICell cellFechaCarga = rowBody.CreateCell(2);
                    cellFechaCarga.SetCellValue(listDescarga[i].FechaCarga.ToShortDateString());
                    cellFechaCarga.CellStyle = bodyStyle;

                    ICell cellMoneda = rowBody.CreateCell(3);
                    cellMoneda.SetCellValue(listDescarga[i].moneda);
                    cellMoneda.CellStyle = bodyStyle;

                    ICell cellTotalRegistros = rowBody.CreateCell(4);
                    cellTotalRegistros.SetCellValue(listDescarga[i].TotalRegistros);
                    cellTotalRegistros.CellStyle = bodyStyle;

                    ICell cellTotalImporte = rowBody.CreateCell(5);
                    cellTotalImporte.SetCellValue(listDescarga[i].TotalImporte);
                    cellTotalImporte.CellStyle = bodyStyle;

                    ICell cellFechaInfo = rowBody.CreateCell(6);
                    cellFechaInfo.SetCellValue(listDescarga[i].FechaInfo.ToShortDateString());
                    cellFechaInfo.CellStyle = bodyStyle;

                    ICell cellUsuReg = rowBody.CreateCell(7);
                    cellUsuReg.SetCellValue(listDescarga[i].UsuReg);
                    cellUsuReg.CellStyle = bodyStyle;
                }
                if (File.Exists(rutaTemporal))
                {
                    File.Delete(rutaTemporal);
                }
                using (var file = new FileStream(rutaTemporal, FileMode.Create, FileAccess.ReadWrite))
                {
                    book.Write(file);
                    file.Close();
                    book.Close();
                }

                return(rutaTemporal);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
예제 #16
0
        private void SetInsertarActualizarContratoSys()
        {
            var mensajeConfirmn = string.Empty;

            try
            {
                Int32 resp        = 0;
                var   contratoSis = new eContratoSys()
                {
                    _id_Empresa   = Convert.ToInt32(Session["idempresa"]),
                    _ide_Contrato = Convert.ToInt32(txt_ide_contrato_sis.Value),
                    _nro_Contrato = txt_nrocont_sys.Text,
                    _cla_Contrato = string.Empty,
                    _fec_Ini_Vig  = DateTime.Parse(txtFechaInicio_sys.Text),
                    _fec_Fin_Vig  = DateTime.Parse(txtFechaFin_sys.Text),
                    _des_Contrato = txtdescripcion_sys.Text,
                    _estado       = ddl_estado_sys.SelectedItem.Value,
                    _usu_reg      = Session["username"].ToString(),
                    _usu_mod      = Session["username"].ToString(),
                    _nro_empresa  = int.Parse(txt_numero_empresa.Text),
                    _centro_costo = txt_centro_costo_sys.Text
                };

                if (contratoSis._fec_Ini_Vig >= contratoSis._fec_Fin_Vig)
                {
                    MessageBox("La fecha de inicio no debe ser mayor al de fin");
                    return;
                }

                if (contratoSis._nro_empresa < 4 || contratoSis._nro_empresa > 7)
                {
                    MessageBox("El rango de N° de empresas por contrato puede ser entre 4 y 7");
                    return;
                }

                //valida rango de fecha para un contrato
                var contratoSisEF = new CONTRATO_SYS()
                {
                    FEC_INI_VIG  = DateTime.Parse(txtFechaInicio_sys.Text),
                    FEC_FIN_VIG  = DateTime.Parse(txtFechaFin_sys.Text),
                    NRO_CONTRATO = txt_nrocont_sys.Text
                };
                var siExisteFecha = new nContratoSis().existeFecha(contratoSisEF, 0);

                bContratoSys control = new bContratoSys();
                if (contratoSis._ide_Contrato == 0)
                {
                    if (contratoSis._estado.Equals("A"))
                    {
                        MessageBox("Para crear la empresa como activa, debe completar la infomación de las CSV SIS.");
                        return;
                    }
                    if (siExisteFecha > 0)
                    {
                        MessageBox("La fecha ingresada se sobrepone al rango de fechas de otro contrato.");
                        return;
                    }
                    else
                    {
                        var siExisteFechaV2 = new nContratoSis().existeFecha(contratoSisEF, 1);
                        if (siExisteFechaV2 > 0)
                        {
                            MessageBox("La fecha ingresada se sobrepone al rango de fechas de otro contrato.");
                            return;
                        }
                    }
                    resp = control.SetInsertarContratoSys(contratoSis);
                    //var elog = nlog.setLLenarEntidad(resp, "C001", "CONSIS_C", resp.ToString(), Session["username"].ToString());
                    //nlog.setGuardarLogOperacion(elog);
                    if (resp != 0)
                    {
                        //contrato sys
                        var bContrato = new bContratoSys();
                        bContrato.SetEstablecerDataSourceContratoSys(ddl_contrato_sis);
                        MessageBox("Registro Grabado Correctamente");
                    }
                    else
                    {
                        MessageBox("Ocurrio un Error en el Servidor!");
                    }
                }
                else
                {
                    if (!validaContratoSisDetalle(contratoSis) && contratoSis._estado.Equals("A"))
                    {
                        MessageBox("Para pasar la empresa como activa, debe completar la infomación de las CSV SIS.");
                    }
                    else
                    {
                        //validar si existe o no las reglas para el numero de contrato selecciondo
                        var existeReglaArchivo = new nReglaArchivo().validarExisteReglaByContrato(contratoSisEF);
                        if (existeReglaArchivo == 0)
                        {
                            var numeroContrato = new nReglaArchivo().copiarUltimaReglaArchivo(contratoSisEF);
                            mensajeConfirmn = string.Format(", Se copió las reglas del contrato Nro: {0}", numeroContrato);
                        }
                        resp = control.SetActualizarContratoSys(contratoSis);
                        if (resp != 0)
                        {
                            nlog.setLLenarEntidad(Convert.ToInt32(txt_ide_contrato_sis.Value), "A", "A01", contratoSis._ide_Contrato.ToString(), Session["username"].ToString(), "Contrato");
                            //contrato sys
                            var bContrato = new bContratoSys();
                            bContrato.SetEstablecerDataSourceContratoSys(ddl_contrato_sis);
                            MessageBox(string.Format("Registro Actualizado Correctamente {0}", mensajeConfirmn));
                        }
                        else
                        {
                            MessageBox("Ocurrio un Error en el Servidor!");
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBoxcCatch("ERROR =>" + e.Message);
            }
        }
        public static object listApruebaCarga(int jtStartIndex, int jtPageSize, string jtSorting, CONTRATO_SYS contrato, object[] filtersP)
        {
            filtersP[3] = filters[0].ToString();
            var negocio = new nAprobacionCarga();

            return(new { Result = "OK", Records = negocio.listApruebaCarga(contrato, jtStartIndex, jtPageSize, jtSorting, filtersP, out total), TotalRecordCount = total });
        }
 public List <ESegDescarga> listSegDescarga(CONTRATO_SYS contrato, object[] filters, int jtStartIndex, int jtPageSize, string jtSorting, out int total)
 {
     return(new dSegDescarga().listSegDescarga(contrato, filters, jtStartIndex, jtPageSize, jtSorting, out total));
 }
        public string descargarConsultaExcel(CONTRATO_SYS contrato, object[] filters)
        {
            var helperStyle = new Helpers.excelStyle();

            try
            {
                var      nombreArchivo = "Descarga " + filters[0].ToString() + " " + DateTime.Now.ToString("yyyyMMdd");
                var      rutaTemporal  = @HttpContext.Current.Server.MapPath("~/Temp/Descargas/" + nombreArchivo + ".xlsx");
                int      total;
                var      book        = new XSSFWorkbook();
                string[] columns     = { "Archivo", "Fecha Carga", "Usuario", "Nro Lineas", "Estado", "Moneda", "Importe" };
                var      sheet       = book.CreateSheet(nombreArchivo);
                var      rowBook     = sheet.CreateRow(1);
                var      headerStyle = helperStyle.setFontText(12, true, book);
                var      bodyStyle   = helperStyle.setFontText(11, false, book);
                ICell    cellBook;
                for (int i = 0; i < columns.Length; i++)
                {
                    cellBook = rowBook.CreateCell(i + 1);
                    cellBook.SetCellValue(columns[i]);
                    cellBook.CellStyle = headerStyle;
                }

                var listSegDescarga = new nSegDescarga().listSegDescarga(contrato, filters, 0, 100000, "Estado ASC", out total);
                for (int i = 0; i < listSegDescarga.Count; i++)
                {
                    var rowBody = sheet.CreateRow(2 + i);

                    ICell cellNombre = rowBody.CreateCell(1);
                    cellNombre.SetCellValue(listSegDescarga[i].NombreArchivo);
                    cellNombre.CellStyle = bodyStyle;

                    ICell cellFecCarga = rowBody.CreateCell(2);
                    cellFecCarga.SetCellValue(listSegDescarga[i].FechaCarga.ToShortDateString());
                    cellFecCarga.CellStyle = bodyStyle;

                    ICell cellUsuario = rowBody.CreateCell(3);
                    cellUsuario.SetCellValue(listSegDescarga[i].Usuario);
                    cellUsuario.CellStyle = bodyStyle;

                    ICell cellNroLinea = rowBody.CreateCell(4);
                    cellNroLinea.SetCellValue(listSegDescarga[i].NroLineas);
                    cellNroLinea.CellStyle = bodyStyle;

                    ICell cellEstado = rowBody.CreateCell(5);
                    cellEstado.SetCellValue(listSegDescarga[i].Estado);
                    cellEstado.CellStyle = bodyStyle;

                    ICell cellMoneda = rowBody.CreateCell(6);
                    cellMoneda.SetCellValue(listSegDescarga[i].Moneda);
                    cellMoneda.CellStyle = bodyStyle;

                    ICell cellImporte = rowBody.CreateCell(7);
                    cellImporte.SetCellValue(listSegDescarga[i].Importe);
                    cellImporte.CellStyle = bodyStyle;
                }
                if (File.Exists(rutaTemporal))
                {
                    File.Delete(rutaTemporal);
                }
                using (var file = new FileStream(rutaTemporal, FileMode.Create, FileAccess.ReadWrite))
                {
                    book.Write(file);
                    file.Close();
                    book.Close();
                }

                return(rutaTemporal);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public static object listSegDescarga(int jtStartIndex, int jtPageSize, string jtSorting, CONTRATO_SYS contrato, object[] filters)
        {
            var negocio = new nSegDescarga();

            return(new { Result = "OK", Records = negocio.listSegDescarga(contrato, filters, jtStartIndex, jtPageSize, jtSorting, out total), TotalRecordCount = total });
        }
 public List <EAprobacionCarga> listApruebaCarga(CONTRATO_SYS contrato, int jtStartIndex, int jtPageSize, string sorting, object[] filters, out int total)
 {
     return(new dAprobacionCarga().listApruebaCarga(contrato, jtStartIndex, jtPageSize, sorting, filters, out total));
 }