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

📄 frmaddemployee.frm

📁 数据库课程设计
💻 FRM
📖 第 1 页 / 共 2 页
字号:
         TabIndex        =   6
         Top             =   720
         Width           =   615
      End
      Begin VB.Label Label2 
         Caption         =   "员  工  号:"
         Height          =   255
         Left            =   3360
         TabIndex        =   4
         Top             =   360
         Width           =   975
      End
      Begin VB.Label Label1 
         Caption         =   "姓名:"
         Height          =   255
         Left            =   240
         TabIndex        =   2
         Top             =   360
         Width           =   735
      End
   End
End
Attribute VB_Name = "frmAddEmployee"
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 cmdAdd_Click()

Dim j As Integer

fgHistory.Rows = fgHistory.Rows + 1

    
       fgHistory.Row = fgHistory.Rows - 1
       For j = 0 To fgHistory.Cols - 1
       
        fgHistory.Col = j '设置当前为列为第j列
        fgHistory.CellAlignment = 4  '每列内容居中显示
    
        
        Select Case j
            Case 0
               fgHistory.Text = txtStart.Text
            Case 1
               fgHistory.Text = txtEnd.Text
            Case 2
               fgHistory.Text = txtCorpName.Text
            Case 3
               fgHistory.Text = txtPosition.Text
            Case 4
               fgHistory.Text = txtResumeMemo.Text
        End Select
      Next j
    

End Sub

Private Sub cmdCancel_Click()
Unload Me
End Sub


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


Sub initResume()
   txtStart = ""
   txtEnd = ""
   txtCorpName = ""
   txtPosition = ""
   txtResumeMemo = ""
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
            cboDept.ListIndex = 0
        
    Else
        MsgBox "没有部门信息,请添加部门!", vbOKOnly + vbExclamation, "警告"
        
        Exit Sub
    End If
    rstDept.Close

End Sub

Sub initHistory()

    Dim i As Integer
    
    fgHistory.Rows = 1
    fgHistory.Cols = 5
    
  
    '设定行高
    For i = 0 To fgHistory.Rows - 1
       fgHistory.RowHeight(i) = 280
    Next i
    
    '设定列的属性
    fgHistory.Row = 0
    
    For i = 0 To fgHistory.Cols - 1
       fgHistory.Col = i  '指定当前列为第i列
       fgHistory.FixedAlignment(i) = 4  '每列内容居中显示
       Select Case i
           Case 0
              fgHistory.ColWidth(i) = 1100  '设定列宽
              fgHistory.Text = "起始时间"
           Case 1
              fgHistory.ColWidth(i) = 1100  '设定列宽
              fgHistory.Text = "终止时间"
           Case 2
              fgHistory.ColWidth(i) = 2200  '设定列宽
              fgHistory.Text = "单位名称"
           Case 3
              fgHistory.ColWidth(i) = 900  '设定列宽
              fgHistory.Text = "职务"
           Case 4
              fgHistory.ColWidth(i) = 1000  '设定列宽
              fgHistory.Text = "备注"
        End Select
           
    Next i

End Sub


Private Sub cmdOK_Click()

'保存员工基本信息
saveBasicInfo

'保存员工履历信息
saveJobHistory

'初始化输入框,便于继续添加员工信息
initForm

End Sub

Private Sub Form_Load()
   initForm
End Sub

Sub saveBasicInfo()
   Dim rstEmployee As ADODB.Recordset
   Dim employeeName As String
   Dim employeeNo As String
   Dim department As String
   Dim dateBirth As String
   Dim sex As String
   Dim birthplace As String
   Dim degree As String
   Dim major As String
   Dim title As String
   Dim dateIn As String
   
   
   '获取数据
   employeeName = Trim(txtEName.Text)
   employeeNo = Trim(txtENo.Text)
   department = Trim(cboDept.Text)
   dateBirth = Trim(txtBirth.Text)
   sex = cboSex.Text
   birthplace = Trim(txtBirthPlace.Text)
   degree = cboDegree.Text
   major = Trim(txtMajor.Text)
   title = Trim(txtTitle.Text)
   dateIn = Trim(txtdateIn.Text)
   
   If employeeName = "" Or employeeNo = "" Then
   
      MsgBox "请将信息补充完整", vbOKOnly + vbExclamation, "警告"

      Exit Sub
   
   End If
     
   
    '添加新记录
    sqlStr = "select * from employeeBasic"
    Set rstEmployee = ExecuteSQL(sqlStr, msgText)
    rstEmployee.addNew
    rstEmployee.Fields("employeeNo") = employeeNo
    rstEmployee.Fields("name") = employeeName
    rstEmployee.Fields("department") = department
    rstEmployee.Fields("sex") = sex
    rstEmployee.Fields("birthdate") = dateBirth
    rstEmployee.Fields("birthplace") = birthplace
    rstEmployee.Fields("degree") = degree
    rstEmployee.Fields("major") = major
    rstEmployee.Fields("dateStart") = dateIn
    rstEmployee.Fields("title") = title
    
    rstEmployee.update
    rstEmployee.Close
        
    MsgBox "员工基本信息添加完成!", vbOKOnly + vbExclamation, "警告"
    

End Sub

Sub saveJobHistory()
    Dim i, j As Integer
    Dim rstHistory As ADODB.Recordset
    
    i = 0: j = 0
    sqlStr = "select * from employeeJobs"
    Set rstHistory = ExecuteSQL(sqlStr, msgText)

    If fgHistory.Rows > 1 Then
        '取出表中列出的数据
        For i = 1 To fgHistory.Rows - 1
           fgHistory.Row = i
           
           '将数据插入数据库
           rstHistory.addNew
           rstHistory.Fields("employeeNo") = txtENo.Text
           
           '获取列表中每列的数据
           For j = 0 To fgHistory.Cols - 1
           fgHistory.Col = j
           Select Case j
           Case 0:
              rstHistory.Fields("startDate") = fgHistory.Text
           Case 1:
              rstHistory.Fields("endDate") = fgHistory.Text
           Case 2:
              rstHistory.Fields("companyName") = fgHistory.Text
           Case 3:
              rstHistory.Fields("position") = fgHistory.Text
           Case 4:
              rstHistory.Fields("memo") = fgHistory.Text
           End Select
           Next j
           rstHistory.update
           
        Next i
    End If
    rstHistory.Close
    
    MsgBox "员工履历信息添加完成!", vbOKOnly + vbExclamation, "警告"
   
End Sub

⌨️ 快捷键说明

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