Beispiel #1
0
        protected void btnSave_ServerClick(object sender, EventArgs e)
        {
            string strFuncName = txt_FunctionName.Value.Trim();
            string strValue = txt_Value.Value.Trim();
            string strTip = txt_Tip.Value.Trim();
            string strImage = txt_Image.Value.Trim();

            FunctionItem funcObj = FunctionItem.Get(nId);
            if (null == funcObj)
            {
                funcObj = new FunctionItem();
                funcObj.ParentId = nParentId;
                funcObj.Level = nParentId == -1 ? -1 : (FunctionItem.Get(nParentId).Level + 1);
            }

            funcObj.Name = strFuncName;
            funcObj.Value = strValue;
            funcObj.Tip = strTip;
            funcObj.IconName = strImage;
            funcObj.Target = sel_Target.SelectedValue;
            funcObj.Width = Util.ParseInt(txt_Width.Value.Trim(), 0);
            funcObj.Height = Util.ParseInt(txt_Height.Value.Trim(), 0);
            funcObj.IsResize = rb_IsResizeYes.Checked ? Constants.Yes : Constants.No;
            funcObj.IsToMove = rb_IsToMoveYes.Checked ? Constants.Yes : Constants.No;
            funcObj.IsShowInTaskBar = rb_IsShowInTaskBarYes.Checked ? Constants.Yes : Constants.No;
            funcObj.IsIncludeMinBox = rb_IsIncludeMinBoxYes.Checked ? Constants.Yes : Constants.No;
            funcObj.IsIncludeMaxBox = rb_IsIncludeMaxBoxYes.Checked ? Constants.Yes : Constants.No;
            HEntityCommon.HEntity(funcObj).EntitySave();
            PageUtil.PageAlert(this.Page, "保存成功!");
            PageUtil.PageAppendScript(this.Page, "top.windowFactory.refreshRoot();top.windowFactory.closeTopFocusForm();");
        }
Beispiel #2
0
 public static FunctionItem Get(int __nId)
 {
     if (__nId <= 0)
         return null;
     string strFilter = "Id=" + __nId;
     FunctionItem funcItem = new FunctionItem();
     FunctionItem[] alist = (FunctionItem[])HEntityCommon.HEntity(funcItem).EntityList(strFilter);
     if (null == alist || alist.Length == 0)
         return null;
     if (alist.Length > 1)
         throw new Exception(string.Format("{0}-{1}:{2} exist mutil records", funcItem.GetTableName(), funcItem.GetKeyName(), __nId));
     return alist[0];
 }
Beispiel #3
0
 private static string __GetTagString(FunctionItem _FuncObj)
 {
     if (null == _FuncObj)
         return "";
     int nChildrenCount = Util.ParseInt(htParentIdToCount[_FuncObj.Id] + "", -1);
     string strNodeType = nChildrenCount > 0 ? FunctionUtil.NodeType_Parent : FunctionUtil.NodeType_Son;
     StringBuilder sbTag = new StringBuilder();
     sbTag.Append(string.Format(" _tag=\"{0}\"", _FuncObj.Id));
     sbTag.Append(string.Format(" _type=\"{0}\"", strNodeType));
     sbTag.Append(string.Format(" _name=\"{0}\"", _FuncObj.Name.Replace("\"", "").Replace("'", "")));
     sbTag.Append(string.Format(" _value=\"{0}\"", _FuncObj.Value));
     sbTag.Append(string.Format(" _icon=\"{0}\"", _FuncObj.Id));
     sbTag.Append(string.Format(" _target=\"{0}\"", _FuncObj.Target));
     sbTag.Append(string.Format(" _width=\"{0}\"", _FuncObj.Width));
     sbTag.Append(string.Format(" _height=\"{0}\"", _FuncObj.Height));
     sbTag.Append(string.Format(" _resize=\"{0}\"", _FuncObj.IsResize));
     sbTag.Append(string.Format(" _move=\"{0}\"", _FuncObj.IsToMove));
     sbTag.Append(string.Format(" _minbox=\"{0}\"", _FuncObj.IsIncludeMinBox));
     sbTag.Append(string.Format(" _maxbox=\"{0}\"", _FuncObj.IsIncludeMaxBox));
     sbTag.Append(string.Format(" _intaskbar=\"{0}\"", _FuncObj.IsShowInTaskBar));
     return sbTag.ToString();
 }
Beispiel #4
0
 /*
  * tree结构
  * 节点id命名规则:tree_n1_n1_...,tree_n1_n2_....,tree_n2_n1_....
  * 节点的子节点div容器id命名规则为:父节点id + "nodes";
  */
 private static string __CreateTree(FunctionItem __FunctionNode, int __NodeIndex)
 {
     int nSonCount = Util.ParseInt(htParentIdToCount[__FunctionNode.Id] + "", 0);
     int nFriendCount = Util.ParseInt(htParentIdToCount[__FunctionNode.ParentId] + "", 0);
     Hashtable ht = new Hashtable();
     ht["index"] = __NodeIndex;
     ht["friend"] = nFriendCount;
     ht["son"] = nSonCount;
     htIdToProperty[__FunctionNode.Id] = ht;
     string strNode = __CreateNode(__FunctionNode);
     if (nSonCount > 0)
     {
         int nNodeIndex = 1;
         int nLength = Functions.Length;
         StringBuilder sbNodes = new StringBuilder();
         for (int i = 0; i < nLength; i++)
         {
             if (Functions[i].ParentId == __FunctionNode.Id)
             {
                 sbNodes.Append(__CreateTree(Functions[i], nNodeIndex));
                 nNodeIndex++;
             }
         }
         strNode = strNode + string.Format("<div class='{0}'>{1}</div>", node_box, sbNodes.ToString());
     }
     return strNode;
 }
