📄 gongzixinxi.frm
字号:
rs.Close
End If
End Sub
Private Sub Command1_Click() '在时间上有问题
Dim a As String
Dim b As String
Set db = OpenDatabase(App.Path & "\考勤信息")
Set rs = db.OpenRecordset("考勤信息")
a = "select 加班费,扣考核 from 考勤信息 where 编码='" & Text15.Text & "'" & " and 考勤年月 >= '" & Format(DateSerial(Year(Now), Month(Now), 1), "yyyy/mm/dd") & "' and 考勤年月<='" & Format(Now, "yyyy/mm/dd") & "'"
If rs.EOF = True And rs.BOF = True Then
MsgBox "请先对员工进行考勤!"
Exit Sub
Else
Text(4) = rs.Fields(7)
Text(3) = rs.Fields(6)
rs.Close
End If
Set db = OpenDatabase(App.Path & "\员工基本信息")
Set rs = db.OpenRecordset("员工基本信息")
Set rs = db.OpenRecordset("select 编号 from 员工基本信息 where 部门='" & Trim(Combo1(0)) & "' and 姓名='" & Trim(Combo1(1)) & "'")
If rs.EOF = True Then
MsgBox "编号不正确!"
Exit Sub
Else
c = rs.Fields(0)
rs.Close
End If
Set db = OpenDatabase(App.Path & "\工资信息")
Set rs = db.OpenRecordset("工资信息")
Set rs = db.OpenRecordset("select * from 工资信息 where 部门='" & Trim(Combo1(0)) & "' and 姓名='" & Trim(Combo1(1)) & "'")
If Combo1(0).Text = "" Then
MsgBox "请选择部门"
Exit Sub
End If
If Combo1(1).Text = "" Then
MsgBox "请选择姓名!"
Exit Sub
End If
If Text15.Text = "" Then
MsgBox "请输入编号!"
Exit Sub
ElseIf Text15 <> c Then
MsgBox "编号不正确!"
Exit Sub
Text15 = c
End If
If Text(0).Text = "" Then
MsgBox "底薪不能为空!"
Text(0).SetFocus
Exit Sub
End If
If Text(13).Text <> "" Then
If Not IsDate(Text(13)) Then
MsgBox "时间输入格式不正确!,应输入如下格式(YYYY-MM-DD)!"
Text(13).SetFocus
Exit Sub
Else
Text(13) = Format(Text(13), "yyyy-mm-dd")
End If
Else
MsgBox "时间不能为空!"
Text(13).SetFocus
Exit Sub
End If
'添加判断是否有相同的ID记录
a = "select * from 工资信息 where 编号='" & Text15 & "' and 计发时间 between'" '?????参考书(时间不合格,完成不了记录是否为本月已经记录了信息,而总是说已经记录了本月信息,分辨不了月份
a = a & Format(Year(Format(Text(13), "yyyy-mm-dd")) & "-" & Month(Format(Text(13), "yyyy-mm-dd")) & "-01", "yyyy-mm-dd") & "'"
a = a & " and '" & Format(DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(Year(Format(Text(13), "yyyy-mm-dd"))), CInt(Month(Format(Text(13), "yyyy-mm-dd"))), 1))), "yyyy-mm-dd") & "'"
' returnDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-" & cboDay), "yyyy-mm-dd")
If rs.EOF = False Then
MsgBox "已经存在该员工该月的工资记录!"
Text(13).SetFocus
Exit Sub
End If
rs.AddNew
rs.Fields(16) = Trim(Text15)
rs.Fields(0) = Combo1(1)
rs.Fields(1) = Combo1(0)
rs.Fields(2) = Trim(Text(0))
rs.Fields(3) = Trim(Text(2))
rs.Fields(4) = Trim(Text(4))
rs.Fields(5) = Trim(Text(11))
rs.Fields(6) = Trim(Text(1))
rs.Fields(7) = Trim(Text(3))
rs.Fields(8) = Trim(Text(10))
rs.Fields(9) = Trim(Text(5))
rs.Fields(10) = Trim(Text(7))
rs.Fields(11) = Trim(Text(6))
rs.Fields(12) = Trim(Text(8))
rs.Fields(13) = Trim(Text(9))
rs.Fields(14) = Trim(Text(12))
rs.Fields(15) = Trim(Text(13))
rs.Update
rs.Close
MsgBox "添加成功!"
Combo1(0) = ""
Combo1(1) = ""
Text(1) = ""
Text(2) = ""
Text(3) = ""
Text(4) = ""
Text(5) = ""
Text(6) = ""
Text(7) = ""
Text(8) = ""
Text(9) = ""
Text(10) = ""
Text(11) = ""
Text(12) = ""
Text(13) = ""
Text(0) = ""
Text15 = ""
End Sub
Private Sub Command2_Click() 'OK
gongzixinxi.Hide
jiudianneibuziliaocaidan.Show
End Sub
Private Sub Command3_Click() 'OK
Dim db As Database
Dim rs As Recordset
Dim a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, X, Y, z As String * 50
On Error Resume Next
Set db = OpenDatabase(App.Path & "\工资信息")
Set rs = db.OpenRecordset("工资信息")
If Text15.Text = "" Then
MsgBox "请输入要修改的员工编号!"
Exit Sub
End If
If Combo1(1).Text = "" Then
MsgBox "请输入要修改的员工姓名"
Exit Sub
End If
Set rs = db.OpenRecordset("select 编号,姓名 from 工资信息 where 编号='" & Text15.Text & "' and 姓名='" & Combo1(1).Text & "'")
If rs.EOF = True And rs.BOF = True Then
MsgBox "员工的信息错误,请检验编号和姓名!"
Exit Sub
Else
If Combo1(0).Text <> "" Then
b = "update 工资信息 set 部门='" & Combo1(0).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute b
If Text(0).Text <> "" Then
c = "update 工资信息set 底薪='" & Text(0).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute c
If Text(1).Text <> "" Then
d = "update 工资信息 set 补贴='" & Text(1).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute d
If Text(2).Text <> "" Then
e = "update 工资信息 set 奖金='" & Text(2).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute e
If Text(3).Text <> "" Then
f = "update 工资信息 set 加班费='" & Text(3).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute f
If Text(4).Text <> "" Then
g = "update 工资信息 set 扣考核='" & Text(4).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute g
If Text(5).Text <> "" Then
h = "update 工资信息 set 养老金='" & Text(5).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute h
If Text(6).Text <> "" Then
i = "update 工资信息 set 医疗保险='" & Text(6).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute i
If Text(7).Text <> "" Then
j = "update 工资信息 set 住房公积金='" & Text(7).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute j
If Text(8).Text <> "" Then
k = "update 工资信息 set 税前小计='" & Text(8).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute k
If Text(9).Text <> "" Then
l = "update 工资信息 set 所得税='" & Text(9).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute l
If Text(10).Text <> "" Then
m = "update 工资信息 set 房帖='" & Text(10).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute m
If Text(11).Text <> "" Then
n = "update 工资信息 set 房租='" & Text(11).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute n
If Text(12).Text <> "" Then
o = "update 工资信息 set 实发工资='" & Text(12).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute o
If Text(13).Text <> "" Then
p = "update 工资信息 set 计发时间='" & Text(13).Text & "' where 编号='" & Text15.Text & "'and 姓名='" & Combo1(1).Text & "'"
db.Execute p
MsgBox "工资信息修改成功"
rs.Close
Text(1).Text = ""
Text(2).Text = ""
Text(3).Text = ""
Text(4).Text = ""
Text(5).Text = ""
Text(6).Text = ""
Text(7).Text = ""
Text(8).Text = ""
Text(9).Text = ""
Text(10).Text = ""
Text(11).Text = ""
Text(12).Text = ""
Text(13).Text = ""
Text(0).Text = ""
Combo1(0).Text = ""
Combo1(1).Text = ""
Else
MsgBox "计发时间!"
End If
Else
MsgBox "实发工资!"
End If
Else
MsgBox "房租"
End If
Else
MsgBox "房帖!"
End If
Else
MsgBox "所得税!"
End If
Else
MsgBox "税前小计"
End If
Else
MsgBox "住房公积金"
End If
Else
MsgBox "医疗保险"
End If
Else
MsgBox "养老金!"
End If
Else
MsgBox "扣考核!"
End If
Else
MsgBox "加班费!"
End If
Else
MsgBox "奖金!"
End If
Else
MsgBox "补贴!"
End If
Else
MsgBox "底薪!"
End If
Else
MsgBox "部门!"
End If
End If
End Sub
Private Sub Form_Load() '初始化部门名称
Set db = OpenDatabase(App.Path & "\员工基本信息")
Set rs = db.OpenRecordset("员工基本信息")
Set rs = db.OpenRecordset("select distinct 部门 from 员工基本信息")
If Not rs.EOF Then
Do While Not rs.EOF
Combo1(0).AddItem Trim(rs!部门)
rs.MoveNext
Loop
Combo1(0).ListIndex = 0
Else
MsgBox "请先进行员工档案登记!", vbOKOnly + vbExclamation, "警告"
Command1.Enabled = False
Exit Sub
End If
End Sub
Private Sub Text_Change(Index As Integer) '参考
Dim intcount As Integer
Dim z As Double
Dim Y As Boolean
Y = True
If (Index >= 0 And Index < 8) Or Index = 10 Or Index = 11 Then
z = 0
For intcount = 0 To 3 '底薪,补贴,奖金,加班费为应得
If Trim(Text(intcount)) <> "" Then
z = z + CDbl(Text(intcount))
End If
Next intcount
For intcount = 4 To 7 '扣考核,养老金,医疗保险,住房公积金为扣除的
If Trim(Text(intcount)) <> "" Then
z = z - CDbl(Text(intcount))
End If
Next intcount
If Trim(Text(10)) <> "" Then '房帖为单位补助
z = z + CDbl(Text(10))
End If
If Trim(Text(11)) <> "" Then '房租为扣除项目
z = z - CDbl(Text(11))
End If
Text(8) = Format(z, "#0.00") '税前小计为在没有扣除税额之前的工资
End If
If Index = 9 Then '税额变化
If Trim(Text(9) & " ") = "" Then '所得税
Text(12) = Trim(Text(8) & " ") '实发工资=税前小计
Else
Text(12) = Format(CDbl(Text(8)) - CDbl(Text(9)), "#0.00") '实发工资=税前小计-所得税
End If
End If
If Index = 8 And Trim(Text(8) & " ") <> "" Then '税前小计变化
z = CDbl(Text(8)) '工资=税前小计
z = z - 1200 '去掉不交税的工资部分
If z <= 0 Then '计算税额
z = 0
ElseIf z > 0 And z <= 500 Then
z = z * 0.05
ElseIf z > 500 And z <= 2000 Then
z = z * 0.1 - 25#
ElseIf z > 2000 And z <= 5000 Then
z = z * 0.15 - 125#
ElseIf z > 5000 And z <= 20000 Then
z = z * 0.2 - 375#
Else
MsgBox "请手工计算税额!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
Text(9) = Format(z, "#0.00") '所得税
End If
Exit Sub
End Sub
Private Sub Text_KeyPress(Index As Integer, KeyAscii As Integer) '参考
If Index >= 0 And Index <= 12 Then
'MsgBox KeyCode
'对键入字符进行控制
'txtQuantity(Index).Locked = False
'小数点只允许输入一次
If KeyAscii = 190 Then
If InStr(Trim(Text(Index)), ".") = 0 Then
If Len(Trim(Text(Index))) > 0 Then
Text(Index).Locked = False
Else
Text(Index).Locked = True
End If
Else
Text(Index).Locked = True
End If
Exit Sub
End If
'非数字不能输入
If KeyAscii > 57 Or KeyAscii < 48 Then
Text(Index).Locked = True
Else
Text(Index).Locked = False
End If
'允许Backspace
If KeyAscii = 8 Then
Text(Index).Locked = False
End If
'Delete键
If KeyAscii = 46 Then
Text(Index).Locked = False
End If
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -