CSqlite3.h 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. #pragma once
  2. #include <sqlite3/sqlite3.h>
  3. #include "CSetting.h"
  4. #include "../zhipuzi/CFoodtype.h"
  5. #include "../zhipuzi/CFood.h"
  6. #include "../zhipuzi/CFoodpackage.h"
  7. class CSqlite3
  8. {
  9. public:
  10. CSqlite3();
  11. ~CSqlite3();
  12. public:
  13. //下面这些是初始化数据库表的函数
  14. bool InitDB();
  15. bool InitPosConfig();
  16. bool InitPosChufangPrinter();
  17. bool InitPosUser();
  18. bool InitPosFood();
  19. bool InitPosFoodType();
  20. bool InitPosFoodPackage();
  21. //下面这些是读写数据库特定表的函数
  22. bool SaveParams(std::map<std::string, std::string>& params);
  23. bool SaveChufangPrinter(std::vector<ChufangPrinter>& printers);
  24. bool SaveUsers(std::map<string, string> users);
  25. //登录成功的时候,初始化数据库数据
  26. bool InitFoodData(rapidjson::Value& foodrows);
  27. bool InitFoodtypeData(rapidjson::Value& foodtyperows);
  28. bool InitFoodpackageData(rapidjson::Value& foodpackagerows);
  29. //获取套餐商品的数量
  30. int GetFoodpackageNum();
  31. std::vector<CFoodType> GetFoodtypes(bool is_shouyinji_show = true);
  32. std::vector<CFood> GetFoodByTypeid(std::string type_id, bool is_shouyinji_show = true);
  33. std::vector<CFoodpackage> GetFoodpackages(bool is_shouyinji_show = true);
  34. //通过商品ID查找商品,如果找到返回true,找不到返回false
  35. bool GetFoodById(std::string food_id, CFood& newFood);
  36. //更新商品ID的库存
  37. void UpdateFoodStock(std::string food_id, std::string stock);
  38. private:
  39. bool ExeSQl(std::string sql);
  40. private:
  41. int m_rc;
  42. sqlite3* m_db = NULL;
  43. };