protected void Button1_Click(object sender, EventArgs e) { Model.MenuInfoModel model = new Model.MenuInfoModel(); model.MenuName = this.txtMenuName.Text; model.MenuUrl = this.txtMenuUrl.Text; model.OrderId = Common.TypeHelper.ObjectToInt(this.txtOrderId.Text, 100); model.Bid = Common.TypeHelper.ObjectToInt(this.ddlBid.SelectedValue, 0); model.StatusId = Common.TypeHelper.ObjectToInt(this.radStatusId.SelectedValue, 0); int id = Common.TypeHelper.ObjectToInt(this.hidId.Value, 0); model.MenuId = id; if (id > 0) { if (dal.Update(model) > 0) { JScript.Loction("p", "admin_Menu.aspx?action=add&" + menuUrl, this.Page); } } else { if (dal.Add(model) > 0) { JScript.Loction("p", "admin_Menu.aspx?action=add&" + menuUrl, this.Page); } } }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.menuList.DataSource = dal.GetList(" and bid =0 order by orderid desc"); this.menuList.DataBind(); this.ddlBid.DataSource = dal.GetList(" and bid =0 order by orderid desc"); this.ddlBid.DataTextField = "MenuName"; this.ddlBid.DataValueField = "MenuId"; this.ddlBid.DataBind(); this.ddlBid.Items.Add(new ListItem("一级菜单", "0")); this.ddlBid.SelectedValue = "0"; //删除 if (Request["action"] == "del") { int id = Common.TypeHelper.ObjectToInt(Request["id"], 0); if (dal.IsHave(id) > 0) { JScript.alert("p", "该菜单下有子菜单,不能删除", "admin_Menu.aspx?" + menuUrl, this.Page); } else { if (dal.Del(id) > 0) { JScript.Loction("p", "admin_Menu.aspx?" + menuUrl, this.Page); } } } ///添加 if (Request["action"] == "add") { int bid = Common.TypeHelper.ObjectToInt(Request["bid"], 0); this.ddlBid.SelectedValue = bid.ToString(); } //修改 if (Request["action"] == "update") { int id = Common.TypeHelper.ObjectToInt(Request["id"], 0); Model.MenuInfoModel model = dal.GetModel(id); this.txtMenuName.Text = model.MenuName; this.txtMenuUrl.Text = model.MenuUrl; this.txtOrderId.Text = model.OrderId.ToString(); this.ddlBid.SelectedValue = model.Bid.ToString(); this.radStatusId.SelectedValue = model.StatusId.ToString(); this.hidId.Value = id.ToString(); } } }
protected void Page_Load(object sender, EventArgs e) { if (Request["action"] == "add") { Model.MenuInfoModel model = new Model.MenuInfoModel(); model.MenuName = Request["menuName"]; model.MenuUrl = Request["menuUrl"]; model.OrderId = Common.TypeHelper.ObjectToInt(Request["OrderId"], 0); model.Bid = Common.TypeHelper.ObjectToInt(Request["bid"], 0); model.StatusId = Common.TypeHelper.ObjectToInt(Request["StatusId"], 0); int i = dal.Add(model); if (i > 0) { JScript.alert("ok", "操作成功", this.Page, "admin_menu.aspx?" + menuUrl); } else { } } }