DataImpl.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /************************************************************************/
  2. /* Copyright (C), 2016-2020, [IT], 保留所有权利;
  3. /* 模 块 名:;
  4. /* 描 述:当前项目数据库操作实现;
  5. /*
  6. /* 版 本:[V];
  7. /* 作 者:[IT];
  8. /* 日 期:[11/13/2016];
  9. /*
  10. /*
  11. /* 注 意:;
  12. /*
  13. /* 修改记录:[IT];
  14. /* 修改日期:;
  15. /* 修改版本:;
  16. /* 修改内容:;
  17. /************************************************************************/
  18. #ifndef __DATA_IMPL__
  19. #define __DATA_IMPL__
  20. #pragma once
  21. #include <vector>
  22. #include "TableInfo.h"
  23. class CDataImpl
  24. {
  25. public:
  26. CDataImpl(void);
  27. virtual ~CDataImpl(void);
  28. // 私有变量;
  29. private:
  30. sqlite3 *m_psqlite3;
  31. // 用户函数;
  32. public:
  33. BOOL Open();
  34. void Close();
  35. // begin;
  36. int TransactionBegin()
  37. {
  38. char* psqlite_error = NULL;
  39. INT nRet = sqlite3_exec(m_psqlite3, "begin;", 0, 0, &psqlite_error);
  40. if ( nRet != SQLITE_OK)
  41. {
  42. if ( psqlite_error )
  43. {
  44. sqlite3_free(psqlite_error);
  45. psqlite_error = NULL;
  46. }
  47. return nRet;
  48. }
  49. return SQLITE_OK;
  50. }
  51. // commit;
  52. int TransactionCommit()
  53. {
  54. char* psqlite_error = NULL;
  55. INT nRet = sqlite3_exec(m_psqlite3, "commit;", 0, 0, &psqlite_error);
  56. if ( nRet != SQLITE_OK)
  57. {
  58. if ( psqlite_error )
  59. {
  60. sqlite3_free(psqlite_error);
  61. psqlite_error = NULL;
  62. }
  63. return nRet;
  64. }
  65. return SQLITE_OK;
  66. }
  67. // 执行语句;
  68. BOOL ExecteSQL(IN LPCSTR lpSQL);
  69. // 查询表是否存在;
  70. BOOL QueryTable(std::string table);
  71. public:
  72. INT InsertOrder(const TB_ORDER &order);
  73. INT InsertOrder(std::string strOrder, std::string strDeltaEType, std::string strDeltaEValue, int nMode);
  74. INT InsertSN(const TB_SN &sn_data);
  75. INT InsertSN(std::string strOrder, std::string strLine, std::string strSN, std::string strTesttTime, int nElapsed, int nTestResult, DOUBLE dDeltaAVGEValue, DOUBLE dDeltaEValue, std::string strDetails );
  76. INT QueryOrder(std::string strOrder, TB_ORDER &order);
  77. INT QueryOrders(std::vector<TB_ORDER> &vtOrders, std::string strBeginTime, std::string EndTime);
  78. INT QuerySNData(std::string strSN, TB_SN &sn_data);
  79. INT QuerySNData(std::string strOrder, std::vector<TB_SN> &vtSNdata);
  80. INT QuerySNData(std::vector<TB_SN> &vtSNData, std::string strBeginTime, std::string EndTime);
  81. BOOL UpdateOrder(TB_ORDER &order);
  82. BOOL UpdateOrder(std::string strOrder, std::string strDeltaEType, std::string strDeltaEValue, int nMode);
  83. BOOL UpdateSNData(TB_SN &sn_data);
  84. BOOL UpdateSNData(std::string strOrder,std::string strSN, std::string strLine, std::string strTestTime, int nElapsed, int nTestResult, double dAVGDeltaEVlaue, DOUBLE dDeltaEValue, std::string strDetails);
  85. BOOL DeleteOrder(std::string strOrder);//同时删除所有关联的SN;
  86. BOOL DeleteSNData(std::string strSN);
  87. };
  88. #endif