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

📄 frmdelivery_main.frm

📁 英文版Access数据库编程
💻 FRM
📖 第 1 页 / 共 4 页
字号:
    cmdSave.Visible = False
    cmdCancel.Visible = False
End If
End Sub

Public Sub prePrintDO(ByVal strDO As String)
'Delivery order is designed based on requirement
'Uncommented codes when printing on non-preprinted papers.
Dim printRS As Recordset, tmpX As Long, tmpY As Long, grandtotal As Single
cdlg.DialogTitle = "Print Delivery Order"
cdlg.CancelError = True
On Error Resume Next
cdlg.ShowPrinter
If Err Then
    Exit Sub
Else
    RSOpen printRS, "SELECT Delivery.DOnumber, Delivery.Date, Delivery.IssuedBy, Delivery.EmployeeID, Delivery.PONumber, Delivery.Remark, Delivery.Attn, Delivery.Description, Delivery.Charges, Delivery.DelTime, Delivery.DelDate, Customers.Name, Customers.Address, Customers.City, Customers.State, Customers.Zip, Customers.Country, Customers.CreditTerm " & _
    "FROM Customers INNER JOIN Delivery ON Customers.CustomerID = Delivery.CustomerID WHERE Delivery.DOnumber='" & strDO & "';", dbOpenSnapshot
    If Not printRS.EOF Then
        With Printer
            .PaperSize = 9 'A4 size
            .FontSize = CLng(GetFromINI("PrintDO", "FontSize", "", pathFileSettings))
            'Begin printing receiver details
            grandtotal = 0
            tmpX = CLng(GetFromINI("PrintDO", "CustMargin", "", pathFileSettings))
            .CurrentX = tmpX
            .CurrentY = CLng(GetFromINI("PrintDO", "CustY", "", pathFileSettings))
            Printer.Print printRS("Name")
            .CurrentX = tmpX
            Printer.Print printRS("Address")
            .CurrentX = tmpX
            Printer.Print printRS("Zip") & " " & printRS("City")
            .CurrentX = tmpX
            Printer.Print printRS("State") & ", " & printRS("Country")
            'Print delivery order details
            tmpX = CLng(GetFromINI("PrintDO", "OrderMargin", "", pathFileSettings))
            .CurrentX = tmpX
            .CurrentY = CLng(GetFromINI("PrintDO", "OrderY", "", pathFileSettings))
            Printer.Print printRS("DOnumber")
            .CurrentX = tmpX
            Printer.Print printRS("Date")
            .CurrentX = tmpX
            Printer.Print printRS("PONumber")
            .CurrentX = tmpX
            Printer.Print printRS("Attn")
            .CurrentX = tmpX
            Printer.Print printRS("CustomerID")
            .CurrentX = tmpX
            Printer.Print printRS("CreditTerm") & " days"
            .CurrentX = tmpX
            Printer.Print .Page
            Dim cnt As Byte, strPrint As String
            RSOpen printRS, "SELECT * FROM D_Details WHERE DOnumber='" & strDO & "';", dbOpenSnapshot
            cnt = 1
            .CurrentY = CLng(GetFromINI("PrintDO", "DetailY", "", pathFileSettings))
            While Not printRS.EOF
                'Loop through the items and print every detail
                tmpX = CLng(GetFromINI("PrintDO", "CntMargin", "", pathFileSettings))
                .CurrentX = tmpX
                tmpY = .CurrentY
                Printer.Print CStr(cnt)
                tmpX = CLng(GetFromINI("PrintDO", "DescMargin", "", pathFileSettings))
                strPrint = printRS("Description")
                .CurrentX = tmpX
                .CurrentY = tmpY
                Printer.Print strPrint
                tmpX = CLng(GetFromINI("PrintDO", "QtyMargin", "", pathFileSettings))
                strPrint = printRS("Quantity")
                .CurrentX = tmpX - (25 + .TextWidth(strPrint))
                .CurrentY = tmpY
                Printer.Print strPrint
                strPrint = printRS("UnitLabel")
                .CurrentX = tmpX + 25
                .CurrentY = tmpY
                Printer.Print strPrint
                strPrint = Format$(printRS("SalePrice"), "#,##0.00")
                .CurrentX = CLng(GetFromINI("PrintDO", "SaleMargin", "", pathFileSettings)) - .TextWidth(strPrint)
                .CurrentY = tmpY
                Printer.Print strPrint
                strPrint = Format$(CSng(printRS("SalePrice")) * CInt(printRS("Quantity")), "#,##0.00")
                grandtotal = grandtotal + CSng(strPrint)
                .CurrentX = CLng(GetFromINI("PrintDO", "SubMargin", "", pathFileSettings)) - .TextWidth(strPrint)
                .CurrentY = tmpY
                Printer.Print strPrint
                Printer.Print
                printRS.MoveNext
                cnt = cnt + 1
            Wend
            'Print charges and total
            tmpY = .ScaleHeight - CLng(GetFromINI("PrintDO", "TermsY", "", pathFileSettings))
            
            If printRS("Charges") > 0 Then
                tmpX = CLng(GetFromINI("PrintDO", "DescMargin", "", pathFileSettings))
                .CurrentY = tmpY
                .CurrentX = CLng(GetFromINI("PrintDO", "DescMargin", "", pathFileSettings))
                Printer.Print printRS("Description")
                .CurrentY = tmpY
                .CurrentX = CLng(GetFromINI("PrintDO", "SubMargin", "", pathFileSettings))
                grandtotal = grandtotal + CSng(printRS("charges"))
                Printer.Print Format$(printRS("Charges"), "#,##0.00")
                tmpY = .CurrentY
            End If
            'Prints the total line
            .CurrentY = tmpY
            .CurrentX = CLng(GetFromINI("PrintDO", "DescMargin", "", pathFileSettings))
            Printer.Print "Grand Total:"
            strPrint = Format$(grandtotal, "#,##0.00")
            .CurrentY = tmpY
            .CurrentX = CLng(GetFromINI("PrintDO", "SubMargin", "", pathFileSettings)) - .TextWidth(strPrint)
            Printer.Print strPrint
            Printer.Print
            Printer.Print
            'Prints the total in string
            tmpX = CLng(GetFromINI("PrintDO", "DescMargin", "", pathFileSettings))
            .CurrentX = tmpX
            Printer.Print "RINGGIT MALAYSIA " & UCase(NumToString(CCur(grandtotal))) & " ONLY"
            .EndDoc
            InfoMsg "The delivery order has been successfully sent to the printer for printing.", "Document ready"
        End With
    Else
        ValidMsg "An error occured while the system tried to load the delivery order. Please try again.", "Error occured"
    End If
