VB学生学籍管理系统(论文+源程序) 第10页
Public Sub ListView_DblClick()
On Error Resume Next
If ListView.SelectedItem.Selected Then
SelectNum = ListView.SelectedItem.Text
If SelectNum <> "" Then
'显示出该生全部信息表单
Call frmstuinfo.LoadStuInfo(SelectNum)
Else
Exit Sub
End If
End If
End Sub
在frmstuinfo的代码窗口中添入以下代码用来显示该学生的详细资料。
Public Sub LoadStuInfo(StuNum As String)
sqlstr = "select * from StuInfo where SID='" & StuNum & "'"
rs.Open sqlstr, con, 1, 1
StuInfo(0).Caption = rs.Fields("SID")
StuInfo(1).Caption = rs.Fields("SName")
StuInfo(2).Caption = rs.Fields("SGender")
StuInfo(3).Caption = rs.Fields("SZhengzhi")
StuInfo(4).Caption = rs.Fields("SPlace")
StuInfo(5).Caption = rs.Fields("SMinzu")
StuInfo(6).Caption = rs.Fields("SBirthday")
StuInfo(7).Caption = rs.Fields("SDormitory")
StuInfo(8).Caption = rs.Fields("SAddress")
StuInfo(9).Caption = rs.Fields("SCode")
StuInfo(10).Caption = rs.Fields("STel")
StuInfo(11).Caption = rs.Fields("SRemark")
rs.Close: Set rs = Nothing
Me.Show 1
End Sub
3.3.6 添加/修改学生信息窗体(frmAddstu)
该窗体运行时界面如图3.7所示
图3.7 添加/修改学生信息界面
当窗体加载时,首先判断是修改学生资料还是添加新的学生资料,如果学号为“00000000”,则为添加新的学生资料,反之则为修改学生资料。如果为修改资料,则以学生的学号为关键字将该学生的信息加载到该窗体的对应文本框,同时将该学号框(EditStu(0))的Enable属性设置为False。如果为添加新的学生资料,则将学号的前6位置为该班级的ID,并将学号输入框的SelStart属性设为6。根据以上设计,在Form_Load中添加如下代码:
Private Sub Form_Load()
'确定添加或者修改,保存数据
Combo1.Clear
Combo1.AddItem "男"
Combo1.AddItem "女"
Combo1.ListIndex = 0
Combo2.Clear
Combo2.AddItem ""
Combo2.AddItem "团员"
Combo2.AddItem "党员"
Combo2.AddItem "预备党员"
Combo2.ListIndex = 1Combo3.Clear
Combo3.AddItem "汉族"
Combo3.AddItem "瑶族"
Combo3.AddItem "土家族"
Combo3.AddItem "侗族"
Combo3.AddItem "白族"
Combo3.AddItem "苗族"
Combo3.AddItem "回族"
Combo3.AddItem "壮族"
Combo3.ListIndex = 0
If EditNum = "00000000" Then
Me.Caption = "添加学生资料(班级:" & classid & ")"
Command1.Caption = "添加(&A)"
EditStu(0).Text = classid
EditStu(0).SelStart = 6
Else
Me.Caption = "修改学号为" & EditNum & "的学生资料"
EditStu(0).Enabled = False
Command1.Caption = "修改(&M)"
Dim rs As New ADODB.Recordset, sqlstr As String
sqlstr = "select * from StuInfo where SID='" & EditNum & "'"
rs.Open sqlstr, con
'把数据代入文本框中
EditStu(0).Text = rs.Fields("SID")
EditStu(1).Text = rs.Fields("SName")
EditStu(2).Text = rs.Fields("SBirthday")
EditStu(3).Text = rs.Fields("SPlace")
EditStu(4).Text = rs.Fields("SAddress")
EditStu(5).Text = rs.Fields("SCode")
EditStu(6).Text = rs.Fields("STel")
EditStu(7).Text = rs.Fields("SDormitory")
EditStu(8).Text = rs.Fields("SRemark")
If rs.Fields("SGender") = "男" Then
Combo1.ListIndex = 0
ElseIf rs.Fields("SGender") = "女" Then
Combo1.ListIndex = 1
End If
If rs.Fields("SZhengzhi") = "" Then
Combo2.ListIndex = 0
ElseIf rs.Fields("SZhengzhi") = "团员" Then
Combo2.ListIndex = 1
ElseIf rs.Fields("SZhengzhi") = "党员" Then
Combo2.ListIndex = 2
ElseIf rs.Fields("SZhengzhi") = "预备党员" Then
Combo2.ListIndex = 3
End If
Select Case rs.Fields("SMinzu")
Case "汉族": Combo3.ListIndex = 0
Case "瑶族": Combo3.ListIndex = 1
Case "土家族": Combo3.ListIndex = 2
Case "侗族": Combo3.ListIndex = 3
Case "白族": Combo3.ListIndex = 4
Case "苗族": Combo3.ListIndex = 5
Case "回族": Combo3.ListIndex = 6
Case "壮族": Combo3.ListIndex = 7
End Select
rs.Close: Set rs = NothingEnd If
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] ... 下一页 >>
VB学生学籍管理系统(论文+源程序) 第10页下载如图片无法显示或论文不完整,请联系qq752018766