|
@@ -0,0 +1,313 @@
|
|
|
|
|
+#include "../pch/pch.h"
|
|
|
|
|
+#include "CShangpinCreatePageUI.h"
|
|
|
|
|
+
|
|
|
|
|
+#include "../control/ControlEx.h"
|
|
|
|
|
+
|
|
|
|
|
+#include "../tool/CSqlite3.h"
|
|
|
|
|
+
|
|
|
|
|
+CShangpinCreatePageUI::CShangpinCreatePageUI()
|
|
|
|
|
+{
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+CShangpinCreatePageUI::~CShangpinCreatePageUI()
|
|
|
|
|
+{
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//初始化当前页面的展示,处理默认展示效果,在页面被加载的时候调用
|
|
|
|
|
+void CShangpinCreatePageUI::InitShow()
|
|
|
|
|
+{
|
|
|
|
|
+ //一个个初始化新建商品的默认值
|
|
|
|
|
+
|
|
|
|
|
+ //初始化商品分类
|
|
|
|
|
+ CComboUI* com_fenlei = static_cast<CComboUI*>(this->FindSubControl(_T("shangpin_create_page_foodtype")));
|
|
|
|
|
+ com_fenlei->RemoveAll();
|
|
|
|
|
+
|
|
|
|
|
+ CSqlite3 sqlite;
|
|
|
|
|
+ std::vector<CFoodType> foodtypes = sqlite.GetFoodtypes();
|
|
|
|
|
+
|
|
|
|
|
+ std::string first_food_name = "";
|
|
|
|
|
+ int nTypeNum = 0;
|
|
|
|
|
+ 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 == foodtypes.begin())
|
|
|
|
|
+ {
|
|
|
|
|
+ first_food_name = it->name;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ nTypeNum++;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ com_fenlei->SetInternVisible(true);
|
|
|
|
|
+
|
|
|
|
|
+ if (nTypeNum > 0)
|
|
|
|
|
+ {
|
|
|
|
|
+ com_fenlei->SelectItem(0, false, false);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ com_fenlei->SetText(CLewaimaiString::UTF8ToUnicode(first_food_name).c_str());
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//处理按钮点击类事件
|
|
|
|
|
+void CShangpinCreatePageUI::HandleClickMsg(TNotifyUI& msg)
|
|
|
|
|
+{
|
|
|
|
|
+ CDuiString name = msg.pSender->GetName();
|
|
|
|
|
+
|
|
|
|
|
+ if (name == L"shangpin_create_page_save_btn")
|
|
|
|
|
+ {
|
|
|
|
|
+ StartSave();
|
|
|
|
|
+ }
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//处理option切换事件
|
|
|
|
|
+void CShangpinCreatePageUI::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 CShangpinCreatePageUI::HandleItemSelectMsg(TNotifyUI& msg)
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+//处理编辑框输入内容改变事件
|
|
|
|
|
+void CShangpinCreatePageUI::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 CShangpinCreatePageUI::HandleTextCapture(std::string content)
|
|
|
|
|
+{
|
|
|
|
|
+
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CShangpinCreatePageUI::SetPos(RECT rc, bool bNeedInvalidate)
|
|
|
|
|
+{
|
|
|
|
|
+ m_nPageWidth = rc.right - rc.left;
|
|
|
|
|
+
|
|
|
|
|
+ CContainerUI::SetPos(rc, bNeedInvalidate);
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
|
|
+void CShangpinCreatePageUI::StartSave()
|
|
|
|
|
+{
|
|
|
|
|
+ //把参数一个个读出来
|
|
|
|
|
+ CEditUI* pName = static_cast<CEditUI*>(this->FindSubControl(L"shangpin_create_page_name_edit"));
|
|
|
|
|
+ std::wstring ws_name = pName->GetText();
|
|
|
|
|
+ std::string name = CLewaimaiString::UnicodeToUTF8(ws_name);
|
|
|
|
|
+}
|