End If
End Sub

Public Sub printDO(ByVal strDO As String)
'Delivery order is designed based on requirement
'Uncommented codes when printing on non-preprinted papers.
Dim printRS As Recordset, tmpX As Long, tmpY As Long, grandtotal As Single
cdlg.DialogTitle = "Print Delivery Order"
cdlg.CancelError = True
On Error Resume Next
cdlg.ShowPrinter
If Err Then
    Exit Sub
Else
    RSOpen printRS, "SELECT Delivery.DOnumber, Delivery.Date, Delivery.IssuedBy, Delivery.EmployeeID, Delivery.PONumber, Delivery.Remark, Delivery.Attn, Delivery.Description, Delivery.Charges, Delivery.DelTime, Delivery.DelDate, Customers.Name, Customers.Address, Customers.City, Customers.State, Customers.Zip, Customers.Country, Customers.CreditTerm " & _
    "FROM Customers INNER JOIN Delivery ON Customers.CustomerID = Delivery.CustomerID WHERE Delivery.DOnumber='" & strDO & "';", dbOpenSnapshot
    If Not printRS.EOF Then
        With Printer
            .PaperSize = 9 'A4 size
            .FontSize = CLng(GetFromINI("PrintDO", "FontSize", "", pathFileSettings))
            'Begin printing receiver details
            grandtotal = 0
            tmpX = CLng(GetFromINI("PrintDO", "CustMargin", "", pathFileSettings))
            tmpY = CLng(GetFromINI("PrintDO", "CustY", "", pathFileSettings))
            .CurrentX = tmpX
            .CurrentY = tmpY
            Printer.Print "Delivery To:"
            .CurrentX = tmpX
            Printer.Print printRS("Name")
            .CurrentX = tmpX
            Printer.Print printRS("Address")
            .CurrentX = tmpX
            Printer.Print printRS("Zip") & " " & printRS("City")
            .CurrentX = tmpX
            Printer.Print printRS("State") & ", " & printRS("Country")
            'Print delivery order details
            Dim strLen As Single
            tmpX = CLng(GetFromINI("PrintDO", "OrderMargin", "", pathFileSettings))
            strLen = .TextWidth("PO Number: ")
            tmpX = tmpX - strLen
            .CurrentX = tmpX
            .CurrentY = tmpY
            Printer.Print "DO Number:"
            .CurrentX = tmpX
            Printer.Print "Date:"
            .CurrentX = tmpX
            Printer.Print "PO Number:"
            .CurrentX = tmpX
            Printer.Print "Reference:"
            .CurrentX = tmpX
            Printer.Print "A/C No:"
            .CurrentX = tmpX
            Printer.Print "Terms"
            .CurrentX = tmpX
            Printer.Print "Page No:"
            tmpX = tmpX + strLen
            .CurrentX = tmpX
            .CurrentY = tmpY
            Printer.Print printRS("DOnumber")
            .CurrentX = tmpX
            Printer.Print printRS("Date")
            .CurrentX = tmpX
            Printer.Print printRS("PONumber")
            .CurrentX = tmpX
            Printer.Print printRS("Attn")
            .CurrentX = tmpX
            Printer.Print printRS("CustomerID")
             .CurrentX = tmpX
            Printer.Print printRS("CreditTerm") & " days"
            .CurrentX = tmpX
            Printer.Print .Page
           
            Dim cnt As Byte, strPrint As String
            RSOpen printRS, "SELECT * FROM D_Details WHERE DOnumber='" & strDO & "';", dbOpenSnapshot
            cnt = 1
            .CurrentY = CLng(GetFromINI("PrintDO", "DetailY", "", pathFileSettings))
            While Not printRS.EOF
                'Loop through the items and print every detail
                tmpX = CLng(GetFromINI("PrintDO", "CntMargin", "", pathFileSettings))
                .CurrentX = tmpX
                tmpY = .CurrentY
                Printer.Print CStr(cnt)
                tmpX = CLng(GetFromINI("PrintDO", "DescMargin", "", pathFileSettings))
                strPrint = printRS("Description")
                .CurrentX = tmpX
                .CurrentY = tmpY
                Printer.Print strPrint
                tmpX = CLng(GetFromINI("PrintDO", "QtyMargin", "", pathFileSettings))
                strPrint = printRS("Quantity")
                .CurrentX = tmpX - (25 + .TextWidth(strPrint))
                .CurrentY = tmpY
                Printer.Print strPrint
                strPrint = printRS("UnitLabel")
                .CurrentX = tmpX + 25
                .CurrentY = tmpY
                Printer.Print strPrint
                strPrint = Format$(printRS("SalePrice"), "#,##0.00")
                .CurrentX = CLng(GetFromINI("PrintDO", "SaleMargin", "", pathFileSettings)) - .TextWidth(strPrint)
                .CurrentY = tmpY
                Printer.Print strPrint
                strPrint = Format$(CSng(printRS("SalePrice")) * CInt(printRS("Quantity")), "#,##0.00")
                grandtotal = grandtotal + CSng(strPrint)
                .CurrentX = CLng(GetFromINI("PrintDO", "SubMargin", "", pathFileSettings)) - .TextWidth(strPrint)
                .CurrentY = tmpY
                Printer.Print strPrint
                Printer.Print
                printRS.MoveNext
                cnt = cnt + 1
            Wend
            'Print charges and total
            tmpY = .ScaleHeight - CLng(GetFromINI("PrintDO", "TermsY", "", pathFileSettings))
            
            If printRS("Charges") > 0 Then
                tmpX = CLng(GetFromINI("PrintDO", "DescMargin", "", pathFileSettings))
                .CurrentY = tmpY
                .CurrentX = CLng(GetFromINI("PrintDO", "DescMargin", "", pathFileSettings))
                Printer.Print printRS("Description")
                strPrint = Format$(printRS("Charges"), "#,##0.00")
                .CurrentY = tmpY
                .CurrentX = CLng(GetFromINI("PrintDO", "SubMargin", "", pathFileSettings)) - .TextWidth(strPrint)
                grandtotal = grandtotal + CSng(printRS("charges"))
                Printer.Print strPrint
                tmpY = .CurrentY
            End If
            'Prints the total line
            .CurrentY = tmpY
            .CurrentX = CLng(GetFromINI("PrintDO", "DescMargin", "", pathFileSettings))
            Printer.Print "Grand Total:"
            strPrint = Format$(grandtotal, "#,##0.00")
            .CurrentY = tmpY
            .CurrentX = CLng(GetFromINI("PrintDO", "SubMargin", "", pathFileSettings)) - .TextWidth(strPrint)
            Printer.Print strPrint
            'Prints the total in string
            tmpX = CLng(GetFromINI("PrintDO", "DescMargin", "", pathFileSettings))
            .CurrentX = tmpX
            Printer.Print "RINGGIT MALAYSIA " & UCase(NumToString(CCur(grandtotal))) & " ONLY"
            'Signature and terms & conditions
            strPrint = "Terms and conditions: "
            tmpY = .ScaleHeight - CLng(GetFromINI("PrintDO", "TermsY", "", pathFileSettings))
            tmpX = CLng(GetFromINI("PrintDO", "TermsMargin", "", pathFileSettings))
            .CurrentX = tmpX
            .CurrentY = tmpY
            Printer.Print strPrint
            strPrint = "Issued By:"
            .CurrentX = CLng(GetFromINI("PrintDO", "SignMargin", "", pathFileSettings))
            tmpY = .ScaleHeight - CLng(GetFromINI("PrintDO", "SignY", "", pathFileSettings))
            .CurrentY = tmpY
            Printer.Print strPrint
            Printer.Line (tmpX + .TextWidth(strPrint) + 50, .CurrentY)-Step(3500, 0)
            strPrint = "Received By:"
            tmpX = .ScaleWidth / 2
            .CurrentX = tmpX
            .CurrentY = tmpY
            Printer.Print strPrint
            Printer.Line (tmpX + .TextWidth(strPrint) + 50, .CurrentY)-Step(3500, 0)
            .EndDoc
            InfoMsg "The delivery order has been successfully sent to the printer for printing.", "Document ready"
        End With
    Else
        ValidMsg "An error occured while the system tried to load the delivery order. Please try again.", "Error occured"
    End If
End If
End Sub

Private Sub charges_GotFocus()
SelText charges
End Sub

Private Sub charges_KeyPress(KeyAscii As Integer)
If KeyAscii <> Asc(".") Then
    OnlyNum KeyAscii
End If
End Sub

Private Sub charges_LostFocus()
If charges.Text = "" Then
    charges.Text = "0"
End If
charges.Text = Format$(charges.Text, "#,##0.00")
End Sub

Private Sub cmdCancel_Click()
Dim k As Integer
doNum.Text = doNum.Tag
For k = 0 To 2
    cmbDate(k).Text = cmbDate(k).Tag
    cmbDelDate(k).Text = cmbDelDate(k).Tag
    If k < 2 Then
        cmbDelTime(k).Text = cmbDelTime(k).Tag
    End If
Next k
employee(0).Text = lblEnd.Caption
employee(1).Text = lblDel.Caption

notes.Text = notes.Tag
charges.Text = charges.Tag

⌨️ 快捷键说明

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