LiFan
2024-07-22 aecae8e9fa34b6307fb1b0e5478a69962d5ddd72
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
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
ÿþuse "xcontrol.vframe.vbusiness.vd"
use "xbase.vframe.vbusiness.vd"
use "base.view.vd"
use "publiccode.vutil.vbusiness.vd"
 
unit trade
[
    namespace _excel for ole "Excel.Application,{00020813-0000-0000-C000-000000000046}";
 
    class cexcel : public xnative native from "XControl.dll"
    {
        void Release(int t) alias "?Release@CExcelApplication@@QAEXPAV1@@Z";
        static int CreateInstance() alias "?CreateInstance@CExcelApplication@@SAPAV1@XZ";
        void put_Visible(bool t) alias "?put_Visible@CExcelApplication@@QAEXH@Z";
        bool get_Visible() alias "?get_Visible@CExcelApplication@@QAEHXZ";
        void OpenDocument(const string filename) alias "?OpenDocument@CExcelApplication@@QAEXQA_W@Z";
        void TransShape() alias "?TransShape@CExcelApplication@@QAEXXZ";
        void SaveToFile(string filename) alias "?SaveToFile@CExcelApplication@@QAEXQA_W@Z";
        void Quit() alias "?Quit@CExcelApplication@@QAEXXZ";
    };
 
    struct OPENFILENAMEW
    {
       unsigned int    lStructSize;
       unsigned int   hwndOwner;
       unsigned int   hInstance;
       string                 lpstrFilter;
       
       string               lpstrCustomFilter;
       unsigned int   nMaxCustFilter;
       unsigned int        nFilterIndex;
       string                    lpstrFile;
       
       unsigned int        nMaxFile;
       string                    lpstrFileTitle;
       unsigned int        nMaxFileTitle;
       string      lpstrInitialDir;
       
       string      lpstrTitle;
       unsigned int        Flags;
       unsigned short         nFileOffset;
       unsigned short         nFileExtension;
       string      lpstrDefExt;
       
       unsigned int       lCustData;
       unsigned int lpfnHook;
       string      lpTemplateName;
       
        //_WIN32_WINNT >= 0x0500
       unsigned int         pvReserved;
       unsigned int        dwReserved;
       unsigned int        FlagsEx;
        // (_WIN32_WINNT >= 0x0500)
    };
    
    class Exporter
    {
        cexcel   excel;
 
        
        static stdcall int GetModuleFileName(int hModule ,string lpFileName ,int nSize ) native from "kernel32.dll" alias "GetModuleFileNameW";
        static stdcall int PathRemoveFileSpec(string lpFileName ) native from "shlwapi.dll" alias "PathRemoveFileSpecW";
        static stdcall int DeleteFile(string lpFileName) native from "kernel32.dll" alias "DeleteFileW";    
        static stdcall bool GetSaveFileName(ref OPENFILENAMEW)native from "comdlg32.dll" alias "GetSaveFileNameW"; 
 
        string GetModulePath()
        {
            string str ="";
            str = str.space(255);
            GetModuleFileName(0,str,250);
            PathRemoveFileSpec(str);
            return str;
        }
        string GetModuleTmpPath()
        {
            string str ="";
            str = str.space(255);
            GetModuleFileName(0,str,250);
            PathRemoveFileSpec(str);
            string tmp = str + "\\Temp";
            xaserver::CreateDirectory(tmp);
            return tmp;
        }
        
        string GetSaveFileName(string initFileName, string filter, string ext)
        {
            char[]  szFileName = new char[255] ;
            char[]  szPath =  new char[255];
            szFileName[0] = 0;
            szPath[0] = 0;
            
            if(initFileName !="")
            {
                int len = initFileName.length();
                char[] tmp = initFileName;
                for(int i=0; i<len+1;i++)
                {
                    //szFileName[i] = tmp[i];
                    szPath[i] = tmp[i];
                }
            }
            
            int     nFilterIndex = 1;
            ref OPENFILENAMEW ofn = new OPENFILENAMEW;
 
            ofn.lStructSize = 88;//sizeof(ofn);
            ofn.hwndOwner = 0;
            ofn.hInstance = 0;
            ofn.lpstrFilter = filter;
                //"JPEG ‡eöN(*.jpg)\0*.jpg;*.jpeg;*.png;*.gif;*.bmp\0hQ萇eöN(*.*)\0*.*\0";
            ofn.lpstrCustomFilter = 0;
            ofn.nMaxCustFilter = 0;
            ofn.nFilterIndex = nFilterIndex;
            ofn.lpstrFile = szPath;
            ofn.nMaxFile = 255;
            ofn.lpstrFileTitle = szFileName;
            ofn.nMaxFileTitle = 255;
            ofn.lpstrTitle = "÷‹cš[‡eöN T";
            ofn.lpstrDefExt = ext; 
                //"jpg";
            ofn.lpstrInitialDir = 0;
            ofn.Flags = 0x00000010/*OFN_SHOWHELP*/ | 0x00001000/*OFN_FILEMUSTEXIST*/;
            ofn.lCustData = 0;
            ofn.lpfnHook = 0;
            ofn.lpTemplateName = 0;
 
            //debugbreak();
            if(GetSaveFileName(ofn))
            {
                delete ofn;
                return szPath;
            }
            else
            {
                return "";
            }
        }
        
        string getfilePath()
        {
            string path=GetModulePath()+"\\resource\\image";        
            return path;
        }
            
        int OnExport(int hWnd,string htmlStr)
        {
            string pre ="–™!kúQ'°eÁTß~¡‹hˆ";
            string file =  GetSaveFileName(pre+".xlsx",
                "Excel‡eöN(*.xlsx)\0*.xlsx;*.xls\0Excel97‡eöN(*.xls)\0*.xls\0PDF‡eöN(*.pdf)\0*.pdf\0",
                "xlsx");
            if(file =="") return 1;
            
            if(win32::PathFileExists(file))
            {
                int res = win32::MessageBox(hWnd, "‡eöNò]Ï~X[(W ÿ/f&T†‰Öv?","Ðc:y",4);
                if(res != 6) return 1;
            }
            
            xutil::SaveToFile(file, htmlStr,"","","");
            
            return 1;
            
            trace("\r\n link excel");
            excel = new cexcel;
            int hexcel = cexcel::CreateInstance();
            excel.setNativePointer(hexcel);
            if(hexcel == 0)
            {
                win32::alert(" Ný€Þ¥cExcel");
                return 1;
            }
 
            string gid =  publiccode::GetGuid();
            string filename= pre+"_.htm";
            xutil::SaveToFile(GetModuleTmpPath() + "\\"+ filename, htmlStr,"","","");
            trace("\r\n excel to open");
            excel .OpenDocument(GetModuleTmpPath() + "\\"+ filename);
            trace("\r\n trans shape");
            //excel .put_Visible(true);
            //excel.TransShape();
            trace("\r\n save to tmp excel file");
            if(file.find(".xls"))
            {
                if(win32::PathFileExists(GetModuleTmpPath() + "\\"+ pre+"_.xls"))
                    DeleteFile(GetModuleTmpPath() + "\\"+ pre+"_.xls");
                excel.SaveToFile(GetModuleTmpPath() + "\\"+ pre+"_.xls");
                //alert(GetModuleTmpPath() + "\\"+ pre+m_EntityNo+"_.xls");
            }
            else 
            {
                if(win32::PathFileExists(GetModuleTmpPath() + "\\"+ pre+"_.xlsx"))
                    DeleteFile(GetModuleTmpPath() + "\\"+ pre+"_.xlsx");
                excel.SaveToFile(GetModuleTmpPath() + "\\"+ pre+"_.xlsx");
            }
            
            trace("\r\n save to excel file");
            if(win32::PathFileExists(file)) //GetModuleTmpPath() + "\\"+ pre+m_EntityNo+"_.xlsx"))
                DeleteFile(file);
            excel.SaveToFile(file);
            
            excel.Quit();
            excel.Release(excel.ptr_native_);
            return 1;
        }
            
        int OntoExcel(string htmlStr ) //l:NExcel
        {
            excel = new cexcel;
            excel.setNativePointer(cexcel::CreateInstance());
            
            string gid =  publiccode::GetGuid();
            string pre = "–™!kúQ'°eÁTß~¡‹hˆ";
            string filename= pre+".htm";
            string filenameex= pre+".xlsx";
            xutil::SaveToFile(GetModuleTmpPath() + "\\"+ filename, htmlStr,"","","");
            excel .OpenDocument(GetModuleTmpPath() + "\\"+ filename);
            //excel.put_Visible(true);
            //excel.TransShape();
            if(win32::PathFileExists(GetModuleTmpPath() + "\\"+ filenameex))
                DeleteFile(GetModuleTmpPath() + "\\"+ filenameex);
            excel.SaveToFile(GetModuleTmpPath() + "\\"+ filenameex);
            excel.put_Visible(true);
 
            excel.Release(excel.ptr_native_);
            return 1;
        }
            
        string replaceInnerElement(string html)
        {
            string str = html;
            if(str.find("[$element:")<0) return str;
            
            int len = 0;
            int pos = 0;
            int pos1 = 0;
            string pre="";
            string left="";
            string right="";
            string tag="";
            
            len = "[$element:".length();
            while(true)
            {
                pos = str.find("[$element:");
                if(pos < 0) break;
                left = str.left(pos);
                right = str.mid(pos+ len,999999);
                
                pos1 = right.find("]");
                if(pos1>=0)
                {
                    tag = right.left(pos1);
                    if(tag.right(1)=="$") tag=tag.left(tag.length() - 1);
                    pre = pre + left + "<" + tag +">";
                    str = right.mid(pos1+ 1,999999);
                }else
                {
                    pre = pre + left+"<";
                    str = right;
                }
            }
            
            str = pre + str;
            pre = "";
            len = "[/$element:".length();
            while(true)
            {
                pos = str.find("[/$element:");
                if(pos < 0) break;
                left = str.left(pos);
                right = str.mid(pos+ len,999999);
                pos1 = right.find("]");
                if(pos1>=0)
                {
                    tag = right.left(pos1);
                    if(tag.right(1)=="$") tag=tag.left(tag.length() - 1);
                    pre = pre + left + "</" + tag +">";
                    str = right.mid(pos1+ 1,999999);
                }else
                {
                    pre = pre + left+"</";
                    str = right;
                }
            }
            str  = pre + str;
            return str;
        }
 
        string adjustXsl(string str,string localPath)
        {
            //if(str.find("%")>=0)  str = str.replace("%","");
            if(str.find("[$path]/rpttemplate")>=0) str = str.replace("[$path]/rpttemplate",localPath);
            str = replaceInnerElement(str);
            return str;
        }
            
        string DownLoadSKUNoPic(string serverUrl,string SKUNo,string CustomerID,string CustomerItemNo)
        {
            xml x = new xml;
            x.setNativePointer(xml::CreateInstance());
            xaserverarg arg = new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg("SKUNo",SKUNo);
            trace("\n\t*******"+SKUNo+"*******"+CustomerID+"*******"+CustomerItemNo);
            
            string src ="/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo";
            if(CustomerID !="")
            {
                arg.AddArg("CustomerID",CustomerID);
                arg.AddArg("CustomerItemNo",CustomerItemNo);
                src ="/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKUNo";
            }
            //trace("SKUNo="+SKUNo);//‰    gU\:yþVGrågâ‹agöN…QÅ_š[‰skuno
            if(url::get(src,arg.GetString(),x)!=1)
            {
                trace("error for download skuno pic!");
                return "";
            }
            
            string spath = "";
            string path =GetModuleTmpPath();
            string ext = "jpg";
            if(x.GetXmlDoc().selectSingleNode("//FileExt[1]"))
            {
                ext = x.GetXmlDoc().selectSingleNode("//FileExt[1]").text;
            }else if(CustomerID !="")
            {
                src ="/sale/data/ProductLibrary3/pref/picture/imagelistSKUNo";
                if(url::get(src,arg.GetString(),x)!=1)
                {
                    trace("error for download skuno pic!");
                    return "";
                }
                if(x.GetXmlDoc().selectSingleNode("//FileExt[1]"))
                    ext = x.GetXmlDoc().selectSingleNode("//FileExt[1]").text;
            }
                
            string filename = SKUNo + "." + ext;
            if(x.GetXmlDoc().selectSingleNode("//PicPath[1]"))
                spath = x.GetXmlDoc().selectSingleNode("//PicPath[1]").text;
            if(spath != "")
            {
                 xaserver::DownLoadFile(serverUrl,spath,"",path+"/"+filename);
            }
            return "file://"+ path+"/"+filename;
        }
            
        string DownLoadPaperPic(string guid,string serverUrl)
        {
            
            string path =GetModuleTmpPath();
            string ext = "jpg";
            string filename = guid + "." + ext;
            string str = guid.mid(0,2);
            string spath = "/business/products/chanpin/"+str+"/"+guid+".jpg";
            xaserver::DownLoadFile(serverUrl,spath,"",path+"/"+filename);
            return "file://"+ path+"/"+filename;
        }
            
        string GetHtml(xdwgrid dw_obj, string xslPath,string serverUrl)
        {
            int hCursor = xutil::SetCursorWait();
 
            xml m_dataset = new xml;
            m_dataset .setNativePointer(xml::CreateInstance());
            dw_obj.DwUpdateAllTo(m_dataset.GetXmlDoc());
            
            string argstr = "<args><arg name='xsl' value='/business/"+xslPath+"' type=''/></args>";
            xml xsl = new xml;
            xsl.setNativePointer(xml::CreateInstance());
            if (url::get("/sale/data/SysPrintTemplate/getxsl",argstr ,xsl) != 1)
            {
                win32::alert("penc!jg•ï‹!");
                return "";
            }
            
            string xslStr = xsl.GetXml();
            xslStr = xslStr.replace("data/row","data");
            xslStr = xslStr.replace("//ÁT T1/ĉ<hy˜1","Item");
            
            string sdate = publiccode::GetCurrentDate();
            
            xslStr = xslStr.replace("<xsl:value-of select=\"CreateDate\"/>",sdate);
            xslStr = adjustXsl(xslStr,getfilePath());
                trace("-----"+xslStr+"-------");
            xsl.LoadXml(xslStr);
            
            string htmlStr = m_dataset.GetXmlDoc().transformNode(xsl.GetXmlDoc());
            
            string aspace = htmlStr.replace("[zz]","&nbsp;",0);
            aspace = aspace.replace("[line]","<br/>",0);
            string scontent = aspace.replace("<?xml version=\"1.0\"?>","",0);
            
            string head ="";
            string tail = scontent;
        
            int pos = tail.find("src=\"item-picture:");
            while(pos > 0)
            {
                int spos = pos+"src=\"item-picture:".length();
                int pos1 = tail.find("\"",spos+1);
                string skuno = tail.mid(spos,pos1 - spos ).trim();
                //string skunoEx="244E9FF3-BFBD-49CF-9437-887AD134AAF7,382846,C106792";
                string CustomerID="";
                string CustomerItemNo="";
                //trace("\n\t*******skunoEx:"+skunoEx);
                trace("\n\t*******skuno:"+skuno);
                if(skuno.find(",")>0)
                {
                    CustomerID = skuno.left(skuno.find(",")).trim();
                    skuno = skuno.mid(skuno.find(",")+1,256).trim();
                    trace("\n\t*******CustomerID:"+CustomerID);
                    trace("\n\t*******skuno:"+skuno);
                }
                if(skuno.find(",")>0)
                {
                    CustomerItemNo = skuno.left(skuno.find(",")).trim();
                    skuno = skuno.mid(skuno.find(",")+1,256).trim();
                    trace("\n\t*******CustomerItemNo:"+CustomerItemNo);
                    trace("\n\t*******skuno:"+skuno);
                }
                string src =  DownLoadSKUNoPic(serverUrl,skuno,CustomerID,CustomerItemNo);
                
                head += tail.left(pos) + "src=\"" + src;
                tail = tail.mid(pos1,999999999);
                pos = tail.find("src=\"item-picture:");
            }
            scontent = head + tail;
            
            head ="";
            tail = scontent;
            int position = tail.find("src=\"paper-picture:");
            while(position > 0)
            {
                int sposition = position+"src=\"paper-picture:".length();
                int position1 = tail.find("\"",sposition+1);
                string guid = tail.mid(sposition,position1 - sposition ).trim();
                string src2 =  DownLoadPaperPic(guid,serverUrl);
                head += tail.left(position) + "src=\"" + src2;
                tail = tail.mid(position1,999999999);
                position = tail.find("src=\"paper-picture:");
            }
            scontent = head + tail;
            
            //scontent = adjustXsl(scontent,sPath);
            htmlStr = scontent;
            
            
            /*
            string xcontent = htmlStr.replace("[zz]"," ",0);
            int pos0 = xcontent.find("<xml");
            int pos2 = xcontent.find("</xml>");
            if(pos0>=0) 
            {
                string str = xcontent.left(pos0)+ xcontent.mid(pos2+6,9999999);
                xcontent = str;
            }*/
            
            return htmlStr;
        }
    };
]
 
