CSqlite3.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  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. bool UpdateOneFood(rapidjson::Value& foodrows);
  30. bool DeleteOneFood(std::string food_id);
  31. bool AddOneFoodtype(std::string type_id, std::string name, std::string is_shouyinji_show, std::string tag);
  32. //获取套餐商品的数量
  33. int GetFoodpackageNum();
  34. //获取所有分类信息
  35. std::vector<CFoodType> GetFoodtypes(bool is_shouyinji_show = true);
  36. bool GetFoodtypeById(std::string foodtype_id, CFoodType& newFoodType);
  37. //获取某一个商品分类下的商品
  38. std::vector<CFood> GetFoodByTypeid(std::string type_id, bool is_shouyinji_show = true);
  39. //获取某一个商品分类下的商品
  40. std::vector<CFood> GetFoodForTiaomacheng();
  41. //用于商品搜索
  42. std::vector<CFood> GetFoodByFoodname(std::string foodname, bool is_shouyinji_show = true);
  43. std::vector<CFoodpackage> GetFoodpackages(bool is_shouyinji_show = true);
  44. //通过商品ID查找商品,如果找到返回true,找不到返回false
  45. bool GetFoodById(std::string food_id, CFood& newFood);
  46. //通过商品条码查找商品,如果找到返回true,找不到返回false
  47. bool GetFoodByBarcode(std::string barcode, CFood& newFood);
  48. //通过PLU商品编码查找商品,如果找到返回true,找不到返回false
  49. bool GetFoodByPluBianma(std::string barcode, CFood& newFood);
  50. //更新商品ID的库存
  51. void UpdateFoodStock(std::string food_id, std::string stock);
  52. private:
  53. bool ExeSQl(std::string sql);
  54. private:
  55. int m_rc;
  56. sqlite3* m_db = NULL;
  57. };