Example #1
0
 public CollapseMenuHeaderTemplate(AjaxMenuRootItem rootItem, bool userProvide, AjaxColorStyle style)
 {
     _item = rootItem;
     _style = style;
     _userProvide = userProvide;
 }
Example #2
0
        private List<AjaxMenuRootItem> GenItems()
        {
            List<AjaxMenuRootItem> items = null;
            DataTable tab = null;
            string parentSql = "";
            if (this.UseMenuTable)
            {
                parentSql = string.IsNullOrEmpty(this.MenuIDStartValue) ? "ISNULL([PARENT],'')=''" : "[PARENT]='{0}'";
                //string sql = string.Format("SELECT * FROM MENUTABLE WHERE (" + parentSql + " OR [PARENT] IN (SELECT MENUID FROM MENUTABLE WHERE " + parentSql + ")) AND MODULETYPE IN ('W','O') AND ITEMTYPE IN (SELECT ITEMTYPE FROM MENUITEMTYPE WHERE ITEMTYPE = '{2}') AND (MENUID IN (SELECT MENUID FROM GROUPMENUS WHERE GROUPID IN (SELECT GROUPID FROM USERGROUPS WHERE USERID='{1}') OR GROUPID='00') OR MENUID IN (SELECT MENUID FROM USERMENUS WHERE USERID = '{1}') OR (ISNULL([PARENT],'')='' AND ISNULL([PACKAGE],'')='')) ORDER BY SEQ_NO", this.MenuIDStartValue, CliUtils.fLoginUser, CliUtils.fCurrentProject);
                //tab = CliUtils.ExecuteSql("GLModule", "cmdRefValUse", sql, true, CliUtils.fCurrentProject).Tables[0];
                object[] menuResult = CliUtils.CallMethod("GLModule", "FetchMenus", new object[] { CliUtils.fCurrentProject, "W" });
                if (menuResult != null && (int)menuResult[0] == 0)
                {
                    tab = ((DataSet)menuResult[1]).Tables[0];
                }
            }
            else
            {
                WebDataSource wds = this.GetDataSource();
                if (wds != null)
                {
                    string dbAlias = this.GetDBAlias();
                    string cmdText = this.GetCommandText();
                    if (dbAlias != "" && cmdText != "")
                        tab = wds.CommandTable;
                    else
                        tab = wds.InnerDataSet.Tables[0];
                }
                parentSql = string.IsNullOrEmpty(this.MenuIDStartValue) ? string.Format("ISNULL([{0}],'')=''", this.MenuParentField) : ("[" + this.MenuParentField + "]='{0}'");
            }
            if (tab != null && tab.Rows.Count > 0)
            {
                DataRow[] rootRows = tab.Select(string.Format(parentSql, this.MenuIDStartValue)).Clone() as DataRow[];
                string LanIndex = ((int)CliUtils.fClientLang).ToString();
                foreach (DataRow rootRow in rootRows)
                {
                    AjaxMenuRootItem rootItem = new AjaxMenuRootItem();
                    rootItem.MenuId = rootRow[this.UseMenuTable ? "MENUID" : this.MenuIDField].ToString();
                    rootItem.Caption = rootRow[this.UseMenuTable ? "CAPTION" + LanIndex : this.MenuTextField].ToString();
                    if (rootItem.Caption == "")
                        rootItem.Caption = rootRow[this.UseMenuTable ? "CAPTION" : this.MenuTextField].ToString();
                    rootItem.ImageUrl = rootRow[this.UseMenuTable ? "IMAGEURL" : this.MenuImageField].ToString();

                    DataRow[] leafRows = tab.Select(string.Format(this.UseMenuTable ? "[PARENT]='{0}'" : "[" + this.MenuParentField + "]='{0}'", rootItem.MenuId)).Clone() as DataRow[];
                    foreach (DataRow leafRow in leafRows)
                    {
                        AjaxMenuLeafItem leafItem = new AjaxMenuLeafItem();
                        leafItem.MenuId = leafRow[this.UseMenuTable ? "MENUID" : this.MenuIDField].ToString();
                        leafItem.Parent = leafRow[this.UseMenuTable ? "PARENT" : this.MenuParentField].ToString();
                        leafItem.Caption = leafRow[this.UseMenuTable ? "CAPTION" + LanIndex : this.MenuTextField].ToString();
                        if (leafItem.Caption == "")
                            leafItem.Caption = leafRow[this.UseMenuTable ? "CAPTION" : this.MenuTextField].ToString();
                        leafItem.ImageUrl = leafRow[this.UseMenuTable ? "IMAGEURL" : this.MenuImageField].ToString();
                        if (this.UseMenuTable)
                        {
                            if (leafRow["MODULETYPE"].ToString() == "O")
                            {
                                leafItem.Href = string.Format("InnerPages/FlowDesigner.aspx?FlowFileName={0}", HttpUtility.UrlEncode(leafRow["FORM"].ToString()));
                            }
                            else
                            {
                                string param = "";
                                if (leafRow["ITEMPARAM"] != null && !string.IsNullOrEmpty(leafRow["ITEMPARAM"].ToString()))
                                {
                                    param = "?" + ConvertParamter(leafRow["ITEMPARAM"].ToString());
                                }
                                leafItem.Href = string.Format("{0}/{1}.aspx{2}",
                                    leafRow["PACKAGE"].ToString(),
                                    leafRow["FORM"].ToString(),
                                    param);
                            }
                        }
                        else
                        {
                            leafItem.Href = leafRow[this.MenuUrlField].ToString();
                        }

                        rootItem.Items.Add(leafItem);
                    }
                    if (leafRows.Length > 0)
                    {
                        if (items == null) items = new List<AjaxMenuRootItem>();
                        items.Add(rootItem);
                    }
                }
            }
            return items;
        }