示例#1
0
 public bool UpdateMenu(MenuInfo menu)
 {
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("UPDATE vshop_Menu SET ParentMenuId = @ParentMenuId, Name = @Name, Type = @Type, ReplyId = @ReplyId, DisplaySequence = @DisplaySequence, Bind = @Bind, [Content] = @Content WHERE MenuId = @MenuId");
     this.database.AddInParameter(sqlStringCommand, "ParentMenuId", DbType.Int32, menu.ParentMenuId);
     this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, menu.Name);
     this.database.AddInParameter(sqlStringCommand, "Type", DbType.String, menu.Type);
     this.database.AddInParameter(sqlStringCommand, "ReplyId", DbType.Int32, menu.ReplyId);
     this.database.AddInParameter(sqlStringCommand, "DisplaySequence", DbType.Int32, menu.DisplaySequence);
     this.database.AddInParameter(sqlStringCommand, "MenuId", DbType.Int32, menu.MenuId);
     this.database.AddInParameter(sqlStringCommand, "Bind", DbType.Int32, (int) menu.BindType);
     this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, menu.Content);
     return (this.database.ExecuteNonQuery(sqlStringCommand) == 1);
 }
示例#2
0
 public bool SaveMenu(MenuInfo menu)
 {
     int allMenusCount = this.GetAllMenusCount();
     DbCommand sqlStringCommand = this.database.GetSqlStringCommand("INSERT INTO vshop_Menu (ParentMenuId, Name, Type, ReplyId, DisplaySequence, Bind, [Content]) VALUES(@ParentMenuId, @Name, @Type, @ReplyId, @DisplaySequence, @Bind, @Content)");
     this.database.AddInParameter(sqlStringCommand, "ParentMenuId", DbType.Int32, menu.ParentMenuId);
     this.database.AddInParameter(sqlStringCommand, "Name", DbType.String, menu.Name);
     this.database.AddInParameter(sqlStringCommand, "Type", DbType.String, menu.Type);
     this.database.AddInParameter(sqlStringCommand, "ReplyId", DbType.Int32, menu.ReplyId);
     this.database.AddInParameter(sqlStringCommand, "DisplaySequence", DbType.Int32, allMenusCount);
     this.database.AddInParameter(sqlStringCommand, "Bind", DbType.Int32, (int) menu.BindType);
     this.database.AddInParameter(sqlStringCommand, "Content", DbType.String, menu.Content);
     return (this.database.ExecuteNonQuery(sqlStringCommand) == 1);
 }
示例#3
0
        private void btnAddMenu_Click(object sender, EventArgs e)
        {
            MenuInfo menu = new MenuInfo {
                Name = this.txtCategoryName.Text,
                ParentMenuId = base.GetUrlIntParam("pid")
            };
            if (!VShopHelper.CanAddMenu(menu.ParentMenuId))
            {
                this.ShowMsg("一级菜单不能超过三个,对应二级菜单不能超过五个", false);
            }
            else
            {
                menu.Bind = Convert.ToInt32(this.ddlType.SelectedValue);
                BindType bindType = menu.BindType;
                switch (bindType)
                {
                    case BindType.Key:
                        menu.ReplyId = Convert.ToInt32(this.ddlValue.SelectedValue);
                        break;

                    case BindType.Topic:
                        menu.Content = this.ddlValue.SelectedValue;
                        break;

                    default:
                        if (bindType == BindType.Url)
                        {
                            menu.Content = this.txtUrl.Text.Trim();
                        }
                        break;
                }
                menu.Type = "click";
                if (menu.ParentMenuId == 0)
                {
                    menu.Type = "view";
                }
                else if (string.IsNullOrEmpty(this.ddlType.SelectedValue) || (this.ddlType.SelectedValue == "0"))
                {
                    this.ShowMsg("二级菜单必须绑定一个对象", false);
                    return;
                }
                if (VShopHelper.SaveMenu(menu))
                {
                    base.Response.Redirect("ManageMenu.aspx");
                }
                else
                {
                    this.ShowMsg("添加失败", false);
                }
            }
        }
示例#4
0
        private SingleButton BuildMenu(MenuInfo menu)
        {
            switch (menu.BindType)
            {
                case BindType.Key:
                    return new SingleClickButton { name = menu.Name, key = menu.MenuId.ToString() };

                case BindType.Topic:
                case BindType.HomePage:
                case BindType.ProductCategory:
                case BindType.ShoppingCar:
                case BindType.OrderCenter:
                case BindType.MemberCard:
                case BindType.Url:
                    return new SingleViewButton { name = menu.Name, url = menu.Url };
            }
            return new SingleClickButton { name = menu.Name, key = "None" };
        }
示例#5
0
 public static bool UpdateMenu(MenuInfo menu)
 {
     return new MenuDao().UpdateMenu(menu);
 }
示例#6
0
 public static bool SaveMenu(MenuInfo menu)
 {
     return new MenuDao().SaveMenu(menu);
 }