CGDSAService.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Data;
  5. using System.Data.SqlClient;
  6. using System.Linq;
  7. using System.Text;
  8. namespace DAL
  9. {
  10. public class CGDSAService
  11. {
  12. /// <summary>
  13. /// 查询所有
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<CarGuideData_SA> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<CarGuideData_SA>.excuteSql(new CarGuideData_SA(), "CarGuideData_SA", sql, CommandType.Text, param);
  21. }
  22. /// <summary>
  23. /// 获取单个对象
  24. /// </summary>
  25. /// <param name="sql">sql语句</param>
  26. /// <param name="param">可变参数数组</param>
  27. /// <returns>返回空或者单个对象</returns>
  28. CarGuideData_SA excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<CarGuideData_SA> hdList = excuteSql(sql, param);
  32. //判断集合是否为空
  33. if (hdList == null || hdList.Count == 0)
  34. //返回null
  35. return null;
  36. //返回单个对象
  37. return hdList[0];
  38. }
  39. /// <summary>
  40. /// 获取全部 - 分页
  41. /// </summary>
  42. /// <returns></returns>
  43. public List<CarGuideData_SA> GetALL(int pageIndex, out int sumPage, out int totalRecord, string Area)
  44. {
  45. string sqlwhere = "IsDel = 0";
  46. if (!string.IsNullOrEmpty(Area))
  47. sqlwhere += " and Area like '%" + Area + "%'";
  48. return PageBase<CarGuideData_SA>.excutePageSql(new CarGuideData_SA(), "CarGuideData_SA", "CarGuideData_SA", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  49. }
  50. /// <summary>
  51. /// 单个查询
  52. /// </summary>
  53. /// <returns></returns>
  54. public CarGuideData_SA GetALL(string area, string type, string cost)
  55. {
  56. return excuteType("select * from CarGuideData_SA where IsDel=0 and area like '%" + area + "%' " + "and CarType like '%" + type + "%' " + "and CarCost like '%" + cost + "%'");
  57. }
  58. }
  59. }