FunctionOperatingService.cs 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Models;
  6. using System.Data;
  7. using System.Data.SqlClient;
  8. namespace DAL
  9. {
  10. /// <summary>
  11. /// 功能权限多表联查数据访问类
  12. /// </summary>
  13. public class FunctionOperatingService
  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<FunctionOperating> excuteSql(string sql, params SqlParameter[] param)
  25. {
  26. List<FunctionOperating> foList = null;
  27. FunctionOperating fo = null;
  28. using (SqlDataReader dr = SqlHelper.ExcuteReader(sql, CommandType.Text, param))
  29. {
  30. if (dr != null)
  31. {
  32. foList = new List<FunctionOperating>();
  33. while (dr.Read())
  34. {
  35. fo = new FunctionOperating();
  36. fo.Name = dr["Name"].ToString();
  37. fo.Code = dr["Code"].ToString();
  38. fo.IsEnable = Convert.ToInt32(dr["IsEnable"]);
  39. fo.Uid = Convert.ToInt32(dr["Uid"]);
  40. foList.Add(fo);
  41. }
  42. }
  43. }
  44. return foList;
  45. }
  46. /// <summary>
  47. /// 根据用户编号获取数据
  48. /// </summary>
  49. /// <param name="uid"></param>
  50. /// <returns></returns>
  51. public List<FunctionOperating> GetAll(string code,int uid)
  52. {
  53. 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";
  54. return excuteSql(sql, new SqlParameter("@Code", code), new SqlParameter("@Uid", uid));
  55. }
  56. }
  57. }