⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frmqueryemployee.frm

📁 使用vb开发的课程设计
💻 FRM
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form frmQueryEmployee 
   Caption         =   "员工查询"
   ClientHeight    =   3930
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   5865
   LinkTopic       =   "Form1"
   ScaleHeight     =   3930
   ScaleWidth      =   5865
   StartUpPosition =   3  'Windows Default
   Begin MSFlexGridLib.MSFlexGrid fgResult 
      Height          =   1695
      Left            =   120
      TabIndex        =   8
      Top             =   2160
      Width           =   5655
      _ExtentX        =   9975
      _ExtentY        =   2990
      _Version        =   393216
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "返回(&C)"
      Height          =   375
      Left            =   3240
      TabIndex        =   7
      Top             =   1680
      Width           =   1215
   End
   Begin VB.CommandButton cmdQuery 
      Caption         =   "查询(&A)"
      Height          =   375
      Left            =   1440
      TabIndex        =   6
      Top             =   1680
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询方式"
      Height          =   1335
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   5655
      Begin VB.TextBox txtName 
         Height          =   285
         Left            =   1560
         TabIndex        =   5
         Top             =   840
         Width           =   1575
      End
      Begin VB.TextBox txtNo 
         Height          =   285
         Left            =   1560
         TabIndex        =   4
         Top             =   360
         Width           =   1575
      End
      Begin VB.OptionButton optQuery 
         Caption         =   "查询全部员工"
         Height          =   255
         Index           =   2
         Left            =   3480
         TabIndex        =   3
         Top             =   360
         Width           =   1455
      End
      Begin VB.OptionButton optQuery 
         Caption         =   "按员工姓名"
         Height          =   255
         Index           =   1
         Left            =   360
         TabIndex        =   2
         Top             =   840
         Width           =   1335
      End
      Begin VB.OptionButton optQuery 
         Caption         =   "按员工编号"
         Height          =   255
         Index           =   0
         Left            =   360
         TabIndex        =   1
         Top             =   360
         Width           =   1335
      End
   End
End
Attribute VB_Name = "frmQueryEmployee"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit

Public sqlStr As String
Public msgText As String

Private Sub cmdCancel_Click()
Unload Me

End Sub

Sub queryEmployee()
    Dim rs As ADODB.Recordset
    Dim i As Integer
    Dim j As Integer
    
    If optQuery(0).Value = True Then
         sqlStr = "select * from employee where" _
                & " employeeNo='" & txtNo.Text & "'"
    End If
    If optQuery(1).Value = True Then
         sqlStr = "select * from employee where" _
                & " employeeName='" & txtName.Text & "'"
    End If
    If optQuery(2).Value = True Then
         sqlStr = "select * from employee"
    End If
    
    Set rs = ExecuteSQL(sqlStr, msgText)
    
    If rs.RecordCount = 0 Then
    
        MsgBox "没有查找满足条件的数据!", vbExclamation, "提示"
        fgResult.Rows = 1
       
    Else
        
        fgResult.Rows = rs.RecordCount + 1
        
        fgResult.Cols = 6
        
        '设定行高
        For i = 0 To fgResult.Rows - 1
           fgResult.RowHeight(i) = 280
        Next i
        
        '设定列的属性
        fgResult.Row = 0
        
        For i = 0 To fgResult.Cols - 1
           fgResult.Col = i  '指定当前列为第i列
           fgResult.FixedAlignment(i) = 4  '每列内容居中显示
           Select Case i
               Case 0
                  fgResult.ColWidth(i) = 1000  '设定列宽
                  fgResult.Text = "员工编号"
               Case 1
                  fgResult.ColWidth(i) = 1100  '设定列宽
                  fgResult.Text = "姓名"
               Case 2
                  fgResult.ColWidth(i) = 800  '设定列宽
                  fgResult.Text = "性别"
               Case 3
                  fgResult.ColWidth(i) = 1000  '设定列宽
                  fgResult.Text = "出生日期"
               Case 4
                  fgResult.ColWidth(i) = 1200  '设定列宽
                  fgResult.Text = "职务"
               Case 5
                  fgResult.ColWidth(i) = 1000  '设定列宽
                  fgResult.Text = "部门"
            End Select
               
        Next i
           
           
        'rs.MoveFirst
        
        i = 1
        
        While (Not rs.EOF)
        
           fgResult.Row = i
           For j = 0 To fgResult.Cols - 1
           
            fgResult.Col = j '设置当前为列为第j列
            fgResult.CellAlignment = 4  '每列内容居中显示
        
            
            Select Case j
               Case 0
                  fgResult.Text = rs.Fields("employeeNo")
               Case 1
                  fgResult.Text = rs.Fields("employeeName")
               Case 2
                  fgResult.Text = rs.Fields("sex")
               Case 3
                  fgResult.Text = rs.Fields("birthdate")
               Case 4
                  fgResult.Text = rs.Fields("title")
               Case 5
                  fgResult.Text = rs.Fields("department")
            End Select
          Next j
        
            rs.MoveNext
            i = i + 1
        Wend
    
    End If
    
    rs.Close

End Sub


Private Sub cmdQuery_Click()
queryEmployee
End Sub

Private Sub txtName_GotFocus()
optQuery(1).Value = True

End Sub

Private Sub txtNo_Click()
optQuery(0).Value = True
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -