Commit c22bc376ab45cc70cea26ac96dd9e00f7800df5e

Authored by liuye
1 parent 7c3f2e17

feat<central_clearing_system>:基本完成下单控件开发

完成下单控件开发,快捷键开发,列表正在开发中。
central_clearing_system/ETradeClient.rc
... ... @@ -130,7 +130,10 @@ END
130 130  
131 131 IDR_ACCELERATOR_ORDER ACCELERATORS
132 132 BEGIN
  133 + VK_RETURN, ID_ACCELERATOR_ENTER, VIRTKEY, NOINVERT
133 134 VK_TAB, ID_ACCELERATOR_TAB, VIRTKEY, NOINVERT
  135 + VK_UP, ID_ACCELERATOR_UP, VIRTKEY, NOINVERT
  136 + VK_DOWN, ID_ACCELERATOR_DOWN, VIRTKEY, NOINVERT
134 137 END
135 138  
136 139  
... ... @@ -200,7 +203,7 @@ BEGIN
200 203 CONTROL "新中新电子读卡器",IDC_RADIO_XINZHONGXIN,"Button",BS_AUTORADIOBUTTON | WS_TABSTOP,174,186,71,10
201 204 END
202 205  
203   -IDD_DIALOG_PLACE_ORDER DIALOGEX 0, 0, 324, 238
  206 +IDD_DIALOG_PLACE_ORDER DIALOGEX 0, 0, 338, 238
204 207 STYLE DS_SYSMODAL | DS_SETFONT | DS_MODALFRAME | DS_3DLOOK | DS_CENTER | WS_POPUP | WS_VISIBLE | WS_CAPTION | WS_SYSMENU
205 208 CAPTION "结算下单"
206 209 FONT 12, "微软雅黑", 400, 0, 0x86
... ... @@ -221,10 +224,10 @@ BEGIN
221 224 EDITTEXT IDC_EDIT_PRICE,30,70,53,15,ES_MULTILINE | ES_AUTOHSCROLL
222 225 LTEXT "数 量",IDC_STATIC_COUNT,92,70,30,14
223 226 EDITTEXT IDC_EDIT_COUNT,114,69,44,13,ES_MULTILINE | ES_AUTOHSCROLL
224   - PUSHBUTTON "去支付(&S)",IDC_BUTTON_PAY,270,10,50,14
  227 + PUSHBUTTON "去支付(&S)",IDC_BUTTON_PAY,284,10,50,14
225 228 LTEXT "合计:",IDC_STATIC_HEJI,246,227,20,8
226 229 LTEXT "",IDC_STATIC_TOTAL_MONEY,289,227,8,8
227   - LTEXT "",IDC_STATIC_ERROR,182,67,119,16
  230 + LTEXT "",IDC_STATIC_ERROR,262,67,8,8
228 231 END
229 232  
230 233  
... ... @@ -299,7 +302,7 @@ BEGIN
299 302 IDD_DIALOG_PLACE_ORDER, DIALOG
300 303 BEGIN
301 304 MOCKUP, 1, 50, -25, -30, "C:\Users\WangGY\Desktop\TIM图片20180918183513.png"
302   - RIGHTMARGIN, 320
  305 + RIGHTMARGIN, 334
303 306 HORZGUIDE, 67
304 307 END
305 308 END
... ...
central_clearing_system/ETradeClient/mfc_ui/GridCtrl.cpp
... ... @@ -3333,6 +3333,8 @@ void CGridCtrl::ResetScrollBars()
3333 3333 si.nMin = 0;
3334 3334 si.nMax = m_nVScrollMax;
3335 3335 SetScrollInfo(SB_VERT, &si, TRUE);
  3336 +
  3337 + ShowScrollBar(SB_HORZ, FALSE);
3336 3338 }
3337 3339  
3338 3340 ////////////////////////////////////////////////////////////////////////////////////
... ...
central_clearing_system/ETradeClient/mfc_ui/etrade_edit_control.cpp
... ... @@ -2,43 +2,30 @@
2 2 #include "etrade_edit_control.h"
3 3 #include "resource.h"
4 4 #include "place_order_dlg.h"
  5 +#include "etradeclient/utility/win_http.h"
  6 +#include "etradeclient/utility/logging.h"
  7 +#include "ETradeClient/utility/win_msg_define.h"
5 8  
6   -IMPLEMENT_DYNAMIC( CEditBox, CEdit )
  9 +
  10 +IMPLEMENT_DYNAMIC( CEditBox, CMFCMaskedEdit )
7 11  
8 12 CEditBox::CEditBox()
9 13 {
10   - m_clrFrame = RGB( 245, 108, 108 );
  14 + m_clrFrame = RGB( 245, 108, 108 );
11 15 is_edit_red_ = false;
  16 + check_type_ = DoNotCheck;
12 17 }
13 18  
14 19 CEditBox::~CEditBox()
15 20 {
16   - m_brushBk.DeleteObject();
17 21 }
18 22  
19   -BEGIN_MESSAGE_MAP( CEditBox, CEdit )
20   - ON_WM_CTLCOLOR_REFLECT()
  23 +BEGIN_MESSAGE_MAP(CEditBox, CEdit)
21 24 ON_WM_NCPAINT()
22 25 ON_WM_KILLFOCUS()
  26 + ON_WM_CHAR()
