📄 frmstudent.frm
字号:
VERSION 5.00
Begin VB.Form frmstudent
BackColor = &H80000014&
Caption = "学籍管理"
ClientHeight = 4560
ClientLeft = 60
ClientTop = 450
ClientWidth = 6180
ForeColor = &H80000001&
LinkTopic = "Form1"
ScaleHeight = 4560
ScaleWidth = 6180
StartUpPosition = 2 '屏幕中心
Begin VB.ComboBox cmbdate
Height = 315
Left = 960
TabIndex = 26
Top = 1560
Width = 1575
End
Begin VB.ComboBox cmbId
Height = 315
Left = 960
TabIndex = 25
Top = 120
Width = 1455
End
Begin VB.ComboBox cmbdepar
Height = 315
Left = 960
TabIndex = 24
Top = 2040
Width = 1695
End
Begin VB.ComboBox cmbSex
Height = 315
Left = 960
TabIndex = 23
Top = 1080
Width = 855
End
Begin VB.CommandButton cmdchange
Caption = "修改"
Height = 375
Left = 3840
TabIndex = 22
Top = 3720
Width = 855
End
Begin VB.CommandButton cmdCancel
Caption = "删除"
Height = 375
Left = 2880
TabIndex = 21
Top = 3720
Width = 975
End
Begin VB.CommandButton cmdQuery
Caption = "查询"
Height = 375
Left = 1800
TabIndex = 20
Top = 3720
Width = 1095
End
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 735
Left = -480
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 3360
Visible = 0 'False
Width = 1260
End
Begin VB.CommandButton cmdexit
Caption = "取消"
Height = 375
Left = 4680
TabIndex = 19
Top = 3720
Width = 1215
End
Begin VB.CommandButton cmdAdd
Caption = "添加"
Height = 375
Left = 720
TabIndex = 18
Top = 3720
Width = 1095
End
Begin VB.TextBox txtAge
Height = 375
Left = 3480
TabIndex = 17
Top = 2160
Width = 615
End
Begin VB.TextBox txtClass
Height = 375
Left = 3480
TabIndex = 16
Top = 1560
Width = 855
End
Begin VB.TextBox txtTele
Height = 375
Left = 3480
TabIndex = 15
Top = 960
Width = 1575
End
Begin VB.TextBox txtCode
Height = 285
Left = 3480
TabIndex = 14
Top = 480
Width = 1935
End
Begin VB.TextBox txtAdress
Height = 375
Left = 3480
TabIndex = 13
Top = 0
Width = 2415
End
Begin VB.TextBox txtName
Height = 375
Left = 960
TabIndex = 12
Top = 600
Width = 1455
End
Begin VB.TextBox txtInfo
Height = 855
Left = 960
TabIndex = 11
Top = 2640
Width = 3975
End
Begin VB.Label Label11
Caption = "电话号码"
Height = 255
Left = 2520
TabIndex = 10
Top = 960
Width = 855
End
Begin VB.Label Label10
Caption = "年龄"
Height = 255
Left = 2760
TabIndex = 9
Top = 2160
Width = 615
End
Begin VB.Label Label9
Caption = "班级"
Height = 255
Left = 2760
TabIndex = 8
Top = 1560
Width = 495
End
Begin VB.Label Label8
Caption = "简介"
Height = 375
Left = 360
TabIndex = 7
Top = 2760
Width = 735
End
Begin VB.Label Label7
Caption = "身份证号码"
Height = 255
Left = 2400
TabIndex = 6
Top = 480
Width = 975
End
Begin VB.Label Label6
Caption = "地址"
Height = 255
Left = 2760
TabIndex = 5
Top = 120
Width = 495
End
Begin VB.Label Label5
Caption = "系别"
Height = 255
Left = 360
TabIndex = 4
Top = 2160
Width = 495
End
Begin VB.Label Label4
Caption = "入校日期"
Height = 255
Left = 120
TabIndex = 3
Top = 1680
Width = 735
End
Begin VB.Label Label3
Caption = "性别"
Height = 255
Left = 360
TabIndex = 2
Top = 1200
Width = 375
End
Begin VB.Label Label2
Caption = "姓名"
Height = 255
Left = 360
TabIndex = 1
Top = 720
Width = 495
End
Begin VB.Label Label1
Caption = "学号"
Height = 255
Left = 360
TabIndex = 0
Top = 240
Width = 495
End
End
Attribute VB_Name = "frmstudent"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub cmdAdd_Click()
If flag = 2 Then
MsgBox "您没有权限进行添加学籍!退出操作!!"
cmbId.Text = ""
txtName.Text = ""
cmbSex.Text = ""
cmbdate.Text = ""
cmbdepar.Text = ""
txtAdress.Text = ""
txtCode.Text = ""
txtTele.Text = ""
txtClass.Text = ""
txtAge.Text = ""
txtInfo.Text = ""
Exit Sub
End If
'判断基本信息不能为空!!
If cmbId = "" Then
MsgBox "学号不能为空,请重新输入!!!"
cmbId.SetFocus
Exit Sub
End If
If txtName = "" Then
MsgBox "姓名不能为空,请重新输入!!"
txtName.SetFocus
Exit Sub
End If
If cmbSex = "" Then
MsgBox "性别不能为空!!"
cmbSex.SetFocus
Exit Sub
End If
If cmbdepar = "" Then
MsgBox "系别不能为空!!"
cmbdepar.SetFocus
Exit Sub
End If
If txtClass = "" Then
MsgBox "班级不能为空!!!"
txtClass.SetFocus
Exit Sub
End If
If txtAge.Text = "" Then
MsgBox "年龄不能为空!!!"
txtAge.SetFocus
Exit Sub
End If
If txtTele.Text = "" Then
MsgBox "电话号码不能为空!!!"
txtTele.SetFocus
Exit Sub
End If
If cmbdate.Text = "" Then
MsgBox "入学日期不能为空!!!"
cmbdate.SetFocus
Exit Sub
End If
If txtInfo.Text = "" Then
MsgBox "简介不能为空!!!"
Exit Sub
End If
If txtAdress.Text = "" Then
MsgBox "地址不能为空!!!"
Exit Sub
End If
If txtCode.Text = "" Then
MsgBox "身份证不能为空!!!"
txtCode.SetFocus
Exit Sub
End If
Data1.Recordset.MoveFirst
While Data1.Recordset.Fields("id") <> cmbId.Text
Data1.Recordset.MoveNext
If Data1.Recordset.EOF Then
GoTo a
End If
Wend
If Data1.Recordset.Fields("id") = cmbId.Text Then
MsgBox "该学生已经添加!!!"
cmbId.Text = ""
txtName.Text = ""
cmbSex.Text = ""
cmbdate.Text = ""
cmbdepar.Text = ""
txtAdress.Text = ""
txtCode.Text = ""
txtTele.Text = ""
txtClass.Text = ""
txtAge.Text = ""
txtInfo.Text = ""
cmbId.SetFocus
Exit Sub
End If
Data1.Recordset.MoveLast
a: '添加学籍
Data1.Recordset.AddNew
Data1.Recordset.Fields("id") = cmbId.Text
Data1.Recordset.Fields("name") = txtName.Text
Data1.Recordset.Fields("sex") = cmbSex.Text
Data1.Recordset.Fields("ru_Date") = cmbdate.Text
Data1.Recordset.Fields("department") = cmbdepar.Text
Data1.Recordset.Fields("adress") = txtAdress.Text
Data1.Recordset.Fields("card_Id") = txtCode.Text
Data1.Recordset.Fields("tele_Num") = txtTele.Text
Data1.Recordset.Fields("class") = txtClass.Text
Data1.Recordset.Fields("age") = txtAge.Text
Data1.Recordset.Fields("introduce") = txtInfo.Text
Data1.Recordset.Update
MsgBox "添加成功!!!!"
cmbId.Text = ""
txtName.Text = ""
cmbSex.Text = ""
cmbdate.Text = ""
cmbdepar.Text = ""
txtAdress.Text = ""
txtCode.Text = ""
txtTele.Text = ""
txtClass.Text = ""
txtAge.Text = ""
txtInfo.Text = ""
cmbId.SetFocus
End Sub
Private Sub cmdcancel_Click()
If flag = 2 Then
MsgBox "您没有权限进行删除学籍!退出操作!!"
cmbId.Text = ""
txtName.Text = ""
cmbSex.Text = ""
cmbdate.Text = ""
cmbdepar.Text = ""
txtAdress.Text = ""
txtCode.Text = ""
txtTele.Text = ""
txtClass.Text = ""
txtAge.Text = ""
txtInfo.Text = ""
Exit Sub
End If
'提示要删除学籍的学号
If cmbId = "" Then
MsgBox "请输入要删除学籍的学号!!!"
cmbId.SetFocus
Exit Sub
End If
'查找要删除的学籍
Data1.Recordset.MoveFirst
While Data1.Recordset.Fields("id") <> cmbId.Text
Data1.Recordset.MoveNext
If Data1.Recordset.EOF Then
MsgBox "您要删除的学籍可能已经删除!!!"
cmbId.SetFocus
cmbId = ""
Exit Sub
End If
Wend
Data1.Recordset.Delete
MsgBox "删除成功!!"
cmbId = ""
txtName.Text = ""
cmbSex.Text = ""
cmbdate.Text = ""
cmbdepar.Text = ""
txtAdress.Text = ""
txtCode.Text = ""
txtTele.Text = ""
txtClass.Text = ""
txtAge.Text = ""
txtInfo.Text = ""
cmbId.SetFocus
End Sub
'修改学籍
Private Sub cmdChange_Click()
If flag = 2 Then
MsgBox "您没有权限进行修改学籍!退出操作!!"
cmbId.Text = ""
txtName.Text = ""
cmbSex.Text = ""
cmbdate.Text = ""
cmbdepar.Text = ""
txtAdress.Text = ""
txtCode.Text = ""
txtTele.Text = ""
txtClass.Text = ""
txtAge.Text = ""
txtInfo.Text = ""
Exit Sub
End If
If cmbId = "" Or txtName.Text = "" Or cmbSex.Text = "" Or cmbdate.Text = "" Or cmbdepar.Text = "" Then
MsgBox "请先查找出您要修改的记录!"
Exit Sub
End If
'修改记录
Data1.Recordset.Edit
Data1.Recordset.Fields("id") = cmbId.Text
Data1.Recordset.Fields("name") = txtName.Text
Data1.Recordset.Fields("sex") = cmbSex.Text
Data1.Recordset.Fields("ru_Date") = cmbdate.Text
Data1.Recordset.Fields("department") = cmbdepar.Text
Data1.Recordset.Fields("adress") = txtAdress.Text
Data1.Recordset.Fields("card_Id") = txtCode.Text
Data1.Recordset.Fields("tele_Num") = txtTele.Text
Data1.Recordset.Fields("class") = txtClass.Text
Data1.Recordset.Fields("age") = txtAge.Text
Data1.Recordset.Fields("introduce") = txtInfo.Text
Data1.Recordset.Update
MsgBox "修改成功,请确定!!!"
cmbId.Text = ""
txtName.Text = ""
cmbSex.Text = ""
cmbdate.Text = ""
cmbdepar.Text = ""
txtAdress.Text = ""
txtCode.Text = ""
txtTele.Text = ""
txtClass.Text = ""
txtAge.Text = ""
txtInfo.Text = ""
cmbId.SetFocus
End Sub
Private Sub cmdexit_Click()
Unload frmstudent
End Sub
'查询学籍
Private Sub cmdQuery_Click()
If cmbId = "" Then
MsgBox "查询学籍时,学号不能为空!!!"
cmbId.SetFocus
Exit Sub
End If
Data1.Recordset.MoveFirst
While Data1.Recordset.Fields("id") <> cmbId.Text
Data1.Recordset.MoveNext
If Data1.Recordset.EOF Then
MsgBox "该学生不在该表上,请重新输入学号!!"
cmbId.Text = ""
txtName.Text = ""
cmbSex.Text = ""
cmbdate.Text = ""
cmbdepar.Text = ""
txtAdress.Text = ""
txtCode.Text = ""
txtTele.Text = ""
txtClass.Text = ""
txtAge.Text = ""
txtInfo.Text = ""
cmbId.SetFocus
Exit Sub
End If
Wend
cmbId = Data1.Recordset.Fields("id")
txtName = Data1.Recordset.Fields("name")
cmbSex = Data1.Recordset.Fields("sex")
cmbdate = Data1.Recordset.Fields("ru_Date")
cmbdepar = Data1.Recordset.Fields("department")
txtAdress = Data1.Recordset.Fields("adress")
txtCode = Data1.Recordset.Fields("card_Id")
txtTele = Data1.Recordset.Fields("tele_Num")
txtClass = Data1.Recordset.Fields("class")
txtAge = Data1.Recordset.Fields("age")
txtInfo = Data1.Recordset.Fields("introduce")
MsgBox "查询成功!请确定!!"
cmbId.SetFocus
End Sub
Private Sub Form_Load()
If flag = 2 Then
Label1.ToolTipText = "您无权添加、删除、修改!"
cmbId.ToolTipText = "您无权添加、删除、修改!"
End If
cmbdate.AddItem "2003-09-08"
cmbdate.AddItem "2003-09-09"
cmbId.AddItem "200326140227"
cmbdepar.AddItem "计算机系"
cmbdepar.AddItem "外国语学院"
cmbdepar.AddItem "文学院"
cmbdepar.AddItem "体育系"
cmbdepar.AddItem "化学系"
cmbdepar.AddItem "物电系"
cmbdepar.AddItem "数学系"
cmbdepar.AddItem "生物系"
cmbdepar.AddItem "贸经系"
cmbdepar.AddItem "艺术学院"
cmbdepar.AddItem "教育技术系"
cmbSex.AddItem "男"
cmbSex.AddItem "女"
Data1.Connect = "Access"
Data1.DatabaseName = "" & App.Path & "\db1.mdb"
Data1.RecordSource = "student"
Data1.Refresh
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -