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

Visual C++

  1. // MobileClientDlg.cpp : 实现文件
  2. #include "stdafx.h"
  3. #include "MobileClient.h"
  4. #include "MobileClientDlg.h"
  5. #include "OrderCourse.h"
  6. #include "Special.h"
  7. #include "DataParsing.h"
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #endif
  11. // CMobileClientDlg 对话框
  12. CMobileClientDlg::CMobileClientDlg(CWnd* pParent /*=NULL*/)
  13. : CDialog(CMobileClientDlg::IDD, pParent)
  14. {
  15. m_hIcon = AfxGetApp()->LoadIcon(IDR_MAINFRAME);
  16. }
  17. void CMobileClientDlg::DoDataExchange(CDataExchange* pDX)
  18. {
  19. CDialog::DoDataExchange(pDX);
  20. }
  21. BEGIN_MESSAGE_MAP(CMobileClientDlg, CDialog)
  22. #if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
  23. ON_WM_SIZE()
  24. #endif
  25. //}}AFX_MSG_MAP
  26. ON_BN_CLICKED(IDC_BTN_ORDER, &CMobileClientDlg::OnBnClickedBtnOrder)
  27. ON_BN_CLICKED(IDC_BTN_SPLINFO, &CMobileClientDlg::OnBnClickedBtnSplinfo)
  28. ON_BN_CLICKED(IDCANCEL, &CMobileClientDlg::OnBnClickedCancel)
  29. END_MESSAGE_MAP()
  30. // CMobileClientDlg 消息处理程序
  31. BOOL CMobileClientDlg::OnInitDialog()
  32. {
  33. CDialog::OnInitDialog();
  34. SetIcon(m_hIcon, TRUE); // 设置大图标
  35. SetIcon(m_hIcon, FALSE); // 设置小图标
  36. return TRUE;  // 除非将焦点设置到控件,否则返回 TRUE
  37. }
  38. #if defined(_DEVICE_RESOLUTION_AWARE) && !defined(WIN32_PLATFORM_WFSP)
  39. void CMobileClientDlg::OnSize(UINT /*nType*/, int /*cx*/, int /*cy*/)
  40. {
  41. if (AfxIsDRAEnabled())
  42. {
  43. DRA::RelayoutDialog(
  44. AfxGetResourceHandle(), 
  45. this->m_hWnd, 
  46. DRA::GetDisplayMode() != DRA::Portrait ? 
  47. MAKEINTRESOURCE(IDD_MOBILECLIENT_DIALOG_WIDE) : 
  48. MAKEINTRESOURCE(IDD_MOBILECLIENT_DIALOG));
  49. }
  50. }
  51. #endif
  52. //进入点餐界面
  53. void CMobileClientDlg::OnBnClickedBtnOrder()
  54. {
  55. CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
  56. CString reqOrderList;
  57. reqOrderList = _T("O@END");//向服务器请求菜单信息
  58. char * sendBuf;
  59. int sendLen=0;
  60. sendLen=reqOrderList.GetLength();
  61. sendBuf=new char[sendLen*2];
  62. WideCharToMultiByte(CP_OEMCP,NULL,reqOrderList,-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. COrderCourse dlg;
  70. dlg.DoModal();
  71. }
  72. //进入优惠/特价菜界面
  73. void CMobileClientDlg::OnBnClickedBtnSplinfo()
  74. {
  75. CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
  76. CString reqSplinfo;
  77. reqSplinfo = _T("S@END");//向服务器请求优惠/特价菜信息
  78. char * sendBuf;
  79. int sendLen=0;
  80. sendLen=reqSplinfo.GetLength();
  81. sendBuf=new char[sendLen*2];
  82. WideCharToMultiByte(CP_OEMCP,NULL,reqSplinfo,-1,sendBuf,sendLen*2,NULL,FALSE);
  83. if (!App->m_tcp.SendData(sendBuf,sendLen*2))
  84. {
  85. AfxMessageBox(_T("请求菜单失败"));
  86. }
  87. delete []sendBuf;
  88. sendBuf=NULL;
  89. CSpecial dlg;
  90. dlg.DoModal();
  91. }
  92. //返回主界面
  93. void CMobileClientDlg::OnBnClickedCancel()
  94. {
  95. CMobileClientApp* App=(CMobileClientApp*)AfxGetApp();
  96. if(App->m_tcp.Close())
  97. {
  98.   
  99. }
  100. else
  101. {
  102. AfxMessageBox(_T("连接断开"));
  103. }
  104. OnCancel();
  105. }