#pragma once #include #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& params); bool SaveChufangPrinter(std::vector& printers); bool SaveUsers(std::map 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 GetFoodtypes(bool is_shouyinji_show = true); bool GetFoodtypeById(std::string foodtype_id, CFoodType& newFoodType); //获取某一个商品分类下的商品 std::vector GetFoodByTypeid(std::string type_id, bool is_shouyinji_show = true); //获取某一个商品分类下的商品 std::vector GetFoodForTiaomacheng(); //用于商品搜索 std::vector GetFoodByFoodname(std::string foodname, bool is_shouyinji_show = true); std::vector 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; };