Check.cpp
上传用户:hnzycx
上传日期:2022-08-09
资源大小:12567k
文件大小:2k
- // Check.cpp : implementation file
- //
- #include "stdafx.h"
- #include "MobileClient.h"
- #include "Check.h"
- #include "DataParsing.h"
- // CCheck dialog
- IMPLEMENT_DYNAMIC(CCheck, CDialog)
- CCheck::CCheck(CWnd* pParent /*=NULL*/)
- : CDialog(CCheck::IDD, pParent)
- {
- CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
- App->m_tcp.OnRead = OnReadCheck;
- }
- CCheck::~CCheck()
- {
- }
- void CCheck::DoDataExchange(CDataExchange* pDX)
- {
- CDialog::DoDataExchange(pDX);
- DDX_Control(pDX, IDC_COMBO1, m_table);
- DDX_Control(pDX, IDC_EDIT2, m_checkList);
- }
- BEGIN_MESSAGE_MAP(CCheck, CDialog)
- ON_BN_CLICKED(IDOK, &CCheck::OnBnClickedOk)
- ON_BN_CLICKED(IDC_BUTTON3, &CCheck::OnBnClickedButton3)
- END_MESSAGE_MAP()
- // CCheck message handlers
- void CALLBACK CCheck::OnReadCheck(CWnd* pWnd,const char *buf,int len)
- {
- CString strRecv(buf);
- CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
- App->context = strRecv;
- }
- BOOL CCheck::OnInitDialog()
- {
- CDialog::OnInitDialog();
- CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
- m_table.AddString(_T("1"));
- m_table.AddString(_T("2"));
- m_table.AddString(_T("3"));
- m_table.AddString(_T("4"));
- m_table.AddString(_T("5"));
- m_table.AddString(_T("6"));
- m_table.AddString(_T("包厢一"));
- m_table.AddString(_T("包厢二"));
- m_table.AddString(_T("包厢三"));
- m_table.AddString(_T("包厢四"));
- return TRUE;
- }
- void CCheck::OnBnClickedOk()
- {
- CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
- CString table;
- m_table.GetWindowTextW(table);
- CString sendCheck;
- sendCheck = _T("C@")+table+_T("@END");
- char * sendBuf;
- int sendLen = 0;
- sendLen = sendCheck.GetLength();
- sendBuf = new char[sendLen*2];
- WideCharToMultiByte(CP_OEMCP,NULL,sendCheck,-1,sendBuf,sendLen*2,NULL,FALSE);
- if (!App->m_tcp.SendData(sendBuf,sendLen*2))
- {
- AfxMessageBox(_T("发送查询结账失败"));
- }
- delete []sendBuf;
- sendBuf = NULL;
-
-
- CStringList returnValue;
- CDataParsing *dp = new CDataParsing(App->context);
- dp->ProcessDataForDB(returnValue);
- POSITION pos = returnValue.GetHeadPosition();
- Sleep(5000);
- CString tail;
- tail = returnValue.GetTail();
- if(tail==_T("END"))
- {
- CString arg1;
- arg1 = returnValue.GetNext(pos);
- arg1 = returnValue.GetNext(pos);
- m_checkList.SetWindowTextW(arg1);
- }
- }
- void CCheck::OnBnClickedButton3()
- {
- // TODO: 在此添加控件通知处理程序代码
- OnCancel();
- }