QrCodeTradeStat.cs 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. using System;
  2. using System.Collections.Generic;
  3. using Library;
  4. using System.Linq;
  5. using MySystem.Models.Main;
  6. namespace MySystem
  7. {
  8. public class QrCodeTradeStat
  9. {
  10. public readonly static QrCodeTradeStat Instance = new QrCodeTradeStat();
  11. public QrCodeTradeStat()
  12. { }
  13. public decimal Amount(string SnNo)
  14. {
  15. decimal amt = 0;
  16. WebCMSEntities db = new WebCMSEntities();
  17. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo);
  18. if (check)
  19. {
  20. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo).Sum(m => m.TradeAmount);
  21. }
  22. db.Dispose();
  23. return amt;
  24. }
  25. public decimal Amount(string SnNo, string DateOrMonth)
  26. {
  27. decimal amt = 0;
  28. WebCMSEntities db = new WebCMSEntities();
  29. if(DateOrMonth.Length == 8)
  30. {
  31. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.TradeDate == DateOrMonth);
  32. if (check)
  33. {
  34. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.TradeDate == DateOrMonth).Sum(m => m.TradeAmount);
  35. }
  36. }
  37. else
  38. {
  39. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.TradeMonth == DateOrMonth);
  40. if (check)
  41. {
  42. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.TradeMonth == DateOrMonth).Sum(m => m.TradeAmount);
  43. }
  44. }
  45. db.Dispose();
  46. return amt;
  47. }
  48. public int Count(string SnNo, string DateOrMonth)
  49. {
  50. int amt = 0;
  51. WebCMSEntities db = new WebCMSEntities();
  52. if(DateOrMonth.Length == 8)
  53. {
  54. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.TradeDate == DateOrMonth);
  55. if (check)
  56. {
  57. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.TradeDate == DateOrMonth).Sum(m => m.TradeCount);
  58. }
  59. }
  60. else
  61. {
  62. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.TradeMonth == DateOrMonth);
  63. if (check)
  64. {
  65. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.TradeMonth == DateOrMonth).Sum(m => m.TradeCount);
  66. }
  67. }
  68. db.Dispose();
  69. return amt;
  70. }
  71. public decimal Amount(string SnNo, string DateOrMonth, int PayMode)
  72. {
  73. decimal amt = 0;
  74. WebCMSEntities db = new WebCMSEntities();
  75. if(DateOrMonth.Length == 8)
  76. {
  77. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.PayMode == PayMode && m.TradeDate == DateOrMonth);
  78. if (check)
  79. {
  80. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.PayMode == PayMode && m.TradeDate == DateOrMonth).Sum(m => m.TradeAmount);
  81. }
  82. }
  83. else
  84. {
  85. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.PayMode == PayMode && m.TradeMonth == DateOrMonth);
  86. if (check)
  87. {
  88. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.PayMode == PayMode && m.TradeMonth == DateOrMonth).Sum(m => m.TradeAmount);
  89. }
  90. }
  91. db.Dispose();
  92. return amt;
  93. }
  94. public int Count(string SnNo, string DateOrMonth, int PayMode)
  95. {
  96. int amt = 0;
  97. WebCMSEntities db = new WebCMSEntities();
  98. if(DateOrMonth.Length == 8)
  99. {
  100. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.PayMode == PayMode && m.TradeDate == DateOrMonth);
  101. if (check)
  102. {
  103. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.PayMode == PayMode && m.TradeDate == DateOrMonth).Sum(m => m.TradeCount);
  104. }
  105. }
  106. else
  107. {
  108. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.PayMode == PayMode && m.TradeMonth == DateOrMonth);
  109. if (check)
  110. {
  111. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.PayMode == PayMode && m.TradeMonth == DateOrMonth).Sum(m => m.TradeCount);
  112. }
  113. }
  114. db.Dispose();
  115. return amt;
  116. }
  117. public decimal Amount(string SnNo, string DateOrMonth, int PayMode, int IsAct)
  118. {
  119. decimal amt = 0;
  120. WebCMSEntities db = new WebCMSEntities();
  121. if(DateOrMonth.Length == 8)
  122. {
  123. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth);
  124. if (check)
  125. {
  126. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth).Sum(m => m.TradeAmount);
  127. }
  128. }
  129. else
  130. {
  131. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth);
  132. if (check)
  133. {
  134. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth).Sum(m => m.TradeAmount);
  135. }
  136. }
  137. db.Dispose();
  138. return amt;
  139. }
  140. public int Count(string SnNo, string DateOrMonth, int PayMode, int IsAct)
  141. {
  142. int amt = 0;
  143. WebCMSEntities db = new WebCMSEntities();
  144. if(DateOrMonth.Length == 8)
  145. {
  146. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth);
  147. if (check)
  148. {
  149. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeDate == DateOrMonth).Sum(m => m.TradeCount);
  150. }
  151. }
  152. else
  153. {
  154. bool check = db.QrCodeAmountSummay.Any(m => m.SnNo == SnNo && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth);
  155. if (check)
  156. {
  157. amt = db.QrCodeAmountSummay.Where(m => m.SnNo == SnNo && m.PayMode == PayMode && m.IsAct == IsAct && m.TradeMonth == DateOrMonth).Sum(m => m.TradeCount);
  158. }
  159. }
  160. db.Dispose();
  161. return amt;
  162. }
  163. }
  164. }