void COrderManageDlg::InitOrder()
{
	//当前用户单子
	bool bHasOrder = false;
	COrder order;
	CString strCustomer = m_pCustomerCombo->GetText();
	if (!strCustomer.IsEmpty() && COrderManager::Instance()->GetOrder(strCustomer, order))
	{
		bHasOrder = true;
	}

	//添加号码	
	for (int i=1; i<=12; i++)	
	{
		for (int j=0; j<=4; j++)
		{
			int nCode = i+j*12;
			if (nCode > COrder::CODE_NUMBER)
			{
				continue;
			}

			DuiLib::CControlUI* pCodeMoney = FindCode(nCode);
			if (pCodeMoney == NULL)  //还没有添加一个
			{
				pCodeMoney = AddCode(nCode);
				if (pCodeMoney == NULL)
				{
					continue;
				}
			}

			if (bHasOrder && order.Money(nCode)>0)
			{
				pCodeMoney->SetText(CStringUtil::Int64ToStr(order.Money(nCode)));
			}
			else
			{
				pCodeMoney->SetText(_T(""));
			}			
		}
	}		

	//总共下注数 16=%s总共下注%I64d 
	CString strTotal;
	strTotal.Format(CLanguageManager::Instance()->LoadString(16), strCustomer, bHasOrder?order.GetTotalBuyMoney():0);
	m_pTotalInfoLabel->SetText(strTotal);

	//显示删除单子按钮 和 删除所有单子按钮
	m_pDeleteOrderBtn->SetVisible(bHasOrder);
	m_pDeleteAllOrderBtn->SetVisible(COrderManager::Instance()->IsHasOrder());	
}
void COrderManageDlg::OnNewCustomer(const CString& strCustomer)
{
	DuiLib::CDialogBuilder builder;
	DuiLib::CControlUI* pControl = builder.Create(_T("item_list_label_element.xml"));
	if (pControl == NULL)
	{
		return;
	}

	pControl->SetText(strCustomer);
	m_pCustomerCombo->Add(pControl);
	m_pCustomerCombo->SelectItem(m_pCustomerCombo->GetCount()-1);
	m_pNoCustomerContainer->SetVisible(false);	
}
void COrderManageDlg::AddGroup(DuiLib::CContainerUI* pContainer, int nGroupID)
{
	DuiLib::CDialogBuilder builder;
	DuiLib::CControlUI* pControl = builder.Create(_T("item_group.xml"), NULL, NULL, &m_pm);
	if (pControl == NULL)
	{
		return;
	}

	CCodeGroup group(nGroupID);
	pControl->SetText(group.Name());
	pControl->SetTag(nGroupID);  //group id保存在此
	pContainer->Add(pControl);	
}
DuiLib::CControlUI* COrderManageDlg::FindCode(int nCode)
{
	DuiLib::CControlUI* pParentControl[2] = {m_pCodeContainer, m_pLastCodeContainer};
	for (int j=0; j<2; j++)
	{
		DuiLib::CStdPtrArray* pControlArray = m_pm.FindSubControlsByClass(pParentControl[j], _T("EditUI"));
		for (int i=0; i<pControlArray->GetSize(); i++)
		{
			DuiLib::CControlUI* pControl = (DuiLib::CControlUI*)(pControlArray->GetAt(i));
			if (pControl->GetName() == _T("moneyEdit") && pControl->GetTag() == nCode)
			{
				return pControl;
			}
		}
	}

	return NULL;
}
void COrderManageDlg::InitCustomer()
{
	m_pCustomerCombo->RemoveAll();
	vector<CUSTOMER> customerVec = CCustomerManager::Instance()->GetCustomerList();
	for (vector<CUSTOMER>::const_iterator it=customerVec.begin(); it!=customerVec.end(); it++)
	{
		DuiLib::CDialogBuilder builder;
		DuiLib::CControlUI* pControl = builder.Create(_T("item_list_label_element.xml"));
		if (pControl == NULL)
		{
			continue;
		}

		pControl->SetText(it->strName);
		m_pCustomerCombo->Add(pControl);
	}

	m_pCustomerCombo->SelectItem(0);
	m_pNoCustomerContainer->SetVisible(customerVec.size()<=0);
}
Example #6
0
LRESULT	CMainFrame::OnTimer(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	bHandled = TRUE;
	UINT	nIDEvent = (UINT)wParam;
	switch(nIDEvent)
	{
	case 1:
	case 2:
	default:break;
	}

	if (g_nCount > 5) g_nCount = 0;
	CString strResourcePath=m_PaintManager.GetInstancePath();
	strResourcePath+=GetSkinFolder().GetData();
	CString	sPic;
	sPic.Format(_T("%sSignalRect0%d.png"), strResourcePath, g_nCount);
	DuiLib::CControlUI* pctrl = static_cast<DuiLib::CControlUI*>(m_PaintManager.FindControl(_T("ctrl")));
	if (pctrl) pctrl->SetBkImage(sPic);
	g_nCount++;
	return 0;
}
Example #7
0
void RemoteKeyboard::OnClickSyncBtn(TNotifyUI & msg, bool & handled)
{
	auto const &items = g_LessionMappingTable;
	DuiLib::CControlUI *ctrl;

	if (msg.pSender->GetName() == _T("sync_ok")) {
		pugi::xml_document xmldoc;
		pugi::xml_node root = xmldoc.append_child(PUGIXML_TEXT("lesson"));

		for (int i = 0; i < _countof(items); ++i) {
			pugi::xml_attribute attr = root.append_attribute(items[i].attr);
			if (ctrl = m_PaintManager.FindControl(items[i].name))
				attr = ctrl->GetText();
		}
		std::wostringstream oss;
		root.print(oss, L"", pugi::format_raw);

		auto _ExecuteExtendCmdWrap = [this](const std::wstring &buf) -> boolean {
			boolean ret = false;
			RpcTryExcept
				ret = rkbc_ExecuteExtendCmd(m_hwBinding, kExtendType_LessionInfo, reinterpret_cast<const byte *>(buf.data()), (buf.size() + 1) * sizeof(wchar_t));
			RpcExcept(1)
				ret = false;
			RpcEndExcept

				return ret;
		};

		if (_ExecuteExtendCmdWrap(oss.str())) {
			m_lession_info = oss.str();

			boost::crc_32_type result;
			result.process_bytes(reinterpret_cast<const byte *>(m_lession_info.data()), (m_lession_info.size() + 1) * sizeof(wchar_t));
			m_lession_info_checksum = result.checksum();
		}
	}
Example #8
0
LRESULT RemoteKeyboard::OnUpdateStatus(UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL & bHandle)
{
	static bool _last_enabled = true;
	bool _enable = (wParam != 0);
	unsigned int _check_value = (unsigned int)(lParam);
	TCHAR name[32];

	if (_last_enabled != _enable) {
		_last_enabled = _enable;
		for (int i = 1;; ++i) {
			_stprintf_s(name, sizeof(name) / sizeof(TCHAR), _T("rkbc_%02d"), i);
			if (!EnableControl(name, _last_enabled))
				break;
		}
	}

	if (_last_enabled) {
		unsigned int _recode_status = _check_value & 0x3;
		unsigned int _ch_status = (_check_value >> 2) & 0xf;
		unsigned int _director_status = (_check_value >> 6) & 0x3;

		for (int i = 1; i < 14; ++i) {
			_stprintf_s(name, sizeof(name) / sizeof(TCHAR), _T("rkbc_%02d"), i);

			if (i < 4) {
				EnableControl(name, _recode_status != i);
			} else if (i < 12) {
				EnableControl(name, _ch_status != i - 3);
			} else {
				EnableControl(name, _director_status != i - 11);
			}
		}
	}

	auto _GetExtendInfoWrap = [this](byte* &pBuf, long &nSize) -> boolean {
		boolean ret = false;

		RpcTryExcept
			ret = rkbc_GetExtendInfo(m_hwBinding, kExtendType_LessionInfo, __int64(m_lession_info_checksum), &pBuf, &nSize);
		RpcExcept(1)
			ret = false;
		RpcEndExcept

			return ret;
	};

	/* 如果同步排课界面不处于显示状态,则不刷新 */
	if (!m_PaintManager.FindControl(_T("sync_panel"))->IsVisible())	 
		return 0;
	byte *pBuf = 0;
	long nSize = 0;
	if (_enable && _GetExtendInfoWrap(pBuf, nSize) && pBuf) {
		auto const &items = g_LessionMappingTable;

		pugi::xml_document doc;
		if (doc.load(LPCTSTR(pBuf))) {
			pugi::xml_node elem = doc.child(_T("lesson"));
			if (elem) {
				for (int i = 0; i < _countof(items); ++i) {
					DuiLib::CControlUI *ctrl;
					if (ctrl = m_PaintManager.FindControl(items[i].name))
						ctrl->SetText(elem.attribute(items[i].attr).as_string());
				}

				m_lession_info = LPCTSTR(pBuf);
				boost::crc_32_type result;
				result.process_bytes(reinterpret_cast<const byte *>(m_lession_info.data()), (m_lession_info.size() + 1) * sizeof(wchar_t));
				m_lession_info_checksum = result.checksum();
			}
		}
		midl_user_free(pBuf);
	}

	return LRESULT();
}