⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmpdcmanagerae.frm

📁 Inventory control system
💻 FRM
📖 第 1 页 / 共 2 页
字号:
   Begin VB.Label Labels 
      Alignment       =   1  'Right Justify
      Caption         =   "Account Name"
      Height          =   240
      Index           =   3
      Left            =   -75
      TabIndex        =   18
      Top             =   1275
      Width           =   1365
   End
   Begin VB.Label Labels 
      Alignment       =   1  'Right Justify
      Caption         =   "Address"
      Height          =   240
      Index           =   2
      Left            =   -75
      TabIndex        =   17
      Top             =   2775
      Width           =   1365
   End
   Begin VB.Label Labels 
      Alignment       =   1  'Right Justify
      Caption         =   "Bank Name"
      Height          =   240
      Index           =   1
      Left            =   75
      TabIndex        =   16
      Top             =   2400
      Width           =   1215
   End
   Begin VB.Label Labels 
      Alignment       =   1  'Right Justify
      Caption         =   "Check No."
      Height          =   240
      Index           =   0
      Left            =   375
      TabIndex        =   15
      Top             =   150
      Width           =   915
   End
End
Attribute VB_Name = "frmPDCManagerAE"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False

Option Explicit

Public State                As FormState 'Variable used to determine on how the form used
Public PK                   As Long 'Variable used to get what record is going to edit
Public srcText              As TextBox 'Used in pop-up mode

Dim HaveAction              As Boolean 'Variable used to detect if the user perform some action
Dim rs                      As New Recordset

Private Sub DisplayForEditing()
    On Error GoTo err
    
    With rs
        txtEntry(0).Text = .Fields("CheckNo")
        dtpIssue.Value = .Fields("DateIssued")
        dtpDue.Value = .Fields("DateDue")
        txtEntry(1).Text = .Fields("AccountName")
        txtEntry(2).Text = .Fields("AccountNo")
        txtEntry(3).Text = toMoney(.Fields("CheckAmount"))
        txtEntry(4).Text = .Fields("BankName")
        txtEntry(5).Text = .Fields("Address")
        txtEntry(6).Text = .Fields("Remarks")
        chkCleared.Value = changeYNValue(.Fields("Cleared"))
        dcVan.BoundText = ![VanFK]
    End With
    
    Exit Sub
err:
        If err.Number = 94 Then Resume Next
End Sub

Private Sub cmdBrowser_Click()
    With frmSelectBank
        Set .srcTextBank = txtEntry(4)
        Set .srcTextBAddress = txtEntry(5)
    
        .show vbModal
    End With
End Sub

Private Sub cmdCancel_Click()
    Unload Me
End Sub

Private Sub ResetFields()
    clearText Me
    
    dtpIssue.Value = Date
    dtpDue.Value = Date
    chkCleared.Value = 0
    
    txtEntry(0).SetFocus
End Sub

Private Sub GeneratePK()
    PK = getIndex("tbl_AR_PDCManager")
End Sub

Private Sub cmdSave_Click()
    If is_empty(txtEntry(0), True) = True Then Exit Sub
    If is_empty(txtEntry(1), True) = True Then Exit Sub
    If is_empty(txtEntry(2), True) = True Then Exit Sub
    If toNumber(txtEntry(3).Text) < 1 Then
        MsgBox "Check amouny must have a non-zero value.", vbExclamation
        txtEntry(3).SetFocus
        Exit Sub
    End If
    
    If State = adStateAddMode Or State = adStatePopupMode Then
        rs.AddNew
        rs.Fields("PK") = PK
        rs.Fields("DateAdded") = Now
        rs.Fields("AddedByFK") = CurrUser.USER_PK
    Else
        rs.Fields("DateModified") = Now
        rs.Fields("LastUserFK") = CurrUser.USER_PK
    End If
    
    With rs
        .Fields("CheckNo") = txtEntry(0).Text
        .Fields("DateIssued") = dtpIssue.Value
        .Fields("DateDue") = dtpDue.Value
        .Fields("AccountName") = txtEntry(1).Text
        .Fields("AccountNo") = txtEntry(2).Text
        .Fields("CheckAmount") = toNumber(txtEntry(3).Text)
        .Fields("BankName") = txtEntry(4).Text
        .Fields("Address") = txtEntry(5).Text
        .Fields("Remarks") = txtEntry(6).Text
        .Fields("Cleared") = changeYNValue(chkCleared.Value)
        .Fields("VanFK") = dcVan.BoundText
    
        .Update
    End With
    
    HaveAction = True
    
    If State = adStateAddMode Then
        MsgBox "New record has been successfully saved.", vbInformation
        If MsgBox("Do you want to add another new record?", vbQuestion + vbYesNo) = vbYes Then
            ResetFields
            GeneratePK
         Else
            Unload Me
        End If
    ElseIf State = adStatePopupMode Then
        MsgBox "New record has been successfully saved.", vbInformation
        Unload Me
    Else
        MsgBox "Changes in  record has been successfully saved.", vbInformation
        Unload Me
    End If
