📄 frmpayroll_print.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Object = "{86CF1D34-0C5F-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCT2.OCX"
Begin VB.Form frmPayroll_Print
BorderStyle = 1 'Fixed Single
Caption = "Print Payroll"
ClientHeight = 4545
ClientLeft = 45
ClientTop = 435
ClientWidth = 4680
ControlBox = 0 'False
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4545
ScaleWidth = 4680
StartUpPosition = 3 'Windows Default
Begin MSComDlg.CommonDialog cDlg
Left = 3360
Top = 1080
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin MSComctlLib.StatusBar stBar2
Align = 2 'Align Bottom
Height = 255
Left = 0
TabIndex = 8
Top = 4290
Width = 4680
_ExtentX = 8255
_ExtentY = 450
_Version = 393216
BeginProperty Panels {8E3867A5-8586-11D1-B16A-00C0F0283628}
NumPanels = 1
BeginProperty Panel1 {8E3867AB-8586-11D1-B16A-00C0F0283628}
EndProperty
EndProperty
End
Begin MSComCtl2.DTPicker datepk
Height = 255
Left = 720
TabIndex = 0
Top = 120
Width = 2175
_ExtentX = 3836
_ExtentY = 450
_Version = 393216
CustomFormat = "MM, yyyy"
Format = 50987011
CurrentDate = 38157
End
Begin VB.Frame Frame1
Caption = "Payrolls for the month:"
Enabled = 0 'False
Height = 2775
Left = 120
TabIndex = 3
Top = 1320
Width = 4455
Begin MSComctlLib.ListView lvEmp
Height = 2415
Left = 120
TabIndex = 4
Top = 240
Width = 4215
_ExtentX = 7435
_ExtentY = 4260
LabelEdit = 1
LabelWrap = -1 'True
HideSelection = -1 'True
FullRowSelect = -1 'True
_Version = 393217
ForeColor = -2147483640
BackColor = -2147483643
Appearance = 1
NumItems = 0
End
End
Begin VB.OptionButton OnlySelected
Caption = "Print only selected employees."
Height = 255
Left = 360
TabIndex = 2
Top = 960
Width = 2775
End
Begin VB.OptionButton AllPayroll
Caption = "Print payroll for all employees."
Height = 255
Left = 360
TabIndex = 1
Top = 600
Width = 2775
End
Begin VB.CommandButton cmdClose
Caption = "&Close"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3480
TabIndex = 6
Top = 600
Width = 1095
End
Begin VB.CommandButton cmdPrint
Caption = "&Print"
BeginProperty Font
Name = "Tahoma"
Size = 8.25
Charset = 0
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 3480
TabIndex = 5
Top = 120
Width = 1095
End
Begin VB.Label Label1
Caption = "Month:"
Height = 255
Left = 120
TabIndex = 7
Top = 120
Width = 615
End
End
Attribute VB_Name = "frmPayroll_Print"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Private Sub AllPayroll_Click()
Frame1.Enabled = False
End Sub
Private Sub cmdClose_Click()
Unload Me
End Sub
Private Sub cmdPrint_Click()
If lvEmp.ListItems.Count = 0 Then
ValidMsg "No records available to print. Please try selecting another month.", "No records available"
ElseIf (OnlySelected.Value = True) And (lvEmp.SelectedItem.Selected = False) Then
ValidMsg "Please select at least a employee payroll record to be printed.", "No record selected"
Else
'begin print
With cDlg
On Error Resume Next
.CancelError = True
.ShowPrinter
If Err Then
Exit Sub
Else
If AllPayroll.Value = True Then
getPrintPayroll "SELECT Payroll.*, Employees.Name, Employees.PositionID, Employees.IC " & _
"FROM Employees INNER JOIN Payroll ON Employees.EmployeeID = Payroll.EmployeeID;"
Else
Dim i As Integer
For i = 1 To lvEmp.ListItems.Count
If lvEmp.ListItems(i).Selected Then
getPrintPayroll "SELECT Payroll.*, Employees.Name, Employees.PositionID, Employees.IC " & _
"FROM Employees INNER JOIN Payroll ON Employees.EmployeeID = Payroll.EmployeeID WHERE Payroll.payrollID=" & lvEmp.ListItems(i).Tag & ";"
End If
Next i
End If
End If
End With
End If
End Sub
Private Sub datepk_Click()
getPayroll Format$(Month(datepk.Value), "00"), Format$(Year(datepk.Value), "0000")
End Sub
Private Sub Form_Load()
With lvEmp
.View = lvwReport
.MultiSelect = True
.ColumnHeaders.add , , "ID", 0
.ColumnHeaders.add , , "Name", 4000
End With
AllPayroll.Value = True
stBar2.Panels(stBar2.Panels.Count).width = stBar2.width
Call datepk_Click
End Sub
Private Sub getPayroll(ByVal strMonth As String, strYear As String)
Dim payRS As Recordset
lvEmp.ListItems.Clear
RSOpen payRS, "SELECT Payroll.payrollID, Employees.EmployeeID, Employees.Name, Payroll.dateIssued " & _
"FROM Employees INNER JOIN Payroll ON Employees.EmployeeID = Payroll.EmployeeID WHERE Payroll.dateIssued LIKE '##/" & strMonth & "/" & strYear & "';", dbOpenSnapshot
While Not payRS.EOF
lvEmp.ListItems.add , , payRS("EmployeeID")
lvEmp.ListItems(lvEmp.ListItems.Count).Tag = payRS("payrollID")
lvEmp.ListItems(lvEmp.ListItems.Count).SubItems(1) = payRS("Name")
payRS.MoveNext
Wend
payRS.Close
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -