public bool ChangePower(int rid, List <int> ids) { HashSet <int> hs = new HashSet <int>(ids); try { //先根据角色id删除已有权限 Model.Power p = new Model.Power() { RoleID = rid }; if (DalBase.Delete(p) != 0) { foreach (int item in hs) { Model.Power p1 = new Model.Power() { MenuID = item, RoleID = rid }; DalBase.Insert(p1); } return(true); } else { return(false); } } catch (Exception) { return(false); } }
public IList <Model.Power> GetPowerByRoleIdAndPrarentId(int roleId, int prarentId) { IList <Model.Power> list = new List <Model.Power>(); string proName = "Usp_GetPowerByRoleIdAndPrarentId"; SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@roleId", roleId), new SqlParameter("@prarentId", prarentId) }; using (SqlDataReader reader = DBHelper.ExecuteReaderProc(proName, pars)) { if (reader.HasRows) { while (reader.Read()) { Model.Power p = new Model.Power(); p.PowerId = (int)reader["PowerId"]; p.PowerName = (string)reader["PowerName"]; p.prarentId = (int)reader["prarentId"]; p.URL = (string)reader["URL"]; p.Description = (string)reader["Description"]; list.Add(p); } } } return(list); }
public string AddPower(Model.Power power) { string proName = "usp_AddNewPower"; SqlParameter[] pars = new SqlParameter[] { new SqlParameter("@PowerName", power.PowerName), new SqlParameter("@URL", power.URL), new SqlParameter("@prarentId", power.prarentId), new SqlParameter("@description", power.Description), }; return(DBHelper.ExecuteNonQueryProc(proName, pars).ToString()); }
public IList <Model.Power> selectAllPowersByUserId(int uid) { IList <Model.Power> list = new List <Model.Power>(); string proName = "usp_selectAllPowersByUserId"; using (SqlDataReader reader = DBHelper.ExecuteReaderProc(proName, new SqlParameter("@uid", uid))) { while (reader.Read()) { Model.Power p = new Model.Power(); p.PowerId = (int)reader["PowerId"]; p.PowerName = (string)reader["PowerName"]; p.prarentId = (int)reader["prarentId"]; p.URL = (string)reader["URL"]; p.Description = (string)reader["Description"]; list.Add(p); } } return(list); }
public IList <Model.Power> SelectPowersByRoleId(int roleId) { string proName = "usp_selectPowersByRoleId"; IList <Model.Power> list = new List <Model.Power>(); using (SqlDataReader reader = DBHelper.ExecuteReaderProc(proName, new SqlParameter("@roleId", roleId))) { if (reader.HasRows) { while (reader.Read()) { Model.Power power = new Model.Power(); power.Description = (string)reader["Description"]; power.PowerId = (int)reader["PowerId"]; power.PowerName = (string)reader["PowerName"]; power.prarentId = (int)reader["prarentId"]; power.URL = (string)reader["URL"]; list.Add(power); } } } return(list); }
public string AddPower(Model.Power power) { return(rolePowerService.AddPower(power)); }