Commit 7419ca36a1e0a70a6f99bddf96472e81b745e545
1 parent
cf153888
feat<central_clearing_system>:修改下单页面
修改下单页面enter键作用。
Showing
6 changed files
with
177 additions
and
99 deletions
central_clearing_system/ETradeClient.rc
... | ... | @@ -155,9 +155,10 @@ END |
155 | 155 | |
156 | 156 | IDR_ACCELERATOR_PAY ACCELERATORS |
157 | 157 | BEGIN |
158 | - "X", ID_ACCELERATOR_X, VIRTKEY, NOINVERT | |
159 | 158 | "F", ID_ACCELERATOR_F, VIRTKEY, NOINVERT |
160 | - "S", ID_ACCELERATOR_S, VIRTKEY, NOINVERT | |
159 | + "A", ID_ACCELERATOR_A, VIRTKEY, NOINVERT | |
160 | + "X", ID_ACCELERATOR_X, VIRTKEY, NOINVERT | |
161 | + VK_RETURN, ID_ACCELERATOR_ENTER, VIRTKEY, NOINVERT | |
161 | 162 | END |
162 | 163 | |
163 | 164 | ... | ... |
central_clearing_system/ETradeClient/mfc_ui/pay_dlg.cpp
... | ... | @@ -20,6 +20,7 @@ |
20 | 20 | #include "ETradeClient/utility/logging.h" |
21 | 21 | #include <sstream> |
22 | 22 | #include "LoginDialog.h" |
23 | +#include "place_order_dlg.h" | |
23 | 24 | |
24 | 25 | |
25 | 26 | // PayDlg ¶Ô»°¿ò |
... | ... | @@ -57,9 +58,10 @@ BEGIN_MESSAGE_MAP(PayDlg, CDialogEx) |
57 | 58 | ON_BN_CLICKED(IDC_PAY_BUTTON_PAY, &PayDlg::OnBnClickedPayButtonPay) |
58 | 59 | ON_WM_CTLCOLOR() |
59 | 60 | ON_BN_CLICKED(IDC_PAY_BUTTON_PASSWORD, &PayDlg::OnBnClickedPayButtonPassword) |
60 | - ON_COMMAND(ID_ACCELERATOR_X, &PayDlg::OnBnClickedPayButtonPassword) | |
61 | + ON_COMMAND(ID_ACCELERATOR_A, &PayDlg::OnBnClickedPayButtonPassword) | |
61 | 62 | ON_COMMAND(ID_ACCELERATOR_F, &PayDlg::OnBnClickedPayButtonPay) |
62 | - ON_COMMAND(ID_ACCELERATOR_S, &PayDlg::OnBnClickedPayButtonClose) | |
63 | + ON_COMMAND(ID_ACCELERATOR_X, &PayDlg::OnBnClickedPayButtonClose) | |
64 | + ON_COMMAND(ID_ACCELERATOR_ENTER, &PayDlg::OnBnClickedEnter) | |
63 | 65 | ON_MESSAGE(WM_CEF_SESSION_EXPIRED, &PayDlg::OnSessionExpired) |
64 | 66 | END_MESSAGE_MAP() |
65 | 67 | |
... | ... | @@ -80,12 +82,14 @@ BOOL PayDlg::OnInitDialog() |
80 | 82 | password_static_.ShowWindow(SW_HIDE); |
81 | 83 | password_edit_.ShowWindow(SW_HIDE); |
82 | 84 | password_button_.ShowWindow(SW_HIDE); |
85 | + pay_button_.SetFocus(); | |
83 | 86 | } |
84 | 87 | else |
85 | 88 | { |
86 | 89 | password_static_.ShowWindow(SW_SHOW); |
87 | 90 | password_edit_.ShowWindow(SW_SHOW); |
88 | 91 | password_button_.ShowWindow(SW_SHOW); |
92 | + password_button_.SetFocus(); | |
89 | 93 | } |
90 | 94 | |
91 | 95 | acce_ = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR_PAY)); |
... | ... | @@ -374,3 +378,38 @@ LRESULT PayDlg::OnSessionExpired(WPARAM wParam, LPARAM lParam) |
374 | 378 | return 0; |
375 | 379 | } |
376 | 380 | |
381 | +void PayDlg::OnBnClickedEnter() | |
382 | +{ | |
383 | + int item_id = GetFocus()->GetDlgCtrlID(); | |
384 | + | |
385 | + switch (item_id) | |
386 | + { | |
387 | + case IDC_PAY_BUTTON_PASSWORD: | |
388 | + { | |
389 | + OnBnClickedPayButtonPassword(); | |
390 | + CString error; | |
391 | + error_msg_static_.GetWindowText(error); | |
392 | + if (error.IsEmpty()) | |
393 | + { | |
394 | + pay_button_.SetFocus(); | |
395 | + } | |
396 | + else | |
397 | + { | |
398 | + password_button_.SetFocus(); | |
399 | + } | |
400 | + break; | |
401 | + } | |
402 | + case IDC_PAY_BUTTON_PAY: | |
403 | + { | |
404 | + OnBnClickedPayButtonPay(); | |
405 | + break; | |
406 | + } | |
407 | + case IDC_PAY_BUTTON_CLOSE: | |
408 | + { | |
409 | + OnBnClickedPayButtonClose(); | |
410 | + break; | |
411 | + } | |
412 | + | |
413 | + } | |
414 | + | |
415 | +} | ... | ... |
central_clearing_system/ETradeClient/mfc_ui/pay_dlg.h
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.cpp
... | ... | @@ -100,7 +100,8 @@ BOOL PlaceOrderDlg::OnInitDialog() |
100 | 100 | InitList(); |
101 | 101 | |
102 | 102 | acce_ = LoadAccelerators(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDR_ACCELERATOR_ORDER)); |
103 | - | |
103 | + | |
104 | + swip_card_button_.SetFocus(); | |
104 | 105 | return FALSE; // return TRUE unless you set the focus to a control |
105 | 106 | // 异常: OCX 属性页应返回 FALSE |
106 | 107 | } |
... | ... | @@ -594,109 +595,121 @@ int PlaceOrderDlg::GetCommIndex() |
594 | 595 | |
595 | 596 | void PlaceOrderDlg::OnAcceleratorEnter() |
596 | 597 | { |
597 | - OnEditKillFocus(IDC_EDIT_CARD, NULL); | |
598 | - OnEditKillFocus(IDC_EDIT_COMM_NUM, NULL); | |
599 | - OnEditKillFocus(IDC_EDIT_UNIT, NULL); | |
600 | - OnEditKillFocus(IDC_EDIT_HEAVY, NULL); | |
601 | - OnEditKillFocus(IDC_EDIT_PRICE, NULL); | |
602 | - OnEditKillFocus(IDC_EDIT_COUNT, NULL); | |
598 | + int item_id = GetFocus()->GetDlgCtrlID(); | |
599 | + if (item_id == IDC_BUTTON_SWIP_CARD) | |
600 | + { | |
601 | + OnBnClickedButtonSwipCard(); | |
602 | + } | |
603 | + else if (item_id == IDC_EDIT_COUNT) | |
604 | + { | |
605 | + OnEditKillFocus(IDC_EDIT_CARD, NULL); | |
606 | + OnEditKillFocus(IDC_EDIT_COMM_NUM, NULL); | |
607 | + OnEditKillFocus(IDC_EDIT_UNIT, NULL); | |
608 | + OnEditKillFocus(IDC_EDIT_HEAVY, NULL); | |
609 | + OnEditKillFocus(IDC_EDIT_PRICE, NULL); | |
610 | + OnEditKillFocus(IDC_EDIT_COUNT, NULL); | |
603 | 611 | |
604 | - card_edit_.SetFocus(); | |
612 | + card_edit_.SetFocus(); | |
605 | 613 | |
606 | - do | |
607 | - { | |
608 | - if (card_edit_.IsEditRed() || comm_num_edit_.IsEditRed() || | |
609 | - unit_edit_.IsEditRed() || (heavy_edit_.IsWindowEnabled() && heavy_edit_.IsEditRed()) || | |
610 | - price_edit_.IsEditRed() || count_edit_.IsEditRed()) | |
614 | + do | |
611 | 615 | { |
612 | - break; | |
613 | - } | |
614 | - | |
615 | - CString text; | |
616 | - double price = 0, count = 0; | |
617 | - card_edit_.GetWindowText(text); | |
618 | - CommInfo comm; | |
619 | - comm.comm_id = GetCommIndex(); | |
620 | - comm.seller_card = text; | |
621 | - text.Empty(); | |
622 | - name_edit_.GetWindowText(text); | |
623 | - comm.seller_name = text; | |
624 | - text.Empty(); | |
625 | - comm_name_edit_.GetWindowText(text); | |
626 | - comm.comm_name = text; | |
627 | - comm.product_id = product_id_; | |
628 | - text.Empty(); | |
629 | - price_edit_.GetWindowText(text); | |
630 | - price = _ttof(text); | |
631 | - comm.price = text; | |
632 | - text.Empty(); | |
633 | - count_edit_.GetWindowText(text); | |
634 | - count = _ttof(text); | |
635 | - comm.count = text; | |
636 | - text.Empty(); | |
637 | - real_unit_static.GetWindowText(text); | |
638 | - comm.unit = text; | |
639 | - text.Empty(); | |
640 | - heavy_edit_.GetWindowText(text); | |
641 | - comm.weight = text; | |
642 | - text.Empty(); | |
643 | - | |
644 | - double money = price * count * 100; | |
645 | - money = std::round(money) / 100; | |
646 | - | |
647 | - text.Format(_T("%.2f"), money); | |
648 | - comm.total_money = text; | |
649 | - comm_vec_.push_back(comm); | |
650 | - | |
651 | - product_list_.DeleteAllItems(); | |
616 | + if (card_edit_.IsEditRed() || comm_num_edit_.IsEditRed() || | |
617 | + unit_edit_.IsEditRed() || (heavy_edit_.IsWindowEnabled() && heavy_edit_.IsEditRed()) || | |
618 | + price_edit_.IsEditRed() || count_edit_.IsEditRed()) | |
619 | + { | |
620 | + break; | |
621 | + } | |
652 | 622 | |
653 | - InitList(); | |
623 | + CString text; | |
624 | + double price = 0, count = 0; | |
625 | + card_edit_.GetWindowText(text); | |
626 | + CommInfo comm; | |
627 | + comm.comm_id = GetCommIndex(); | |
628 | + comm.seller_card = text; | |
629 | + text.Empty(); | |
630 | + name_edit_.GetWindowText(text); | |
631 | + comm.seller_name = text; | |
632 | + text.Empty(); | |
633 | + comm_name_edit_.GetWindowText(text); | |
634 | + comm.comm_name = text; | |
635 | + comm.product_id = product_id_; | |
636 | + text.Empty(); | |
637 | + price_edit_.GetWindowText(text); | |
638 | + price = _ttof(text); | |
639 | + comm.price = text; | |
640 | + text.Empty(); | |
641 | + count_edit_.GetWindowText(text); | |
642 | + count = _ttof(text); | |
643 | + comm.count = text; | |
644 | + text.Empty(); | |
645 | + real_unit_static.GetWindowText(text); | |
646 | + comm.unit = text; | |
647 | + text.Empty(); | |
648 | + heavy_edit_.GetWindowText(text); | |
649 | + comm.weight = text; | |
650 | + text.Empty(); | |
651 | + | |
652 | + double money = price * count * 100; | |
653 | + money = std::round(money) / 100; | |
654 | + | |
655 | + text.Format(_T("%.2f"), money); | |
656 | + comm.total_money = text; | |
657 | + comm_vec_.push_back(comm); | |
658 | + | |
659 | + product_list_.DeleteAllItems(); | |
660 | + | |
661 | + InitList(); | |
662 | + | |
663 | + for (int index = 0; index != comm_vec_.size(); ++index) | |
664 | + { | |
665 | + int row_index = product_list_.InsertRow(L"", -1); | |
666 | + product_list_.SetItemText(row_index, 0, comm_vec_[index].seller_card, comm_vec_[index].comm_id); | |
667 | + product_list_.SetItemText(row_index, 1, comm_vec_[index].seller_name, comm_vec_[index].comm_id); | |
668 | + product_list_.SetItemText(row_index, 2, comm_vec_[index].comm_name, comm_vec_[index].comm_id, comm_vec_[index].product_id); | |
669 | + product_list_.SetItemText(row_index, 3, comm_vec_[index].price, comm_vec_[index].comm_id); | |
670 | + product_list_.SetItemText(row_index, 4, comm_vec_[index].count, comm_vec_[index].comm_id); | |
671 | + product_list_.SetItemText(row_index, 5, comm_vec_[index].unit, comm_vec_[index].comm_id); | |
672 | + product_list_.SetItemText(row_index, 6, comm_vec_[index].weight, comm_vec_[index].comm_id); | |
673 | + product_list_.SetItemText(row_index, 7, comm_vec_[index].total_money, comm_vec_[index].comm_id); | |
674 | + for (int index = 0; index < 8; ++index) | |
675 | + { | |
676 | + product_list_.SetItemFormat(row_index, index, DT_CENTER | DT_VCENTER | DT_SINGLELINE); | |
677 | + } | |
678 | + } | |
654 | 679 | |
655 | - for (int index = 0; index != comm_vec_.size(); ++index) | |
656 | - { | |
657 | - int row_index = product_list_.InsertRow(L"", -1); | |
658 | - product_list_.SetItemText(row_index, 0, comm_vec_[index].seller_card, comm_vec_[index].comm_id); | |
659 | - product_list_.SetItemText(row_index, 1, comm_vec_[index].seller_name, comm_vec_[index].comm_id); | |
660 | - product_list_.SetItemText(row_index, 2, comm_vec_[index].comm_name, comm_vec_[index].comm_id, comm_vec_[index].product_id); | |
661 | - product_list_.SetItemText(row_index, 3, comm_vec_[index].price, comm_vec_[index].comm_id); | |
662 | - product_list_.SetItemText(row_index, 4, comm_vec_[index].count, comm_vec_[index].comm_id); | |
663 | - product_list_.SetItemText(row_index, 5, comm_vec_[index].unit, comm_vec_[index].comm_id); | |
664 | - product_list_.SetItemText(row_index, 6, comm_vec_[index].weight, comm_vec_[index].comm_id); | |
665 | - product_list_.SetItemText(row_index, 7, comm_vec_[index].total_money, comm_vec_[index].comm_id); | |
666 | - for (int index = 0; index < 8; ++index) | |
680 | + EmptyCtrl(false); | |
681 | + SortList(); | |
682 | + | |
683 | + CString subtotal; | |
684 | + double total_price = 0; | |
685 | + int list_count = product_list_.GetRowCount(); | |
686 | + for (int index = 1; index <= list_count; ++index) | |
667 | 687 | { |
668 | - product_list_.SetItemFormat(row_index, index, DT_CENTER | DT_VCENTER | DT_SINGLELINE); | |
688 | + subtotal = product_list_.GetItemText(index, 7); | |
689 | + total_price += _ttof(subtotal); | |
669 | 690 | } |
670 | - } | |
671 | - | |
672 | - EmptyCtrl(false); | |
673 | - SortList(); | |
674 | 691 | |
675 | - CString subtotal; | |
676 | - double total_price = 0; | |
677 | - int list_count = product_list_.GetRowCount(); | |
678 | - for (int index = 1; index <= list_count; ++index) | |
679 | - { | |
680 | - subtotal = product_list_.GetItemText(index, 7); | |
681 | - total_price += _ttof(subtotal); | |
682 | - } | |
692 | + CString total_price_s; | |
693 | + total_price_s.Format(L"%.2f", total_price); | |
694 | + total_real_money_static_.SetWindowText(total_price_s); | |
683 | 695 | |
684 | - CString total_price_s; | |
685 | - total_price_s.Format(L"%.2f", total_price); | |
686 | - total_real_money_static_.SetWindowText(total_price_s); | |
696 | + } while (0); | |
687 | 697 | |
688 | - } while (0); | |
689 | - | |
690 | - if (product_list_.GetRowCount() > 1) | |
691 | - { | |
692 | - pay_button_.EnableWindow(TRUE); | |
698 | + if (product_list_.GetRowCount() > 1) | |
699 | + { | |
700 | + pay_button_.EnableWindow(TRUE); | |
701 | + } | |
702 | + else | |
703 | + { | |
704 | + pay_button_.EnableWindow(FALSE); | |
705 | + } | |
706 | + product_list_.Invalidate(TRUE); | |
707 | + UpdateWindow(); | |
693 | 708 | } |
694 | 709 | else |
695 | 710 | { |
696 | - pay_button_.EnableWindow(FALSE); | |
711 | + OnAcceleratorDown(); | |
697 | 712 | } |
698 | - product_list_.Invalidate(TRUE); | |
699 | - UpdateWindow(); | |
700 | 713 | } |
701 | 714 | |
702 | 715 | |
... | ... | @@ -715,6 +728,8 @@ void PlaceOrderDlg::SetCtrlInitData() |
715 | 728 | |
716 | 729 | card_edit_.SetFocus(); |
717 | 730 | card_edit_.SetSel(4, 4); |
731 | + | |
732 | + unit_edit_.SetWindowText(L"1"); | |
718 | 733 | heavy_edit_.EnableWindow(FALSE); |
719 | 734 | pay_button_.EnableWindow(FALSE); |
720 | 735 | } |
... | ... | @@ -871,6 +886,10 @@ LRESULT PlaceOrderDlg::OnEditKillFocus(WPARAM wParam, LPARAM lParam) |
871 | 886 | SetErrorMsg(CString(L"错误信息:库存不足")); |
872 | 887 | ((CEditBox*)GetDlgItem(dlg_id))->SetEditRed(true); |
873 | 888 | } |
889 | + else | |
890 | + { | |
891 | + ((CEditBox*)GetDlgItem(dlg_id))->SetEditRed(false); | |
892 | + } | |
874 | 893 | } |
875 | 894 | else |
876 | 895 | { |
... | ... | @@ -1101,6 +1120,7 @@ void PlaceOrderDlg::OnAcceleratorDown() |
1101 | 1120 | case IDC_EDIT_COMM_NUM: |
1102 | 1121 | { |
1103 | 1122 | unit_edit_.SetFocus(); |
1123 | + unit_edit_.SetSel(0, -1); | |
1104 | 1124 | break; |
1105 | 1125 | } |
1106 | 1126 | case IDC_EDIT_UNIT: |
... | ... | @@ -1144,26 +1164,39 @@ void PlaceOrderDlg::OnAcceleratorUp() |
1144 | 1164 | case IDC_EDIT_COUNT: |
1145 | 1165 | { |
1146 | 1166 | price_edit_.SetFocus(); |
1167 | + price_edit_.SetSel(0, -1); | |
1147 | 1168 | break; |
1148 | 1169 | } |
1149 | 1170 | case IDC_EDIT_PRICE: |
1150 | 1171 | { |
1151 | - heavy_edit_.IsWindowEnabled() ? heavy_edit_.SetFocus() : unit_edit_.SetFocus(); | |
1172 | + if (heavy_edit_.IsWindowEnabled()) | |
1173 | + { | |
1174 | + heavy_edit_.SetFocus(); | |
1175 | + heavy_edit_.SetSel(0, -1); | |
1176 | + } | |
1177 | + else | |
1178 | + { | |
1179 | + unit_edit_.SetFocus(); | |
1180 | + unit_edit_.SetSel(0, -1); | |
1181 | + } | |
1152 | 1182 | break; |
1153 | 1183 | } |
1154 | 1184 | case IDC_EDIT_HEAVY: |
1155 | 1185 | { |
1156 | 1186 | unit_edit_.SetFocus(); |
1187 | + unit_edit_.SetSel(0, -1); | |
1157 | 1188 | break; |
1158 | 1189 | } |
1159 | 1190 | case IDC_EDIT_UNIT: |
1160 | 1191 | { |
1161 | 1192 | comm_num_edit_.SetFocus(); |
1193 | + comm_num_edit_.SetSel(0, -1); | |
1162 | 1194 | break; |
1163 | 1195 | } |
1164 | 1196 | case IDC_EDIT_COMM_NUM: |
1165 | 1197 | { |
1166 | 1198 | card_edit_.SetFocus(); |
1199 | + card_edit_.SetSel(0, -1); | |
1167 | 1200 | break; |
1168 | 1201 | } |
1169 | 1202 | } |
... | ... | @@ -1238,7 +1271,7 @@ void PlaceOrderDlg::EmptyCtrl(bool is_empty_buyer) |
1238 | 1271 | name_edit_.SetWindowText(L""); |
1239 | 1272 | comm_num_edit_.SetWindowText(L""); |
1240 | 1273 | comm_name_edit_.SetWindowText(L""); |
1241 | - unit_edit_.SetWindowText(L"");; | |
1274 | + unit_edit_.SetWindowText(L"1");; | |
1242 | 1275 | real_unit_static.SetWindowText(L"斤"); |
1243 | 1276 | heavy_edit_.SetWindowText(L""); |
1244 | 1277 | heavy_edit_.EnableWindow(FALSE); |
... | ... | @@ -1348,7 +1381,7 @@ void PlaceOrderDlg::EnableCtrl(bool is_enable) |
1348 | 1381 | name_edit_.SetWindowTextW(L""); |
1349 | 1382 | comm_num_edit_.SetWindowTextW(L""); |
1350 | 1383 | comm_name_edit_.SetWindowTextW(L""); |
1351 | - unit_edit_.SetWindowTextW(L""); | |
1384 | + unit_edit_.SetWindowTextW(L"1"); | |
1352 | 1385 | price_edit_.SetWindowTextW(L""); |
1353 | 1386 | count_edit_.SetWindowTextW(L""); |
1354 | 1387 | } | ... | ... |
central_clearing_system/ETradeClient/mfc_ui/place_order_dlg.h
... | ... | @@ -107,7 +107,6 @@ private: |
107 | 107 | CStatic buyer_static_; |
108 | 108 | CEditBox buyer_card_edit_; |
109 | 109 | CEditBox buyer_name_edit_; |
110 | - CButton swip_card_button_; | |
111 | 110 | |
112 | 111 | CPen line_pen_; |
113 | 112 | CPoint line_point_[3]; |
... | ... | @@ -121,4 +120,7 @@ private: |
121 | 120 | |
122 | 121 | std::vector<CommInfo> comm_vec_; |
123 | 122 | int comm_id_index_; |
123 | + | |
124 | +public: | |
125 | + CButton swip_card_button_; | |
124 | 126 | }; | ... | ... |
central_clearing_system/Resource.h
... | ... | @@ -91,6 +91,8 @@ |
91 | 91 | #define ID_ACCELERATOR_ALT_S 32884 |
92 | 92 | #define ID_ACCELERATOR_F 32886 |
93 | 93 | #define ID_ACCELERATOR_X 32887 |
94 | +#define ID_ACCELERATOR_A 32895 | |
95 | +#define ID_ACCELERATOR32896 32896 | |
94 | 96 | #define ID_POINT_RULE 40001 |
95 | 97 | #define ID_CATEGORY_RULE 40002 |
96 | 98 | #define ID_AGREEMENT 40003 |
... | ... | @@ -106,7 +108,7 @@ |
106 | 108 | #ifdef APSTUDIO_INVOKED |
107 | 109 | #ifndef APSTUDIO_READONLY_SYMBOLS |
108 | 110 | #define _APS_NEXT_RESOURCE_VALUE 333 |
109 | -#define _APS_NEXT_COMMAND_VALUE 32895 | |
111 | +#define _APS_NEXT_COMMAND_VALUE 32898 | |
110 | 112 | #define _APS_NEXT_CONTROL_VALUE 1055 |
111 | 113 | #define _APS_NEXT_SYMED_VALUE 311 |
112 | 114 | #endif | ... | ... |