?? main.frm
字號:
VERSION 5.00
Object = "{F9043C88-F6F2-101A-A3C9-08002B2F49FB}#1.2#0"; "COMDLG32.OCX"
Begin VB.Form main
Caption = "學(xué)生信息 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 = "學(xué)生信息"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游標(biāo)
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 = "其它表項(xiàng):"
Height = 855
Left = 120
TabIndex = 15
Top = 4920
Width = 5055
Begin VB.CommandButton Command_search
Caption = "查 詢 項(xiàng)"
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 = "學(xué)號"
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 = "學(xué) 號:"
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" '鏈接數(shù)據(jù)庫:必須把數(shù)據(jù)庫放在同級文件夾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 = "學(xué)生表"
Data_stu.Refresh
End Sub
'===============================================================
'===================== 對數(shù)據(jù)的基本操作 ========================
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("對不起學(xué)生表中已經(jīng)沒有信息了!!", vbInformation + vbOKOnly, "數(shù)據(jù)庫信息") '如果表為空的話,彈出窗口來提示
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() '讓各個顯示記錄的控件處于不可編輯的鎖定狀態(tài)
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() '讓各個顯示記錄的控件處于可編輯的非鎖定狀態(tài)
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
'================================================================
'====================== 跳轉(zhuǎn)到其它窗體 ==========================
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
'================================================================
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -