예제 #1
0
        //保存
        protected void btnSave_Click(object sender, EventArgs e)
        {
            string      id    = Request["RoleId"] == null ? "" : Request["RoleId"].Trim();
            UserRoleBll bll   = new UserRoleBll();
            UserRole    model = new UserRole();

            if (!string.IsNullOrEmpty(id))//如果是修改操作
            {
                model.RoleId = Convert.ToInt32(id);
            }

            model.RoleName = this.txtRoleName.Text.Trim();
            model.RoleDesc = this.txtRoleDesc.Text.Trim();

            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>");
            }
        }