xj qian
2024-06-27 e4b4c508c599943ddb22b7d4868ccd40ac05a043
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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
#include <xcontrol/xcell.hpp>
 
 
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
 
 
 
    class __declspec(dllexport) DeliveryEdit : public xframe
    {
    public:
        xdwtable    dw_1;
 
        vcontrol vc;
        xcell    dw_cell;
 
    public:
        DeliveryEdit(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
    public:
        static DeliveryEdit* CreateInstance(void* implPtr, void* hWnd)
        {
            DeliveryEdit* pWin = new DeliveryEdit(implPtr, (HWND)hWnd);
            return pWin;
        }
 
        xstring OnCreateTxt()
        {
            //dw_1.AcceptText(); //²»Äܼӻᱨ´í
            xstring sType;
            xstring sDeliveryRule;
            xstring sDeliveryDays;
            xstring sScheduleShipDate;
            xstring sTxt;
 
            sType = dw_1.GetItemString(1, L"DeliveryRule");
            sDeliveryRule = dw_1.GetItemDisplayString(1, L"DeliveryRule");
            sDeliveryDays = dw_1.GetItemString(1, L"DeliveryDays");
            sScheduleShipDate = dw_1.GetItemString(1, L"ScheduleShipDate");
 
            if (sType == L"1")
            {
                if (sDeliveryDays != L"")
                    sTxt = L"Shipment within " + sDeliveryDays + L" days after receipt of L/C.";
                else
                    sTxt = L"";
            }
            else if (sType == L"2")
            {
                if (sDeliveryDays != L"")
                    sTxt = L"Within " + sDeliveryDays + L" days after receiving the deposit.";
                else
                    sTxt = L"";
            }
            else if (sType == L"3")
                if (sDeliveryDays != L"")
                    sTxt = L"Within " + sDeliveryDays + L" days after receiving the signed P/I.";
                else
                    sTxt = L"";
            else if (sType == L"4")
            {
                if (sScheduleShipDate != L"")
                    sTxt = sScheduleShipDate;
                else
                    sTxt = L"";
            }
            else
                sTxt = L"";
 
            return sTxt;
        }
 
        int OnOk()
        {
            dw_1.AcceptText();
 
            CloseWindow();
 
            return 1;
        }
 
        int OnItemChanged(TEvent* evt, LPARAM p)
        {
            DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
            xstring colname = hdr.colname;
            xstring value = hdr.data;
 
            if (colname == L"DeliveryRule")
            {
                xstring sP = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='±£»¤' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial=''><edit edittype=''/></cellprop>";
                xstring sUp = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial=''><edit edittype=''/></cellprop>";
 
                if (value == L"1" || value == L"2" || value == L"3")
                {
                    dw_cell.SetCellProps(3, 3, sUp);
                    dw_cell.SetCellProps(4, 3, sP);
                }
                else if (value == L"4")
                {
                    dw_cell.SetCellProps(3, 3, sP);
                    dw_1.SetItemString(1, L"DeliveryDays", L"");
                }
                else
                {
                    dw_cell.SetCellProps(3, 3, sP);
                    dw_cell.SetCellProps(4, 3, sUp);
                    dw_1.SetItemString(1, L"DeliveryDays", L"");
                }
 
            }
 
            //Éú³É½»»õÆÚ
            if (colname == L"DeliveryRule" || colname == L"DeliveryDays" || colname == L"ScheduleShipDate")
            {
                xstring sTxt = OnCreateTxt();
                dw_1.SetItemString(1, L"DeliveryTime", sTxt);
            }
 
            return 1;
        }
 
        int OnCmdDispatch(xstring comdid)
        {
 
            if (comdid == L"xmOk") return OnOk();
 
            return 0;
        }
 
        int OnXCommand(TEvent* evt, LPARAM p)
        {
            
            return OnCmdDispatch(evt->xcommand.pStrID);
        }
 
        int OnAttachEvent()
        {
            AttachEvent(L"WM_XCOMMAND", (FEvent)&DeliveryEdit::OnXCommand);
            AttachEvent(L"dw_1", L"DWV_ITEMCHANGED", (FEvent)&DeliveryEdit::OnItemChanged);
 
            return 1;
        }
 
        int OnInit()
        {
            int iArgs = GetParam();
 
            XXmlContentSvr xdoc = new XXmlContentSvr;
            xdoc.setNativePointer(iArgs);
            vc = new vcontrol;
            vc.xdoc = xdoc;
 
            vbind bind = new vbind;
            bind.bind(dw_1, vc);
 
            xml x;
            x = new xml;
            x.setNativePointer(xml::CreateInstance());
            x.LoadXml(vc.GetContent());
 
            dw_1.Retrieve(x);
 
            xstring sDeliveryRule = dw_1.GetItemString(1, L"DeliveryRule");
            xstring sP = L"<cellprop searchcolumn='' celltype='' cellformatex='' cellformat='' cellprotectex='' cellprotect='±£»¤' cellvisibleex='' cellvisible='' cellneeddata='' cellvalid='' cellinitial=''><edit edittype=''/></cellprop>";
            if (sDeliveryRule != L"1" && sDeliveryRule != L"2" && sDeliveryRule != L"3")
                dw_cell.SetCellProps(3, 3, sP);
            if (sDeliveryRule != L"5")
                dw_cell.SetCellProps(4, 3, sP);
 
            return 1;
        }
 
        int onload()
        {
            dw_1 = GetControl(L"dw_1");
            dw_1.openUrl(L"/sale/view/SaleOrder/template/delivery"); //base.maint.so.tpl/delivery
            dw_1.SetColHeaderHeight(0);
            dw_1.SetRowSelectorWidth(0);
            dw_1.SetScrollState(false);
 
            dw_cell = new xcell;
            dw_cell.setNativePointer(dw_1.QueryItem(L"ixcell"));
            OnAttachEvent();
 
            if (GetParam())OnInit();
 
            return 1;
        }
    };