using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Data.SqlClient; using Models; using System.Data; namespace DAL { /// /// 主界面多表联查数据访问类 /// public class MailPageService { /// /// 读取方法 /// /// 对象 /// 对象区分 /// sql语句 /// 文本类型 /// 可变参数数组 /// 返回集合 public List excuteSql(string sql,params SqlParameter[] param) { List mpList = null; MailPage mp = null; using (SqlDataReader dr = SqlHelper.ExcuteReader(sql,CommandType.Text, param)) { if (dr != null) { mpList = new List(); while (dr.Read()) { mp = new MailPage(); mp.ModelName = dr["ModelName"].ToString(); mp.ShowName = dr["ShowName"].ToString(); mp.PageUrl = dr["PageUrl"].ToString(); mp.Uid = Convert.ToInt32(dr["Uid"]); mp.MName = dr["MName"].ToString(); mpList.Add(mp); } } } return mpList; } /// /// 根据用户编号获取数据 /// /// /// public List GetAll(int uid) { string sql = "select sd2.Name as ModelName,sd1.ShowName,sd1.PageUrl,sd1.MName,sd1.Uid from "+ "(select sm.ShowName, sm.PageName as PageUrl,c.Uid,sd.[Name] as MName,Mid "+ "from SystemMenu sm "+ "join Competence c on sm.Id = c.Sid " + "join SetData sd on sd.id = sm.Mnid " + "where c.STable = 0 " + "and sm.IsEnable = 1 " + "and sm.IsDel = 0 " + "and sm.IsShow = 1 " + "and Uid = @Uid ) sd1 ,SetData sd2 " + "where sd1.Mid = sd2.Id " + "and sd2.STid = 5"; return excuteSql(sql, new SqlParameter("@Uid", uid)); } } }