23 27 END_MESSAGE_MAP()
24 28  
25   -HBRUSH CEditBox::CtlColor( CDC *pDC, UINT nCtlColor )
26   -{
27   - if( IsWindowEnabled() ) {
28   - m_brushBk.DeleteObject();
29   - m_brushBk.CreateSolidBrush( m_clrBackground );
30   - pDC->SetBkColor( m_clrBackground );
31   - pDC->SetTextColor( m_clrText );
32   - }
33   - else {
34   - m_brushBk.DeleteObject();
35   - m_brushBk.CreateSolidBrush( m_clrDisabledBack );
36   - pDC->SetBkColor( m_clrDisabledBack );
37   - pDC->SetTextColor( m_clrDisabledText );
38   - }
39   -
40   - return (HBRUSH)m_brushBk.GetSafeHandle();
41   -}
42 29  
43 30 void CEditBox::OnNcPaint()
44 31 {
... ... @@ -66,87 +53,289 @@ void CEditBox::OnKillFocus(CWnd* pNewWnd)
66 53 CEdit::OnKillFocus(pNewWnd);
67 54  
68 55 int dlg_id = GetDlgCtrlID();
  56 + GetParent()->SendMessage(WM_ORDER_KILL_FOCUS, dlg_id);
  57 +}
  58 +
  59 +void CEditBox::SetEditRed(bool is_red)
  60 +{
  61 + is_edit_red_ = is_red;
  62 + UpdateWindow();
  63 +}
  64 +
  65 +void CEditBox::SetCheck(CheckType type)
  66 +{
  67 + check_type_ = type;
  68 +}
  69 +
69 70  
70   - switch (dlg_id)
  71 +void CEditBox::OnChar(UINT nChar, UINT nRepCnt, UINT nFlags)
  72 +{
  73 + if (check_type_ == DoNotCheck || nChar < 32 || nChar > 126)
71 74 {
72   - case IDC_EDIT_CARD:
  75 + CEdit::OnChar(nChar, nRepCnt, nFlags);
  76 + return;
  77 + }
  78 +
  79 + CString sBefore, sAfter;
  80 + GetWindowText(sBefore);
  81 + //保存光标位置
  82 + int nPosCurbgn, nPosCurend;
  83 + GetSel(nPosCurbgn, nPosCurend);
  84 + CEdit::OnChar(nChar, nRepCnt, nFlags);
  85 +
  86 + GetWindowText(sAfter);
  87 + bool result = true;
  88 + switch (check_type_)
73 89 {
74   - CString error;
75   - do
76   - {
77   - CString num;
78   - GetWindowText(num);
79   - if (!CheckCardNum(num))
80   - {
81   - error = L"卡号错误!";
82   - break;
83   - }
84   - CString name;
85   - bool result = GetCardName(num, name);
86   - if (result)
87   - {
88   - ((PlaceOrderDlg*)GetParent())->name_edit_.SetWindowText(name);
89   - }
90   - else
91   - {
92   - error = name;
93   - }
94   - } while (0);
95   -
96   - if (!error.IsEmpty())
  90 + case CardNumType:
  91 + {
  92 + result = CheckCardNum(sAfter);
  93 + break;
  94 + }
  95 + case CommNumType:
  96 + {
  97 + result = CheckCommNum(sAfter);
  98 + break;
  99 + }
  100 + case UnitType:
  101 + {
  102 + result = CheckUnitNum(sAfter);
  103 + break;
  104 + }
  105 + case HeavyType:
  106 + {
  107 + result = CheckHeavy(sAfter);
  108 + break;
  109 + }
  110 + case PriceType:
  111 + {
  112 + result = CheckPrice(sAfter);
  113 + break;
  114 + }
  115 + case CountType:
  116 + {
  117 + result = CheckCount(sAfter);
  118 + break;
  119 + }
  120 + }
  121 +
  122 + if (!result)
  123 + {
  124 + SetWindowText(sBefore);
  125 + SetSel(nPosCurbgn, nPosCurend, true);
  126 + }
  127 +}
  128 +
  129 +bool CEditBox::CheckCardNum(CString num)
  130 +{
  131 + bool result = true;
  132 +
  133 + do
  134 + {
  135 + if (num.GetLength() > 12)
97 136 {
98   - SetEditRed(true);
  137 + result = false;
  138 + break;
99 139 }
100   - else
  140 +
  141 + if (num.SpanIncluding(L"0123456789") != num)
101 142 {
102   - SetEditRed(false);
  143 + result = false;
  144 + break;
103 145 }
  146 + } while (0);
104 147  
105   - ((PlaceOrderDlg*)GetParent())->error_static_.SetWindowText(error);
106   - UpdateWindow();
  148 + return result;
  149 +}
107 150  
108   - break;
109   - }
110   - case IDC_EDIT_COMM_NUM:
  151 +bool CEditBox::CheckCommNum(CString num)
  152 +{
  153 + bool result = true;
  154 +
  155 + do
111 156 {
  157 + if (num.GetLength() > 3)
  158 + {
  159 + result = false;
  160 + break;
  161 + }
112 162  
113   - break;
114   - }
  163 + if (num.SpanIncluding(L"0123456789") != num)
  164 + {
  165 + result = false;
  166 + break;
  167 + }
  168 + } while (0);
  169 +
  170 + return result;
  171 +}
  172 +
  173 +bool CEditBox::CheckUnitNum(CString num)
  174 +{
  175 + bool result = true;
  176 +
  177 + if (num.Compare(L"1") != 0 && num.Compare(L"2") != 0)
  178 + {
  179 + result = false;
115 180 }
  181 +
  182 + return result;
116 183 }
117 184  
118   -bool CEditBox::CheckCardNum(CString &num)
  185 +bool CEditBox::CheckHeavy(CString heavy)
