CGDEUService.cs 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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 CGDEUService
  11. {
  12. /// <summary>
  13. /// 查询所有
  14. /// </summary>
  15. /// <param name="sql">sql语句</param>
  16. /// <param name="param">可变参数数组</param>
  17. /// <returns>返回集合</returns>
  18. List<CarGuideData_EU> excuteSql(string sql, params SqlParameter[] param)
  19. {
  20. return ServiceBase<CarGuideData_EU>.excuteSql(new CarGuideData_EU(), "CarGuideData_EU", 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_EU excuteType(string sql, params SqlParameter[] param)
  29. {
  30. //查询结果放入对象集合
  31. List<CarGuideData_EU> 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_EU> 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_EU>.excutePageSql(new CarGuideData_EU(), "CarGuideData_EU", "CarGuideData_EU", "*", "id asc", sqlwhere, 10, pageIndex, out sumPage, out totalRecord);
  49. }
  50. /// <summary>
  51. /// 获取全部
  52. /// </summary>
  53. /// <returns></returns>
  54. public List<CarGuideData_EU> GetALL()
  55. {
  56. return excuteSql("select * from CarGuideData_EU where IsDel=0");
  57. }
  58. /// <summary>
  59. /// 单个查询
  60. /// </summary>
  61. /// <returns></returns>
  62. public CarGuideData_EU GetALL(string area, string type, string cost)
  63. {
  64. return excuteType("select * from CarGuideData_EU where IsDel=0 and area like '%" + area + "%' " + "and CarType like '%" + type + "%' " + "and CarCost like '%" + cost + "%'");
  65. }
  66. }
  67. }