Tk_GalleryBLL.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. using Interface;
  2. using Models;
  3. using Models.Entity.LottomatBaseDB;
  4. using Models.Views;
  5. using Newtonsoft.Json;
  6. using Newtonsoft.Json.Linq;
  7. using Services;
  8. using System;
  9. using System.Collections.Generic;
  10. using System.Linq;
  11. using System.Web;
  12. namespace Business.TK
  13. {
  14. public static class Tk_GalleryBLL
  15. {
  16. static ZXInterface service;
  17. static Tk_GalleryBLL()
  18. {
  19. service = new ZXServic();
  20. }
  21. public static List<Tk_Gallery> GetPageList(int page, int rows, Dictionary<string, Object> queryParam, out int count, string order = null, bool isDesc = false)
  22. {
  23. List<EExpression> listexp = new List<EExpression>();
  24. if (queryParam.Keys.Count > 0)
  25. {
  26. if (queryParam.ContainsKey("ID"))
  27. {
  28. string ID = queryParam["ID"].ToString();
  29. listexp.Add(new EExpression("ID", "=", ID));
  30. }
  31. if (queryParam.ContainsKey("GalleryNumber"))
  32. {
  33. int GalleryNumber = (int)queryParam["GalleryNumber"];
  34. listexp.Add(new EExpression("GalleryNumber", "=", GalleryNumber));
  35. }
  36. if (queryParam.ContainsKey("GalleryName"))
  37. {
  38. string GalleryName = queryParam["GalleryName"].ToString();
  39. listexp.Add(new EExpression("GalleryName", "=", GalleryName));
  40. }
  41. if (queryParam.ContainsKey("CategoryId"))
  42. {
  43. string CategoryId = queryParam["CategoryId"].ToString();
  44. listexp.Add(new EExpression("CategoryId", "=", CategoryId));
  45. }
  46. if (queryParam.ContainsKey("SortCode"))
  47. {
  48. int SortCode = (int)queryParam["SortCode"];
  49. listexp.Add(new EExpression("SortCode", "=", SortCode));
  50. }
  51. if (queryParam.ContainsKey("IsPicZip"))
  52. {
  53. int IsPicZip = (int)queryParam["IsPicZip"];
  54. listexp.Add(new EExpression("IsPicZip", "=", IsPicZip));
  55. }
  56. if (queryParam.ContainsKey("Reamrk"))
  57. {
  58. string Reamrk = queryParam["Reamrk"].ToString();
  59. listexp.Add(new EExpression("Reamrk", EnumExpression.like, Reamrk));
  60. }
  61. if (queryParam.ContainsKey("SeoKey"))
  62. {
  63. string SeoKey = "%" + queryParam["SeoKey"].ToString() + "%";
  64. listexp.Add(new EExpression("SeoKey", EnumExpression.like, SeoKey));
  65. }
  66. if (queryParam.ContainsKey("CreateTime"))
  67. {
  68. string CreateTime = queryParam["CreateTime"].ToString();
  69. listexp.Add(new EExpression("CreateTime", "=", CreateTime));
  70. }
  71. if (queryParam.ContainsKey("HotNumber"))
  72. {
  73. int HotNumber = (int)queryParam["HotNumber"];
  74. listexp.Add(new EExpression("HotNumber", "=", HotNumber));
  75. }
  76. if (queryParam.ContainsKey("AreaCode"))
  77. {
  78. string AreaCode = queryParam["AreaCode"].ToString();
  79. listexp.Add(new EExpression("AreaCode", "=", AreaCode));
  80. }
  81. }
  82. var data = service.GetList<Tk_Gallery>(page, rows, order, listexp, isDesc);
  83. count = service.GetPageListCount<Tk_Gallery>(listexp);
  84. return data;
  85. }
  86. /// <summary>
  87. /// 获取数据最新期号
  88. /// </summary>
  89. /// <returns></returns>
  90. public static int NewPeriodsNumber()
  91. {
  92. string sql = string.Format(@" select top 1 * from Tk_GalleryDetail where
  93. GalleryId in (select ID from Tk_Gallery ) order by PeriodsNumber desc");
  94. List<Tk_GalleryDetail> list = service.ExSqlGetList<Tk_GalleryDetail>(sql);
  95. if (list != null)
  96. {
  97. return int.Parse(list[0].PeriodsNumber.ToString());
  98. }
  99. return 0;
  100. }
  101. public static List<string> GalleryNumberList()
  102. {
  103. string sql = string.Format(@"SELECT DISTINCT TOP 100 PeriodsNumber FROM (SELECT TOP 100000 PeriodsNumber FROM Tk_GalleryDetail ORDER BY addTime DESC) AS a ");
  104. List<string> list = service.ExSqlGetstringList(sql);
  105. return list;
  106. }
  107. /// <summary>
  108. /// 获取此年份的最大期数
  109. /// </summary>
  110. /// <param name="year">年份</param>
  111. /// <returns></returns>
  112. public static string GetYearMaxPeridos(string year)
  113. {
  114. string sql= string.Format(@" select PeriodsNumber
  115. from Tk_GalleryDetail
  116. where CreateTime =(select MAX(CreateTime)
  117. from Tk_GalleryDetail
  118. where CreateTime <='{0}-12-31 00:00:00')", year);
  119. string peridos = service.ExecuteScalar(sql).ToString();
  120. return peridos;
  121. }
  122. public static Tk_Gallery QueryItemByKey(object key)
  123. {
  124. return service.QueryItembyKey<Tk_Gallery>(key);
  125. }
  126. }
  127. }