Example #1
0
        protected override void btnSave_Click(object sender, EventArgs e)
        {
            if(string.IsNullOrEmpty(txtOrder.Text.Trim())) txtOrder.Text = "0";

            if (action.Equals("add"))
            {
                menu = new cmsMenu();
            }
            else if(action.Equals("edit"))
            {
                if (ddlParentNode.SelectedValue.StartsWith(hidCode.Value))
                {
                    ScriptUtil.Alert("上级菜单不能设为自身或其子级!");
                    return;
                }
                menu = ms.Get(code);
                if (menu != null)
                {
                    menu.Attach();
                }
                else
                {
                    menu = new cmsMenu();
                }
            }
            if (menu.ParentCode != ddlParentNode.SelectedValue)
            {
                menu.MenuCode = ms.GetNextChildCode(ddlParentNode.SelectedValue);
            }
            menu.ParentCode = ddlParentNode.SelectedValue;
            menu.MenuName = txtName.Text.Trim();
            menu.MenuUrl = txtUrl.Text.Trim();
            menu.MenuType = ddlType.SelectedIndex;
            menu.OrderNo = Convert.ToInt32(txtOrder.Text.Trim());
            menu.IsEnabled = chkEnabled.Checked ? 1 : 0;

            try
            {
                int r = ms.Save(menu);
                //if (r > 0)
                {
                    hidCode.Value = menu.MenuCode;

                    if (action.Equals("add"))
                    {
                        ScriptUtil.ConfirmAndRedirect(@"菜单添加成功!\n“确定”继续添加,“取消”则跳转到列表页。", "MenuAdd.aspx?node=" + NodeCode, "MenuList.aspx?node=" + NodeCode);
                    }
                    else
                    {
                        ScriptUtil.ConfirmAndRedirect(@"菜单修改成功!\n“确定”留在本页,“取消”则跳转到列表页。", "MenuAdd.aspx?node=" + NodeCode + "&code=" + code + "&action=" + action, "MenuList.aspx?node=" + NodeCode);
                        //ScriptUtil.Alert("菜单修改成功!");
                    }
                }
            }
            catch(Exception ex)
            {
                ScriptUtil.Alert(ex.Message);

                Logger.Error(ex.Message);
            }
        }
Example #2
0
 private void InitData()
 {
     if (!string.IsNullOrEmpty(code))
     {
         if (action.Equals("add"))
         {
             ddlParentNode.SelectedValue = code;
         }
         else if (action.Equals("edit"))
         {
             menu = ms.Get(code);
             if (menu != null)
             {
                 hidCode.Value = menu.MenuCode;
                 ddlParentNode.SelectedValue = menu.ParentCode;
                 txtName.Text = menu.MenuName;
                 ddlType.SelectedIndex = menu.MenuType.Value;
                 txtUrl.Text = menu.MenuUrl;
                 txtOrder.Text = menu.OrderNo.ToString();
                 chkEnabled.Checked = menu.IsEnabled.HasValue ? menu.IsEnabled.Value == 1 : false;
             }
         }
     }
 }