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

📄 frmmodifyemployee.frm

📁 数据库课程设计
💻 FRM
字号:
VERSION 5.00
Begin VB.Form frmModifyEmployee 
   Caption         =   "删改员工信息"
   ClientHeight    =   4290
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6840
   LinkTopic       =   "Form1"
   ScaleHeight     =   4290
   ScaleWidth      =   6840
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdCancel 
      Caption         =   "返回(&C)"
      Height          =   375
      Left            =   4200
      TabIndex        =   26
      Top             =   3720
      Width           =   1095
   End
   Begin VB.CommandButton cmdDelete 
      Caption         =   "删除(&D)"
      Height          =   375
      Left            =   2640
      TabIndex        =   25
      Top             =   3720
      Width           =   1215
   End
   Begin VB.CommandButton cmdUpdate 
      Caption         =   "修改(&U)"
      Height          =   375
      Left            =   1080
      TabIndex        =   24
      Top             =   3720
      Width           =   1215
   End
   Begin VB.Frame Frame1 
      Caption         =   "基本信息"
      Height          =   2295
      Index           =   1
      Left            =   120
      TabIndex        =   3
      Top             =   1200
      Width           =   6615
      Begin VB.TextBox txtEName 
         Enabled         =   0   'False
         Height          =   285
         Left            =   840
         TabIndex        =   13
         Text            =   "Text1"
         Top             =   360
         Width           =   1935
      End
      Begin VB.TextBox txtENo 
         Enabled         =   0   'False
         Height          =   285
         Left            =   4320
         TabIndex        =   12
         Text            =   "Text2"
         Top             =   360
         Width           =   2055
      End
      Begin VB.ComboBox cboDept 
         Height          =   315
         Left            =   840
         TabIndex        =   11
         Text            =   "Combo1"
         Top             =   720
         Width           =   1935
      End
      Begin VB.TextBox txtBirth 
         Enabled         =   0   'False
         Height          =   285
         Left            =   4320
         TabIndex        =   10
         Text            =   "Text3"
         Top             =   720
         Width           =   2055
      End
      Begin VB.ComboBox cboSex 
         Enabled         =   0   'False
         Height          =   315
         Left            =   840
         TabIndex        =   9
         Text            =   "Combo2"
         Top             =   1080
         Width           =   1935
      End
      Begin VB.TextBox txtBirthPlace 
         Enabled         =   0   'False
         Height          =   285
         Left            =   4320
         TabIndex        =   8
         Text            =   "Text4"
         Top             =   1080
         Width           =   2055
      End
      Begin VB.ComboBox cboDegree 
         Height          =   315
         Left            =   840
         TabIndex        =   7
         Text            =   "Combo3"
         Top             =   1440
         Width           =   1935
      End
      Begin VB.TextBox txtMajor 
         Height          =   285
         Left            =   4320
         TabIndex        =   6
         Text            =   "Text5"
         Top             =   1440
         Width           =   2055
      End
      Begin VB.TextBox txtTitle 
         Height          =   285
         Left            =   840
         TabIndex        =   5
         Text            =   "Text6"
         Top             =   1800
         Width           =   1935
      End
      Begin VB.TextBox txtdateIn 
         Enabled         =   0   'False
         Height          =   285
         Left            =   4320
         TabIndex        =   4
         Text            =   "Text7"
         Top             =   1800
         Width           =   2055
      End
      Begin VB.Label Label1 
         Caption         =   "姓名:"
         Height          =   255
         Index           =   1
         Left            =   240
         TabIndex        =   23
         Top             =   360
         Width           =   735
      End
      Begin VB.Label Label2 
         Caption         =   "员  工  号:"
         Height          =   255
         Left            =   3360
         TabIndex        =   22
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label3 
         Caption         =   "部门:"
         Height          =   255
         Left            =   240
         TabIndex        =   21
         Top             =   720
         Width           =   615
      End
      Begin VB.Label Label4 
         Caption         =   "出生日期:"
         Height          =   255
         Left            =   3360
         TabIndex        =   20
         Top             =   720
         Width           =   1095
      End
      Begin VB.Label Label5 
         Caption         =   "性别:"
         Height          =   255
         Left            =   240
         TabIndex        =   19
         Top             =   1080
         Width           =   615
      End
      Begin VB.Label Label6 
         Caption         =   "籍        贯:"
         Height          =   255
         Left            =   3360
         TabIndex        =   18
         Top             =   1080
         Width           =   975
      End
      Begin VB.Label Label7 
         Caption         =   "学历:"
         Height          =   255
         Left            =   240
         TabIndex        =   17
         Top             =   1440
         Width           =   615
      End
      Begin VB.Label Label8 
         Caption         =   "专        业:"
         Height          =   255
         Left            =   3360
         TabIndex        =   16
         Top             =   1440
         Width           =   975
      End
      Begin VB.Label Label9 
         Caption         =   "入职时间:"
         Height          =   255
         Left            =   3360
         TabIndex        =   15
         Top             =   1800
         Width           =   975
      End
      Begin VB.Label Label10 
         Caption         =   "职称:"
         Height          =   255
         Left            =   240
         TabIndex        =   14
         Top             =   1800
         Width           =   615
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "查询"
      Height          =   975
      Index           =   0
      Left            =   120
      TabIndex        =   0
      Top             =   120
      Width           =   6615
      Begin VB.ComboBox cboNo 
         Height          =   315
         Left            =   1440
         TabIndex        =   2
         Top             =   360
         Width           =   2535
      End
      Begin VB.Label Label1 
         Caption         =   "员工编号:"
         Height          =   375
         Index           =   0
         Left            =   480
         TabIndex        =   1
         Top             =   360
         Width           =   975
      End
   End
