コード例 #1
0
        public void TestForAdd1()
        {
            Node  a;
            Tree2 tree = new Tree2(10);

            tree.AddChild(new Node(9));
            bool check = false, isright = false;

            a = tree.FindNode(100, ref check, ref isright);
            Assert.AreEqual(false, check);

            tree.AddChild(new Node(100));
            a = tree.FindNode(100, ref check, ref isright);
            Assert.AreEqual(true, check);
        }
コード例 #2
0
        public void TestForFind1()
        {
            Tree2 tree = new Tree2(10);
            bool  check = false, isright = false;
            Node  a = tree.FindNode(100, ref check, ref isright);

            Assert.AreEqual(false, check);
        }
コード例 #3
0
        public void TestForFind2()
        {
            Tree2 tree = new Tree2(10);

            tree.AddChild(new Node(9));
            bool check = false, isright = false;
            Node a = tree.FindNode(9, ref check, ref isright);

            Assert.AreEqual(true, check);
        }
コード例 #4
0
ファイル: User.aspx.cs プロジェクト: radtek/WasteManager
        private void CheckTree2()
        {
            if (GridUser.SelectedRowIndex < 0)
            {
                return;
            }
            Tree2.UncheckAllNodes(Tree2.Nodes);

            strUserGuid = GridUser.DataKeys[GridUser.SelectedRowIndex][0].ToString();
            List <Entity.Menu> menus = DAL.User.GetMenu(strUserGuid);

            foreach (Entity.Menu menu in menus)
            {
                int             menuID = menu.ID;
                FineUI.TreeNode tn     = Tree2.FindNode(menuID.ToString());
                tn.Checked = true;
            }
        }
コード例 #5
0
 private void LoadData(string sId)
 {
     if (!string.IsNullOrEmpty(sId))
     {
         StringBuilder   sb       = new StringBuilder();
         Entity.RoleMenu rolemenu = DAL.RoleMenu.GetRoleMenu(sId);
         txt_RoleName.Text    = rolemenu.role.RoleName;
         txt_Description.Text = rolemenu.role.Description;
         foreach (Entity.Menu menu in rolemenu.menuList)
         {
             int             menuID = menu.ID;
             FineUI.TreeNode tn     = Tree2.FindNode(menuID.ToString());
             tn.Checked = true;
             sb.Append(menuID.ToString() + ",");
         }
         old = sb.ToString().Substring(0, sb.Length - 1);
     }
 }
コード例 #6
0
        protected void btn_save_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(sGuid))
            {
                //Add
                Entity.RoleMenu roleMenu = new Entity.RoleMenu();
                roleMenu.role.RoleName    = txt_RoleName.Text;
                roleMenu.role.Description = txt_Description.Text;
                string[] checkmenus = Tree2.GetCheckedNodeIDs();
                foreach (string checkID in checkmenus)
                {
                    Entity.Menu menu = new Entity.Menu();
                    menu.ID = int.Parse(checkID.ToString());
                    roleMenu.menuList.Add(menu);
                }

                int success = DAL.RoleMenu.AddRoleMenu(roleMenu);
                if (success == 1)
                {
                    Alert.ShowInTop(" 保存成功!", MessageBoxIcon.Information);
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop("保存失败!", MessageBoxIcon.Warning);
                }
            }
            else
            {
                //Update
                Entity.RoleMenu roleMenu = new Entity.RoleMenu();
                roleMenu.role.ID          = int.Parse(sGuid);
                roleMenu.role.RoleName    = txt_RoleName.Text;
                roleMenu.role.Description = txt_Description.Text;
                string[] checkmenus = Tree2.GetCheckedNodeIDs();

                int[] check = new int[checkmenus.Length];
                for (int i = 0; i < checkmenus.Length; i++)
                {
                    check[i] = int.Parse(checkmenus[i]);
                }



                StringBuilder   sb       = new StringBuilder();
                Entity.RoleMenu rolemenu = DAL.RoleMenu.GetRoleMenu(sGuid);
                txt_RoleName.Text    = rolemenu.role.RoleName;
                txt_Description.Text = rolemenu.role.Description;
                foreach (Entity.Menu menu in rolemenu.menuList)
                {
                    int             menuID = menu.ID;
                    FineUI.TreeNode tn     = Tree2.FindNode(menuID.ToString());
                    tn.Checked = true;
                    sb.Append(menuID.ToString() + ",");
                }
                old = sb.ToString().Substring(0, sb.Length - 1);
                string[] oldIds = old.Split(',');
                int[]    oldid  = new int[oldIds.Length];
                for (int s = 0; s < oldIds.Length; s++)
                {
                    oldid[s] = int.Parse(oldIds[s]);
                }

                List <int> Checked = new List <int>();
                for (int i = 0; i < checkmenus.Length; i++)
                {
                    Checked.Add(int.Parse(checkmenus[i]));
                }
                List <int> OldID = new List <int>();
                for (int i = 0; i < oldIds.Length; i++)
                {
                    OldID.Add(int.Parse(oldIds[i]));
                }
                List <int> Delete = ListHelper.ExceptList(OldID, Checked);
                List <int> Add    = ListHelper.ExceptList(Checked, OldID);
                foreach (int a in Delete)
                {
                    roleMenu.Delete.Add(a.ToString());
                }
                foreach (int b in Add)
                {
                    roleMenu.NewAdd.Add(b.ToString());
                }
                //var c = oldid.Intersect(check);
                //var d = oldid.Except(check);
                //var f = check.Except(oldid);
                //foreach (var q in d)
                //{
                //    roleMenu.Delete.Add(q.ToString());
                //}
                //foreach (var w in f)
                //{
                //    roleMenu.NewAdd.Add(w.ToString());
                //}
                int success = DAL.RoleMenu.UpdateRoleMenu(roleMenu);
                if (success == 1)
                {
                    Alert.ShowInTop(" 修改成功!", MessageBoxIcon.Information);
                    PageContext.RegisterStartupScript(ActiveWindow.GetHidePostBackReference());
                }
                else
                {
                    Alert.ShowInTop("修改失败!", MessageBoxIcon.Warning);
                }
            }
        }