using System; using System.Collections.Generic; using System.Linq; using System.Text; using Models; using System.Data; using System.Data.SqlClient; namespace DAL { /// /// 功能权限多表联查数据访问类 /// public class FunctionOperatingService { /// /// 读取方法 /// /// 对象 /// 对象区分 /// sql语句 /// 文本类型 /// 可变参数数组 /// 返回集合 public List excuteSql(string sql, params SqlParameter[] param) { List foList = null; FunctionOperating fo = null; using (SqlDataReader dr = SqlHelper.ExcuteReader(sql, CommandType.Text, param)) { if (dr != null) { foList = new List(); while (dr.Read()) { fo = new FunctionOperating(); fo.Name = dr["Name"].ToString(); fo.Code = dr["Code"].ToString(); fo.IsEnable = Convert.ToInt32(dr["IsEnable"]); fo.Uid = Convert.ToInt32(dr["Uid"]); foList.Add(fo); } } } return foList; } /// /// 根据用户编号获取数据 /// /// /// public List GetAll(string code,int uid) { string sql = "select sf.[Name],sf.Code,sf.IsEnable,c.Uid from SystemFunction sf join Competence c on sf.Id = c.Sid where STable = 1 and IsEnable = 1 and Code = @Code and c.uid = @Uid"; return excuteSql(sql, new SqlParameter("@Code", code), new SqlParameter("@Uid", uid)); } } }