www.pudn.com > renshixitong.rar > frmManRecord2.frm


VERSION 5.00 
Begin VB.Form frmManRecord2  
   BorderStyle     =   3  'Fixed Dialog 
   Caption         =   "员工信息查询" 
   ClientHeight    =   2640 
   ClientLeft      =   48 
   ClientTop       =   336 
   ClientWidth     =   4704 
   LinkTopic       =   "Form1" 
   MaxButton       =   0   'False 
   MinButton       =   0   'False 
   ScaleHeight     =   2640 
   ScaleWidth      =   4704 
   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           =   2 
      Left            =   240 
      TabIndex        =   19 
      TabStop         =   0   'False 
      Top             =   1080 
      Width           =   132 
   End 
   Begin VB.Frame Frame1  
      Height          =   1095 
      Left            =   1560 
      TabIndex        =   12 
      Top             =   960 
      Width           =   2895 
      Begin VB.ComboBox cboMonth  
         Height          =   300 
         Index           =   0 
         Left            =   1845 
         Style           =   2  'Dropdown List 
         TabIndex        =   3 
         Top             =   240 
         Width           =   645 
      End 
      Begin VB.ComboBox cboMonth  
         Height          =   300 
         Index           =   1 
         Left            =   1845 
         Style           =   2  'Dropdown List 
         TabIndex        =   5 
         Top             =   690 
         Width           =   645 
      End 
      Begin VB.ComboBox cboYear  
         Height          =   300 
         Index           =   0 
         Left            =   675 
         Style           =   2  'Dropdown List 
         TabIndex        =   2 
         Top             =   240 
         Width           =   765 
      End 
      Begin VB.ComboBox cboYear  
         Height          =   300 
         Index           =   1 
         Left            =   675 
         Style           =   2  'Dropdown List 
         TabIndex        =   4 
         Top             =   690 
         Width           =   765 
      End 
      Begin VB.Label Label1  
         Caption         =   "月" 
         Height          =   210 
         Index           =   7 
         Left            =   2520 
         TabIndex        =   18 
         Top             =   720 
         Width           =   240 
      End 
      Begin VB.Label Label1  
         Caption         =   "从:" 
         Height          =   210 
         Index           =   6 
         Left            =   240 
         TabIndex        =   17 
         Top             =   240 
         Width           =   375 
      End 
      Begin VB.Label Label1  
         Caption         =   "年" 
         Height          =   210 
         Index           =   1 
         Left            =   1515 
         TabIndex        =   16 
         Top             =   240 
         Width           =   240 
      End 
      Begin VB.Label Label1  
         Caption         =   "月" 
         Height          =   210 
         Index           =   2 
         Left            =   2520 
         TabIndex        =   15 
         Top             =   240 
         Width           =   240 
      End 
      Begin VB.Label Label1  
         Caption         =   "到:" 
         Height          =   210 
         Index           =   3 
         Left            =   255 
         TabIndex        =   14 
         Top             =   735 
         Width           =   375 
      End 
      Begin VB.Label Label1  
         Caption         =   "年" 
         Height          =   210 
         Index           =   4 
         Left            =   1560 
         TabIndex        =   13 
         Top             =   720 
         Width           =   225 
      End 
   End 
   Begin VB.CheckBox chkItem  
      Caption         =   "Check1" 
      Height          =   180 
      Index           =   1 
      Left            =   240 
      TabIndex        =   11 
      TabStop         =   0   'False 
      Top             =   600 
      Width           =   132 
   End 
   Begin VB.CheckBox chkItem  
      Caption         =   "Check1" 
      Height          =   180 
      Index           =   0 
      Left            =   240 
      TabIndex        =   10 
      TabStop         =   0   'False 
      Top             =   240 
      Value           =   1  'Checked 
      Width           =   132 
   End 
   Begin VB.CommandButton cmdOk  
      Caption         =   "确定 (&O)" 
      Default         =   -1  'True 
      Height          =   375 
      Left            =   1080 
      TabIndex        =   6 
      Top             =   2160 
      Width           =   1215 
   End 
   Begin VB.CommandButton cmdExit  
      Caption         =   "取消 (&X)" 
      Height          =   375 
      Left            =   2520 
      TabIndex        =   7 
      Top             =   2160 
      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        =   20 
      Top             =   600 
      Width           =   1095 
   End 
   Begin VB.Label lblitem  
      Caption         =   "参加工作时间:" 
      Height          =   375 
      Index           =   1 
      Left            =   600 
      TabIndex        =   9 
      Top             =   1080 
      Width           =   735 
   End 
   Begin VB.Label lblitem  
      Caption         =   "姓    名:" 
      Height          =   255 
      Index           =   0 
      Left            =   600 
      TabIndex        =   8 
      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 = " ygname = '" & Trim(txtItem(0) & " ") & "'" 
    End If 
     
    If chkItem(1).Value = vbChecked Then 
        If Trim(sQSql & " ") = "" Then 
            sQSql = " ygdept = '" & Trim(txtItem(1) & " ") & "'" 
        Else 
            sQSql = sQSql & " and ygdept = '" & 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 manrecord " 
        flagEdit = True 
        frmManRecord.ShowTitle 
        frmManRecord.ShowData 
    Else 
        frmManRecord.txtSQL = "select * from manrecord 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 manrecord" 
    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