张洋 пре 4 година
родитељ
комит
3fd506c4cb

BIN
bin/Win32/Release/setup/zhipuzi_pos_windows_setup_1.0.0.1.exe


+ 2 - 1
zhipuzi_pos_windows/page/CShangpinPageUI.cpp

@@ -428,7 +428,8 @@ void CShangpinPageUI::ShowNewtype()
 
 		if (ret == IDOK)
 		{
-			
+			//这里表示添加分类成功了,刷新分类显示
+			InitFoodtypeShow();
 
 			m_is_show_modal_wnd = false;
 			delete pMemoDlg;

BIN
zhipuzi_pos_windows/resource/skin.zip


+ 26 - 2
zhipuzi_pos_windows/tool/CSqlite3.cpp

@@ -593,7 +593,8 @@ bool CSqlite3::InitPosFoodType()
 				sql = "CREATE TABLE pos_foodtype("  \
 					"id         CHAR(20)          UNIQUE NOT NULL,"\
 					"name    CHAR(200)         NOT NULL," \
-					"is_shouyinji_show   CHAR(100)          NOT NULL);";
+					"is_shouyinji_show   CHAR(100)          NOT NULL," \
+					"tag   CHAR(100)          NOT NULL);";
 
 				if (sqlite3_prepare_v2(m_db, sql.c_str(), -1, &stmt, NULL) == SQLITE_OK)
 				{
@@ -919,9 +920,10 @@ bool CSqlite3::InitFoodtypeData(rapidjson::Value& foodtyperows)
 		std::string type_id = foodtypeinfo["type_id"].GetString();
 		std::string name = foodtypeinfo["name"].GetString();
 		std::string is_shouyinji_show = foodtypeinfo["is_shouyinji_show"].GetString();
+		std::string tag = foodtypeinfo["tag"].GetString();
 
 		//插入一个商品数据
-		std::string sql = "INSERT INTO pos_foodtype (id,name,is_shouyinji_show) VALUES ('" + type_id + "' ,'" +  name + "', '" + is_shouyinji_show + "')";
+		std::string sql = "INSERT INTO pos_foodtype (id,name,is_shouyinji_show,tag) VALUES ('" + type_id + "' ,'" +  name + "', '" + is_shouyinji_show + "', '" + tag + "')";
 
 		bool ret = this->ExeSQl(sql);
 		if (!ret)
@@ -1086,6 +1088,25 @@ bool CSqlite3::DeleteOneFood(std::string food_id)
 	return true;
 }
 
+bool CSqlite3::AddOneFoodtype(std::string type_id, std::string name, std::string is_shouyinji_show, std::string tag)
+{
+	this->ExeSQl("begin;");
+
+	//插入一个商品数据
+	std::string sql = "INSERT INTO pos_foodtype (id,name,is_shouyinji_show,tag) VALUES ('" + type_id + "' ,'" + name + "', '" + is_shouyinji_show + "', '" + tag + "')";
+
+	bool ret = this->ExeSQl(sql);
+	if (!ret)
+	{
+		LOG_INFO("商品分类插入失败:");
+		return false;
+	}
+
+	this->ExeSQl("commit;");
+
+	return true;
+}
+
 bool CSqlite3::ExeSQl(std::string sql)
 {
 	char *zErrMsg = 0;
@@ -1157,11 +1178,13 @@ std::vector<CFoodType> CSqlite3::GetFoodtypes(bool is_shouyinji_show)
 			std::string id = (char*)sqlite3_column_text(stmt, 0);
 			std::string name = (char*)sqlite3_column_text(stmt, 1);
 			std::string is_shouyinji_show = (char*)sqlite3_column_text(stmt, 2);
+			std::string tag = (char*)sqlite3_column_text(stmt, 3);
 
 			CFoodType newtype;
 			newtype.id = id;
 			newtype.name = name;
 			newtype.is_shouyinji_show = is_shouyinji_show;
+			newtype.tag = tag;
 
 			data.push_back(newtype);
 		}
@@ -1194,6 +1217,7 @@ bool CSqlite3::GetFoodtypeById(std::string foodtype_id, CFoodType& newFoodType)
 			newFoodType.id = (char*)sqlite3_column_text(stmt, 0);
 			newFoodType.name = (char*)sqlite3_column_text(stmt, 1);
 			newFoodType.is_shouyinji_show = (char*)sqlite3_column_text(stmt, 2);
+			newFoodType.tag = (char*)sqlite3_column_text(stmt, 3);
 		}
 
 		sqlite3_finalize(stmt);

+ 2 - 0
zhipuzi_pos_windows/tool/CSqlite3.h

@@ -37,6 +37,8 @@ public:
 	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();
 

+ 24 - 1
zhipuzi_pos_windows/wnd/CShangpinNewTypeWnd.cpp

@@ -1,6 +1,8 @@
 #include "../pch/pch.h"
 #include "CShangpinNewTypeWnd.h"
 
+#include "../tool/CSqlite3.h"
+
 LRESULT CShangpinNewTypeWnd::OnNcPaint(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
 {
 	return 0;
@@ -229,10 +231,25 @@ void CShangpinNewTypeWnd::StartSave()
 
 void CShangpinNewTypeWnd::HandleSave()
 {
+	CEditUI* pFukuanEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("fenlei_create_page_name_edit")));
+	std::wstring ws_foodtype_name = pFukuanEdit->GetText();
+	std::string foodtype_name = CLewaimaiString::UnicodeToUTF8(ws_foodtype_name);
+
+	CEditUI* pXuhaoEdit = static_cast<CEditUI*>(m_pm.FindControl(_T("fenlei_create_page_xuhao_edit")));
+	std::wstring ws_xuhao = pXuhaoEdit->GetText();
+	std::string xuhao = CLewaimaiString::UnicodeToUTF8(ws_xuhao);
+	if (xuhao == "")
+	{
+		xuhao = "0";
+	}
+
 	std::map<string, string> params;
+	params["name"] = foodtype_name;
+	params["tag"] = xuhao;
+	params["is_show"] = "1";
 
 	std::string response;
-	bool ret = CZhipuziHttpClient::GetInstance()->Request("/goods/newtype", params, response);
+	bool ret = CZhipuziHttpClient::GetInstance()->Request("/goods/CreateFoodType", params, response);
 	if (!ret)
 	{
 		m_errorInfo = _T("网络请求出错");
@@ -274,6 +291,12 @@ void CShangpinNewTypeWnd::HandleSave()
 
 		rapidjson::Value& data = document["data"];
 
+		//分类创建成功,开始进行后续处理
+		std::string type_id = data["type_id"].GetString();
+
+		CSqlite3 sqlite;
+		sqlite.AddOneFoodtype(type_id, foodtype_name, "1", xuhao);
+
 		PostMessage(WM_MEMBER_CHECK_SUCCESS);
 	}
 }

+ 1 - 0
zhipuzi_pos_windows/zhipuzi/CFoodtype.h

@@ -9,4 +9,5 @@ public:
 	std::string id;
 	std::string name;
 	std::string is_shouyinji_show;
+	std::string tag;
 };