VbzCart/docs/archive/code/VBA/clsPackageQueueItem

From Woozle Writes Code
< VbzCart‎ | docs‎ | archive‎ | code‎ | VBA
Jump to navigation Jump to search
' CLASS: clsPackageQueueItem

Option Compare Database
Option Explicit
Private vID As Long
Private vPackage As Long
Private vReport As String
Private vWhenPrinted As Variant
Public Sub Init(iFields As Fields)
    With iFields
        vID = !ID
        vPackage = !ID_Package
        vReport = !ReportName
        vWhenPrinted = !WhenPrinted
    End With
End Sub
Public Sub Create(iPackage As Long, iReport As String)
    With clsPackageQueue
        .DataOpen
        With .Data
            .AddNew
            vID = !ID
            !ID_Package = iPackage
            !ReportName = iReport
            .Update
        End With
        .DataShut
    End With
End Sub
Public Property Get Package_ID() As Long
    Package_ID = vPackage
End Property
Public Property Get Report() As String
    Report = vReport
End Property
Public Property Get WhenPrinted() As Date
    WhenPrinted = vWhenPrinted
End Property
Public Property Get Printed() As Boolean
    Printed = Not IsNull(vWhenPrinted)
End Property
Private Function Located() As Boolean
    With clsPackageQueue
        .DataOpen
        With .Data
            .FindFirst "ID=" & vID
            Located = Not .NoMatch
        End With
        .DataShut
    End With
End Function
Public Property Let Printed(iDone As Boolean)
    If iDone <> Me.Printed Then
        With clsPackageQueue
            .DataOpen
            If Located Then
                With .Data
                    .Edit
                    If iDone Then
                    ' set the timestamp
                        !WhenPrinted = Now
                    Else
                        !WhenPrinted = Null
                    End If
                    .Update
                End With
            End If
        End With
    End If
End Property