📄 main.frm
字号:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form main
Caption = "学生信息 Powered by Heheboy.2004"
ClientHeight = 5925
ClientLeft = 1830
ClientTop = 1815
ClientWidth = 7575
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 5925
ScaleWidth = 7575
Begin VB.Data Data_stu
Caption = "学生信息"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 495
Left = 5400
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 5160
Width = 2055
End
Begin VB.Frame Frame4
Caption = "其它表项:"
Height = 855
Left = 120
TabIndex = 15
Top = 4920
Width = 5055
Begin VB.CommandButton Command_search
Caption = "查 询 项"
Height = 375
Left = 3480
TabIndex = 26
Top = 300
Width = 1215
End
Begin VB.CommandButton Command_course
Caption = "课 程 表"
Height = 375
Left = 360
TabIndex = 25
Top = 300
Width = 1215
End
Begin VB.CommandButton Command_select
Caption = "选 课 表"
Height = 375
Left = 1920
TabIndex = 24
Top = 300
Width = 1215
End
End
Begin VB.Frame Frame3
Height = 1095
Left = 6360
TabIndex = 22
Top = 3720
Width = 1095
Begin VB.CommandButton end
Caption = "EXIT"
Height = 735
Left = 120
TabIndex = 23
Top = 240
Width = 855
End
End
Begin VB.Frame Frame1
Height = 3375
Left = 6360
TabIndex = 16
Top = 120
Width = 1095
Begin VB.CommandButton del_stu
Caption = "删 除"
Height = 495
Left = 120
TabIndex = 21
Top = 2640
Width = 855
End
Begin VB.CommandButton cancal_stu
Caption = "取 消"
Height = 495
Left = 120
TabIndex = 20
Top = 2040
Width = 855
End
Begin VB.CommandButton save_stu
Caption = "保 存"
Height = 495
Left = 120
TabIndex = 19
Top = 1440
Width = 855
End
Begin VB.CommandButton updata_stu
Caption = "修 改"
Height = 495
Left = 120
TabIndex = 18
Top = 840
Width = 855
End
Begin VB.CommandButton add_stu
Caption = "添 加"
Height = 495
Left = 120
TabIndex = 17
Top = 240
Width = 855
End
End
Begin VB.Frame Frame2
Height = 4695
Left = 120
TabIndex = 0
Top = 120
Width = 6015
Begin VB.TextBox Text1
DataField = "学号"
DataSource = "Data_stu"
Height = 375
Left = 1200
TabIndex = 8
Top = 360
Width = 2055
End
Begin VB.PictureBox Picture1
DataField = "照片"
DataSource = "Data_stu"
Height = 2055
Left = 3600
ScaleHeight = 1995
ScaleWidth = 1875
TabIndex = 7
Top = 480
Width = 1935
End
Begin VB.CommandButton Command1
Caption = "更改照片"
Height = 375
Left = 4080
TabIndex = 6
Top = 2760
Width = 1095
End
Begin VB.TextBox Text2
DataField = "姓名"
DataSource = "Data_stu"
Height = 375
Left = 1200
TabIndex = 5
Top = 960
Width = 2055
End
Begin VB.TextBox Text3
DataField = "系别"
DataSource = "Data_stu"
Height = 375
Left = 1200
TabIndex = 4
Top = 1560
Width = 2055
End
Begin VB.TextBox Text4
DataField = "住址"
DataSource = "Data_stu"
Height = 375
Left = 1200
TabIndex = 3
Top = 2160
Width = 2055
End
Begin VB.TextBox Text5
DataField = "电话"
DataSource = "Data_stu"
Height = 375
Left = 1200
TabIndex = 2
Top = 2760
Width = 2055
End
Begin VB.TextBox Text6
DataField = "备注"
DataSource = "Data_stu"
Height = 855
Left = 1200
TabIndex = 1
Top = 3480
Width = 4335
End
Begin MSComDlg.CommonDialog ofile
Left = 3480
Top = 2760
_ExtentX = 847
_ExtentY = 847
_Version = 393216
End
Begin VB.Label Label1
Caption = "学 号:"
Height = 255
Left = 360
TabIndex = 14
Top = 480
Width = 855
End
Begin VB.Label Label2
Caption = "姓 名:"
Height = 255
Left = 360
TabIndex = 13
Top = 1080
Width = 975
End
Begin VB.Label Label3
Caption = "院 系:"
Height = 375
Left = 360
TabIndex = 12
Top = 1680
Width = 735
End
Begin VB.Label Label4
Caption = "住 址:"
Height = 375
Left = 360
TabIndex = 11
Top = 2280
Width = 735
End
Begin VB.Label Label5
Caption = "电 话:"
Height = 375
Left = 360
TabIndex = 10
Top = 2880
Width = 735
End
Begin VB.Label Label6
Caption = "备 注:"
Height = 375
Left = 360
TabIndex = 9
Top = 3600
Width = 735
End
End
End
Attribute VB_Name = "main"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
'======================= 初始化 =================================
Private Sub Form_Load()
saveoff
openbook App.Path & "\MDB\成绩管理.mdb" '链接数据库:必须把数据库放在同级文件夹MDB中
Form_course.Visible = False
Form_select.Visible = False
Form_search.Visible = False
End Sub
Public Sub openbook(filename As String)
Data_stu.DatabaseName = filename
Data_stu.RecordSource = "学生表"
Data_stu.Refresh
End Sub
'===============================================================
'===================== 对数据的基本操作 ========================
Private Sub add_stu_Click() '添加记录
saveok
Data_stu.Recordset.AddNew
End Sub
Private Sub cancal_stu_Click() '添加更新
On Error Resume Next
saveoff
Data_stu.Recordset.CancelUpdate
End Sub
Private Sub del_stu_Click() '删除记录
On Error Resume Next
Dim sel As String
sel = MsgBox("确定要删除这条信息吗?", vbInformation + vbOKCancel, "询问")
If sel = 1 Then
BeginTrans
Data_stu.Recordset.Delete
CommitTrans
Data_stu.Refresh
If Data_stu.Recordset.Fields(0) = "" Then
sel = MsgBox("对不起学生表中已经没有信息了!!", vbInformation + vbOKOnly, "数据库信息") '如果表为空的话,弹出窗口来提示
End If
End If
End Sub
Private Sub end_Click() '退出
End
End Sub
Private Sub save_stu_Click() '保存记录
On Error Resume Next
saveoff
BeginTrans
Data_stu.Recordset.update
CommitTrans
Data_stu.Refresh
End Sub
Private Sub updata_stu_Click() '修改记录
saveok
Data_stu.Recordset.edit
End Sub
'================================================================
''======================= 照片的选择 ===========================
Private Sub Command1_Click()
On Error Resume Next
ofile.Filter = "图片文件|*.bmp;*.jpg;*.jpeg;*.gif" '定义图片类型
ofile.CancelError = True
ofile.ShowOpen
If Err.Number <> 0 Then
Err.Clear
Exit Sub
End If
Picture1.Picture = LoadPicture(ofile.filename) '在Picture1控件中显示刚刚选择的图片
End Sub
'================================================================
' ======================= 公共子程序 =======================
Public Sub saveoff() '让各个显示记录的控件处于不可编辑的锁定状态
Text1.Locked = True
Text1.BackColor = &H8000000F
Text2.Locked = True
Text2.BackColor = &H8000000F '控件的背景色为灰色
Text3.Locked = True
Text3.BackColor = &H8000000F
Text4.Locked = True
Text4.BackColor = &H8000000F
Text5.Locked = True '控件锁定
Text5.BackColor = &H8000000F
Text6.Locked = True
Text6.BackColor = &H8000000F
Command1.Enabled = False
Command1.BackColor = &H8000000F
End Sub
Public Sub saveok() '让各个显示记录的控件处于可编辑的非锁定状态
Text1.Locked = False
Text1.BackColor = &H80000005
Text2.Locked = False
Text2.BackColor = &H80000005 '控件的背景色为白色
Text3.Locked = False
Text3.BackColor = &H80000005
Text4.Locked = False '控件未锁定
Text4.BackColor = &H80000005
Text5.Locked = False
Text5.BackColor = &H80000005
Text6.Locked = False
Text6.BackColor = &H80000005
Command1.Enabled = True
Command1.BackColor = &H80000005
End Sub
'================================================================
'====================== 跳转到其它窗体 ==========================
Private Sub Command_course_Click()
main.Visible = False
Form_course.Visible = True
End Sub
Private Sub Command_select_Click()
main.Visible = False
Form_select.Visible = True
End Sub
Private Sub Command_search_Click()
main.Visible = False
Form_search.Visible = True
End Sub
'================================================================
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -