员工培训管理系统 第9页
List1.Selected(i) = False
List1.ListIndex = -1
Next I
End Sub
5.5 设置界面及代码设计
5.5.1设置界面
系统的设置界面包括:成绩信息设置、课程基本信息设置、培训计划添加、培训效果评价、课程培训需求、员工信息设置等。
图5-5 设置界面
5.5.2设置界面代码设计
设置界面实现的代码设计如下(这里以员工基本信息设置为例,包括添加、修改、删除和简单查询等):
Option Explicit
Dim myModiStudent As New OpenRs '声明连接数据库的类
Dim Change As Boolean
Private Sub cboClass_Click()
txtStudentId.Text = ""
cmdDel.Enabled = False
End Sub
Private Sub cboClass_KeyPress(KeyAscii As Integer) ’部门设置回车确定
If KeyAscii = 13 Then
txtStudentId.SetFocus
Else
KeyAscii = 0
End If
End Sub
Private Sub cboSex_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
txtBirth.SetFocus
Else
KeyAscii = 0
End If
End Sub
Private Sub cmdAdd_Click() ’添加按钮的设置
If cmdAdd.Caption = "添加(&A)" Then
Call ClearText
cmdAdd.Caption = "取消(&C)"
Frame2.Enabled = True
Change = True
txtstudentName.SetFocus
cmdSave.Caption = "保存(&S)"
cmdSave.Enabled = True
cmdDel.Enabled = False
Else
Call ClearText
cmdAdd.Caption = "添加(&A)"
Frame2.Enabled = False
cmdSave.Caption = "保存(&S)"
cmdSave.Enabled = False
cmdDel.Enabled = False
End If
End Sub
Private Sub cmdDel_Click() ’删除按钮的设置
myModiStudent.rsDK1 "SELECT * FROM student_info where student_id='" & txtStudentId.Text & "'" ’把sql语句传递给函数
If MsgBox("确认要删除该记录吗?", vbQuestion + vbOKCancel, "删除记录") = vbOK Then
myModiStudent.rs1.Delete ’删除记录集
Else
Exit Sub
End If
Call ClearText
cmdSave.Caption = "保存(&S)"
cmdSave.Enabled = False
cmdDel.Enabled = False
myModiStudent.rsDK1 "SELECT * FROM student_info"
If myModiStudent.rs1.EOF Then ’如记录为空只显示列名
StudentGrid.Clear
StudentGrid.FormatString = " | 编号| 姓名|性别| 出生日期 |部门| 联系电话| 就职时间| 家庭住址 | 注释"
Else ’否则显示所有数据
Set StudentGrid.DataSource = myModiStudent.rs1
StudentGrid.FormatString = " | 编号| 姓名|性别| 出生日期 |部门| 联系电话| 就职时间| 家庭住址 | 注释" ’设置列表框的列头
End If
myModiStudent.rsDK1 "select * from student_info"
Set StudentGrid.DataSource = myModiStudent.rs1
StudentGrid.FormatString = " | 编号| 姓名|性别| 出生日期 |部门| 联系电话| 就职时间| 家庭住址 | 注释"
End Sub
Private Sub cmdExit_Click() ’退出设置
Unload Me
End Sub
Private Sub Cmdfind_Click() ’查询设置
Dim sql As String
Dim sql1 As String
Dim sql2 As String
If txtName.Text = Empty And txtClass.Text = Empty Then
MsgBox "请输入查询条件!", vbOKOnly + vbInformation, "员工信息设置"
Exit Sub
End If
If txtName.Text <> "" Then ’设置sql各分支查询语句
sql1 = "and student_name='" & txtName.Text & "'"
Else
sql1 = " "
End If
If txtClass.Text <> "" Then
sql2 = "and depart='" & txtClass.Text & "'"
Else
sql2 = " "
End If
sql = "SELECT * FROM student_info where 1=1" & sql1 & sql2 ’合并sql语句
myModiStudent.rsDK1 sql ’将sql语句赋给函数
If myModiStudent.rs1.EOF Then
StudentGrid.Clear
StudentGrid.FormatString = " | 编号| 姓名|性别| 出生日期 |部门| 联系电话| 就职时间| 家庭住址 | 注释"
MsgBox "没有找到符合条件的记录!", vbOKOnly + vbInformation, "提示"
txtName.Text = "" ’设置0记录显示
Else
Set StudentGrid.DataSource = myModiStudent.rs1
StudentGrid.FormatString = " | 编号| 姓名|性别| 出生日期 |部门| 联系电话| 就职时间| 家庭住址 | 注释"
Frame2.Enabled = True
Change = False ’找到记录把其值传给各输入控件
txtstudentName.Text = myModiStudent.rs1!student_name
cboClass.Text = myModiStudent.rs1!depart
txtStudentId.Text = myModiStudent.rs1!student_id
cboSex.Text = myModiStudent.rs1!student_sex
txtBirth.Text = Format(myModiStudent.rs1!Birth_date, "yyyy-mm-dd")
txtTel.Text = myModiStudent.rs1!tele_number
txtInDate.Text = Format(myModiStudent.rs1!in_date, "yyyy-mm-dd")
txtAdd.Text = myModiStudent.rs1!address
txtcomment.Text = myModiStudent.rs1!comment
cmdAdd.Enabled = True
cmdSave.Caption = "更新(&U)"
cmdSave.Enabled = True
cmdDel.Enabled = True
myModiStudent.rsDK1 sql
Set StudentGrid.DataSource = myModiStudent.rs1
StudentGrid.FormatString = " | 编号| 姓名|性别| 出生日期 |部门| 联系电话| 就职时间| 家庭住址 | 注释"
End If
End Sub
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>