/// <summary> /// /// </summary> /// <param name="mItem"></param> /// <param name="menuType"> </param> /// <returns></returns> public static int AddMenuItem(AdvMenuItem mItem, EMenuType menuType) { return(SQLDataAccess.ExecuteScalar <int>(string.Format( "INSERT INTO {0} (MenuItemParentID, MenuItemName, MenuItemIcon, MenuItemUrlPath, MenuItemUrlType, SortOrder, ShowMode, Enabled, Blank) VALUES (@MenuItemParentID, @MenuItemName, @MenuItemIcon, @MenuItemUrlPath, @MenuItemUrlType, @SortOrder, @ShowMode, @Enabled, @Blank); SELECT scope_identity();", MenuTypeTables[menuType]), CommandType.Text, new SqlParameter("@MenuItemParentID", mItem.MenuItemParentID == 0 ? DBNull.Value : (object)mItem.MenuItemParentID), new SqlParameter("@MenuItemName", mItem.MenuItemName), new SqlParameter("@MenuItemIcon", string.IsNullOrEmpty(mItem.MenuItemIcon) ? DBNull.Value : (object)mItem.MenuItemIcon), new SqlParameter("@MenuItemUrlPath", mItem.MenuItemUrlPath), new SqlParameter("@MenuItemUrlType", mItem.MenuItemUrlType), new SqlParameter("@SortOrder", mItem.SortOrder), new SqlParameter("@Blank", mItem.Blank), new SqlParameter("@ShowMode", mItem.ShowMode), new SqlParameter("@Enabled", mItem.Enabled))); }
/// <summary> /// /// </summary> /// <param name="mItem"></param> /// <param name="menuType"> </param> /// <returns></returns> public static int AddMenuItem(AdvMenuItem mItem, EMenuType menuType) { return SQLDataAccess.ExecuteScalar<int>(string.Format( "INSERT INTO {0} (MenuItemParentID, MenuItemName, MenuItemIcon, MenuItemUrlPath, MenuItemUrlType, SortOrder, ShowMode, Enabled, Blank, NoFollow) VALUES (@MenuItemParentID, @MenuItemName, @MenuItemIcon, @MenuItemUrlPath, @MenuItemUrlType, @SortOrder, @ShowMode, @Enabled, @Blank, @NoFollow); SELECT scope_identity();", MenuTypeTables[menuType]), CommandType.Text, new SqlParameter("@MenuItemParentID", mItem.MenuItemParentID == 0 ? DBNull.Value : (object)mItem.MenuItemParentID), new SqlParameter("@MenuItemName", mItem.MenuItemName), new SqlParameter("@MenuItemIcon", string.IsNullOrEmpty(mItem.MenuItemIcon) ? DBNull.Value : (object)mItem.MenuItemIcon), new SqlParameter("@MenuItemUrlPath", mItem.MenuItemUrlPath), new SqlParameter("@MenuItemUrlType", mItem.MenuItemUrlType), new SqlParameter("@SortOrder", mItem.SortOrder), new SqlParameter("@Blank", mItem.Blank), new SqlParameter("@ShowMode", mItem.ShowMode), new SqlParameter("@Enabled", mItem.Enabled), new SqlParameter("@NoFollow", mItem.NoFollow)); }
/// <summary> /// /// </summary> /// <param name="mItem"></param> /// <param name="menuType"> </param> public static void UpdateMenuItem(AdvMenuItem mItem, EMenuType menuType) { SQLDataAccess.ExecuteNonQuery( "[CMS].[sp_UpdateMenuItemByItemId]", CommandType.StoredProcedure, new SqlParameter("@MenuType", menuType.ToString()), new SqlParameter("@MenuItemID", mItem.MenuItemID), new SqlParameter("@MenuItemParentID", mItem.MenuItemParentID == 0 ? DBNull.Value : (object)mItem.MenuItemParentID), new SqlParameter("@MenuItemName", mItem.MenuItemName), new SqlParameter("@MenuItemIcon", string.IsNullOrEmpty(mItem.MenuItemIcon) ? DBNull.Value : (object)mItem.MenuItemIcon), new SqlParameter("@MenuItemUrlPath", mItem.MenuItemUrlPath), new SqlParameter("@MenuItemUrlType", mItem.MenuItemUrlType), new SqlParameter("@SortOrder", mItem.SortOrder), new SqlParameter("@ShowMode", mItem.ShowMode), new SqlParameter("@Enabled", mItem.Enabled), new SqlParameter("@Blank", mItem.Blank)); }
/// <summary> /// /// </summary> /// <param name="mItem"></param> /// <param name="menuType"> </param> public static void UpdateMenuItem(AdvMenuItem mItem, EMenuType menuType) { SQLDataAccess.ExecuteNonQuery( "[CMS].[sp_UpdateMenuItemByItemId]", CommandType.StoredProcedure, new SqlParameter("@MenuType", menuType.ToString()), new SqlParameter("@MenuItemID", mItem.MenuItemID), new SqlParameter("@MenuItemParentID", mItem.MenuItemParentID == 0 ? DBNull.Value : (object)mItem.MenuItemParentID), new SqlParameter("@MenuItemName", mItem.MenuItemName), new SqlParameter("@MenuItemIcon", string.IsNullOrEmpty(mItem.MenuItemIcon) ? DBNull.Value : (object)mItem.MenuItemIcon), new SqlParameter("@MenuItemUrlPath", mItem.MenuItemUrlPath), new SqlParameter("@MenuItemUrlType", mItem.MenuItemUrlType), new SqlParameter("@SortOrder", mItem.SortOrder), new SqlParameter("@ShowMode", mItem.ShowMode), new SqlParameter("@Enabled", mItem.Enabled), new SqlParameter("@Blank", mItem.Blank), new SqlParameter("@NoFollow", mItem.NoFollow)); }
protected void Page_Load(object sender, EventArgs e) { SetMeta(string.Format("{0} - {1}", SettingsMain.ShopName, Resource.Admin_MenuManager_TopMenu)); Int32.TryParse(Request["menuid"], out _menuId); _needReloadTree = SQLDataHelper.GetBoolean(ViewState["updateTree"]); hlEditCategory.Visible = _menuId > 0; lblSeparator.Visible = _menuId > 0; hlDeleteCategory.Visible = _menuId > 0; if (!string.IsNullOrWhiteSpace(Request["type"])) Enum.TryParse(Request["type"], true, out _menuType); var menuitem = new AdvMenuItem(); switch (_menuType) { case MenuService.EMenuType.Top: menuitem = MenuService.GetMenuItemById(_menuId, _menuType); lblHead.Text = menuitem == null ? Resource.Admin_MenuManager_TopMenu : string.Format("{0} - {1}", Resource.Admin_MenuManager_TopMenu, menuitem.MenuItemName); lblSubHead.Text = Resource.Admin_MenuManager_SubHeaderTop; Page.Title = menuitem == null ? Resource.Admin_MenuManager_TopMenu : string.Format("{0} - {1}", Resource.Admin_MenuManager_TopMenu, menuitem.MenuItemName); break; case MenuService.EMenuType.Bottom: menuitem = MenuService.GetMenuItemById(_menuId, _menuType); lblHead.Text = menuitem == null ? Resource.Admin_MenuManager_BottomMenu : string.Format("{0} - {1}", Resource.Admin_MenuManager_BottomMenu, menuitem.MenuItemName); lblSubHead.Text = Resource.Admin_MenuManager_SubHeaderBottom; Page.Title = menuitem == null ? Resource.Admin_MenuManager_BottomMenu : string.Format("{0} - {1}", Resource.Admin_MenuManager_BottomMenu, menuitem.MenuItemName); break; } btnAdd.OnClientClick = "open_window('m_Menu.aspx?MenuID=" + _menuId + "&mode=create&type=" + _menuType + "', 750, 640);return false;"; hlEditCategory.NavigateUrl = "javascript:open_window(\'m_Menu.aspx?MenuID=" + _menuId + "&mode=edit&type=" + _menuType + "\', 750, 640)"; ConfirmButtonExtenderCategory.ConfirmText = string.Format(Resource.Admin_MasterPageAdminCatalog_MenuConfirmation, menuitem != null ? menuitem.MenuItemName : string.Empty); if (!IsPostBack) { switch (_menuType) { case MenuService.EMenuType.Top: _paging = new SqlPaging { TableName = "[CMS].[MainMenu]", ItemsPerPage = 10 }; break; case MenuService.EMenuType.Bottom: _paging = new SqlPaging { TableName = "[CMS].[BottomMenu]", ItemsPerPage = 10 }; break; } _paging.AddFieldsRange(new List<Field> { new Field { Name = "MenuItemID as ID", IsDistinct = true }, new Field {Name = "MenuItemParentID" }, new Field {Name = "MenuItemName"}, new Field {Name = "Enabled"}, new Field {Name = "Blank"}, new Field {Name = "SortOrder",Sorting = SortDirection.Ascending} }); if (_menuId != 0) { var filter = new EqualFieldFilter { ParamName = "@MenuItemParentID", Value = _menuId.ToString() }; _paging.Fields["MenuItemParentID"].Filter = filter; } else { var filter = new NullFieldFilter { ParamName = "@MenuItemParentID", Null = true }; _paging.Fields["MenuItemParentID"].Filter = filter; } grid.ChangeHeaderImageUrl("arrowSortOrder", "images/arrowup.gif"); _paging.ItemsPerPage = 10; pageNumberer.CurrentPageIndex = 1; _paging.CurrentPageIndex = 1; ViewState["Paging"] = _paging; } else { _paging = (SqlPaging)(ViewState["Paging"]); _paging.ItemsPerPage = SQLDataHelper.GetInt(ddRowsPerPage.SelectedValue); if (_paging == null) { throw (new Exception("Paging lost")); } string strIds = Request.Form["SelectedIds"]; if (!string.IsNullOrEmpty(strIds)) { strIds = strIds.Trim(); string[] arrids = strIds.Split(' '); _selectionFilter = new InSetFieldFilter(); if (arrids.Contains("-1")) { _selectionFilter.IncludeValues = false; _inverseSelection = true; } else { _selectionFilter.IncludeValues = true; } _selectionFilter.Values = arrids.Where(id => id != "-1").ToArray(); } } }
private void SaveMenuItem() { if (_mode == eMenuMode.Err) { return; } if (!ValidateData()) { return; } var url = string.Empty; if (txtUrl.Text.Contains("www.")) { url = txtUrl.Text.Contains("http://") ? txtUrl.Text : "http://" + txtUrl.Text; } else { url = txtUrl.Text; } lblError.Text = String.Empty; var mItem = new AdvMenuItem { MenuItemID = _menuItemId, MenuItemName = txtName.Text, MenuItemParentID = string.IsNullOrEmpty(hParent.Value) ? 0 : Convert.ToInt32(hParent.Value), MenuItemUrlPath = url, SortOrder = Convert.ToInt32(txtSortOrder.Text), Blank = ckbBlank.Checked, Enabled = ckbEnabled.Checked, MenuItemUrlType = (EMenuItemUrlType)Convert.ToInt32(rblLinkType.SelectedValue), ShowMode = (EMenuItemShowMode)Convert.ToInt32(ddlShowMode.SelectedValue), NoFollow = ckbNofollow.Checked }; if (IconFileUpload.HasFile) { PhotoService.DeletePhotos(_menuItemId, PhotoType.MenuIcon); using (IconFileUpload.FileContent) { var tempName = PhotoService.AddPhoto(new Photo(0, _menuItemId, PhotoType.MenuIcon) { OriginName = IconFileUpload.FileName }); if (!string.IsNullOrWhiteSpace(tempName)) { IconFileUpload.SaveAs(FoldersHelper.GetPathAbsolut(FolderType.MenuIcons, tempName)); } mItem.MenuItemIcon = tempName; } } else { mItem.MenuItemIcon = pnlIcon.Visible ? imgIcon.ToolTip : null; } MenuService.UpdateMenuItem(mItem, _type); if (_type == MenuService.EMenuType.Top) { CacheManager.RemoveByPattern(CacheNames.GetMainMenuCacheObjectName()); CacheManager.RemoveByPattern(CacheNames.GetMainMenuAuthCacheObjectName()); } else if (_type == MenuService.EMenuType.Bottom) { var cacheName = CacheNames.GetBottomMenuCacheObjectName(); if (CacheManager.Contains(cacheName)) CacheManager.Remove(cacheName); var cacheAuthName = CacheNames.GetBottomMenuAuthCacheObjectName(); if (CacheManager.Contains(cacheAuthName)) CacheManager.Remove(cacheAuthName); } }
private string RenderChildItem(AdvMenuItem childMenuItem) { var result = new StringBuilder(); result.Append("<li class=\"menu-bottom-row\">"); if (!string.IsNullOrEmpty(childMenuItem.MenuItemIcon)) { result.AppendFormat("<img src=\"{0}\" alt=\"\" class=\"menu-bottom-icon\" />", "pictures/icons/" + childMenuItem.MenuItemIcon); } if (childMenuItem.NoFollow) { result.Append("<!--noindex-->"); } result.AppendFormat("<a href='{0}' class='link-footer'{2}{3}>{1}</a>", childMenuItem.MenuItemUrlPath, childMenuItem.MenuItemName, childMenuItem.Blank ? " target='_blank'" : string.Empty, childMenuItem.NoFollow ? " rel='nofollow'" : string.Empty); if (childMenuItem.NoFollow) { result.Append("<!--/noindex-->"); } result.Append("</li>"); return result.ToString(); }