|
|
@@ -0,0 +1,769 @@
|
|
|
+#include "../pch/pch.h"
|
|
|
+#include "CShangpinUpdatePageUI.h"
|
|
|
+
|
|
|
+#include "../control/ControlEx.h"
|
|
|
+
|
|
|
+#include "../tool/CSqlite3.h"
|
|
|
+#include "../tool/CFoodHandle.h"
|
|
|
+#include "../wnd/CMainWnd.h"
|
|
|
+
|
|
|
+#include "../print/CPosPrinter.h"
|
|
|
+
|
|
|
+CShangpinUpdatePageUI::CShangpinUpdatePageUI()
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+
|
|
|
+CShangpinUpdatePageUI::~CShangpinUpdatePageUI()
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
+//初始化当前页面的展示,处理默认展示效果,在页面被加载的时候调用
|
|
|
+void CShangpinUpdatePageUI::InitShow()
|
|
|
+{
|
|
|
+ //商品名字
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_name_edit"));
|
|
|
+ pName->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.name).c_str());
|
|
|
+ pName->SetFocus();
|
|
|
+
|
|
|
+ //商品序号
|
|
|
+ CEditUI* pXuhao = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_xuhao_edit"));
|
|
|
+ pXuhao->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.tag).c_str());
|
|
|
+
|
|
|
+ //初始化商品分类
|
|
|
+ CComboUI* com_fenlei = static_cast<CComboUI*>(this->FindSubControl(_T("shangpin_create_page_foodtype")));
|
|
|
+ com_fenlei->RemoveAll();
|
|
|
+
|
|
|
+ CSqlite3 sqlite;
|
|
|
+ std::vector<CFoodType> foodtypes = sqlite.GetFoodtypes();
|
|
|
+
|
|
|
+ int nSelectType = -1;
|
|
|
+ int nCurNum = 0;
|
|
|
+ std::string select_foodtype_name;
|
|
|
+ for (std::vector<CFoodType>::iterator it = foodtypes.begin(); it != foodtypes.end(); it++)
|
|
|
+ {
|
|
|
+ CListLabelElementUI* elem = new CListLabelElementUI();
|
|
|
+
|
|
|
+ elem->SetText(CLewaimaiString::UTF8ToUnicode(it->name).c_str());
|
|
|
+ com_fenlei->Add(elem);
|
|
|
+
|
|
|
+ if (it->id == m_foodinfo.type_id)
|
|
|
+ {
|
|
|
+ nSelectType = nCurNum;
|
|
|
+ select_foodtype_name = it->name;
|
|
|
+ }
|
|
|
+
|
|
|
+ nCurNum++;
|
|
|
+
|
|
|
+ m_foodtype_id_map[it->name] = it->id;
|
|
|
+ }
|
|
|
+
|
|
|
+ com_fenlei->SetInternVisible(true);
|
|
|
+
|
|
|
+ if (nSelectType != -1)
|
|
|
+ {
|
|
|
+ com_fenlei->SelectItem(nSelectType, false, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ com_fenlei->SetText(CLewaimaiString::UTF8ToUnicode(select_foodtype_name).c_str());
|
|
|
+
|
|
|
+ //商品条码
|
|
|
+ CEditUI* pTiaoma = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_barcode_edit"));
|
|
|
+ pXuhao->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.barcode).c_str());
|
|
|
+
|
|
|
+ //商品价格
|
|
|
+ CEditUI* pPrice = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_price_edit"));
|
|
|
+ pPrice->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.price).c_str());
|
|
|
+
|
|
|
+ //商品单位
|
|
|
+ CEditUI* pDanwei = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_unit_edit"));
|
|
|
+ pDanwei->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.unit).c_str());
|
|
|
+
|
|
|
+ //是否称重
|
|
|
+ CCheckBoxUI* pChengzhong = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_chengzhong"));
|
|
|
+ if (m_foodinfo.is_weight == "1")
|
|
|
+ {
|
|
|
+ pChengzhong->Selected(true, false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pChengzhong->Selected(false, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ //plu编码
|
|
|
+ CEditUI* pPlu = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_plu"));
|
|
|
+ pPlu->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.weight_plu_code).c_str());
|
|
|
+
|
|
|
+ //商品编码
|
|
|
+ CEditUI* pShangpin = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_shangpinbianma"));
|
|
|
+ pShangpin->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.weight_food_code).c_str());
|
|
|
+
|
|
|
+ //库存类型
|
|
|
+ CCheckBoxUI* pKucuntypeOpen = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_kucun_open"));
|
|
|
+ CCheckBoxUI* pKucuntypeXiajia = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_status_xiajia"));
|
|
|
+ if (m_foodinfo.stockvalid == "1")
|
|
|
+ {
|
|
|
+ pKucuntypeOpen->Selected(true, false);
|
|
|
+ pKucuntypeXiajia->Selected(false, false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pKucuntypeOpen->Selected(false, false);
|
|
|
+ pKucuntypeXiajia->Selected(true, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ //当前库存
|
|
|
+ CEditUI* pDangqiankucun = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_kucun_now"));
|
|
|
+ pDangqiankucun->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.stock).c_str());
|
|
|
+
|
|
|
+ //商品状态
|
|
|
+ CCheckBoxUI* pStatusNormal = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_status_normal"));
|
|
|
+ CCheckBoxUI* pStatusXiajia = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_status_xiajia"));
|
|
|
+ if (m_foodinfo.status == "NORMAL")
|
|
|
+ {
|
|
|
+ pStatusNormal->Selected(true, false);
|
|
|
+ pStatusXiajia->Selected(false, false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pStatusNormal->Selected(false, false);
|
|
|
+ pStatusXiajia->Selected(true, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ //进货价
|
|
|
+ CEditUI* pJinhuojia = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_buyingprice_edit"));
|
|
|
+ pJinhuojia->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.buying_price).c_str());
|
|
|
+
|
|
|
+ //进货价模式
|
|
|
+ CCheckBoxUI* pJinhuomoshiNormal = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_jinhuojia_normal"));
|
|
|
+ CCheckBoxUI* pJinhuomoshiJiaquan = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_jinhuojia_jiaquan"));
|
|
|
+
|
|
|
+ //在哪些地方显示
|
|
|
+ CCheckBoxUI* pShouyinji = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_shouyinji"));
|
|
|
+ CCheckBoxUI* pWaimai = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_waimai"));
|
|
|
+ CCheckBoxUI* pSaomaidancan = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_saomadiancan"));
|
|
|
+
|
|
|
+ pShouyinji->Selected(true, false);
|
|
|
+ pWaimai->Selected(true, false);
|
|
|
+ pSaomaidancan->Selected(true, false);
|
|
|
+
|
|
|
+ //是否开启打包费
|
|
|
+ CCheckBoxUI* pDabao = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_is_dabao"));
|
|
|
+ if (m_foodinfo.is_dabao == "1")
|
|
|
+ {
|
|
|
+ pDabao->Selected(true, false);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ pDabao->Selected(false, false);
|
|
|
+ }
|
|
|
+
|
|
|
+ //打包费
|
|
|
+ CEditUI* pDaobaofei = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_dabao_money"));
|
|
|
+ pDaobaofei->SetText(CLewaimaiString::UTF8ToUnicode(m_foodinfo.dabao_money).c_str());
|
|
|
+
|
|
|
+ //商品加工方式
|
|
|
+ CCheckBoxUI* pJiagongfangshi = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_fangan_1"));
|
|
|
+ pJiagongfangshi->Selected(true, false);
|
|
|
+}
|
|
|
+
|
|
|
+//处理按钮点击类事件
|
|
|
+void CShangpinUpdatePageUI::HandleClickMsg(TNotifyUI& msg)
|
|
|
+{
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
+
|
|
|
+ if (name == L"shangpin_create_page_save_btn")
|
|
|
+ {
|
|
|
+ StartSave();
|
|
|
+ }
|
|
|
+ else if (name == L"shangpin_create_page_return_btn")
|
|
|
+ {
|
|
|
+ m_pMainWnd->SwitchPage(CMainWnd::SHANGPIN, false);
|
|
|
+ }
|
|
|
+ else if (name == L"shangpin_create_page_delete_btn")
|
|
|
+ {
|
|
|
+ StartDelete();
|
|
|
+ }
|
|
|
+ else if (name == L"shangpin_create_page_print_btn")
|
|
|
+ {
|
|
|
+ PrintShangpinTiaoma();
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//处理option切换事件
|
|
|
+void CShangpinUpdatePageUI::HandleSelectChangeMsg(TNotifyUI& msg)
|
|
|
+{
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
+
|
|
|
+ COptionUI* curOption = static_cast<COptionUI*>(msg.pSender);
|
|
|
+ std::wstring groupname = curOption->GetGroup();
|
|
|
+
|
|
|
+ if (groupname == L"shangpin_foodtype")
|
|
|
+ {
|
|
|
+
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//处理下拉框、radio的切换事件
|
|
|
+void CShangpinUpdatePageUI::HandleItemSelectMsg(TNotifyUI& msg)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+//处理编辑框输入内容改变事件
|
|
|
+void CShangpinUpdatePageUI::HandleTextChangedMsg(TNotifyUI& msg)
|
|
|
+{
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
+
|
|
|
+ if (name == L"shangpin_create_page_xuhao_edit")
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("shangpin_create_page_xuhao_edit")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if ((tmp > 57 || tmp < 48))
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (name == L"shangpin_create_page_barcode_edit")
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("shangpin_create_page_barcode_edit")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if ((tmp > 57 || tmp < 48))
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (name == L"shangpin_create_page_price_edit")
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("shangpin_create_page_price_edit")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if ((tmp > 57 || tmp < 48) && tmp != 46)
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (name == L"shangpin_create_page_buyingprice_edit")
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("shangpin_create_page_buyingprice_edit")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if ((tmp > 57 || tmp < 48) && tmp != 46)
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (name == L"shangpin_create_page_plu")
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("shangpin_create_page_plu")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if ((tmp > 57 || tmp < 48))
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (name == L"shangpin_create_page_shangpinbianma")
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("shangpin_create_page_shangpinbianma")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if ((tmp > 57 || tmp < 48))
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (name == L"shangpin_create_page_dabao_money")
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("shangpin_create_page_dabao_money")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if ((tmp > 57 || tmp < 48) && tmp != 46)
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (name == L"shangpin_create_page_kucun_now")
|
|
|
+ {
|
|
|
+ //只能输入数字,其他的全部删除
|
|
|
+ CEditUI* m_pEdit = static_cast<CEditUI*>(m_pManager->FindControl(_T("shangpin_create_page_kucun_now")));
|
|
|
+ if (!m_pEdit->GetText().IsEmpty())
|
|
|
+ {
|
|
|
+ wstring ws_Value = m_pEdit->GetText();
|
|
|
+ string strValue = CLewaimaiString::UnicodeToUTF8(ws_Value);
|
|
|
+
|
|
|
+ for (size_t nIndex = 0; nIndex < strValue.length(); nIndex++)
|
|
|
+ {
|
|
|
+ unsigned char tmp = strValue.at(nIndex);
|
|
|
+ if ((tmp > 57 || tmp < 48))
|
|
|
+ {
|
|
|
+ //ASCII码不是数字的都过滤掉
|
|
|
+ strValue = strValue.substr(0, nIndex);
|
|
|
+
|
|
|
+ m_pEdit->SetText(CLewaimaiString::UTF8ToUnicode(strValue).c_str());
|
|
|
+ m_pEdit->SetSel(strValue.length(), strValue.length());//重设给光标设置位置
|
|
|
+
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+//处理扫码枪捕捉到的扫码信息
|
|
|
+void CShangpinUpdatePageUI::HandleTextCapture(std::string content)
|
|
|
+{
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+void CShangpinUpdatePageUI::SetPos(RECT rc, bool bNeedInvalidate)
|
|
|
+{
|
|
|
+ m_nPageWidth = rc.right - rc.left;
|
|
|
+
|
|
|
+ CContainerUI::SetPos(rc, bNeedInvalidate);
|
|
|
+}
|
|
|
+
|
|
|
+void CShangpinUpdatePageUI::StartSave()
|
|
|
+{
|
|
|
+ //把参数一个个读出来
|
|
|
+
|
|
|
+ //商品名字
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_name_edit"));
|
|
|
+ std::wstring ws_name = pName->GetText();
|
|
|
+ m_name = CLewaimaiString::UnicodeToUTF8(ws_name);
|
|
|
+
|
|
|
+ //商品序号
|
|
|
+ CEditUI* pXuhao = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_xuhao_edit"));
|
|
|
+ std::wstring ws_xuhao = pXuhao->GetText();
|
|
|
+ m_xuhao = CLewaimaiString::UnicodeToUTF8(ws_xuhao);
|
|
|
+
|
|
|
+ //初始化商品分类
|
|
|
+ CComboUI* com_fenlei = static_cast<CComboUI*>(this->FindSubControl(_T("shangpin_create_page_foodtype")));
|
|
|
+ std::wstring ws_type = com_fenlei->GetText();
|
|
|
+ m_fenlei = CLewaimaiString::UnicodeToUTF8(ws_type);
|
|
|
+
|
|
|
+ //商品条码
|
|
|
+ CEditUI* pTiaoma = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_barcode_edit"));
|
|
|
+ std::wstring ws_tiaoma = pTiaoma->GetText();
|
|
|
+ m_tiaoma = CLewaimaiString::UnicodeToUTF8(ws_tiaoma);
|
|
|
+
|
|
|
+ //商品价格
|
|
|
+ CEditUI* pPrice = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_price_edit"));
|
|
|
+ std::wstring ws_price = pPrice->GetText();
|
|
|
+ m_price = CLewaimaiString::UnicodeToUTF8(ws_price);
|
|
|
+
|
|
|
+ //商品单位
|
|
|
+ CEditUI* pDanwei = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_unit_edit"));
|
|
|
+ std::wstring ws_danwei = pDanwei->GetText();
|
|
|
+ m_danwei = CLewaimaiString::UnicodeToUTF8(ws_danwei);
|
|
|
+
|
|
|
+ //是否称重
|
|
|
+ CCheckBoxUI* pChengzhong = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_chengzhong"));
|
|
|
+ m_is_chengzhong = pChengzhong->IsSelected();
|
|
|
+
|
|
|
+ //plu编码
|
|
|
+ CEditUI* pPlu = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_plu"));
|
|
|
+ std::wstring ws_plu = pPlu->GetText();
|
|
|
+ m_plu = CLewaimaiString::UnicodeToUTF8(ws_plu);
|
|
|
+
|
|
|
+ //商品编码
|
|
|
+ CEditUI* pShangpin = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_shangpinbianma"));
|
|
|
+ std::wstring ws_shangpin = pShangpin->GetText();
|
|
|
+ m_shangpinbianma = CLewaimaiString::UnicodeToUTF8(ws_shangpin);
|
|
|
+
|
|
|
+ //库存类型
|
|
|
+ CCheckBoxUI* pKucuntype = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_kucun_open"));
|
|
|
+ if (pKucuntype->IsSelected())
|
|
|
+ {
|
|
|
+ m_kucuntype = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_kucuntype = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //当前库存
|
|
|
+ CEditUI* pDangqiankucun = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_kucun_now"));
|
|
|
+ std::wstring ws_dangqiankucun = pDangqiankucun->GetText();
|
|
|
+ m_dangqiankucun = CLewaimaiString::UnicodeToUTF8(ws_dangqiankucun);
|
|
|
+
|
|
|
+ //商品状态
|
|
|
+ CCheckBoxUI* pStatus = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_status_normal"));
|
|
|
+ if (pStatus->IsSelected())
|
|
|
+ {
|
|
|
+ m_status = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_status = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //进货价
|
|
|
+ CEditUI* pJinhuojia = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_buyingprice_edit"));
|
|
|
+ std::wstring ws_jinhuojia = pJinhuojia->GetText();
|
|
|
+ m_jinhuojia = CLewaimaiString::UnicodeToUTF8(ws_jinhuojia);
|
|
|
+
|
|
|
+ //进货价模式
|
|
|
+ CCheckBoxUI* pJinhuomoshi = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_jinhuojia_normal"));
|
|
|
+ if (pJinhuomoshi->IsSelected())
|
|
|
+ {
|
|
|
+ m_jinhuo_type = 0;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ m_jinhuo_type = 1;
|
|
|
+ }
|
|
|
+
|
|
|
+ //在哪些地方显示
|
|
|
+ CCheckBoxUI* pShouyinji = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_shouyinji"));
|
|
|
+ CCheckBoxUI* pWaimai = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_waimai"));
|
|
|
+ CCheckBoxUI* pSaomaidancan = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_showplace_saomadiancan"));
|
|
|
+
|
|
|
+ m_is_shouyinji_show = pShouyinji->IsSelected();
|
|
|
+ m_is_waimai_show = pWaimai->IsSelected();
|
|
|
+ m_is_saomadiancan_show = pSaomaidancan->IsSelected();
|
|
|
+
|
|
|
+ //是否开启打包费
|
|
|
+ CCheckBoxUI* pDabao = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_is_dabao"));
|
|
|
+ m_is_dabao_fei = pDabao->IsSelected();
|
|
|
+
|
|
|
+ //打包费
|
|
|
+ CEditUI* pDaobaofei = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_dabao_money"));
|
|
|
+ std::wstring ws_dabaofei = pDaobaofei->GetText();
|
|
|
+ m_dabaofei = CLewaimaiString::UnicodeToUTF8(ws_dabaofei);
|
|
|
+
|
|
|
+ //商品加工方式
|
|
|
+ CCheckBoxUI* pJiagongfangshi_1 = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_fangan_1"));
|
|
|
+ CCheckBoxUI* pJiagongfangshi_2 = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_fangan_2"));
|
|
|
+ CCheckBoxUI* pJiagongfangshi_3 = static_cast<CCheckBoxUI*>(this->FindSubControl(L"shangpin_create_page_fangan_3"));
|
|
|
+
|
|
|
+ if (pJiagongfangshi_1->IsSelected())
|
|
|
+ {
|
|
|
+ m_jiagong_type = 0;
|
|
|
+ }
|
|
|
+ else if (pJiagongfangshi_2->IsSelected())
|
|
|
+ {
|
|
|
+ m_jiagong_type = 1;
|
|
|
+ }
|
|
|
+ else if (pJiagongfangshi_3->IsSelected())
|
|
|
+ {
|
|
|
+ m_jiagong_type = 2;
|
|
|
+ }
|
|
|
+
|
|
|
+ ShowError(L"正在保存商品...");
|
|
|
+
|
|
|
+ std::thread(&CShangpinUpdatePageUI::HandleSave, this).detach();
|
|
|
+}
|
|
|
+
|
|
|
+void CShangpinUpdatePageUI::HandleSave()
|
|
|
+{
|
|
|
+ std::map<string, string> params;
|
|
|
+
|
|
|
+ params["goods_name"] = m_name;
|
|
|
+ params["goods_tag"] = m_xuhao;
|
|
|
+ params["type_lv1_id"] = m_foodtype_id_map[m_fenlei];
|
|
|
+ params["barcode"] = m_tiaoma;
|
|
|
+ params["goods_price"] = m_price;
|
|
|
+ params["unit"] = m_danwei;
|
|
|
+
|
|
|
+ if (m_is_chengzhong)
|
|
|
+ {
|
|
|
+ params["is_weight"] = "1";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["is_weight"] = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ params["weight_plu_code"] = m_plu;
|
|
|
+ params["weight_food_code"] = m_shangpinbianma;
|
|
|
+
|
|
|
+ if (m_kucuntype == 0)
|
|
|
+ {
|
|
|
+ params["stock_status"] = "OPEN";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["stock_status"] = "CLOSED";
|
|
|
+ }
|
|
|
+
|
|
|
+ params["stock"] = m_dangqiankucun;
|
|
|
+
|
|
|
+ if (m_status == 0)
|
|
|
+ {
|
|
|
+ params["goods_status"] = "NORMAL";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["goods_status"] = "CLOSED";
|
|
|
+ }
|
|
|
+
|
|
|
+ params["buying_price"] = m_jinhuojia;
|
|
|
+
|
|
|
+ if (m_is_shouyinji_show)
|
|
|
+ {
|
|
|
+ params["is_shouyinji_show"] = "1";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["is_shouyinji_show"] = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_is_waimai_show)
|
|
|
+ {
|
|
|
+ params["is_waimai_show"] = "1";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["is_waimai_show"] = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_is_saomadiancan_show)
|
|
|
+ {
|
|
|
+ params["is_tangshi_show"] = "1";
|
|
|
+ params["is_zhengcan_show"] = "1";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["is_tangshi_show"] = "0";
|
|
|
+ params["is_zhengcan_show"] = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ if (m_is_dabao_fei)
|
|
|
+ {
|
|
|
+ params["is_dabao"] = "1";
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ params["is_dabao"] = "0";
|
|
|
+ }
|
|
|
+
|
|
|
+ params["dabao_money"] = m_dabaofei;
|
|
|
+
|
|
|
+ params["jiagong_type"] = m_jiagong_type;
|
|
|
+
|
|
|
+ //这下面是接口要求必传参数
|
|
|
+ params["goods_img"] = "";
|
|
|
+ params["open_autostock"] = "0";
|
|
|
+ params["stock_warning"] = "0";
|
|
|
+
|
|
|
+ std::string response;
|
|
|
+
|
|
|
+ std::string url = "/goods/updategoods";
|
|
|
+ bool ret = CZhipuziHttpClient::GetInstance()->Request(url.c_str(), params, response);
|
|
|
+
|
|
|
+ if (ret == false)
|
|
|
+ {
|
|
|
+ ShowError(L"请求服务器失败,请检查网络设置!");
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(response.c_str());
|
|
|
+
|
|
|
+ if (document.HasParseError())
|
|
|
+ {
|
|
|
+ ShowError(L"服务器错误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
|
|
|
+ {
|
|
|
+ ShowError(L"服务器错误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& v_errcode = document["errcode"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
+ if (errcode != 0)
|
|
|
+ {
|
|
|
+ std::string v_errmsg = document["errmsg"].GetString();
|
|
|
+
|
|
|
+ ShowError(CLewaimaiString::UTF8ToUnicode(v_errmsg));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& data = document["data"];
|
|
|
+
|
|
|
+ std::string id = data["goods_id"].GetString();
|
|
|
+
|
|
|
+ //走到这里说明商品保存成功了,接着把商品的数据更新到数据库
|
|
|
+ CFoodHandle::GetInstance()->UpdateOneFood(id);
|
|
|
+
|
|
|
+ //然后返回到商品页面
|
|
|
+ m_pMainWnd->SwitchPage(CMainWnd::SHANGPIN);
|
|
|
+}
|
|
|
+
|
|
|
+void CShangpinUpdatePageUI::StartDelete()
|
|
|
+{
|
|
|
+ std::thread(&CShangpinUpdatePageUI::HandleDelete, this).detach();
|
|
|
+}
|
|
|
+
|
|
|
+void CShangpinUpdatePageUI::HandleDelete()
|
|
|
+{
|
|
|
+ std::map<string, string> params;
|
|
|
+ params["goods_id"] = m_foodinfo.id;
|
|
|
+
|
|
|
+ std::string response;
|
|
|
+
|
|
|
+ std::string url = "/goods/deletegoods";
|
|
|
+ bool ret = CZhipuziHttpClient::GetInstance()->Request(url.c_str(), params, response);
|
|
|
+
|
|
|
+ if (ret == false)
|
|
|
+ {
|
|
|
+ ShowError(L"请求服务器失败,请检查网络设置!");
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Document document;
|
|
|
+ document.Parse(response.c_str());
|
|
|
+
|
|
|
+ if (document.HasParseError())
|
|
|
+ {
|
|
|
+ ShowError(L"服务器错误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!document.HasMember("errcode") || !document.HasMember("errmsg"))
|
|
|
+ {
|
|
|
+ ShowError(L"服务器错误");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ rapidjson::Value& v_errcode = document["errcode"];
|
|
|
+ int errcode = v_errcode.GetInt();
|
|
|
+ if (errcode != 0)
|
|
|
+ {
|
|
|
+ std::string v_errmsg = document["errmsg"].GetString();
|
|
|
+
|
|
|
+ ShowError(CLewaimaiString::UTF8ToUnicode(v_errmsg));
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ //本地数据库删除这个商品
|
|
|
+ CFoodHandle::GetInstance()->DeleteOndeFood(m_foodinfo.id);
|
|
|
+
|
|
|
+ //然后返回到商品页面
|
|
|
+ m_pMainWnd->SwitchPage(CMainWnd::SHANGPIN);
|
|
|
+}
|
|
|
+
|
|
|
+void CShangpinUpdatePageUI::ShowError(std::wstring msg)
|
|
|
+{
|
|
|
+ CLabelUI* pResult = static_cast<CLabelUI*>(this->FindSubControl(L"shangpin_create_page_save_result"));
|
|
|
+ pResult->SetText(msg.c_str());
|
|
|
+}
|
|
|
+
|
|
|
+void CShangpinUpdatePageUI::PrintShangpinTiaoma()
|
|
|
+{
|
|
|
+ CPosPrinter printer;
|
|
|
+ printer.PrintShangpinTiaoma(m_foodinfo);
|
|
|
+}
|