119 186 {
120 187 bool result = true;
121 188  
122 189 do
123 190 {
124   - if (num.GetLength() != 12)
  191 + int length = heavy.GetLength();
  192 + if (length > 8)
125 193 {
126 194 result = false;
127 195 break;
128 196 }
129 197  
130   - if (num.SpanIncluding(L"0123456789") != num)
  198 + if (heavy.SpanIncluding(L"0123456789.") != heavy)
  199 + {
  200 + result = false;
  201 + break;
  202 + }
  203 +
  204 + double num = _ttof(heavy);
  205 + if (num > 100000)
  206 + {
  207 + result = false;
  208 + break;
  209 + }
  210 +
  211 + //如果精度超过设置的精度则返回
  212 + int dec_pos = heavy.Find(L".");
  213 + if (dec_pos != CB_ERR && length - dec_pos - 1 > 1)
131 214 {
132 215 result = false;
133 216 break;
134 217 }
  218 + //小数点不在首位
  219 + if (length > 0 && heavy.Left(1) == ".")
  220 + {
  221 + result = false;
  222 + break;
  223 + }
  224 + //只有一个小数点
  225 + if (heavy.Replace(L".", L".") > 1)
  226 + {
  227 + result = false;
  228 + break;
  229 + }
  230 +
135 231 } while (0);
  232 +
  233 + return result;
  234 +}
  235 +
  236 +bool CEditBox::CheckPrice(CString price)
  237 +{
  238 + bool result = true;
136 239  
  240 + do
  241 + {
  242 + int length = price.GetLength();
  243 + if (length > 8)
  244 + {
  245 + result = false;
  246 + break;
  247 + }
  248 +
  249 + if (price.SpanIncluding(L"0123456789.") != price)
  250 + {
  251 + result = false;
  252 + break;
  253 + }
  254 +
  255 + double num = _ttof(price);
  256 + if (num > 50000)
  257 + {
  258 + result = false;
  259 + break;
  260 + }
  261 +
  262 + //如果精度超过设置的精度则返回
  263 + int dec_pos = price.Find(L".");
  264 + if (dec_pos != CB_ERR && length - dec_pos - 1 > 2)
  265 + {
  266 + result = false;
  267 + break;
  268 + }
  269 + //小数点不在首位
  270 + if (length > 0 && price.Left(1) == ".")
  271 + {
  272 + result = false;
  273 + break;
  274 + }
  275 + //只有一个小数点
  276 + if (price.Replace(L".", L".") > 1)
  277 + {
  278 + result = false;
  279 + break;
  280 + }
  281 +
  282 + } while (0);
  283 +
137 284 return result;
138 285 }
139 286  
140   -bool CEditBox::GetCardName(CString &num, CString &name)
  287 +bool CEditBox::CheckCount(CString count)
141 288 {
142 289 bool result = true;
143 290  
  291 + do
  292 + {
  293 + int length = count.GetLength();
  294 + if (length > 8)
  295 + {
  296 + result = false;
  297 + break;
  298 + }
  299 +
  300 + if (count.SpanIncluding(L"0123456789.") != count)
  301 + {
  302 + result = false;
  303 + break;
  304 + }
  305 +
  306 + double num = _ttof(count);
  307 + if (num > 100000)
  308 + {
  309 + result = false;
  310 + break;
  311 + }
  312 +
  313 + //如果精度超过设置的精度则返回
  314 + int dec_pos = count.Find(L".");
  315 + if (dec_pos != CB_ERR && length - dec_pos - 1 > 1)
  316 + {
  317 + result = false;
  318 + break;
  319 + }
  320 + //小数点不在首位
  321 + if (length > 0 && count.Left(1) == ".")
  322 + {
  323 + result = false;
  324 + break;
  325 + }
  326 + //只有一个小数点,这里有个坑,必须用L".",不能用'.',否则始终返回0
  327 + if (count.Replace(L".", L".") > 1)
  328 + {
  329 + result = false;
  330 + break;
  331 + }
144 332  
  333 + } while (0);
145 334  
146 335 return result;
147 336 }
148 337  
149   -void CEditBox::SetEditRed(bool is_red)
  338 +bool CEditBox::IsEditRed()
150 339 {
151   - is_edit_red_ = is_red;
  340 + return is_edit_red_;
152 341 }
153 342 \ No newline at end of file
... ...
central_clearing_system/ETradeClient/mfc_ui/etrade_edit_control.h
1 1 #ifndef __my_edit_control_h__
2 2 #define __my_edit_control_h__
3 3  
  4 +enum CheckType
  5 +{
  6 + CardNumType = 0,
  7 + CommNumType,
  8 + UnitType,
  9 + HeavyType,
  10 + PriceType,
  11 + CountType,
  12 + DoNotCheck
  13 +};
  14 +
