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

📄 employee.frm

📁 simple supermarket for beginners
💻 FRM
字号:
VERSION 5.00
Begin VB.Form employee 
   Appearance      =   0  'Flat
   BackColor       =   &H80000013&
   Caption         =   "Employee Information"
   ClientHeight    =   7260
   ClientLeft      =   3765
   ClientTop       =   4590
   ClientWidth     =   11850
   FillStyle       =   0  'Solid
   LinkTopic       =   "Form1"
   MDIChild        =   -1  'True
   ScaleHeight     =   7260
   ScaleWidth      =   11850
   WindowState     =   2  'Maximized
   Begin VB.CommandButton cmdexit 
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Exit"
      Height          =   495
      Left            =   10440
      Style           =   1  'Graphical
      TabIndex        =   18
      Top             =   3600
      Width           =   1215
   End
   Begin VB.CommandButton cmddelete 
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Delete"
      Height          =   495
      Left            =   10440
      Style           =   1  'Graphical
      TabIndex        =   17
      Top             =   3000
      Width           =   1215
   End
   Begin VB.CommandButton cmdupdate 
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Update"
      Height          =   495
      Left            =   10440
      Style           =   1  'Graphical
      TabIndex        =   16
      Top             =   2400
      Width           =   1215
   End
   Begin VB.CommandButton cmdadd 
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Add"
      Height          =   495
      Left            =   10440
      Style           =   1  'Graphical
      TabIndex        =   15
      Top             =   1800
      Width           =   1215
   End
   Begin VB.CommandButton cmdprevious 
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Previous"
      Height          =   495
      Left            =   5520
      Style           =   1  'Graphical
      TabIndex        =   14
      Top             =   4560
      Width           =   1215
   End
   Begin VB.CommandButton cmdnext 
      BackColor       =   &H00E0E0E0&
      Caption         =   "&Next"
      Height          =   495
      Left            =   7320
      Style           =   1  'Graphical
      TabIndex        =   13
      Top             =   4560
      Width           =   1215
   End
   Begin VB.TextBox txtssn 
      Appearance      =   0  'Flat
      Height          =   285
      Left            =   6120
      MaxLength       =   10
      TabIndex        =   12
      Top             =   1800
      Visible         =   0   'False
      Width           =   3135
   End
   Begin VB.TextBox txtpnone_no 
      Appearance      =   0  'Flat
      Height          =   300
      Left            =   6120
      MaxLength       =   15
      TabIndex        =   9
      Top             =   2880
      Width           =   3110
   End
   Begin VB.TextBox txtadi 
      Appearance      =   0  'Flat
      Height          =   780
      Left            =   6120
      MultiLine       =   -1  'True
      TabIndex        =   7
      Top             =   3240
      Width           =   3110
   End
   Begin VB.TextBox txtlast_name 
      Appearance      =   0  'Flat
      Height          =   300
      Left            =   6120
      MaxLength       =   20
      TabIndex        =   5
      Top             =   2520
      Width           =   3110
   End
   Begin VB.TextBox txtf_name 
      Appearance      =   0  'Flat
      Height          =   300
      Left            =   6120
      MaxLength       =   20
      TabIndex        =   3
      Top             =   2160
      Width           =   3110
   End
   Begin VB.TextBox Txtemployee_no 
      Appearance      =   0  'Flat
      Height          =   300
      Left            =   6120
      Locked          =   -1  'True
      TabIndex        =   1
      Top             =   1800
      Width           =   3110
   End
   Begin VB.Image Image1 
      Height          =   1440
      Left            =   120
      Picture         =   "employee.frx":0000
      Top             =   120
      Width           =   1440
   End
   Begin VB.Label lblssn 
      BackColor       =   &H00FFC0C0&
      Caption         =   " SSN"
      Height          =   375
      Left            =   3960
      TabIndex        =   11
      Top             =   1800
      Visible         =   0   'False
      Width           =   2175
   End
   Begin VB.Label Label8 
      BackColor       =   &H00FFC0C0&
      Caption         =   " Mobile Number"
      BeginProperty Font 
         Name            =   "Century Gothic"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   3960
      TabIndex        =   10
      Top             =   2880
      Width           =   2175
   End
   Begin VB.Label Label7 
      BackColor       =   &H00FFC0C0&
      Caption         =   " Address"
      BeginProperty Font 
         Name            =   "Century Gothic"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   795
      Left            =   3960
      TabIndex        =   8
      Top             =   3240
      Width           =   2175
   End
   Begin VB.Label Label4 
      BackColor       =   &H00FFC0C0&
      Caption         =   " Last Name"
      BeginProperty Font 
         Name            =   "Century Gothic"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   3960
      TabIndex        =   6
      Top             =   2520
      Width           =   2175
   End
   Begin VB.Label Label3 
      BackColor       =   &H00FFC0C0&
      Caption         =   " First Name"
      BeginProperty Font 
         Name            =   "Century Gothic"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   3960
      TabIndex        =   4
      Top             =   2160
      Width           =   2175
   End
   Begin VB.Label Label2 
      BackColor       =   &H00FFC0C0&
      Caption         =   " Employee Number"
      BeginProperty Font 
         Name            =   "Century Gothic"
         Size            =   9.75
         Charset         =   0
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Height          =   420
      Left            =   3960
      TabIndex        =   2
      Top             =   1800
      Width           =   2175
   End
   Begin VB.Label Label1 
      BackStyle       =   0  'Transparent
      Caption         =   "Employee Information"
      BeginProperty Font 
         Name            =   "Verdana"
         Size            =   18
         Charset         =   0
         Weight          =   700
         Underline       =   0   'False
         Italic          =   -1  'True
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H00FFFFFF&
      Height          =   495
      Left            =   3720
      TabIndex        =   0
      Top             =   360
      Width           =   4575
   End
