📄 frmtransaction.frm
字号:
EndProperty
ForeColor = &H0000FF00&
Height = 495
Left = 240
TabIndex = 23
Top = 240
Width = 10695
End
Begin VB.Label lblDisplay2
Alignment = 1 'Right Justify
BackColor = &H00000000&
Caption = "0.00"
BeginProperty Font
Name = "Arial"
Size = 36
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H0000FF00&
Height = 815
Left = 240
TabIndex = 22
Top = 840
Width = 10695
End
End
End
End
Attribute VB_Name = "frmTransaction"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim ArrayOFNamesAndID(), MembersID(), MemberID_FindMode As String
Dim PrevTransItems() As String 'List of PrevTransaction items
Dim DeletedItems() As String
Dim PrevTransMode As Boolean
Private Sub cboDeleteRow_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then Call cmdDeleteRow_Click
End Sub
Private Sub cboItemCode_KeyPress(KeyAscii As Integer)
If KeyAscii = vbKeyReturn Then Call cmdAddItem_Click
End Sub
Private Sub cmdAddItem_Click()
Dim strMembersFile As String
Dim loop1 As Long
Dim TotalAmountDue As Double
Dim vr_engine As VRENTAL_ENGINE
Set vr_engine = New VRENTAL_ENGINE
If Trim(cboItemCode.Text) = "" Then
cboItemCode.SetFocus
Exit Sub
End If
'Start - Chk if item has been borrowed already.
If PrevTransMode = False Then
strMembersFile = txtName.Text & " ID - " & MembersID(lstMembers.ListIndex + 1)
Else
strMembersFile = txtName.Text & " ID - " & MemberID_FindMode
End If
If vr_engine.Transaction_ChkIfItemHasBeenBorrowed(App.Path & "\Transaction\MembersRecords\" & strMembersFile & ".mdb", cboItemCode.Text) = True Then
cboItemCode.Text = ""
cboItemCode.SetFocus
Exit Sub
End If
'End - Chk if item has been borrowed already.
'Start - Chk if item code is already selected
For loop1 = 1 To MSFlexGrid1.Rows
If loop1 <= MSFlexGrid1.Rows - 1 Then
If cboItemCode.Text = MSFlexGrid1.TextMatrix(loop1, 1) Then
MsgBox "Item code is already in the list. ", vbInformation, "Item Code Has Been Loaded."
cboItemCode.SetFocus
Exit Sub
End If
End If
Next
'End - Chk if item code is already selected
Call vr_engine.Transaction_AddItem(MSFlexGrid1, cboItemCode)
'' caculate Total Amnt.
For loop1 = 1 To MSFlexGrid1.Rows - 1
TotalAmountDue = TotalAmountDue + Val(MSFlexGrid1.TextMatrix(loop1, 3))
Next
If MSFlexGrid1.Rows = 1 Then MSFlexGrid1.AddItem ""
If Trim(MSFlexGrid1.TextMatrix(1, 0)) = "" And Trim(MSFlexGrid1.TextMatrix(1, 1)) = "" And Trim(MSFlexGrid1.TextMatrix(1, 2)) = "" And Trim(MSFlexGrid1.TextMatrix(1, 3)) = "" Then
cmdDeleteRow.Enabled = False
cboDeleteRow.Enabled = False
cboDeleteRow.Clear
Else
cmdDeleteRow.Enabled = True
cboDeleteRow.Enabled = True
cboDeleteRow.Clear
For loop1 = 1 To MSFlexGrid1.Rows - 1
cboDeleteRow.AddItem str(loop1)
Next
End If
txtTotalAmountDue.Text = str(TotalAmountDue)
cboItemCode.Text = ""
cboItemCode.SetFocus
End Sub
Private Sub cmdCancel_Click()
cmdCancel.Enabled = False
txtName.Text = ""
txtInvoiceNumber.Text = ""
txtDate.Text = ""
cmdRefreshList.Enabled = False
lstMembers.Clear
lstMembers.Enabled = False
cboItemCode.Clear
cboItemCode.Enabled = False
cmdAddItem.Enabled = False
cmdDeleteRow.Enabled = False
cboDeleteRow.Clear
cboDeleteRow.Enabled = False
txtTotalAmountDue.Text = ""
txtAmountPaid.Text = ""
txtChange.Text = ""
MSFlexGrid1.Rows = 2
MSFlexGrid1.TextMatrix(1, 0) = ""
MSFlexGrid1.TextMatrix(1, 1) = ""
MSFlexGrid1.TextMatrix(1, 2) = ""
MSFlexGrid1.TextMatrix(1, 3) = ""
lblDisplay2.Caption = "0.00"
cmdNew.Enabled = True
cmdFind.Enabled = True
If cmdEdit.Enabled = True Then cmdEdit.Enabled = False
If cmdDelete.Enabled = True Then cmdDelete.Enabled = False
If cmdPrint.Enabled = True Then cmdPrint.Enabled = False
End Sub
Private Sub cmdDelete_Click()
Dim vr_engine As VRENTAL_ENGINE
Set vr_engine = New VRENTAL_ENGINE
Dim X
X = MsgBox("Are you sure you want to delete this transaction? ", vbYesNo, "Confirm Delete")
If X = vbNo Then
MSFlexGrid1.SetFocus
Exit Sub
End If
Call vr_engine.Transaction_DeletePrevTransaction(Trim(txtInvoiceNumber.Text), Trim(txtName.Text) & " ID - " & MemberID_FindMode & ".mdb")
Call cmdCancel_Click
End Sub
Private Sub cmdDeleteRow_Click()
Dim loop1 As Integer
Dim FlagFORone As Boolean
Dim TotalAmountDue As Double
FlagFORone = False
If IsNumeric(cboDeleteRow.Text) = True Then
If Int(cboDeleteRow.Text) + 1 = MSFlexGrid1.Rows Then
MSFlexGrid1.Rows = MSFlexGrid1.Rows - 1
cboDeleteRow.RemoveItem (cboDeleteRow.ListCount - 1)
For loop1 = 1 To MSFlexGrid1.Rows - 1
TotalAmountDue = TotalAmountDue + Val(MSFlexGrid1.TextMatrix(loop1, 3))
Next
txtTotalAmountDue.Text = str(TotalAmountDue)
cboItemCode.Text = ""
cboItemCode.SetFocus
Else
If Int(cboDeleteRow.Text) = 1 Then FlagFORone = True
For loop1 = Int(cboDeleteRow.Text) + 1 To cboDeleteRow.ListCount
If FlagFORone = True Then loop1 = 2
FlagFORone = False
MSFlexGrid1.TextMatrix(loop1 - 1, 1) = MSFlexGrid1.TextMatrix(loop1, 1)
MSFlexGrid1.TextMatrix(loop1 - 1, 2) = MSFlexGrid1.TextMatrix(loop1, 2)
MSFlexGrid1.TextMatrix(loop1 - 1, 3) = MSFlexGrid1.TextMatrix(loop1, 3)
Next
MSFlexGrid1.Rows = MSFlexGrid1.Rows - 1
For loop1 = 1 To MSFlexGrid1.Rows - 1
TotalAmountDue = TotalAmountDue + Val(MSFlexGrid1.TextMatrix(loop1, 3))
Next
cboDeleteRow.RemoveItem (cboDeleteRow.ListCount - 1)
txtTotalAmountDue.Text = str(TotalAmountDue)
cboItemCode.Text = ""
cboItemCode.SetFocus
End If
End If
cboItemCode.SetFocus
End Sub
Private Sub cmdEdit_Click()
Dim vr_engine As VRENTAL_ENGINE
Set vr_engine = New VRENTAL_ENGINE
Dim loop1 As Long
cmdEdit.Enabled = False
cmdSave.Enabled = True
cmdPrint.Enabled = True
Call vr_engine.Transaction_LoadItemCodes(cboItemCode)
cboItemCode.Enabled = True
cmdAddItem.Enabled = True
'' Load cboRow Number
If MSFlexGrid1.Rows = 1 Then MSFlexGrid1.AddItem ""
If Trim(MSFlexGrid1.TextMatrix(1, 0)) = "" And Trim(MSFlexGrid1.TextMatrix(1, 1)) = "" And Trim(MSFlexGrid1.TextMatrix(1, 2)) = "" And Trim(MSFlexGrid1.TextMatrix(1, 3)) = "" Then
cmdDeleteRow.Enabled = False
cboDeleteRow.Enabled = False
cboDeleteRow.Clear
Else
cmdDeleteRow.Enabled = True
cboDeleteRow.Enabled = True
cboDeleteRow.Clear
For loop1 = 1 To MSFlexGrid1.Rows - 1
cboDeleteRow.AddItem str(loop1)
Next
End If
'' End cboLoad Row Number
'' START -- Store Prev Borrowed items to Memory
ReDim PrevTransItems(MSFlexGrid1.Rows - 1)
For loop1 = 1 To MSFlexGrid1.Rows - 1
'Stores Item Code
PrevTransItems(loop1) = MSFlexGrid1.TextMatrix(loop1, 1)
''Debug.Print PrevTransItems(loop1)
Next
'' END -- Store Prev Borrowed items to Memory
End Sub
Private Sub cmdFind_Click()
Dim vr_engine As VRENTAL_ENGINE
Set vr_engine = New VRENTAL_ENGINE
Dim InvoiceNumber As String
InvoiceNumber = InputBox("Enter Invoice Number:", "Find Previous Transaction")
If Trim(InvoiceNumber) <> "" Then
txtInvoiceNumber.Text = InvoiceNumber
Else
MSFlexGrid1.SetFocus
Exit Sub
End If
If vr_engine.Transaction_LoadPrevTransaction(MSFlexGrid1, txtTotalAmountDue, txtAmountPaid, txtChange, txtDate, txtInvoiceNumber, txtName, MemberID_FindMode) = True Then
txtAmountPaid.Locked = True
cmdFind.Enabled = False
cmdNew.Enabled = False
cmdEdit.Enabled = True
cmdCancel.Enabled = True
cmdDelete.Enabled = True
PrevTransMode = True
End If
End Sub
Private Sub cmdNew_Click()
cmdNew.Enabled = False
Dim vr_engine As VRENTAL_ENGINE
Set vr_engine = New VRENTAL_ENGINE
'' SetFlag
PrevTransMode = False
'' Load ItemCodes
Call vr_engine.Transaction_LoadItemCodes(cboItemCode)
'' Load Members ' Once
Call vr_engine.Transaction_LoadNameOfMembers(lstMembers, ArrayOFNamesAndID(), MembersID())
cmdRefreshList.Enabled = True
cmdFind.Enabled = False
cmdCancel.Enabled = True
lstMembers.Enabled = True
lblDisplay1.Caption = "NEW TRANSACTION"
lblDisplay2.Caption = "SELECT NAME FROM LIST "
If lstMembers.Enabled = True Then lstMembers.SetFocus
End Sub
Private Sub cmdPrint_Click()
'--------------------------------------------
If MsgBox("Please insert 8 1/2"" by 13"" paper. ", vbOKCancel, "Insert Paper ") = vbCancel Then
MSFlexGrid1.SetFocus
Exit Sub
End If
'--------------------------------------------
MousePointer = vbHourglass
Dim vr_engine As VRENTAL_ENGINE
Set vr_engine = New VRENTAL_ENGINE
Printer.Font = "Lucida Console"
Printer.PaperSize = vbPRPSLegal ' 8.5 by 14 inc
Printer.FontSize = 9
Printer.Orientation = 1 'Portrait
Dim LeftMargin, PageCount, BlankLines As Integer
Dim DateDue() As String
Dim loop1, loop2, Lines, Flag As Long
LeftMargin = 10
Lines = MSFlexGrid1.Rows - 1
' Start Calculate DateDue
For loop1 = 1 To Lines
ReDim Preserve DateDue(loop1)
DateDue(loop1) = vr_engine.Transaction_GetDateDue(MSFlexGrid1.TextMatrix(loop1, 1), Format(Now, "mm/dd/yyyy"))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -