【VB开源代码栏目提醒】:以下是网学会员为您推荐的VB开源代码-frmCheckInfo2.frm,希望本篇文章对您学习有所帮助。
VERSION 5.00
Object = "{C932BA88-4374-101B-A56C-00AA003668DC}#1.1#0"; "MSMASK32.OCX"
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form frmCheckInfo2
BorderStyle = 3 'Fixed Dialog
Caption = "员工考勤查询"
ClientHeight = 6795
ClientLeft = 45
ClientTop = 330
ClientWidth = 9480
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 6795
ScaleWidth = 9480
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.Frame Frame1
Caption = "查询条件"
Height = 1935
Left = 0
TabIndex = 3
Top = 0
Width = 8775
Begin VB.CommandButton Command3
Caption = "开始
搜索"
Default = -1 'True
Height = 375
Left = 7080
TabIndex = 9
Top = 1320
Width = 975
End
Begin VB.ComboBox cboDept
Height = 300
Left = 1200
TabIndex = 8
Top = 1320
Width = 2775
End
Begin VB.ComboBox cboCheckYear
Height = 300
Left = 5400
TabIndex = 7
Top = 360
Width = 1335
End
Begin VB.TextBox Text1
Height = 390
Left = 1200
TabIndex = 6
Top = 840
Width = 2775
End
Begin VB.ComboBox cboCheckMonth
Height = 300
Left = 7200
TabIndex = 5
Top = 360
Width = 855
End
Begin MSMask.MaskEdBox MskId
Height = 375
Left = 1200
TabIndex = 4
Top = 360
Width = 2775
_ExtentX = 4895
_ExtentY = 661
_Version = 393216
PromptChar = "_"
End
Begin VB.Label Label1
AutoSize = -1 'True
Caption = "工 号:"
Height = 180
Left = 360
TabIndex = 16
Top = 480
Width = 720
End
Begin VB.Label Label2
AutoSize = -1 'True
Caption = "姓 名:"
Height = 180
Left = 360
TabIndex = 15
Top = 960
Width = 720
End
Begin
VB.Label Label3
AutoSize = -1 'True
Caption = "部 门:"
Height = 180
Left = 360
TabIndex = 14
Top = 1440
Width = 720
End
Begin VB.Label Label4
AutoSize = -1 'True
Caption = "工资年月:"
Height = 180
Left = 4440
TabIndex = 13
Top = 480
Width = 900
End
Begin VB.Label Label5
AutoSize = -1 'True
Caption = "以上条件均为可选项"
Height = 180
Left = 4920
TabIndex = 12
Top = 1440
Width = 1620
End
Begin VB.Label Label6
AutoSize = -1 'True
Caption = "年"
Height = 180
Left = 6840
TabIndex = 11
Top = 480
Width = 180
End
Begin VB.Label Label7
AutoSize = -1 'True
Caption = "月"
Height = 180
Left = 8160
TabIndex = 10
Top = 480
Width = 180
End
End
Begin VB.CommandButton Command1
Caption = "返 回"
Height = 375
Left = 7800
TabIndex = 2
Top = 5880
Width = 975
End
Begin MSFlexGridLib.MSFlexGrid flxShow
Height = 3255
Left = 360
TabIndex = 1
Top = 2280
Width = 8775
_ExtentX = 15478
_ExtentY = 5741
_Version = 393216
Redraw = -1 'True
ScrollBars = 2
End
Begin VB.Label Label8
AutoSize = -1 'True
Height = 180
Left = 600
TabIndex = 0
Top = 5760
Width = 90
End
End
Attribute VB_Name = "frmCheckInfo2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs As New ADODB.Recordset
Dim strSql As String
Dim i As Integer
Private Sub Command1_Click()
Unload Me
End Sub
Private Sub Command3_Click()
Dim strId As String
Dim strName As String
Dim strDept As String
Dim strCheck As String
'按工号查询
If Len(Trim(MskId)) = 0 Then
strId = ""
Else
strId = "and a.emp_id= CLng('" & MskId & "')"
End If
'按
查询 If Len(Trim(Text1)) = 0 Then
strName = ""
Else
strName = "and b.emp_name='" & Trim(Text1) & "'"
End If
'按部门查询
If cboDept = "" Then
strDept = ""
Else
strDept = "and c.dept_name='" & cboDept & "'"
End If
'按时间查询
If cboCheckYear = "" Then
If cboCheckMonth = "" Then '年月都为空时
strCheck = ""
Else '任意年份的指定月
strCheck = "and a.check_ym in ('" & Year(Date) & cboCheckMonth & "','" & Year(Date) - 1 & cboCheckMonth & "')"
End If
Else
If cboCheckMonth = "" Then '指定年份的任意月
strCheck = "and a.check_ym in ('" & cboCheckYear & "01" & "','" & cboCheckYear & "02" & "','" & cboCheckYear & "03" & "','" & cboCheckYear & "04" & "','" & cboCheckYear & "05" & "','" & cboCheckYear & "06" & "','" & cboCheckYear & "03" & "','" & cboCheckYear & "07" & "','" & cboCheckYear & "08" & "','" & cboCheckYear & "09" & "','" & cboCheckYear & "10" & "','" & cboCheckYear & "11" & "','" & cboCheckYear & "12" & "' )"
Else '指定的年月
strCheck = "and a.check_ym in('" & cboCheckYear & cboCheckMonth & "')"
End If
End If
'打开一个数据集
strSql = "select a.emp_id,b.emp_name,c.dept_name,a.check_ym,a.w_days,a.l_nums,a.e_nums,a.h_days,a.n_days from checkin a ,employee b,department c where a.emp_id = b.emp_id and c.dept_id=b.dept_id " & strCheck & " " &