4 15 class CEditBox : public CEdit
5 16 {
6   - DECLARE_DYNAMIC( CEditBox )
  17 + DECLARE_DYNAMIC(CEditBox)
7 18  
8 19 public:
9 20 CEditBox();
10 21 ~CEditBox();
11 22  
12 23 private:
13   - COLORREF m_clrBackground;
14 24 COLORREF m_clrFrame;
15   - COLORREF m_clrText;
16   - COLORREF m_clrDisabledBackground;
17   - COLORREF m_clrDisabledBack;
18   - COLORREF m_clrDisabledText;
19   -
20   - CBrush m_brushBk;
21   -
22   -public:
23   - void SetBackgroundColor( COLORREF clr ) { m_clrBackground = clr; }
24   - void SetFrameColor( COLORREF clr ) { m_clrFrame = clr; }
25   - void SetTextColor( COLORREF clr ) { m_clrText = clr; }
26   - void SetDisabledColor( COLORREF clrBack, COLORREF clrText ) {
27   - m_clrDisabledBack = clrBack;
28   - m_clrDisabledText = clrText;
29   - }
30   -
31   - COLORREF GetBackgroundColor() const { return m_clrBackground; }
32   - COLORREF GetFrameColor() const { return m_clrFrame; }
33   - COLORREF GetTextColor() const { return m_clrText; }
34   - COLORREF GetDisabledColor( COLORREF& clrBack, COLORREF& clrText ) const {
35   - clrBack = m_clrDisabledBack;
36   - clrText = m_clrDisabledText;
37   - }
38 25  
39 26 protected:
40   - afx_msg HBRUSH CtlColor( CDC *pDC, UINT nCtlColor );
41 27 afx_msg void OnNcPaint();
42 28  
43 29 DECLARE_MESSAGE_MAP()
44 30 public:
45 31 afx_msg void OnKillFocus(CWnd* pNewWnd);
46   -
47   -private:
48   - bool CheckCardNum(CString &num);
49   - bool GetCardName(CString &num, CString &name);
50   -
51 32 public:
52 33 void SetEditRed(bool is_red);
  34 + bool IsEditRed();
53 35  
54 36 bool is_edit_red_;
  37 + afx_msg void OnChar(UINT nChar, UINT nRepCnt, UINT nFlags);
  38 +
  39 + void SetCheck(CheckType type);
  40 +
  41 + CheckType check_type_;
  42 +
  43 + bool CheckCardNum(CString num);
  44 + bool CheckCommNum(CString num);
  45 + bool CheckUnitNum(CString num);
  46 + bool CheckHeavy(CString heavy);
  47 + bool CheckPrice(CString price);
  48 + bool CheckCount(CString count);
55 49 };
56 50  
57 51 #endif // __my_edit_control_h__
... ...
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.cpp
... ... @@ -5,6 +5,13 @@
5 5 #include "ETradeClient.h"
6 6 #include "place_order_dlg.h"
7 7 #include "afxdialogex.h"
  8 +#include "ETradeClient/utility/win_msg_define.h"
  9 +#include "ETradeClient/utility/logging.h"
  10 +#include "etradeclient/utility/url_config.h"
  11 +#include "etradeclient/utility/application_config.h"
  12 +#include "etradeclient/browser/session.h"
  13 +#include "ETradeClient/utility/string_converter.h"
  14 +#include "ETradeClient/utility/win_msg_define.h"
8 15  
9 16  
10 17 // PlaceOrderDlg 对话框
... ... @@ -16,6 +23,15 @@ PlaceOrderDlg::PlaceOrderDlg(CWnd* pParent /*=NULL*/)
16 23 {
17 24 line_pen_.CreatePen(PS_SOLID, 1, RGB(0, 0, 0));
18 25 edit_brush_.CreateSolidBrush(RGB(245, 247, 250));
  26 + /*error_count_ = 6;
  27 + card_num_ = ErrorCode;
  28 + card_name_ = ErrorCode;
  29 + comm_num_ = ErrorCode;
  30 + comm_name_ = ErrorCode;
  31 + unit_ = ErrorCode;
  32 + heavy_ = ErrorCode;
  33 + price_ = ErrorCode;
  34 + count_ = ErrorCode;*/
19 35 }
20 36  
21 37 PlaceOrderDlg::~PlaceOrderDlg()
... ... @@ -55,7 +71,11 @@ BEGIN_MESSAGE_MAP(PlaceOrderDlg, CDialogEx)
55 71 ON_WM_CTLCOLOR()
56 72 ON_BN_CLICKED(IDC_BUTTON_PAY, &PlaceOrderDlg::OnBnClickedButtonPay)
57 73 ON_COMMAND(ID_ACCELERATOR_TAB, &PlaceOrderDlg::OnAcceleratorTab)
58   - ON_WM_KILLFOCUS()
  74 + ON_COMMAND(ID_ACCELERATOR_ENTER, &PlaceOrderDlg::OnAcceleratorEnter)
  75 + ON_MESSAGE(WM_ORDER_KILL_FOCUS, &PlaceOrderDlg::OnEditKillFocus)
  76 + ON_COMMAND(ID_ACCELERATOR_DOWN, &PlaceOrderDlg::OnAcceleratorDown)
  77 + ON_COMMAND(ID_ACCELERATOR_UP, &PlaceOrderDlg::OnAcceleratorUp)
  78 + ON_WM_SETFOCUS()
59 79 END_MESSAGE_MAP()
60 80  
61 81  
... ... @@ -68,11 +88,12 @@ BOOL PlaceOrderDlg::OnInitDialog()
68 88  
69 89 //设置窗口样式
70 90 SetCtrlPos();
  91 + SetCtrlInitData();
71 92 InitList();
72 93  
73 94 acce_ = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR_ORDER));
74 95  
75   - return TRUE; // return TRUE unless you set the focus to a control
  96 + return FALSE; // return TRUE unless you set the focus to a control
76 97 // 异常: OCX 属性页应返回 FALSE
77 98 }
78 99  
... ... @@ -192,10 +213,15 @@ void PlaceOrderDlg::SetCtrlPos()
192 213 ctrl_rect.right += EditWidth;
193 214 count_edit_.MoveWindow(&ctrl_rect);
194 215  
195   - const int TotalMoneyStaticWidth = 80, TotalMoneyStaticHeight = 35;
196   -
197 216 CRect dlg_rect;
198 217 GetClientRect(&dlg_rect);
  218 + ctrl_rect.top += 10;
  219 + ctrl_rect.left = ctrl_rect.right + 30;
  220 + ctrl_rect.right = dlg_rect.right;
  221 + error_static_.MoveWindow(&ctrl_rect);
  222 +
  223 + const int TotalMoneyStaticWidth = 80, TotalMoneyStaticHeight = 35;
  224 +
