📄 form1.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form Form1
Caption = "管理学生表T_STUDENT"
ClientHeight = 5055
ClientLeft = 60
ClientTop = 450
ClientWidth = 6855
LinkTopic = "Form1"
ScaleHeight = 5055
ScaleWidth = 6855
StartUpPosition = 2 '屏幕中心
Begin VB.TextBox TxtEntrance
DataField = "t_s_entrance"
DataSource = "Adodc1"
Height = 375
Left = 1200
TabIndex = 22
Top = 2040
Width = 5295
End
Begin VB.TextBox TxtBirthday
DataField = "t_s_birthday"
DataSource = "Adodc1"
Height = 375
Left = 4440
TabIndex = 19
Top = 1440
Width = 2055
End
Begin VB.TextBox TxtClass
DataField = "t_s_class"
DataSource = "Adodc1"
Height = 375
Left = 1200
TabIndex = 18
Top = 1440
Width = 1935
End
Begin VB.TextBox TxtDepartment
DataField = "t_s_department"
DataSource = "Adodc1"
Height = 375
Left = 4440
TabIndex = 16
Top = 840
Width = 2055
End
Begin VB.TextBox TxtSex
DataField = "t_s_sex"
DataSource = "Adodc1"
Height = 375
Left = 4440
TabIndex = 13
Top = 360
Width = 2055
End
Begin VB.TextBox TxtName
DataField = "t_s_name"
DataSource = "Adodc1"
Height = 315
Left = 1200
TabIndex = 11
Top = 960
Width = 1875
End
Begin VB.TextBox TxtStudentno
DataField = "t_s_studentno"
DataSource = "Adodc1"
Height = 315
Left = 1200
TabIndex = 10
Top = 360
Width = 1935
End
Begin VB.CommandButton CmdLast
Caption = "尾记录"
Height = 555
Left = 4020
TabIndex = 8
Top = 3300
Width = 1275
End
Begin VB.CommandButton CmdNext
Caption = "后一条"
Height = 555
Left = 2760
TabIndex = 7
Top = 3300
Width = 1275
End
Begin VB.CommandButton CmdPrevious
Caption = "前一条"
Height = 555
Left = 1500
TabIndex = 6
Top = 3300
Width = 1275
End
Begin VB.CommandButton CmdFirst
Caption = "首记录"
Height = 555
Left = 240
TabIndex = 5
Top = 3300
Width = 1275
End
Begin VB.CommandButton CmdCancel
Caption = "取消"
Height = 555
Left = 5280
TabIndex = 4
Top = 2760
Width = 1275
End
Begin VB.CommandButton CmdSave
Caption = "保存"
Height = 555
Left = 4035
TabIndex = 3
Top = 2760
Width = 1275
End
Begin VB.CommandButton CmdUpdate
Caption = "修改"
Height = 555
Left = 2775
TabIndex = 2
Top = 2760
Width = 1275
End
Begin VB.CommandButton CmdDelete
Caption = "删除"
Height = 555
Left = 1515
TabIndex = 1
Top = 2760
Width = 1275
End
Begin VB.CommandButton CmdInsert
Caption = "添加"
Height = 555
Left = 240
TabIndex = 0
Top = 2760
Width = 1275
End
Begin MSAdodcLib.Adodc Adodc1
Height = 555
Left = 240
Top = 4200
Visible = 0 'False
Width = 6375
_ExtentX = 11245
_ExtentY = 979
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 2
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = $"Form1.frx":0000
OLEDBString = $"Form1.frx":008A
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "t_student"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
Begin VB.Label LblEntrance
Caption = "入学年月:"
Height = 375
Left = 240
TabIndex = 21
Top = 2160
Width = 1215
End
Begin VB.Label LblBirthday
Caption = "出生年月:"
Height = 375
Left = 3480
TabIndex = 20
Top = 1560
Width = 1215
End
Begin VB.Label LblClass
Caption = "所在班级:"
Height = 255
Left = 240
TabIndex = 17
Top = 1560
Width = 975
End
Begin VB.Label LblDepartment
Caption = "院系名称:"
Height = 375
Left = 3480
TabIndex = 15
Top = 960
Width = 1095
End
Begin VB.Label LblSex
Caption = "学生性别:"
Height = 495
Left = 3480
TabIndex = 14
Top = 360
Width = 1455
End
Begin VB.Label LblName
AutoSize = -1 'True
Caption = "学生姓名:"
Height = 180
Left = 240
TabIndex = 12
Top = 960
Width = 900
End
Begin VB.Label LblStudentno
AutoSize = -1 'True
Caption = "学生编号:"
Height = 180
Left = 240
TabIndex = 9
Top = 360
Width = 900
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
'单击添加按钮后的执行代码
Private Sub CmdInsert_Click()
'调用AddNew方法向记录集中添加记录
Adodc1.Recordset.AddNew
'设置其他按钮的状态
CmdInsert.Enabled = False
CmdDelete.Enabled = False
CmdUpdate.Enabled = False
CmdFirst.Enabled = False
CmdPrevious.Enabled = False
CmdNext.Enabled = False
CmdLast.Enabled = False
CmdSave.Enabled = True
CmdCancel.Enabled = True
End Sub
'单击删除按钮后的执行代码
Private Sub CmdDelete_Click()
Dim Ans As Integer
'在删除记录之前对用户有一个警告
Ans = MsgBox("确定删除该记录吗?", vbYesNo, "警告")
If Ans = vbYes Then
Adodc1.Recordset.Delete
End If
End Sub
'单击修改按钮后的执行代码
Private Sub CmdUpdate_Click()
'直接对文本框中的数据进行修改就可以,然后单击保存按钮就可以
CmdInsert.Enabled = False
CmdDelete.Enabled = False
CmdUpdate.Enabled = True
CmdCancel.Enabled = True
CmdSave.Enabled = True
CmdFirst.Enabled = False
CmdPrevious.Enabled = False
CmdNext.Enabled = False
CmdLast.Enabled = False
End Sub
'单击保存按钮后的执行代码
Private Sub CmdSave_Click()
'通过Update方法将Recordset中的数据提交到数据库
Adodc1.Recordset.Update
'恢复其他控件的属性
CmdInsert.Enabled = True
CmdDelete.Enabled = True
CmdUpdate.Enabled = True
CmdFirst.Enabled = True
CmdPrevious.Enabled = True
CmdNext.Enabled = True
CmdLast.Enabled = True
'同时使保存和取消按钮失效
CmdSave.Enabled = False
CmdCancel.Enabled = False
End Sub
'单击取消按钮后的执行代码
Private Sub CmdCancel_Click()
'通过CancelUpdate方法取消对数据的保存
Adodc1.Recordset.CancelUpdate
'恢复其他控件的属性
CmdInsert.Enabled = True
CmdDelete.Enabled = True
CmdUpdate.Enabled = True
CmdFirst.Enabled = True
CmdPrevious.Enabled = True
CmdNext.Enabled = True
CmdLast.Enabled = True
'同时使保存和取消按钮失效
CmdSave.Enabled = False
CmdCancel.Enabled = False
End Sub
'单击首记录按钮后的执行代码
Private Sub CmdFirst_Click()
'调用MoveFirst方法指向记录集的首记录
Adodc1.Recordset.MoveFirst
End Sub
'单击前一条按钮后的执行代码
Private Sub CmdPrevious_Click()
'移动记录到下一条的方法是MovePrevious
'在调用MovePrevious方法之前,首先需要判断,当前是不是已经到了最前面
'判断方法是调用BOF属性,如果BOF为真,则表示一定到了最前,不能移动
'否则会出错
If Not Adodc1.Recordset.BOF Then
Adodc1.Recordset.MovePrevious
Else '如果为真,则移动到第一条记录
Adodc1.Recordset.MoveFirst
End If
End Sub
'单击后一条按钮后的执行代码
Private Sub CmdNext_Click()
'移动记录到下一条的方法是MoveNext
'在调用MoveNext方法之前,首先需要判断,当前是不是已经到了最后
'判断方法是调用EOF属性,如果EOF为真,则表示一定到了最后,不能移动
'否则会出错
If Not Adodc1.Recordset.EOF Then
Adodc1.Recordset.MoveNext
Else '如果为真,则移动到最后一条记录
Adodc1.Recordset.MoveLast
End If
End Sub
'单击尾记录按钮后的执行代码
Private Sub CmdLast_Click()
'调用MoveLast
Adodc1.Recordset.MoveLast
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -