📄 frmcountpay.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form frmCountPay
Caption = "员工工资"
ClientHeight = 8490
ClientLeft = 60
ClientTop = 345
ClientWidth = 10800
LinkTopic = "Form1"
MDIChild = -1 'True
ScaleHeight = 8490
ScaleWidth = 10800
WindowState = 2 'Maximized
Begin VB.CommandButton Command3
Caption = "计算"
Height = 735
Left = 8400
TabIndex = 9
Top = 1320
Width = 1695
End
Begin MSAdodcLib.Adodc Adodc1
Height = 495
Left = 2760
Top = 7320
Visible = 0 'False
Width = 2775
_ExtentX = 4895
_ExtentY = 873
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=personnel"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "personnel"
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "info"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.CommandButton Command2
Caption = "退出"
Height = 735
Left = 8400
TabIndex = 11
Top = 4800
Width = 1695
End
Begin VB.CommandButton Command1
Caption = "保存"
Height = 735
Left = 8400
TabIndex = 10
Top = 3120
Width = 1695
End
Begin VB.Frame Frame4
Caption = "工资总计"
Height = 1575
Left = 960
TabIndex = 20
Top = 5280
Width = 6255
Begin VB.TextBox txtgzdate
DataField = "计发时间"
DataSource = "Adodc1"
Height = 390
Left = 4560
TabIndex = 8
Text = "YYYY-MM-DD"
Top = 840
Width = 1455
End
Begin VB.TextBox txtgzduty
DataField = "所得税"
DataSource = "Adodc1"
Height = 375
Left = 4560
TabIndex = 7
Text = "0.00"
Top = 240
Width = 1455
End
Begin VB.TextBox txtgzlaborage
DataField = "实发工资"
DataSource = "Adodc1"
Height = 375
Left = 1320
Locked = -1 'True
TabIndex = 26
Text = "0.00"
Top = 840
Width = 1455
End
Begin VB.TextBox txtgztotal
DataField = "税前小计"
DataSource = "Adodc1"
Height = 375
Left = 1320
Locked = -1 'True
TabIndex = 25
Text = "0.00"
Top = 240
Width = 1455
End
Begin VB.Label Label14
Caption = "计发时间:"
Height = 615
Left = 3480
TabIndex = 24
Top = 840
Width = 1095
End
Begin VB.Label Label13
Caption = "所得税:"
Height = 495
Left = 3480
TabIndex = 23
Top = 240
Width = 1335
End
Begin VB.Label Label12
Caption = "实发工资:"
Height = 495
Left = 120
TabIndex = 22
Top = 840
Width = 975
End
Begin VB.Label Label11
Caption = "税前小计:"
Height = 495
Left = 120
TabIndex = 21
Top = 240
Width = 1215
End
End
Begin VB.Frame Frame3
Caption = "代扣项目"
Height = 1335
Left = 960
TabIndex = 17
Top = 3600
Width = 6255
Begin VB.TextBox txtgzmedical
DataField = "医疗保险"
DataSource = "Adodc1"
Height = 375
Left = 4560
TabIndex = 6
Text = "0.00"
Top = 480
Width = 1455
End
Begin VB.TextBox txtgzhouse1
DataField = "住房公积金"
DataSource = "Adodc1"
Height = 375
Left = 1320
TabIndex = 5
Text = "0.00"
Top = 480
Width = 1455
End
Begin VB.Label Label10
Caption = "医疗保险:"
Height = 495
Left = 3480
TabIndex = 19
Top = 480
Width = 975
End
Begin VB.Label Label9
Caption = "住房公积金:"
Height = 615
Left = 120
TabIndex = 18
Top = 480
Width = 1095
End
End
Begin VB.Frame Frame2
Caption = "基本工资"
Height = 1575
Left = 960
TabIndex = 13
Top = 1680
Width = 6255
Begin VB.TextBox txtgzall
DataField = "工资小计"
DataSource = "Adodc1"
Height = 375
Left = 4560
Locked = -1 'True
TabIndex = 12
Text = "0.00"
Top = 240
Width = 1455
End
Begin VB.TextBox txtgzbonus
DataField = "奖金"
DataSource = "Adodc1"
Height = 375
Left = 1200
TabIndex = 4
Text = "0.00"
Top = 840
Width = 1455
End
Begin VB.TextBox txtgzbase
DataField = "底薪"
DataSource = "Adodc1"
Height = 375
Left = 1200
TabIndex = 3
Text = "0.00"
Top = 240
Width = 1455
End
Begin VB.Label Label6
Caption = "工资小计:"
Height = 495
Left = 3480
TabIndex = 16
Top = 240
Width = 975
End
Begin VB.Label Label4
Caption = "奖金:"
Height = 495
Left = 360
TabIndex = 15
Top = 840
Width = 855
End
Begin VB.Label Label3
Caption = "底薪:"
Height = 495
Left = 360
TabIndex = 14
Top = 240
Width = 1095
End
End
Begin VB.Frame Frame1
Caption = "员工信息"
Height = 975
Left = 960
TabIndex = 0
Top = 360
Width = 6255
Begin VB.OptionButton OptionName
Caption = "姓名:"
Height = 375
Left = 240
TabIndex = 28
Top = 360
Value = -1 'True
Width = 855
End
Begin VB.OptionButton OptionID
Caption = "编号:"
Height = 375
Left = 3360
TabIndex = 27
Top = 360
Width = 975
End
Begin VB.ComboBox ComboName
Height = 300
ItemData = "frmCountPay.frx":0000
Left = 1200
List = "frmCountPay.frx":0002
Style = 2 'Dropdown List
TabIndex = 1
Top = 360
Width = 1455
End
Begin VB.ComboBox ComboID
Height = 300
ItemData = "frmCountPay.frx":0004
Left = 4440
List = "frmCountPay.frx":0006
Style = 2 'Dropdown List
TabIndex = 2
Top = 360
Width = 1575
End
End
End
Attribute VB_Name = "frmCountPay"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'为组合框添加员工姓名列表
Private Sub addNameList()
Adodc1.Recordset.MoveFirst
While (Not Adodc1.Recordset.EOF)
ComboName.AddItem Adodc1.Recordset("姓名")
Adodc1.Recordset.MoveNext
Wend
End Sub
'为组合框添加编号列表
Private Sub addIDList()
Adodc1.Recordset.MoveFirst
While (Not Adodc1.Recordset.EOF)
ComboID.AddItem Adodc1.Recordset("编号")
Adodc1.Recordset.MoveNext
Wend
End Sub
'确定相应的员工姓名
Private Sub fixName()
Dim ID As Integer
ID = ComboID.Text
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "编号=" & ID
ComboName.Text = Adodc1.Recordset("姓名")
End Sub
'确定相应的员工编号
Private Sub fixID()
Dim name As String
name = ComboName.Text
name = "'" & name & "'"
Adodc1.Recordset.MoveFirst
Adodc1.Recordset.Find "姓名=" & name
ComboID.Text = Adodc1.Recordset("编号")
End Sub
'编号组合框信息改变
Private Sub ComboID_Click()
If OptionID.Value Then
fixName
End If
End Sub
'姓名组合框信息改变
Private Sub ComboName_Click()
If OptionName.Value Then
fixID
End If
End Sub
'判断工资数据是否有效
Private Function check(num As String) As Boolean
If IsNumeric(num) Then
If (num <= 100000#) And (num >= 0#) Then
check = True
Else
check = False
End If
Else
check = False
End If
End Function
'判断日期输入是否有效
Private Function checkDate(dat As String) As Boolean
If IsDate(dat) Then
checkDate = True
Else
checkDate = False
End If
End Function
Private Sub Command3_Click()
'定义变量
Dim all As Double
Dim base As Double
Dim bonus As Double
Dim house As Double
Dim medical As Double
Dim total As Double
Dim laborage As Double
Dim burden As Double
Dim duty As Double
Dim txtlaborage As String
Dim txtall As String
Dim txttotal As String
Dim txtbase As String
Dim txtbonus As String
Dim txthouse As String
Dim txtduty As String
Dim txtmedical As String
If (check(txtgzbase.Text)) And (check(txtgzbonus.Text)) And (check(txtgzduty.Text)) And (check(txtgzhouse1.Text)) And (check(txtgzmedical.Text)) Then
'读入文本框字符
txtbase = txtgzbase.Text
txtbonus = txtgzbonus.Text
txthouse = txtgzhouse1.Text
txtduty = txtgzduty.Text
txtmedical = txtgzmedical.Text
'将字符型转换为浮点型
base = txtbase
bonus = txtbonus
house = txthouse
duty = txtduty
medical = txtmedical
'计算工资
all = base + bonus
burden = house + medical
total = all - burden
laborage = total - duty
'将浮点型转换为字符型
txtlaborage = laborage
txtall = all
txttotal = total
'在文本框显示工资数据
txtgzlaborage.Text = txtlaborage
txtgzall.Text = txtall
txtgztotal.Text = txttotal
Else
MsgBox "工资数据必须为0.00~100000.00的数字,请重新输入!", vbOKOnly + vbExclamation, "提示信息"
End If
End Sub
'初始化该窗体,设置控件标题
Private Sub Form_Load()
addIDList
addNameList
txtgzdate.Text = "YYYY-MM-DD"
txtgzbase.Text = "0.00"
txtgzall.Text = "0.00"
txtgzbonus.Text = "0.00"
txtgzduty.Text = "0.00"
txtgzhouse1.Text = "0.00"
txtgzlaborage.Text = "0.00"
txtgzmedical.Text = "0.00"
txtgztotal.Text = "0.00"
End Sub
Private Sub Command1_Click()
If (ComboName.Text = "") And (ComboID.Text = "") Then
MsgBox "请选择一个员工!", vbOKOnly + vbExclamation, "提示信息"
Else
'判断所有工资数据输入是否均有效
If (check(txtgzbase.Text)) And (check(txtgzbonus.Text)) And (check(txtgzduty.Text)) And (check(txtgzhouse1.Text)) And (check(txtgzmedical.Text)) Then
If (checkDate(txtgzdate.Text)) Then
Adodc1.Recordset.UpdateBatch
MsgBox "保存工资信息成功!", vbOKOnly + vbInformation, "提示信息"
Else
MsgBox "请按“YYYY-MM-DD”格式输入有效日期!", vbOKOnly + vbExclamation, "提示信息"
End If
Else
MsgBox "工资数据必须为0.00~100000.00的数字,请重新输入!", vbOKOnly + vbExclamation, "提示信息"
End If
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -