Exemple #1
0
        private void LoadData()
        {
            Maticsoft.BLL.tMenu BLL = new Maticsoft.BLL.tMenu();
            DataSet             ds  = BLL.GetList(string.Format(" mCode in (select mCode from tRoleMenu where rCode={0}) order by mSort desc ", GetIdentityUser().roleCode));

            ds.Relations.Add("TreeRelation", ds.Tables[0].Columns["mCode"], ds.Tables[0].Columns["mFaherId"], false);

            foreach (DataRow row in ds.Tables[0].Rows)
            {
                if (row.IsNull("mFaherId"))
                {
                    FineUIPro.TreeNode node = new FineUIPro.TreeNode();
                    node.Text   = row["mName"].ToString();
                    node.NodeID = row["mCode"].ToString();


                    if (!string.IsNullOrEmpty(row["mIcon"].ToString()))
                    {
                        node.Icon = (Icon)Enum.Parse(typeof(Icon), row["mIcon"].ToString(), true);
                    }

                    treeMenu.Nodes.Add(node);
                    ResolveSubTree(row, node);
                }
            }
        }
        protected void GridDpt_RowCommand(object sender, GridCommandEventArgs e)
        {
            int deptID = GetSelectedDataKeyID(GridDpt);


            if (e.CommandName == "Delete")
            {
                if (TreeDpt.FindNode(deptID.ToString()).Nodes.Count > 0)
                {
                    Alert.ShowInTop("请先删除该菜单下子菜单!");
                    return;
                }


                BLL.tMenu BLL = new Maticsoft.BLL.tMenu();

                bool isTrue = BLL.Delete(deptID);


                if (!isTrue)
                {
                    Alert.ShowInTop("删除失败!");
                    return;
                }
                else
                {
                    BindTree();
                    LoadData();
                }
            }
            if (e.CommandName == "Edit")
            {
                Window1.Title = "菜单管理";
                string openUrl = String.Format("./MenuEdit.aspx?mCode={0}", HttpUtility.UrlEncode(deptID.ToString()));
                PageContext.RegisterStartupScript(Window1.GetSaveStateReference(deptID.ToString()) + Window1.GetShowReference(openUrl));
            }
        }
        protected void LoadData()
        {
            Maticsoft.BLL.tMenu BLL = new Maticsoft.BLL.tMenu();
            string sortField        = GridDpt.SortField;
            string sortDirection    = GridDpt.SortDirection;

            if (TreeDpt.SelectedNode == null)
            {
                GridDpt.RecordCount = BLL.GetRecordCount("");

                DataView view = BLL.GetListByPage("", " mSort desc ", GridDpt.PageIndex * GridDpt.PageSize, (GridDpt.PageIndex + 1) * GridDpt.PageSize).Tables[0].DefaultView;
                view.Sort          = String.Format("{0} {1}", sortField, sortDirection);
                GridDpt.DataSource = view.ToTable();
            }
            else
            {
                string NodeId = TreeDpt.SelectedNodeID;
                GridDpt.RecordCount = BLL.GetRecordCount(" mFaherId=" + NodeId + " or mCode=" + NodeId);
                DataView view = BLL.GetListByPage(" mFaherId=" + NodeId + " or mCode=" + NodeId, " mSort desc ", GridDpt.PageIndex * GridDpt.PageSize, (GridDpt.PageIndex + 1) * GridDpt.PageSize).Tables[0].DefaultView;
                view.Sort          = String.Format("{0} {1}", sortField, sortDirection);
                GridDpt.DataSource = view.ToTable();
            }
            GridDpt.DataBind();
        }