End
Attribute VB_Name = "frmModifyEmployee"
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 cboNo_Click()
getEmployeeInfo cboNo.Text

End Sub

Private Sub cmdCancel_Click()
Unload Me

End Sub

Private Sub cmdDelete_Click()
   Dim conn As ADODB.Connection
   
   sqlStr = "delete from employeeBasic where employeeNo='" & txtENo.Text & "'"
   On Error GoTo exitSub
   Set conn = New ADODB.Connection
   conn.Open connStr
   
   conn.Execute sqlStr
   MsgBox "成功删除数据!!"
   initForm
exitSub:
   
   conn.Close

End Sub

Private Sub cmdUpdate_Click()
   Dim conn As ADODB.Connection
   
   sqlStr = "Update employeeBasic set name='" & txtEName.Text _
          & "',department='" & cboDept.Text & "',degree='" _
          & cboDegree.Text & "',major='" & txtMajor.Text _
          & "',title='" & txtTitle.Text _
          & "' where employeeNo='" & txtENo.Text & "'"
   On Error GoTo exitSub
   Set conn = New ADODB.Connection
   conn.Open connStr
   
   conn.Execute sqlStr
   MsgBox "成功修改数据!!"
   initForm
exitSub:
   
   conn.Close

End Sub

Private Sub Form_Load()
initForm
End Sub

Sub initDept()
Dim rstDept As ADODB.Recordset

    '从数据库中读取所有部门名称并添加到组合列表框中
    '方便录入时进行选择
    sqlStr = "select departName from department"
    Set rstDept = ExecuteSQL(sqlStr, msgText)
    cboDept.Clear
    
    If Not rstDept.EOF Then
        
            Do While Not rstDept.EOF
                cboDept.AddItem Trim(rstDept.Fields(0))
                rstDept.MoveNext
            Loop
        
    Else
        MsgBox "没有部门信息,请添加部门!", vbOKOnly + vbExclamation, "警告"
        
        Exit Sub
    End If
    rstDept.Close

End Sub

Sub initForm()
   txtEName = ""
   txtENo = ""
   txtBirth = ""
   txtBirthPlace = ""
   txtMajor = ""
   txtTitle = ""
   txtdateIn = ""
   
   cboSex.Clear
   cboSex.AddItem "男"
   cboSex.AddItem "女"
   
   cboDegree.Clear
   cboDegree.AddItem "高中"
   cboDegree.AddItem "专科"
   cboDegree.AddItem "本科"
   cboDegree.AddItem "硕士研究生"
   cboDegree.AddItem "博士研究生"
   
   initDept
   initEmployeeNo
   
End Sub

Sub initEmployeeNo()
Dim rstEmployeeNo As ADODB.Recordset

    '从数据库中读取所有员工编号并添加到组合列表框中
    sqlStr = "select employeeNo from employeeBasic"
    Set rstEmployeeNo = ExecuteSQL(sqlStr, msgText)
    cboNo.Clear
    
    If Not rstEmployeeNo.EOF Then
        
            Do While Not rstEmployeeNo.EOF
                cboNo.AddItem Trim(rstEmployeeNo.Fields(0))
                rstEmployeeNo.MoveNext
            Loop
            cboNo.ListIndex = 0
        
    Else
        MsgBox "没有员工信息,请添加员工信息!", vbOKOnly + vbExclamation, "警告"
        
        Exit Sub
    End If
    rstEmployeeNo.Close

End Sub

Sub getEmployeeInfo(no As String)
Dim rstEmployee As ADODB.Recordset

    '从数据库中读取员工信息并添加到窗体中的输入框
    sqlStr = "select * from EmployeeBasic where employeeNo='" & no & "'"
    Set rstEmployee = ExecuteSQL(sqlStr, msgText)
    
    If Not rstEmployee.EOF Then
                txtEName.Text = Trim(rstEmployee.Fields("name"))
                txtENo.Text = Trim(rstEmployee.Fields("employeeNo"))
                cboDept.Text = Trim(rstEmployee.Fields("department"))
                cboSex.Text = Trim(rstEmployee.Fields("sex"))
                cboDegree.Text = Trim(rstEmployee.Fields("degree"))
                txtBirth.Text = Trim(rstEmployee.Fields("birthdate"))
                txtBirthPlace.Text = rstEmployee.Fields("birthplace")
                txtMajor.Text = rstEmployee.Fields("major")
                txtTitle.Text = rstEmployee.Fields("title")
                txtdateIn.Text = rstEmployee.Fields("dateStart")
    Else
        MsgBox "没找到符合条件的数据!", vbOKOnly + vbExclamation, "警告"
        
        Exit Sub
    End If
    rstEmployee.Close

End Sub

⌨️ 快捷键说明

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