员工培训管理系统 第11页
End Sub
Private Sub txtcomment_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then
KeyAscii = 0
ElseIf KeyAscii = 13 Then
Call Cmdsave_Click
End If
End Sub
Private Sub txtInDate_GotFocus()
If cmdSave.Caption = "保存(&S)" Then
txtInDate.Text = Format(Date, "yyyy/mm/dd")
End If
End Sub
Private Sub txtInDate_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtAdd.SetFocus
End Sub
Private Sub txtInDate_LostFocus()
txtInDate.Text = Format(txtInDate.Text, "yyyy/mm/dd")
End Sub
Private Sub txtName_KeyPress(KeyAscii As Integer)
If KeyAscii = 39 Then KeyAscii = 0
End Sub
Private Sub txtStudentId_GotFocus()
If cboClass.Text = Empty Then
MsgBox "请选择部门.", vbInformation, "提示"
cboClass.SetFocus
Exit Sub
End If
End Sub
Private Sub txtStudentId_KeyPress(KeyAscii As Integer)
If KeyAscii >= 33 Then
If KeyAscii <= vbKey9 And KeyAscii >= vbKey0 Then
Else
KeyAscii = 0
MsgBox "请输入数字!"
End If
End If
End Sub
Private Sub txtstudentName_Change()
cmdDel.Enabled = False
End Sub
Private Sub txtstudentName_KeyPress(KeyAscii As Integer)
If (KeyAscii >= 33 And KeyAscii <= 64) Or (KeyAscii >= 91 And KeyAscii <= 96) Or (KeyAscii >= 123 And KeyAscii <= 127) Then KeyAscii = 0
If KeyAscii = 13 Then cboClass.SetFocus
End Sub
Private Sub txtTel_KeyPress(KeyAscii As Integer)
If KeyAscii >= 32 And KeyAscii <= 34 Or KeyAscii >= 36 And KeyAscii <= 44 Or KeyAscii > 45 And KeyAscii < 48 Or KeyAscii >= 58 And KeyAscii <= 127 Then KeyAscii = 0
If KeyAscii = 13 Then txtInDate.SetFocus
End Sub
Public Sub ClearText() ’清空子函数
txtstudentName.Text = ""
cboClass.Text = ""
txtStudentId.Text = ""
txtBirth.Text = "____-__-__" ’日期格式
txtTel.Text = ""
txtInDate.Text = "____-__-__"
txtAdd.Text = ""
txtcomment.Text = ""
End Sub
Private Sub Form_Load() ’载入表时清空输入框,显示数据列表
Set myModiStudent = New OpenRs
StudentGrid.FormatString = " | 编号| 姓名|性别| 出生日期 |部门| 联系电话| 就职时间| 家庭住址 | 注释"
myModiStudent.rsDK1 "select * from student_info"
Set StudentGrid.DataSource = myModiStudent.rs1
StudentGrid.FormatString = " | 编号| 姓名|性别| 出生日期 |部门| 联系电话| 就职时间| 家庭住址 | 注释"
Call ClearText
txtstudentName.SetFocus
cmdAdd.Enabled = True
End Sub
5.6 查询界面及代码设计
5.6.1查询界面
系统的查询界面包括:成绩信息查询、课程信息查询、培训计划查询、员工信息查询等。
图6-6 查询界面
5.6.2查询界面代码设计
系统查询界面的代码设计如下(这里以成绩信息查询为例):
Dim ResultQuery As OpenRs ’ 定义函数和sql查询语句
Dim sql As String
Dim sql1 As String
Dim sql2 As String
Dim sql3 As String
Dim sql4 As String
Dim sql5 As String
Private Sub cboClassno_KeyPress(KeyAscii As Integer) ’课程编号的输入范围
KeyAscii = Asc(UCase(Chr(KeyAscii)))
If Not ((Chr(KeyAscii) <= "Z" And Chr(KeyAscii) >= "A") Or (Chr(KeyAscii) <= "9" And Chr(KeyAscii) >= "0") Or KeyAscii = 8) Then
KeyAscii = 0
End If
End Sub
Private Sub cmdExit_Click() ’退出按钮设置
Unload Me
End Sub
Private Sub CmdQuery_Click() ’查询按钮设置
sql = "select student_info.student_id,student_info.student_name,result_info.course_no,result_info.course_name,result_info.exam_no,result_info.result from result_info inner join student_info on result_info.student_id=result_info.student_id inner join course_info on result_info.course_no=course_info.course_no where 1=1" ’用sql语句连接几个相关表
If txtStudentId.Text <> "" Then ’以下设置各分支语句
sql1 = "and student_info.student_id='" & txtStudentId.Text & "'"
Else
sql1 = " "
End If
If txtStudentName.Text <> "" Then
sql2 = "and student_info.student_name='" & txtStudentName.Text & "'"
Else
sql2 = " "
End If
If cboResult.Text <> "" Then
sql3 = "and result_info.result" & cboResult.Text & ""
Else
sql3 = " "
<< 上一页 [11] [12] [13] [14] 下一页