199 225 ctrl_rect.top = ctrl_rect.bottom + 20;
200 226 ctrl_rect.bottom = dlg_rect.bottom - TotalMoneyStaticHeight;
201 227 ctrl_rect.left = 0;
... ... @@ -277,17 +303,12 @@ HBRUSH PlaceOrderDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
277 303 {
278 304 HBRUSH hbr = CDialogEx::OnCtlColor(pDC, pWnd, nCtlColor);
279 305  
280   - switch (pWnd->GetDlgCtrlID())
281   - {
282   - case IDC_EDIT_CARD:
283   - case IDC_EDIT_COMM_NAME:
  306 + if (nCtlColor == CTLCOLOR_STATIC)
284 307 {
285   - pDC->SetBkColor(RGB(245, 247, 250));
286   - HBRUSH edit_bgc = ::CreateSolidBrush(RGB(245, 247, 250));
287   - return edit_bgc;
288   - }
289   - default:
290   - break;
  308 + if (IDC_STATIC_ERROR == pWnd->GetDlgCtrlID())
  309 + {
  310 + pDC->SetTextColor(RGB(200, 0, 0));
  311 + }
291 312 }
292 313  
293 314 return hbr;
... ... @@ -296,12 +317,11 @@ HBRUSH PlaceOrderDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
296 317  
297 318 void PlaceOrderDlg::OnBnClickedButtonPay()
298 319 {
299   -
  320 + SetErrorMsg(CString(L"anniuanniu"));
300 321 }
301 322  
302 323 void PlaceOrderDlg::InitList()
303 324 {
304   - product_list_.AutoSize(GVS_HEADER);
305 325 product_list_.InsertColumn(L"货主卡号");
306 326 product_list_.InsertColumn(L"货主姓名");
307 327 product_list_.InsertColumn(L"商品名称");
... ... @@ -332,91 +352,341 @@ void PlaceOrderDlg::InitList()
332 352  
333 353 product_list_.SetFixedColumnCount(1);
334 354 product_list_.SetFixedColumnCount(2);
335   -
336 355  
337   - //product_list_.GetDefaultCell(FALSE, FALSE)->SetBackClr(RGB(0xFF, 0xFF, 0xE0));
  356 + product_list_.SetRowResize(FALSE);
  357 + product_list_.SetColumnResize(FALSE);
338 358  
339   - /*product_list_.EnableDragAndDrop(TRUE);
  359 + product_list_.SetTrackFocusCell(FALSE);
  360 +}
340 361  
341 362  
  363 +BOOL PlaceOrderDlg::PreTranslateMessage(MSG* pMsg)
  364 +{
  365 + if (WM_KEYFIRST <= pMsg->message&&pMsg->message <= WM_KEYLAST)
  366 + {
  367 + if (acce_ && ::TranslateAccelerator(m_hWnd, acce_, pMsg))
  368 + return TRUE;
  369 + }
  370 + return CDialogEx::PreTranslateMessage(pMsg);
  371 +}
342 372  
343 373  
344   - product_list_.SetFixedColumnSelection(TRUE);
345   - product_list_.SetFixedRowSelection(TRUE);
346   - product_list_.EnableColumnHide();
  374 +void PlaceOrderDlg::OnAcceleratorTab()
  375 +{
  376 +
  377 +}
  378 +void PlaceOrderDlg::OnAcceleratorEnter()
  379 +{
  380 + OnEditKillFocus(GetFocus()->GetDlgCtrlID(), NULL);
347 381  
  382 + do
  383 + {
  384 + if (card_edit_.IsEditRed() || comm_num_edit_.IsEditRed() ||
  385 + unit_edit_.IsEditRed() || (heavy_edit_.IsWindowEnabled() && heavy_edit_.IsEditRed()) ||
  386 + price_edit_.IsEditRed() || count_edit_.IsEditRed())
  387 + {
  388 + break;
  389 + }
  390 +
  391 + int row_index = product_list_.InsertRow(L"", -1);
  392 + product_list_.Invalidate();
  393 + CString text;
  394 + double price = 0, count = 0;
  395 + card_edit_.GetWindowText(text);
  396 + product_list_.SetItemText(row_index, 0, text);
  397 + text.Empty();
  398 + name_edit_.GetWindowText(text);
  399 + product_list_.SetItemText(row_index, 1, text);
  400 + text.Empty();
  401 + comm_name_edit_.GetWindowText(text);
  402 + product_list_.SetItemText(row_index, 2, text);
  403 + text.Empty();
  404 + price_edit_.GetWindowText(text);
  405 + price = _ttof(text);
  406 + product_list_.SetItemText(row_index, 3, text);
  407 + text.Empty();
  408 + count_edit_.GetWindowText(text);
  409 + count = _ttof(text);
  410 + product_list_.SetItemText(row_index, 4, text);
  411 + text.Empty();
  412 + real_unit_static.GetWindowText(text);
  413 + product_list_.SetItemText(row_index, 5, text);
  414 + text.Empty();
  415 + heavy_edit_.GetWindowText(text);
  416 + product_list_.SetItemText(row_index, 6, text);
  417 + text.Empty();
  418 + text.Format(_T("%.1f"), price * count);
  419 + product_list_.SetItemText(row_index, 7, text);
  420 +
  421 + for (int index = 0; index < 8; ++index)
  422 + {
  423 + product_list_.SetItemFormat(row_index, index, DT_CENTER | DT_VCENTER | DT_SINGLELINE);
  424 + }
  425 +
  426 + product_list_.
  427 +
  428 + } while (0);
  429 +
  430 + UpdateWindow();
  431 +}
348 432  
349 433  
350   - product_list_.SetCompareFunction(CGridCtrl::pfnCellNumericCompare);*/
  434 +void PlaceOrderDlg::SetCtrlInitData()
  435 +{
  436 + card_edit_.SetWindowTextW(L"8888");
  437 +
  438 + card_edit_.SetCheck(CardNumType);
  439 + comm_num_edit_.SetCheck(CommNumType);
  440 + unit_edit_.SetCheck(UnitType);
  441 + heavy_edit_.SetCheck(HeavyType);
  442 + price_edit_.SetCheck(PriceType);
  443 + count_edit_.SetCheck(CountType);
  444 +
  445 + card_edit_.SetFocus();
  446 + card_edit_.SetSel(4, 4);
  447 + heavy_edit_.EnableWindow(FALSE);
351 448 }
352 449  
  450 +void PlaceOrderDlg::SetErrorMsg(CString &error)
  451 +{
  452 + error_static_.SetWindowTextW(error);
  453 +}
353 454  
354   -BOOL PlaceOrderDlg::PreTranslateMessage(MSG* pMsg)
  455 +LRESULT PlaceOrderDlg::OnEditKillFocus(WPARAM wParam, LPARAM lParam)
355 456 {
356   - if (WM_KEYFIRST <= pMsg->message&&pMsg->message <= WM_KEYLAST)
  457 + int dlg_id = wParam;
  458 +
  459 + CString text;
  460 + GetDlgItem(dlg_id)->GetWindowText(text);
  461 +
  462 + switch (dlg_id)
357 463 {
358   - if (acce_ && ::TranslateAccelerator(m_hWnd, acce_, pMsg))
359   - return TRUE;
  464 + case IDC_EDIT_CARD:
  465 + {
  466 + CString name;
  467 + if (text.GetLength() < 12)
  468 + {
  469 + card_edit_.SetEditRed(true);
  470 + break;
  471 + }
  472 +
  473 + bool result = GetCardName(text, name);
  474 + if (result)
  475 + {
  476 + name_edit_.SetWindowText(name);
  477 + card_edit_.SetEditRed(false);
  478 + }
  479 + else
  480 + {
  481 + SetErrorMsg(name);
  482 + card_edit_.SetEditRed(true);
  483 + }
  484 +
  485 + break;
360 486 }
361   - if (card_edit_)
  487 + case IDC_EDIT_COMM_NUM:
362 488 {
  489 + CString name;
  490 + if (text.GetLength() < 3)
  491 + {
  492 + comm_num_edit_.SetEditRed(true);
  493 + break;
  494 + }
  495 +
  496 + bool result = GetCardName(text, name);
  497 + if (result)
  498 + {
  499 + name_edit_.SetWindowText(name);
  500 + comm_num_edit_.SetEditRed(false);
  501 + }
  502 + else
  503 + {
  504 + SetErrorMsg(name);
  505 + comm_num_edit_.SetEditRed(true);
  506 + }
  507 +
  508 + break;
363 509 }
364   - return CDialogEx::PreTranslateMessage(pMsg);
  510 + case IDC_EDIT_UNIT:
  511 + {
  512 + if (text.Compare(L"1") == 0)
  513 + {
  514 + real_unit_static.SetWindowTextW(L"斤");
  515 + heavy_edit_.SetEditRed(false);
  516 + heavy_edit_.SetWindowText(L"");
  517 + heavy_edit_.EnableWindow(FALSE);
  518 + unit_edit_.SetEditRed(false);
  519 + }
  520 + else if (text.Compare(L"2") == 0)
  521 + {
  522 + real_unit_static.SetWindowTextW(L"件");
  523 + heavy_edit_.EnableWindow(TRUE);
  524 + unit_edit_.SetEditRed(false);
  525 + }
  526 + else
  527 + {
  528 + unit_edit_.SetEditRed(true);
  529 + }
  530 + break;
  531 + }
  532 + case IDC_EDIT_HEAVY:
  533 + case IDC_EDIT_PRICE:
  534 + case IDC_EDIT_COUNT:
  535 + {
  536 + if (text.IsEmpty())
  537 + {
  538 + ((CEditBox*)GetDlgItem(dlg_id))->SetEditRed(true);
  539 + }
  540 + else if (text.Right(1).Compare(L".") == 0)
  541 + {
  542 + ((CEditBox*)GetDlgItem(dlg_id))->SetEditRed(true);
  543 + }
  544 + else
  545 + {
  546 + ((CEditBox*)GetDlgItem(dlg_id))->SetEditRed(false);
  547 + }
  548 +
  549 + break;
  550 + }
  551 + }
  552 +
  553 + UpdateWindow();
  554 +
  555 + return S_OK;
365 556 }
366 557  
367 558  
368   -void PlaceOrderDlg::OnAcceleratorTab()
  559 +bool PlaceOrderDlg::GetCardName(CString &num, CString &name)
369 560 {
370   - /*CWnd *wnd = GetFocus();
  561 + //for test
  562 + return true;
  563 + //
371 564  
372   - int ctrl_id = wnd->GetDlgCtrlID();
373 565  
374   - switch (ctrl_id)
375   - {
376   - case IDC_EDIT_CARD:
  566 + bool result = true;
  567 +
  568 + CString sLog;
  569 +
  570 + LOG_TRACE(_T("获取开卡人姓名!"));
  571 +
  572 + const uint32_t kHTTPOK = 200;
  573 + WinHttp win_http;
  574 + auto& url_cfg = URLConfig::Instance();
  575 + win_http.ConnectHost(url_cfg.Host(), url_cfg.Port(), url_cfg.IsHttps());
  576 + auto& request = win_http.OpenRequest(WinHttp::Method::GET, url_cfg.GetCardNamePath());
  577 + if (url_cfg.IsHttps())
377 578 {
378   - CString name;
379   - if (GetUserName(name))
  579 + auto& app_cfg = ApplicationConfig::Instance();
  580 + request.SetClientCertificate(app_cfg.ClientCertStore(), app_cfg.ClientCertSubject());
  581 + }
  582 + request.SetCookies(Session::Instance().Cookies());
  583 + request.Send();
  584 + uint32_t status_code = request.GetResponseStatus();
  585 + if (kHTTPOK != status_code)
380 586 {
381   - name_edit_.SetWindowTextW(name);
382   - comm_num_edit_.SetFocus();
  587 + std::string err_msg = "网络请求错误! 错误码: " + std::to_string(status_code);
  588 + LOG_ERROR(str_2_wstr(err_msg.c_str()));
383 589 }
384   - else
  590 + std::string response_body = request.ReadResponseBody();
  591 + if (response_body.empty())
385 592 {
386   - name_edit_.SetFocus();
  593 + LOG_ERROR(L"获取服务器响应数据失败,请确保网络连接正常!");
387 594 }
388   - break;
  595 +
  596 + return result;
  597 +}
  598 +
  599 +bool PlaceOrderDlg::GetCommName(CString &num, CString &name)
  600 +{
  601 + return true;
  602 +}
  603 +
  604 +void PlaceOrderDlg::OnAcceleratorDown()
  605 +{
  606 + int item_id = GetFocus()->GetDlgCtrlID();
  607 +
  608 + switch (item_id)
  609 + {
  610 + case IDC_EDIT_CARD:
  611 + {
  612 + comm_num_edit_.SetFocus();
  613 + break;
389 614 }
390 615 case IDC_EDIT_COMM_NUM:
391 616 {
392   - CString name;
393   - if (GetCommName(name))
  617 + unit_edit_.SetFocus();
  618 + break;
  619 + }
  620 + case IDC_EDIT_UNIT:
394 621 {
395   - comm_name_edit_.SetWindowTextW(name);
396   - comm_num_edit_.SetFocus();
  622 + CString unit;
  623 + unit_edit_.GetWindowText(unit);
  624 + if (unit.IsEmpty())
  625 + {
  626 + heavy_edit_.IsWindowEnabled() ? heavy_edit_.SetFocus() : price_edit_.SetFocus();
  627 + }
  628 + else if (unit.Compare(L"1") == 0)
  629 + {
  630 + price_edit_.SetFocus();
  631 + }
  632 + else
  633 + {
  634 + heavy_edit_.EnableWindow(TRUE);
  635 + heavy_edit_.SetFocus();
  636 + }
  637 + break;
397 638 }
398   - else
  639 + case IDC_EDIT_HEAVY:
399 640 {
400   - name_edit_.SetFocus();
  641 + price_edit_.SetFocus();
  642 + break;
401 643 }
402   - break;
  644 + case IDC_EDIT_PRICE:
  645 + {
  646 + count_edit_.SetFocus();
  647 + break;
403 648 }
404 649 }
  650 +}
405 651  
406   - if ( == card_edit_.GetDlgCtrlID())
407   - {
  652 +void PlaceOrderDlg::OnAcceleratorUp()
  653 +{
  654 + int item_id = GetFocus()->GetDlgCtrlID();
408 655  
  656 + switch (item_id)
  657 + {
  658 + case IDC_EDIT_COUNT:
  659 + {
  660 + price_edit_.SetFocus();
  661 + break;
  662 + }
  663 + case IDC_EDIT_PRICE:
  664 + {
  665 + heavy_edit_.IsWindowEnabled() ? heavy_edit_.SetFocus() : unit_edit_.SetFocus();
  666 + break;
  667 + }
  668 + case IDC_EDIT_HEAVY:
  669 + {
  670 + unit_edit_.SetFocus();
  671 + break;
409 672 }
410   - else
411   - if ()
  673 + case IDC_EDIT_UNIT:
412 674 {
413   - }*/
  675 + comm_num_edit_.SetFocus();
  676 + break;
  677 + }
  678 + case IDC_EDIT_COMM_NUM:
  679 + {
  680 + card_edit_.SetFocus();
  681 + break;
  682 + }
  683 + }
414 684 }
415 685  
416   -
417   -void PlaceOrderDlg::OnKillFocus(CWnd* pNewWnd)
  686 +void PlaceOrderDlg::OnSetFocus(CWnd* pOldWnd)
