Beispiel #1
0
        public FileResult DownLayoutComplemento(int id)
        {
            DatoComplemento dc           = new DatoComplemento();
            var             archivoBytes = dc.CrearLayoutComplemento(id);

            var periodoPago = Session["periodo"] as NOM_PeriodosPago;

            //Se crea un nuevo nombre de archivo para el usuario
            string newFileName = "LC_" + periodoPago.Descripcion + "_.xlsx";

            //application/vnd.ms-excel
            //application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

            //application / vnd.ms - excel(official)
            //application / msexcel
            //application / x - msexcel
            //application / x - ms - excel
            //application / x - excel
            //application / x - dos_ms_excel
            //application / xls
            //application / x - xls
            //application / vnd.openxmlformats - officedocument.spreadsheetml.sheet(xlsx)

            //header('Content-Disposition: attachment; filename="name_of_excel_file.xls"');
            //Regresa el archivo
            // System.Net.Mime.MediaTypeNames.Application.
            return(File(archivoBytes, "application /vnd.openxmlformats-officedocument.spreadsheetml.sheet", newFileName));
        }
Beispiel #2
0
        public JsonResult UploadFileDetalle(HttpPostedFileBase file)
        {
            int idPeriodo = 0;

            //Validar que el file no este vacio o null
            if (file != null)
            {
                try
                {
                    var periodoPago = Session["periodo"] as NOM_PeriodosPago;
                    // idPeriodo = periodoPago.IdPeriodoPago;

                    // PeriodosPago ctx = new PeriodosPago();
                    //  var periodoActualizado = ctx.GetPeriodoPagoById(periodoPago.IdPeriodoPago);

                    if (!file.FileName.Contains("Plantilla"))
                    {
                        return(Json(new { error = "ERROR: Debe subir el archivo con el nombre que fue generado." }, JsonRequestBehavior.AllowGet));
                    }


                    //if (periodoActualizado.Autorizado) --
                    //{
                    //    return Json(new { error = "ERROR: No se puede subir datos a un periodo Autorizado" }, JsonRequestBehavior.AllowGet);
                    //}

                    DataTable dt = new DataTable();
                    dt = Utils.ExcelToDataTable(file, false);


                    if (dt == null)
                    {
                        return(Json(new { error = "ERROR: El archivo no tiene el formato correcto" }, JsonRequestBehavior.AllowGet));
                    }

                    DatoComplemento dc = new DatoComplemento();
                    dc.ImportarDetalleComplemento(dt, periodoPago.IdPeriodoPago);
                }
                catch (Exception)
                {
                    return(Json(new { error = "ERROR: El archivo no contiene datos correctos o esta dañado." }, JsonRequestBehavior.AllowGet));
                }
            }
            //filebatchuploadsuccess
            return(Json(new { fileuploaded = "agregado", filebatchuploadsuccess = "Batch success" }, JsonRequestBehavior.AllowGet));
        }
Beispiel #3
0
        // GET: Complemento
        public PartialViewResult Index()
        {
            int idPeriodoPago = 0;

            if (Session["periodo"] != null)
            {
                var periodoPago = Session["periodo"] as NOM_PeriodosPago;
                idPeriodoPago     = periodoPago.IdPeriodoPago;
                ViewBag.IdPeriodo = periodoPago.IdPeriodoPago;
            }

            ViewBag.IdPeriodo = idPeriodoPago;
            DatoComplemento dc     = new DatoComplemento();
            var             modelo = dc.GetDatosComplementoByIdPeriodo(idPeriodoPago);

            return(PartialView(modelo));
        }
Beispiel #4
0
        public JsonResult BorrarComplemento(int[] arrayComplemento)
        {
            DatoComplemento dc = new DatoComplemento();

            if (Session["periodo"] != null)
            {
                var periodoPago = Session["periodo"] as NOM_PeriodosPago;

                if (periodoPago == null)
                {
                }

                if (periodoPago.Autorizado)
                {
                    return(Json(new { status = "OK - El periodo esta autorizado. No se puede eliminar el registro." }, JsonRequestBehavior.AllowGet));
                }


                dc.EliminarComplemento(arrayComplemento, periodoPago.IdPeriodoPago);
            }

            return(Json(new { status = "OK - El elemento se borro " }, JsonRequestBehavior.AllowGet));
        }