End Sub

Private Sub cmdUsrHistory_Click()
    On Error Resume Next
    Dim tDate1 As String
    Dim tDate2 As String
    Dim tUser1 As String
    Dim tUser2 As String
    
    tDate1 = Format$(rs.Fields("DateAdded"), "MMM-dd-yyyy HH:MM AMPM")
    tDate2 = Format$(rs.Fields("DateModified"), "MMM-dd-yyyy HH:MM AMPM")
    
    tUser1 = getValueAt("SELECT PK,CompleteName FROM tbl_SM_Users WHERE PK = " & rs.Fields("AddedByFK"), "CompleteName")
    tUser2 = getValueAt("SELECT PK,CompleteName FROM tbl_SM_Users WHERE PK = " & rs.Fields("LastUserFK"), "CompleteName")
    
    MsgBox "Date Added: " & tDate1 & vbCrLf & _
           "Added By: " & tUser1 & vbCrLf & _
           "" & vbCrLf & _
           "Last Modified: " & tDate2 & vbCrLf & _
           "Modified By: " & tUser2, vbInformation, "Modification History"
           
    tDate1 = vbNullString
    tDate2 = vbNullString
    tUser1 = vbNullString
    tUser2 = vbNullString
End Sub

Private Sub Form_Load()
    'Set the graphics for the controls
    With MAIN
        cmdBrowser.Picture = .i16x16.ListImages(8).Picture
    End With
    
    'Set the controls default property
    dtpIssue.Value = Date
    dtpDue.Value = Date
    
    bind_dc "SELECT * FROM tbl_AR_Van", "VanName", dcVan, "PK", True
    
    rs.CursorLocation = adUseClient
    rs.Open "SELECT * FROM tbl_AR_PDCManager WHERE PK = " & PK, CN, adOpenStatic, adLockOptimistic
    'Check the form state
    If State = adStateAddMode Or State = adStatePopupMode Then
        If State = adStatePopupMode Then
            Caption = "New PDC Entry"
        Else
            Caption = "Create New Entry"
        End If
        cmdUsrHistory.Enabled = False
        GeneratePK
    Else
        Caption = "Edit Entry"
        DisplayForEditing
    End If

End Sub

Private Sub Form_Unload(Cancel As Integer)
    If HaveAction = True Then
        If State = adStateAddMode Or State = adStateEditMode Then
            frmPDCManager.RefreshRecords
        ElseIf State = adStatePopupMode Then
            If isObjectSet(srcText) = True Then
                srcText.Text = rs![CheckNo]
                srcText.Tag = rs![PK]
            End If
        End If
        MAIN.UpdateInfoMsg
    End If
    
    Set frmPDCManagerAE = Nothing
End Sub

Private Sub txtEntry_GotFocus(Index As Integer)
    If Index = 6 Then cmdSave.Default = False
    HLText txtEntry(Index)
End Sub

Private Sub txtEntry_KeyPress(Index As Integer, KeyAscii As Integer)
    If Index = 3 Then KeyAscii = isNumber(KeyAscii)
End Sub

Private Sub txtEntry_LostFocus(Index As Integer)
    If Index = 6 Then cmdSave.Default = True
End Sub

Private Sub txtEntry_Validate(Index As Integer, Cancel As Boolean)
    If Index = 3 Then txtEntry(Index).Text = toMoney(toNumber(txtEntry(Index).Text))
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -