예제 #1
0
 public virtual bool Insert(SMC_Functions function)
 {
     try
     {
         SMC_AutoTableIDDao autoDao = new SMC_AutoTableIDDao(AppConfig.statisticDBKey);
         if (autoDao.HasMaxID("SMC_Functions"))
         {
             int max_id = autoDao.GetMaxID("SMC_Functions");
             function.FN_ID = max_id + 1;
         }
         else
         {
             function.FN_ID = 1;
         }
         int i = SMC_FunctionsDao.Insert(function);
         if (i > 0)
         {
             autoDao.UpdateMaxID("SMC_Functions");
         }
         return(i > 0);
     }
     catch (DalException ex)
     {
         throw new BOException("调用方法Insert失败", ex);
     }
 }
예제 #2
0
        private void parseChildTreeData(Hashtable pHash, SMC_Functions parent_fncs, SMC_FunctionRoleDao frDao)
        {
            IList <SMC_Functions> funcs = SMC_FunctionsDao.QueryFunctionsByUpperFNIDForSystemManager(parent_fncs.FN_ID);

            if (funcs != null && funcs.Count > 0)
            {
                List <Hashtable> objs = new List <Hashtable>();
                foreach (SMC_Functions fn in funcs)
                {
                    Hashtable hash = new Hashtable();
                    hash["id"]   = fn.FN_ID;
                    hash["name"] = fn.FN_Name;
                    //hash["url"] = "/AuthManage/FunctionList?upper_fn_id=" + fn.FN_ID;

                    if (SMC_FunctionsDao.HasChild(fn.FN_ID))
                    {
                        hash["url"]    = "/AuthManage/FunctionList?upper_fn_id=" + fn.FN_ID;
                        hash["target"] = "ifrm";
                    }
                    else
                    {   //叶节点
                        hash["url"]    = "/AuthManage/AddModifyFunction?upper_fn_id=" + parent_fncs.FN_ID + "&FN_ID=" + fn.FN_ID;
                        hash["target"] = "_top";
                    }
                    parseChildTreeData(hash, fn, frDao);
                    objs.Add(hash);
                }
                if (objs.Count > 0)
                {
                    pHash["children"] = objs;
                }
            }
        }
예제 #3
0
 public virtual int Save(SMC_Functions entity)
 {
     if (SMC_FunctionsDao.Get(entity.FN_ID) == null)
     {
         return(SMC_FunctionsDao.Insert(entity));
     }
     else
     {
         return(SMC_FunctionsDao.Update(entity));
     }
 }
예제 #4
0
 public virtual void Delete(SMC_Functions entity)
 {
     try
     {
         SMC_FunctionsDao.Delete(entity);
     }
     catch (DalException ex)
     {
         throw new BOException("Delete", ex);
     }
 }
예제 #5
0
 public virtual bool Update(SMC_Functions function)
 {
     try
     {
         int i = SMC_FunctionsDao.Update(function);
         return(i > 0);
     }
     catch (DalException ex)
     {
         throw new BOException("调用方法Update失败", ex);
     }
 }
예제 #6
0
        public ActionResult DelFunction(int fn_id)
        {
            JsonReturnMessages data = new JsonReturnMessages()
            {
                IsSuccess = true, Msg = "操作成功"
            };
            SMC_Functions fn = BoFactory.GetSMC_FunctionsBo.Get(fn_id);

            //判断权限是否有下一级权限,如有则不能删除
            var func = BoFactory.GetSMC_FunctionsBo.GetFunctionsByUpperId(fn_id);
            int i    = func.Count;

            //判断有否有角色关联
            //BoFactory.GetSMC_FunctionsBo.QueryFunctionsByRoleID

            if (i > 0)
            {
                data.IsSuccess = false;
                data.Msg       = "已有下级权限,请先删除下级权限!";
            }
            else
            if (fn != null)
            {
                BoFactory.GetSMC_FunctionRoleBo.DeleteByFID(fn_id);
                BoFactory.GetSMC_FunctionsBo.Delete(fn);

                //删除图标
                string saveDir  = HttpRuntime.AppDomainAppPath + AppConfig.FuncIconFolder;
                string savePath = "";
                string fileName = fn_id.ToString() + "_SIcon.png";
                savePath = System.IO.Path.Combine(saveDir, fileName);
                if (System.IO.File.Exists(savePath))
                {
                    System.IO.File.Delete(savePath);
                }
                fileName = fn_id.ToString() + "_Icon.png";
                savePath = System.IO.Path.Combine(saveDir, fileName);
                if (System.IO.File.Exists(savePath))
                {
                    System.IO.File.Delete(savePath);
                }
            }
            return(Json(data));
        }
