protected void lbtSave_Click(object sender, EventArgs e) { RolesOR cg = setValue(); RolesDA carClassAdin = new RolesDA(); try { if (Request.QueryString["opType"] == null) { DataTable dt = carClassAdin.SelectAllRoles(); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["Role_Name"].ToString().Trim().ToLower() == txtName.Text.Trim().ToLower()) { Alert("该角色已存在!"); return; } } carClassAdin.Insert(cg); } else if (Request.QueryString["opType"].ToString() == "alert") { RolesOR or = new RolesDA().selectARowDate(Request["id"].ToString()); DataTable dt = carClassAdin.SelectRolesWithoutSelf(or.RoleName); for (int i = 0; i < dt.Rows.Count; i++) { if (dt.Rows[i]["Role_Name"].ToString().Trim().ToLower() == txtName.Text.Trim().ToLower()) { Alert("该角色已存在!"); return; } } carClassAdin.Update(cg); } base.Close(true); } catch (Exception ex) { base.Alert(ex.Message); } }