LiFan
2025-04-24 9b3b2eb20b09e13da837a28f16e552ba70a090c4
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
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
#include <wobject/xstring.hpp>
#include <xcontrol/xtreeview.hpp>
#include <xcontrol/xdwgrid.hpp>
 
#include "vbusiness/vframe/listwin.vframe.vbusiness.hpp"
#include "viewobject/view.base.hpp"
 
using xml = KXMLDOMDocument;
    class __declspec(dllexport) listvatnotifyWin : public xframe
    {
    public:
        xdwgrid    dw_list;
        xdwpages dw_pages;
        xdwtable dw_arg;
 
        xnode    m_agentNode;    //Agent Condition
 
        int     m_pageindex;
        int    m_pagenumber;
        xstring     m_QueryTxt;
        xstring DatePicker;
 
    public:
        listvatnotifyWin(void* implPtr, HWND hWnd) :xframe(implPtr, hWnd) {}
    public:
        static listvatnotifyWin* CreateInstance(void* implPtr, void* hWnd)
        {
            listvatnotifyWin* pWin = new listvatnotifyWin(implPtr, (HWND)hWnd);
            return pWin;
        }
        int SetAgent()
        {
            xstring xfNodeAgentArea = L"agentarea";
            xnode anode = GetAgentNode(xfNodeAgentArea);
            if (m_agentNode)
            {
                SetAgentNode(anode, m_agentNode);
            }
            else
            {
                KXMLDOMElement xframeElement = GetElement();
                KXMLDOMElement agent = xframeElement.selectSingleNode(L"agent/" + xfNodeAgentArea + L"[1]/*");
                if (agent)
                {
                    xstring s = agent.xml();
                    m_agentNode = SetAgentNode(anode, s);
                }
            }
            return 1;
        }
 
        //½¹µã¼¤»î´¦Àíº¯Êý
        int OnSetFocus(TEvent* evt, LPARAM param)
        {
            //ÖØÖù¤¾ßÌõ
            SetAgent();
            return 1;
        }
 
        int OnDWClick(TEvent* evt, LPARAM p)
        {
            DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
            xstring value = hdr.data;
            xstring colname = hdr.colname;
            int row = hdr.row;
 
            if (row < 1) return 1;
 
            xaserverarg arg;
            if (colname == L"SONo")
            {
                xstring SONo = dw_list.GetItemString(row, colname.c_str());
                
                arg.AddArg(L"EntityNo", SONo);
                arg.AddArg(L"ReadOnly", L"true");
                OpenWindow(L"dev:xpage[base.maint.so.vx]", arg);
            }
            if (colname == L"InvoiceNo")
            {
                xstring InvoiceNo = dw_list.GetItemString(row, colname.c_str());
                
                arg.AddArg(L"EntityNo", InvoiceNo);
                arg.AddArg(L"ReadOnly", L"true");
                OpenWindow(L"dev:xpage[maintex.GDN3.vx]", arg);
            }
            return 1;
        }
 
        int OnPrint()
        {
            xaserverarg arg ;
            
            arg.AddArg(L"EntityName", L"VATNotify");
            arg.AddArg(L"EntityID", L"", L"");
            xstring InvoiceNo = dw_list.GetItemString(dw_list.GetRow(), L"NInvoiceNo");
            if (InvoiceNo == L"") InvoiceNo = dw_list.GetItemString(dw_list.GetRow(), L"InvoiceNo");
 
            xstring NInvoiceNoEx = dw_list.GetItemString(dw_list.GetRow(), L"NInvoiceNo");
            xstring InvoiceNoEx = dw_list.GetItemString(dw_list.GetRow(), L"InvoiceNo");
            xstring SupplierName = dw_list.GetItemString(dw_list.GetRow(), L"ShortName");
            if (NInvoiceNoEx != InvoiceNoEx)
            {
                NInvoiceNoEx = InvoiceNoEx;
            }
            xstring SupplierID = dw_list.GetItemString(dw_list.GetRow(), L"SupplierID");
            arg.AddArg(L"EntityNo", InvoiceNo, L"");
            arg.AddArg(L"EntityNoEx", NInvoiceNoEx, L"");
            arg.AddArg(L"SupplierID", SupplierID);
            arg.AddArg(L"VATNotifyID", L"");
            arg.AddArg(L"SupplierName", SupplierName);
            trace(InvoiceNo + L"==1" + NInvoiceNoEx + L"==2" + SupplierID + L"==3" + dw_list.GetGuid(dw_list.GetRow()));
            
            openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", arg);
            return 1;
        }
 
        int OnPrintItem()
        {
            xaserverarg arg;
            
            arg.AddArg(L"EntityName", L"VATNotify");
            arg.AddArg(L"EntityID", L"", L"");
            xstring InvoiceNo = dw_list.GetItemString(dw_list.GetRow(), L"NInvoiceNo");
            if (InvoiceNo == L"") InvoiceNo = dw_list.GetItemString(dw_list.GetRow(), L"InvoiceNo");
 
            xstring NInvoiceNoEx = dw_list.GetItemString(dw_list.GetRow(), L"NInvoiceNo");
            xstring InvoiceNoEx = dw_list.GetItemString(dw_list.GetRow(), L"InvoiceNo");
            if (NInvoiceNoEx != InvoiceNoEx)
            {
                NInvoiceNoEx = InvoiceNoEx;
            }
            xstring SupplierID = dw_list.GetItemString(dw_list.GetRow(), L"SupplierID");
            xstring SupplierName = dw_list.GetItemString(dw_list.GetRow(), L"ShortName");
            arg.AddArg(L"EntityNo", InvoiceNo, L"");
            arg.AddArg(L"EntityNoEx", NInvoiceNoEx, L"");
            arg.AddArg(L"SupplierID", SupplierID);
            arg.AddArg(L"VATNotifyID", dw_list.GetGuid(dw_list.GetRow()));
            arg.AddArg(L"SupplierName", SupplierName);
            trace(L"=====L" + InvoiceNo + L"=====L" + SupplierID + L"=====L" + dw_list.GetGuid(dw_list.GetRow()));
            
            openUrl(L"/sale/view/view.base/xpage/Template/PrintViewEx", arg);
            return 1;
        }
 
        int OnOpen() {
            int row = dw_list.GetRow();
            if (row < 1) return 0;
            KXMLDOMElement ele = dw_list.GetRowElement(row);
            xstring entityid = ele.selectSingleNode(L"InvoiceNo").text();
            xaserverarg arg;
            
            arg.AddArg(L"invoiceno", entityid);
            
            OpenWindow(L"dev:xpage[simple.maint.vatnotify.vx]", arg);
            return 1;
        }
 
        int OnPapercardOpen() {
            int row = dw_list.GetRow();
            if (row < 1) return 0;
            KXMLDOMElement ele = dw_list.GetRowElement(row);
            xstring entityid = ele.selectSingleNode(L"InvoiceNo").text();
            xstring classifyID = ele.selectSingleNode(L"ClassifyID").text();
            xstring supplierID = ele.selectSingleNode(L"SupplierID").text();
            xstring cname = ele.selectSingleNode(L"CName").text();
 
            xaserverarg arg;
            
            arg.AddArg(L"invoiceno", entityid);
            arg.AddArg(L"ClassifyID", classifyID);
            arg.AddArg(L"SupplierID", supplierID);
            arg.AddArg(L"CName", cname);
            
            OpenWindow(L"dev:xpage[maint.papercard.vatnotify.vx]", arg);
            return 1;
        }
 
        int OnModify() {
            int row = dw_list.GetRow();
            if (row < 1) return 0;
            KXMLDOMElement ele = dw_list.GetRowElement(row);
            xstring entityid = ele.selectSingleNode(L"InvoiceNo").text();
            xaserverarg arg;
            
            arg.AddArg(L"invoiceno", entityid);
            
            OpenWindow(L"dev:xpage[update.vatnotify.vx]", arg);
            return 1;
        }
 
        int Onfinish() {
 
            return 1;
        }
 
        int OnDeleteRow()
        {
            if (dw_list.GetRow() < 1) return 1;
            int row = dw_list.GetRow();
            xstring InvoiceNo = dw_list.GetItemString(row, L"InvoiceNo");
            int res = MessageBox(GetHWND(), L"ÊÇ·ñÈ·ÈÏɾ³ý" + InvoiceNo + L"µÄ¿ªÆ±Í¨Öª?", L"Ìáʾ", 4);
            if (res == 6)
            {
                xml x = ViewObject::RetrieveData(L"/sale/data/VATNotify/entity/delete", L"invoiceno", InvoiceNo);
                if (!x)
                {
                    alert(L"ɾ³ý´íÎó");
                    return 1;
                }
                //dw_list.DeleteRow(row);
                alert(x.text());
                OnRetrieve(DatePicker);
            }
 
            return 1;
        }
 
        //ÃüÁî·¢²¼º¯Êý
        int OnCmdDispatch(xstring comdid)
        {
            if (comdid == L"xm:import") {
                OpenWindow(L"dev:xpage[import.vatnotify.vx]", 0);
            }
            if (comdid == L"action:bill.open") {
                OnOpen();
            }
            else if (comdid == L"xm:notify") {
                OnOpen();
            }
            else if (comdid == L"xm:papercardnotify") {
                OnPapercardOpen();
            }
            else if (comdid == L"xm:modify") {
                OnModify();
            }
            else if (comdid == L"xm:finish") {
                Onfinish();
            }
            else if (comdid == L"xm:ratecalc") {
 
            }
            else if (comdid == L"find")
            {
                m_QueryTxt = xcontrol(GetControl(L"txt")).GetText();
                return OnRetrieve(DatePicker);
            }
            else if (comdid == L"xmRefresh")
            {
                return OnRetrieve(DatePicker);
            }
            else if (comdid == L"xmDeleteRow")
            {
                return OnDeleteRow();
            }
            else if (comdid == L"xmPrint") {
                return OnPrint();
            }
            else if (comdid == L"xmPrintItem") {
                return OnPrintItem();
            }
            else if (comdid == L"xmSaveAs")
            {
                dw_list.SaveAs(L"");
                return 1;
            }
            return 0;
        }
 
        //ÃüÁî´¦Àíʼþ
        int OnXCommand(TEvent* evt, LPARAM param)
        {
            return OnCmdDispatch(evt->xcommand.pStrID);
        }
 
        int OnAttachEvent()
        {
            //°ó¶¨¹¤¾ßÌõµã»÷ʼþ
            AttachEvent(L"WM_XCOMMAND", (FEvent)&listvatnotifyWin::OnXCommand);
            //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
            AttachEvent(L"WM_SETFOCUS", (FEvent)&listvatnotifyWin::OnSetFocus);
            AttachEvent(L"dw_list", L"DWV_CLICKED", (FEvent)&listvatnotifyWin::OnDWClick);
            AttachEvent(L"cbx_state", L"CBN_SELCHANGE", (FEvent)&listvatnotifyWin::OnDatePicker);
            return 1;
        }
 
        int OnDatePicker(TEvent* evt, int lParam)
        {
            
            DWNMHDR& hdr = *(DWNMHDR*)evt->notify.pnmh;
 
            int h = xcombobox::GetCurSel(evt->command.hCtrl);
            if (h > -1)
            {
                xstring txt = (string)xcombobox::GetLBText(evt->command.hCtrl, h);
                if (txt == L"֪ͨÈÕÆÚ")
                {
 
                    DatePicker = L"NotifyDate";
                    OnRetrieve(DatePicker);
                }
                else if (txt == L"³öÔËÈÕÆÚ")
                {
 
                    DatePicker = L"ETD";
                    OnRetrieve(DatePicker);
                }
            }
            return 1;
        }
 
 
        xstring GetQueryArg()
        {
            dw_arg.AcceptText();
            xml x ;
            
            dw_arg.DwUpdateAllTo(x);
            return x.xml();
        }
 
        int  OnRetrieve(xstring DatePicker)
        {
            HCURSOR  hCursor = xutil::SetCursorWait();
            xml x ;
            
            xaserverarg arg;
            
            arg.AddArg(L"pageindex", xstring(m_pageindex));
            arg.AddArg(L"pagenumber", xstring(m_pagenumber));
            arg.AddArg(L"QueryTxt", m_QueryTxt);
            arg.AddArg(L"QueryArg", GetQueryArg());
            arg.AddArg(L"DatePicker", DatePicker);
            if (getUrl(L"/sale/data/VATNotify/entity/listOne", arg.GetString(), x) != 1)
            {
                trace(x.text());
                xutil::RestoreCursor(hCursor);
                return -1;
            }
            else
            {
                //trace(x.xml);
                KXMLDOMElement ele = x.documentElement();
                if (dw_pages.getNativePointer())
                {
                    if (ele.selectSingleNode(L"@TotalPage"))
                    {
                        xstring s = ele.selectSingleNode(L"@TotalPage").text(); //×ÜÊýÁ¿                
                        dw_pages.SetMaxPage(s.toInt());
                    }
                }
                dw_list.Retrieve(x);
                dw_list.Redraw();
                dw_list.SetReadOnly(true);
            }
            xutil::RestoreCursor(hCursor);
            return 1;
        }
 
        int OnChangePages(TEvent* evt, LPARAM p)
        {
            PAGENMHDR& h = *(PAGENMHDR*)evt->notify.pnmh;
            int c = h.cur;
            HCURSOR hCursor = xutil::SetCursorWait();
            m_pageindex = c;
            OnRetrieve(DatePicker);
            xutil::RestoreCursor(hCursor);
            return 1;
        }
 
        int OnDoubleClicked(TEvent* evt, LPARAM p)
        {
            HCURSOR hCursor = xutil::SetCursorWait();
            OnCmdDispatch(L"action:bill.open");
            xutil::RestoreCursor(hCursor);
            return 1;
        }
 
        int onload()
        {
            dw_list = GetControl(L"dw_list");
            dw_list.openUrl(L"/sale/view/VATNotify/template/VATNotify/list");
            dw_list.SetColumnState(L"ShortName", false);
 
            dw_arg = GetControl(L"dw_arg");
            dw_arg.openUrl(L"/sale/view/AR/template/queryarg");
            dw_arg.SetColHeaderHeight(0);
            dw_arg.SetRowSelectorWidth(0);
            dw_arg.SetHScrollState(false);
            dw_arg.SetVScrollState(false);
            dw_arg.SetItemString(1, L"DateType", L"±¾ÔÂ");
            //dw_arg.SetItemString(1,L"DateType",L"");
            AttachEvent(L"dw_list", L"DWV_DOUBLECLICKED", (FEvent)&listvatnotifyWin::OnDoubleClicked);//ÐÐË«»÷
            dw_pages = GetControl(L"pages");
            AttachEvent(L"pages", L"PAGE_CLICK", (FEvent)&listvatnotifyWin::OnChangePages);
 
 
            OnAttachEvent();
 
            return 1;
        }
 
        int onloaded()
        {
            SetAgent();
 
            m_pageindex = 1;
            m_pagenumber = 10000;
            m_QueryTxt = L"";
 
            //OnRetrieve();
 
            return 1;
        }
    };