You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

124 lines
4.1 KiB

2 years ago
  1. using EasyNet.Common;
  2. using EasyNet.Manager;
  3. using System;
  4. namespace EasyNet.DBUtility
  5. {
  6. public class DBHelper
  7. {
  8. private DbManager m;
  9. public DBHelper()
  10. {
  11. m = DbManager.PriviteInstance();
  12. }
  13. public static DBHelper GetInstance() => new DBHelper();
  14. /// <summary>
  15. /// 自定義刪除資料
  16. /// </summary>
  17. /// <param name="obj">todo: describe obj parameter on Delete</param>
  18. /// <typeparam name="param">sql</typeparam>
  19. /// <returns></returns>
  20. public int Delete(Object obj) => m.Delete(obj);
  21. /// <summary>
  22. /// 自定義修改資料
  23. /// </summary>
  24. /// <param name="obj">todo: describe obj parameter on Update</param>
  25. /// <typeparam name="param">sql</typeparam>
  26. /// <returns></returns>
  27. public int Update(Object obj) => m.Update(obj);
  28. /// <summary>
  29. /// 自定義修改資料(MasterDteil)
  30. /// </summary>
  31. /// <param name="obj">todo: describe obj parameter on UpdateTran</param>
  32. /// <typeparam name="param">sql</typeparam>
  33. /// <returns></returns>
  34. public int UpdateTran(Object obj) => m.UpdateTran(obj);
  35. /// <summary>
  36. /// 自定義修改資料
  37. /// </summary>
  38. /// <param name="obj">todo: describe obj parameter on Insert</param>
  39. /// <typeparam name="param">sql</typeparam>
  40. /// <returns></returns>
  41. public int Insert(Object obj) => m.Insert(obj);
  42. /// <summary>
  43. /// 執行預存函數
  44. /// </summary>
  45. /// <param name="param">參數</param>
  46. /// <returns></returns>
  47. public static int ExecuteSqlTran(Object param) => DbManager.ExecuteSqlTran(param);
  48. /// <summary>
  49. /// 根據SQL查詢資料
  50. /// </summary>
  51. /// <param name="sSql">SQL命令</param>
  52. /// <param name="obj">todo: describe obj parameter on QueryList</param>
  53. /// <typeparam name="T">對象類型</typeparam>
  54. /// <returns></returns>
  55. public static Object QueryList(string sSql, Object obj) => DbManager.QueryList(sSql, obj);
  56. /// <summary>
  57. /// 根據SQL查詢資料
  58. /// </summary>
  59. /// <param name="obj">todo: describe obj parameter on QueryCount</param>
  60. /// <typeparam name="T">對象類型</typeparam>
  61. /// <returns></returns>
  62. public static int QueryCount(Object obj) => DbManager.QueryCount(obj);
  63. /// <summary>
  64. /// 根據SQL查詢單筆資料
  65. /// </summary>
  66. /// <param name="sSql">SQL命令</param>
  67. /// <param name="obj">todo: describe obj parameter on QueryOne</param>
  68. /// <typeparam name="T">對象類型</typeparam>
  69. /// <returns></returns>
  70. public static Object QueryOne(string sSql, Object obj) => DbManager.QueryOne(sSql, obj);
  71. /// <summary>
  72. /// 分頁查詢返回分頁對象
  73. /// </summary>
  74. /// <typeparam name="T">對象類型</typeparam>
  75. /// <param name="param">參數</param>
  76. /// <returns></returns>
  77. public PageResult QueryPage(ParamMap param) => m.QueryPage(param);
  78. /// <summary>
  79. /// 分頁查詢返回分頁對象
  80. /// </summary>
  81. /// <param name="sSql">SQL命令</param>
  82. /// <param name="param">參數</param>
  83. /// <param name="bCount">todo: describe bCount parameter on QueryPageByPrc</param>
  84. /// <typeparam name="T">對象類型</typeparam>
  85. /// <returns></returns>
  86. public static PageResult QueryPageByPrc(string sSql, Object param, bool bCount) => DbManager.QueryPageByPrc(sSql, param, bCount);
  87. /// <summary>
  88. /// 開啟事務
  89. /// </summary>
  90. public void BeginTransaction()
  91. {
  92. m.BeginTransaction();
  93. }
  94. /// <summary>
  95. /// 提交事務
  96. /// </summary>
  97. public void CommitTransaction()
  98. {
  99. m.Commit();
  100. }
  101. /// <summary>
  102. /// 回滾事務
  103. /// </summary>
  104. public void RollbackTransaction()
  105. {
  106. m.Rollback();
  107. }
  108. }
  109. }