-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDefault.aspx.vb
More file actions
4576 lines (3740 loc) · 181 KB
/
Default.aspx.vb
File metadata and controls
4576 lines (3740 loc) · 181 KB
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
Imports BusinessManagers.Implementation
Imports BusinessManagers.Interfaces
Imports System.Data.SqlClient
Imports System.Data
Imports System.IO
Imports System.Web
Imports System.Web.UI.WebControls
Imports Telerik.Web.UI
Imports Subgurim.Controles
Imports System.Collections.Generic
Imports TrailerLoading
Imports System.Web.Security
Imports System.Web.Mail
Imports System.Net
Imports System.Text
Imports System.Reflection
Imports System
Imports System.Collections
Imports Org.BouncyCastle.Asn1.X509.Qualified
Imports System.Diagnostics
Partial Class LoadConsolidation_Default
Inherits System.Web.UI.Page
Dim sameNode As String = ""
Dim dtNow As DateTime = DateTime.Now
Dim RefreshDS As String
Dim isUpdated As Integer = 0
Dim _status As String = ""
Dim _queue As String = ""
Dim obj As New CCommon
Dim loadConsolidationManager As LoadConsolidationManager
Dim accessorialsManager As AccessorialsManager
Dim orderRoutingManager As OrderRoutingManager
Dim objShipmentsManager As ShipmentsManager
Dim objCommonManager As CommonManager
Dim shipManager As ShipmentsManager
Dim iCal As Integer = 0
Public rNumb As New Random
Public val As Decimal
Public Shared noOfAxles
Public Shared axleSpacing
Public Shared MovieName As String
Public Shared drawMCTop
Public Shared drawMCSide
Public Shared drawMCEnd
Public Shared FAlpha = 100
Public Shared ColorName = "green"
Public Shared c = 0
Public Shared nextCntBurstWgt = 10000
Public Shared posW As Decimal = 0
Public Shared posWE As Decimal = 0
Public Shared posL As Decimal = 0
Public Shared posH As Decimal = 0
Public Shared trailerRow = 1
Public Shared cntBurstWeight = 10000
Public Shared prevCntArea = 61056
Public Shared cntArea = 0
Public Shared cntRemainArea = 10000
Public Shared contactArea '= 0
Public Shared contactAreaBurstPsiGood = True
Public Shared noCntLoaded = 0
Public Shared noCntOnTruck = 0
Public Shared noSurfLoaded = 0
Public Shared noSurfRemoved = 0
Public Shared noSurfChecked = 0
Public Shared nextCntWidth As Decimal = 0
Public Shared nextCntLength As Decimal = 0
Public Shared nextCntHeight As Decimal = 0
Public Shared nextCntID
Public Shared cntLoading = 0
Public Shared prevCntID = 0
Public Shared widthRemain As Decimal = 0
Public Shared nextCntBurstWeight = 0
Public Shared nextCntWgt = 0
Public Shared loadedTrailerWgt = 0
Public Shared maxTrailerW = 97 'pull from web later
Public Shared maxTrailerL = 636 'pull from web later
Public Shared maxTrailerH = 109 'pull from web later
Public Shared truckNetWeight = 15000
Public Shared trailerNetWeight = 13000
Public Shared driveAxleNetLoad = (truckNetWeight / 2) + (trailerNetWeight / 2)
Public Shared rearAxleNetLoad = trailerNetWeight / 2
Public Shared maxTrailerWgt = 54000 'pull from web later
Public Shared singleDriveAxle As Boolean = False
Public Shared tandemDriveAxle As Boolean = False
Public Shared singleRearAxle As Boolean = False
Public Shared tandemRearAxle As Boolean = False
Public Shared minTrailerLength As Decimal = 0
Public Shared minTrailerLengthFeet = 0
Public Shared minTrailerlengthInches = 0
Public Shared totalNoOfCnts = 16 'pull from web later
Public Shared hitFlagTop = False
Public Shared hitFlagSide = False
Public Shared hitFlagEnd = False
Public Shared hitFlagTrailer = False
Public Shared hitFlagCnt = False
Public Shared p2HitFlag As Boolean = False
Public Shared p1HitFlag As Boolean = False
Public Shared heightPln = 0
Public Shared topOffsetX = 40
Public Shared topOffsetY = 80
Public Shared sideOffsetX = 40
Public Shared sideOffsetY = 351 + 109
Public Shared endOffsetX = 867
Public Shared endOffsetY = 460
Public Shared cntSeqNoInHeightPln = 0
Public Shared p8x As Decimal
Public Shared p8y As Decimal
Public Shared p8z As Decimal
Public Shared p2x As Decimal
Public Shared p2y As Decimal
Public Shared p2z As Decimal
Public Shared p3x As Decimal
Public Shared p3y As Decimal
Public Shared p3z As Decimal
Public Shared p4x As Decimal
Public Shared p4y As Decimal
Public Shared p4z As Decimal
Public Shared p5x As Decimal
Public Shared p5y As Decimal
Public Shared p5z As Decimal
Public Shared p6x As Decimal
Public Shared p6y As Decimal
Public Shared p6z As Decimal
Public Shared p7x As Decimal
Public Shared p7y As Decimal
Public Shared p7z As Decimal
Public Shared p1xHit = False
Public Shared p1yHit = False
Public Shared p1zHit = False
Public Shared p2xHit = False
Public Shared p2yHit = False
Public Shared p2zHit = False
Public Shared p3xHit = False
Public Shared p3yHit = False
Public Shared p3zHit = False
Public Shared p4xHit = False
Public Shared p4yHit = False
Public Shared p4zHit = False
Public Shared p5xHit = False
Public Shared p5yHit = False
Public Shared p5zHit = False
Public Shared p6xHit = False
Public Shared p6yHit = False
Public Shared p6zHit = False
Public Shared p7xHit = False
Public Shared p7yHit = False
Public Shared p7zHit = False
Public Shared p8xHit = False
Public Shared p8yHit = False
Public Shared p8zHit = False
Public Shared tmpp1xHit = False
Public Shared tmpp1yHit = False
Public Shared tmpp1zHit = False
Public Shared tmpp2xHit = False
Public Shared tmpp2yHit = False
Public Shared tmpp2zHit = False
Public Shared tmpp3xHit = False
Public Shared tmpp3yHit = False
Public Shared tmpp3zHit = False
Public Shared tmpp4xHit = False
Public Shared tmpp4yHit = False
Public Shared tmpp4zHit = False
Public Shared tmpp5xHit = False
Public Shared tmpp5yHit = False
Public Shared tmpp5zHit = False
Public Shared tmpp6xHit = False
Public Shared tmpp6yHit = False
Public Shared tmpp6zHit = False
Public Shared tmpp7xHit = False
Public Shared tmpp7yHit = False
Public Shared tmpp7zHit = False
Public Shared tmpp8xHit = False
Public Shared tmpp8yHit = False
Public Shared tmpp8zHit = False
Public Shared tmpP8x As Decimal
Public Shared topFrontCheck = False
Public Shared contactAreaSizeOk = False
Public Shared checkTopNextCounter = 0
Public Shared minBurstStrength = 0
Public Shared tmpMinBurstStrength = 0
Public Shared tmpP8xVal As Decimal = 0
Public Shared kingPinOverHang = 60
Public Shared driveAxleWgt = driveAxleNetLoad
Public Shared rearAxleWgt = rearAxleNetLoad
Public Shared txtInit = 0
Public Shared startTime
Public Shared endTime
Public Shared nowTime
Public Shared lX = 0
Public Const gridSizeS = 34
Public Const ArrayNumberS = 1000
Public Const gridSizeC = 13
Public Const ArrayNumberC = 1000
Public Shared loadArrC(ArrayNumberC, gridSizeC) As String
Public Shared surfaceArr(ArrayNumberS, gridSizeS) As String
Public Shared p2HitFlagArr(100, 3) As String
Public Shared p1HitFlagArr(100, 3) As String
Public Shared surfFound As Boolean = False
Public Shared verticalContact As Boolean = False
Public Shared verticalContactRight As Boolean = False
Public Shared surfaceContact As Boolean = False
Public Shared foundMatch As Boolean = False
Public Shared burstStrength = 0
Public Shared p2HitFlagCounter As Integer = 0
Public Shared p1HitFlagCounter As Integer = 0
Public Shared driveAxleNoTxt As String
Public Shared rearAxleNoTxt As String
#Region "ReadOnly Property"
Public ReadOnly Property userCode() As Double
Get
Try
Return Convert.ToDouble(obj.gblUserCode)
Catch ex As Exception
Return 0.0
End Try
End Get
End Property
Public ReadOnly Property TimeZoneCode() As Double
Get
Try
Return Convert.ToDouble(obj.gblLocalComputerTimeZoneCode)
Catch ex As Exception
Return 0.0
End Try
End Get
End Property
Public ReadOnly Property DefaultShipper() As Double
Get
Try
Return Convert.ToDouble(obj.gblDefaultShipper)
Catch ex As Exception
Return 0.0
End Try
End Get
End Property
Public ReadOnly Property MultipleFOBSelection() As Double
Get
Try
Return Convert.ToDouble(obj.gblMultipleFOBSelection)
Catch ex As Exception
Return 0.0
End Try
End Get
End Property
Public ReadOnly Property defaultMeasure() As Double
Get
Try
Return Convert.ToDouble(obj.gblDefaultMeasure)
Catch ex As Exception
Return 0.0
End Try
End Get
End Property
Public ReadOnly Property Origin_Destination() As String
Get
Try
If hdnSelectedRegion IsNot Nothing AndAlso Not String.IsNullOrWhiteSpace(hdnSelectedRegion.Value) Then
Return hdnSelectedRegion.Value.Trim() + "$%?|*"
End If
Return Me.grdLoadConsolidation.MasterTableView.GetColumn("Origin").CurrentFilterValue + "$%?|*" + Me.grdLoadConsolidation.MasterTableView.GetColumn("Destination").CurrentFilterValue
Catch ex As Exception
Return String.Empty
End Try
End Get
End Property
#End Region
Protected Sub grdLoadConsolidation_CustomAggregate(ByVal sender As Object, ByVal e As GridCustomAggregateEventArgs)
Dim str As String = ""
If (grdLoadConsolidation.Items.Count > 0) Then
Dim item = DirectCast(grdLoadConsolidation.Items(0), GridDataItem)
If item IsNot Nothing Then
str += item.GetDataKeyValue("Summary_Current")
End If
End If
e.Result = str
End Sub
Private Sub RedirectToMainLoginPage()
Const loginUrl As String = "~/Common/Login.aspx"
If ScriptManager.GetCurrent(Me) IsNot Nothing AndAlso ScriptManager.GetCurrent(Me).IsInAsyncPostBack Then
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "SessionTimeoutRedirect", "window.top.location='" & ResolveUrl(loginUrl) & "';", True)
Context.ApplicationInstance.CompleteRequest()
Else
Response.Redirect(loginUrl, False)
Context.ApplicationInstance.CompleteRequest()
End If
End Sub
Protected Sub btnApprove_Click(ByVal sender As Object, ByVal e As System.EventArgs)
If (Session.IsNewSession) Then
RedirectToMainLoginPage()
Exit Sub
End If
Try
Dim isSelectedCheckbox As Boolean = False
If (obj.gblInvoiceAdjustments = -1) Then
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Msg", "alert('You are not authorized to approve invoices!')", True)
Exit Sub
End If
For Each grdItem As GridDataItem In grdLoadConsolidation.Items
Dim chkTender As CheckBox = DirectCast(grdItem.FindControl("chkTender"), CheckBox)
If (chkTender.Checked = True) Then
isSelectedCheckbox = True
End If
Next
If isSelectedCheckbox = False Then
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Msg", "alert('Please make a selection.');", True)
UnCheckedChk()
Exit Sub
For Each grdItem As GridItem In grdLoadConsolidation.Items
Dim chkTender As CheckBox = DirectCast(grdItem.FindControl("chkTender"), CheckBox)
If (chkTender.Checked = True) Then
Dim LoadNumberDetails As Double = 0
LoadNumberDetails = grdItem.OwnerTableView.DataKeyValues(grdItem.ItemIndex)("LoadNumber")
Dim dtShipmentTender As DataTable = shipManager.getShipmentTender(LoadNumberDetails, userCode)
End If
Next
Else
Dim LoadNumberDetails As Double = 0
For Each grdItem As GridItem In grdLoadConsolidation.Items
Dim chkTender As CheckBox = DirectCast(grdItem.FindControl("chkTender"), CheckBox)
If (chkTender.Checked = True) Then
Dim cmd As New SqlCommand
Dim db As New CDatabase
Dim dtShipmentTender As New DataTable
Dim proNumber As String = grdItem.Cells(12).Text
'LoadNumberDetails = grdItem.OwnerTableView.DataKeyValues(grdItem.ItemIndex)("LoadNumber")
'objcmd.CommandTimeout = 50000
'cmd.Parameters.Add(New SqlParameter("@SessionID", userCode))
'cmd.Parameters.Add(New SqlParameter("@LoadNumber", LoadNumberDetails))
'dtShipmentTender = db.FillDataSql("spInvoiceSummaryApproval", cmd).Tables(0)
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('You are not authorized to print Proof of Deliveries!');", True)
End If
Next
End If
Catch ex As Exception
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred_1!');", True)
End Try
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Session.IsNewSession) Then
RedirectToMainLoginPage()
Else
Try
MenuImage()
If Not Page.IsPostBack Then
hdnAllowedRegionIds.Value = GetAllowedRegionIdsCsv()
' Req 9: Skip Selection Criteria overlay, load grid directly
Session.Remove("grdLoadConsolidationData")
Session.Remove("childDataCache")
loadConsolidation_MainGrid()
Else
loadConsolidation_MainGrid()
End If
Catch ex As Exception
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred_2!');", True)
End Try
End If
End Sub
Private Function GetAllowedRegionIdsCsv() As String
Try
If obj Is Nothing Then
obj = TryCast(Session("COMMON_OBJ"), CCommon)
End If
If obj Is Nothing Then
Return String.Empty
End If
Using connection As New SqlConnection(ConfigurationManager.ConnectionStrings("ConStr").ConnectionString)
Using command As New SqlCommand("sp000001942514572", connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.AddWithValue("@P001", obj.gblUserCode)
Dim outputParam As New SqlParameter("@P002", SqlDbType.VarChar, -1)
outputParam.Direction = ParameterDirection.Output
command.Parameters.Add(outputParam)
connection.Open()
command.ExecuteNonQuery()
If outputParam.Value Is Nothing OrElse outputParam.Value Is DBNull.Value Then
Return String.Empty
End If
Return Convert.ToString(outputParam.Value).Trim()
End Using
End Using
Catch ex As Exception
Return String.Empty
End Try
End Function
'Protected Sub btnProcess_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnProcess.Click
' If (Session.IsNewSession) Then
' Response.Redirect("~/Common/Login.aspx")
' Exit Sub
' End If
'End Sub
Protected Overrides Sub OnInit(ByVal e As System.EventArgs)
Try
obj = Session("COMMON_OBJ")
loadConsolidationManager = New BusinessManagers.Implementation.LoadConsolidationManager()
accessorialsManager = New BusinessManagers.Implementation.AccessorialsManager
orderRoutingManager = New BusinessManagers.Implementation.OrderRoutingManager()
objShipmentsManager = New BusinessManagers.Implementation.ShipmentsManager()
objCommonManager = New BusinessManagers.Implementation.CommonManager()
MyBase.OnInit(e)
Catch ex As Exception
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred_3!');", True)
End Try
End Sub
'Protected Sub Page_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
' If (Session.IsNewSession) Then
' Response.Redirect("~/Common/Login.aspx")
' Exit Sub
' End If
' Try
' If Not Page.IsPostBack Then
' If (iCal = 0) Then
' If (Session("login") IsNot Nothing) Then
' If (Session("login") = "Y") Then
' MPLoadConsolidation.Show()
' End If
' End If
' End If
' End If
' Catch ex As Exception
' ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred_4!');", True)
' End Try
'End Sub
Private Sub UnCheckedChk()
If (Session.IsNewSession) Then
RedirectToMainLoginPage()
Exit Sub
End If
For Each grdItem As GridDataItem In grdLoadConsolidation.Items
Dim chkTender As CheckBox = DirectCast(grdItem.FindControl("chkTender"), CheckBox)
chkTender.Checked = False
Next
End Sub
Private Sub MenuImage()
Dim RadMenuCtrl As New RadMenu
RadMenuCtrl = Me.Master.FindControl("Menu1")
RadMenuCtrl.Visible = False
Dim RadMenuCtrl2 As New RadMenu
RadMenuCtrl2 = Me.Master.FindControl("menu2")
RadMenuCtrl2.Visible = True
Dim ctrl As New System.Web.UI.WebControls.Image
ctrl = Me.Master.FindControl("Image2")
ctrl.ImageUrl = "~/Images/caption_load_consolidation.png"
End Sub
'Private Sub LoadCostCenter(ByVal filter As String)
' If (Session.IsNewSession) Then
' Response.Redirect("~/Common/Login.aspx")
' Exit Sub
' End If
' Try
' Dim cmd As New SqlCommand
' Dim dt As New DataTable
' Dim db1 As New CDatabase
' cmd.Parameters.Add(New SqlParameter("@start", filter))
' cmd.Parameters.Add(New SqlParameter("@MultipleFOBSelection", MultipleFOBSelection))
' cmd.Parameters.Add(New SqlParameter("@DefaultFOBPoint", DefaultShipper))
' cmd.Parameters.Add(New SqlParameter("@SessionID", userCode))
' ddlCostCenter.DataSource = db1.FillDataSql("spFOBList", cmd).Tables(0)
' ddlCostCenter.DataTextField = "ContactAddress"
' ddlCostCenter.DataValueField = "ContactCode"
' ddlCostCenter.DataBind()
' Catch ex As Exception
' ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred!');", True)
' End Try
'End Sub
'Protected Sub ddlCostCenter_ItemsRequested(ByVal o As Object, ByVal e As Telerik.Web.UI.RadComboBoxItemsRequestedEventArgs) Handles ddlCostCenter.ItemsRequested
' If (Session.IsNewSession) Then
' Response.Redirect("~/Common/Login.aspx")
' Exit Sub
' End If
' Try
' LoadCostCenter(e.Text)
' Catch ex As Exception
' ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred!');", True)
' End Try
'End Sub
'Protected Sub btnProcess_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnProcess.Click
' If (Session.IsNewSession) Then
' Response.Redirect("~/Common/Login.aspx")
' Exit Sub
' End If
' Try
' Dim cmd As New SqlCommand
' Dim db As New CDatabase
' Dim obj As New CCommon
' obj = Session("COMMON_OBJ")
' Dim dt As New DataTable
' Dim objcmd As New SqlCommand
' cmd.CommandTimeout = 50000
' Dim isCalculation As Integer = 0
' Dim connection As SqlConnection = New SqlConnection()
' connection.ConnectionString = ConfigurationManager.ConnectionStrings("ConStr").ConnectionString
' Dim command As New SqlCommand("sp000000777217971", connection)
' command.CommandType = CommandType.StoredProcedure
' command.Parameters.Add("@P001", SqlDbType.Bit).Direction = ParameterDirection.Output
' connection.Open()
' command.ExecuteNonQuery()
' isCalculation = Convert.ToInt32(command.Parameters("@P001").Value)
' connection.Close()
' If (isCalculation <> 1) Then
' objcmd.Parameters.Clear()
' objcmd.Parameters.Add(New SqlParameter("@P001", obj.gblUserCode))
' objcmd.Parameters.Add(New SqlParameter("@P002", obj.gblDefaultMeasure))
' objcmd.Parameters.Add(New SqlParameter("@P003", obj.gblDefaultMeasure))
' dt = db.FillDataSql("sp000001741100755", objcmd).Tables(0)
' grdLoadConsolidation.Visible = False
' grdLoadConsolidation.DataSource = dt
' grdLoadConsolidation.Visible = True
' grdLoadConsolidation.Rebind()
' Else
' ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('Calculations are in progress!');", True)
' grdLoadConsolidation.Visible = False
' menuLoadConsolidation.Visible = False
' End If
' Catch ex As Exception
' ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred_5!');", True)
' iCal = 0
' End Try
'End Sub
Protected Sub loadConsolidation_MainGrid()
If (Session.IsNewSession) Then
RedirectToMainLoginPage()
Exit Sub
End If
Try
If (iCal = 0) Then
' If data is already cached in session, skip DB call and let NeedDataSource handle pagination
If Session("grdLoadConsolidationData") IsNot Nothing Then
grdLoadConsolidation.Visible = True
dropdownTreeContainer.Visible = True
Exit Sub
End If
If (Session("login") IsNot Nothing) Then
If (Session("login") = "Y") Then
Dim cmd As New SqlCommand
Dim db As New CDatabase
Dim obj As New CCommon
obj = Session("COMMON_OBJ")
Dim dt As New DataTable
Dim objcmd As New SqlCommand
cmd.CommandTimeout = 50000
Dim isCalculation As Integer = 0
Dim connection As SqlConnection = New SqlConnection()
connection.ConnectionString = ConfigurationManager.ConnectionStrings("ConStr").ConnectionString
Dim command As New SqlCommand()
command.Connection = connection
command.CommandText = "sp000000777217971"
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@P001", SqlDbType.Bit).Direction = ParameterDirection.Output
connection.Open()
command.ExecuteNonQuery()
isCalculation = Convert.ToInt32(command.Parameters("@P001").Value)
connection.Close()
Select Case isCalculation
Case Is <> 1
' sp000001812195728 intentionally not executed (disabled).
objcmd.Parameters.Add(New SqlParameter("@P001", obj.gblUserCode))
objcmd.Parameters.Add(New SqlParameter("@P002", obj.gblDefaultMeasure))
objcmd.Parameters.Add(New SqlParameter("@P003", obj.gblDefaultMeasure))
dt = db.FillDataSql("sp000001741100755", objcmd).Tables(0)
Session("grdLoadConsolidationData") = dt
Session.Remove("childDataCache")
grdLoadConsolidation.Visible = False
grdLoadConsolidation.DataSource = dt
grdLoadConsolidation.Visible = True
dropdownTreeContainer.Visible = True
grdLoadConsolidation.Rebind()
Case Else
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('Calculations are in progress!');", True)
grdLoadConsolidation.Visible = False
dropdownTreeContainer.Visible = False
End Select
End If
End If
End If
Catch ex As Exception
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred_5!');", True)
iCal = 0
End Try
End Sub
Protected Sub grdLoadConsolidation_detailDataBind(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs)
If (Session.IsNewSession) Then
RedirectToMainLoginPage()
Exit Sub
End If
Try
Dim FOBCodeData As GridDataItem = DirectCast(e.DetailTableView.ParentItem, GridDataItem)
Dim FOBCode As String = FOBCodeData.GetDataKeyValue("COL_1999870249").ToString()
Dim currentItemIndex = FOBCodeData.ItemIndexHierarchical
If (FOBCode.Equals("Calculating...")) Then
FOBCodeData.Expanded = False
Else
For Each item As GridDataItem In grdLoadConsolidation.MasterTableView.Items
If item.ItemIndexHierarchical <> currentItemIndex.ToString() AndAlso item.Expanded Then
item.Expanded = False
End If
Next
' Use cached child data if available, otherwise fetch from DB and cache (max 500 rows)
Dim childCache As Dictionary(Of String, DataTable) = TryCast(Session("childDataCache"), Dictionary(Of String, DataTable))
If childCache Is Nothing Then
childCache = New Dictionary(Of String, DataTable)()
Session("childDataCache") = childCache
End If
Dim dtChild As DataTable = Nothing
If childCache.ContainsKey(FOBCode) Then
dtChild = childCache(FOBCode)
Else
dtChild = loadConsolidationManager.getShipmentConsolidation_Output_Grid(0, System.Web.HttpContext.Current.Session.SessionID, FOBCode, defaultMeasure, Origin_Destination, TimeZoneCode, userCode)
' Limit to 500 rows
If dtChild IsNot Nothing AndAlso dtChild.Rows.Count > 500 Then
Dim dtLimited As DataTable = dtChild.Clone()
For i As Integer = 0 To 499
dtLimited.ImportRow(dtChild.Rows(i))
Next
dtChild = dtLimited
End If
If dtChild IsNot Nothing Then
childCache(FOBCode) = dtChild
Session("childDataCache") = childCache
End If
End If
e.DetailTableView.DataSource = dtChild
' Hide/show Trailers column based on COL_1192779487
Dim colValue As String = FOBCodeData.GetDataKeyValue("COL_1192779487").ToString()
Dim trailersCol As GridColumn = e.DetailTableView.GetColumnSafe("Action")
If trailersCol IsNot Nothing Then
trailersCol.Visible = (colValue <> "0")
End If
' Rename headers based on Consolidation (Strategies) value
If FOBCode.Trim() = "Pooling, Inbound" Then
Dim shipperCol As GridColumn = e.DetailTableView.GetColumnSafe("Shipper")
If shipperCol IsNot Nothing Then
shipperCol.HeaderText = "Shippers, Count"
End If
ElseIf FOBCode.Trim() = "Pooling, Outbound" Then
Dim consigneeCol As GridColumn = e.DetailTableView.GetColumnSafe("TemplateColumn")
If consigneeCol IsNot Nothing Then
consigneeCol.HeaderText = "Consignees, Count"
End If
End If
End If
Catch ex As Exception
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred!');", True)
iCal = 0
End Try
End Sub
Protected Sub grdLoadConsolidation_itemDataBound(sender As Object, e As GridItemEventArgs)
' Replace pager text for child table
If TypeOf e.Item Is GridPagerItem Then
Dim pager As GridPagerItem = CType(e.Item, GridPagerItem)
If pager.OwnerTableView.ParentItem IsNot Nothing AndAlso pager.OwnerTableView.Name = "ShippingDetails" Then
For Each ctrl As Control In pager.Controls
ReplacePagerText(ctrl)
Next
End If
End If
End Sub
Private Sub ReplacePagerText(ctrl As Control)
If TypeOf ctrl Is LiteralControl Then
Dim lit As LiteralControl = CType(ctrl, LiteralControl)
If lit.Text.Contains(" items in ") Then
lit.Text = lit.Text.Replace(" items in ", " Consolidations in ")
End If
End If
For Each child As Control In ctrl.Controls
ReplacePagerText(child)
Next
End Sub
'Protected Sub btnProcess_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnProcess.Click
' If (Session.IsNewSession) Then
' Response.Redirect("~/Common/Login.aspx")
' Exit Sub
' End If
' Try
' 'If ddlCostCenter.SelectedValue = "" Then
' ' Dim dtSelectionCriteriaCostCenterCheckData As DataTable = objCommonManager.getSelectionCriteriaCostCenterCheckData(userCode)
' ' If dtSelectionCriteriaCostCenterCheckData.Rows.Count > 0 Then
' ' If dtSelectionCriteriaCostCenterCheckData.Rows(0)(0).ToString().Equals("NO") Then
' ' ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('Please select a Cost Center!');", True)
' ' Exit Sub
' ' End If
' ' End If
' 'End If
' Dim cmd As New SqlCommand
' Dim db As New CDatabase
' Dim obj As New CCommon
' obj = Session("COMMON_OBJ")
' Dim dt As New DataTable
' Dim objcmd As New SqlCommand
' cmd.CommandTimeout = 50000
' objcmd.Parameters.Add(New SqlParameter("@SessionID", obj.gblUserCode))
' objcmd.Parameters.Add(New SqlParameter("@FOBCode", IIf(ddlCostCenter.SelectedValue = String.Empty, 0, ddlCostCenter.SelectedValue)))
' objcmd.Parameters.Add(New SqlParameter("@GlobalSessionID", System.Web.HttpContext.Current.Session.SessionID))
' dt = db.FillDataSql("sp000000163445969", objcmd).Tables(0)
' pnlLoadDetails.Visible = False
' iCal = 1
' Dim dtShipmentsSummary_Parameters As DataTable = objShipmentsManager.getShipmentsSummary_Parameters(userCode, TimeZoneCode, defaultMeasure, IIf(ddlCostCenter.SelectedValue = String.Empty, 0, ddlCostCenter.SelectedValue))
' Dim dtShipmentConsolidation_Output_PanelBarHeader As DataTable = loadConsolidationManager.getShipmentConsolidation_Output_PanelBarHeader(IIf(ddlCostCenter.SelectedValue = String.Empty, 0, ddlCostCenter.SelectedValue), userCode)
' If (dtShipmentConsolidation_Output_PanelBarHeader.Rows.Count > 0) Then
' Dim i As Integer = 0
' For i = 0 To dtShipmentConsolidation_Output_PanelBarHeader.Rows.Count - 1
' Dim PanelBarHeader As String = dtShipmentConsolidation_Output_PanelBarHeader.Rows(i)("Descriptions").ToString()
' Dim HeaderItem As New RadPanelItem()
' HeaderItem.Text = PanelBarHeader
' radPnlbarLoad.Items.Add(HeaderItem)
' Dim dtShipmentConsolidation_Output_PanelBarBody As DataTable = loadConsolidationManager.getShipmentConsolidation_Output_PanelBarBody(IIf(ddlCostCenter.SelectedValue = String.Empty, 0, ddlCostCenter.SelectedValue), System.Web.HttpContext.Current.Session.SessionID, userCode)
' If (dtShipmentConsolidation_Output_PanelBarBody.Rows.Count > 0) Then
' Dim j As Integer = 0
' For j = 0 To dtShipmentConsolidation_Output_PanelBarBody.Rows.Count - 1
' Dim PanelBarBody As String = dtShipmentConsolidation_Output_PanelBarBody.Rows(j)("BodyDescriptions").ToString()
' Dim BodyItem As New RadPanelItem()
' BodyItem.Text = PanelBarBody
' HeaderItem.Items.Add(BodyItem)
' Next
' End If
' Next
' End If
' pnlLoadDetails.Visible = True
' Catch ex As Exception
' ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred_5!');", True)
' iCal = 0
' End Try
'End Sub
'Protected Sub grdLoadConsolidation_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdLoadConsolidation.NeedDataSource
' If (Session.IsNewSession) Then
' Response.Redirect("~/Common/Login.aspx")
' Exit Sub
' End If
' 'Try
' If Not e.IsFromDetailTable Then
' Dim BodyItem As String = radPnlbarLoad.SelectedItem.Text
' Dim Header As New RadPanelItem()
' Header = DirectCast(radPnlbarLoad.SelectedItem.Parent, RadPanelItem)
' Dim HeaderItem As String = Header.Text
' BindGridLoad(BodyItem, HeaderItem)
' End If
' 'Catch ex As Exception
' ' ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred_6!');", True)
' 'End Try
'End Sub
'Private Sub BindGridLoad(ByVal BodyItem As String, ByVal HeaderItem As String)
' Me.grdLoadConsolidation.Visible = False
' Dim dtShipmentConsolidation_Output_Grid As DataTable = loadConsolidationManager.getShipmentConsolidation_Output_Grid(IIf(ddlCostCenter.SelectedValue = String.Empty, 0, ddlCostCenter.SelectedValue), System.Web.HttpContext.Current.Session.SessionID, BodyItem, defaultMeasure, Origin_Destination, TimeZoneCode, userCode)
' grdLoadConsolidation.DataSource = dtShipmentConsolidation_Output_Grid
' grdLoadConsolidation.DataBind()
' Me.grdLoadConsolidation.Visible = True
'End Sub
Protected Sub grdLoadConsolidation_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles grdLoadConsolidation.NeedDataSource
Try
If Session.IsNewSession Then
RedirectToMainLoginPage()
Exit Sub
End If
If Not e.IsFromDetailTable Then
Dim dt As DataTable = TryCast(Session("grdLoadConsolidationData"), DataTable)
If dt IsNot Nothing Then
grdLoadConsolidation.DataSource = dt
End If
End If
Catch ex As Exception
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred while loading data.');", True)
End Try
End Sub
Private Sub BindGridLoad(ByVal BodyItem As String, ByVal HeaderItem As String)
Try
' Fetch data from the data source
Dim dtShipmentConsolidation_Output_Grid As DataTable = loadConsolidationManager.getShipmentConsolidation_Output_Grid(0, System.Web.HttpContext.Current.Session.SessionID, BodyItem, defaultMeasure, Origin_Destination, TimeZoneCode, userCode)
' Check if data source is not null
If dtShipmentConsolidation_Output_Grid IsNot Nothing AndAlso dtShipmentConsolidation_Output_Grid.Rows.Count > 0 Then
' Cache data and clear child cache
Session("grdLoadConsolidationData") = dtShipmentConsolidation_Output_Grid
Session.Remove("childDataCache")
' Assign the fetched data to the DataSource property of the grid and bind data
grdLoadConsolidation.DataSource = dtShipmentConsolidation_Output_Grid
' Make the grid and dropdown visible after data binding
grdLoadConsolidation.Visible = True
dropdownTreeContainer.Visible = True
grdLoadConsolidation.DataBind()
Else
' If data source is empty, display a message or handle accordingly
ScriptManager.RegisterStartupScript(Page, GetType(Page), "NoData", "alert('No data available.');", True)
End If
Catch ex As Exception
' Handle any exceptions that occur during data binding
ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred while binding data: " & ex.Message & "');", True)
End Try
End Sub
'Protected Sub radPnlbarLoad_ItemClick(ByVal sender As Object, ByVal e As Telerik.Web.UI.RadPanelBarEventArgs) Handles radPnlbarLoad.ItemClick
' If (Session.IsNewSession) Then
' Response.Redirect("~/Common/Login.aspx")
' Exit Sub
' End If
' 'Try
' iCal = 1
' grdLoadConsolidation.Visible = False
' If (e.Item.Level > 0) Then
' grdLoadConsolidation.Visible = True
' grdLoadConsolidation.CurrentPageIndex = 0
' grdLoadConsolidation.EditIndexes.Clear()
' grdLoadConsolidation.Rebind()
' End If
' 'Catch ex As Exception
' ' ScriptManager.RegisterStartupScript(Page, GetType(Page), "Error", "alert('An error occurred_7!');", True)
' 'End Try
'End Sub
'Protected Sub grdLoadConsolidation_ItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs)
' If (Session.IsNewSession) Then
' Response.Redirect("~/Common/Login.aspx")
' Exit Sub
' End If
' Try
' If TypeOf e.Item Is GridDataItem Then
' Dim lbtnDelete As LinkButton = DirectCast(e.Item.FindControl("lbtnDelete"), LinkButton)
' Dim lblMakeLineRed As Label = DirectCast(e.Item.FindControl("lblMakeLineRed"), Label)
' If lblMakeLineRed.Text.Equals("YES") Then
' e.Item.ForeColor = Drawing.Color.Red
' lbtnDelete.ForeColor = Drawing.Color.Red
' End If
' Dim BodyItem As String = radPnlbarLoad.SelectedItem.Text
' Dim Header As New RadPanelItem()
' Header = DirectCast(radPnlbarLoad.SelectedItem.Parent, RadPanelItem)
' Dim HeaderItem As String = Header.Text
' 'Option
' Dim lbtnAccept As LinkButton = DirectCast(e.Item.FindControl("lbtnAccept"), LinkButton)
' Dim lblDetailsSep As Label = DirectCast(e.Item.FindControl("lblDetailsSep"), Label)
' Dim lbtnDetails As LinkButton = DirectCast(e.Item.FindControl("lbtnDetails"), LinkButton)
' Dim lblLaneGroupSep As Label = DirectCast(e.Item.FindControl("lblLaneGroupSep"), Label)
' Dim lbtnLaneGroup As LinkButton = DirectCast(e.Item.FindControl("lbtnLaneGroup"), LinkButton)
' Dim lblMapSep As Label = DirectCast(e.Item.FindControl("lblMapSep"), Label)
' Dim lbtnMap As LinkButton = DirectCast(e.Item.FindControl("lbtnMap"), LinkButton)
' Dim lblItinerarySep As Label = DirectCast(e.Item.FindControl("lblItinerarySep"), Label)
' Dim lbtnItinerary As LinkButton = DirectCast(e.Item.FindControl("lbtnItinerary"), LinkButton)
' Dim lblTrailerSep As Label = DirectCast(e.Item.FindControl("lblTrailerSep"), Label)
' Dim lbtnTrailer As LinkButton = DirectCast(e.Item.FindControl("lbtnTrailer"), LinkButton)
' Dim lblDriversSep As Label = DirectCast(e.Item.FindControl("lblDriversSep"), Label)
' Dim lbtnDrivers As LinkButton = DirectCast(e.Item.FindControl("lbtnDrivers"), LinkButton)
' If (HeaderItem = "Parcel to Less-than-Truckload") Then
' lblLaneGroupSep.Visible = False
' lbtnLaneGroup.Visible = False
' lblMapSep.Visible = False
' lbtnMap.Visible = False
' lblItinerarySep.Visible = False
' lbtnItinerary.Visible = False
' lblTrailerSep.Visible = False
' lbtnTrailer.Visible = False
' lblDriversSep.Visible = False
' lbtnDrivers.Visible = False
' ElseIf (HeaderItem = "Consolidation") Then
' lblLaneGroupSep.Visible = False