protected void ShowData() { string id = Request["MenuId"]; if (!string.IsNullOrEmpty(id)) { UserMenuBll bll = new UserMenuBll(); UserMenu model = bll.GetModel(Convert.ToInt32(id)); if (model != null) { this.txtMenuName.Text = model.MenuName; this.txtMenuAddress.Text = model.MenuAddress; this.txtMenuOrder.Text = model.MenuOrder.ToString(); this.rdoList.SelectedValue = model.IsNavigation.ToString(); if (model.ParentId == 0) { this.ddlParent.Enabled = false; } else { this.ddlParent.SelectedValue = model.ParentId.ToString(); } } } }
//保存 protected void btnSave_Click(object sender, EventArgs e) { string id = Request["MenuId"]; UserMenuBll bll = new UserMenuBll(); UserMenu model = null; if (!string.IsNullOrEmpty(id))//如果是修改操作 { model = bll.GetModel(Convert.ToInt32(id)); } else //如果是新增操作 { model = new UserMenu(); } model.MenuName = this.txtMenuName.Text.Trim(); model.MenuAddress = this.txtMenuAddress.Text.Trim(); model.MenuOrder = Convert.ToInt32(this.txtMenuOrder.Text.Trim()); model.ParentId = Convert.ToInt32(this.ddlParent.SelectedValue); model.IsNavigation = Convert.ToInt32(this.rdoList.SelectedValue); int n = 0; if (!string.IsNullOrEmpty(id))//如果是修改操作 { n = bll.Update(model, null); } else //如果是新增操作 { n = bll.Insert(model, null); } if (n > 0) { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('保存成功!');frameElement.lhgDG.curWin.location.reload();</script>"); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "", "<script>alert('保存失败!');frameElement.lhgDG.curWin.location.reload();</script>");//刷新,lhgDG是个第三方的JS弹出窗 } }