MailPageService.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.SqlClient;
  6. using Models;
  7. using System.Data;
  8. namespace DAL
  9. {
  10. /// <summary>
  11. /// 主界面多表联查数据访问类
  12. /// </summary>
  13. public class MailPageService
  14. {
  15. /// <summary>
  16. /// 读取方法
  17. /// </summary>
  18. /// <param name="t">对象</param>
  19. /// <param name="type">对象区分</param>
  20. /// <param name="sql">sql语句</param>
  21. /// <param name="cmdType">文本类型</param>
  22. /// <param name="param">可变参数数组</param>
  23. /// <returns>返回集合</returns>
  24. public List<MailPage> excuteSql(string sql,params SqlParameter[] param)
  25. {
  26. List<MailPage> mpList = null;
  27. MailPage mp = null;
  28. using (SqlDataReader dr = SqlHelper.ExcuteReader(sql,CommandType.Text, param))
  29. {
  30. if (dr != null)
  31. {
  32. mpList = new List<MailPage>();
  33. while (dr.Read())
  34. {
  35. mp = new MailPage();
  36. mp.ModelName = dr["ModelName"].ToString();
  37. mp.ShowName = dr["ShowName"].ToString();
  38. mp.PageUrl = dr["PageUrl"].ToString();
  39. mp.Uid = Convert.ToInt32(dr["Uid"]);
  40. mp.MName = dr["MName"].ToString();
  41. mpList.Add(mp);
  42. }
  43. }
  44. }
  45. return mpList;
  46. }
  47. /// <summary>
  48. /// 根据用户编号获取数据
  49. /// </summary>
  50. /// <param name="uid"></param>
  51. /// <returns></returns>
  52. public List<MailPage> GetAll(int uid)
  53. {
  54. string sql = "select sd2.Name as ModelName,sd1.ShowName,sd1.PageUrl,sd1.MName,sd1.Uid from "+
  55. "(select sm.ShowName, sm.PageName as PageUrl,c.Uid,sd.[Name] as MName,Mid "+
  56. "from SystemMenu sm "+
  57. "join Competence c on sm.Id = c.Sid " +
  58. "join SetData sd on sd.id = sm.Mnid " +
  59. "where c.STable = 0 " +
  60. "and sm.IsEnable = 1 " +
  61. "and sm.IsDel = 0 " +
  62. "and sm.IsShow = 1 " +
  63. "and Uid = @Uid ) sd1 ,SetData sd2 " +
  64. "where sd1.Mid = sd2.Id " +
  65. "and sd2.STid = 5";
  66. return excuteSql(sql, new SqlParameter("@Uid", uid));
  67. }
  68. }
  69. }