-
Notifications
You must be signed in to change notification settings - Fork 0
/
frmCreateNewReceipt.frm
818 lines (790 loc) · 25.6 KB
/
frmCreateNewReceipt.frm
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
VERSION 5.00
Object = "{CFC13920-9EF4-11D0-B72F-0000C04D4C0A}#6.0#0"; "mswless.ocx"
Begin VB.Form frmCreateNewReceipt
BorderStyle = 1 'Fixed Single
Caption = "Create New Receipt"
ClientHeight = 7875
ClientLeft = 45
ClientTop = 390
ClientWidth = 7725
HelpContextID = 20
Icon = "frmCreateNewReceipt.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 7875
ScaleWidth = 7725
StartUpPosition = 2 'CenterScreen
Begin MSWLess.WLText txtQuantity
Height = 495
Left = 360
TabIndex = 23
ToolTipText = "Name of the client"
Top = 3960
Width = 3135
_ExtentX = 5530
_ExtentY = 873
_Version = 393216
MaxLength = 6
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSWLess.WLText txtID
Height = 495
Left = 360
TabIndex = 21
ToolTipText = "Receipt ID"
Top = 1200
Width = 3135
_ExtentX = 5530
_ExtentY = 873
_Version = 393216
Alignment = 1
Text = "ID"
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
Enabled = 0 'False
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSWLess.WLCheck chk3PersonInsurance
Height = 375
Left = 360
TabIndex = 20
ToolTipText = "Insurance in case of accidents with people"
Top = 5520
Width = 3255
_ExtentX = 5741
_ExtentY = 661
_Version = 393216
Caption = "Third Person Insurance"
ForeColor = -2147483630
BackColor = -2147483633
Appearance = 1
End
Begin MSWLess.WLCommand btnCreate
Height = 975
Left = 1080
TabIndex = 19
Top = 6720
Width = 2535
_ExtentX = 4471
_ExtentY = 1720
_Version = 393216
Caption = "&Create"
ForeColor = -1
BackColor = -2147483633
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSWLess.WLCommand btnReset
Height = 975
Left = 4200
TabIndex = 18
Top = 6720
Width = 2535
_ExtentX = 4471
_ExtentY = 1720
_Version = 393216
Caption = "&Reset"
ForeColor = -1
BackColor = -2147483633
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 14.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSWLess.WLText txtTotal
Height = 495
Left = 4200
TabIndex = 16
ToolTipText = "Total (Includes 13% taxes)"
Top = 5880
Width = 3135
_ExtentX = 5530
_ExtentY = 873
_Version = 393216
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
Enabled = 0 'False
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSWLess.WLText txtSubTotal
Height = 495
Left = 4200
TabIndex = 14
ToolTipText = "Subtotal to pay"
Top = 4920
Width = 3135
_ExtentX = 5530
_ExtentY = 873
_Version = 393216
ForeColor = 255
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
Enabled = 0 'False
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSWLess.WLCombo cmbSeller
Height = 390
Left = 4200
TabIndex = 12
ToolTipText = "Seller"
Top = 3960
Width = 3135
_ExtentX = 5530
_ExtentY = 688
_Version = 393216
Style = 2
ListCount = -9740
Text = "cmbSeller"
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
List = "frmCreateNewReceipt.frx":3AFA
End
Begin MSWLess.WLCheck chkVehicleInsurance
Height = 375
Left = 360
TabIndex = 10
ToolTipText = "Insurance in case of crashes"
Top = 4920
Width = 3255
_ExtentX = 5741
_ExtentY = 661
_Version = 393216
Caption = "Vehicle Insurance"
ForeColor = -2147483630
BackColor = -2147483633
Appearance = 1
End
Begin VB.Label Label4
Caption = "Extras"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 9
Top = 4680
Width = 3255
End
Begin MSWLess.WLCombo cmbModel
Height = 390
Left = 4200
TabIndex = 7
ToolTipText = "Model"
Top = 3120
Width = 3135
_ExtentX = 5530
_ExtentY = 688
_Version = 393216
Style = 2
ListCount = -9860
Text = "cmbModel"
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
List = "frmCreateNewReceipt.frx":3B16
End
Begin MSWLess.WLCombo cmbManufacturer
Height = 390
Left = 360
TabIndex = 5
ToolTipText = "Manufacturer"
Top = 3120
Width = 3135
_ExtentX = 5530
_ExtentY = 688
_Version = 393216
Style = 2
ListCount = -10660
Text = "cmbManufacturer"
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
List = "frmCreateNewReceipt.frx":3B64
End
Begin MSWLess.WLText txtLastName
Height = 495
Left = 4200
TabIndex = 3
ToolTipText = "Last name of the client"
Top = 2160
Width = 3135
_ExtentX = 5530
_ExtentY = 873
_Version = 393216
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin MSWLess.WLText txtName
Height = 495
Left = 360
TabIndex = 1
ToolTipText = "Name of the client"
Top = 2160
Width = 3135
_ExtentX = 5530
_ExtentY = 873
_Version = 393216
ForeColor = -2147483640
BackColor = -2147483643
BorderStyle = 1
Appearance = 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "Consolas"
Size = 11.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
End
Begin VB.Label lblTitle
Alignment = 2 'Center
Caption = "Receipt"
BeginProperty Font
Name = "Javanese Text"
Size = 24
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 735
Left = 240
TabIndex = 0
Top = 0
Width = 7215
End
Begin VB.Label lblName
Caption = "Name"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 2
Top = 1920
Width = 3135
End
Begin VB.Label lblLastName
Caption = "Last Name"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 4
Top = 1920
Width = 3135
End
Begin VB.Label lblManufacturer
Caption = "Manufacturer"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 6
Top = 2880
Width = 3135
End
Begin VB.Label lblModel
Caption = "Model"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 8
Top = 2880
Width = 3135
End
Begin VB.Label lblQuantity
Caption = "Quantity"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 11
Top = 3720
Width = 3135
End
Begin VB.Label lblSeller
Caption = "Seller"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 13
Top = 3720
Width = 3135
End
Begin VB.Label Label8
Caption = "SubTotal"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 15
Top = 4680
Width = 3135
End
Begin VB.Label Label9
Caption = "Total"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 4200
TabIndex = 17
Top = 5640
Width = 3135
End
Begin VB.Label Label10
Caption = "Receipt ID"
BeginProperty Font
Name = "Consolas"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 255
Left = 360
TabIndex = 22
Top = 960
Width = 3135
End
End
Attribute VB_Name = "frmCreateNewReceipt"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim AlreadyMarked As Boolean
Public SubTotalValue As Double
Public TotalValue As Double
Public PreviousStatus As String
Const VehicleInsuranceValue = 4000
Const ThirdPersonInsuranceValue = 7500
Private Sub btnCreate_Click()
On Error GoTo ErrHandler
Dim Subtotal As Long
Dim Total As Long
If IsInformationValid And IsQuantityAvailable Then
If btnCreate.Caption = "&Create" Then
ExecuteSQL "Select * from Receipt"
rs.AddNew
rs!Receipt_ID = txtID
PreviousStatus = "Approved"
MsgBox "New receipt created successfully!", vbOKOnly, "Information"
ElseIf btnCreate.Caption = "&Update" Then
ExecuteSQL "Select * from Receipt where Receipt_ID = '" & txtID & "'"
MsgBox "Receipt updated successfully!", vbOKOnly, "Information"
End If
Else
MsgBox "Fill all the required spaces in the form", vbInformation, "Information"
CheckEmptyText
AlreadyMarked = True
Exit Sub
End If
rs!Client_Name = txtName
rs!Client_LastName = txtLastName
rs!Manufacturer_ID = GetManufacturerID
rs!Model_ID = GetModelID
rs!Quantity = FormatNumber(txtQuantity.Text, 0)
rs!Seller_ID = GetSellerID
rs!Vehicle_Insurance = chkVehicleInsurance.value
rs!Third_Person_Insurance = chk3PersonInsurance.value
Subtotal = FormatNumber(Replace(txtSubTotal.Text, "$", ""), 0)
rs!Subtotal = Subtotal
Total = FormatNumber(Replace(txtTotal.Text, "$", ""), 0)
rs!Total = Total
rs!Status = PreviousStatus
rs.Update
UpdateVehicleQuantity
AlreadyMarked = False
RemoveMark Me
ClearForm
If btnCreate.Caption = "&Update" Then
Unload Me
End If
Exit Sub
ErrHandler:
MsgBox "There was an error during the operation", vbCritical, "Error"
Exit Sub
End Sub
Function IsQuantityAvailable() As Boolean
Dim NextAvailable As Variant
Dim value As Boolean
value = True
ExecuteSQL "Select * from Vehicle where ID = " & GetModelID
NextAvailable = rs.Fields!Quantity - CDbl(txtQuantity)
If NextAvailable < 0 Then
MsgBox "Quantity is not available or vehicle is currently Out of Stock"
value = False
End If
IsQuantityAvailable = value
End Function
Sub UpdateVehicleQuantity()
ExecuteSQL "Select * from Vehicle where ID = " & GetModelID
rs.Fields!Quantity = rs.Fields!Quantity - CDbl(txtQuantity)
rs.Update
End Sub
Sub CheckEmptyText()
If Not AlreadyMarked Then
AddRequiredMark lblName, vbRed, txtName
AddRequiredMark lblLastName, vbRed, txtLastName
AddRequiredMark lblManufacturer, vbRed, , cmbManufacturer
AddRequiredMark lblModel, vbRed, , cmbModel
AddRequiredMark lblQuantity, vbRed, txtQuantity
AddRequiredMark lblSeller, vbRed, , cmbSeller
End If
End Sub
Private Sub chk3PersonInsurance_Click()
On Error GoTo ErrHandler
If chk3PersonInsurance.value = wlChecked Then
SubTotalValue = Replace(txtSubTotal, "$", "")
SubTotalValue = SubTotalValue + ThirdPersonInsuranceValue
txtSubTotal.Text = ""
FormatSubTotalValue
Else
SubTotalValue = Replace(txtSubTotal, "$", "")
SubTotalValue = SubTotalValue - ThirdPersonInsuranceValue
txtSubTotal.Text = ""
FormatSubTotalValue
End If
Exit Sub
ErrHandler:
Exit Sub
End Sub
Private Sub txtQuantity_LostFocus()
Dim currentQuantity As Variant
If cmbManufacturer.ListIndex = -1 Or cmbModel.ListIndex = -1 Or txtQuantity.Text = "" Then
Exit Sub
End If
If IsQuantityValid(currentQuantity) Then
txtQuantity.Text = Format(txtQuantity.Text, "###,#")
SetSubTotal
Else
MsgBox "There are not enough vehicles, maximum available is " & currentQuantity, vbOKOnly, "Information"
txtQuantity = "0"
txtQuantity.SetFocus
End If
End Sub
Function IsQuantityValid(ByRef currentQuantity As Variant) As Boolean
ExecuteSQL2 "Select * from Vehicle where Vehicle_Name = '" & cmbModel.Text & "'"
currentQuantity = rs2.Fields!Quantity
If currentQuantity >= CDbl(txtQuantity.Text) Then
IsQuantityValid = True
Else
IsQuantityValid = False
End If
End Function
Function GetManufacturerID() As Integer
ExecuteSQL3 "Select * from Brand where Brand_Name = '" & cmbManufacturer.Text & "'"
GetManufacturerID = rs3.Fields!ID
End Function
Function GetModelID() As Integer
ExecuteSQL3 "Select * from Vehicle where Vehicle_Name = '" & cmbModel.Text & "'"
GetModelID = rs3.Fields!ID
End Function
Function GetSellerID() As Integer
Dim SellerDNI As String
SellerDNI = Right(cmbSeller, 9)
ExecuteSQL3 "Select * from Staff where DNI = '" & SellerDNI & "'"
GetSellerID = rs3.Fields!ID
End Function
Private Sub btnReset_Click()
ClearForm
End Sub
Sub ClearForm()
RemoveMark Me
AlreadyMarked = False
txtID.Text = ""
txtName.Text = ""
txtLastName.Text = ""
txtQuantity.Text = ""
cmbManufacturer.ListIndex = -1
cmbModel.ListIndex = -1
cmbSeller.ListIndex = -1
txtSubTotal.Text = ""
txtTotal.Text = ""
chkVehicleInsurance.value = wlUnchecked
chk3PersonInsurance.value = wlUnchecked
LoadReceiptID
End Sub
Function IsInformationValid() As Boolean
If txtName.Text <> "" And txtLastName.Text <> "" And _
cmbManufacturer.ListIndex <> -1 And cmbModel.ListIndex <> -1 And _
txtQuantity.Text <> "" And cmbSeller.ListIndex <> -1 Then
IsInformationValid = True
Else
IsInformationValid = False
End If
End Function
Private Sub chkVehicleInsurance_Click()
On Error GoTo ErrHandler
If chkVehicleInsurance.value = wlChecked Then
SubTotalValue = Replace(txtSubTotal, "$", "")
SubTotalValue = SubTotalValue + VehicleInsuranceValue
txtSubTotal.Text = ""
FormatSubTotalValue
Else
SubTotalValue = Replace(txtSubTotal, "$", "")
SubTotalValue = SubTotalValue - VehicleInsuranceValue
txtSubTotal.Text = ""
FormatSubTotalValue
End If
Exit Sub
ErrHandler:
Exit Sub
End Sub
Private Sub cmbManufacturer_Click()
If cmbManufacturer.Text <> "" Then
LoadModels
txtQuantity.Text = ""
txtSubTotal.Text = ""
txtTotal.Text = ""
chk3PersonInsurance.value = wlUnchecked
chkVehicleInsurance.value = wlUnchecked
End If
End Sub
Private Sub cmbModel_Click()
If cmbModel = "" Then
Exit Sub
End If
txtQuantity.Text = ""
txtSubTotal.Text = ""
txtTotal.Text = ""
chk3PersonInsurance.value = wlUnchecked
chkVehicleInsurance.value = wlUnchecked
End Sub
Sub SetSubTotal()
If txtQuantity.Text <> "" Then
ExecuteSQL2 "Select * from Vehicle where Vehicle_Name = '" & cmbModel.Text & "'"
vehiclePrice = rs2.Fields!Price
SubTotalValue = CDbl(vehiclePrice * txtQuantity)
If chkVehicleInsurance.value = wlChecked Then
SubTotalValue = SubTotalValue + VehicleInsuranceValue
End If
If chk3PersonInsurance.value = wlChecked Then
SubTotalValue = SubTotalValue + ThirdPersonInsuranceValue
End If
FormatSubTotalValue
Else
SubTotalValue = 0
TotalValue = 0
FormatSubTotalValue
End If
End Sub
Sub FormatSubTotalValue()
txtSubTotal = Format(SubTotalValue, "$#,###")
TotalValue = SubTotalValue + SubTotalValue * 0.13
txtTotal = Format(TotalValue, "$#,###")
End Sub
Private Sub Form_Load()
LoadReceiptID
LoadManufacturers
LoadSellers
cmbModel.ListIndex = 0
VerifyCurrentRole
End Sub
Sub VerifyCurrentRole()
If frmMain.CurrentUserRoleID = 2 Then
MsgBox "The current user does not have permission to sell cars", vbInformation, "Information"
btnCreate.Enabled = False
End If
End Sub
Sub LoadReceiptID()
ExecuteSQL "Select * from Receipt"
txtID = "V3UC44P" & CStr(rs.RecordCount) + 1
If Len(CStr(rs.RecordCount)) = 2 Then
txtID = "V3UC44" & CStr(rs.RecordCount) + 1
ElseIf Len(CStr(rs.RecordCount)) = 3 Then
txtID = "V3UC4" & CStr(rs.RecordCount) + 1
ElseIf Len(CStr(rs.RecordCount)) = 4 Then
txtID = "V3UC" & CStr(rs.RecordCount) + 1
End If
End Sub
Sub LoadManufacturers()
ExecuteSQL "Select * from Brand"
cmbManufacturer.Clear
While Not rs.EOF
cmbManufacturer.AddItem (rs.Fields!Brand_Name)
rs.MoveNext
Wend
End Sub
Sub LoadModels()
ExecuteSQL "Select * from Vehicle where Manufacturer_ID = " & GetManufacturerID
cmbModel.Clear
While Not rs.EOF
cmbModel.AddItem (rs.Fields!Vehicle_Name)
rs.MoveNext
Wend
End Sub
Sub LoadSellers()
Dim FullName As String
ExecuteSQL "Select * from Staff where Role_ID = 1 or Role_ID = 3"
cmbSeller.Clear
While Not rs.EOF
FullName = rs.Fields!Staff_Name & " " & rs.Fields!Staff_LastName & " - " & rs.Fields!DNI
cmbSeller.AddItem (FullName)
rs.MoveNext
Wend
End Sub