Beispiel #5
0
        private static string __CreateNode(FunctionItem function)
        {
            string strText = function.Name;
            string strUrl = function.Value;
            string strTip = function.Tip;

            Hashtable ht = (Hashtable)htIdToProperty[function.Id];
            int nFriendsCount = Util.ParseInt(ht["friend"] + "", 0);
            int nIndex = Util.ParseInt(ht["index"] + "", 0);
            int nLevel = function.Level;
            StringBuilder sbNode = new StringBuilder();

            int nParentId = function.ParentId;
            for (int i = 0; i < nLevel - 1; i++)
            {
                if (nParentId != -1)
                {
                    FunctionItem parentFunction = (FunctionItem)htIdToFunction[nParentId];
                    Hashtable htParent = (Hashtable)htIdToProperty[parentFunction.Id];
                    int nPCount = Util.ParseInt(htParent["friend"] + "", 0);
                    int nPIndex = Util.ParseInt(htParent["index"] + "", 0);
                    bool bLast = nPCount == nPIndex;
                    string strBranchClassName = bLast ? node_branch_empty : node_branch_line;
                    sbNode.Insert(0, __CreateSpan(FunctionUtil.node_branch_common + " " + strBranchClassName, ""));
                    nParentId = parentFunction.ParentId;
                }
            }
            int nChildrenCount = Util.ParseInt(htParentIdToCount[function.Id] + "", -1);

            if (nChildrenCount > 0)//父节点
            {
                string strDot = FunctionUtil.node_dot_plus;
                if (nLevel == 1 && nFriendsCount == 1)
                {
                    strDot = FunctionUtil.node_dot_one_plus;
                }
                else if (nLevel == 1 && nFriendsCount > 1 && nIndex == 1)
                {
                    strDot = FunctionUtil.node_dot_first_plus;
                }
                else if (nIndex == nFriendsCount)
                {
                    strDot = FunctionUtil.node_dot_last_plus;
                }
                sbNode.Append(__CreateCommonSpan(FunctionUtil.node_branch_common + " " + strDot, "_type=" + NodeType_Parent, true));

                //添加叶子
                string strNodeIcon = __CreateSpan(FunctionUtil.node_head_icon_parent, "");
                string strNodeText = __CreateSpan(FunctionUtil.node_head_text, strText);
                sbNode.Append(__CreateSpan(FunctionUtil.node_head_normal, strNodeIcon + strNodeText, __GetTagString(function)));
            }
            else //子节点
            {
                string strDot = FunctionUtil.node_branch_middle;
                if (nLevel == 1 && nFriendsCount == 1)
                {
                    strDot = FunctionUtil.node_branch_one;
                }
                else if (nLevel == 1 && nFriendsCount > 1 && nIndex == 1)
                {
                    strDot = FunctionUtil.node_branch_first;
                }
                else if (nIndex == nFriendsCount)
                {
                    strDot = FunctionUtil.node_branch_last;
                }
                sbNode.Append(__CreateCommonSpan(FunctionUtil.node_branch_common + " " + strDot, "", false));

                //添加叶子
                string strNodeIcon = __CreateSpan(FunctionUtil.node_head_icon_leaf, "");
                string strNodeText = __CreateSpan(FunctionUtil.node_head_text, string.Format("<a href='#'>{0}</a>", strText));
                sbNode.Append(__CreateSpan(FunctionUtil.node_head_normal, strNodeIcon + strNodeText, __GetTagString(function)));
            }
            string strNode = string.Format("<div class='{0} {1}'>{2}</div>", FunctionUtil.node, "#" == strUrl ? FunctionUtil.node_type_parent : FunctionUtil.node_type_son, sbNode.ToString());
            return strNode;
        }
 private FunctionItem[] _GetSon(FunctionItem _parentFunction)
 {
     List<FunctionItem> ltSon = new List<FunctionItem>();
     foreach (FunctionItem son in AllFunctions)
     {
         if (son.ParentId == _parentFunction.Id)
         {
             ltSon.Add(son);
             ltSon.AddRange(_GetSon(son));
         }
     }
     return ltSon.ToArray();
 }
Beispiel #7
0
 public static Hashtable GetParentIdToCount(FunctionItem[] __alFunctions)
 {
     Hashtable htParentIdToCount = new Hashtable();
     int nCount = __alFunctions.Length;
     for (int i = 0; i < nCount; i++)
     {
         int nParentId = __alFunctions[i].ParentId;
         int nChildrenCount = 0;
         for (int j = 0; j < nCount; j++)
         {
             if (nParentId == __alFunctions[j].ParentId)
                 nChildrenCount++;
         }
         htParentIdToCount[nParentId] = nChildrenCount;
     }
     return htParentIdToCount;
 }