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

📄 frmsearchemp.frm

📁 一个功能完善,界面比较精美的酒店管理系统
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   195
         Left            =   240
         TabIndex        =   14
         Top             =   4560
         Width           =   2085
      End
      Begin VB.Label lbladdress 
         AutoSize        =   -1  'True
         Caption         =   "Address"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   195
         Left            =   240
         TabIndex        =   13
         Top             =   960
         Width           =   795
      End
      Begin VB.Label lblcity 
         AutoSize        =   -1  'True
         Caption         =   "City"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   195
         Left            =   240
         TabIndex        =   12
         Top             =   1320
         Width           =   375
      End
      Begin VB.Label lblstate 
         AutoSize        =   -1  'True
         Caption         =   "State"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   195
         Left            =   240
         TabIndex        =   11
         Top             =   1680
         Width           =   510
      End
      Begin VB.Label lblPhone 
         AutoSize        =   -1  'True
         Caption         =   "Phone/Mobile"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   195
         Left            =   240
         TabIndex        =   10
         Top             =   2400
         Width           =   1350
      End
      Begin VB.Label lblemployeeNo 
         AutoSize        =   -1  'True
         Caption         =   "Employee No."
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   195
         Left            =   240
         TabIndex        =   9
         Top             =   600
         Width           =   1335
      End
      Begin VB.Label lblpin 
         AutoSize        =   -1  'True
         Caption         =   "Pin Code"
         BeginProperty Font 
            Name            =   "Verdana"
            Size            =   8.25
            Charset         =   0
            Weight          =   700
            Underline       =   0   'False
            Italic          =   0   'False
            Strikethrough   =   0   'False
         EndProperty
         ForeColor       =   &H00FF0000&
         Height          =   195
         Left            =   240
         TabIndex        =   8
         Top             =   2040
         Width           =   840
      End
   End
   Begin VB.CommandButton cmdCancel 
      Caption         =   "Cancel"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   9
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   375
      Left            =   7440
      TabIndex        =   0
      Top             =   960
      Width           =   1095
   End
   Begin VB.Label lblTitle 
      AutoSize        =   -1  'True
      Caption         =   "Search Employee Record"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   14.25
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   345
      Left            =   1680
      TabIndex        =   7
      Top             =   120
      Width           =   3990
   End
   Begin VB.Line Line1 
      X1              =   0
      X2              =   9600
      Y1              =   720
      Y2              =   720
   End
   Begin VB.Label lblName 
      AutoSize        =   -1  'True
      Caption         =   "Enter Employee's Name"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   9.75
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   240
      Left            =   120
      TabIndex        =   6
      Top             =   960
      Width           =   2595
   End
   Begin VB.Label lblcount 
      AutoSize        =   -1  'True
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   8.25
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H000000FF&
      Height          =   195
      Left            =   2880
      TabIndex        =   5
      Top             =   1440
      Width           =   60
   End
End
Attribute VB_Name = "frmSearchEmp"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim StrSql As String

Public Sub FindX()

    ' connection and recordset variables
    Dim Cnxn As New ADODB.Connection
    Dim rstName As New ADODB.Recordset
    Dim strCnxn As String
    Dim strSQLEmpName As String
    
     ' record variables
    Dim mark As Variant
    Dim count As Integer
    
     ' open connection
     lblcount.Caption = ""
    Set Cnxn = New ADODB.Connection
    strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
              & App.Path & "\database\HMS.mdb;Persist Security Info=False"
              
    Cnxn.Open strCnxn
       
    ' open recordset with default parameters which are
    ' sufficient to search forward through a Recordset
    Set rstName = New ADODB.Recordset
    strSQLEmpName = "SELECT Name FROM PresentEmp_Table"
    rstName.Open strSQLEmpName, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

    count = 0
    rstName.Find "Name LIKE '" & txtName.Text & "%'"
    Do While Not rstName.EOF
        'continue if last find succeeded
       lstEmpName.AddItem rstName!Name
        'count the last title found
       count = count + 1
        ' note current position
       mark = rstName.Bookmark
       rstName.Find "Name LIKE '" & txtName.Text & "%'", 1, adSearchForward, mark
        ' above code skips current record to avoid finding the same row repeatedly;
        ' last arg (bookmark) is redundant because Find searches from current position
    Loop
    If count = 0 Then
     MsgBox "No Match Found", vbOKOnly + vbInformation, "Information"
     txtName.SetFocus
    Else
     lblcount.Caption = "Total Matches found " & count
    End If
     ' clean up
    rstName.Close
    Cnxn.Close
    Set rstName = Nothing
    Set Cnxn = Nothing

End Sub


Private Sub cmdCancel_Click()
Unload Me
End Sub

Private Sub cmdGo_Click()

lstEmpName.Clear
fraDetails.Visible = False

If txtName.Text = "" Then
 MsgBox "Enter the name", vbOKOnly + vbCritical, "Error"
 txtName.SetFocus
 Exit Sub
End If

FindX


End Sub

Private Sub Command1_Click()
FindAll
End Sub

Private Sub Form_Load()
fraDetails.Visible = False
Me.Top = 3000
Me.Left = 3000

Call Connect


lstEmpName.Clear

End Sub


Private Sub lstEmpName_Click()
With Rs_Details
 .MoveFirst
 While Not .EOF
  If lstEmpName.List(lstEmpName.ListIndex) = .Fields(1) Then
   txtEmpNo.Text = .Fields(0)
   txtaddress.Text = .Fields(2)
   txtcity.Text = .Fields(3)
   txtState.Text = .Fields(4)
   txtpin.Text = .Fields(5)
   txtphone.Text = .Fields(6)
   txtDOJ.Text = .Fields(7)
   txteduqualification.Text = .Fields(8)
   txtdesignation.Text = .Fields(9)
   txtDept.Text = .Fields(10)
   txtExp.Text = .Fields(11)
  End If
  .MoveNext
 Wend
 fraDetails.Visible = True
 End With
End Sub
Public Sub FindAll()

    ' connection and recordset variables
    Dim Cnxn As New ADODB.Connection
    Dim rstName As New ADODB.Recordset
    Dim strCnxn As String
    Dim strSQLEmpName As String
    
     ' record variables
    Dim mark As Variant
    Dim count As Integer
    
     ' open connection
     lblcount.Caption = ""
    Set Cnxn = New ADODB.Connection
    strCnxn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
              & App.Path & "\database\HMS.mdb;Persist Security Info=False"
              
    Cnxn.Open strCnxn
       
    ' open recordset with default parameters which are
    ' sufficient to search forward through a Recordset
    Set rstName = New ADODB.Recordset
    strSQLEmpName = "SELECT * FROM PresentEmp_Table"
    rstName.Open strSQLEmpName, Cnxn, adOpenStatic, adLockReadOnly, adCmdText

    count = 0
'    rstName.Find "Name "
    With rstName
    .MoveFirst
    While Not .EOF
    lstEmpName.AddItem .Fields(1)
    .MoveNext
    Wend
     count = .RecordCount
    End With
    
    If count = 0 Then
     MsgBox "No Match Found", vbOKOnly + vbInformation, "Information"
     txtName.SetFocus
    Else
     lblcount.Caption = "Total Matches found " & count
    End If
     ' clean up
    rstName.Close
    Cnxn.Close
    Set rstName = Nothing
    Set Cnxn = Nothing



End Sub

⌨️ 快捷键说明

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