protected void btnSumbit_OnClick(object sender, EventArgs e) { int pid; if (this.ddlLevel.SelectedValue == "0") { pid = 0; } else if (this.ddlLevel.SelectedValue == "1") { pid = int.Parse(this.ddlParentTitle.SelectedValue); } else { pid = int.Parse(this.ddlSonTitle.SelectedValue); } Model.SystemMenu model = new Model.SystemMenu { Id = int.Parse(this.MenuId.Text), Title = this.MenuTitle.Text, Link = this.MenuLink.Text, ParentId = pid }; int rs = menuSvc.Edit(model); if (rs > 0) { Response.Write("<script>alert('编辑成功');location.href='SystemMenuList.aspx'</script>"); } else { Response.Write("<script>alert('编辑失败');location.href='SystemMenuList.aspx'</script>"); } }
/// <summary> /// 初始化菜单递归 /// </summary> /// <param name="xml"></param> private void init_list(XElement xml) { foreach (var item in xml.Elements()) { if (item.Attribute("Code") != null && item.Attribute("Code").Value != "") { string code = item.Attribute("Code").Value; SystemMenu _menu = _SystemMenuService.GetWhere(m => m.Code.ToLower() == code.ToLower()).FirstOrDefault(); if (_menu != null) { //修改 init(item, _menu); _SystemMenuService.Edit(_menu); } else { //添加 _menu = new SystemMenu(); init(item, _menu); _SystemMenuService.Add(_menu); } _SystemMenuService.Save(); init_list(item); } } }
protected void btnSubmit_Click(object sender, EventArgs e) { var data = smSvc.GetSystemMenus(Guid.Parse(this.HiddenField1.Value)); data.SystemMenus_Title = this.txtName.Text; data.SystemMenus_Link = this.txtLink.Text; data.SystemMenus_Icon = this.txtIcon.Text; if (this.ddlFirst.SelectedValue == "1") { data.SystemMenus_ParentId = Guid.Empty; } else if (this.ddlFirst.SelectedValue == "2") { data.SystemMenus_ParentId = Guid.Parse(this.ddlSecond.SelectedValue); } else if (this.ddlFirst.SelectedValue == "3") { data.SystemMenus_ParentId = Guid.Parse(this.ddlThird.SelectedValue); } data.SystemMenus_UpdateTime = DateTime.Now; var res = smSvc.Edit(data); ReturnMsg rm = res > 0 ? new ReturnMsg() { Code = StatusCode.Ok, Message = "编辑系统菜单成功", Data = null } : new ReturnMsg() { Code = StatusCode.Error, Message = "编辑系统菜单失败", Data = null }; Session["Msg"] = rm; Response.Redirect("SystemMenus_List.aspx"); }