public bool Create(ref ValidationErrors errors, SysModuleOperateModel model)
 {
     try
     {
         SysModuleOperate entity = m_Rep.GetById(model.Id);
         if (entity != null)
         {
             errors.Add(Suggestion.PrimaryRepeat);
             return false;
         }
         entity = new SysModuleOperate();
         entity.Id = model.Id;
         entity.Name = model.Name;
         entity.KeyCode = model.KeyCode;
         entity.ModuleId = model.ModuleId;
         entity.IsValid = model.IsValid;
         entity.Sort = model.Sort;
         if (m_Rep.Create(entity) == 1)
         {
             return true;
         }
         else
         {
             errors.Add(Suggestion.InsertFail);
             return false;
         }
     }
     catch (Exception ex)
     {
         errors.Add(ex.Message);
         ExceptionHander.WriteException(ex);
         return false;
     }
 }
 public ActionResult CreateOpt(string moduleId)
 {
     ViewBag.Perm = GetPermission();
     SysModuleOperateModel sysModuleOptModel = new SysModuleOperateModel();
     sysModuleOptModel.ModuleId = moduleId;
     sysModuleOptModel.IsValid = true;
     return View(sysModuleOptModel);
 }
 public SysModuleOperateModel GetById(string id)
 {
     if (IsExist(id))
     {
         SysModuleOperate entity = m_Rep.GetById(id);
         SysModuleOperateModel model = new SysModuleOperateModel();
         model.Id = entity.Id;
         model.Name = entity.Name;
         model.KeyCode = entity.KeyCode;
         model.ModuleId = entity.ModuleId;
         model.IsValid = entity.IsValid;
         model.Sort = entity.Sort;
         return model;
     }
     else
     {
         return null;
     }
 }
        public JsonResult CreateOpt(SysModuleOperateModel info)
        {
            if (info != null && ModelState.IsValid)
            {
                SysModuleOperateModel entity = operateBLL.GetById(info.Id);
                if (entity != null)
                    return Json(JsonHandler.CreateMessage(0, Suggestion.PrimaryRepeat), JsonRequestBehavior.AllowGet);
                entity = new SysModuleOperateModel();
                entity.Id = info.ModuleId + info.KeyCode;
                entity.Name = info.Name;
                entity.KeyCode = info.KeyCode;
                entity.ModuleId = info.ModuleId;
                entity.IsValid = info.IsValid;
                entity.Sort = info.Sort;

                if (operateBLL.Create(ref errors, entity))
                {
                    SysLogBLL.WriteServiceLog(GetUserId(), "Id:" + info.Id + ",Name:" + info.Name, "成功", "创建", "模块设置");
                    return Json(JsonHandler.CreateMessage(1, Suggestion.InsertSucceed), JsonRequestBehavior.AllowGet);
                }
                else
                {
                    string ErrorCol = errors.Error;
                    SysLogBLL.WriteServiceLog(GetUserId(), "Id:" + info.Id + ",Name:" + info.Name + "," + ErrorCol, "失败", "创建", "模块设置");
                    return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail + ErrorCol), JsonRequestBehavior.AllowGet);
                }
            }
            else
            {
                return Json(JsonHandler.CreateMessage(0, Suggestion.InsertFail), JsonRequestBehavior.AllowGet);
            }
        }