Пример #1
0
        protected virtual IEnumerable <IToolbaritem> GenerarNavegadorRegistros(IGestionService service, TipoOperacion operacion, IModelView model)
        {
            var result     = new List <IToolbaritem>();
            var actionView = operacion == TipoOperacion.Editar && CanModificar ? "Edit" : "Details";

            var firstId = service.FirstRegister();

            result.Add(new ToolbarActionModel()
            {
                Icono               = "fa fa-step-backward",
                Texto               = General.LblPrimero,
                Url                 = string.IsNullOrEmpty(firstId)? string.Empty: Url.Action(actionView, new { id = firstId }),
                Desactivado         = model.GetPrimaryKey() == firstId || string.IsNullOrEmpty(firstId),
                OcultarTextoSiempre = true
            });

            var prevId = operacion == TipoOperacion.Editar || operacion == TipoOperacion.Ver? service.PreviousRegister(model.GetPrimaryKey()): string.Empty;

            result.Add(new ToolbarActionModel()
            {
                Icono               = "fa fa-caret-left",
                Texto               = General.LblAnterior,
                Url                 = Url.Action(actionView, new { id = prevId }),
                Desactivado         = operacion == TipoOperacion.Alta || string.IsNullOrEmpty(prevId),
                OcultarTextoSiempre = true
            });

            var nextId = operacion == TipoOperacion.Editar || operacion == TipoOperacion.Ver ? service.NextRegister(model.GetPrimaryKey()) : string.Empty;

            result.Add(new ToolbarActionModel()
            {
                Icono               = "fa fa-caret-right",
                Texto               = General.LblSiguiente,
                Url                 = Url.Action(actionView, new { id = nextId }),
                Desactivado         = operacion == TipoOperacion.Alta || string.IsNullOrEmpty(nextId),
                OcultarTextoSiempre = true
            });

            var lastId = service.LastRegister();

            result.Add(new ToolbarActionModel()
            {
                Icono               = "fa fa-step-forward",
                Texto               = General.LblUltimo,
                Url                 = string.IsNullOrEmpty(lastId) ? string.Empty : Url.Action(actionView, new { id = lastId }),
                Desactivado         = model.GetPrimaryKey() == lastId || string.IsNullOrEmpty(lastId),
                OcultarTextoSiempre = true
            });

            return(result);
        }
Пример #2
0
        protected virtual IEnumerable <IToolbaritem> VerToolbar(IGestionService service, IModelView model)
        {
            var result = new List <IToolbaritem>();

            //Guardar
            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-plus",
                Texto = General.BtnNuevoRegistro,
                OcultarTextoSiempre = true,
                Url         = Url.Action("Create"),
                Desactivado = !CanCrear
            });

            result.Add(new ToolbarSeparatorModel());

            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-pencil",
                Texto = General.LblEditar,
                OcultarTextoSiempre = true,
                Url         = Url.Action("Edit", new { id = model.GetPrimaryKey() }),
                Desactivado = !CanModificar
            });
            result.Add(new ToolbarSeparatorModel());
            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-trash red",
                Texto = General.LblBorrar,
                OcultarTextoSiempre = true,
                Url         = Url.Action("Delete", new { id = model.GetPrimaryKey() }),
                Desactivado = !CanEliminar
            });

            result.Add(new ToolbarSeparatorModel());

            //Navegador
            result.AddRange(GenerarNavegadorRegistros(service, TipoOperacion.Ver, model));

            return(result);
        }
Пример #3
0
 public static void GenerarCarpetaAsociadaYGuardarBD(IModelView model, TipoDocumentos tipo, IContextService context, MarfilEntities db)
 {
     using (var tran = Marfil.Inf.Genericos.Helper.TransactionScopeBuilder.CreateTransactionObject())
         using (var servModel = FService.Instance.GetService(model.GetType(), context, db))
         {
             GenerarCarpetaAsociada(model, tipo, context, db);
             if (servModel.exists(model.GetPrimaryKey()))
             {
                 servModel.edit(model);
             }
         }
 }
Пример #4
0
        protected virtual IEnumerable <IToolbaritem> DeleteToolbar(IGestionService service, IModelView model)
        {
            var result = new List <IToolbaritem>();

            //Guardar
            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-plus",
                Texto = General.BtnNuevoRegistro,
                OcultarTextoSiempre = true,
                Url         = Url.Action("Create"),
                Desactivado = !CanCrear
            });

            result.Add(new ToolbarSeparatorModel());

            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-pencil",
                Texto = General.LblEditar,
                OcultarTextoSiempre = true,
                Url         = Url.Action("Edit", new { id = model.GetPrimaryKey() }),
                Desactivado = !CanModificar
            });

            result.Add(new ToolbarSeparatorModel());

            result.Add(new ToolbarActionModel()
            {
                Icono = "fa fa-eye",
                Texto = General.LblVer,
                OcultarTextoSiempre = true,
                Url         = Url.Action("Details", new { id = model.GetPrimaryKey() }),
                Desactivado = !IsActivado
            });

            return(result);
        }
Пример #5
0
        public static void GenerarCarpetaAsociada(IModelView model, TipoDocumentos tipo, IContextService context, MarfilEntities db)
        {
            var carpetasService  = FService.Instance.GetService(typeof(CarpetasModel), context, db) as CarpetasService;
            var ejercicioService = FService.Instance.GetService(typeof(EjerciciosModel), context, db) as EjerciciosService;

            if (tipo != TipoDocumentos.Articulos && tipo != TipoDocumentos.Materiales && tipo != TipoDocumentos.GrupoMateriales && tipo != TipoDocumentos.Almacenes && tipo != TipoDocumentos.Familias && tipo != TipoDocumentos.TransformacionesAcabados)
            {
                var ejercicioModel = ejercicioService.get(model.get("Fkejercicio").ToString()) as EjerciciosModel;

                if (!carpetasService.ExisteCarpeta(Path.Combine(ConfigurationManager.AppSettings["FileManagerNodoRaiz"],
                                                                Funciones.GetEnumByStringValueAttribute(tipo), ejercicioModel.Descripcioncorta, model.get("Referencia").ToString())))
                {
                    var carpeta = carpetasService.GenerarCarpetaAsociadaDocumento(tipo, ejercicioModel.Descripcioncorta, model.get("Referencia").ToString());
                    model.set("Fkcarpetas", carpeta.Id);
                }
                else
                {
                    var ruta    = carpetasService.GenerateRutaCarpeta(tipo, ejercicioModel.Descripcioncorta, model.get("Referencia").ToString());
                    var carpeta = carpetasService.GetCarpeta(ruta);
                    model.set("Fkcarpetas", carpeta.Id);
                }
            }
            else
            {
                if (!carpetasService.ExisteCarpeta(Path.Combine(ConfigurationManager.AppSettings["FileManagerNodoRaiz"],
                                                                tipo.ToString(), "Imagenes", model.GetPrimaryKey())))
                {
                    var carpeta = carpetasService.GenerarCarpetaAsociada(tipo.ToString(), "Imagenes", model.GetPrimaryKey());
                    model.set("Fkcarpetas", carpeta.Id);
                }
                else
                {
                    var ruta    = carpetasService.GenerateRutaCarpeta(tipo.ToString(), "Imagenes", model.GetPrimaryKey());
                    var carpeta = carpetasService.GetCarpeta(ruta);
                    model.set("Fkcarpetas", carpeta.Id);
                }
            }
        }