unit trade 
[
    class ShipmentNewSample3 :  public xframe
    {
        xdwgrid    dw_list;
        xdwtable dw_arg;
        xnode    m_agentNode;    //Agent Condition
 
        int SetAgent()
        {
            string xfNodeAgentArea  = "agentarea";
            xnode anode = GetAgentNode(xfNodeAgentArea);
            if(m_agentNode)
            {
                SetAgentNodeContent (anode,m_agentNode);
            }
            else
            {
                msxml::IXMLDOMElement xframeElement =  GetElement();
                msxml::IXMLDOMElement agent = xframeElement.selectSingleNode("agent/"+xfNodeAgentArea+"[1]/*");
                if(agent)
                {
                    string s = agent.xml;
                    m_agentNode =  SetAgentNodeContent (anode,s);
                }
            }
            return 1;
        }
 
        //&q¹pÀo;mYtýQpe
        int OnSetFocus(ref TEvent evt,int param)
        {
            //͑nå]wQag
            SetAgent();
            return 1;
        }
        
            
            
        int OnLookImage(string skuid,string CustomerID,string CustomerItemNo)
        {
            int hCursor = xutil::SetCursorWait();
            xaserverarg arg = ViewObject::MakeArg();
            arg.AddArg("guid",skuid);
            arg.AddArg("CustomerID",CustomerID);
            arg.AddArg("CustomerItemNo",CustomerItemNo);
            OpenWindow("dev:xpage[ViewPicturesEx.vx]",arg.getNativePointer());
            xutil::RestoreCursor(hCursor);
            return 1;
        }    
                    
        int OnPrint()
        {
            
            xaserverarg arg=new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());    
            arg.AddArg("EntityName","Quote","");
            arg.AddArg("EntityID","","");
            arg.AddArg("EntityNo","22JR0089","");
            int p = arg.ptr_native_;
            openUrl("/sale/view/view.base/xpage/Template/PrintViewEx", p);
            return 1;
        }
            
        //}TäNÑS^ýQpe
        int OnCmdDispatch(string comdid)
        {
            int hCursor =  0;
            if (comdid == "xmRefresh")
            {
                OnRetrieve();
            }
            if(comdid=="xmLookImage")
            {
                int row = dw_list.GetRow();
                string skuid =dw_list.GetGuid(row);
                string CustomerID =dw_list.GetItemString(row,"CustomerID");
                string CustomerItemNo =dw_list.GetItemString(row,"CustomerItemNo");
                OnLookImage(skuid,CustomerID,CustomerItemNo);
                return 1;
            }
            if(comdid=="xmAnalysis")
            {
                hCursor = xutil::SetCursorWait();
                string str = dw_list.DataAnalysis("");
                xaserverarg arg=new xaserverarg;
                arg.setNativePointer(arg.CreateInstance());                        
                arg.AddArg("html", str);
                int obj = cast(dw_list as int);
                arg.AddArg("obj",obj.toString());
                OpenWindow("dev:xpage[data.vanalysis.vx]", cast(arg as int));
                xutil::RestoreCursor(hCursor);
                return 1;
            }
            else if(comdid=="xmExcel")
            {
                Exporter exporter1 = new Exporter;
                exporter1.OntoExcel(exporter1.GetHtml(dw_list,"rpttemplate/Quote/4544F98B-60D1-4787-8092-DFE5ED930560.xsl",GetServerUrl()));
                return 1;
            }
            else if(comdid=="xmSaveAs")
            {
                Exporter exporter = new Exporter;
                /*string file = exporter.GetSaveFileName("eQ“^°eÁTß~¡‹hˆ"+".xlsx",
                "Excel‡eöN(*.xlsx)\0*.xlsx;*.xls\0Excel97‡eöN(*.xls)\0*.xls\0PDF‡eöN(*.pdf)\0*.pdf\0",
                "xlsx");
                */
                
                //dw_list.SaveAs(""); 
                string htmlStr = exporter.GetHtml(dw_list,"rpttemplate/Quote/4544F98B-60D1-4787-8092-DFE5ED930560.xsl",GetServerUrl());
                exporter.OnExport(GetHWND(), htmlStr);
                
                return 1;
            }
            else if(comdid=="xmPrint")
            {
                OnPrint();
                return 1;
            }
            
            return 0;
        }
        
        //æ‰ÑS Ÿh»y_Ttran‹NöN ÿÇåg~bÐg*NÂSpe—_0Rù[”^„vR            
            int OnBaseItemChanged(ref TNotifyEvent evt,int p)
        {
            ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR);
            string colname=hdr.colname;
            string value = hdr.data;
            
            string dwname = "dw_list";
            if(value != "")
            {
                msxml::IXMLDOMNodeList nlist = GetElement().selectNodes("//*[@name='"+dwname+"']/trans[@for='"+colname+"']");
                ViewObject::TransData(nlist, dw_list, hdr.row, colname, value);
            }
            return 1;
        }
            
        
        //}TäNYt‹NöN
        int OnXCommand(ref TXCommandEvent evt,int param)
        {
            return OnCmdDispatch(evt.pStrID);
        }
        
        int OnAttachEvent()
        {
            //Ñ~š[å]wQag¹pûQ‹NöN
            AttachEvent("WM_XCOMMAND",OnXCommand);
            //·ƒÖS&q¹p‹NöN ÿ(uŽN͑nå]wQag
            AttachEvent("WM_SETFOCUS",OnSetFocus);
            AttachEvent("dw_list","DWV_ITEMCHANGED",OnBaseItemChanged);
        }
            
        string GetQueryArg()
        {
            dw_arg.AcceptText();
            xml x = new xml;
            x.setNativePointer(xml::CreateInstance());
            dw_arg.DwUpdateAllTo(x.GetXmlDoc());
            return x.GetXml();
        }    
        
        int  OnRetrieve()
        {
            xml x = new xml;
            x.setNativePointer(xml::CreateInstance());
            xaserverarg arg = new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());    
            arg.AddArg("QueryTxt",GetControl("search").GetText());
            arg.AddArg("QueryArg",GetQueryArg());
            trace(GetQueryArg());
            if (getUrl("/sale/data/Sample/entity/ShipmentNewLsit",arg.GetString(),x)!=1)
            {
                alert(x.GetXml());
                trace(x.GetXmlDoc().text);
                return -1;
            }else    
            {
                
                dw_list.Retrieve(x);
                dw_list.Redraw();
            }
            dw_list.SetSelectionMode(1);
            dw_list.SetReadOnly(true);
            return 1;
        }
    
        int onload()
        {
            dw_list = GetControl("dw_list");
            dw_list.openUrl("/sale/view/Sample/template/Sample/–™!kúQ'°eÁT");
            dw_list.SetColumnState("SKUNo",false);
            dw_list.SetColumnState("CustomerID",false);
            dw_list.SetColumnState("CustomerItemNo",false);
            dw_list.SetColumnState("SKUNoEx",false);
            
            dw_arg = GetControl("dw_arg");
            dw_arg.openUrl("/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,"DateType",",gt^");
            
            OnRetrieve();
        
            OnAttachEvent();    
            
            return 1;
        }
        
        int onloaded()
        {
            SetAgent();
            return 1;
        }        
    };
]