Exemplo n.º 1
0
		public void InitEditModel(SysSubSystem sysSubSystem)
        {
            this.SubSystem = sysSubSystem;

            this.IconString = sysSubSystem.IconString;
            this.MetroBackColor = sysSubSystem.MetroBackColor;
            this.MetroForeColor = sysSubSystem.MetroForeColor;
            this.MetroType = sysSubSystem.MetroType;
            this.Remark = sysSubSystem.Remark;
            this.SubSystemCode = sysSubSystem.SubSystemCode;
            this.SubSystemName = sysSubSystem.SubSystemName;

            if(sysSubSystem.SysMenus != null && sysSubSystem.SysMenus.Count >0)
            {
                this.SysMenus = new List<MenuEditModel>();
                ICollection<SysMenu> subMenus = sysSubSystem.SysMenus;
                foreach (SysMenu sysmenu in subMenus)
                {
                    MenuEditModel submenu = new MenuEditModel();
                    submenu.InitEditModel(sysmenu);
                    this.SysMenus.Add(submenu);
                }
            }
            else
            {
                this.SysMenus = null;
            }
        }
Exemplo n.º 2
0
 public SubSystemEditModel GetSubSystemByCode(string code)
 {
     try
     {
         SubSystemEditModel        subSystemEditModel = new SubSystemEditModel();
         Repository <SysSubSystem> sysSubSystemDal    = this._unitOfWork.GetRepository <SysSubSystem>();
         SysSubSystem sysSubSystem = sysSubSystemDal.GetObjectByKey(code).Entity;
         if (sysSubSystem != null)
         {
             subSystemEditModel.InitEditModel(sysSubSystem);
         }
         return(subSystemEditModel);
     }
     catch (RepositoryException rex)
     {
         string msg    = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg    = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
 }
Exemplo n.º 3
0
        public SubSystemEditModel SetSubSystemMenu(SubSystemEditModel newSubSystem, List <string> menuCodes)
        {
            try
            {
                Repository <SysSubSystem> sysSubSystemDal = this._unitOfWork.GetRepository <SysSubSystem>();
                SysSubSystem sysSubSystem = sysSubSystemDal.GetObjectByKey(newSubSystem.SubSystemCode).Entity;
                if (sysSubSystem != null)
                {
                    sysSubSystem.Remark         = newSubSystem.Remark;
                    sysSubSystem.MetroType      = newSubSystem.MetroType;
                    sysSubSystem.MetroBackColor = newSubSystem.MetroBackColor;
                    sysSubSystem.MetroForeColor = newSubSystem.MetroForeColor;
                    sysSubSystem.IconString     = newSubSystem.IconString;
                    if (sysSubSystem.SysMenus != null && sysSubSystem.SysMenus.Count > 0)
                    {
                        sysSubSystem.SysMenus.Clear();
                    }

                    if (menuCodes != null && menuCodes.Count > 0)
                    {
                        List <SysMenu>       sysMenuListTemp = new List <SysMenu>();
                        Repository <SysMenu> sysMenuDal      = _unitOfWork.GetRepository <SysMenu>();
                        foreach (string menuCode in menuCodes)
                        {
                            SysMenu sysMenu = sysMenuDal.GetObjectByKey(menuCode).Entity;
                            sysMenuListTemp.Add(sysMenu);
                        }
                        sysSubSystem.SysMenus = sysMenuListTemp;
                    }
                }
                _unitOfWork.AddAction(sysSubSystem, DataActions.Update);
                _unitOfWork.Save();
                return(newSubSystem);
            }
            catch (RepositoryException rex)
            {
                string msg    = rex.Message;
                string reason = rex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
            catch (Exception ex)
            {
                string msg    = ex.Message;
                string reason = ex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
        }
Exemplo n.º 4
0
        public SubSystemEditModel Add(SubSystemEditModel newSubSystem)
        {
            try
            {
                if (CheckCodeExists(newSubSystem.SubSystemCode))
                {
                    throw new FaultException <LCFault>(new LCFault("子菜单添加失败"), "该子菜单编号已存在,不能重复添加");
                }
                if (CheckNameExists(newSubSystem.SubSystemName))
                {
                    throw new FaultException <LCFault>(new LCFault("子菜单添加失败"), "该子菜单编号已存在,不能重复添加");
                }

                SysSubSystem sysSubSystem = new SysSubSystem();
                sysSubSystem.IconString     = newSubSystem.IconString;
                sysSubSystem.MetroBackColor = newSubSystem.MetroBackColor;
                sysSubSystem.MetroForeColor = newSubSystem.MetroForeColor;
                sysSubSystem.MetroType      = newSubSystem.MetroType;
                sysSubSystem.Remark         = newSubSystem.Remark;
                sysSubSystem.SubSystemCode  = newSubSystem.SubSystemCode;
                sysSubSystem.SubSystemName  = newSubSystem.SubSystemName;

                this._unitOfWork.AddAction(sysSubSystem, DataActions.Add);
                this._unitOfWork.Save();
                return(newSubSystem);
            }
            catch (RepositoryException rex)
            {
                string msg    = rex.Message;
                string reason = rex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
            catch (Exception ex)
            {
                string msg    = ex.Message;
                string reason = ex.StackTrace;
                throw new FaultException <LCFault>
                          (new LCFault(msg), reason);
            }
        }
Exemplo n.º 5
0
 public SubSystemEditModel Update(SubSystemEditModel newSubSystem)
 {
     try
     {
         if (newSubSystem == null)
         {
             return(null);
         }
         Repository <SysSubSystem> sysSubSystemDal = this._unitOfWork.GetRepository <SysSubSystem>();
         SysSubSystem sysSubSystem = sysSubSystemDal.GetObjectByKey(newSubSystem.SubSystemCode).Entity;
         if (sysSubSystem != null)
         {
             sysSubSystem.SubSystemCode  = newSubSystem.SubSystemCode;
             sysSubSystem.SubSystemName  = newSubSystem.SubSystemName;
             sysSubSystem.Remark         = newSubSystem.Remark;
             sysSubSystem.MetroBackColor = newSubSystem.MetroBackColor;
             sysSubSystem.MetroForeColor = newSubSystem.MetroForeColor;
             sysSubSystem.MetroType      = newSubSystem.MetroType;
             sysSubSystem.IconString     = newSubSystem.IconString;
         }
         this._unitOfWork.AddAction(sysSubSystem, DataActions.Update);
         this._unitOfWork.Save();
         return(newSubSystem);
     }
     catch (RepositoryException rex)
     {
         string msg    = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg    = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
 }
Exemplo n.º 6
0
 public bool DeleteByCode(string code)
 {
     try
     {
         bool res = true;
         Repository <SysSubSystem> sysSubSystemDal = this._unitOfWork.GetRepository <SysSubSystem>();
         SysSubSystem sysSubSystem = sysSubSystemDal.GetObjectByKey(code).Entity;
         if (sysSubSystem != null)
         {
             if (sysSubSystem.SysMenus != null && sysSubSystem.SysMenus.Count > 0)
             {
                 sysSubSystem.SysMenus.Clear();
             }
             this._unitOfWork.AddAction(sysSubSystem, DataActions.Delete);
             this._unitOfWork.Save();
         }
         else
         {
             res = false;
             throw new FaultException <LCFault>(new LCFault("子菜单删除失败"), "该子菜单编号不存在,无法删除");
         }
         return(res);
     }
     catch (RepositoryException rex)
     {
         string msg    = rex.Message;
         string reason = rex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
     catch (Exception ex)
     {
         string msg    = ex.Message;
         string reason = ex.StackTrace;
         throw new FaultException <LCFault>
                   (new LCFault(msg), reason);
     }
 }