protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { if (AdminUser.CheckPower(qhwins.SysPower.Power.SysPower.DelGroup)) { HiddenField hfd = (HiddenField)e.Item.FindControl("HDF_DelInfo"); string GroupID = hfd.Value.ToString(); try { //先把所有属于该角色的用户找出来,删除用户表中即将删除组的ID OleDbConnection conn = qhwins.db.GetConnection(); conn.Open(); OleDbDataAdapter oda = new OleDbDataAdapter("select * from QhWins_WEBADMIN where instr([GroupID],'" + GroupID + "')", conn); OleDbCommandBuilder builder = new OleDbCommandBuilder(oda); DataSet ds = new DataSet(); oda.Fill(ds, "WebAdmin"); DataTable dt = ds.Tables["WebAdmin"]; try { foreach (DataRow row in dt.Rows) { row["GroupID"] = row["GroupID"].ToString().Replace(GroupID + ",", ""); } } catch (Exception ex) { throw new Exception(ex.Message); } conn.Close(); oda.Update(dt); //从qhwins_Group表中删除 OleDbCommand cmd = new OleDbCommand(); cmd.CommandText = "delete * from qhwins_Group where id=@id and IsLock=no"; OleDbParameter p0 = new OleDbParameter("@", OleDbType.VarChar, 22); p0.Value = GroupID; cmd.Parameters.Add(p0); //OleDbConnection conn = qhwins.db.GetConnection(); cmd.Connection = conn; cmd.Connection.Open(); cmd.ExecuteNonQuery(); cmd.Dispose(); conn.Close(); conn.Dispose(); this.BindRPT(); } catch (Exception ex) { this.LB_MSG.Text = "<script>alert('删除失败!提示:如果是系统内置权限是不能删除的!')</script>"; //Response.Write("删除角色失败!" + ex.Message + ""); //throw new Exception(ex.Message); } } else { Response.Redirect("NoPower.aspx"); }
}