📄 frmpayroll_print.frm
字号:
Set payRS = Nothing
End Sub
Private Sub OnlySelected_Click()
Frame1.Enabled = True
End Sub
Private Sub getPrintPayroll(ByVal strParamSQL As String)
'Payroll is designed according to the requirement
Dim net_sal As Single, gross_sal As Single, strText As String
Dim tmpX As Long, tmpY As Long
Dim width As Long, height As Long, coordY As Long, coordX As Long
'On Error GoTo ErrHandler
'Debug.Print strParamSQL
With Printer
' .Orientation = vbPRORLandscape
Dim printRS As Recordset
'.Orientation = vbPRORLandscape
.FontSize = CByte(GetFromINI("PrintDO", "FontSize", "", pathFileSettings))
.PaperSize = 11
'Add a document to the application
RSOpen printRS, strParamSQL, dbOpenSnapshot
While Not printRS.EOF
net_sal = 0
displayMsg "Preparing document for printing."
displayMsg "Writing data to the document"
'Company and payroll details
strText = getSettings("compName")
.CurrentX = .ScaleWidth / 2 - .TextWidth(strText) / 2
Printer.Print strText
Printer.Print
strText = "Employee Payroll Slip"
.CurrentX = .ScaleWidth / 2 - .TextWidth(strText) / 2
Printer.Print strText
Printer.Print
strText = "Month: " & MonthName(datepk.Month, False) & " " & CStr(datepk.Year)
.CurrentX = .ScaleWidth / 2 - .TextWidth(strText) / 2
Printer.Print strText
Printer.Print
'Headings on the left hand side include employee details, performance, etc.
tmpX = CLng(GetFromINI("PrtPayroll", "HeaderLeft", "", pathFileSettings))
tmpY = .CurrentY
strText = "Name: "
.CurrentX = tmpX
Printer.Print strText
strText = "IC No: "
.CurrentX = tmpX
Printer.Print strText
strText = "Position: "
.CurrentX = tmpX
Printer.Print strText
'Format$(printRS("payrollID"), "000000")
strText = "Total working days: "
.CurrentX = tmpX
Printer.Print strText
'printRS ("EmployeeID")
'Monthly performance details
strText = "Total attendants: "
.CurrentX = tmpX
Printer.Print strText
'printRS ("otHours")
strText = "Paid/annual leaves: "
.CurrentX = tmpX
Printer.Print strText
strText = "Sick leaves: "
.CurrentX = tmpX
Printer.Print strText
strText = "Others: "
.CurrentX = tmpX
Printer.Print strText
'Print details for the left hand side
.CurrentY = tmpY
tmpX = .ScaleWidth / 2 - 100
strText = printRS("Name")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
tmpX = .ScaleWidth / 2 - 100
strText = printRS("IC")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
tmpX = .ScaleWidth / 2 - 100
strText = printRS("PositionID")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
tmpX = .ScaleWidth / 2 - 100
strText = printRS("workingDays")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
tmpX = .ScaleWidth / 2 - 100
strText = printRS("dayWorked")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
tmpX = .ScaleWidth / 2 - 100
strText = printRS("annualLeaves")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
tmpX = .ScaleWidth / 2 - 100
strText = printRS("sickLeaves")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
tmpX = .ScaleWidth / 2 - 100
strText = printRS("otherLeaves")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
'headings on the right hand side
.CurrentY = tmpY
.CurrentX = .ScaleWidth / 2
tmpX = .CurrentX
strText = "Gross Salary: "
Printer.Print strText
.CurrentX = tmpX
strText = "Less: unpaid leaves"
Printer.Print strText
.CurrentX = tmpX
strText = "Salary: "
Printer.Print strText
.CurrentX = tmpX
strText = "Less: EPF"
Printer.Print strText
.CurrentX = tmpX + .TextWidth("Less: ")
strText = "SOCSO"
Printer.Print strText
.CurrentX = tmpX + .TextWidth("Less: ")
strText = "Income Tax"
Printer.Print strText
.CurrentX = tmpX + .TextWidth("Less: ")
strText = "Salary Advanced"
Printer.Print strText
.CurrentX = tmpX
strText = "Balance: "
Printer.Print strText
.CurrentX = tmpX
strText = "Add: Incentive"
Printer.Print strText
.CurrentX = tmpX
strText = "Net Salary: "
Printer.Print strText
'Deductions
tmpX = .ScaleWidth / 2 + .ScaleWidth / 4 + 1000
.CurrentY = tmpY
strText = Format$(printRS("initialSalary"), "#,##0.00")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
gross_sal = (printRS("unpaidLeaves") * printRS("initialSalary") / printRS("workingDays"))
strText = Format$(gross_sal, "#,##0.00")
gross_sal = printRS("initialSalary") - gross_sal
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
strText = Format$(printRS("initialSalary"), "#,##0.00")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
strText = Format$(printRS("epfEmployee"), "#,##0.00")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
strText = Format$(printRS("socsoAmount"), "#,##0.00")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
strText = Format$(printRS("incomeTax"), "#,##0.00")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
strText = Format$(printRS("salaryAdvance"), "#,##0.00")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
gross_sal = gross_sal - (printRS("epfEmployee") + printRS("socsoAmount") + printRS("incomeTax") + printRS("salaryAdvance"))
strText = Format$(gross_sal, "#,##0.00")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
strText = Format$(printRS("otAmount"), "#,##0.00")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
net_sal = gross_sal + printRS("otAmount")
strText = Format$(net_sal, "#,##0.00")
.CurrentX = tmpX - .TextWidth(strText)
Printer.Print strText
'Signature
tmpX = CLng(GetFromINI("PrtPayroll", "HeaderLeft", "", pathFileSettings))
tmpY = CLng(GetFromINI("PrtPayroll", "PaymentLeft", "", pathFileSettings))
.CurrentX = tmpX
.CurrentY = tmpY
strText = "Payment method: " & printRS("paymentMethod")
Printer.Print strText
.CurrentX = tmpX
tmpY = CLng(GetFromINI("PrtPayroll", "SignY", "", pathFileSettings))
.CurrentY = tmpY
strText = "Issued by:"
Printer.Print strText
.CurrentX = .ScaleWidth / 2
.CurrentY = tmpY
strText = "Received by:"
Printer.Print strText
'Draw the box
width = CLng(GetFromINI("PrtPayroll", "BoxW", "", pathFileSettings))
height = CLng(GetFromINI("PrtPayroll", "BoxH", "", pathFileSettings))
coordX = CLng(GetFromINI("PrtPayroll", "BoxX", "", pathFileSettings))
coordY = CLng(GetFromINI("PrtPayroll", "BoxY", "", pathFileSettings))
Printer.Line (coordX, coordY)-(width, height), vbBlack, B
Printer.Line ((.ScaleWidth / 2) - 25, 1050)-((.ScaleWidth / 2) - 25, height), vbBlack
.EndDoc
printRS.MoveNext
displayMsg "Document saved and ready for printing"
Wend
printRS.Close
Set printRS = Nothing
End With
ErrHandler:
If Err.Number <> 0 Then
CriticalMsg "Unable to print the payroll due to a critical error. Please close the application and try again.", "Error"
Exit Sub
End If
End Sub
Private Sub displayMsg(ByVal strMsg As String)
stBar2.Panels(stBar2.Panels.Count).Text = strMsg & "..."
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -