frmngztj.frm
来自「企业工资管理系统的具体实现」· FRM 代码 · 共 639 行 · 第 1/2 页
FRM
639 行
Top = 1320
Width = 1050
End
Begin VB.CommandButton Command1
Caption = "统 计"
Enabled = 0 'False
Height = 390
Left = 6960
TabIndex = 11
Top = 1320
Width = 1050
End
Begin VB.TextBox Text4
Height = 375
Left = 7995
TabIndex = 9
Top = 720
Width = 690
End
Begin VB.TextBox Text3
Height = 375
Left = 6570
TabIndex = 7
Top = 720
Width = 945
End
Begin VB.TextBox Text2
BackColor = &H80000000&
Enabled = 0 'False
Height = 375
Left = 5235
TabIndex = 5
Top = 720
Width = 690
End
Begin VB.TextBox Text1
BackColor = &H80000000&
Enabled = 0 'False
Height = 375
Left = 3810
TabIndex = 3
Text = " "
Top = 720
Width = 945
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "月"
Height = 180
Left = 8805
TabIndex = 10
Top = 825
Width = 180
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "年"
Height = 180
Left = 7680
TabIndex = 8
Top = 825
Width = 180
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "月至"
Height = 180
Left = 6060
TabIndex = 6
Top = 825
Width = 360
End
Begin VB.Label Label3
AutoSize = -1 'True
Caption = "年"
Height = 180
Left = 4920
TabIndex = 4
Top = 825
Width = 180
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "统计月份从:"
Height = 180
Left = 2625
TabIndex = 2
Top = 825
Width = 1080
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "Label1"
BeginProperty Font
Name = "宋体"
Size = 18
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ForeColor = &H00004080&
Height = 360
Left = 4125
TabIndex = 1
Top = 210
Width = 1080
End
End
End
Attribute VB_Name = "frmngztj"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Command1_Click()
Dim cnn As New ADODB.Recordset
Dim cnn1 As New ADODB.Recordset
Dim gs As Single, cpjs As Single, cdkc As Single, cpkc As Single, qtkc As Single, jtf As Single, gzhj As Single
Dim qsny As String, jsny As String
gs = 0
cpjs = 0
cdkc = 0
cpkc = 0
qtkc = 0
jtf = 0
If Int(Trim(Text4.Text)) <= 12 Then
MsgBox "未到年底,不能进行年工资统计!", vbInformation, "提示"
Exit Sub
End If
On Error GoTo err1
If Text3.Text = "" Or Text4.Text = "" Then
MsgBox "请输入年份和月份!", vbInformation, "提示"
Text3.SetFocus
Exit Sub
Else
If IsNumeric(Text3.Text) = False Or IsNumeric(Text4.Text) = False Then
MsgBox "输入的年份或月份不是数字!", vbInformation, "提示"
Text3.SetFocus
Exit Sub
ElseIf Val(Trim(Text1.Text)) > Val(Trim(Text3.Text)) Then
MsgBox "结束年份必须大于等于起始年份!", vbInformation, "提示"
Text3.SetFocus
Exit Sub
ElseIf Val(Trim(Text1.Text)) = Val(Trim(Text3.Text)) Then
If Val(Trim(Text2.Text)) > Val(Trim(Text4.Text)) Then
MsgBox "结束时间早于或者等于起始时间!", vbInformation, "提示"
Text4.SetFocus
Exit Sub
End If
End If
End If
qsny = Trim(Text1.Text) & "年" & Trim(Text2.Text) & "月"
jsny = Trim(Text3.Text) & "年" & Trim(Text4.Text) & "月"
With Adodc1
.ConnectionString = constr
.RecordSource = "select * from gzzjb order by grdh"
.Refresh
If Not (.Recordset.EOF And .Recordset.BOF) Then
.Recordset.MoveFirst
Else
MsgBox "请先进行工作分配!", vbInformation, "提示"
Exit Sub
End If
Do While Not .Recordset.EOF
' For i = Val(Trim(Text2.Text)) To Val(Trim(Text4.Text))
With cnn
.ActiveConnection = constr
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockBatchOptimistic '根据工人代号查出在给定日期内的所有此工人的月情况
.Open "select * from ygzqkb where grdh='" & Adodc1.Recordset.Fields("grdh").Value & "' and yf between '" & qsny & "' and '" & jsny & "'"
If Not (.EOF And .BOF) Then
.MoveFirst
End If
Do While Not .EOF '把每个月的工时,产品件数等数目累加起来放入各自的变量中
gs = gs + .Fields("gs").Value
cpjs = cpjs + .Fields("cpjs").Value
cdkc = cdkc + .Fields("cdkc").Value
cpkc = cpkc + .Fields("cpkc").Value
qtkc = qtkc + .Fields("qtkc").Value
jtf = jtf + .Fields("jtf").Value
gzhj = gzhj + .Fields("gzhj").Value
.MoveNext
Loop
.Close
End With
Set cnn = Nothing
' MsgBox "初始化第一步!"
.Recordset.Fields("qsny").Value = Trim(Text1.Text) & "年" & Trim(Text2.Text) & "月"
.Recordset.Fields("jsny").Value = Trim(Text3.Text) & "年" & Trim(Text4.Text) & "月"
.Recordset.Fields("gs").Value = gs
.Recordset.Fields("cpjs").Value = cpjs
.Recordset.Fields("cdkc").Value = cdkc
.Recordset.Fields("cpkc").Value = cpkc
.Recordset.Fields("qtkc").Value = qtkc
.Recordset.Fields("jtf").Value = jtf
gs = 0
cpjs = 0
cdkc = 0
cpkc = 0
qtkc = 0
jtf = 0
With cnn1
.ActiveConnection = constr
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockBatchOptimistic
.Open "select ze from jzb where grdh='" & Adodc1.Recordset.Fields("grdh").Value & "' "
If Not .EOF And Not .BOF Then
Adodc1.Recordset.Fields("jz").Value = .Fields("ze").Value
Adodc1.Recordset.Fields("gzhj").Value = gzhj - .Fields("ze").Value
Else
Adodc1.Recordset.Fields("gzhj").Value = gzhj
End If
gzhj = 0
.Close
End With
Set cnn1 = Nothing
.Recordset.Update
.Recordset.MoveNext
Loop
End With
Set DataGrid1.DataSource = Adodc1
Command3.Enabled = True
MsgBox "统计完成!"
MsgBox "为了便于系统维护,你必须在10天之内初始化统计结果。", vbExclamation, "提示"
Exit Sub
err1:
If Err.Number = -2147217887 Then
MsgBox "文本框中输入的数字过长,请检查!", vbInformation, "提示"
Text3.SetFocus
Exit Sub
End If
End Sub
Private Sub Command2_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Dim cnn As New ADODB.Connection
Dim qsny As String, jsny As String, qsny1 As String, jsny1 As String
If MsgBox("你确信现在进行初始化吗?" & Chr(10) & Chr(13) & "初始化后将删除" & Text1.Text & "年" & Text2.Text & "月到所有工人工资况。如果你已经对工资情况进行备份,即可进行备份。", vbCritical + vbYesNo, "初始化") = vbNo Then
Exit Sub
End If
With Adodc1
.ConnectionString = constr
.RecordSource = "select distinct(qsny) from gzzjb "
.Refresh
qsny = .Recordset.Fields("qsny").Value
.RecordSource = "select distinct(jsny) from gzzjb "
.Refresh
jsny = .Recordset.Fields("jsny").Value
End With
qsny1 = Mid(qsny, 6, 2)
jsny1 = Mid(jsny, 6, 2)
With cnn
.Open constr
For i = Val(Trim(qsny1)) To Val(Trim(jsny1))
If Len(Trim(Str$(i))) = 1 Then
.Execute "delete * from sbqkb" & "0" & Trim(Str$(i))
.Execute "insert into sbqkb" & Trim("0" & Trim(Str$(i))) & "(cjdh,grdh,xm) select cjdh,grdh,xm from grfpb" ' where cjdh='" & Trim(Combo1.Text) & "'"
Else
.Execute "delete * from sbqkb" & Trim(Str$(i))
.Execute "insert into sbqkb" & Trim(Str$(i)) & "(cjdh,grdh,xm) select cjdh,grdh,xm from grfpb "
End If
Next i
.Execute "delete * from gzkcb where yf between '" & qsny & "' and '" & jsny & "'"
.Execute "delete * from jzb"
.Execute "delete * from ygzqkb where yf between '" & qsny & "' and '" & jsny & "'"
.Execute "delete * from gzzjb"
.Execute "insert into gzzjb(cjdh,grdh,xm) select cjdh,grdh,xm from grfpb "
.Close
End With
Set cnn = Nothing
MsgBox "初始化完成!", vbInformation, "提示"
Command3.Enabled = False
Command1.Enabled = False
End Sub
Private Sub Form_Load()
Dim cnn As New ADODB.Recordset
Dim nf As String, yf As String
Dim year1 As String
With cnn
.ActiveConnection = constr
.CursorLocation = adUseClient
.CursorType = adOpenDynamic
.LockType = adLockBatchOptimistic
.Open "select min(yf) as minyf from ygzqkb "
If Not (.EOF And .BOF) And IsNull(.Fields("minyf").Value) = False Then
nf = Left(Trim(.Fields("minyf").Value), 4)
yf = Mid(Trim(.Fields("minyf").Value), 6, 2)
Label1.Caption = nf & "年度工人工资总计"
Text1.Text = nf
Text2.Text = yf
Command1.Enabled = True
Else
Label1.Caption = "没有可以进行统计的工资!"
Command1.Enabled = False
Command3.Enabled = False
End If
.Close
End With
Set cnn = Nothing
year1 = Now
v = Split(year1, "-")
Text3.Text = v(0)
If Len(v(1)) = 1 Then
Text4.Text = "0" & v(1)
Else
Text4.Text = v(1)
End If
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?