예제 #7
0
        private void parseChildTreeData(Hashtable pHash, SMC_Functions parent_fncs, SMC_FunctionRoleDao frDao, int RoleId)
        {
            IList <SMC_Functions> funcs = SMC_FunctionsDao.QueryFunctionsByUpperFNIDForUnitManager(parent_fncs.FN_ID);

            if (funcs != null && funcs.Count > 0)
            {
                List <Hashtable> objs = new List <Hashtable>();
                foreach (SMC_Functions fn in funcs)
                {
                    Hashtable hash = new Hashtable();
                    hash["id"]      = fn.FN_ID;
                    hash["name"]    = fn.FN_Name;
                    hash["checked"] = frDao.IsFunctionInRole(fn.FN_ID, RoleId);
                    parseChildTreeData(hash, fn, frDao, RoleId);
                    objs.Add(hash);
                }
                if (objs.Count > 0)
                {
                    pHash["children"] = objs;
                }
            }
        }
예제 #8
0
        public virtual bool InsertOrUpdate(SMC_Functions functions)
        {
            try
            {
                int i = 0;
                if (SMC_FunctionsDao.Get(functions.FN_ID) == null)
                {
                    //i = SMC_FunctionsDao.Insert(functions);
                    SMC_AutoTableIDDao autoDao = new SMC_AutoTableIDDao(AppConfig.statisticDBKey);
                    if (autoDao.HasMaxID("SMC_Functions"))
                    {
                        int max_id = autoDao.GetMaxID("SMC_Functions");
                        functions.FN_ID = max_id + 1;
                    }
                    else
                    {
                        functions.FN_ID = 1;
                    }
                    i = SMC_FunctionsDao.Insert(functions);
                    if (true)
                    {
                        autoDao.UpdateMaxID("SMC_Functions");
                    }
                }
                else
                {
                    i = SMC_FunctionsDao.Update(functions);
                }

                return(true);
            }
            catch (DalException ex)
            {
                throw new BOException("调用方法InsertOrUpdate失败", ex);
            }
        }
예제 #9
0
        public ActionResult AddModifyFunctionSave(string FN_ID, string Unit_ID, string FN_Code, string Upper_FN_ID, string Upper_FN_Name, string fn_type, string fn_disabled, string fn_visibletype, string FN_Name, string FN_Url, int FN_Sequence, string FN_Demo)
        {
            JsonReturnMessages data = new JsonReturnMessages()
            {
                IsSuccess = true, Msg = "操作成功"
            };

            if (BoFactory.GetSMC_FunctionsBo.ExistsByCode(FN_Code) && int.Parse(FN_ID) == 0)
            {
                data = new JsonReturnMessages()
                {
                    IsSuccess = false, Msg = "权限Code已经存在!"
                };
                return(Json(data));
            }


            SMC_Functions func = null;

            if (FN_ID == "0" || String.IsNullOrEmpty(FN_ID))
            {
                func = new SMC_Functions();
                func.FN_CreatedTime = DateTime.Now;
            }
            else
            {
                func = BoFactory.GetSMC_FunctionsBo.Get(int.Parse(FN_ID));
            }
            func.FN_VisibleType = fn_visibletype;
            func.FN_Disabled    = fn_disabled == "1" ? true : false;
            func.FN_Demo        = FN_Demo;
            func.FN_Name        = FN_Name;
            func.FN_Code        = FN_Code;
            func.FN_Sequence    = FN_Sequence;
            int upper_fn_id = 0;

            if (!String.IsNullOrEmpty(Upper_FN_Name))
            {
                upper_fn_id = int.Parse(Upper_FN_Name);
            }
            //int unit_id = 0;
            //if (!String.IsNullOrEmpty(Unit_ID))
            //    unit_id = int.Parse(Unit_ID);

            func.Upper_FN_ID = upper_fn_id;
            func.FN_ID       = int.Parse(FN_ID);
            func.FN_Url      = FN_Url;
            func.FN_Type     = fn_type;
            func.Unit_ID     = Unit_ID;

            BoFactory.GetSMC_FunctionsBo.InsertOrUpdate(func);

            string saveDir  = HttpRuntime.AppDomainAppPath + AppConfig.FuncIconFolder;
            string savePath = "";

            if (Request.Files.Count > 0)
            {
                if (Request.Files[0].ContentLength > 0)
                {
                    //有小图标文件
                    string fileName = func.FN_ID.ToString() + "_SIcon.png";
                    savePath = System.IO.Path.Combine(saveDir, fileName);
                    if (!System.IO.Directory.Exists(saveDir))
                    {
                        System.IO.Directory.CreateDirectory(saveDir);
                    }
                    if (System.IO.File.Exists(savePath))
                    {
                        System.IO.File.Delete(savePath);
                    }
                    Request.Files[0].SaveAs(savePath);
                }
                if (Request.Files[1].ContentLength > 0)
                {
                    //有图标文件
                    string fileName = func.FN_ID.ToString() + "_Icon.png";
                    savePath = System.IO.Path.Combine(saveDir, fileName);
                    if (!System.IO.Directory.Exists(saveDir))
                    {
                        System.IO.Directory.CreateDirectory(saveDir);
                    }
                    if (System.IO.File.Exists(savePath))
                    {
                        System.IO.File.Delete(savePath);
                    }
                    Request.Files[1].SaveAs(savePath);
                }
            }

            return(Json(data, "text/html"));
        }
예제 #10
0
        public ActionResult AddModifyFunction(int?FN_ID)
        {
            SMC_Functions func = null;

            if (FN_ID != null && FN_ID.Value > 0)
            {
                func = BoFactory.GetSMC_FunctionsBo.Get(FN_ID.Value);
            }
            int    Upper_FN_ID   = int.Parse(Request.QueryString["Upper_FN_ID"]);
            string Upper_FN_Name = string.Empty;

            if (Upper_FN_ID != null && Upper_FN_ID > 0)
            {
                Upper_FN_Name = BoFactory.GetSMC_FunctionsBo.Get(Upper_FN_ID).FN_Name;
            }
            else
            {
                Upper_FN_Name = "权限";
            }


            //权限列表
            List <SelectListItem> fnList = new List <SelectListItem>();
            IList <SMC_Functions> funcs  = BoFactory.GetSMC_FunctionsBo.GetAllFunctions();

            if (Upper_FN_ID == 0)
            {
                fnList.Add(new SelectListItem {
                    Text = "权限", Value = "0", Selected = true
                });
            }
            else
            {
                fnList.Add(new SelectListItem {
                    Text = "权限", Value = "0", Selected = false
                });
            }
            foreach (SMC_Functions f in funcs)
            {
                if (f.FN_ID != FN_ID)
                {
                    fnList.Add(new SelectListItem {
                        Text = f.FN_Name, Value = f.FN_ID.ToString(), Selected = f.FN_ID == Upper_FN_ID
                    });
                }
            }

            //权限类型列表
            List <SelectListItem> fn_type = new List <SelectListItem>();

            fn_type.Add(new SelectListItem {
                Text = "菜单", Value = "Menu"
            });
            fn_type.Add(new SelectListItem {
                Text = "权限", Value = "Func"
            });
            fn_type.Add(new SelectListItem {
                Text = "目录", Value = "Dir"
            });
            if (func != null)
            {
                foreach (var sitem in fn_type)
                {
                    if (sitem.Value == func.FN_Type)
                    {
                        sitem.Selected = true;
                        break;
                    }
                }
            }

            //可见类型列表
            List <SelectListItem> fn_visibletype = new List <SelectListItem>();

            fn_visibletype.Add(new SelectListItem {
                Text = "所有人可见", Value = "0"
            });
            fn_visibletype.Add(new SelectListItem {
                Text = "只单位管理员可见", Value = "1"
            });
            fn_visibletype.Add(new SelectListItem {
                Text = "只系统管理员可见", Value = "2"
            });

            //是否锁定
            List <SelectListItem> fn_disabled = new List <SelectListItem>();

            fn_disabled.Add(new SelectListItem {
                Text = "未锁定", Value = "0"
            });
            fn_disabled.Add(new SelectListItem {
                Text = "锁定", Value = "1"
            });

            ViewData["Upper_FN_Name"]  = fnList;
            ViewData["fn_type"]        = fn_type;
            ViewData["fn_visibletype"] = fn_visibletype;
            ViewData["fn_disabled"]    = fn_disabled;
            //ViewData["Upper_FN_Name"] = Upper_FN_Name;
            return(View(func));
        }