418 687 {
419   - CDialogEx::OnKillFocus(pNewWnd);
  688 + CDialogEx::OnSetFocus(pOldWnd);
420 689  
421 690 // TODO: 在此处添加消息处理程序代码
422 691 }
  692 +
... ...
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.h
... ... @@ -37,23 +37,24 @@ protected:
37 37  
38 38 private:
39 39 void SetCtrlPos();
  40 + void SetCtrlInitData();
40 41 void InitList();
41 42 public:
42 43 CStatic owner_static_;
43 44 CEditBox card_edit_;
44 45 CEdit name_edit_;
45 46 CStatic comm_static_;
46   - CEdit comm_num_edit_;
  47 + CEditBox comm_num_edit_;
47 48 CEdit comm_name_edit_;
48 49 CStatic unit_static_;
49   - CEdit unit_edit_;
  50 + CEditBox unit_edit_;
50 51 CStatic real_unit_static;
51 52 CStatic heavy_static_;
52   - CEdit heavy_edit_;
  53 + CEditBox heavy_edit_;
53 54 CStatic price_static_;
54   - CEdit price_edit_;
  55 + CEditBox price_edit_;
55 56 CStatic count_static_;
56   - CEdit count_edit_;
  57 + CEditBox count_edit_;
57 58 CButton pay_button_;
58 59 CGridCtrl product_list_;
59 60  
... ... @@ -74,7 +75,34 @@ private:
74 75 public:
75 76 virtual BOOL PreTranslateMessage(MSG* pMsg);
76 77 afx_msg void OnAcceleratorTab();
77   - afx_msg void OnKillFocus(CWnd* pNewWnd);
  78 + afx_msg void OnAcceleratorEnter();
