-
Notifications
You must be signed in to change notification settings - Fork 0
/
APViewVoucherLines.vb
5799 lines (5187 loc) · 367 KB
/
APViewVoucherLines.vb
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 System
Imports System.Windows.Forms
Imports System.Math
Imports System.IO
Imports System.Data
Imports System.Data.OleDb
Imports CrystalDecisions.Windows.Forms
Imports CrystalDecisions.ReportSource
Imports CrystalDecisions.CrystalReports.Engine
Imports CrystalDecisions.Shared
Imports System.Data.SqlClient
Public Class APViewVoucherLines
Inherits System.Windows.Forms.Form
Dim LastGLNumber, NextGLNumber, BatchNumber, PONumber, DueDays, DiscountDays As Integer
Dim WhitePaperCheck, GLTaxAccount, GLPayableAccount, GLFreightAccount, VendorClass, GLDate, VoucherSource, VendorName, VoucherStatus, InvoiceNumber, InvoiceDate, ReceiptDate, VendorID, PaymentTerms, DiscountDate, Comment, UniqueInvoice As String
Dim SUMExtendedAmount, InvoiceAmount, DiscountPercent, ProductTotal, InvoiceFreight, InvoiceSalesTax, InvoiceTotal, DiscountAmount As Double
Dim InvoiceDate1, DueDate, DiscountDate1 As Date
Dim TodaysDate As Date = Now()
Dim CheckDiscountDate As Date = Now()
Dim CheckType As String = ""
Dim CheckCode As String = ""
Dim CheckAndValidateDates As String = ""
Dim IsLoaded As Boolean
'Initialize error variables
Dim ErrorDate As String = ""
Dim ErrorDescription As String = ""
Dim ErrorUser As String = ""
Dim ErrorComment As String = ""
Dim ErrorDivision As String = ""
Dim ErrorReferenceNumber As String = ""
'Setup data connection and variables
Dim con As SqlConnection = New SqlConnection("Data Source=TFP-SQL;Initial Catalog=TFPOperationsDatabase;Integrated Security=True;Connect Timeout=30;Connect Timeout=30")
Dim cmd, cmd1, cmd2, cmd3, cmd4, cmd5 As SqlCommand
Dim myAdapter, myAdapter1, myAdapter2, myAdapter3, myAdapter4, myAdapter5 As New SqlDataAdapter
Dim comBuilder As SqlCommandBuilder
Dim ds, ds1, ds2, ds3, ds4, ds5 As DataSet
Dim dt As DataTable
Private Sub APViewVoucherLines_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'TODO: This line of code loads data into the 'SQLTFPOperationsDatabaseDataSet.PaymentTerms' table. You can move, or remove it, as needed.
Me.PaymentTermsTableAdapter.Fill(Me.SQLTFPOperationsDatabaseDataSet.PaymentTerms)
'TODO: This line of code loads data into the 'SQLTFPOperationsDatabaseDataSet.DivisionTable' table. You can move, or remove it, as needed.
Me.DivisionTableTableAdapter.Fill(Me.SQLTFPOperationsDatabaseDataSet.DivisionTable)
If EmployeeCompanyCode = "ADM" Then
cboDivisionID.Enabled = True
cboDivisionID.Text = GlobalDivisionCode
Else
cboDivisionID.Enabled = False
cboDivisionID.Text = GlobalDivisionCode
End If
TodaysDate = Today.ToShortDateString()
If GlobalVoucherNumber2 > 0 Then
cboVoucherNumber.Text = GlobalVoucherNumber2
ShowAllData()
Else
cboVoucherNumber.SelectedIndex = -1
cboPaymentTerms.SelectedIndex = -1
cmdReverse.Enabled = False
cmdPost.Enabled = False
cmdDelete.Enabled = False
End If
End Sub
Public Sub ShowAllData()
cmd = New SqlCommand("SELECT * FROM ReceiptOfInvoiceVoucherLines WHERE VoucherNumber = @VoucherNumber", con)
cmd.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
If con.State = ConnectionState.Closed Then con.Open()
ds = New DataSet()
myAdapter.SelectCommand = cmd
myAdapter.Fill(ds, "ReceiptOfInvoiceVoucherLines")
dgvVoucherLines.DataSource = ds.Tables("ReceiptOfInvoiceVoucherLines")
con.Close()
End Sub
Public Sub ClearDataInDatagrid()
dgvVoucherLines.DataSource = Nothing
End Sub
Public Sub LoadVoucherNumber()
cmd = New SqlCommand("SELECT VoucherNumber FROM ReceiptOfInvoiceBatchLine WHERE DivisionID = @DivisionID AND VoucherStatus <> 'RECURRING' ORDER BY VoucherNumber DESC", con)
cmd.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
If con.State = ConnectionState.Closed Then con.Open()
ds1 = New DataSet()
myAdapter1.SelectCommand = cmd
myAdapter1.Fill(ds1, "ReceiptOfInvoiceBatchLine")
cboVoucherNumber.DataSource = ds1.Tables("ReceiptOfInvoiceBatchLine")
con.Close()
cboVoucherNumber.SelectedIndex = -1
End Sub
Public Sub LoadVendor()
cmd = New SqlCommand("SELECT VendorCode FROM Vendor WHERE DivisionID = @DivisionID", con)
cmd.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
If con.State = ConnectionState.Closed Then con.Open()
ds2 = New DataSet()
myAdapter2.SelectCommand = cmd
myAdapter2.Fill(ds2, "Vendor")
cboVendorID.DataSource = ds2.Tables("Vendor")
con.Close()
cboVendorID.SelectedIndex = -1
End Sub
Public Sub LoadVendorClass()
cmd = New SqlCommand("SELECT VendClassID FROM VendorClass", con)
If con.State = ConnectionState.Closed Then con.Open()
ds3 = New DataSet()
myAdapter3.SelectCommand = cmd
myAdapter3.Fill(ds3, "VendorClass")
cboVendorClass.DataSource = ds3.Tables("VendorClass")
con.Close()
cboVendorClass.SelectedIndex = -1
End Sub
Public Sub TFPErrorLogUpdate()
'Insert Data into error log
If ErrorComment.Length < 400 Then
'Do nothing
Else
ErrorComment = ErrorComment.Substring(0, 399)
End If
cmd = New SqlCommand("INSERT INTO TFPErrorLog (ErrorDate, ErrorDescription, ErrorReferenceNumber, ErrorUserID, ErrorComment, ErrorDivision) values (@ErrorDate, @ErrorDescription, @ErrorReferenceNumber, @ErrorUserID, @ErrorComment, @ErrorDivision)", con)
With cmd.Parameters
.Add("@ErrorDate", SqlDbType.VarChar).Value = ErrorDate
.Add("@ErrorDescription", SqlDbType.VarChar).Value = ErrorDescription
.Add("@ErrorReferenceNumber", SqlDbType.VarChar).Value = ErrorReferenceNumber
.Add("@ErrorUserID", SqlDbType.VarChar).Value = ErrorUser
.Add("@ErrorComment", SqlDbType.VarChar).Value = ErrorComment
.Add("@ErrorDivision", SqlDbType.VarChar).Value = ErrorDivision
End With
If con.State = ConnectionState.Closed Then con.Open()
cmd.ExecuteNonQuery()
con.Close()
End Sub
Private Sub CellValueChanged(ByVal sender As Object, ByVal e As DataGridViewCellEventArgs) Handles dgvVoucherLines.CellValueChanged
Dim LineQuantity, LineExtendedAmount, LineUnitCost As Double
Dim LineNumber As Integer
Dim GLWarning, CheckDebitAccount, CheckCreditAccount, LinePartDescription, LineDebitAccount, LineCreditAccount As String
GLWarning = ""
If VoucherStatus = "OPEN" Then
'UPDATE Line Table on changes in the datagrid and ensure no NULL values
For Each row As DataGridViewRow In dgvVoucherLines.Rows
Try
LineUnitCost = row.Cells("UnitCostColumn").Value
Catch ex As Exception
LineUnitCost = 0
End Try
Try
LineQuantity = row.Cells("QuantityColumn").Value
Catch ex As Exception
LineQuantity = 0
End Try
Try
LineNumber = row.Cells("VoucherLineColumn").Value
Catch ex As Exception
LineNumber = 0
End Try
Try
LineDebitAccount = row.Cells("GLDebitAccountColumn").Value
Catch ex As Exception
LineDebitAccount = ""
End Try
Try
LineCreditAccount = row.Cells("GLCreditAccountColumn").Value
Catch ex As Exception
LineCreditAccount = "20000"
End Try
Try
LinePartDescription = row.Cells("PartDescriptionColumn").Value
Catch ex As Exception
LinePartDescription = ""
End Try
LineExtendedAmount = LineUnitCost * LineQuantity
LineExtendedAmount = Math.Round(LineExtendedAmount, 2)
'Verify GL Accounts
Dim CheckDebitAccountStatement As String = "SELECT GLAccountNumber FROM GLAccounts WHERE GLAccountNumber = @GLAccountNumber"
Dim CheckDebitAccountCommand As New SqlCommand(CheckDebitAccountStatement, con)
CheckDebitAccountCommand.Parameters.Add("@GLAccountNumber", SqlDbType.VarChar).Value = LineDebitAccount
Dim CheckCreditAccountStatement As String = "SELECT GLAccountNumber FROM GLAccounts WHERE GLAccountNumber = @GLAccountNumber"
Dim CheckCreditAccountCommand As New SqlCommand(CheckCreditAccountStatement, con)
CheckCreditAccountCommand.Parameters.Add("@GLAccountNumber", SqlDbType.VarChar).Value = LineCreditAccount
If con.State = ConnectionState.Closed Then con.Open()
Try
CheckDebitAccount = CStr(CheckDebitAccountCommand.ExecuteScalar)
Catch ex As Exception
CheckDebitAccount = "NO"
End Try
Try
CheckCreditAccount = CStr(CheckCreditAccountCommand.ExecuteScalar)
Catch ex As Exception
CheckCreditAccount = "NO"
End Try
con.Close()
'If there is an invalid GL Account, exit the loop - no updates
If CheckCreditAccount = "NO" Or CheckDebitAccount = "NO" Then
GLWarning = "NOT VALID"
Exit For
Else
GLWarning = "VALID"
End If
'Update Voucher Line Table with changes
Try
cmd = New SqlCommand("UPDATE ReceiptOfInvoiceVoucherLines SET PartDescription = @PartDescription, UnitCost = @UnitCost, Quantity = @Quantity, ExtendedAmount = @ExtendedAmount, GLDebitAccount = @GLDebitAccount, GLCreditAccount = @GLCreditAccount WHERE VoucherNumber = @VoucherNumber AND VoucherLine = @VoucherLine", con)
With cmd.Parameters
.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
.Add("@VoucherLine", SqlDbType.VarChar).Value = LineNumber
.Add("@PartDescription", SqlDbType.VarChar).Value = LinePartDescription
.Add("@UnitCost", SqlDbType.VarChar).Value = LineUnitCost
.Add("@Quantity", SqlDbType.VarChar).Value = LineQuantity
.Add("@ExtendedAmount", SqlDbType.VarChar).Value = LineExtendedAmount
.Add("@GLDebitAccount", SqlDbType.VarChar).Value = LineDebitAccount
.Add("@GLCreditAccount", SqlDbType.VarChar).Value = LineCreditAccount
End With
If con.State = ConnectionState.Closed Then con.Open()
cmd.ExecuteNonQuery()
con.Close()
Catch ex As Exception
'Do nothing
End Try
Next
'Reload totals and update header table
ReloadTotals()
'CalculateDiscount()
cmd = New SqlCommand("UPDATE ReceiptOfInvoiceBatchLine SET ProductTotal = @ProductTotal, InvoiceFreight = @InvoiceFreight, InvoiceSalesTax = @InvoiceSalesTax, InvoiceTotal = @InvoiceTotal, InvoiceAmount = @InvoiceAmount, DiscountAmount = @DiscountAmount WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID", con)
With cmd.Parameters
.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
.Add("@ProductTotal", SqlDbType.VarChar).Value = ProductTotal
.Add("@InvoiceFreight", SqlDbType.VarChar).Value = InvoiceFreight
.Add("@InvoiceSalesTax", SqlDbType.VarChar).Value = InvoiceSalesTax
.Add("@InvoiceTotal", SqlDbType.VarChar).Value = InvoiceTotal
.Add("@InvoiceAmount", SqlDbType.VarChar).Value = InvoiceTotal
.Add("@DiscountAmount", SqlDbType.VarChar).Value = Val(txtDiscountAmount.Text)
End With
If con.State = ConnectionState.Closed Then con.Open()
cmd.ExecuteNonQuery()
con.Close()
If GLWarning = "NOT VALID" Then
MsgBox("One or more lines could not be updated because there is an invalid GL Account", MsgBoxStyle.OkOnly)
End If
ShowAllData()
Else
'Do nothing - no changes will be saved
End If
End Sub
Public Sub LoadPaymentTermDetails()
Dim DiscountPercentStatement As String = "SELECT DiscountPercent FROM PaymentTerms WHERE PmtTermsID = @PmtTermsID"
Dim DiscountPercentCommand As New SqlCommand(DiscountPercentStatement, con)
DiscountPercentCommand.Parameters.Add("@PmtTermsID", SqlDbType.VarChar).Value = cboPaymentTerms.Text
Dim DiscountDaysStatement As String = "SELECT DiscountDays FROM PaymentTerms WHERE PmtTermsID = @PmtTermsID"
Dim DiscountDaysCommand As New SqlCommand(DiscountDaysStatement, con)
DiscountDaysCommand.Parameters.Add("@PmtTermsID", SqlDbType.VarChar).Value = cboPaymentTerms.Text
Dim DueDaysStatement As String = "SELECT DueDays FROM PaymentTerms WHERE PmtTermsID = @PmtTermsID"
Dim DueDaysCommand As New SqlCommand(DueDaysStatement, con)
DueDaysCommand.Parameters.Add("@PmtTermsID", SqlDbType.VarChar).Value = cboPaymentTerms.Text
If con.State = ConnectionState.Closed Then con.Open()
Try
DueDays = CInt(DueDaysCommand.ExecuteScalar)
Catch ex As Exception
DueDays = 0
End Try
Try
DiscountDays = CInt(DiscountDaysCommand.ExecuteScalar)
Catch ex As Exception
DiscountDays = 0
End Try
Try
DiscountPercent = CDbl(DiscountPercentCommand.ExecuteScalar)
Catch ex As Exception
DiscountPercent = 0
End Try
con.Close()
'Commands to determine Discount and Due Dates
InvoiceDate1 = dtpInvoiceDate.Value
DueDate = InvoiceDate1.AddDays(DueDays)
dtpDueDate.Text = DueDate
If DiscountPercent = 0 Then
dtpDiscountDate.Text = DueDate
Else
DiscountDate1 = InvoiceDate1.AddDays(DiscountDays)
dtpDiscountDate.Text = DiscountDate1
End If
End Sub
Public Sub CalculateDiscount()
DiscountAmount = DiscountPercent * ProductTotal
txtDiscountAmount.Text = DiscountAmount
End Sub
Public Sub LoadVendorName()
Dim VendorNameStatement As String = "SELECT VendorName FROM Vendor WHERE VendorCode = @VendorCode AND DivisionID = @DivisionID"
Dim VendorNameCommand As New SqlCommand(VendorNameStatement, con)
VendorNameCommand.Parameters.Add("@VendorCode", SqlDbType.VarChar).Value = cboVendorID.Text
VendorNameCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim VendorClassStatement As String = "SELECT VendorClass FROM Vendor WHERE VendorCode = @VendorCode AND DivisionID = @DivisionID"
Dim VendorClassCommand As New SqlCommand(VendorClassStatement, con)
VendorClassCommand.Parameters.Add("@VendorCode", SqlDbType.VarChar).Value = cboVendorID.Text
VendorClassCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim CheckCodeStatement As String = "SELECT CheckCode FROM Vendor WHERE VendorCode = @VendorCode AND DivisionID = @DivisionID"
Dim CheckCodeCommand As New SqlCommand(CheckCodeStatement, con)
CheckCodeCommand.Parameters.Add("@VendorCode", SqlDbType.VarChar).Value = cboVendorID.Text
CheckCodeCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim WhitePaperCheckStatement As String = "SELECT WhitePaperCheck FROM Vendor WHERE VendorCode = @VendorCode AND DivisionID = @DivisionID"
Dim WhitePaperCheckCommand As New SqlCommand(WhitePaperCheckStatement, con)
WhitePaperCheckCommand.Parameters.Add("@VendorCode", SqlDbType.VarChar).Value = cboVendorID.Text
WhitePaperCheckCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
If con.State = ConnectionState.Closed Then con.Open()
Try
VendorName = CStr(VendorNameCommand.ExecuteScalar)
Catch ex As Exception
VendorName = ""
End Try
Try
VendorClass = CStr(VendorClassCommand.ExecuteScalar)
Catch ex As Exception
VendorClass = ""
End Try
Try
CheckCode = CStr(CheckCodeCommand.ExecuteScalar)
Catch ex As Exception
CheckCode = "STANDARD"
End Try
Try
WhitePaperCheck = CStr(WhitePaperCheckCommand.ExecuteScalar)
Catch ex As Exception
WhitePaperCheck = "NO"
End Try
con.Close()
txtVendorName.Text = VendorName
cboVendorClass.Text = VendorClass
cboCheckType.Text = CheckCode
If WhitePaperCheck = "YES" Then
chkWhitePaper.Checked = True
Else
chkWhitePaper.Checked = False
End If
End Sub
Public Sub LoadPostingDateForReversal()
Dim GetGLDateStatement As String = "SELECT MAX(GLTransactionDate) FROM GLTransactionMasterList WHERE GLReferenceNumber = @GLReferenceNumber AND DivisionID = @DivisionID"
Dim GetGLDateCommand As New SqlCommand(GetGLDateStatement, con)
GetGLDateCommand.Parameters.Add("@GLReferenceNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
GetGLDateCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
If con.State = ConnectionState.Closed Then con.Open()
Try
GLDate = CStr(GetGLDateCommand.ExecuteScalar)
Catch ex As Exception
GLDate = dtpInvoiceDate.Text
End Try
con.Close()
End Sub
Public Sub LoadIntercompanyDueDate()
Dim DissectInvoiceDate As Date
Dim intDay, intMonth, intYear As Integer
Dim intNewDay, intNewMonth, intNewYear As Integer
Dim strNewDay, strNewMonth, strNewYear As String
Dim strInterCompanyDueDate As String = ""
DissectInvoiceDate = dtpInvoiceDate.Value
intDay = DissectInvoiceDate.Day
intMonth = DissectInvoiceDate.Month
intYear = DissectInvoiceDate.Year
If intDay <= 15 Then
intNewDay = 1
If intMonth < 12 Then
intNewMonth = intMonth + 1
Else
intNewMonth = 1
End If
Else
intNewDay = 15
If intMonth < 12 Then
intNewMonth = intMonth + 1
Else
intNewMonth = 1
End If
End If
If intMonth = 12 Then
intNewYear = intYear + 1
Else
intNewYear = intYear
End If
strNewDay = CStr(intNewDay)
strNewMonth = CStr(intNewMonth)
strNewYear = CStr(intNewYear)
strInterCompanyDueDate = strNewMonth + "/" + strNewDay + "/" + strNewYear
dtpDiscountDate.Text = strInterCompanyDueDate
dtpDueDate.Text = strInterCompanyDueDate
End Sub
Public Sub LoadFEDEXDueDate()
Dim DissectInvoiceDate As Date
Dim intDay, intMonth, intYear As Integer
Dim intNewDay, intNewMonth, intNewYear As Integer
Dim strNewDay, strNewMonth, strNewYear As String
Dim strFedexDueDate As String = ""
DissectInvoiceDate = dtpInvoiceDate.Value
intDay = DissectInvoiceDate.Day
intMonth = DissectInvoiceDate.Month
intYear = DissectInvoiceDate.Year
If intDay <= 10 Then
intNewDay = 15
intNewMonth = intMonth
ElseIf intDay > 10 And intDay <= 20 Then
intNewDay = 25
intNewMonth = intMonth
ElseIf intDay > 20 And intDay <= 31 Then
intNewDay = 5
If intMonth < 12 Then
intNewMonth = intMonth + 1
Else
intNewMonth = 1
End If
Else
'Do nothing
End If
If intMonth = 12 And intNewDay = 5 Then
intNewYear = intYear + 1
Else
intNewYear = intYear
End If
strNewDay = CStr(intNewDay)
strNewMonth = CStr(intNewMonth)
strNewYear = CStr(intNewYear)
strFedexDueDate = strNewMonth + "/" + strNewDay + "/" + strNewYear
dtpDiscountDate.Text = strFedexDueDate
dtpDueDate.Text = strFedexDueDate
End Sub
Public Sub ValidateDates()
'Check to see if Invoice Date, Due Date, or Discount Date is more than 60 days different from today
Dim CheckInvoiceDate, CheckDueDate, CheckDiscountDate As Date
Dim DateDifference1 As Integer = 0
Dim DateDifference2 As Integer = 0
Dim DateDifference3 As Integer = 0
TodaysDate = Today()
CheckInvoiceDate = dtpInvoiceDate.Value
CheckDueDate = dtpDueDate.Value
CheckDiscountDate = dtpDiscountDate.Value
'Invoice Date
If CheckInvoiceDate > TodaysDate Then
DateDifference1 = DateDiff(DateInterval.Day, TodaysDate, CheckInvoiceDate)
Else
DateDifference1 = DateDiff(DateInterval.Day, CheckInvoiceDate, TodaysDate)
End If
'Due Date
If CheckDueDate > TodaysDate Then
DateDifference2 = DateDiff(DateInterval.Day, TodaysDate, CheckDueDate)
Else
DateDifference2 = DateDiff(DateInterval.Day, CheckDueDate, TodaysDate)
End If
'Discount Date
If CheckDiscountDate > TodaysDate Then
DateDifference3 = DateDiff(DateInterval.Day, TodaysDate, CheckDiscountDate)
Else
DateDifference3 = DateDiff(DateInterval.Day, CheckDiscountDate, TodaysDate)
End If
If DateDifference1 < 90 And DateDifference2 < 90 And DateDifference3 < 90 Then
CheckAndValidateDates = "OKAY"
Else
CheckAndValidateDates = "NOT OKAY"
End If
End Sub
Public Sub ClearData()
cboVoucherNumber.Refresh()
cboVendorID.Refresh()
cboPaymentTerms.Refresh()
cboVendorClass.Refresh()
cboCheckType.Refresh()
cboVoucherNumber.SelectedIndex = -1
cboVendorID.SelectedIndex = -1
cboPaymentTerms.SelectedIndex = -1
cboVendorClass.SelectedIndex = -1
cboCheckType.SelectedIndex = -1
txtComment.Clear()
txtInvoiceNumber.Clear()
txtBatchNumber.Clear()
txtDiscountAmount.Clear()
txtFreight.Clear()
txtSalesTax.Clear()
txtPONumber.Clear()
txtInvoiceTotal.Clear()
txtProductTotal.Clear()
txtVendorName.Clear()
lblVoucherSource.Text = ""
lblVoucherStatus.Text = ""
dtpDiscountDate.Text = ""
dtpDueDate.Text = ""
dtpInvoiceDate.Text = ""
dtpReceiptDate.Text = ""
chkChangePostDate.Checked = False
chkWhitePaper.Checked = False
chkWhitePaper.Enabled = True
cboVoucherNumber.Text = ""
End Sub
Public Sub ClearVariables()
LastGLNumber = 0
NextGLNumber = 0
BatchNumber = 0
PONumber = 0
DueDays = 0
DiscountDays = 0
GLDate = ""
VoucherSource = ""
VendorName = ""
VoucherStatus = ""
InvoiceNumber = ""
InvoiceDate = ""
ReceiptDate = ""
VendorID = ""
PaymentTerms = ""
DiscountDate = ""
Comment = ""
UniqueInvoice = ""
SUMExtendedAmount = 0
InvoiceAmount = 0
DiscountPercent = 0
ProductTotal = 0
InvoiceFreight = 0
InvoiceSalesTax = 0
InvoiceTotal = 0
DiscountAmount = 0
GlobalVoucherNumber = 0
VendorClass = ""
CheckType = ""
CheckCode = "STANDARD"
WhitePaperCheck = "NO"
End Sub
Private Sub LoadVoucherData()
Dim BatchNumberStatement As String = "SELECT BatchNumber FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim BatchNumberCommand As New SqlCommand(BatchNumberStatement, con)
BatchNumberCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
BatchNumberCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim PONumberStatement As String = "SELECT PONumber FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim PONumberCommand As New SqlCommand(PONumberStatement, con)
PONumberCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
PONumberCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim InvoiceNumberStatement As String = "SELECT InvoiceNumber FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim InvoiceNumberCommand As New SqlCommand(InvoiceNumberStatement, con)
InvoiceNumberCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
InvoiceNumberCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim InvoiceDateStatement As String = "SELECT InvoiceDate FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim InvoiceDateCommand As New SqlCommand(InvoiceDateStatement, con)
InvoiceDateCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
InvoiceDateCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim ReceiptDateStatement As String = "SELECT ReceiptDate FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim ReceiptDateCommand As New SqlCommand(ReceiptDateStatement, con)
ReceiptDateCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
ReceiptDateCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim VendorIDStatement As String = "SELECT VendorID FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim VendorIDCommand As New SqlCommand(VendorIDStatement, con)
VendorIDCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
VendorIDCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim ProductTotalStatement As String = "SELECT ProductTotal FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim ProductTotalCommand As New SqlCommand(ProductTotalStatement, con)
ProductTotalCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
ProductTotalCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim InvoiceFreightStatement As String = "SELECT InvoiceFreight FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim InvoiceFreightCommand As New SqlCommand(InvoiceFreightStatement, con)
InvoiceFreightCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
InvoiceFreightCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim InvoiceSalesTaxStatement As String = "SELECT InvoiceSalesTax FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim InvoiceSalesTaxCommand As New SqlCommand(InvoiceSalesTaxStatement, con)
InvoiceSalesTaxCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
InvoiceSalesTaxCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim InvoiceTotalStatement As String = "SELECT InvoiceTotal FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim InvoiceTotalCommand As New SqlCommand(InvoiceTotalStatement, con)
InvoiceTotalCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
InvoiceTotalCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim PaymentTermsStatement As String = "SELECT PaymentTerms FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim PaymentTermsCommand As New SqlCommand(PaymentTermsStatement, con)
PaymentTermsCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
PaymentTermsCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim DiscountDateStatement As String = "SELECT DiscountDate FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim DiscountDateCommand As New SqlCommand(DiscountDateStatement, con)
DiscountDateCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
DiscountDateCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim CommentStatement As String = "SELECT Comment FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim CommentCommand As New SqlCommand(CommentStatement, con)
CommentCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
CommentCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim DueDateStatement As String = "SELECT DueDate FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim DueDateCommand As New SqlCommand(DueDateStatement, con)
DueDateCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
DueDateCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim DiscountAmountStatement As String = "SELECT DiscountAmount FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim DiscountAmountCommand As New SqlCommand(DiscountAmountStatement, con)
DiscountAmountCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
DiscountAmountCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim InvoiceAmountStatement As String = "SELECT InvoiceAmount FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim InvoiceAmountCommand As New SqlCommand(InvoiceAmountStatement, con)
InvoiceAmountCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
InvoiceAmountCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim VoucherSourceStatement As String = "SELECT VoucherSource FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim VoucherSourceCommand As New SqlCommand(VoucherSourceStatement, con)
VoucherSourceCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
VoucherSourceCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim VendorClassStatement As String = "SELECT VendorClass FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim VendorClassCommand As New SqlCommand(VendorClassStatement, con)
VendorClassCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
VendorClassCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim CheckTypeStatement As String = "SELECT CheckType FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim CheckTypeCommand As New SqlCommand(CheckTypeStatement, con)
CheckTypeCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
CheckTypeCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
Dim WhitePaperCheckStatement As String = "SELECT WhitePaper FROM ReceiptOfInvoiceBatchLine WHERE VoucherNumber = @VoucherNumber AND DivisionID = @DivisionID"
Dim WhitePaperCheckCommand As New SqlCommand(WhitePaperCheckStatement, con)
WhitePaperCheckCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
WhitePaperCheckCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
If con.State = ConnectionState.Closed Then con.Open()
Try
BatchNumber = CInt(BatchNumberCommand.ExecuteScalar)
Catch ex As Exception
BatchNumber = 0
End Try
Try
PONumber = CInt(PONumberCommand.ExecuteScalar)
Catch ex As Exception
PONumber = 0
End Try
Try
InvoiceNumber = CStr(InvoiceNumberCommand.ExecuteScalar)
Catch ex As Exception
InvoiceNumber = 0
End Try
Try
InvoiceDate = CStr(InvoiceDateCommand.ExecuteScalar)
Catch ex As Exception
InvoiceDate = ""
End Try
Try
ReceiptDate = CStr(ReceiptDateCommand.ExecuteScalar)
Catch ex As Exception
ReceiptDate = ""
End Try
Try
VendorID = CStr(VendorIDCommand.ExecuteScalar)
Catch ex As Exception
VendorID = ""
End Try
Try
ProductTotal = CDbl(ProductTotalCommand.ExecuteScalar)
Catch ex As Exception
ProductTotal = 0
End Try
Try
InvoiceFreight = CDbl(InvoiceFreightCommand.ExecuteScalar)
Catch ex As Exception
InvoiceFreight = 0
End Try
Try
InvoiceSalesTax = CDbl(InvoiceSalesTaxCommand.ExecuteScalar)
Catch ex As Exception
InvoiceSalesTax = 0
End Try
Try
InvoiceTotal = CDbl(InvoiceTotalCommand.ExecuteScalar)
Catch ex As Exception
InvoiceTotal = 0
End Try
Try
PaymentTerms = CStr(PaymentTermsCommand.ExecuteScalar)
Catch ex As Exception
PaymentTerms = ""
End Try
Try
DiscountDate = CStr(DiscountDateCommand.ExecuteScalar)
Catch ex As Exception
DiscountDate = ""
End Try
Try
Comment = CStr(CommentCommand.ExecuteScalar)
Catch ex As Exception
Comment = ""
End Try
Try
DueDate = CDate(DueDateCommand.ExecuteScalar)
Catch ex As Exception
DueDate = ""
End Try
Try
DiscountAmount = CDbl(DiscountAmountCommand.ExecuteScalar)
Catch ex As Exception
DiscountAmount = 0
End Try
Try
InvoiceAmount = CDbl(InvoiceAmountCommand.ExecuteScalar)
Catch ex As Exception
InvoiceAmount = 0
End Try
Try
VoucherSource = CStr(VoucherSourceCommand.ExecuteScalar)
Catch ex As Exception
VoucherSource = ""
End Try
Try
VendorClass = CStr(VendorClassCommand.ExecuteScalar)
Catch ex As Exception
VendorClass = "CANADIAN"
End Try
Try
CheckType = CStr(CheckTypeCommand.ExecuteScalar)
Catch ex As Exception
CheckType = "STANDARD"
End Try
Try
WhitePaperCheck = CStr(WhitePaperCheckCommand.ExecuteScalar)
Catch ex As Exception
WhitePaperCheck = "NO"
End Try
con.Close()
cboVendorID.Text = VendorID
txtBatchNumber.Text = BatchNumber
IsLoaded = True
cboPaymentTerms.Text = PaymentTerms
IsLoaded = False
txtPONumber.Text = PONumber
txtInvoiceNumber.Text = InvoiceNumber
txtProductTotal.Text = FormatCurrency(ProductTotal, 2)
txtFreight.Text = InvoiceFreight
txtSalesTax.Text = InvoiceSalesTax
txtInvoiceTotal.Text = FormatCurrency(InvoiceTotal, 2)
txtDiscountAmount.Text = DiscountAmount
txtComment.Text = Comment
cboCheckType.Text = CheckType
If WhitePaperCheck = "YES" Then
chkWhitePaper.Checked = True
Else
chkWhitePaper.Checked = False
End If
IsLoaded = True
dtpInvoiceDate.Text = InvoiceDate
IsLoaded = False
dtpReceiptDate.Text = ReceiptDate
dtpDiscountDate.Text = DiscountDate
dtpDueDate.Text = DueDate
If CheckCode = "INTERCOMPANY" Then
chkWhitePaper.Enabled = False
ElseIf CheckCode = "FEDEX" Then
chkWhitePaper.Enabled = False
ElseIf CheckCode = "ACH" Then
chkWhitePaper.Enabled = False
Else
chkWhitePaper.Enabled = True
End If
lblVoucherSource.Text = VoucherSource
LoadStatus()
End Sub
Public Sub VerifyUniqueInvoiceNumber()
Dim CountInvoiceNumber As Integer = 0
Dim UniqueInvoiceStatement As String = "SELECT COUNT(InvoiceNumber) FROM ReceiptOfInvoiceBatchLine WHERE DivisionID = @DivisionID AND VoucherNumber <> @VoucherNumber AND InvoiceNumber = @InvoiceNumber AND VendorID = @VendorID"
Dim UniqueInvoiceCommand As New SqlCommand(UniqueInvoiceStatement, con)
UniqueInvoiceCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
UniqueInvoiceCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
UniqueInvoiceCommand.Parameters.Add("@InvoiceNumber", SqlDbType.VarChar).Value = txtInvoiceNumber.Text
UniqueInvoiceCommand.Parameters.Add("@VendorID", SqlDbType.VarChar).Value = cboVendorID.Text
If con.State = ConnectionState.Closed Then con.Open()
Try
CountInvoiceNumber = CInt(UniqueInvoiceCommand.ExecuteScalar)
Catch ex As Exception
CountInvoiceNumber = 0
End Try
con.Close()
If CountInvoiceNumber = 0 Then
UniqueInvoice = "YES"
Else
UniqueInvoice = "NO"
End If
End Sub
Public Sub LockCertainControls()
cboVendorID.Enabled = False
cboVendorClass.Enabled = False
txtPONumber.Enabled = False
txtBatchNumber.Enabled = False
txtVendorName.Enabled = False
End Sub
Public Sub UnLockCertainControls()
cboVendorID.Enabled = True
cboVendorClass.Enabled = True
txtVendorName.Enabled = True
End Sub
Public Sub LoadStatus()
Dim VoucherStatusStatement As String = "SELECT VoucherStatus FROM ReceiptOfInvoiceBatchLine WHERE DivisionID = @DivisionID AND VoucherNumber = @VoucherNumber"
Dim VoucherStatusCommand As New SqlCommand(VoucherStatusStatement, con)
VoucherStatusCommand.Parameters.Add("@DivisionID", SqlDbType.VarChar).Value = cboDivisionID.Text
VoucherStatusCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
If con.State = ConnectionState.Closed Then con.Open()
Try
VoucherStatus = CStr(VoucherStatusCommand.ExecuteScalar)
Catch ex As Exception
VoucherStatus = "POSTED"
End Try
con.Close()
lblVoucherStatus.Text = VoucherStatus
If VoucherStatus = "CLOSED" Then
cmdDelete.Enabled = False
cmdPost.Enabled = False
cmdReverse.Enabled = False
cmdSave.Enabled = False
LockCertainControls()
ElseIf VoucherStatus = "POSTED" And VoucherSource = "VOUCHER RECEIPT" Then
cmdDelete.Enabled = False
cmdPost.Enabled = False
cmdReverse.Enabled = True
cmdSave.Enabled = True
LockCertainControls()
ElseIf VoucherStatus = "OPEN" And VoucherSource = "VOUCHER RECEIPT" Then
cmdDelete.Enabled = True
cmdPost.Enabled = True
cmdReverse.Enabled = False
cmdSave.Enabled = True
UnLockCertainControls()
ElseIf VoucherStatus = "PENDING" And VoucherSource = "VOUCHER RECEIPT" Then
cmdDelete.Enabled = True
cmdPost.Enabled = True
cmdReverse.Enabled = False
cmdSave.Enabled = True
UnLockCertainControls()
ElseIf VoucherStatus = "POSTED" And VoucherSource = "PO RECEIPT" Then
cmdDelete.Enabled = False
cmdPost.Enabled = False
cmdReverse.Enabled = True
cmdSave.Enabled = True
LockCertainControls()
ElseIf VoucherStatus = "POSTED" And VoucherSource = "RECURRING VOUCHER" Then
cmdDelete.Enabled = False
cmdReverse.Enabled = True
cmdPost.Enabled = False
cmdSave.Enabled = True
LockCertainControls()
ElseIf VoucherStatus = "OPEN" And VoucherSource = "PO RECEIPT" Then
cmdDelete.Enabled = True
cmdPost.Enabled = True
cmdReverse.Enabled = False
cmdSave.Enabled = True
UnLockCertainControls()
ElseIf VoucherStatus = "PENDING" And VoucherSource = "PO RECEIPT" Then
cmdDelete.Enabled = True
cmdPost.Enabled = True
cmdReverse.Enabled = False
cmdSave.Enabled = True
UnLockCertainControls()
ElseIf VoucherStatus = "OPEN" And VoucherSource = "VENDOR RETURN" Then
cmdDelete.Enabled = True
cmdPost.Enabled = True
cmdReverse.Enabled = False
cmdSave.Enabled = True
UnLockCertainControls()
ElseIf VoucherStatus = "PENDING" And VoucherSource = "VENDOR RETURN" Then
cmdDelete.Enabled = True
cmdPost.Enabled = True
cmdReverse.Enabled = False
cmdSave.Enabled = True
UnLockCertainControls()
ElseIf VoucherStatus = "POSTED" And VoucherSource = "VENDOR RETURN" Then
cmdDelete.Enabled = False
cmdPost.Enabled = False
cmdReverse.Enabled = True
cmdSave.Enabled = True
LockCertainControls()
ElseIf VoucherStatus = "POSTED" And VoucherSource = "STEEL RECEIPT" Then
cmdDelete.Enabled = False
cmdPost.Enabled = False
cmdReverse.Enabled = True
cmdSave.Enabled = True
LockCertainControls()
ElseIf VoucherStatus = "OPEN" And VoucherSource = "STEEL RECEIPT" Then
cmdDelete.Enabled = True
cmdPost.Enabled = True
cmdReverse.Enabled = False
cmdSave.Enabled = True
UnLockCertainControls()
ElseIf VoucherStatus = "PENDING" And VoucherSource = "STEEL RECEIPT" Then
cmdDelete.Enabled = True
cmdPost.Enabled = True
cmdReverse.Enabled = False
cmdSave.Enabled = True
UnLockCertainControls()
Else
cmdDelete.Enabled = False
cmdPost.Enabled = False
cmdReverse.Enabled = False
cmdSave.Enabled = False
UnLockCertainControls()
End If
End Sub
Public Sub ReloadTotals()
Dim SUMExtendedAmountStatement As String = "SELECT SUM(ExtendedAmount) FROM ReceiptOfInvoiceVoucherLines WHERE VoucherNumber = @VoucherNumber"
Dim SUMExtendedAmountCommand As New SqlCommand(SUMExtendedAmountStatement, con)
SUMExtendedAmountCommand.Parameters.Add("@VoucherNumber", SqlDbType.VarChar).Value = Val(cboVoucherNumber.Text)
If con.State = ConnectionState.Closed Then con.Open()
Try
SUMExtendedAmount = CDbl(SUMExtendedAmountCommand.ExecuteScalar)
Catch ex As Exception