Exemplo n.º 1
0
 public void ActionApply(ModCVEModel model)
 {
     if (ValidSave(model))
     {
         ApplyRedirect(model.RecordID, entity.ID);
     }
 }
Exemplo n.º 2
0
 public void ActionSaveNew(ModCVEModel model)
 {
     if (ValidSave(model))
     {
         SaveNewRedirect(model.RecordID, entity.ID);
     }
 }
Exemplo n.º 3
0
        public void ActionImportData(ModCVEModel model)
        {
            CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error;

            string filePath = CPViewPage.Server.MapPath(model.File);

            if (!filePath.EndsWith(".xls") && !filePath.EndsWith(".xlsx"))
            {
                CPViewPage.Message.ListMessage.Add("File không đúng định dạng (yêu cầu: .xls, .xlsx).");
            }
            else if (!System.IO.File.Exists(filePath))
            {
                CPViewPage.Message.ListMessage.Add("File không tồn tại.");
            }

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                model.FilePath = filePath;
                string msg = "", success = "";
                int    count = Excel.ImportExcel_CVE(model, ref msg, ref success);

                if (!string.IsNullOrEmpty(msg))
                {
                    CPViewPage.Message.ListMessage.Add(msg);
                }
                else
                {
                    CPViewPage.SetMessage("Đã import được " + count + " sự cố." + success);
                }

                //CPViewPage.CPRedirect("ModCVE/Index.aspx");
                //CPViewPage.Request.RawUrl.Replace("Import.aspx", "Index.aspx");
            }
        }
Exemplo n.º 4
0
 public void ActionSave(ModCVEModel model)
 {
     if (ValidSave(model))
     {
         SaveRedirect();
     }
 }
Exemplo n.º 5
0
        public void ActionImport(ModCVEModel model)
        {
            if (model.MenuID > 0)
            {
            }
            else
            {
            }

            ViewBag.Data  = new ModFileExcelEntity();
            ViewBag.Model = model;
        }
Exemplo n.º 6
0
        public void ActionIndex(ModCVEModel model)
        {
            // sap xep tu dong
            string orderBy = AutoSort(model.Sort);

            // tao danh sach
            var dbQuery = ModCVEService.Instance.CreateQuery()
                          .Where(model.State > 0, o => (o.State & model.State) == model.State)
                          .WhereIn(o => o.MenuID, WebMenuService.Instance.GetChildIDForCP("CVE", model.MenuID, model.LangID))
                          .Take(model.PageSize)
                          .OrderBy(orderBy)
                          .Skip(model.PageIndex * model.PageSize);

            ViewBag.Data      = dbQuery.ToList();
            model.TotalRecord = dbQuery.TotalRecord;
            ViewBag.Model     = model;
        }
Exemplo n.º 7
0
        public void ActionAdd(ModCVEModel model)
        {
            if (model.RecordID > 0)
            {
                entity = ModCVEService.Instance.GetByID(model.RecordID);

                // khoi tao gia tri mac dinh khi update
                entity.Updated = DateTime.Now;
            }
            else
            {
                entity = new ModCVEEntity();

                // khoi tao gia tri mac dinh khi insert
                entity.MenuID   = model.MenuID;
                entity.Activity = CPViewPage.UserPermissions.Approve;
                entity.Order    = GetMaxOrder(model);
            }

            ViewBag.Data  = entity;
            ViewBag.Model = model;
        }
Exemplo n.º 8
0
        private bool ValidSave(ModCVEModel model)
        {
            TryUpdateModel(entity);

            //chong hack
            entity.ID = model.RecordID;

            ViewBag.Data  = entity;
            ViewBag.Model = model;

            CPViewPage.Message.MessageType = Message.MessageTypeEnum.Error;

            //kiem tra quyen han
            if ((model.RecordID < 1 && !CPViewPage.UserPermissions.Add) || (model.RecordID > 0 && !CPViewPage.UserPermissions.Edit))
            {
                CPViewPage.Message.ListMessage.Add("Quyền hạn chế.");
            }

            //kiem tra chuyen muc
            if (entity.MenuID < 1)
            {
                CPViewPage.Message.ListMessage.Add("Chọn chuyên mục.");
            }

            if (CPViewPage.Message.ListMessage.Count == 0)
            {
                //cap nhat state
                entity.State = GetState(model.ArrState);

                //save
                ModCVEService.Instance.Save(entity);

                return(true);
            }

            return(false);
        }
Exemplo n.º 9
0
 private int GetMaxOrder(ModCVEModel model)
 {
     return(ModCVEService.Instance.CreateQuery()
            .Max(o => o.Order)
            .ToValue().ToInt(0) + 1);
 }