UserDataDbconn.cs 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. using System;
  2. using System.Collections.Generic;
  3. using Library;
  4. using System.Linq;
  5. using System.Data;
  6. using MySystem.ReadModels;
  7. namespace MySystem
  8. {
  9. public class UserDataDbconn
  10. {
  11. public readonly static UserDataDbconn Instance = new UserDataDbconn();
  12. #region 广电卡存量查询
  13. public int GetSimActTradeAmt(int UserId, string Month, string Kind = "Self")
  14. {
  15. int ActCount = 0;
  16. string PreMonth = DateTime.Parse(Month.Substring(0, 4) + "-" + Month.Substring(4, 2) + "-01 00:00:00").AddMonths(-1).ToString("yyyyMM");
  17. DataTable dt = CustomerSqlConn.dtable("select SimValidAct" + Kind + "Count from KxsStatServer.SimValidAct" + PreMonth + " where UserId=" + UserId, MysqlConn.ReadSqlConnStr);
  18. if(dt.Rows.Count > 0)
  19. {
  20. ActCount = int.Parse(function.CheckInt(dt.Rows[0]["SimValidAct" + Kind + "Count"].ToString()));
  21. }
  22. return ActCount;
  23. }
  24. #endregion
  25. #region WIFI存量查询
  26. public int GetWifiActTradeAmt(int UserId, string Month, string Kind = "Self")
  27. {
  28. int ActCount = 0;
  29. string PreMonth = DateTime.Parse(Month.Substring(0, 4) + "-" + Month.Substring(4, 2) + "-01 00:00:00").AddMonths(-1).ToString("yyyyMM");
  30. DataTable dt = CustomerSqlConn.dtable("select sum(WifiAct" + Kind + "Count) WifiAct" + Kind + "Count from KxsStatServer.WifiValidAct" + PreMonth + " where UserId=" + UserId, MysqlConn.ReadSqlConnStr);
  31. if(dt.Rows.Count > 0)
  32. {
  33. ActCount = int.Parse(function.CheckInt(dt.Rows[0]["WifiAct" + Kind + "Count"].ToString()));
  34. }
  35. return ActCount;
  36. }
  37. #endregion
  38. }
  39. }