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

📄 frmempadd.frm

📁 员工个人信息管理
💻 FRM
字号:
VERSION 5.00
Begin VB.Form FrmEmpAdd 
   BorderStyle     =   3  'Fixed Dialog
   Caption         =   "员工信息"
   ClientHeight    =   3255
   ClientLeft      =   45
   ClientTop       =   330
   ClientWidth     =   6585
   LinkTopic       =   "Form1"
   MaxButton       =   0   'False
   MDIChild        =   -1  'True
   MinButton       =   0   'False
   ScaleHeight     =   3255
   ScaleWidth      =   6585
   ShowInTaskbar   =   0   'False
   Begin VB.CommandButton CmdSave 
      Caption         =   "保存(&S)"
      Height          =   375
      Left            =   600
      TabIndex        =   14
      Top             =   2760
      Width           =   1215
   End
   Begin VB.CommandButton CmdModify 
      Caption         =   "修改(&M)"
      Height          =   375
      Left            =   2160
      TabIndex        =   5
      Top             =   2760
      Width           =   1215
   End
   Begin VB.CommandButton CmdClose 
      Caption         =   "关闭(&C)"
      Height          =   375
      Left            =   5280
      TabIndex        =   7
      Top             =   2760
      Width           =   1215
   End
   Begin VB.CommandButton CmdAdd 
      Caption         =   "添加(&A)"
      Height          =   375
      Left            =   3720
      TabIndex        =   6
      Top             =   2760
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Height          =   2655
      Left            =   120
      TabIndex        =   8
      Top             =   0
      Width           =   6375
      Begin VB.TextBox TxtCode 
         Height          =   300
         Left            =   1080
         MaxLength       =   32
         TabIndex        =   0
         Top             =   240
         Width           =   2295
      End
      Begin VB.TextBox TxtName 
         Height          =   300
         Left            =   1080
         TabIndex        =   1
         Top             =   720
         Width           =   2295
      End
      Begin VB.TextBox TxtAge 
         Height          =   300
         Left            =   1080
         TabIndex        =   2
         Top             =   1200
         Width           =   2295
      End
      Begin VB.ComboBox CmbDate 
         Height          =   300
         Left            =   1080
         Style           =   2  'Dropdown List
         TabIndex        =   3
         Top             =   1680
         Width           =   2295
      End
      Begin VB.TextBox TxtAddress 
         Height          =   300
         Left            =   1080
         TabIndex        =   4
         Top             =   2160
         Width           =   5055
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "员工号码"
         Height          =   180
         Index           =   0
         Left            =   240
         TabIndex        =   13
         Top             =   360
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "员工姓名"
         Height          =   180
         Index           =   1
         Left            =   240
         TabIndex        =   12
         Top             =   840
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "员工年龄"
         Height          =   180
         Index           =   2
         Left            =   240
         TabIndex        =   11
         Top             =   1320
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "加入日期"
         Height          =   180
         Index           =   3
         Left            =   240
         TabIndex        =   10
         Top             =   1800
         Width           =   720
      End
      Begin VB.Label Label1 
         AutoSize        =   -1  'True
         Caption         =   "员工地址"
         Height          =   180
         Index           =   4
         Left            =   240
         TabIndex        =   9
         Top             =   2280
         Width           =   720
      End
   End
End
Attribute VB_Name = "FrmEmpAdd"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim InfoData(1 To 5) As String
Dim IntIndex As Integer
   
Private Sub CmdAdd_Click()
    
    If TxtCode = Empty Then
        TxtCode.SetFocus
        MsgBox "请输入员工号", , "错误信息"
        Exit Sub
    ElseIf TxtName.Text = Empty Then
        TxtName.SetFocus
        MsgBox "请输入员工姓名", , "错误信息"
        Exit Sub
    ElseIf TxtAge.Text = Empty Then
        TxtAge.SetFocus
        MsgBox "请输入员工年龄", , "错误信息"
        Exit Sub
    ElseIf TxtAddress.Text = Empty Then
        TxtAddress.SetFocus
        MsgBox "请输入员工地址", , "错误信息"
        Exit Sub
    End If
    CmdModify.Visible = True
    
    InfoData(1) = Trim(CStr(TxtCode.Text))
    InfoData(2) = Trim(CStr(TxtName.Text))
    InfoData(3) = Trim(CStr(TxtAge.Text))
    InfoData(4) = Trim(CStr(CmbDate.Text))
    InfoData(5) = Trim(CStr(TxtAddress.Text))
    
    FrmMain.MSFlxData.Col = 1
    For IntIndex = 2 To FrmMain.MSFlxData.Rows - 1
        FrmMain.MSFlxData.Row = IntIndex
        If FrmMain.MSFlxData.Text = InfoData(1) Then
            MsgBox "员工号码为 " & InfoData(1) & " 的员工已经存在!", vbInformation, "输入错误"
            TxtCode.SetFocus
            Exit Sub
        End If
    Next
    FrmMain.MSFlxData.AddItem Empty
    FrmMain.MSFlxData.Row = FrmMain.MSFlxData.Rows - 1
    FrmMain.MSFlxData.Col = 0
    FrmMain.MSFlxData.Text = FrmMain.MSFlxData.Rows - 3
    
    For IntIndex = 1 To 5
    FrmMain.MSFlxData.Col = IntIndex
    FrmMain.MSFlxData.Text = InfoData(IntIndex)
    Next
    FrmMain.Picdisplay.Visible = True
End Sub

Private Sub CmdClose_Click()
    FrmMain.SbStatusBar.Panels(1).Text = "就绪..."
    Unload Me
End Sub

Private Sub CmdModify_Click()
Dim i As Integer
    
    InfoData(1) = Trim(CStr(TxtCode.Text))
    InfoData(2) = Trim(CStr(TxtName.Text))
    InfoData(3) = Trim(CStr(TxtAge.Text))
    InfoData(4) = Trim(CStr(CmbDate.Text))
    InfoData(5) = Trim(CStr(TxtAddress.Text))
    
    FrmMain.MSFlxData.Col = 1
    For IntIndex = 2 To FrmMain.MSFlxData.Rows - 1
        FrmMain.MSFlxData.Row = IntIndex
        If FrmMain.MSFlxData.Text = InfoData(1) Then
            For i = 1 To 5
                FrmMain.MSFlxData.Col = i
                FrmMain.MSFlxData.Text = InfoData(i)
            Next
            Exit Sub
        End If
    Next
    MsgBox "没有找到员工号为 " & InfoData(1) & " 的员工信息", vbInformation, "输入错误"
End Sub
Private Sub CmdSave_Click()
Dim StrInsertSQL As String '定义一个执行 INSERT INTO 的字符串
    '输入数据的完整性检查,并使用TRIM函数进行数据过滤
    If Trim(CStr(TxtCode.Text)) = Empty Or Trim(CStr(TxtName.Text)) = Empty Or Trim(TxtAge.Text) = Empty Or Trim(CStr(CmbDate.Text)) = Empty _
        Or Trim(CStr(TxtAddress.Text)) = Empty Then
        MsgBox "请输入所有数据...", vbInformation, "数据不完整"
    Else
    '调用保存信息到文件中的函数,前面上机阶段的代码,请更改为注释进行屏蔽
    'call writeinfototext(Trim(TxtCode.Text),trim(txtname.text),trim(txtage.text),trim(cmbdate.text),trim(txtaddress.text))
    StrInsertSQL = "INSERT INTO EMPLIST (ENumber,EName,EAge,EDate,EAddress) VALUES ("
    StrInsertSQL = StrInsertSQL & "'" & Trim(CStr(TxtCode.Text)) & "',"
    StrInsertSQL = StrInsertSQL & "'" & Trim(CStr(TxtName.Text)) & "',"
    StrInsertSQL = StrInsertSQL & "'" & Trim(TxtAge.Text) & "',"
    StrInsertSQL = StrInsertSQL & "'" & (CmbDate.Text) & "',"
    StrInsertSQL = StrInsertSQL & "'" & Trim(CStr(TxtAddress.Text)) & "')"
    
        If ExecuteSQL(StrInsertSQL) = True Then
            Call CmdAdd_Click
            MsgBox "员工信息已经保存...", vbInformation, "保存成功"
            'Unload Me
        End If
    End If
End Sub

Private Sub Form_Load()
Dim IntIndex As Long
    For IntIndex = 2000 To 2005
        CmbDate.AddItem CStr(IntIndex) & "年"
    Next
    CmbDate.ListIndex = 0
    If FrmMain.MSFlxData.Rows = 3 Then
        CmdModify.Visible = False
    Else
        CmdModify.Visible = True
    End If
    
End Sub


⌨️ 快捷键说明

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