LiFan
2024-07-10 2a1d4fcebeca6c3b7f8af0c13463486fb30a78e1
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
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
use "xcontrol.vframe.vbusiness.vd"
use "xbase.vframe.vbusiness.vd"
use "multi.vbind.vbind.wface.vd"
use "productlibrary.vd"
use "shoppingcart.vd"
 
unit trade
[
    class EntityProductSelectWin : public xwin
    {
        int hObject = 0;
        string CustomerID;
        string SupplierID;
        string m_customer;
 
        //²úÆ·¿â²úÆ·Áбí
        xdwgrid    dw_list;
        //¹ºÎï³µ²úÆ·Áбí
        xdwgrid    dwc_list;
 
        //²úÆ·»º´æ¶ÔÏó
        xdataset g_xdoc_product;
        xdataset g_xdoc_shoppingcart;
 
        xcombobox  cbx_goodscar;
        //ÊÇ·ñ¶àÑ¡
 
        xnode    m_agentNode;    //Agent Condition
        xtreeview tv_folder;
        string     agentFor;
        msxml::IXMLDOMElement imageElement;
 
        string    impStr;
        string tname;
 
        int FillGoodsCarList()
        {
            xcombobox xc = GetControl("frame:cbx_goodscar");
            if (!xc) return 0;
            xml  x = ShoppingCartView::GetRoleList(CustomerID);
            if (!x) return 0;
            xc.SetText("==Ñ¡Ôñ¹ºÎï³µ==");
 
            msxml::IXMLDOMNodeList nlist = x.GetXmlDoc().SelectNodes("//item");
            int len = nlist.length;
            for (int i = 0; i < len; i++)
            {
                msxml::IXMLDOMElement e = nlist.item(i);
                string name = e.getAttribute("name");
                xcombobox::AddItem(xc.GetId(), name);
            }
            return 1;
        }
 
        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;
        }
 
        //½¹µã¼¤»î´¦Àíº¯Êý
        int OnSetFocus(ref TEvent evt, int param)
        {
            //ÖØÖù¤¾ßÌõ
            SetAgent();
            return 1;
        }
 
        msxml::IXMLDOMElement OnGetCarListRowElement(int row = 0)
        {
            if (row < 1) row = dwc_list.GetRow();
            if (row < 1 || row > dwc_list.GetRowCount()) return 0;
            msxml::IXMLDOMElement e = g_xdoc_shoppingcart.getRowElement("data/Item", row);
            return e;
        }
 
        int OnShowImage(string skuid)
        {
            imageview im = GetControl("im1");
            //im.RemoveImage();
            im.ResetEx();
 
            xml xp = new xml;
            xp.setNativePointer(xml::CreateInstance());
            xaserverarg arg_pic = new xaserverarg;
            arg_pic.setNativePointer(arg_pic.CreateInstance());
            arg_pic.AddArg("SKUID", skuid);
            if (url::get("/sale/data/ProductLibrary3/pref/picture/imagelistSKU", arg_pic.GetString(), xp) != 1)
            {
                trace("xxx", xp.GetXml());
            }
            else
            {
                //trace(skuid+" "+xp.GetXml());
                imageElement = xp.GetXmlDoc().documentElement;
                msxml::IXMLDOMNodeList  nlistp = xp.GetXmlDoc().selectNodes("ImageList/image");
                int lenp = nlistp.length;
                for (int ip = 0; ip < lenp; ip++)
                {
                    msxml::IXMLDOMElement xitem = nlistp.item(ip);
                    string picname = xitem.selectSingleNode("PicPath").text;
                    string goodno = xitem.selectSingleNode("GoodsNo").text;
                    if (picname == "/business/products/Thumbs//")
                        picname = "/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg";
                    im.AddImages(picname, "");
                }
                im.Redraw();
                //win32::SendMessage(im.GetId(),0x000f,0,1);
                //win32::InvalidateRect(im.GetId(),cast(0 as ref xrect),true);
            }
            return 1;
        }
 
        int OnShowImage(string skuid, string customerItemNo)
        {
            imageview im = GetControl("im1");
            //im.RemoveImage();
            im.ResetEx();
 
            xml xp = new xml;
            xp.setNativePointer(xml::CreateInstance());
            xaserverarg arg_pic = new xaserverarg;
            arg_pic.setNativePointer(arg_pic.CreateInstance());
            arg_pic.AddArg("SKUID", skuid);
            arg_pic.AddArg("CustomerID", m_customer);
            arg_pic.AddArg("CustomerItemNo", customerItemNo);
 
            if (url::get("/sale/data/ProductLibrary3/pref/picture/customer/imagelistSKU", arg_pic.GetString(), xp) != 1)
            {
                trace("error:" + xp.GetXml());
            }
            else
            {
                imageElement = xp.GetXmlDoc().documentElement;
                msxml::IXMLDOMNodeList  nlistp = xp.GetXmlDoc().selectNodes("ImageList/image");
                int lenp = nlistp.length;
                for (int ip = 0; ip < lenp; ip++)
                {
                    msxml::IXMLDOMElement xitem = nlistp.item(ip);
                    string picname = xitem.selectSingleNode("PicPath").text;
                    string goodno = xitem.selectSingleNode("GoodsNo").text;
                    if (picname == "/business/products/Thumbs//")
                        picname = "/business/products/Thumbs/00/00000000-0000-0000-0000-000000000000.jpg";
                    im.AddImages(picname, "");
                }
                im.Redraw();
            }
            return 1;
        }
 
        int OnRowChanged(ref TNotifyEvent evt, int p)
        {
            ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR);
            int row = hdr.row;
 
            htmlctrl xs = GetControl("html_detail");
            string html = makeHtml(row);
            xs.SetContent(html);
            xs.Redraw();
 
            string id = g_xdoc_product.getData(0, "data/Item", row, "@guid");
            OnShowImage(id);
 
            return 1;
        }
 
        int OnGoodsCarRowChanged(ref TNotifyEvent evt, int p)
        {
            ref DWNMHDR  hdr = trust(evt.pnmh as ref DWNMHDR);
            int row = hdr.row;
 
            htmlctrl xs = GetControl("html_detail");
            string html = makeGoodscarHtml(row);
            xs.SetContent(html);
            xs.Redraw();
            string id = g_xdoc_shoppingcart.getData(0, "data/Item", row, "SKUID");
            if (m_customer != "")
            {
                string customerItemNo = g_xdoc_shoppingcart.getData(0, "data/Item", row, "CustomerItemNo");
                OnShowImage(id, customerItemNo);
            }
            else
            {
                OnShowImage(id);
            }
 
            return 1;
        }
 
        int DeleteRow(int row)
        {
            int IDOK = 1;
            int MB_OKCANCEL = 1;
            int MB_ICONQUESTION = 32;
            if (win32::MessageBox(GetHWND(), "È·ÈÏɾ³ýÖ¸¶¨µÄÏɾ³ýºó½«²»Äָܻ´?", "Ìáʾ", MB_OKCANCEL | MB_ICONQUESTION) != IDOK) return 1;
            string id = g_xdoc_product.getData(0, "data/Item", row, "@guid");
 
            if (ProductLibraryView::DeleteItem(id) == 1)    dw_list.DeleteRow(0);
            return 1;
        }
 
        int SetSelectState(xdwgrid dw_obj, int state)
        {
            dw_obj.SetSelectionMode(3);
            return 1;
        }
 
        int OnCkbCLick(ref TEvent evt, int p)
        {
            xcheckbox cbx_1 = GetControl("frame:cbx1");
            int state = cbx_1.GetCheck(cbx_1.GetId());
            return SetSelectState(dw_list, state);
        }
 
        int OnCkbCLick2(ref TEvent evt, int p)
        {
            xcheckbox cbx_2 = GetControl("frame:cbx2");
            int state = cbx_2.GetCheck(cbx_2.GetId());
            return SetSelectState(dwc_list, state);
        }
 
        xml  GetGoodsPropList(string guid)
        {
            xml x = new xml;
            x.setNativePointer(xml::CreateInstance());
            xaserverarg arg = new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg("guid", guid);
            if (url::get("/sale/data/SO/goods/goodsprop/list", arg.GetString(), x) != 1)
            {
                string error = x.GetXmlDoc().text;
                alert(error);
            }
            return x;
        }
 
 
 
        string Up(string name) {
            string str = name.mid(0, 2);
            str = str.upper();
            return xaserver::UploadFile("product" + str, name + ".jpg", this.GetHWND(), "", false);
        }
 
        int OnAddImage() {
            if (m_customer != "") return OnAddImageEx();
            int row = dw_list.GetNextSelectRow(1);
            if (row < 1) row = dw_list.GetRow();
            if (row < 1 || row > dw_list.GetRowCount()) return 0;
 
            msxml::IXMLDOMElement e = g_xdoc_product.getRowElement("data/Item", row);
            string skuid = g_xdoc_product.getData(0, "data/Item", row, "@guid");
            string SKUNo = g_xdoc_product.getData(0, "data/Item", row, "SKUNo");
            string id = ViewObject::GetGuid();
            string ret1 = Up(id);
            if (ret1 == "-1") return -1;
            if (ret1 == "0")
            {
                alert("ÉÏ´«Í¼Æ¬Ê§°Ü");
                return -1;
            }
            string originfile = ret1;
            //alert(originfile);
            string ext = originfile.right(7);
            if (ext.find(".") >= 0)
                ext = ext.mid(ext.find(".") + 1, 9999);
            else
                ext = "jpg";
 
            // Í¼Æ¬Ãû¼ÓÈëÊý¾Ý¿â
            xml x = new xml;
            x.setNativePointer(xml::CreateInstance());
            x.LoadXml("<Item update.new='1' update.modify='1' guid='" + id + "'>" +
                "<ProductPictureID>" + id + "</ProductPictureID>" +
                "<OriginFile>" + originfile + "</OriginFile>" +
                "<FileExt>" + ext + "</FileExt>" +
                "<SKUID>" + skuid + "</SKUID>" +
                "<Name>[" + SKUNo.trim() + "]</Name>" +
                "<FileName>" + id + ".jpg</FileName>" +
                "</Item>"
            );
 
            xaserverarg arg = new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg("content", x.GetXml());
            if (url::get("/sale/data/ProductLibrary/image/update", arg.GetString(), x) != 1)
            {
                alert(x.GetXmlDoc().text);
                return -1;
            }
            dw_list.SetItemString(row, "pic", "*");
            dw_list.Redraw();
            //Ë¢ÐÂһϽçÃæ£¬ÏÔʾͼƬ
            OnShowImage(skuid);
            return 1;
        }
 
        int OnAddImageEx() {
            int row = dwc_list.GetNextSelectRow(1);
            if (row < 1) row = dwc_list.GetRow();
            if (row < 1 || row > dwc_list.GetRowCount()) return 0;
 
            msxml::IXMLDOMElement e = g_xdoc_shoppingcart.getRowElement("data/Item", row);
            string skuid = g_xdoc_shoppingcart.getData(0, "data/Item", row, "SKUID");
            string SKUNo = g_xdoc_shoppingcart.getData(0, "data/Item", row, "SKUID/@__displaystring");
            CustomerID = m_customer;
            string CustomerItemNo = g_xdoc_shoppingcart.getData(0, "data/Item", row, "CustomerItemNo");
            string id = ViewObject::GetGuid();
            string ret1 = Up(id);
            if (ret1 == "-1") return -1;
            if (ret1 == "0")
            {
                alert("ÉÏ´«Í¼Æ¬Ê§°Ü");
                return -1;
            }
            string originfile = ret1;
            string ext = originfile.right(7);
            if (ext.find(".") >= 0)
                ext = ext.mid(ext.find(".") + 1, 9999);
            else
                ext = "jpg";
 
            // Í¼Æ¬Ãû¼ÓÈëÊý¾Ý¿â
            xml x = new xml;
            x.setNativePointer(xml::CreateInstance());
            x.LoadXml("<Item update.new='1' update.modify='1' guid='" + id + "'>" +
                "<ProductPictureID>" + id + "</ProductPictureID>" +
                "<OriginFile>" + originfile + "</OriginFile>" +
                "<FileExt>" + ext + "</FileExt>" +
                "<SKUID>" + skuid + "</SKUID>" +
                "<CustomerItemNo>" + CustomerItemNo + "</CustomerItemNo>" +
                "<CustomerID>" + CustomerID + "</CustomerID>" +
                "<Name>[" + SKUNo.trim() + "]</Name>" +
                "<FileName>" + id + ".jpg</FileName>" +
                "</Item>"
            );
 
            xaserverarg arg = new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg("content", x.GetXml());
            if (url::get("/sale/data/ProductLibrary/image/update", arg.GetString(), x) != 1)
            {
                alert(x.GetXmlDoc().text);
                return -1;
            }
            dwc_list.SetItemString(row, "pic", "*");
            dwc_list.Redraw();
            //Ë¢ÐÂһϽçÃæ£¬ÏÔʾͼƬ
            OnShowImage(skuid, CustomerItemNo);
            return 1;
        }
 
        int OnDeleteImageEx()
        {
            int row = dwc_list.GetNextSelectRow(1);
            if (row < 1) row = dwc_list.GetRow();
            if (row < 1 || row > dwc_list.GetRowCount()) return 0;
 
            imageview im = GetControl("im1");
            int index = im.GetSelectIndex();
            int count = im.GetImageCount();
 
            if (count < 1) return 1;
 
            msxml::IXMLDOMNodeList images = imageElement.selectNodes("image");
            int length = images.length;
            if (length < index) return 1;
 
            int MB_OKCANCEL = 0x00000001;
            int IDOK = 1;
            if (win32::MessageBox(GetHWND(), "È·ÈÏɾ³ýµ±Ç°Í¼Æ¬?", "Ìáʾ", MB_OKCANCEL) != IDOK) return 1;
 
            string id = images.item(index).selectSingleNode("@guid").text;
 
            xml x = new xml;
            x.setNativePointer(xml::CreateInstance());
            xaserverarg arg = new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());
            string str = "<Item update.modify='1' update.delete='1' guid='" + id + "'/>";
            arg.AddArg("content", str);
            if (url::get("/sale/data/ProductLibrary/image/update", arg.GetString(), x) != 1)
            {
                alert(x.GetXmlDoc().text);
                return -1;
            }
            if (count == 1)
            {
                dwc_list.SetItemString(row, "pic", "");
                dwc_list.Redraw();
            }
 
            string skuid = g_xdoc_shoppingcart.getData(0, "data/Item", row, "SKUID");
            string SKUNo = g_xdoc_shoppingcart.getData(0, "data/Item", row, "SKUID/@__displaystring");
            CustomerID = m_customer;
            string CustomerItemNo = g_xdoc_shoppingcart.getData(0, "data/Item", row, "CustomerItemNo");
            OnShowImage(skuid, CustomerItemNo);
 
            return 1;
        }
 
        int OnDeleteImage() {
            if (m_customer != "") return OnDeleteImageEx();
 
            int row = dw_list.GetNextSelectRow(1);
            if (row < 1) row = dw_list.GetRow();
            if (row < 1 || row > dw_list.GetRowCount()) return 0;
 
            imageview im = GetControl("im1");
            int index = im.GetSelectIndex();
            int count = im.GetImageCount();
 
            if (count < 1) return 1;
 
            msxml::IXMLDOMNodeList images = imageElement.selectNodes("image");
            int length = images.length;
            if (length < index) return 1;
 
            int MB_OKCANCEL = 0x00000001;
            int IDOK = 1;
            if (win32::MessageBox(GetHWND(), "È·ÈÏɾ³ýµ±Ç°Í¼Æ¬?", "Ìáʾ", MB_OKCANCEL) != IDOK) return 1;
 
            string id = images.item(index).selectSingleNode("@guid").text;
 
            xml x = new xml;
            x.setNativePointer(xml::CreateInstance());
            xaserverarg arg = new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());
            string str = "<Item update.modify='1' update.delete='1' guid='" + id + "'/>";
            arg.AddArg("content", str);
            if (url::get("/sale/data/ProductLibrary/image/update", arg.GetString(), x) != 1)
            {
                alert(x.GetXmlDoc().text);
                return -1;
            }
            if (count == 1)
            {
                dw_list.SetItemString(row, "pic", "");
                dw_list.Redraw();
            }
 
            msxml::IXMLDOMElement e1 = g_xdoc_product.getRowElement("data/Item", row);
            string skuid = e1.getAttribute("guid");
            OnShowImage(skuid);
 
            return 1;
        }
 
        xml  GetGoodsPropListEx(string guid)
        {
            xml x = new xml;
            x.setNativePointer(xml::CreateInstance());
            string fields = "<data>";
 
            /*
            fields +="<field name='HighestPrice' label='×î¸ß¼Û'/>";
            fields +="<field name='LowestPrice' label='×îµÍ¼Û'/>";
 
            fields +="<field name='BulkPrice' label='É¢»õ¼Û'/>";
            fields +="<field name='CardPrice' label='Ö½¿¨¼Û'/>";
            fields +="<field name='BuyPrice' label='²É¹º¼Û'/>";
            fields +="<field name='SupplierID' label='»õÔ´'/>";
            */
 
            fields += "<field name='Packing' label='°ü×°·½Ê½'/>";
            fields += "<field name='PackingRate' label='ÿÏäÊýÁ¿'/>";
            fields += "<field name='VolumeDesc' label='°ü×°³ßÂë'/>";
            fields += "<field name='GWPerPkg' label='Ã«ÖØ'/>";
            fields += "<field name='NWPerPkg' label='¾»ÖØ'/>";
            //fields +="<field name='DeveloperID' label='¿ª·¢ÈËÔ±'/>";
            fields += "<field name='AttributeValue_1' label='²úÆ·ÊôÐÔ'/>";
            //fields +="<field name='Remark' label='±¸×¢'/>";
 
            fields += "</data>";
            x.LoadXml(fields);
 
            return x;
        }
 
        string makeHtml(int row)
        {
            string id = g_xdoc_product.getData(0, "data/Item", row, "@guid");
            xml x = GetGoodsPropList(id);
            xml x1 = GetGoodsPropListEx(id);
 
            string html = "<html><style> .text{ font-weight:400} .label { font-weight:400;}</style><body style='margin:2;background-color1:#ccdccc none #f0f0f0 none'>";
            html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >±àºÅ:</span><span  style='width:90;font-size:10pt'>" + dw_list.GetItemString(row, "No") +
                "</span> <span style='font-weight:700;width:50;font-size:10pt' >ÀàÏî:</span><span  style='width:90;font-size:10pt'>" + dw_list.GetItemString(row, "RefNo") +
                "</span></div>";
            html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >»õºÅ:</span><span  style='width:90;font-size:10pt'>" + dw_list.GetItemString(row, "GoodsNo") +
                "</span></div>";
            html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >Æ·Ãû:</span><span  style='width:90;font-size:10pt'>" + dw_list.GetItemString(row, "CName") +
                "</span></div>";
            if (dw_list.GetItemString(row, "CSpec") != "")
                html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >¹æ¸ñ:</span><span  style='width:90;font-size:10pt'>" + dw_list.GetItemString(row, "CSpec") +
                "</span></div>";
 
            msxml::IXMLDOMNodeList fieldsEx = x1.GetXmlDoc().selectNodes("data/field");
            string ls_detail = "";
            string ls_item = "";
            string name;
            string label;
            int len = fieldsEx.length;
            int i = 0;
 
            for (i = 0; i < len; true)
            {
                int cnt = 0;
                ls_item = "";
                while (cnt < 2)
                {
                    name = fieldsEx.item(i).selectSingleNode("@name").text;
                    label = fieldsEx.item(i).selectSingleNode("@label").text;
                    ls_item += "<td>" + label + "</td>" + "<td style='text-align:center'>" + g_xdoc_product.getData(0, "data/Item", row, name) + "</td>";
                    cnt++;
                    i++;
                    if (i == len)break;
                }
                ls_detail += "<tr>" + ls_item + "</tr>";
            }
            html += "<div style='margin-left:8px;margin-right:16px;'>" +
                +"<table><colgroup span='1' width='70'/><colgroup span='1' width='120'/><colgroup span='1' width='70'/><colgroup span='1' width='120'/>"
                + ls_detail
                + "</table>"
                + "</div>";
 
            string ls_star = "";
            msxml::IXMLDOMNodeList fields = x.GetXmlDoc().selectNodes("data/field");
            len = fields.length;
 
            ls_detail = "";
            if (len > 0)
                html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >¼¼ÊõÒªÇó:</span></div>";
            for (i = 0; i < len; true)
            {
                ls_item = "";
 
                int count = 0;
                while (count < 2)
                {
                    name = fields.item(i).selectSingleNode("@name").text;
                    label = fields.item(i).selectSingleNode("@label").text;
 
                    if (name == "QualityTerm" || name == "PackTerm" || label == "ÖÊÁ¿" || label == "°ü×°ÖÊÁ¿" || label == "¼¼ÊõÒªÇó")
                    {
                        i++;
                        if (i >= len)count = 2;
                        continue;
                    }
                    else if (g_xdoc_product.getData(0, "data/Item", row, name) == "")
                    {
                        msxml::IXMLDOMNodeList options = fields.item(i).selectNodes("item");
                        int tlen = options.length;
                        string terms = "";
                        for (int k = 0; k < tlen; k++)
                        {
                            if (options.item(k).text)
                            {
                                if (k > 0) terms += ", ";
                                terms += "[" + options.item(k).text + "]";
                            }
                        }
                        ls_star += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >" + label + "*:</span><span  style='width:90;font-size:10pt'>" + terms + "</span></div>";
                    }
                    else
                    {
                        ls_item = "<td>" + label + "</td>" + "<td>" + g_xdoc_product.getData(0, "data/Item", row, name) + "</td>";
                        count++;
                    }
                    i++;
                    if (i >= len)count = 2;
                }
                ls_item = "<tr>" + ls_item + "</tr>";
                ls_detail += ls_item;
            }
 
            html += "<div style='margin-left:8px;margin-right:16px;'>" +
                +"<table><colgroup span='1' width='70'/><colgroup span='1' width='120'/><colgroup span='1' width='70'/><colgroup span='1' width='120'/>"
                + ls_detail
                + "</table>"
                + "</div>";
            if (dw_list.GetItemString(row, "QualityTerm") != "")
            {
                html += "<div style='height:12px'/>";
                html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >ÖÊÁ¿:</span></div>";
                html += "<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt'  >" + dw_list.GetItemString(row, "QualityTerm") + "</span></div>";
            }
 
            if (dw_list.GetItemString(row, "PackTerm") != "")
            {
                html += "<div style='height:12px'/>";
                html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >°ü×°ÖÊÁ¿:</span></div>";
                html += "<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + dw_list.GetItemString(row, "PackTerm") + "</span></div>";
            }
 
            if (g_xdoc_product.getData(0, "data/Item", row, "Remark") != "" && id == "23A8BBA2-DEF1-4C00-978E-646151A6082E")
            {
                html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >±¸×¢:</span></div>";
                html += "<div ><span style='margin-left:8px;margin-right:16px;font-weight:400;font-size:10pt' >" + g_xdoc_product.getData(0, "data/Item", row, "Remark") + "</span></div>";
            }
 
            html += "<div style='height:24px'/>";
 
            //ÐDZêÏî
            html += ls_star;
 
            //ÏÔʾͼƬ            
            /*string picname = "1FA9E331-F95C-4E51-B80C-73FB9B911D8D.jpg";//dw_list.GetItemString(row,"ImgName"); //ItemID+".jpg";
            string str = picname.mid(0,2);
            str = str.upper();
            string serversrc ="http://192.168.7.241:1001/business/products/chanpin/"+str+"/"+picname;
            html +=  "<div ><span style='font-weight:700;width:50;font-size:10pt'  >ͼƬ:</span>";
            html +=  "<control visible='layer' controlclass='ximage'  data='' src='"+ serversrc +"'/></div>";
            */
            html += "</body></html>";
            return html;
        }
 
        string makeGoodscarHtml(int row)
        {
            string No = dwc_list.GetItemString(row, "RefNo");//»ñÈ¡ÊôÐÔÖµid                    
            xml x = GetGoodsPropList(No);
 
            string html = "<html><style> .text{ font-weight:400} .label { font-weight:400;}</style><body style='margin:2;background-color1:#ccdccc none #f0f0f0 none'>";
            html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >±àºÅ:</span><span  style='width:90;font-size:10pt'>" + dwc_list.GetItemString(row, "No") +
                "</span></div>";
            html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >Æ·Ãû:</span><span  style='width:90;font-size:10pt'>" + dwc_list.GetItemString(row, "CName") +
                "</span></div>";
            html += "<div ><span style='font-weight:700;width:50;font-size:10pt'  >¹æ¸ñ:</span><span  style='width:90;font-size:10pt'>" + dwc_list.GetItemString(row, "CSpec") +
                "</span></div>";
 
            msxml::IXMLDOMNodeList fields = x.GetXmlDoc().selectNodes("data/field");
            int len = fields.length;
            html += "<table>" +
                "<colgroup span='1' width='80'/>" +
                "<colgroup span='1' width='120'/>" +
                "<colgroup span='1' width='420'/>";
            html += "<tr>";
            html += "<td style='text-align:center'>±àºÅ</td><td style='text-align:center'>ÏîÄ¿</td><td style='text-align:center'>ÄÚÈÝ</td>";
            html += "</tr>";
            for (int i = 0; i < len; i++)
            {
                string name = fields.item(i).selectSingleNode("@name").text;
                string label = fields.item(i).selectSingleNode("@label").text;
                html += "<tr>";
                if (i == 0)
                    html += "<td rowspan='" + len.toString() + "'>" + No + "</td><td >" + label + "</td><td >" + "</td>";
                else
                    html += "<td >" + label + "</td><td >" + g_xdoc_shoppingcart.getData(0, "data/Item", row, name) + "</td>";
                html += "</tr>";
            }
 
            html += "<tr>";
            html += "<td rowspan='3'>" + g_xdoc_shoppingcart.getData(0, "data/Item", row, "PackCode") + "</td><td >°ü×°·½Ê½</td><td >" +
                g_xdoc_shoppingcart.getData(0, "data/Item", row, "CPack") + "</td>";
            html += "</tr>";
            html += "<tr height='48'>";
            html += "<td >°ü×°ÒªÇó</td><td >" + g_xdoc_shoppingcart.getData(0, "data/Item", row, "PackQualityTerm") + "</td>";
            html += "</tr>";
            html += "<tr>";
            html += "<td >²àßé</td><td ></td>";
            html += "</tr>";
 
            html += "<tr height='72'>";
            html += "<td>" + g_xdoc_shoppingcart.getData(0, "data/Item", row, "QualityCode") + "</td><td >ÖÊÁ¿ÒªÇó</td><td >" +
                g_xdoc_shoppingcart.getData(0, "data/Item", row, "QualityTerm") + "</td>";
            html += "</tr>";
 
            html += "</table>";
 
            html += "</body></html>";
            return html;
        }
 
        int OnImport()
        {
            if (!hObject) return 1;
 
            int rw = 0;
            string ls_nos = "ImportXml:";
 
            if (impStr == "")
            {
                alert("ÇëÑ¡ÔñÉÌÆ·!");
                return 1;
            }
            if (tname == "ÒÑѯ¼Û²úÆ·")
            {
                int row = dwc_list.GetNextSelectRow(1);
                while (row > 0)
                {
 
                    if (dwc_list.GetItemString(row, "pic") != "*")
                    {
                        alert("µÚ" + row.toString() + "ÐÐÇëÔö¼Ó²úƷͼƬ!");
                        return 1;
                    }
                    row = dwc_list.GetNextSelectRow(row + 1);
                }
            }
            else {
                row = dw_list.GetNextSelectRow(1);
                while (row > 0)
                {
                    if (dw_list.GetItemString(row, "pic") != "*")
                    {
                        alert("µÚ" + row.toString() + "ÐÐÇëÔö¼Ó²úƷͼƬ!");
                        return 1;
                    }
                    row = dw_list.GetNextSelectRow(row + 1);
                }
            }
            ls_nos += impStr;
 
            dwc_list.SelectRow(0, false);
            dwc_list.Redraw();
            dw_list.SelectRow(0, false);
            dw_list.Redraw();
            impStr = "";
 
            win32::SendMessage(hObject, 0x401, ls_nos, 0);
            alert("תÈëÍê³É!");
 
            return 1;
        }
 
        int OnSearch()
        {
            int hItem = tv_folder.GetSelectedItem();
            return RetrieveItem(hItem);
        }
 
        int DeleteRow(int row)
        {
            int IDOK = 1;
            int MB_OKCANCEL = 1;
            int MB_ICONQUESTION = 32;
            if (win32::MessageBox(GetHWND(), "È·ÈÏɾ³ýÖ¸¶¨µÄÏɾ³ýºó½«²»Äָܻ´?", "Ìáʾ", MB_OKCANCEL | MB_ICONQUESTION) != IDOK) return 1;
            string id = g_xdoc_product.getData(0, "data/Item", row, "@guid");
 
            if (ProductLibraryView::DeleteItem(id) == 1) dw_list.DeleteRow(0);
 
            return 1;
        }
 
        //ÃüÁî·¢²¼º¯Êý
        int OnCmdDispatch(string comdid)
        {
            int hCursor;
            string name = "";
            if (comdid == "xmClose")
            {
                CloseWindow();
                return 1;
            }
            else if (comdid == "xmImport")
            {
                OnImport();
                return 1;
            }
            else if (comdid == "xmSearch")
            {
                OnSearch();
                return 1;
            }
            else if (comdid == "xmAdd")
            {
                ItemAdd();
                return 1;
            }
            else if (comdid == "xmMaint")
            {
                ItemMaint();
                return 1;
            }
            else if (comdid == "xmDelete")
            {
                int row = dw_list.GetRow();
                if (row < 1) return 1;
                DeleteRow(row);
 
                return 1;
            }
            else if (comdid == "xmAddImage")
            {
                return OnAddImage();
            }
            else if (comdid == "xmDeleteImage")
            {
                return OnDeleteImage();
            }
            return 0;
        }
 
        int ItemAdd()
        {
            int hItem = tv_folder.GetSelectedItem();
            int hTopItem = LookupTopFolder(hItem);
            string name = tv_folder.GetItemLabel(hTopItem);
 
            msxml::IXMLDOMElement e = tv_folder.GetItemData(hItem);
            string guid = e.getAttribute("guid");
            if (guid == "") return 1;
            xaserverarg arg = new xaserverarg;
            arg.setNativePointer(arg.CreateInstance());
            arg.AddArg("guid", e.getAttribute("guid"));
            if (name == "¸öÈ˲úÆ·")
                arg.AddArg("FolderID", e.getAttribute("guid"));
            else
                arg.AddArg("CategoryID", e.getAttribute("guid"));
            string No = e.getAttribute("CategoryNo");
            if (No == "") No = e.getAttribute("no");
            string Name = e.getAttribute("CName");
            if (Name == "") Name = e.getAttribute("cname");
            arg.AddArg("No", No);
            arg.AddArg("CName", Name);
            int p = arg;
            OpenWindow("dev:xpage[Quick.Input.NewProductEx.vx]", p);
            if (arg.GetArgString("data.modify") == "1")RetrieveItem(hItem);
            return 1;
        }
 
        int ItemMaint()
        {
            int hItem = tv_folder.GetSelectedItem();
            msxml::IXMLDOMElement e = tv_folder.GetItemData(hItem);
            //string no = e.getAttribute("no");
            //if(no=="") return 1;
            string guid = e.getAttribute("guid");
            if (guid == "") return 1;
 
            /*
            if(no=="NP0000FS" || no=="UP0000FS")
            {
                OpenWindow("dev:xpage[PackSchemaMaint.goodslib.vx]");
            }else
            {
                int pr = g_xdoc_product;
                OpenWindow("dev:xpage[ProductLibraryItemMaint.vx]",pr);
            }
            */
            //msxml::IXMLDOMElement ele = g_xdoc_product.getRowElement("data/Item", 1);
            //alert(ele.xml);
 
            int pr = g_xdoc_product;
            OpenWindow("dev:xpage[ProductLibraryItemMaint3.vx]", pr);
 
            return 1;
        }
 
        //ÃüÁî´¦Àíʼþ
        int OnXCommand(ref TXCommandEvent evt, int param)
        {
            return OnCmdDispatch(evt.pStrID);
        }
 
        //²éÕÒµ±Ç°Ê÷ÏîµÄ¶¥¼¶Ä¿Â¼
        int LookupTopFolder(int hItem)
        {
            int hRoot = tv_folder.GetRootItem();
            while (tv_folder.GetParentItem(hItem)) hItem = tv_folder.GetParentItem(hItem);
            return hItem;
        }
 
        //²åÈë²úÆ·ÀàÏîµÄ×ÓÏî
        int MakeGoodsFolderItem(int hItem, string sno)
        {
            xml x = ProductLibraryView::GetTreeChildItems3(sno);
            if (!x) return 0;
 
            msxml::IXMLDOMNodeList nlist = x.GetXmlDoc().SelectNodes("//Item");
            int len = nlist.length;
            for (int i = 0; i < len; i++)
            {
                msxml::IXMLDOMElement e = nlist.item(i);
                string name = e.getAttribute("CName");
                string no = e.getAttribute("CategoryNo");
                string label = no.trim() + " " + name;
 
                int h = tv_folder.InsertChildItem(hItem, label, trust(e as int), 15);
                tv_folder.SetItemChild(h, 1);
            }
            return 1;
        }
 
        //²åÈëвúƷĿ¼×ÓÏî
        int MakeUserGoodsFolderItem(int hItem, string sno)
        {
            xml x = ProductLibraryView::GetTreeUserChildItems3(sno);
            if (!x) return 0;
 
            msxml::IXMLDOMNodeList nlist = x.GetXmlDoc().SelectNodes("//Item");
            int len = nlist.length;
            for (int i = 0; i < len; i++)
            {
                msxml::IXMLDOMElement e = nlist.item(i);
                string name = e.getAttribute("CName");
                string no = e.getAttribute("CategoryNo");
                string label = no.trim() + " " + name;
 
                int h = tv_folder.InsertChildItem(hItem, label, trust(e as int), 15);
                string child = e.getAttribute("Childs");
                if (child == "")
                    tv_folder.SetItemChild(h, 1);
                else if (child != "0")
                    tv_folder.SetItemChild(h, 1);
            }
            return 1;
        }
 
        //²åÈ빺Îï³µÏî
        int ExpandCatChildFolder(int hItem, msxml::IXMLDOMElement ele, int image)
        {
            msxml::IXMLDOMNodeList nlist = ele.SelectNodes("item");
            int len = nlist.length;
            if (len > 0) tv_folder.SetItemChild(hItem, 1);
            for (int i = 0; i < len; i++)
            {
                msxml::IXMLDOMElement e = nlist.item(i);
                string name = e.getAttribute("name");
                int h = tv_folder.InsertChildItem(hItem, name, trust(e as int), image);
                ExpandCatChildFolder(h, e, 35);
            }
            return 1;
        }
        int MakeGoodCarFolderItem(int hItem)
        {
            xml x = ShoppingCartView::GetSupplierRoleList(SupplierID);
            if (!x) return 0;
            msxml::IXMLDOMNodeList nlist = x.GetXmlDoc().SelectNodes("/data/item");
            int len = nlist.length;
            for (int i = 0; i < len; i++)
            {
                msxml::IXMLDOMElement e = nlist.item(i);
                string name = e.getAttribute("name");
                int h = tv_folder.InsertChildItem(hItem, name, trust(e as int), 35);
                ExpandCatChildFolder(h, e, 35);
            }
            return 1;
        }
 
        //Ê÷Õ¹¿ª
        int OnTreeExpanding(ref TNotifyEvent evt, int p)
        {
            ref NMTREEVIEW nmtv = evt.pnmh;
            int hItem = nmtv.itemNew.hItem;
            int hTopItem = LookupTopFolder(hItem);
            string name = tv_folder.GetItemLabel(hTopItem);
            int child = tv_folder.GetChildItem(hItem);
            string no = "";
            msxml::IXMLDOMElement e;
 
            if (name == "¹«Ë¾¿â" && !child)
            {
                no = "";
                if (hTopItem != hItem)
                {
                    e = tv_folder.GetItemData(hItem);
                    no = e.getAttribute("categoryid");
                }
                else
                {
                    e = tv_folder.GetItemData(hItem);
                    no = e.getAttribute("categoryid");
                }
                MakeGoodsFolderItem(hItem, no);
            }
            else if (name == "¸öÈË¿â" && !child)
            {
                no = "";
                if (hTopItem != hItem)
                {
                    e = tv_folder.GetItemData(hItem);
                    no = e.getAttribute("categoryid");
                    MakeUserGoodsFolderItem(hItem, no);
                }
            }
            else if (name == "ÒÑѯ¼Û²úÆ·" && !child)
            {
                if (hItem == hTopItem)MakeGoodCarFolderItem(hItem);
            }
            return 1;
        }
 
        int ResetAgent(string agentAsk)
        {
            if (agentFor != agentAsk)
            {
                agentFor = agentAsk;
                m_agentNode = 0;
                SetAgent();
            }
            return 1;
        }
 
        int LookupCustomerFolder(int hItem)
        {
            while (true)
            {
                msxml::IXMLDOMElement e1 = cast(tv_folder.GetItemData(hItem) as msxml::IXMLDOMElement);
                string str = e1.getAttribute("no");
                if (str.find("Customer:") >= 0) return hItem;
                hItem = tv_folder.GetParentItem(hItem);
                if (hItem == 0) break;
            }
            return 0;
        }
 
        string LookupCustomer(int hItem)
        {
            hItem = LookupCustomerFolder(hItem);
            if (hItem == 0) return "";
            msxml::IXMLDOMElement e1 = cast(tv_folder.GetItemData(hItem) as msxml::IXMLDOMElement);
            string str = e1.getAttribute("no");
            return str.mid("Customer:".length(), 9999);
        }
 
        int RetrieveItem(int hItem)
        {
            int hTopItem = LookupTopFolder(hItem);
            tname = tv_folder.GetItemLabel(hTopItem);
            string selectname = tv_folder.GetItemLabel(hItem);
            imageview im = GetControl("im1");
            m_customer = "";
            xcontrol query = GetControl("sl_search");
            string queryString = query.GetText();
            if (hTopItem == 0 && queryString != "")
            {
                tname = "ÒÑѯ¼Û²úÆ·";
                selectname = "ÒÑѯ¼Û²úÆ·";
            }
            if (tname == "ÒÑѯ¼Û²úÆ·")
            {
                if (agentFor != "goodscar")SwitchLayer("goodscarsheet", "sheetframe");
                ResetAgent("goodscar");
                if (selectname != tname)
                {
                    msxml::IXMLDOMElement e1 = cast(tv_folder.GetItemData(hItem) as msxml::IXMLDOMElement);
                    string str = e1.getAttribute("no");
                    if (str == "Supplier") return 1;
                    if (str.find("Customer:") == 0 || str.find("SO:") == 0 || str.find("Supplier:") == 0 || str.find("Enquiry:") == 0)
                    {
                        m_customer = LookupCustomer(hItem);
                        if (str.find("Customer:") == 0)
                            dwc_list.openUrl("/sale/view/ProductLibrary/template/cart/goodscustomerlist");
                        else
                            dwc_list.openUrl("/sale/view/ProductLibrary/template/cart/goodssolist");
                        dwc_list.Reset();
                        dwc_list.SetReadOnly(true);
                        if (queryString == "")
                            g_xdoc_shoppingcart.Retrieve(ShoppingCartView::GetGoodsList(str));
                        else
                            g_xdoc_shoppingcart.Retrieve(ShoppingCartView::GetGoodsList(str, queryString));
                        if (str.find("Supplier:") == 0)
                        {
                            if (dwc_list.GetRowCount() > 0)
                            {
                                OnShowImage(dwc_list.GetItemString(1, "SKUID"));
                            }
                        }
                    }
                    else if (e1.getAttribute("categoryid") != "")
                    {
 
                        string categoryid = e1.getAttribute("categoryid");
                        dwc_list.SetDataObject(ProductLibraryView::GetMaintListForm3(categoryid).GetXmlDoc());
                        dwc_list.SetReadOnly(true);
                        dwc_list.Reset();
                        if (queryString == "")
                            g_xdoc_shoppingcart.Retrieve(ProductLibraryView::GetMaintList3(categoryid));
                        else
                            g_xdoc_shoppingcart.Retrieve(ProductLibraryView::GetMaintList3(categoryid, queryString, ""));
                    }
                    else
                    {
                        dwc_list.openUrl("/sale/view/ProductLibrary/template/cart/goodssolist");
                        dwc_list.SetReadOnly(true);
                        dwc_list.Reset();
                        if (queryString == "")
                            g_xdoc_shoppingcart.Retrieve(ShoppingCartView::GetGoodsList(selectname));
                        else
                            g_xdoc_shoppingcart.Retrieve(ShoppingCartView::GetGoodsList(selectname, queryString));
                    }
                    dwc_list.PostRetrieve();
                    dwc_list.Redraw();
 
                    if (dwc_list.GetRowCount() >= 1)
                    {
                        htmlctrl xs = GetControl("html_detail");
                        xs.SetContent(makeGoodscarHtml(1));
 
                        if (m_customer != "")
                        {
                            string skuid = g_xdoc_shoppingcart.getData(0, "data/Item", 1, "SKUID");
                            string customerItemNo = g_xdoc_shoppingcart.getData(0, "data/Item", 1, "CustomerItemNo");
                            OnShowImage(skuid, customerItemNo);
                        }
                    }
                    else {
                        im.ResetEx();
                        im.Redraw();
 
                        xs = GetControl("html_detail");
                        xs.SetContent("<html><body style='margin:2;background-color:#ccdccc none #f0f0f0 none'/></html>");
                    }
                    xs.Redraw();
                }
                else
                {
                    if (queryString == "")
                    {
                        return 0;
                    }
                    else
                    {
                        str = "Supplier:All";
                        g_xdoc_shoppingcart.Retrieve(ShoppingCartView::GetGoodsList(str, queryString));
                        dwc_list.PostRetrieve();
                        dwc_list.Redraw();
                    }
                }
            }
            else
            {
                if (agentFor != "goodslib")SwitchLayer("goodslibsheet", "sheetframe");
                if (tname == "¸öÈË¿â")
                    ResetAgent("userlib");
                else
                    ResetAgent("goodslib");
                int hCursor = xutil::SetCursorWait();
                if (tname == "¸öÈË¿â" || tname == "¹«Ë¾¿â")
                {
                    string no = "N000005";
                    if (tname == "¸öÈË¿â") no = "U000005";
                    if (hItem != hTopItem)
                    {
                        msxml::IXMLDOMElement e = tv_folder.GetItemData(hItem);
                        no = e.getAttribute("guid");
                    }
 
 
                    dw_list = GetControl("dw_list");
                    dw_list.SetDataObject(ProductLibraryView::GetMaintListForm3(no).GetXmlDoc());
                    dw_list.Reset();
                    dw_list.SetReadOnly(true);
                    dw_list.SetColumnState("Submitter1", false);
                    dw_list.SetColumnState("HSCode", false);
 
                    xml x;
                    if (queryString == "")
                    {
                        if (tname == "¸öÈË¿â")
                            x = ProductLibraryView::GetMaintRoleList3(no);
                        else
                            x = ProductLibraryView::GetMaintList3(no);
                        if (x)
                        {
                            g_xdoc_product.Retrieve(x);
                            x.Free();
                        }
                    }
                    else
                    {
                        if (tname == "¸öÈË¿â")
                        {
                            x = ProductLibraryView::GetMaintRoleList3(no, queryString);
                        }
                        else
                        {
                            if (queryString != "")
                            {
                                if (no == "N000005")
                                    x = ProductLibraryView::GetMaintList3("", queryString, "");
                                else
                                    x = ProductLibraryView::GetMaintList3(no, queryString, "");
                            }
                            else
                                x = ProductLibraryView::GetMaintList3(no);
                        }
                        if (x)g_xdoc_product.Retrieve(x);
                    }
                    dw_list.PostRetrieve();
                    dw_list.Redraw();
 
                    if (dw_list.GetRowCount() > 0)
                    {
                        xs = GetControl("html_detail");
                        xs.SetContent(makeHtml(1));
                        string id = g_xdoc_product.getData(0, "data/Item", 1, "@guid");
                        OnShowImage(id);
                    }
                    else
                    {
                        im.ResetEx();
                        im.Redraw();
 
                        xs = GetControl("html_detail");
                        xs.SetContent("<html><body style='margin:2;background-color:#ccdccc none #f0f0f0 none'/></html>");
                    }
                    xs.Redraw();
                    xutil::RestoreCursor(hCursor);
                }
            }
            impStr = "";
        }
 
        int OnTreeSelChanged(ref TNotifyEvent evt, int p)
        {
            ref NMTREEVIEW nmtv = cast(evt.pnmh as NMTREEVIEW);
            int hItem = nmtv.itemNew.hItem;
            return RetrieveItem(hItem);
        }
 
        int  ExpandChildFolder(int hItem, msxml::IXMLDOMElement pElement)
        {
            msxml::IXMLDOMNodeList nlist = pElement.SelectNodes("Item");
            int len = nlist.length;
            for (int i = 0; i < len; i++)
            {
                msxml::IXMLDOMElement e = nlist.item(i);
                string name = e.getAttribute("cname");
                string sImage = e.getAttribute("image");
                int image = 15;
                //if(sImage) image = sImage.toInt();
                int h = tv_folder.InsertChildItem(tv_folder.GetId(), hItem, name, trust(e as int), image);
                tv_folder.SetItemChild(h, 1);
                ExpandChildFolder(h, e);
            }
            return 1;
        }
 
        int  InitialFolder()
        {
            msxml::IXMLDOMElement xframeElement = GetElement();
            msxml::IXMLDOMElement e = xframeElement.selectSingleNode("//xtree[@name='tv_folder']/initial");
            ExpandChildFolder(0, e);
            return 1;
        }
 
        int OnDwClicked(ref TNotifyEvent evt, int p)
        {
            ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
            char ch;
            int row = hdr.row;
            string col = hdr.colname;
 
            string str = "";
            if (dw_list.GetItemString(row, "SKUNo") != "")
                str = dw_list.GetItemString(row, "SKUNo");
            else
                str = dw_list.GetItemString(row, "No");
 
            if (dw_list.IsRowSelected(row) & 0xff)
            {
                //will unselect
                impStr = impStr.replace(" " + str, "");
            }
            else
            {
                //will select
                impStr += " " + str;
            }
            return 1;
        }
 
        int OnDwcClicked(ref TNotifyEvent evt, int p)
        {
            ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
            char ch;
            int row = hdr.row;
            string col = hdr.colname;
            string str = g_xdoc_shoppingcart.getData(0, "data/Item", row, "SOLineID");
            if (str != "")
                str = "sl:" + str;
            else if (dwc_list.GetItemString(row, "SKUNo") != "")
                str = dwc_list.GetItemString(row, "SKUNo");
            else
                str = dwc_list.GetItemString(row, "No");
 
            if (dwc_list.IsRowSelected(row) & 0xff)
            {
                //will unselect
                impStr = impStr.replace(" " + str, "");
            }
            else
            {
                //will select
                impStr += " " + str;
            }
            return 1;
        }
 
        int OnDwcDoubleClicked(ref TNotifyEvent evt, int p)
        {
 
            int hCursor = xutil::SetCursorWait();
            ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
            int row = hdr.row;
            string ls_nos = "ImportXml:";
            string str = g_xdoc_shoppingcart.getData(0, "data/Item", row, "SOLineID");
            string str1 = g_xdoc_shoppingcart.getData(0, "data/Item", row, "EnquiryPriceListID");
            if (str1 != "")
                str += "el:" + str1;
            else if (str != "")
                str = "sl:" + str;
            else if (dwc_list.GetItemString(row, "SKUNo") != "")
                str = dwc_list.GetItemString(row, "SKUNo");
            else
                str = dwc_list.GetItemString(row, "No");
            ls_nos += str;
 
            dw_list.SelectRow(0, false);
            dwc_list.SelectRow(0, false);
            dw_list.Redraw();
            dwc_list.Redraw();
            impStr = "";
            win32::SendMessage(hObject, 0x401, ls_nos, 0);
            xutil::RestoreCursor(hCursor);
            CloseWindow();
            return 1;
        }
        int OnDwDoubleClicked(ref TNotifyEvent evt, int p)
        {
            int hCursor = xutil::SetCursorWait();
            ref DWNMHDR hdr = cast(evt.pnmh as ref DWNMHDR);
            int row = hdr.row;
            if (row > 0)
            {
                if (dw_list.GetItemString(row, "pic") != "*")
                {
                    alert("µÚ" + row.toString() + "ÐÐÇëÔö¼Ó²úƷͼƬ!");
                    return 1;
                }
            }
            string ls_nos = "ImportXml:";
            string str = "";
            if (dw_list.GetItemString(row, "SKUNo") != "")
                str = dw_list.GetItemString(row, "SKUNo");
            else
                str = dw_list.GetItemString(row, "No");
            ls_nos += str;
            dw_list.SelectRow(0, false);
            dwc_list.SelectRow(0, false);
            dw_list.Redraw();
            dwc_list.Redraw();
            impStr = "";
            win32::SendMessage(hObject, 0x401, ls_nos, 0);
            xutil::RestoreCursor(hCursor);
            CloseWindow();
            return 1;
        }
 
        int OnAttachEvent()
        {
            //°ó¶¨¹¤¾ßÌõµã»÷ʼþ
            AttachEvent("WM_XCOMMAND", OnXCommand);
            //»ñÈ¡½¹µãʼþ£¬ÓÃÓÚÖØÖù¤¾ßÌõ
            AttachEvent("WM_SETFOCUS", OnSetFocus);
            AttachEvent("dw_list", "DWV_ROWFOCUSCHANGED", OnRowChanged);
            AttachEvent("dwc_list", "DWV_ROWFOCUSCHANGED", OnGoodsCarRowChanged);
            AttachEvent("tv_folder", "TVN_ITEMEXPANDING", OnTreeExpanding);
            AttachEvent("tv_folder", "TVN_SELCHANGED", OnTreeSelChanged);
            AttachEvent("WM_COMMAND", OnCkbCLick);    //checkbox´ò¹³Ê¼þ
            AttachEvent("WM_COMMAND", OnCkbCLick2);    //checkbox´ò¹³Ê¼þ    
 
            AttachEvent("dwc_list", "DWV_DOUBLECLICKED", OnDwcDoubleClicked);
            AttachEvent("dw_list", "DWV_DOUBLECLICKED", OnDwDoubleClicked);
 
            AttachEvent("dw_list", "DWV_CLICKED", OnDwClicked);
            AttachEvent("dwc_list", "DWV_CLICKED", OnDwcClicked);
        }
 
        int onload()
        {
            agentFor = "goodslib";
            impStr = "";
 
            OnAttachEvent();
            imageElement = 0;
 
            tv_folder = GetControl("tv_folder");
            dw_list = GetControl("dw_list");
            dwc_list = GetControl("dwc_list");
 
            xaserverarg arg = GetParam();
            CustomerID = "";
            SupplierID = "";
            m_customer = "";
            hObject = 0;
            if (arg)
            {
                hObject = arg.GetArgString("HWND").toInt();
                CustomerID = arg.GetArgString("CustomerID");
                CustomerID = arg.GetArgString("SupplierID");
            }
            InitialFolder();
 
            g_xdoc_product = new xdataset;
            g_xdoc_product.Init();
            xbind bindproduct = new xbind;
            bindproduct.bindEx(dw_list, g_xdoc_product, "");
 
            g_xdoc_shoppingcart = new xdataset;
            g_xdoc_shoppingcart.Init();
 
            xbind bindcart = new xbind;
            bindcart.bindEx(dwc_list, g_xdoc_shoppingcart, "");
 
            dw_list.SetDataObject(ProductLibraryView::GetMaintListForm3("").GetXmlDoc());
            dw_list = GetControl("dw_list");
            dw_list.SetReadOnly(true);
            dw_list.SetColumnState("Submitter1", false);
            dw_list.SetColumnState("HSCode", false);
 
            dwc_list.openUrl("/sale/view/ProductLibrary/template/cart/goodssolist");
            dwc_list.SetReadOnly(true);
 
            if (dw_list.GetRowCount())
            {
                htmlctrl xs = GetControl("html_detail");
                xs.SetContent(makeHtml(1));
            }
 
            xtreeview::ExpandItem(tv_folder.GetId(),
                xtreeview::GetNextItem(tv_folder.GetId(), xtreeview::GetRootItem(tv_folder.GetId())));
            xtreeview::ExpandItem(tv_folder.GetId(),
                xtreeview::GetNextItem(tv_folder.GetId(), xtreeview::GetNextItem(tv_folder.GetId(), xtreeview::GetRootItem(tv_folder.GetId()))));
 
            dw_list.SetSelectionMode(3);
            dwc_list.SetSelectionMode(3);
 
            return 1;
        }
 
        int onloaded()
        {
            SetAgent();
 
            return 1;
        }
    };
]