78 79  
  80 + void SetErrorMsg(CString &error);
79 81 CStatic error_static_;
  82 +
  83 + afx_msg LRESULT OnEditKillFocus(WPARAM wParam, LPARAM lParam);
  84 +
  85 + bool GetCardName(CString &num, CString &name);
  86 + bool GetCommName(CString &num, CString &name);
  87 +
  88 + afx_msg void OnAcceleratorDown();
  89 + afx_msg void OnAcceleratorUp();
  90 + afx_msg void OnSetFocus(CWnd* pOldWnd);
  91 +
  92 + //bool CheckCardData(CString card_data);
  93 + //bool CheckCommData(CString comm_data);
  94 + //bool CheckUnitData(CString unit_data);
  95 + //bool CheckPriceData(CString price_data);
  96 + //bool CheckCountData(CString count_data);
  97 +
  98 + //CString card_num_;
  99 + //CString card_name_;
  100 + //CString comm_num_;
  101 + //CString comm_name_;
  102 + //CString unit_;
  103 + //CString heavy_;
  104 + //CString price_;
  105 + //CString count_;
  106 + //int error_count_;
  107 + //const CString ErrorCode = L"-9000";
80 108 };
... ...
central_clearing_system/ETradeClient/utility/url_config.cpp
... ... @@ -61,6 +61,8 @@ URLConfig::URLConfig()
61 61 m_user_msg_count_path = ptree.get<std::string>("user_msg_count_path");
62 62 m_user_msg_path = ptree.get<std::string>("user_msg_path");
63 63 m_modify_pwd_path = ptree.get<std::string>("modify_pwd_path");
  64 + m_get_card_name_path = ptree.get<std::string>("get_card_name");
  65 +
