protected void btnConfrim_Click(object sender, EventArgs e) { if (Page.IsValid) { List <TablePrimary> t = new List <TablePrimary>(); TablePrimary userPrimary = new TablePrimary(); userPrimary.PrimaryName = "UserGroupName"; userPrimary.PrimaryValue = GetUserGroupInfo().UserGroupName; t.Add(userPrimary); if (Request.QueryString["Type"] != null && Request.QueryString["Type"].ToString() == "0")//新增状态 { if (Common.IsExsit("UserGroup", t)) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('用户组已经存在,请确认!');", true); } else { if (UserManage.AddUserGroup(GetUserGroupInfo())) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Sucess", "alert('操作成功!');location.replace('UserGroupList.aspx?Refresh=1');", true); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('操作失败!');", true); } } } else { if (Common.IsExsit("UserGroup", t, GetUserGroupInfo().UserGroupID)) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('用户组已经存在,请确认!');", true); } else { if (UserManage.UpdateUserGroup(GetUserGroupInfo())) { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Sucess", "alert('操作成功!');location.replace('UserGroupList.aspx?Refresh=1');", true); } else { ScriptManager.RegisterStartupScript(UpdatePanel1, this.GetType(), "Fail", "alert('操作失败!');", true); } } } } }