📄 frmmanrecord2.frm
字号:
VERSION 5.00
Begin VB.Form frmManRecord2
BorderStyle = 3 'Fixed Dialog
Caption = "员工信息查询"
ClientHeight = 1740
ClientLeft = 45
ClientTop = 330
ClientWidth = 4710
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 1740
ScaleWidth = 4710
ShowInTaskbar = 0 'False
StartUpPosition = 1 'CenterOwner
Begin VB.TextBox txtItem
Height = 270
Index = 1
Left = 1560
TabIndex = 1
Top = 600
Width = 2895
End
Begin VB.CheckBox chkItem
Caption = "Check1"
Height = 180
Index = 1
Left = 240
TabIndex = 6
TabStop = 0 'False
Top = 600
Width = 132
End
Begin VB.CheckBox chkItem
Caption = "Check1"
Height = 180
Index = 0
Left = 240
TabIndex = 5
TabStop = 0 'False
Top = 240
Value = 1 'Checked
Width = 132
End
Begin VB.CommandButton cmdOk
Caption = "确定 (&O)"
Default = -1 'True
Height = 375
Left = 720
TabIndex = 2
Top = 1200
Width = 1215
End
Begin VB.CommandButton cmdExit
Caption = "取消 (&X)"
Height = 375
Left = 2640
TabIndex = 3
Top = 1200
Width = 1215
End
Begin VB.TextBox txtItem
Height = 270
Index = 0
Left = 1560
TabIndex = 0
Top = 240
Width = 2895
End
Begin VB.Label lblitem
Caption = "部 门:"
Height = 255
Index = 2
Left = 600
TabIndex = 7
Top = 600
Width = 1095
End
Begin VB.Label lblitem
Caption = "姓 名:"
Height = 255
Index = 0
Left = 600
TabIndex = 4
Top = 240
Width = 1095
End
End
Attribute VB_Name = "frmManRecord2"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'用于传递查询块
Public sQSql As String
Private Sub cboMonth_Click(Index As Integer)
If cboMonth(0) <> "" And cboMonth(1) <> "" Then
If CInt(cboYear(0)) = CInt(cboYear(1)) Then
Select Case Index
Case 0
If CInt(cboMonth(Index)) > CInt(cboMonth(1)) Then
cboMonth(Index) = cboMonth(1)
End If
Case 1
If CInt(cboMonth(Index)) < CInt(cboMonth(0)) Then
cboMonth(Index) = cboMonth(0)
End If
End Select
End If
End If
End Sub
Private Sub cboYear_Click(Index As Integer)
If cboYear(0) <> "" And cboYear(1) <> "" Then
Select Case Index
Case 0
If CInt(cboYear(Index)) > CInt(cboYear(1)) Then
cboYear(Index) = cboYear(1)
End If
Case 1
If CInt(cboYear(Index)) < CInt(cboYear(1)) Then
cboYear(Index) = cboYear(0)
End If
End Select
Call cboMonth_Click(Index)
End If
End Sub
Private Sub chkItem_Click(Index As Integer)
If Index = 2 Then
cboYear(0).SetFocus
Else
txtItem(Index).SetFocus
End If
End Sub
Private Sub cmdExit_Click()
Me.Hide
End Sub
Private Sub cmdOK_Click()
Dim dBeginDate As String
Dim dEndDateTemp As Date
Dim dEndDate As String
If chkItem(0).Value = vbChecked Then
sQSql = " Em_name = '" & Trim(txtItem(0) & " ") & "'"
End If
If chkItem(1).Value = vbChecked Then
If Trim(sQSql & " ") = "" Then
sQSql = " Em_dept = '" & Trim(txtItem(1) & " ") & "'"
Else
sQSql = sQSql & " and Em_dept = '" & Trim(txtItem(1) & " ") & "'"
End If
End If
If chkItem(2).Value = vbChecked Then
dBeginDate = Format(CDate(cboYear(0) & "-" & cboMonth(0) & "-1"), "yyyy-mm-dd")
dEndDateTemp = DateAdd("d", -1, DateAdd("m", 1, DateSerial(CInt(cboYear(1)), CInt(cboMonth(1)), 1)))
dEndDate = Format(dEndDateTemp, "yyyy-mm-dd")
If Trim(sQSql & " ") = "" Then
sQSql = " ygdate1 >= '" & dBeginDate & "' and ygdate1 <= '" & dEndDate & "'"
Else
sQSql = sQSql & " and (ygdate1 >= '" & dBeginDate & "' and ygdate1 <= '" & dEndDate & "')"
End If
Else
End If
If Trim(sQSql) = "" Then
frmManRecord.txtSQL = "select * from EmployeeTable "
flagEdit = True
frmManRecord.ShowTitle
frmManRecord.ShowData
Else
frmManRecord.txtSQL = "select * from EmployeeTable where " & sQSql
flagEdit = True
frmManRecord.ShowTitle
frmManRecord.ShowData
End If
Me.Hide
End Sub
Private Sub Form_Load()
Dim i As Integer
Dim j As Integer
Dim txtSQL As String
Dim MsgText As String
Dim mrc As ADODB.Recordset
' txtSQL = "select distinct datepart(yy,ygdate1) from EmployeeTable"
' Set mrc = ExecuteSQL(txtSQL, MsgText)
' If mrc.EOF = False Then
' With mrc
' Do While Not .EOF
' If Not IsNull(.Fields(0)) Then
' cboYear(0).AddItem .Fields(0)
' cboYear(1).AddItem .Fields(0)
' End If
' .MoveNext
' Loop
' End With
' mrc.Close
' For i = 0 To 1
' cboYear(i).ListIndex = 0
' Next i
'
' For i = 0 To 1
' For j = 1 To 12
' cboMonth(i).AddItem j
' Next j
' Next i
' For i = 0 To 1
' cboMonth(i).Text = Month(Now())
' Next i
' Else
' cmdOk.Enabled = False
' End If
End Sub
Private Sub lblitem_Click(Index As Integer)
chkItem(Index).Value = vbChecked
End Sub
Private Sub txtItem_GotFocus(Index As Integer)
txtItem(Index).SelStart = 0
txtItem(Index).SelLength = Len(txtItem(Index))
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -