コード例 #1
0
        /// <summary>
        /// Gets the HTML to create a menu element that has no children menu items.
        /// </summary>
        /// <param name="menuItem">The menu item.</param>
        /// <returns>A formatted <li></li> tag."</returns>
        public string GetNonDropDownHTML(MenuItem menuItem)
        {
            //initialize the html to return
            StringBuilder markup = new StringBuilder("<li>");

            //add the anchor tag for the link
            if (!string.IsNullOrEmpty(menuItem.URL))
            {
                markup.Append("<a href=\"");
                markup.Append(menuItem.URL.Trim());
                markup.Append("\">");

                //add a class if one is specified
                if (!string.IsNullOrEmpty(menuItem.Class))
                {
                    markup.Append("<span class=\"");
                    markup.Append(menuItem.Class.Trim());
                    markup.Append("\">");

                    //add the label
                    if (!string.IsNullOrEmpty(menuItem.Label))
                    {
                        markup.Append(menuItem.Label.Trim());
                    }
                    markup.Append("</span>");

                    //check for special classes for KPI Notifications and Workflows
                    //if they exist an additional span is created with the total notifications and workflows
                    if (menuItem.Class.Contains(BOOTSTRAP_CLASS_KPI_ICON))
                    {
                        markup.Append(GetKPINotificationSpan());
                    }
                    if (menuItem.Class.Contains(BOOTSTRAP_CLASS_WORKFLOW_ICON))
                    {
                        markup.Append(GetWorkflowsSpan());
                    }
                }
                //close the anchor tag
                markup.Append("</a>");
            }

            //add closing tag
            markup.Append("</li>");
            return markup.ToString();
        }
コード例 #2
0
        public MenuItem GetById(int menuItemId)
        {
            using (SqlConnection conn = new SqlConnection(this.connString))
            {
                conn.Open();

                //call the stored procedure
                using (SqlCommand sqlCmd = new SqlCommand("dbo.ubh_sp_MenuItem_Select"))
                {
                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    sqlCmd.CommandTimeout = 9999;
                    sqlCmd.Connection = conn;
                    sqlCmd.Parameters.Add("@miIdentity", SqlDbType.Int).Value = menuItemId;

                    MenuItem theItem = new MenuItem();
                    using (SqlDataReader dr = sqlCmd.ExecuteReader())
                    {
                        if (dr.HasRows)
                        {
                            while (dr.Read())
                            {
                                theItem.Identity = Convert.ToInt32(dr["miIdentity"]);
                                theItem.MenuName = dr["miMenuName"].ToString();
                                theItem.Label = dr["miLabel"].ToString();
                                theItem.ParentId = Convert.ToInt32(dr["miParentId"]);
                                theItem.SortOrder = Convert.ToInt32(dr["miSortOrder"]);
                                theItem.URL = dr["miURL"].ToString();
                                theItem.Class = dr["miClass"].ToString();
                                theItem.Target = dr["miTarget"].ToString();
                                theItem.CreatedBy = dr["CreatedBy"].ToString();
                                theItem.CreatedDate = (DateTime)dr["CreatedDate"];
                            }
                        }
                        else
                        {
                            theItem.Identity = 0;
                        }

                        return theItem;
                    }
                }
            }
        }
コード例 #3
0
        public List<MenuItem> GetAll()
        {
            //setup collection to return
            List<MenuItem> itemList = new List<MenuItem>();

            //call the stored procedure
            using (SqlConnection conn = new SqlConnection(this.connString))
            {
                conn.Open();
                //call the stored procedure
                using (SqlCommand sqlCmd = new SqlCommand("dbo.ubh_sp_MenuItem_Select"))
                {
                    sqlCmd.CommandType = CommandType.StoredProcedure;
                    sqlCmd.CommandTimeout = 9999;
                    sqlCmd.Connection = conn;

                    SqlDataReader rdr = sqlCmd.ExecuteReader();

                    //loop through the menu items returned and build the collection to return
                    while (rdr.Read())
                    {
                        MenuItem newItem = new MenuItem();
                        newItem.Identity = Convert.ToInt32(rdr["miIdentity"]);
                        newItem.MenuName = rdr["miMenuName"].ToString();
                        newItem.Label = rdr["miLabel"].ToString();
                        newItem.ParentId = Convert.ToInt32(rdr["miParentId"]);
                        newItem.SortOrder = Convert.ToInt32(rdr["miSortOrder"]);
                        newItem.URL = rdr["miURL"].ToString();
                        newItem.Class = rdr["miClass"].ToString();
                        newItem.Target = rdr["miTarget"].ToString();
                        newItem.CreatedBy = rdr["CreatedBy"].ToString();
                        newItem.CreatedDate = (DateTime)rdr["CreatedDate"];
                        itemList.Add(newItem);
                    }

                    return itemList;
                }
            }
        }
コード例 #4
0
        /// <summary>
        /// Gets the HTML for a menu item that also has children menu items.
        /// </summary>
        /// <param name="menuItem">The menu item.</param>
        /// <returns>A formatted <li></li> tag."</returns>
        public string GetDropDownHTML(MenuItem menuItem)
        {
            //initialize the html to return
            StringBuilder markup = new StringBuilder("<li class=\"dropdown\">");

            //add the anchor tag for top level
            markup.Append("<a href=\"#\" class=\"dropdown-toggle\" data-toggle=\"dropdown\">");
            if (!string.IsNullOrEmpty(menuItem.Label))
            {
                markup.Append(menuItem.Label.Trim());
            }
            markup.Append("<b class=\"caret\"></b></a>");

            //get the collection of sub menu items
            List<MenuItem> subMenuItems = MenuItemBLL.GetListByParentId(menuItem.Identity);

            //create markup for the submenu items
            markup.Append("<ul class=\"dropdown-menu\">");
            foreach (MenuItem subItem in subMenuItems)
            {
                markup.Append("<li>");
                markup.Append("<a href=\"");
                markup.Append(subItem.URL);
                markup.Append("\">");
                if (!string.IsNullOrEmpty(subItem.Label))
                {
                    markup.Append(subItem.Label);
                }
                markup.Append("</a>");
                markup.Append("</li>");
            }
            markup.Append("</ul>");

            //add closing tag
            markup.Append("</li>");
            return markup.ToString();
        }