Beispiel #1
0
    private void GetMenuGroup(int iMenuID)
    {
        BSMenuGroup menuGroup = BSMenuGroup.GetMenuGroup(iMenuID);

        if (menuGroup != null)
        {
            txtTitle.Text       = menuGroup.Title;
            txtDescription.Text = menuGroup.Description;
            cbxDefault.Checked  = menuGroup.Default;

            rpMenuItems.DataSource = menuGroup.Menu;
            rpMenuItems.DataBind();
        }

        int menuID = 0;

        int.TryParse(Request["ItemID"], out menuID);

        if (menuID > 0)
        {
            BSMenu menu = BSMenu.GetMenu(menuID);
            if (menu != null)
            {
                txtMenuTitle.Text       = menu.Title;
                txtMenuUrl.Text         = menu.Url;
                txtMenuDescription.Text = menu.Description;
                txtMenuTarget.Text      = menu.Target;
            }
        }
    }
Beispiel #2
0
 protected void rpMenuItems_ItemCommand(object source, RepeaterCommandEventArgs e)
 {
     if (e.CommandName.Equals("DeleteMenuItem"))
     {
         int    iMenuItemID = Convert.ToInt32(e.CommandArgument);
         BSMenu menu        = BSMenu.GetMenu(iMenuItemID);
         if (menu != null)
         {
             if (menu.Remove())
             {
                 GetMenuGroup(menu.MenuGroupID);
             }
         }
     }
 }
Beispiel #3
0
    protected void btnAddMenuItem_Click(object sender, EventArgs e)
    {
        int iMenuGroupID = 0;

        int.TryParse(Request["MenuID"], out iMenuGroupID);

        if (iMenuGroupID > 0)
        {
            BSMenuGroup menuGroup = BSMenuGroup.GetMenuGroup(iMenuGroupID);
            if (menuGroup != null)
            {
                BSMenu menu = null;

                int menuID = 0;
                int.TryParse(Request["ItemID"], out menuID);

                if (menuID > 0)
                {
                    menu = BSMenu.GetMenu(menuID);
                }

                if (menu == null)
                {
                    menu             = new BSMenu();
                    menu.MenuGroupID = menuGroup.MenuGroupID;
                    menu.ObjectType  = ObjectTypes.Custom;
                    menu.Sort        = (short)(menuGroup.Menu.Count + 1);
                    menu.MenuType    = MenuTypes.Single;
                }

                menu.Title       = txtMenuTitle.Text;
                menu.Description = txtMenuTitle.Text;
                menu.Url         = txtMenuUrl.Text;
                menu.Target      = txtMenuTarget.Text;

                if (menu.Save())
                {
                    txtMenuTarget.Text      = String.Empty;
                    txtMenuTitle.Text       = String.Empty;
                    txtMenuDescription.Text = String.Empty;
                    txtMenuUrl.Text         = String.Empty;

                    Response.Redirect(String.Format("Menus.aspx?MenuID={0}", menuGroup.MenuGroupID));
                }
            }
        }
    }