-
Notifications
You must be signed in to change notification settings - Fork 0
/
OrderSelectForm.cs
2199 lines (2154 loc) · 102 KB
/
OrderSelectForm.cs
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
// Decompiled with JetBrains decompiler
// Type: WebOrderImportCraft.OrderSelectForm
// Assembly: WebOrderImportCraft, Version=1000.510.8894.24695, Culture=neutral, PublicKeyToken=bf11c4f15ab4e1ef
// MVID: F965BC17-D6AC-43D0-B104-3E53F0C380F8
// Assembly location: P:\Synergy\VMAWS Custom Apps\WebOrderImportCraft\WebOrderImportCraft.exe
using CraftCMS;
using MsgBox;
using SRISupport;
using Synergy.BusinessObjects;
using Synergy.BusinessObjects.AllObjects;
using Synergy.BusinessObjects.Schema;
using Synergy.BusinessObjects.VE;
using Synergy.DistributedERP;
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Security;
using System.Reflection;
using System.Security.Cryptography.X509Certificates;
using System.ServiceModel;
using System.Windows.Forms;
using WebOrderImportCraft.Properties;
namespace WebOrderImportCraft
{
public class OrderSelectForm : Form
{
private bool _Debug = false;
internal List<object> _OrderList = new List<object>();
private int listOffset = 0;
private int listChunkSize = 25;
private bool ReadyToLoad = false;
private char[] valSep = new char[1]{ '|' };
private char[] qualSep = new char[1]{ ':' };
private string accessToken = Settings.Default.APIKEY;
private WSHttpBinding binding = new WSHttpBinding();
private CraftUtil craftUtil = new CraftUtil();
internal ExternalReferenceService extRefSvc0;
internal CustomerService custSvc0;
internal SalesOrderService orderSvc0;
internal ContactService contactSvc0;
internal ExternalReferenceService extRefSvc1;
internal CustomerService custSvc1;
internal SalesOrderService orderSvc1;
internal ContactService contactSvc1;
internal NotationService notationSvc1;
internal InventoryService inventorySvc1;
internal EstimateService quoteSvc1;
internal UserDefinedFieldService UDFSvc1;
internal ExternalReferenceService extRefSvc2;
internal CustomerService custSvc2;
internal SalesOrderService orderSvc2;
internal ContactService contactSvc2;
internal NotationService notationSvc2;
internal InventoryService inventorySvc2;
internal EstimateService quoteSvc2;
internal UserDefinedFieldService UDFSvc2;
internal Header header0 = (Header) null;
internal Header header1 = (Header) null;
internal Header header2 = (Header) null;
internal DatabaseConnection Database0;
internal DatabaseConnection Database1;
internal DatabaseConnection Database2;
private logger LogFile;
private UserMessageBatch UserMsg;
private MethodInfo SchemaGetter = (MethodInfo) null;
private bool _isDroppedDown = false;
private bool datePush = false;
private IContainer components = (IContainer) null;
private ComboBox comboBoxVisualConnect;
private ComboBox comboBoxOrderStatus;
private DateTimePicker dateTimePickerTo;
private DateTimePicker dateTimePickerFrom;
private ComboBox comboBoxCustomer;
private Label label7;
private Label label6;
private Label label4;
private Label label1;
private DataGridView dataGridView1;
private Label labelServerURL;
private Label labelVersion;
private Button buttonCancel;
private Button buttonOK;
private ContextMenuStrip contextMenuStripCustID;
private ToolStripMenuItem toolStripMenuItemLookupID;
private ToolStripMenuItem toolStripMenuItemEditID;
private ContextMenuStrip contextMenuStripOrderID;
private ToolStripMenuItem openCustomerOrderToolStripMenuItem;
private Button buttonRefresh;
private ComboBox comboBoxListChunk;
private Button buttonNext;
private Button buttonPrev;
private ComboBox comboBoxStore;
private ComboBox comboBoxTaxStatus;
private Label label2;
private Label label3;
private Label labelTotalOrders;
private Label labelSelectedOrders;
private ContextMenuStrip contextMenuStripAssocOrder;
private ToolStripMenuItem associateOrderToolStripMenuItem;
private CheckBox chkBox_Incomplete;
private DataGridViewTextBoxColumn Store;
private DataGridViewTextBoxColumn OrderID;
private DataGridViewTextBoxColumn VisualOrderID;
private DataGridViewTextBoxColumn OrderDate;
private DataGridViewTextBoxColumn CustomerID;
private DataGridViewTextBoxColumn VisualCustomerID;
private DataGridViewTextBoxColumn CustomerName;
private DataGridViewTextBoxColumn VisualCustomerName;
private DataGridViewTextBoxColumn EmailAddress;
private DataGridViewTextBoxColumn PhoneNo;
private DataGridViewTextBoxColumn OrderStatus;
private DataGridViewTextBoxColumn PaymentAuth;
private DataGridViewTextBoxColumn TaxStatus;
private DataGridViewTextBoxColumn Shipping;
private DataGridViewTextBoxColumn IncrementId;
private DataGridViewTextBoxColumn CouponID;
private ToolStripMenuItem craftOrderDetailToolStripMenuItem;
private ToolStripMenuItem craftOrderDetailToolStripMenuItem2;
internal Panel panelDownLoad;
private Label labelDownLoading;
private PictureBox pictureBox1;
internal Label labelFName;
public OrderSelectForm()
{
this.InitializeComponent();
this.panelDownLoad.Visible = false;
this.comboBoxStore.Visible = false;
this.label3.Visible = false;
this.comboBoxTaxStatus.Visible = false;
this.label2.Visible = false;
this.dataGridView1.Columns[nameof (TaxStatus)].Visible = false;
Assembly executingAssembly = Assembly.GetExecutingAssembly();
Label labelVersion = this.labelVersion;
int num = executingAssembly.GetName().Version.Major;
string str1 = num.ToString();
num = executingAssembly.GetName().Version.Minor;
string str2 = num.ToString();
string str3 = "v." + str1 + "." + str2;
labelVersion.Text = str3;
EndpointAddress endpointAddress = new EndpointAddress(Settings.Default.EComSite_Service);
this.binding.MaxReceivedMessageSize = 65536000L;
if (endpointAddress.Uri.Scheme == "https")
{
this.binding.Security.Mode = SecurityMode.Transport;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(OrderSelectForm.trustCertificatesCallback);
ServicePointManager.SecurityProtocol = (SecurityProtocolType) 4080;
}
else
this.binding.Security.Mode = SecurityMode.None;
this.craftUtil.binding = (System.ServiceModel.Channels.Binding) this.binding;
this.craftUtil.accessToken = this.accessToken;
this.labelServerURL.Text = endpointAddress.Uri.ToString();
this.header0 = new Header();
this.header1 = new Header();
this.header1.Key = Settings.Default.VMKey;
this.header1.ExternalRefGroup = Settings.Default.ExternalReferenceGroup;
this.header2 = new Header();
this.header2.Key = Settings.Default.VMKey2;
this.header2.ExternalRefGroup = Settings.Default.ExternalReferenceGroup;
Alias.aliasDictionary.Clear();
string siteAliases = Settings.Default.SiteAliases;
if (!string.IsNullOrEmpty(siteAliases))
{
foreach (string str4 in siteAliases.Split(this.valSep))
{
string[] strArray = str4.Split(this.qualSep, 2);
if (strArray.Length == 2 && !string.IsNullOrWhiteSpace(strArray[1]))
Alias.aliasDictionary.Add(strArray[0], strArray[1]);
}
}
FreightSvcChg.freightSvcChgDictionary.Clear();
string freightSvcChg = Settings.Default.FreightSvcChg;
if (!string.IsNullOrEmpty(freightSvcChg))
{
foreach (string str5 in freightSvcChg.Split(this.valSep))
{
string[] strArray = str5.Split(this.qualSep, 2);
if (strArray.Length == 2 && !string.IsNullOrWhiteSpace(strArray[1]))
FreightSvcChg.freightSvcChgDictionary.Add(strArray[0], strArray[1]);
}
}
TaxSvcChg.taxSvcChgDictionary.Clear();
string taxSvcChg = Settings.Default.TaxSvcChg;
if (!string.IsNullOrEmpty(taxSvcChg))
{
foreach (string str6 in taxSvcChg.Split(this.valSep))
{
string[] strArray = str6.Split(this.qualSep, 2);
if (strArray.Length == 2 && !string.IsNullOrWhiteSpace(strArray[1]))
TaxSvcChg.taxSvcChgDictionary.Add(strArray[0], strArray[1]);
}
}
SmallOrderSvcChg.smallOrderSvcChgDictionary.Clear();
string smallOrderSvcChg = Settings.Default.SmallOrderSvcChg;
if (!string.IsNullOrEmpty(smallOrderSvcChg))
{
foreach (string str7 in smallOrderSvcChg.Split(this.valSep))
{
string[] strArray = str7.Split(this.qualSep, 2);
if (strArray.Length == 2 && !string.IsNullOrWhiteSpace(strArray[1]))
SmallOrderSvcChg.smallOrderSvcChgDictionary.Add(strArray[0], strArray[1]);
}
}
OrderStatusDefault.orderStatusDictionary.Clear();
string orderStatusDefault = Settings.Default.OrderStatusDefault;
if (!string.IsNullOrEmpty(orderStatusDefault))
{
foreach (string str8 in orderStatusDefault.Split(this.valSep))
{
string[] strArray = str8.Split(this.qualSep, 2);
if (strArray.Length == 2 && !string.IsNullOrWhiteSpace(strArray[1]))
OrderStatusDefault.orderStatusDictionary.Add(strArray[0], strArray[1]);
}
}
SiteDBMap.siteDBMapDictionary.Clear();
string siteDbMap = Settings.Default.SiteDBMap;
if (!string.IsNullOrEmpty(siteDbMap))
{
foreach (string str9 in siteDbMap.Split(this.valSep))
{
string[] strArray = str9.Split(this.qualSep, 2);
if (strArray.Length == 2 && !string.IsNullOrWhiteSpace(strArray[1]))
SiteDBMap.siteDBMapDictionary.Add(strArray[0], strArray[1]);
}
}
OrderPrefixMap.prefixMapDictionary.Clear();
string orderPrefixMap = Settings.Default.OrderPrefixMap;
if (!string.IsNullOrEmpty(orderPrefixMap))
{
foreach (string str10 in orderPrefixMap.Split(this.valSep))
{
string[] strArray = str10.Split(this.qualSep, 2);
if (strArray.Length == 2 && !string.IsNullOrWhiteSpace(strArray[1]))
OrderPrefixMap.prefixMapDictionary.Add(strArray[0], strArray[1]);
}
}
QuotePrefixMap.prefixMapDictionary.Clear();
string quotePrefixMap = Settings.Default.QuotePrefixMap;
if (string.IsNullOrEmpty(quotePrefixMap))
return;
foreach (string str11 in quotePrefixMap.Split(this.valSep))
{
string[] strArray = str11.Split(this.qualSep, 2);
if (strArray.Length == 2 && !string.IsNullOrWhiteSpace(strArray[1]))
QuotePrefixMap.prefixMapDictionary.Add(strArray[0], strArray[1]);
}
}
private static bool trustCertificatesCallback(
object sender,
X509Certificate cert,
X509Chain chain,
SslPolicyErrors errors)
{
switch (errors)
{
case SslPolicyErrors.None:
return true;
case SslPolicyErrors.RemoteCertificateNameMismatch:
if (cert.Subject == "CN=*.cloudfront.net, O=\"Amazon.com, Inc.\", L=Seattle, S=Washington, C=US" || cert.Subject == "CN = mwi.ecomm.vigetx.com")
return true;
break;
}
return false;
}
private void PokeContactNoSchema(BaseDomainObject obj)
{
try
{
if (this.SchemaGetter == (MethodInfo) null)
this.SchemaGetter = typeof (BaseDomainObject).GetMethod("get__TableObjectSchema", BindingFlags.Instance | BindingFlags.NonPublic);
iTableObjectSchema tableObjectSchema = (iTableObjectSchema) this.SchemaGetter.Invoke((object) obj, (object[]) null);
if (tableObjectSchema != null && tableObjectSchema.Fields.ContainsKey("CONTACT_NO"))
{
bool isPrimaryKey = tableObjectSchema.Fields["CONTACT_NO"].IsPrimaryKey;
tableObjectSchema.Fields.Remove("CONTACT_NO");
tableObjectSchema.Fields.Add("CONTACT_NO", new FieldObjectDefinition("CONTACT_NO", typeof (Decimal), 8, isPrimaryKey, 10));
}
else
{
int num = (int) MBox.Show("Field not Found: CONTACT_NO", "Error in Schema Update", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
catch (Exception ex)
{
int num1 = (int) MBox.Show(ex.ToString(), "Error in Schema Update", MessageBoxButtons.OK, MessageBoxIcon.Hand);
if (ex.InnerException == null)
return;
int num2 = (int) MBox.Show("Inner Exception\r\n\r\n" + ex.InnerException.Message, "Error in Schema Update", MessageBoxButtons.OK, MessageBoxIcon.Hand);
}
}
internal void AutoImportQuotes()
{
this.LogFile = new logger(Settings.Default.LogFileRoot, "LogFiles");
this.UserMsg = new UserMessageBatch(this.LogFile);
MBox.logIt = true;
MBox.UserMsg = this.UserMsg;
try
{
Assembly executingAssembly = Assembly.GetExecutingAssembly();
this.UserMsg.MessageSend(string.Format("Running WebOrderImport, version {0}", (object) ("v." + executingAssembly.GetName().Version.Major.ToString() + "." + executingAssembly.GetName().Version.Minor.ToString())), "Program", UserMessage.msgLevel.Information);
this.JobSelector_Load((object) null, (EventArgs) null);
this.JobSelector_Shown((object) null, (EventArgs) null);
this.comboBoxVisualConnect.SelectedItem = (object) "Quotes";
this.dateTimePickerFrom.Value = DateTime.Today.AddDays(-10.0);
foreach (DataGridViewRow row in (IEnumerable) this.dataGridView1.Rows)
{
if (row.Cells[10].Value.ToString() == "submitted")
{
row.Selected = true;
this.UserMsg.MessageSend(string.Format("Processing: {0}", (object) row.Cells[1].Value.ToString()), "Program", UserMessage.msgLevel.Information);
}
}
this.buttonOK_Click((object) null, (EventArgs) null);
}
catch (Exception ex)
{
this.UserMsg.MessageSend(string.Format("Exception: {0}", (object) ex.ToString()), "Program", UserMessage.msgLevel.Error);
}
this.LogFile.createlog();
}
private void LoadGrid(bool resetOffset)
{
Decimal num1 = 0M;
if (!this.ReadyToLoad)
return;
using (new HourGlass())
{
try
{
this.dataGridView1.Rows.Clear();
this.labelTotalOrders.Text = "Total Orders: ";
this.labelSelectedOrders.Text = "Selected Orders: ";
Application.DoEvents();
if (resetOffset)
{
this.listOffset = 0;
this.buttonPrev.Enabled = false;
this.buttonNext.Enabled = true;
}
CraftUtil.SearchFilterGroup[] filtresIn1 = new CraftUtil.SearchFilterGroup[0];
CraftUtil.SearchFilterGroup[] filtresIn2 = new CraftUtil.SearchFilterGroup[0];
CraftUtil.SearchFilterGroup[] filtresIn3 = this.craftUtil.AddFilter2(filtresIn1, "isCompleted", "eq", this.chkBox_Incomplete.Checked ? "false" : "true");
CraftUtil.SearchFilterGroup[] searchFilterGroupArray1 = this.craftUtil.AddFilter2(filtresIn2, "isCompleted", "eq", this.chkBox_Incomplete.Checked ? "false" : "true");
CraftUtil.SearchFilterGroup[] searchFilterGroupArray2 = this.craftUtil.AddFilter2(filtresIn3, "ordered_at", "from", this.dateTimePickerFrom.Value.ToString("yyyy-MM-dd HH:mm:ss"));
CraftUtil craftUtil1 = this.craftUtil;
CraftUtil.SearchFilterGroup[] filtresIn4 = searchFilterGroupArray2;
DateTime dateTime = this.dateTimePickerTo.Value;
dateTime = dateTime.AddDays(1.0);
string str1 = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
CraftUtil.SearchFilterGroup[] searchFilterGroupArray3 = craftUtil1.AddFilter2(filtresIn4, "ordered_at", "to", str1);
CraftUtil craftUtil2 = this.craftUtil;
CraftUtil.SearchFilterGroup[] filtresIn5 = searchFilterGroupArray1;
dateTime = this.dateTimePickerFrom.Value;
string str2 = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
CraftUtil.SearchFilterGroup[] searchFilterGroupArray4 = craftUtil2.AddFilter2(filtresIn5, "dateCompleted", "from", str2);
CraftUtil craftUtil3 = this.craftUtil;
CraftUtil.SearchFilterGroup[] filtresIn6 = searchFilterGroupArray4;
dateTime = this.dateTimePickerTo.Value;
dateTime = dateTime.AddDays(1.0);
string str3 = dateTime.ToString("yyyy-MM-dd HH:mm:ss");
CraftUtil.SearchFilterGroup[] filterGroups = this.craftUtil.AddFilter2(craftUtil3.AddFilter2(filtresIn6, "dateCompleted", "to", str3), "type", "eq", "reorderRequest,default");
if (this.comboBoxCustomer.SelectedIndex > 0)
{
if (this.comboBoxCustomer.SelectedItem.ToString().Split(' ').Length == 0)
;
}
if (this.comboBoxOrderStatus.SelectedIndex > 0)
{
string str4 = this.comboBoxOrderStatus.SelectedItem.ToString();
searchFilterGroupArray3 = !(str4 == "Not complete") ? this.craftUtil.AddFilter2(searchFilterGroupArray3, "status", "eq", str4) : this.craftUtil.AddFilter2(searchFilterGroupArray3, "status", "nin", "Complete");
}
if (this.comboBoxTaxStatus.SelectedIndex <= 0)
;
List<string> stringList = new List<string>();
Order[] orderArray = new Order[0];
Quote[] quoteArray = new Quote[0];
if (this.comboBoxVisualConnect?.SelectedItem.ToString() == "Quotes")
quoteArray = this.craftUtil.Quotes(filterGroups);
else
orderArray = this.craftUtil.Orders(searchFilterGroupArray3);
int num2;
foreach (Quote quote in quoteArray)
{
string id = "";
string str5 = "";
string str6 = "";
string str7 = "";
string str8 = "";
bool flag1 = false;
if (((this.comboBoxStore.Text != "" ? 1 : 0) | 1) != 0)
{
bool flag2 = false;
if (quote.lineItems != null)
{
foreach (QLineitem lineItem in quote.lineItems)
{
if (str7 == "")
str7 = Alias.Get(lineItem.location ?? "");
if (Alias.Get(lineItem.location ?? "") != Alias.Get(lineItem.location ?? "", true))
{
if (Alias.Get(lineItem.location ?? "") + "/" + Alias.Get(lineItem.location ?? "", true) == this.comboBoxStore.Text)
{
flag2 = true;
break;
}
}
else if (Alias.Get(lineItem.location ?? "") == this.comboBoxStore.Text)
{
flag2 = true;
break;
}
}
}
if (this.comboBoxStore.Text != "" && !flag2)
continue;
}
ExternalReferenceService referenceService = this.extRefSvc(str7);
num2 = quote.quoteId;
string ExternalID1 = num2.ToString();
List<ExternalReference.Reference> referenceList1 = referenceService.ExternalReferenceLookup("N", "WebQuote", ExternalID1, "0", "EstimateHeader", (string) null, "0");
if (referenceList1.Count >= 1)
str6 = referenceList1[0].ID;
string str9 = string.Empty;
if (quote.lineItems != null)
{
foreach (QLineitem lineItem in quote.lineItems)
{
if (string.IsNullOrEmpty(lineItem.location))
{
str9 = str9 + "\r\n" + lineItem.sku;
if (!stringList.Contains(lineItem.sku))
stringList.Add(lineItem.sku);
if (lineItem.sku.EndsWith("CS"))
{
lineItem.location = "Century Spring";
}
else
{
string sku = lineItem.sku;
num2 = quote.quoteId;
string str10 = num2.ToString();
int num3 = (int) MBox.Show("No Location specified for SKU: " + sku + " on order: " + str10);
}
}
if (string.IsNullOrEmpty(str8))
{
if (!string.IsNullOrEmpty(lineItem.location))
str8 = Alias.Get(lineItem.location);
}
else if (!string.IsNullOrEmpty(lineItem.location) && str8 != Alias.Get(lineItem.location))
flag1 = true;
}
}
string ExternalID2 = "NOMATCHCUSTOMERID!@#$";
int? nullable = quote.userId;
if (!nullable.HasValue)
{
if (flag1)
{
string str11 = str8;
num2 = quote.quoteId;
string str12 = num2.ToString();
int num4 = (int) MBox.Show("Multiple sites on a Guest Quote. Using site: " + str11 + " For Quote: " + str12);
}
if (string.IsNullOrEmpty(str8))
{
string[] strArray = new string[5]
{
"No Site found on Guest Quote: ",
null,
null,
null,
null
};
num2 = quote.quoteId;
strArray[1] = num2.ToString();
strArray[2] = " ";
strArray[3] = quote.number.Substring(0, 7);
strArray[4] = str9;
int num5 = (int) MBox.Show(string.Concat(strArray));
}
else
ExternalID2 = "[" + str8 + "_Guest]";
}
else
ExternalID2 = quote.visualCustomerId;
if (!string.IsNullOrWhiteSpace(ExternalID2))
{
List<ExternalReference.Reference> referenceList2 = this.extRefSvc(str7).ExternalReferenceLookup("N", "WebCustomer", ExternalID2, "0", "Customer", (string) null, "0");
if (referenceList2.Count >= 1)
{
id = referenceList2[0].ID;
str5 = this.custSvc(str7).LookupNameByID(id);
}
}
DateTime result = new DateTime();
DateTime.TryParse(quote.dateCompleted.date + " " + quote.dateCompleted.time, out result);
if (!(quote.type == "default") || DateTime.Compare(DateTime.Parse(quote.dateCompleted.date), new DateTime(2023, 8, 30)) >= 0)
{
DataGridViewRowCollection rows = this.dataGridView1.Rows;
object[] objArray = new object[16];
objArray[0] = (object) str7;
string[] strArray1 = new string[5];
num2 = quote.quoteId;
strArray1[0] = num2.ToString();
strArray1[1] = " (";
strArray1[2] = QuotePrefixMap.Get(quote.type);
strArray1[3] = ")";
strArray1[4] = flag1 ? " ***" : "";
objArray[1] = (object) string.Concat(strArray1);
objArray[2] = (object) ("QUOTE: " + str6);
objArray[3] = (object) result.ToString("yyyy-MM-dd HH:mm:ss");
nullable = quote.userId;
string str13;
if (nullable.HasValue)
{
nullable = quote.userId;
ref int? local = ref nullable;
if (!local.HasValue)
{
str13 = (string) null;
}
else
{
num2 = local.GetValueOrDefault();
str13 = num2.ToString();
}
}
else
str13 = ExternalID2;
objArray[4] = (object) str13;
objArray[5] = string.IsNullOrEmpty(id) ? (object) quote.visualCustomerId : (object) id;
objArray[6] = (object) (quote.firstName + " " + quote.lastName + " " + quote.company + " " + quote.visualOrderId + " " + quote.visualCustomerId);
objArray[7] = (object) str5;
objArray[8] = (object) quote.email;
objArray[9] = (object) "";
objArray[10] = (object) quote.stage;
objArray[11] = (object) "";
objArray[12] = (object) "";
objArray[13] = (object) "";
objArray[14] = (object) quote.quoteId;
objArray[15] = (object) "";
int index1 = rows.Add(objArray);
this.dataGridView1.Rows[index1].Tag = (object) quote;
this.dataGridView1.Rows[index1].DefaultCellStyle.BackColor = Color.Bisque;
for (int index2 = 0; index2 < this.dataGridView1.ColumnCount; ++index2)
{
if (this.dataGridView1.Columns[index2].HeaderText == "Website Order ID")
{
string str14 = "No line Items";
if (quote.lineItems != null)
{
num2 = quote.lineItems.GetLength(0);
str14 = string.Format("{0} Item(s).", (object) num2.ToString()) + "\r\n itemId : sku/svc : qty : brand";
foreach (QLineitem lineItem in quote.lineItems)
{
string[] strArray2 = new string[10];
strArray2[0] = str14;
strArray2[1] = "\r\n";
nullable = lineItem.purchasableId;
strArray2[2] = nullable.ToString();
strArray2[3] = " : ";
strArray2[4] = lineItem.sku;
strArray2[5] = lineItem.serviceChargeId;
strArray2[6] = " : ";
num2 = lineItem.qty;
strArray2[7] = num2.ToString();
strArray2[8] = " : ";
strArray2[9] = lineItem.location;
str14 = string.Concat(strArray2);
}
}
this.dataGridView1.Rows[index1].Cells[index2].ToolTipText = str14;
}
else if (this.dataGridView1.Columns[index2].HeaderText == "Visual Order ID")
{
string str15 = string.Empty;
foreach (ExternalReference.Reference reference in referenceList1)
str15 = str15 + reference.ID + "\r\n";
this.dataGridView1.Rows[index1].Cells[index2].ToolTipText = str15;
}
else
this.dataGridView1.Rows[index1].Cells[index2].ToolTipText = Convert.ToString(this.dataGridView1.Rows[index1].Cells[index2].Value);
}
if (id != "" || ExternalID2 != null && ExternalID2.EndsWith("_Guest]"))
this.dataGridView1.Rows[index1].Cells["VisualCustomerID"].ReadOnly = true;
}
}
foreach (Order order in orderArray)
{
string id = "";
string str16 = "";
string str17 = "";
string str18 = "";
if (((this.comboBoxStore.Text != "" ? 1 : 0) | 1) != 0)
{
bool flag = false;
if (order.lineItems != null)
{
foreach (Lineitem lineItem in order.lineItems)
{
if (str18 == "")
str18 = Alias.Get(lineItem.location ?? "");
if (Alias.Get(lineItem.location ?? "") != Alias.Get(lineItem.location ?? "", true))
{
if (Alias.Get(lineItem.location ?? "") + "/" + Alias.Get(lineItem.location ?? "", true) == this.comboBoxStore.Text)
{
flag = true;
break;
}
}
else if (Alias.Get(lineItem.location ?? "") == this.comboBoxStore.Text)
{
flag = true;
break;
}
}
}
if (this.comboBoxStore.Text != "" && !flag)
continue;
}
ExternalReferenceService referenceService = this.extRefSvc(str18);
num2 = order.id;
string ExternalID3 = num2.ToString();
List<ExternalReference.Reference> referenceList3 = referenceService.ExternalReferenceLookup("N", "WebOrder", ExternalID3, "0", "CustomerOrderHeader", (string) null, "0");
if (referenceList3.Count >= 1)
str17 = referenceList3[0].ID;
string str19 = string.Empty;
string str20 = "";
bool flag3 = false;
if (order.lineItems != null)
{
foreach (Lineitem lineItem in order.lineItems)
{
if (string.IsNullOrEmpty(lineItem.location))
{
str19 = str19 + "\r\n" + lineItem.sku;
if (!stringList.Contains(lineItem.sku))
stringList.Add(lineItem.sku);
if (lineItem.sku.EndsWith("CS"))
{
lineItem.location = "Century Spring";
}
else
{
string sku = lineItem.sku;
num2 = order.id;
string str21 = num2.ToString();
int num6 = (int) MBox.Show("No Location specified for SKU: " + sku + " on order: " + str21);
}
}
if (string.IsNullOrEmpty(str20))
{
if (!string.IsNullOrEmpty(lineItem.location))
str20 = Alias.Get(lineItem.location);
}
else if (!string.IsNullOrEmpty(lineItem.location) && str20 != Alias.Get(lineItem.location))
flag3 = true;
}
}
string ExternalID4 = "NOMATCHCUSTOMERID!@#$";
if (string.IsNullOrEmpty(order.customer.userId))
{
if (flag3 && order.status == "new")
{
string str22 = str20;
num2 = order.id;
string str23 = num2.ToString();
int num7 = (int) MBox.Show("Multiple sites on a Guest Order. Using site: " + str22 + " For Order: " + str23);
}
if (string.IsNullOrEmpty(str20))
{
string[] strArray = new string[5]
{
"No Site found on Guest Order: ",
null,
null,
null,
null
};
num2 = order.id;
strArray[1] = num2.ToString();
strArray[2] = " ";
strArray[3] = order.reference;
strArray[4] = str19;
int num8 = (int) MBox.Show(string.Concat(strArray));
}
else
ExternalID4 = "[" + str20 + "_Guest]";
}
else
ExternalID4 = order.customerId;
List<ExternalReference.Reference> referenceList4 = this.extRefSvc(str18).ExternalReferenceLookup("N", "WebCustomer", ExternalID4, "0", "Customer", (string) null, "0");
if (referenceList4.Count >= 1)
{
id = referenceList4[0].ID;
str16 = this.custSvc(str18).LookupNameByID(id);
}
if (this.comboBoxVisualConnect.SelectedIndex >= 0)
{
Shippingaddress shippingaddress = order.shippingAddress ?? new Shippingaddress();
Adjustment adjustment1 = ((IEnumerable<Adjustment>) order.adjustments).Where<Adjustment>((Func<Adjustment, bool>) (x => x.type == "shipping")).FirstOrDefault<Adjustment>() ?? new Adjustment();
Adjustment adjustment2 = ((IEnumerable<Adjustment>) order.adjustments).Where<Adjustment>((Func<Adjustment, bool>) (x => x.type == "tax")).FirstOrDefault<Adjustment>() ?? new Adjustment();
Adjustment adjustment3 = ((IEnumerable<Adjustment>) order.adjustments).Where<Adjustment>((Func<Adjustment, bool>) (x => x.type == "small-order")).FirstOrDefault<Adjustment>() ?? new Adjustment();
if (string.IsNullOrEmpty(this.comboBoxVisualConnect.SelectedItem.ToString()) || this.comboBoxVisualConnect.SelectedItem.ToString() == "Customer" && id != "" || this.comboBoxVisualConnect.SelectedItem.ToString() == "Customer Only" && str17 == "" && id != "" || this.comboBoxVisualConnect.SelectedItem.ToString() == "Order" && str17 != "" || this.comboBoxVisualConnect.SelectedItem.ToString() == "No Order" && str17 == "" || this.comboBoxVisualConnect.SelectedItem.ToString() == "Neither" && str17 == "" && id == "")
{
DataGridViewRowCollection rows = this.dataGridView1.Rows;
object[] objArray = new object[16];
objArray[0] = (object) str18;
string[] strArray3 = new string[6];
num2 = order.id;
strArray3[0] = num2.ToString();
strArray3[1] = " (";
strArray3[2] = order.reference;
strArray3[3] = ") ";
strArray3[4] = OrderPrefixMap.Get(order.type);
strArray3[5] = flag3 ? " ***" : "";
objArray[1] = (object) string.Concat(strArray3);
objArray[2] = (object) str17;
objArray[3] = (object) order.dateOrdered.date.Substring(0, 19);
objArray[4] = string.IsNullOrEmpty(order.customer.userId) ? (object) ExternalID4 : (object) order.customerId;
objArray[5] = (object) id;
objArray[6] = (object) ((order.customer?.user?.firstName ?? order.billingAddress?.firstName) + " " + (order.customer?.user?.lastName ?? order.billingAddress?.lastName) + (order.customer?.user?.visualId == null || !this.Debug ? "" : " {" + order.customer?.user?.visualId + "}"));
objArray[7] = (object) str16;
objArray[8] = (object) order.email;
objArray[9] = (object) shippingaddress.phone;
objArray[10] = (object) order.status;
objArray[11] = (object) (order.lastTransaction?.paymentAmountAsCurrency ?? "No CC Info");
objArray[12] = Convert.ToDecimal(order.totalTax) == 0M ? (object) "" : (object) "Taxed";
objArray[13] = (object) (order.shippingAddress?.id.ToString() + " " + order.shippingMethodName);
objArray[14] = (object) order.id;
Decimal num9 = order.total;
objArray[15] = (object) (num9.ToString() + " : " + order.couponCode);
int index3 = rows.Add(objArray);
this.dataGridView1.Rows[index3].Tag = (object) order;
if (!order.customer?.user?.termsCustomer.GetValueOrDefault() && order.paymentMethod != "creditCard")
{
this.dataGridView1.Rows[index3].DefaultCellStyle.BackColor = Color.Red;
this.dataGridView1.Rows[index3].DefaultCellStyle.ForeColor = Color.White;
}
for (int index4 = 0; index4 < this.dataGridView1.ColumnCount; ++index4)
{
if (this.dataGridView1.Columns[index4].HeaderText == "Shipping")
{
string str24 = "";
string str25 = "" + " \r\n" + shippingaddress.id + " \r\n" + shippingaddress.firstName + " \r\n" + shippingaddress.lastName;
num9 = order.totalShippingCost;
string str26 = num9.ToString();
string str27 = str25 + " \r\n" + str26 + " \r\n" + order.shippingMethodName + " \r\n" + order.shippingAccountNumber + " \r\n" + order.deliveryInstructions;
this.dataGridView1.Rows[index3].Cells[index4].ToolTipText = str27 + "\r\n" + str24;
}
else if (this.dataGridView1.Columns[index4].HeaderText == "Website Order ID")
{
string str28 = "No line Items";
if (order.lineItems != null)
{
num2 = order.lineItems.GetLength(0);
str28 = string.Format("{0} Item(s).", (object) num2.ToString()) + "\r\n itemId : desc : price : sku : qty : brand";
foreach (Lineitem lineItem in order.lineItems)
{
string[] strArray4 = new string[11];
strArray4[0] = str28;
strArray4[1] = "\r\n";
strArray4[2] = lineItem.purchasableId;
strArray4[3] = " : ";
num9 = lineItem.price;
strArray4[4] = num9.ToString();
strArray4[5] = " : ";
strArray4[6] = lineItem.sku;
strArray4[7] = " : ";
num9 = lineItem.qty;
strArray4[8] = num9.ToString();
strArray4[9] = " : ";
strArray4[10] = lineItem.location;
str28 = string.Concat(strArray4);
}
}
string str29 = str28 + "\r\n\r\n Adjustments" + "\r\n Small Order Fee : " + adjustment3.amountAsCurrency + "\r\n Tax : " + adjustment2.amountAsCurrency + "\r\n Shipping : " + adjustment1.name + " : " + adjustment1.amountAsCurrency;
this.dataGridView1.Rows[index3].Cells[index4].ToolTipText = str29;
}
else if (this.dataGridView1.Columns[index4].HeaderText == "Visual Order ID")
{
string str30 = string.Empty;
foreach (ExternalReference.Reference reference in referenceList3)
str30 = str30 + reference.ID + "\r\n";
this.dataGridView1.Rows[index3].Cells[index4].ToolTipText = str30;
}
else if (this.dataGridView1.Columns[index4].HeaderText == "Payment Auth")
{
string str31 = "No CC Info";
if (order.lastTransaction != null)
{
string str32 = "method: " + order.paymentMethod + "\r\n Id : " + order.lastTransaction.id + "\r\n orderId : " + order.lastTransaction.orderId + "\r\n parentId : " + order.lastTransaction.parentId + "\r\n userId : " + order.lastTransaction.userId + "\r\n hash : " + order.lastTransaction.hash + "\r\n gatewayId : " + order.lastTransaction.gatewayId + "\r\n currency : " + order.lastTransaction.currency;
num9 = order.lastTransaction.paymentAmount;
string str33 = num9.ToString();
string str34 = str32 + "\r\n paymentAmount : " + str33 + "\r\n paymentCurrency : " + order.lastTransaction.paymentCurrency + "\r\n paymentRate : " + order.lastTransaction.paymentRate + "\r\n type : " + order.lastTransaction.type;
num9 = order.lastTransaction.amount;
string str35 = num9.ToString();
string str36 = str34 + "\r\n amount : " + str35 + "\r\n status : " + order.lastTransaction.status + "\r\n reference : " + order.lastTransaction.reference + "\r\n code : " + order.lastTransaction.code + "\r\n message : " + order.lastTransaction.message + "\r\n note : " + order.lastTransaction.note;
dateTime = order.lastTransaction.dateCreated;
string shortDateString1 = dateTime.ToShortDateString();
string str37 = str36 + "\r\n dateCreated : " + shortDateString1;
dateTime = order.lastTransaction.dateUpdated;
string shortDateString2 = dateTime.ToShortDateString();
str31 = str37 + "\r\n dateUpdated : " + shortDateString2 + "\r\n amountAsCurrency : " + order.lastTransaction.amountAsCurrency + "\r\n paymentAmountAsCurrency : " + order.lastTransaction.paymentAmountAsCurrency + "\r\n refundableAmountAsCurrency : " + order.lastTransaction.refundableAmountAsCurrency;
}
this.dataGridView1.Rows[index3].Cells[index4].ToolTipText = str31;
}
else
this.dataGridView1.Rows[index3].Cells[index4].ToolTipText = Convert.ToString(this.dataGridView1.Rows[index3].Cells[index4].Value);
}
if (id != "" || ExternalID4 != null && ExternalID4.EndsWith("_Guest]"))
this.dataGridView1.Rows[index3].Cells["VisualCustomerID"].ReadOnly = true;
if (order.lastTransaction != null)
num1 += order.lastTransaction.amount;
}
}
}
if (this.Debug && stringList.Count > 0)
{
stringList.Sort();
string text = string.Empty;
int num10 = 1;
foreach (string str38 in stringList)
{
string[] strArray = new string[5]
{
text,
null,
null,
null,
null
};
num2 = num10++;
strArray[1] = num2.ToString();
strArray[2] = ". ";
strArray[3] = str38;
strArray[4] = "\r\n";
text = string.Concat(strArray);
}
int num11 = (int) MBox.Show(text, "Parts with no Location specified");
}
this.dataGridView1.Sort(this.dataGridView1.Columns["OrderDate"], ListSortDirection.Ascending);
if (this.dataGridView1.Rows.Count > 0)
this.dataGridView1.ClearSelection();
Label labelTotalOrders1 = this.labelTotalOrders;
num2 = this.dataGridView1.Rows.Count;
string str39 = "Total Orders: " + num2.ToString();
labelTotalOrders1.Text = str39;
if (this.Debug)
{
Label labelTotalOrders2 = this.labelTotalOrders;
labelTotalOrders2.Text = labelTotalOrders2.Text + " Total Sold: " + num1.ToString("C");
}
Label labelSelectedOrders = this.labelSelectedOrders;
num2 = this.dataGridView1.SelectedRows.Count;
string str40 = "Selected Orders: " + num2.ToString();
labelSelectedOrders.Text = str40;
}
catch (Exception ex)
{
int num12 = (int) MBox.Show(ex.ToString());
}
}
}
private bool isWindowVisible(Rectangle rect)
{
foreach (Screen allScreen in Screen.AllScreens)
{
if (allScreen.Bounds.IntersectsWith(rect))
return true;
}
return false;
}
internal int findDB(string visualSite)
{
string str = SiteDBMap.Get(visualSite);
if (str == Settings.Default.VMKey)
return 1;
return str == Settings.Default.VMKey2 ? 2 : 0;
}
internal ExternalReferenceService extRefSvc(string visualSite)
{
switch (this.findDB(visualSite))
{
case 1:
return this.extRefSvc1;
case 2:
return this.extRefSvc2;
default:
return this.extRefSvc1;
}
}
internal CustomerService custSvc(string location)
{
switch (this.findDB(location))
{
case 1:
return this.custSvc1;
case 2:
return this.custSvc2;
default:
return this.custSvc1;
}
}
internal SalesOrderService orderSvc(string location)
{
switch (this.findDB(location))
{
case 1:
return this.orderSvc1;
case 2:
return this.orderSvc2;
default:
return this.orderSvc1;
}
}
internal ContactService contactSvc(string location)
{
switch (this.findDB(location))
{
case 1:
return this.contactSvc1;
case 2:
return this.contactSvc2;
default:
return this.contactSvc1;
}
}
internal NotationService notationSvc(string location)
{
switch (this.findDB(location))
{
case 1:
return this.notationSvc1;
case 2:
return this.notationSvc2;
default:
return this.notationSvc1;
}
}
internal InventoryService inventorySvc(string location)
{
switch (this.findDB(location))
{
case 1:
return this.inventorySvc1;
case 2:
return this.inventorySvc2;
default:
return this.inventorySvc1;
}
}
internal EstimateService quoteSvc(string location)
{
switch (this.findDB(location))
{
case 1:
return this.quoteSvc1;
case 2:
return this.quoteSvc2;
default:
return this.quoteSvc1;
}
}
internal UserDefinedFieldService UDFSvc(string location)
{
switch (this.findDB(location))
{
case 1:
return this.UDFSvc1;
case 2:
return this.UDFSvc2;
default:
return this.UDFSvc1;
}
}