Check.cpp
上传用户:hnzycx
上传日期:2022-08-09
资源大小:12567k
文件大小:2k
开发平台:

Visual C++

  1. // Check.cpp : implementation file
  2. //
  3. #include "stdafx.h"
  4. #include "MobileClient.h"
  5. #include "Check.h"
  6. #include "DataParsing.h"
  7. // CCheck dialog
  8. IMPLEMENT_DYNAMIC(CCheck, CDialog)
  9. CCheck::CCheck(CWnd* pParent /*=NULL*/)
  10. : CDialog(CCheck::IDD, pParent)
  11. {
  12. CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
  13. App->m_tcp.OnRead = OnReadCheck;
  14. }
  15. CCheck::~CCheck()
  16. {
  17. }
  18. void CCheck::DoDataExchange(CDataExchange* pDX)
  19. {
  20. CDialog::DoDataExchange(pDX);
  21. DDX_Control(pDX, IDC_COMBO1, m_table);
  22. DDX_Control(pDX, IDC_EDIT2, m_checkList);
  23. }
  24. BEGIN_MESSAGE_MAP(CCheck, CDialog)
  25. ON_BN_CLICKED(IDOK, &CCheck::OnBnClickedOk)
  26. ON_BN_CLICKED(IDC_BUTTON3, &CCheck::OnBnClickedButton3)
  27. END_MESSAGE_MAP()
  28. // CCheck message handlers
  29. void CALLBACK CCheck::OnReadCheck(CWnd* pWnd,const char *buf,int len)
  30. {
  31. CString strRecv(buf);
  32.     CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
  33. App->context = strRecv;
  34. }
  35. BOOL CCheck::OnInitDialog()
  36. {
  37. CDialog::OnInitDialog();
  38. CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
  39. m_table.AddString(_T("1"));
  40. m_table.AddString(_T("2"));
  41. m_table.AddString(_T("3"));
  42. m_table.AddString(_T("4"));
  43. m_table.AddString(_T("5"));
  44. m_table.AddString(_T("6"));
  45. m_table.AddString(_T("包厢一"));
  46. m_table.AddString(_T("包厢二"));
  47. m_table.AddString(_T("包厢三"));
  48. m_table.AddString(_T("包厢四"));
  49. return TRUE;
  50. }
  51. void CCheck::OnBnClickedOk()
  52. {
  53. CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
  54. CString table;
  55. m_table.GetWindowTextW(table);
  56. CString sendCheck;
  57. sendCheck = _T("C@")+table+_T("@END");
  58. char * sendBuf;
  59. int sendLen = 0;
  60. sendLen = sendCheck.GetLength();
  61. sendBuf = new char[sendLen*2];
  62. WideCharToMultiByte(CP_OEMCP,NULL,sendCheck,-1,sendBuf,sendLen*2,NULL,FALSE);
  63. if (!App->m_tcp.SendData(sendBuf,sendLen*2))
  64. {
  65. AfxMessageBox(_T("发送查询结账失败"));
  66. }
  67. delete []sendBuf;
  68. sendBuf = NULL;
  69. CStringList returnValue;
  70. CDataParsing *dp = new CDataParsing(App->context);
  71. dp->ProcessDataForDB(returnValue); 
  72. POSITION pos = returnValue.GetHeadPosition();
  73. Sleep(5000);
  74. CString tail;
  75. tail = returnValue.GetTail();
  76. if(tail==_T("END"))
  77. {
  78. CString arg1;
  79. arg1 = returnValue.GetNext(pos);
  80. arg1 = returnValue.GetNext(pos);
  81. m_checkList.SetWindowTextW(arg1);
  82. }
  83. }
  84. void CCheck::OnBnClickedButton3()
  85. {
  86. // TODO: 在此添加控件通知处理程序代码
  87. OnCancel();
  88. }