End
Attribute VB_Name = "employee"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim cn As ADODB.Connection
Dim RS As ADODB.Recordset
Dim add As Boolean
Dim validated As Boolean
Dim vaccumated As Boolean

Private Sub cmdadd_Click()
add = True
clear
cmdupdate.Caption = "Save"
lblssn.Visible = True
txtssn.Visible = True
txtssn.SetFocus

End Sub

Private Sub cmdcancel_Click()
clear
Display
cmdupdate.Caption = "Update"
End Sub

Private Sub cmdupdate_Click()
vaccumate
If vaccumated = False Then
    Exit Sub
End If
validate
If validated = False Then
    Exit Sub
End If
lblssn.Visible = False
txtssn.Visible = False
cmdupdate.Caption = "Update"
    If add = True Then
        add = False
        RS.AddNew
        save
        RS.Update
        MsgBox "The Record has been Saved"
        RS.MoveLast
        Display
    Else
        save
        RS.Update
        MsgBox "The Record has been Saved"
        Display
    End If
End Sub

Private Sub cmddelete_Click()
On Error Resume Next
RS.Delete
clear
MsgBox "The Record has been Deleted"
Call cmdnext_Click
If Err Then
MsgBox Err.Number + Err.Description
End If
End Sub

Private Sub cmdnext_Click()
On Error Resume Next
RS.MoveNext
Display
If RS.EOF = True Then
MsgBox "This is the last record"
RS.MoveLast
End If
End Sub

Private Sub cmdprevious_Click()
On Error Resume Next
RS.MovePrevious
Display
If RS.BOF = True Then
MsgBox "This is the first record"
RS.MoveFirst
End If
End Sub

Private Sub cmdexit_Click()
Unload Me
End Sub

Private Sub Form_Load()

On Error Resume Next
Set cn = New ADODB.Connection
Set RS = New ADODB.Recordset
cn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=TRANSPORT.MDB;Persist Security Info=False"
RS.Open "select * from employee", cn, adOpenDynamic, adLockPessimistic
RS.MoveFirst
Display
If Err Then
MsgBox Err.Number + Err.Description
End If
End Sub

Public Sub Display()
Txtemployee_no.Text = RS.Fields("employee_number")
txtf_name.Text = RS.Fields("first_name")
txtlast_name.Text = RS.Fields("last_name")
txtadi.Text = RS!address
txtpnone_no.Text = RS.Fields("mobile")

End Sub

Public Sub clear()
Txtemployee_no.Text = ""
txtf_name.Text = ""
txtlast_name.Text = ""
txtadi.Text = ""
txtpnone_no.Text = ""
txtssn.Text = ""
End Sub

Public Sub save()
RS("first_name") = txtf_name.Text
RS.Fields("last_name") = txtlast_name.Text
RS.Fields("address") = txtadi.Text
RS.Fields("mobile") = txtpnone_no.Text
RS!SSN = txtssn.Text
End Sub


Public Sub vaccumate()

    If txtf_name.Text = "" Then
        Label3.ForeColor = vbRed
        MsgBox "First Name of The Employee is required!", vbCritical, "Data Required!"
        txtf_name.SetFocus
        vaccumated = False
        Exit Sub
    ElseIf txtlast_name.Text = "" Then
        Label4.ForeColor = vbRed
        MsgBox "Last Name of The Employee is required!", vbCritical, "Data Required!"
        txtlast_name.SetFocus
        vaccumated = False
        Exit Sub
    ElseIf txtpnone_no.Text = "" Then
        Label8.ForeColor = vbRed
        MsgBox "Phone Number of The Employee is required!", vbCritical, "Data Required!"
        txtpnone_no.SetFocus
        vaccumated = False
        Exit Sub
    ElseIf txtadi.Text = "" Then
        Label7.ForeColor = vbRed
        MsgBox "Address of The Employee is required!", vbCritical, "Data Required!"
        txtadi.SetFocus
        vaccumated = False
        Exit Sub
    Else
        vaccumated = True
    End If

End Sub

Private Sub Label5_Click()

End Sub

Private Sub txtadi_Change()
Label7.ForeColor = black
End Sub

Private Sub txtf_name_Change()
Label3.ForeColor = black
End Sub

Public Sub validate()
    If IsNumeric(txtf_name.Text) Then
        Label3.ForeColor = vbRed
        MsgBox "First Name in letters!!" & Chr(13) & "Please.", vbCritical, "Datatype Mismatch."
        txtf_name.SetFocus
        SendKeys "{Home}+{End}"
        validated = False
        Exit Sub
    ElseIf IsNumeric(txtlast_name.Text) Then
        Label4.ForeColor = vbRed
        MsgBox "Last Name in letters!!" & Chr(13) & "Please.", vbCritical, "Datatype Mismatch."
        txtlast_name.SetFocus
        SendKeys "{Home}+{End}"
        validated = False
        Exit Sub
    ElseIf Not IsNumeric(txtpnone_no.Text) Then
        Label8.ForeColor = vbRed
        MsgBox "Phone Number In Digits!!" & Chr(13) & "Please.", vbCritical, "Datatype Mismatch."
        txtpnone_no.SetFocus
        SendKeys "{Home}+{End}"
        validated = False
        Exit Sub
    Else
        validated = True
    End If
End Sub

Private Sub txtlast_name_Change()
Label4.ForeColor = black
End Sub

Private Sub txtpnone_no_Change()
Label8.ForeColor = black
End Sub

⌨️ 快捷键说明

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