protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        try
        {
            //当前职员。
            string staffId = Request.QueryString["id"];
            Staff  staff   = CommonSrv.LoadObjectById(typeof(Staff), staffId) as Staff;

            //权限。
            SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights");

            //生成树节点。
            IList topModuleTypes = ModuleTypeSrv.GetAllTopModuleType();
            foreach (ModuleType mt in topModuleTypes)
            {
                Microsoft.Web.UI.WebControls.TreeNode node = new Microsoft.Web.UI.WebControls.TreeNode();
                tvRights.Nodes.Add(node);
                node.Type = "moduletype";
                node.Text = mt.Name;

                AddSubNodes(node, mt, staff, sct);

                node.Expanded = true;
            }
        }
        catch (Exception ex)
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script type=\"text/javascript\">error=true;</script>");
            log.Error(null, ex);
        }
    }
Beispiel #2
0
        public ActionResult EditModule(string Id)
        {
            Module    mt   = CommonSrv.LoadObjectById(typeof(Module), Id) as Module;
            ModuleDTO mdto = new ModuleDTO();

            mdto.Id           = mt.Id;
            mdto.ModuleTypeId = mt.ModuleType.Id;
            mdto.ModuleUrl    = mt.ModuleUrl;
            mdto.Name         = mt.Name;
            mdto.OrderId      = mt.OrderId;
            mdto.Remark       = mt.Remark;
            mdto.Tag          = mt.Tag;
            //获取 syscode - rights
            SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights");

            if (sct != null)
            {
                foreach (SysCode sc in sct.SysCodes)
                {
                    if (mt.ModuleRights.ContainsKey(sc.Tag))
                    {
                        mdto.ModuleRights.Add(sc.Name + "|" + sc.Tag + "|" + sc.Id + "|√");
                    }
                    else
                    {
                        mdto.ModuleRights.Add(sc.Name + "|" + sc.Tag + "|" + sc.Id);
                    }
                }
            }
            return(View("ModuleInfo", mdto));
        }
Beispiel #3
0
    private void LoadSysCodeTree()
    {
        IList ilSysCodeType = SysCodeTypeSrv.GetAllSysCodeType();

        foreach (SysCodeType sct in ilSysCodeType)
        {
            Microsoft.Web.UI.WebControls.TreeNode node = new Microsoft.Web.UI.WebControls.TreeNode();
            tvSysCodes.Nodes[0].Nodes.Add(node);
            node.Type    = "syscodetype";
            node.Text    = sct.Name;
            node.PKId    = sct.Id;
            node.OrderId = sct.OrderId.ToString();

            foreach (SysCode sc in sct.SysCodes)
            {
                Microsoft.Web.UI.WebControls.TreeNode node2 = new Microsoft.Web.UI.WebControls.TreeNode();
                node.Nodes.Add(node2);
                node2.Type    = "syscode";
                node2.Text    = sc.Name;
                node2.PKId    = sc.Id;
                node2.OrderId = sc.OrderId.ToString();
            }
        }

        tvSysCodes.Nodes[0].Expanded = true;
    }
        /// <summary>
        /// 获取 权限代码 tree
        /// </summary>
        /// <returns></returns>
        public ActionResult SysCodeTree(string Id)
        {
            if (!string.IsNullOrEmpty(Id))
            {
                return(null);
            }

            IList rootNodeTypeList = new List <NodeType>();

            var rootNodeType = new NodeType();

            rootNodeType.id    = "0";
            rootNodeType.text  = "权限代码维护";
            rootNodeType.state = "open";
            rootNodeType.ntype = "root";

            IList ilSysCodeType = SysCodeTypeSrv.GetAllSysCodeType();

            foreach (SysCodeType sct in ilSysCodeType)
            {
                var nodeType = new NodeType();
                nodeType.id    = sct.Id;
                nodeType.text  = sct.Name;
                nodeType.ntype = "sysCodeType";
                if (sct.SysCodes.Count > 0)
                {
                    nodeType.state    = "closed";
                    nodeType.children = new List <NodeType>();
                    foreach (SysCode sc in sct.SysCodes)
                    {
                        var nodeSubType = new NodeType();
                        nodeSubType.id     = sc.Id;
                        nodeSubType.text   = sc.Name;
                        nodeSubType.suburl = sc.Tag;
                        nodeSubType.ntype  = "sysCode";
                        nodeSubType.tag    = sc.Tag;
                        nodeType.children.Add(nodeSubType);
                    }
                }

                rootNodeTypeList.Add(nodeType);
            }

            rootNodeType.children = rootNodeTypeList;

            List <NodeType> rootListNodeType = new List <NodeType>();

            rootListNodeType.Add(rootNodeType);
            string jsonResult = JsonConvert.SerializeObject(rootListNodeType, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            return(Content(jsonResult, "application/json"));
        }
 public string SysCodeTypeDel(string Id)
 {
     try
     {
         SysCodeTypeSrv.DeleteSysCodeType(Id);
     }
     catch (Exception e)
     {
         return("-1");
     }
     return("1");
 }
Beispiel #6
0
    private void InitModuleRights()
    {
        SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights");

        if (sct != null)
        {
            StringBuilder sb = new StringBuilder();
            foreach (SysCode sc in sct.SysCodes)
            {
                sb.Append("<div><span id='" + sc.Tag + "' class='redSpanCheck'></span>" + sc.Name + "</div>");
            }
            divRights.InnerHtml = sb.ToString();
        }
    }
Beispiel #7
0
        public ActionResult CreateModule(string Id)
        {
            ModuleDTO dto = new ModuleDTO();

            dto.ModuleTypeId = Id;

            //获取 syscode - rights
            SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights");

            if (sct != null)
            {
                foreach (SysCode sc in sct.SysCodes)
                {
                    dto.ModuleRights.Add(sc.Name + "|" + sc.Tag + "|" + sc.Id);
                }
            }
            return(View("ModuleInfo", dto));
        }
Beispiel #8
0
        public JsonResult ModuleInfo(string Id)
        {
            JsonResult jresult = new JsonResult();

            jresult.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
            try
            {
                Module    mt   = CommonSrv.LoadObjectById(typeof(Module), Id) as Module;
                ModuleDTO mdto = new ModuleDTO();
                mdto.Id           = mt.Id;
                mdto.ModuleTypeId = mt.ModuleType.Id;
                mdto.ModuleUrl    = mt.ModuleUrl;
                mdto.Name         = mt.Name;
                mdto.OrderId      = mt.OrderId;
                mdto.Remark       = mt.Remark;
                mdto.Tag          = mt.Tag;
                mdto.Disabled     = mt.Disabled == 1 ? true : false;
                //获取 syscode - rights
                SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights");
                if (sct != null)
                {
                    foreach (SysCode sc in sct.SysCodes)
                    {
                        if (mt.ModuleRights.ContainsKey(sc.Tag))
                        {
                            mdto.ModuleRights.Add(sc.Name + "|√");
                        }
                        else
                        {
                            mdto.ModuleRights.Add(sc.Name);
                        }
                    }
                }
                jresult.Data = mdto;
            }
            catch
            {
                //TODO js 异常判断
                jresult.Data = "[{result:-1}]";
            }
            return(jresult);
        }
Beispiel #9
0
        public ActionResult PermissionsTree(string Id)
        {
            Staff role = CommonSrv.LoadObjectById(typeof(Staff), Id) as Staff;
            //权限。
            SysCodeType sct   = SysCodeTypeSrv.GetSysCodeTypeByTag("rights");
            NodeType    ntype = new NodeType();

            ntype.id    = "0";
            ntype.text  = "模块分类";
            ntype.ntype = "root";
            IList ilModuleType = ModuleTypeSrv.GetAllTopModuleType();
            var   ilNodeType   = GetModulePermissionList(ilModuleType, sct, role);

            ntype.children = ilNodeType;
            var rNodeType = new List <NodeType>();

            rNodeType.Add(ntype);
            string jsonResult = JsonConvert.SerializeObject(rNodeType, Formatting.Indented, new JsonSerializerSettings {
                NullValueHandling = NullValueHandling.Ignore
            });

            return(Content(jsonResult, "application/json"));
        }
 public ActionResult SysCodeTypeInfo(SysCodeTypeDTO sysCodeType)
 {
     if (ModelState.IsValid)
     {
         //添加
         if (string.IsNullOrEmpty(sysCodeType.Id))
         {
             string result = SysCodeTypeSrv.InsertSysCodeType(sysCodeType);
             if (!string.IsNullOrEmpty(result) && result != "-2")
             {
                 result = "1";
             }
             return(Content(result, "text/plain"));
         }
         else
         {
             //编辑
             string result = SysCodeTypeSrv.UpdateSysCodeType(sysCodeType);
             return(Content(result, "text/plain"));
         }
     }
     return(View(sysCodeType));
 }
Beispiel #11
0
    protected void Page_Load(object sender, EventArgs e)
    {
        Response.Cache.SetCacheability(HttpCacheability.NoCache);

        try
        {
            //模块权限。
            SysCodeType sct = SysCodeTypeSrv.GetSysCodeTypeByTag("rights");

            StringBuilder sb = new StringBuilder();

            if (Request.QueryString["mode"] == "new")
            {
                divTitleMess.InnerText = "新增模块";

                if (sct != null)
                {
                    for (int i = 0; i < sct.SysCodes.Count; i++)
                    {
                        SysCode sc = sct.SysCodes[i] as SysCode;
                        sb.Append("<div><input type=checkbox id='" + sc.Tag + "' />" + sc.Name + "</div>");
                    }
                    divRights.InnerHtml = sb.ToString();
                }
            }
            else if (Request.QueryString["mode"] == "edit")
            {
                divTitleMess.InnerText = "编辑模块";

                string id = Request.QueryString["id"];
                if (id != null)
                {
                    Module m = CommonSrv.LoadObjectById(typeof(Module), id) as Module;
                    txtModuleTag.Value       = m.Tag;
                    txtModuleName.Value      = m.Name;
                    txtModuleOrderId.Value   = m.OrderId.ToString();
                    txtaModuleRemark.Value   = m.Remark;
                    txtModuleModuleUrl.Value = m.ModuleUrl;
                    cbModuleDisabled.Checked = (m.Disabled == 1);

                    if (sct != null)
                    {
                        for (int i = 0; i < sct.SysCodes.Count; i++)
                        {
                            SysCode sc = sct.SysCodes[i] as SysCode;
                            if (m.ModuleRights.Contains(sc.Tag))
                            {
                                sb.Append("<div><input type=checkbox checked id='" + sc.Tag + "' />" + sc.Name + "</div>");
                            }
                            else
                            {
                                sb.Append("<div><input type=checkbox id='" + sc.Tag + "' />" + sc.Name + "</div>");
                            }
                        }
                        divRights.InnerHtml = sb.ToString();
                    }
                }
            }
        }
        catch (Exception ex)
        {
            ClientScript.RegisterClientScriptBlock(this.GetType(), "error", "<script type=\"text/javascript\">error=true;</script>");
            log.Error(null, ex);
        }
    }
Beispiel #12
0
    private void FillSelects()
    {
        //国家。
        SysCodeType sctCountry = SysCodeTypeSrv.GetSysCodeTypeByTag("countrys");

        selectStaffCountry.Items.Add(new ListItem("", "-1"));
        foreach (SysCode sc in sctCountry.SysCodes)
        {
            selectStaffCountry.Items.Add(new ListItem(sc.Name, sc.Tag));
        }

        //民族。
        SysCodeType sctNation = SysCodeTypeSrv.GetSysCodeTypeByTag("nations");

        selectStaffNation.Items.Add(new ListItem("", "-1"));
        foreach (SysCode sc in sctNation.SysCodes)
        {
            selectStaffNation.Items.Add(new ListItem(sc.Name, sc.Tag));
        }

        //职位。
        SysCodeType sctPosition = SysCodeTypeSrv.GetSysCodeTypeByTag("positions");

        selectStaffPosition.Items.Add(new ListItem("", "-1"));
        foreach (SysCode sc in sctPosition.SysCodes)
        {
            selectStaffPosition.Items.Add(new ListItem(sc.Name, sc.Tag));
        }

        //职称。
        SysCodeType sctTitle = SysCodeTypeSrv.GetSysCodeTypeByTag("titles");

        selectStaffTitle.Items.Add(new ListItem("", "-1"));
        foreach (SysCode sc in sctTitle.SysCodes)
        {
            selectStaffTitle.Items.Add(new ListItem(sc.Name, sc.Tag));
        }

        //政治面貌。
        SysCodeType sctPolitical = SysCodeTypeSrv.GetSysCodeTypeByTag("politicals");

        selectStaffPolitical.Items.Add(new ListItem("", "-1"));
        foreach (SysCode sc in sctPolitical.SysCodes)
        {
            selectStaffPolitical.Items.Add(new ListItem(sc.Name, sc.Tag));
        }

        //最高学历。
        SysCodeType sctDegree = SysCodeTypeSrv.GetSysCodeTypeByTag("degrees");

        selectStaffDegree.Items.Add(new ListItem("", "-1"));
        foreach (SysCode sc in sctDegree.SysCodes)
        {
            selectStaffDegree.Items.Add(new ListItem(sc.Name, sc.Tag));
        }

        //性别。
        selectStaffSex.Items.Add(new ListItem("", "-1"));
        selectStaffSex.Items.Add(new ListItem("男", "0"));
        selectStaffSex.Items.Add(new ListItem("女", "1"));

        //婚否。
        selectStaffMarried.Items.Add(new ListItem("", "-1"));
        selectStaffMarried.Items.Add(new ListItem("未婚", "0"));
        selectStaffMarried.Items.Add(new ListItem("已婚", "1"));
    }