| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879 |
- #pragma once
- #include <sqlite3/sqlite3.h>
- #include "CSetting.h"
- #include "../zhipuzi/CFoodtype.h"
- #include "../zhipuzi/CFood.h"
- #include "../zhipuzi/CFoodpackage.h"
- class CSqlite3
- {
- public:
- CSqlite3();
- ~CSqlite3();
- public:
- //下面这些是初始化数据库表的函数
- bool InitDB();
- bool InitPosConfig();
- bool InitPosChufangPrinter();
- bool InitPosUser();
- bool InitPosFood();
- bool InitPosFoodType();
- bool InitPosFoodPackage();
- //下面这些是读写数据库特定表的函数
- bool SaveParams(std::map<std::string, std::string>& params);
- bool SaveChufangPrinter(std::vector<ChufangPrinter>& printers);
- bool SaveUsers(std::map<string, string> users);
- //登录成功的时候,初始化数据库数据
- bool InitFoodData(rapidjson::Value& foodrows);
- bool InitFoodtypeData(rapidjson::Value& foodtyperows);
- bool InitFoodpackageData(rapidjson::Value& foodpackagerows);
- bool UpdateOneFood(rapidjson::Value& foodrows);
- bool DeleteOneFood(std::string food_id);
- bool AddOneFoodtype(std::string type_id, std::string name, std::string is_shouyinji_show, std::string tag);
- //获取套餐商品的数量
- int GetFoodpackageNum();
- //获取所有分类信息
- std::vector<CFoodType> GetFoodtypes(bool is_shouyinji_show = true);
- bool GetFoodtypeById(std::string foodtype_id, CFoodType& newFoodType);
- //获取某一个商品分类下的商品
- std::vector<CFood> GetFoodByTypeid(std::string type_id, bool is_shouyinji_show = true);
- //获取某一个商品分类下的商品
- std::vector<CFood> GetFoodForTiaomacheng();
- //用于商品搜索
- std::vector<CFood> GetFoodByFoodname(std::string foodname, bool is_shouyinji_show = true);
- std::vector<CFoodpackage> GetFoodpackages(bool is_shouyinji_show = true);
- //通过商品ID查找商品,如果找到返回true,找不到返回false
- bool GetFoodById(std::string food_id, CFood& newFood);
- //通过商品条码查找商品,如果找到返回true,找不到返回false
- bool GetFoodByBarcode(std::string barcode, CFood& newFood);
- //通过PLU商品编码查找商品,如果找到返回true,找不到返回false
- bool GetFoodByPluBianma(std::string barcode, CFood& newFood);
- //更新商品ID的库存
- void UpdateFoodStock(std::string food_id, std::string stock);
- private:
- bool ExeSQl(std::string sql);
- private:
- int m_rc;
- sqlite3* m_db = NULL;
- };
|