📄 absenceform.frm
字号:
'表中显示数据
Set MSHFlexGrid3.DataSource = Ado_RS
'断开数据库连结
SqlDisConnect Ado_RS
'设定各列的宽度
MSHFlexGrid3.ColWidth(1) = 3950
End Select
'更新月份表内容
InitializeMonth
End Sub
Private Sub Combo2_Click()
'更新表单内容:
'连结数据库
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
Select Case SSTab1.Tab
Case 0
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
str_RS = "select EDate 日期,EState 考勤,EOverwork 加班 from ExtendTable where EID='" & Trim(ID) & "' and year(EDate) = '" & Combo1.List(Combo1.ListIndex) & "'and month(EDate) = '" & Combo2.List(Combo2.ListIndex) & "'"
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
'表中显示数据
Set MSHFlexGrid1.DataSource = Ado_RS
'断开数据库连结
SqlDisConnect Ado_RS
'统计考勤月结
Dim cNormal, cLeave, cLate, cAbsenteeism, cOut, COverwork As Integer
Dim i As Integer
cNormal = 0: cLeave = 0: cLate = 0: cAbsenteeism = 0: cOut = 0: COverwork = 0
For i = 1 To MSHFlexGrid1.Rows - 1
If MSHFlexGrid1.TextMatrix(i, 1) = "正常" Then cNormal = cNormal + 1
If MSHFlexGrid1.TextMatrix(i, 1) = "请假" Then cLeave = cLeave + 1
If MSHFlexGrid1.TextMatrix(i, 1) = "迟到" Then cLate = cLate + 1
If MSHFlexGrid1.TextMatrix(i, 1) = "旷到" Then cAbsenteeism = cAbsenteeism + 1
If MSHFlexGrid1.TextMatrix(i, 1) = "出差" Then cOut = cOut + 1
If MSHFlexGrid1.TextMatrix(i, 2) = "有" Then COverwork = COverwork + 1
Next
Label2.Caption = "正常:" & cNormal & "次"
Label3.Caption = "请假:" & cLeave & "次"
Label4.Caption = "迟到:" & cLate & "次"
Label5.Caption = "旷到:" & cAbsenteeism & "次"
Label6.Caption = "出差:" & cOut & "次"
Label7.Caption = "加班:" & COverwork & "次"
Case 1
'连结数据库
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
str_RS = "select EDate 日期,ERAP 奖惩 from ExtendTable where EID='" & Trim(ID) & "' and ERAP is not null and year(EDate) = '" & Combo1.List(Combo1.ListIndex) & "'and month(EDate) = '" & Combo2.List(Combo2.ListIndex) & "'"
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
'表中显示数据
Set MSHFlexGrid2.DataSource = Ado_RS
'断开数据库连结
SqlDisConnect Ado_RS
'设定各列的宽度
MSHFlexGrid2.ColWidth(1) = 3950
Case 2
'连结数据库
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
str_RS = "select EDate 日期,ETraining 培训内容 from ExtendTable where EID='" & Trim(ID) & "' and ETraining is not null and year(EDate) = '" & Combo1.List(Combo1.ListIndex) & "'and month(EDate) = '" & Combo2.List(Combo2.ListIndex) & "'"
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
'表中显示数据
Set MSHFlexGrid3.DataSource = Ado_RS
'断开数据库连结
SqlDisConnect Ado_RS
'设定各列的宽度
MSHFlexGrid3.ColWidth(1) = 3950
End Select
End Sub
Private Sub Command1_Click()
Select Case PriForm '选择返回的表
Case "EmployeeFrom"
EmployeeFrom.Enabled = True
Case "ManagerFrom"
ManagerFrom.Enabled = True
Case "PresidentForm"
PresidentForm.Enabled = True
End Select
Unload Me
End Sub
Private Sub Command2_Click()
SureExit
End Sub
Private Sub Form_Load()
InitializeState '初始化考勤状况
InitializeRAP '初始化考核奖惩
InitializeTraining '初始化考核奖惩
InitializeYear '初始化年份表
Combo2.Enabled = False
Caption = PriForm
End Sub
Public Sub InitializeState() '初始化考勤状况
'连结数据库
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
str_RS = "select EDate 日期,EState 考勤,EOverwork 加班 from ExtendTable where EID='" & Trim(ID) & "'"
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
'表中显示数据
Set MSHFlexGrid1.DataSource = Ado_RS
'断开数据库连结
SqlDisConnect Ado_RS
'统计考勤月结
Dim cNormal, cLeave, cLate, cAbsenteeism, cOut, COverwork As Integer
Dim i As Integer
cNormal = 0: cLeave = 0: cLate = 0: cAbsenteeism = 0: cOut = 0: COverwork = 0
For i = 1 To MSHFlexGrid1.Rows - 1
If MSHFlexGrid1.TextMatrix(i, 1) = "正常" Then cNormal = cNormal + 1
If MSHFlexGrid1.TextMatrix(i, 1) = "请假" Then cLeave = cLeave + 1
If MSHFlexGrid1.TextMatrix(i, 1) = "迟到" Then cLate = cLate + 1
If MSHFlexGrid1.TextMatrix(i, 1) = "旷到" Then cAbsenteeism = cAbsenteeism + 1
If MSHFlexGrid1.TextMatrix(i, 1) = "出差" Then cOut = cOut + 1
If MSHFlexGrid1.TextMatrix(i, 2) = "有" Then COverwork = COverwork + 1
Next
Label2.Caption = "正常:" & cNormal & "次"
Label3.Caption = "请假:" & cLeave & "次"
Label4.Caption = "迟到:" & cLate & "次"
Label5.Caption = "旷到:" & cAbsenteeism & "次"
Label6.Caption = "出差:" & cOut & "次"
Label7.Caption = "加班:" & COverwork & "次"
End Sub
Public Sub InitializeRAP() '初始化考核奖惩
'连结数据库
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
str_RS = "select EDate 日期,ERAP 奖惩 from ExtendTable where EID='" & Trim(ID) & "' and ERAP is not null"
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
'表中显示数据
Set MSHFlexGrid2.DataSource = Ado_RS
'断开数据库连结
SqlDisConnect Ado_RS
'设定各列的宽度
MSHFlexGrid2.ColWidth(1) = 3950
End Sub
Public Sub InitializeTraining() '初始化培训
'连结数据库
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
str_RS = "select EDate 日期,ETraining 培训内容 from ExtendTable where EID='" & Trim(ID) & "' and ETraining is not null"
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
'表中显示数据
Set MSHFlexGrid3.DataSource = Ado_RS
'断开数据库连结
SqlDisConnect Ado_RS
'设定各列的宽度
MSHFlexGrid3.ColWidth(1) = 3950
End Sub
Public Function InitializeYear() '初始化年份表
'连结数据库,找出表中所有的年份
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
Select Case SSTab1.Tab '因考勤、奖惩、培训有不同的年份
Case 0
str_RS = "select distinct year(EDate) from ExtendTable where EID='" & ID & "'"
Case 1
str_RS = "select distinct year(EDate) from ExtendTable where ERAP is not null and EID='" & ID & "'"
Case 2
str_RS = "select distinct year(EDate) from ExtendTable where ETraining is not null and EID='" & ID & "'"
End Select
Ado_RS.CursorLocation = adUseClient '把游标改为客户端模式
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
'把不同的年份加入年份选择中
Combo1.Clear
Combo1.Text = "请选择年份"
Dim i As Integer
For i = 1 To Ado_RS.RecordCount
Combo1.AddItem Ado_RS.Fields(0)
Ado_RS.MoveNext
Next
'返回年份表是否为空
If Ado_RS.RecordCount > 0 Then InitializeYear = False Else InitializeYear = True
'断开数据库连结
SqlDisConnect Ado_RS
End Function
Public Function InitializeMonth() '初始化月份表
'连结数据库,找出表中所有的年份
Set Ado_Conn = New ADODB.Connection
Set Ado_RS = New ADODB.Recordset
str_CS = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ManageSystem"
Select Case SSTab1.Tab '因考勤、奖惩、培训有不同的年份
Case 0
str_RS = "select distinct month(EDate) from ExtendTable where year(EDate) ='" & Combo1.List(Combo1.ListIndex) & "'"
Case 1
str_RS = "select distinct month(EDate) from ExtendTable where ERAP is not null and year(EDate) ='" & Combo1.List(Combo1.ListIndex) & "'"
Case 2
str_RS = "select distinct month(EDate) from ExtendTable where ETraining is not null and year(EDate) ='" & Combo1.List(Combo1.ListIndex) & "'"
End Select
Ado_RS.CursorLocation = adUseClient '把游标改为客户端模式
SqlConnect Ado_Conn, Ado_RS, str_CS, str_RS
'把不同的年份加入年份选择中
Combo2.Clear
Combo2.Text = "请选择月份"
Dim i As Integer
For i = 1 To Ado_RS.RecordCount
Combo2.AddItem Ado_RS.Fields(0)
Ado_RS.MoveNext
Next
'返回月份表是否为空
If Ado_RS.RecordCount > 0 Then InitializeMonth = False Else InitializeMonth = True
'断开数据库连结
SqlDisConnect Ado_RS
End Function
Private Sub MSHFlexGrid2_SelChange() '显示出一些看不到的内容
If MSHFlexGrid2.ColSel = 0 Then Exit Sub
MSHFlexGrid2.ToolTipText = MSHFlexGrid2.TextMatrix(MSHFlexGrid2.RowSel, MSHFlexGrid2.ColSel)
End Sub
Private Sub MSHFlexGrid3_SelChange() '显示出一些看不到的内容
If MSHFlexGrid3.ColSel = 0 Then Exit Sub
MSHFlexGrid3.ToolTipText = MSHFlexGrid3.TextMatrix(MSHFlexGrid3.RowSel, MSHFlexGrid3.ColSel)
End Sub
Private Sub SSTab1_Click(PreviousTab As Integer)
Dim Is_Empty As Boolean
Is_Empty = InitializeYear '初始化年份表
If Is_Empty Then '如果没有相关记录
Combo1.Enabled = False
MsgBox "没有" & SSTab1.TabCaption(SSTab1.Tab) & "的相关记录", vbInformation, "没有相关记录"
Else
Combo1.Enabled = True
End If
Combo2.Clear
Combo2.Text = "请选择月份"
Combo2.Enabled = False
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -