pay_dlg.cpp
4.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
// D:\GitProject\etradeclient\central_clearing_system\ETradeClient\mfc_ui\pay_dlg.cpp : 实现文件
//
#include "stdafx.h"
#include "ETradeClient.h"
#include "D:\GitProject\etradeclient\central_clearing_system\ETradeClient\mfc_ui\pay_dlg.h"
#include "afxdialogex.h"
#include "etradeclient/hardware/hardware_cmd.h"
#include "etradeclient/boost_patch/property_tree/json_parser.hpp"
// PayDlg 对话框
IMPLEMENT_DYNAMIC(PayDlg, CDialogEx)
PayDlg::PayDlg(CWnd* pParent /*=NULL*/)
: CDialogEx(PayDlg::IDD, pParent)
{
}
PayDlg::~PayDlg()
{
}
void PayDlg::DoDataExchange(CDataExchange* pDX)
{
CDialogEx::DoDataExchange(pDX);
DDX_Control(pDX, IDC_PAY_STATIC_TOTAL_MONEY, total_money_static_);
DDX_Control(pDX, IDC_PAY_STATIC_REAL_MONEY, real_money_static_);
DDX_Control(pDX, IDC_PAY_STATIC_PASSWORD, password_static_);
DDX_Control(pDX, IDC_PAY_EDIT_PASSWORD, password_edit_);
DDX_Control(pDX, IDC_PAY_BUTTON_PAY, pay_button_);
DDX_Control(pDX, IDC_PAY_BUTTON_CLOSE, close_button_);
DDX_Control(pDX, IDC_PAY_BUTTON_PASSWORD, password_button_);
}
BEGIN_MESSAGE_MAP(PayDlg, CDialogEx)
ON_BN_CLICKED(IDC_PAY_BUTTON_CLOSE, &PayDlg::OnBnClickedPayButtonClose)
ON_BN_CLICKED(IDC_PAY_BUTTON_PAY, &PayDlg::OnBnClickedPayButtonPay)
END_MESSAGE_MAP()
// PayDlg 消息处理程序
BOOL PayDlg::OnInitDialog()
{
CDialogEx::OnInitDialog();
SetCtrlPos();
return TRUE; // return TRUE unless you set the focus to a control
// 异常: OCX 属性页应返回 FALSE
}
void PayDlg::SetCtrlPos()
{
const int StaticWidth = 80, StaticHeigth = 35;
const int EditWidth = 140, EditHeigth = 35;
const int EditWidthShort = 70, StaticWidthShort = 70;
const int ButtonWidth = 120, ButtonHeight = 40;
CRect ctrl_rect;
ctrl_rect.top = 30 + 10;
ctrl_rect.bottom = ctrl_rect.top + StaticHeigth;
ctrl_rect.left = 30;
ctrl_rect.right = ctrl_rect.left + StaticWidth;
total_money_static_.MoveWindow(&ctrl_rect);
ctrl_rect.left = ctrl_rect.right;
ctrl_rect.right += StaticWidth;
real_money_static_.MoveWindow(&ctrl_rect);
ctrl_rect.top = ctrl_rect.bottom + 30;
ctrl_rect.bottom = ctrl_rect.top + StaticHeigth;
ctrl_rect.left = 30;
ctrl_rect.right = ctrl_rect.left + StaticWidth;
password_static_.MoveWindow(ctrl_rect);
ctrl_rect.left = ctrl_rect.right;
ctrl_rect.right += EditWidth;
password_edit_.MoveWindow(&ctrl_rect);
ctrl_rect.left = ctrl_rect.right + 10;
ctrl_rect.right += ButtonWidth;
password_button_.MoveWindow(&ctrl_rect);
CRect dlg_rect;
GetClientRect(&dlg_rect);
ctrl_rect.bottom = dlg_rect.bottom;
ctrl_rect.top = ctrl_rect.bottom - ButtonHeight;
ctrl_rect.right = dlg_rect.right - 100;
ctrl_rect.left = ctrl_rect.right - ButtonWidth;
close_button_.MoveWindow(&ctrl_rect);
ctrl_rect.right = ctrl_rect.left - 100;
ctrl_rect.left = ctrl_rect.right - ButtonWidth;
pay_button_.MoveWindow(ctrl_rect);
CRect rect;
password_edit_.GetClientRect(&rect);
OffsetRect(&rect, 0, 10);
password_edit_.SendMessage(EM_SETRECT, 0, (LPARAM)&rect);
password_edit_.EnableWindow(FALSE);
}
void PayDlg::OnBnClickedPayButtonClose()
{
CDialogEx::OnCancel();
}
void PayDlg::OnBnClickedPayButtonPay()
{
auto printer_device = StylusPrinterCmd();
HardwareCmd::Reply reply = printer_device.Execute("{\"title\":\"长春结地利算单\",\"orders\":[{\"statementId\":\"123456\",\"tradeTime\":\"2018/10/10\",\"buyerName\":\"大熊\",\"sellerName\":\"卖家大熊\",\"userName\":\"结算员大熊\",\"totalMoney\":\"11001.91\",\"products\":[{\"orderId\":1000,\"productName\":\"商品名称大熊\",\"price\":\"55.5\",\"amount\":\"500\",\"money\":\"1021.01\"},{\"orderId\":1000,\"productName\":\"商品名称大熊\",\"price\":\"2753\",\"amount\":\"752\",\"money\":\"1021.01\"},{\"orderId\":1000,\"productName\":\"商品名称大熊\",\"price\":\"2753\",\"amount\":\"752\",\"money\":\"1021.01\"},{\"orderId\":1000,\"productName\":\"商品名称大熊\",\"price\":\"2753\",\"amount\":\"752\",\"money\":\"1021.01\"},{\"orderId\":1000,\"productName\":\"商品名称大熊\",\"price\":\"2753\",\"amount\":\"752\",\"money\":\"1021.01\"},{\"orderId\":1000,\"productName\":\"商品名称大熊\",\"price\":\"2753\",\"amount\":\"752\",\"money\":\"1021.01\"},{\"orderId\":1000,\"productName\":\"商品名称大熊\",\"price\":\"2753\",\"amount\":\"752\",\"money\":\"1021.01\"},{\"orderId\":1000,\"productName\":\"商品名称大熊\",\"price\":\"2753\",\"amount\":\"752\",\"money\":\"1021.01\"},{\"orderId\":1000,\"productName\":\"商品名称大熊\",\"price\":\"2753\",\"amount\":\"752\",\"money\":\"1021.01\"},{\"orderId\":1000,\"productName\":\"商品名称大熊\",\"price\":\"2753\",\"amount\":\"752\",\"money\":\"1021.01\"}]}]}");
}