64 66 }
65 67 catch (...) // Catch the exception in order for logging.
66 68 {
... ... @@ -91,6 +93,7 @@ void URLConfig::ModifyCfg(bool is_https, uint16_t port)
91 93 root.put("user_msg_count_path", m_user_msg_count_path);
92 94 root.put("user_msg_path", m_user_msg_path);
93 95 root.put("modify_pwd_path", m_modify_pwd_path);
  96 + root.put("get_card_name_path", m_get_card_name_path);
94 97 PT::write_json(ss, root, true);
95 98 }
96 99 catch (...) // Catch the exception in order for logging.
... ... @@ -166,4 +169,8 @@ std::string URLConfig::UserMsgPath() const
166 169 std::string URLConfig::PwdModificationPath() const
167 170 {
168 171 return m_modify_pwd_path;
  172 +}
  173 +std::string URLConfig::GetCardNamePath() const
  174 +{
  175 + return m_get_card_name_path;
169 176 }
170 177 \ No newline at end of file
... ...
central_clearing_system/ETradeClient/utility/url_config.h
... ... @@ -29,6 +29,7 @@ public:
29 29 std::string UserMsgCountPath() const;
30 30 std::string UserMsgPath() const;
31 31 std::string PwdModificationPath() const;
  32 + std::string GetCardNamePath() const;
32 33 private:
33 34 URLConfig();
34 35 URLConfig(const URLConfig&);
... ... @@ -45,5 +46,6 @@ private:
45 46 std::string m_user_msg_count_path;
46 47 std::string m_user_msg_path;
47 48 std::string m_modify_pwd_path;
  49 + std::string m_get_card_name_path;
48 50 };
49 51 #endif // ETRADECLIENT_UTILITY_URL_CONFIG_H_INCLUDED
... ...
central_clearing_system/ETradeClient/utility/win_msg_define.h
... ... @@ -22,6 +22,7 @@
22 22 #define WM_CEF_MSG_VIEW_NEW_BROWSER (WM_USER + 116)
23 23 #define WM_CEF_MSG_VIEW_CLOSE_BROWSER (WM_USER + 117)
24 24 #define WM_CRASH_CLOSE (WM_USER + 118)
  25 +#define WM_ORDER_KILL_FOCUS (WM_USER + 119)
25 26  
26 27 #define WM_CEF_JS_CAMMAND_CLOSE_WND (WM_USER + 301)
27 28 #define WM_CEF_JS_CAMMAND_USER_RELOGIN (WM_USER + 302)
... ...
central_clearing_system/Resource.h
... ... @@ -54,7 +54,7 @@
54 54 #define IDC_STATIC_COUNT 1040
55 55 #define IDC_STATIC_HEJI 1042
56 56 #define IDC_STATIC_TOTAL_MONEY 1043
57   -#define IDC_STATIC_ERROR 1044
  57 +#define IDC_STATIC_ERROR 1046
58 58 #define ID_PAY_FEE 10001
59 59 #define ID_ORDER 10002
60 60 #define ID_STATEMENT_MANAGE 10003
... ... @@ -71,14 +71,18 @@
71 71 #define ID_32849 32849
72 72 #define ID_POPMENU_DELETE 32850
73 73 #define ID_ACCELERATOR_TAB 32851
  74 +#define ID_ACCELERATOR_ENTER 32852
  75 +#define ID_ACCELERATOR_UP 32854
  76 +#define ID_ACCELERATOR_LEFT 32855
  77 +#define ID_ACCELERATOR_DOWN 32855
74 78  
75 79 // Next default values for new objects
76 80 //
77 81 #ifdef APSTUDIO_INVOKED
78 82 #ifndef APSTUDIO_READONLY_SYMBOLS
79 83 #define _APS_NEXT_RESOURCE_VALUE 331
80   -#define _APS_NEXT_COMMAND_VALUE 32852
81   -#define _APS_NEXT_CONTROL_VALUE 1045
  84 +#define _APS_NEXT_COMMAND_VALUE 32857
  85 +#define _APS_NEXT_CONTROL_VALUE 1047
82 86 #define _APS_NEXT_SYMED_VALUE 311
83 87 #endif
84 88 #endif
... ...