📄 sales.frm
字号:
MsgBox "Please enter amount!", vbInformation
txtPayments.SetFocus
Exit Sub
Else
If adoOrders.State = 1 Then Set adoOrders = Nothing
adoOrders.Open "SELECT * from [Invoice] where [Invoice No] = '" & txtInvoiceNo.Text & "'", con, adOpenDynamic, adLockPessimistic
With adoOrders
If .EOF Then
Timer2 = True
con.BeginTrans
.AddNew
.Fields(0) = txtInvoiceNo.Text
.Fields(1) = txtAmount.Text
.Fields(2) = txtDiscount.Text
.Fields(3) = txtPayments.Text
.Fields(4) = txtChange.Text
.Fields(5) = Date
.Update
.Requery
con.CommitTrans
.Close
End If
End With
For i = 1 To lvprod.ListItems.Count
If adoInvoice.State = 1 Then Set adoInvoice = Nothing
adoInvoice.Open "SELECT * from SIDetails", con, adOpenDynamic, adLockPessimistic
With adoInvoice
con.BeginTrans
.AddNew
.Fields(0) = txtInvoiceNo.Text
.Fields(1) = lvprod.ListItems(i).Text
.Fields(2) = lvprod.ListItems(i).SubItems(1)
.Fields(3) = lvprod.ListItems(i).SubItems(4)
.Update
.Requery
con.CommitTrans
.Close
End With
calther = "update Product set Quantity = Quantity - '" & lvprod.ListItems(i).SubItems(1) & "' where [Product Id] ='" & lvprod.ListItems(i).Text & "'"
con.Execute calther
Next i
btnSave.Enabled = False
btnPrint.Enabled = True
End If
End If
End Sub
Private Sub btnStart_Click()
Call autoSalesNo
txtSearch.locked = False
txtPayments.locked = False
btnStart.Enabled = False
btnCancel.Enabled = True
txtSearch.SetFocus
txtAmount.Text = ""
txtDiscount.Text = ""
End Sub
Private Sub cmdOrder_Click()
Dim ilan As Double
txtDiscount.Text = "0.00"
If Val(txtQtyOrder.Text) > Val(txtQtyHand.Text) Then
MsgBox "The stocks on Product Entry " + vbCrLf + " is not enough pls..change" + vbCrLf + " the value of the item ordered", vbOKOnly + vbInformation, "Insufficient"
SendKeys "{home}" + "{end}"
Exit Sub
Else
If txtID.Text = Empty Or txtQtyOrder.Text = Empty Then
Exit Sub
Else
If Val(txtQtyHand.Text) <= 0 Then
MsgBox "There is no stocks on Product Entry " + vbCrLf + " please re-order to continue sales", vbOKOnly + vbInformation, "Empty Stock"
Else
ans = MsgBox("Sure to Order this?", vbQuestion + vbYesNo, "Order?")
If ans = vbYes Then
ilan = Val(txtPrice) * Val(txtQtyOrder)
txtAmount.Text = CStr(Format(ilan, "##,###.#0"))
Call orderItem
Call Cleartext
Else
Exit Sub
End If
End If
End If
End If
txtPayments.SetFocus
End Sub
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1
Call btnStart_Click
Case vbKeyF2
LookUp.Show vbModal
Case vbKeyF3
btnCancel_Click
Case vbKeyF4
Call btnSave_Click
Case vbKeyF9
ans = MsgBox("Are you sure do you want Log Off?", vbQuestion + vbYesNo, "Log Off")
If ans = vbYes Then
Unload Me
Password.Show
mdiMain.Hide
Else
Exit Sub
End If
End Select
End Sub
Private Sub Form_Load()
Me.Width = 9675
Me.Height = 9315
Timer2 = False
sb2.Visible = False
lblCashier.BorderStyle = 0
lblCashier.Caption = "Your Cashier is: " + mdiMain.sb1.Panels(5).Text
mdiMain.sb1.Visible = False
End Sub
Private Sub Form_Unload(Cancel As Integer)
If lvprod.ListItems.Count > 0 Then
MsgBox "Active transaction detected" + vbCrLf + "please cancel or continue transaction" + vbCrLf + "to close this form", vbExclamation, "Active Trans"
Cancel = Not Me
End If
End Sub
Private Sub lv1_Click()
txtSearch.Text = lv1.SelectedItem.SubItems(1)
txtQtyOrder.SetFocus
End Sub
Private Sub lvprod_DblClick()
If lvprod.ListItems.Count = 0 Then
MsgBox "No items to remove!", vbOKOnly + vbInformation, "Remove"
Else
If MsgBox("Are you sure you want to remove " & Chr(10) & Chr(10) & StrConv(lvprod.SelectedItem.SubItems(2), vbUpperCase), vbYesNo + vbQuestion, "Remove Item") = vbYes Then
lvprod.ListItems.Remove lvprod.SelectedItem.Index
txtAmount.Text = CStr(Format(ComputeAmount, "########0.00"))
Else
Exit Sub
End If
End If
End Sub
Private Sub lvprod_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1
Call btnStart_Click
Case vbKeyF2
LookUp.Show vbModal
Case vbKeyF3
btnCancel_Click
Case vbKeyF4
Call btnSave_Click
Case vbKeyF9
ans = MsgBox("Are you sure do you want Log Off?", vbQuestion + vbYesNo, "Log Off")
If ans = vbYes Then
Unload Me
Password.Show
mdiMain.Hide
Else
Exit Sub
End If
End Select
End Sub
Private Sub Timer1_Timer()
txtInvoiceDate.Text = Format(Date, "mm.dd.yyyy")
txtTime.Text = Time
End Sub
Private Sub Timer2_Timer()
On Error Resume Next
Bar.Value = Bar.Value + 1
Screen.MousePointer = vbHourglass
If Bar.Value <= 10 Then
lblStatus.Caption = "Processing...."
ElseIf Bar.Value <= 20 Then
lblStatus.Caption = "Please wait...."
ElseIf Bar.Value <= 30 Then
lblStatus.Caption = "Transaction Complete"
If Bar.Value = 30 Then
If Timer2.Interval >= 1 Then
lblStatus.Caption = ""
btnPrint.SetFocus
Call btnPrint_Click
Timer2 = False
Screen.MousePointer = vbDefault
End If
End If
End If
End Sub
Private Sub txtDiscount_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1
Call btnStart_Click
Case vbKeyF2
LookUp.Show vbModal
Case vbKeyF3
btnCancel_Click
Case vbKeyF4
Call btnSave_Click
Case vbKeyF9
ans = MsgBox("Are you sure do you want Log Off?", vbQuestion + vbYesNo, "Log Off")
If ans = vbYes Then
Unload Me
Password.Show
mdiMain.Hide
Else
Exit Sub
End If
End Select
End Sub
Private Sub txtDiscount_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
If Val(txtDiscount.Text) < Val(txtAmount.Text) Then
txtDiscount.Text = txtDiscount.Text / 100
btnCompute.Enabled = True
a = Val(txtAmount.Text) * Val(txtDiscount.Text)
b = Val(txtAmount.Text) - a
txtAmount.Text = b
txtPayments.SetFocus
Else
MsgBox "Discount should be less than " & vbCrLf & "the total amount", vbExclamation, "Discount"
End If
End If
End Sub
Private Sub txtPayments_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1
Call btnStart_Click
Case vbKeyF2
LookUp.Show vbModal
Case vbKeyF3
btnCancel_Click
Case vbKeyF4
Call btnSave_Click
Case vbKeyF9
ans = MsgBox("Are you sure do you want Log Off?", vbQuestion + vbYesNo, "Log Off")
If ans = vbYes Then
Unload Me
Password.Show
mdiMain.Hide
Else
Exit Sub
End If
End Select
End Sub
Private Sub txtPayments_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Call btnCompute_Click
End If
End Sub
Private Sub txtQtyOrder_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyF1
Call btnStart_Click
Case vbKeyF2
LookUp.Show vbModal
Case vbKeyF3
btnCancel_Click
Case vbKeyF4
Call btnSave_Click
Case vbKeyF9
ans = MsgBox("Are you sure do you want Log Off?", vbQuestion + vbYesNo, "Log Off")
If ans = vbYes Then
Unload Me
Password.Show
mdiMain.Hide
Else
Exit Sub
End If
End Select
End Sub
Private Sub txtQtyOrder_KeyPress(KeyAscii As Integer)
Select Case KeyAscii
Case Asc(0) To Asc(9)
Case Str("8")
Case Str("13")
Case Else
KeyAscii = 0
End Select
If KeyAscii = 13 Then
Call cmdOrder_Click
End If
End Sub
Private Sub txtSearch_Change()
If Orders.State = 1 Then Set Orders = Nothing
calther = "SELECT * from [Product] where [Product Id] like '" & Trim(txtSearch) & "%'"
Orders.Open calther, con, adOpenKeyset, adLockOptimistic
With Orders
If Not .EOF Then
txtID.Text = .Fields(0)
txtName.Text = .Fields(1)
txtPrice.Text = CStr(Format(.Fields(5), "##,###.#0"))
txtQtyHand.Text = .Fields(3)
Else
Call Cleartext
End If
End With
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -