📄 frm_stulist.frm
字号:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form Frm_StuList
BorderStyle = 1 'Fixed Single
Caption = "学生信息表"
ClientHeight = 4050
ClientLeft = 45
ClientTop = 330
ClientWidth = 7455
LinkTopic = "Form1"
LockControls = -1 'True
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 4050
ScaleWidth = 7455
StartUpPosition = 1 '所有者中心
Begin MSDataGridLib.DataGrid DataGrid1
Bindings = "Frm_StuList.frx":0000
Height = 2895
Left = 240
TabIndex = 4
Top = 240
Width = 6975
_ExtentX = 12303
_ExtentY = 5106
_Version = 393216
AllowUpdate = 0 'False
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
Begin VB.CommandButton Command4
Caption = "退 出"
Height = 495
Left = 5250
TabIndex = 3
Top = 3360
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "删 除"
Height = 495
Left = 3810
TabIndex = 2
Top = 3360
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "修 改"
Height = 495
Left = 2370
TabIndex = 1
Top = 3360
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "添 加"
Height = 495
Left = 990
TabIndex = 0
Top = 3360
Width = 1215
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 0
Top = 0
Visible = 0 'False
Width = 2175
_ExtentX = 3836
_ExtentY = 661
ConnectMode = 0
CursorLocation = 3
IsolationLevel = -1
ConnectionTimeout= 15
CommandTimeout = 30
CursorType = 3
LockType = 3
CommandType = 8
CursorOptions = 0
CacheSize = 50
MaxRecords = 0
BOFAction = 0
EOFAction = 0
ConnectStringType= 3
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "DSN=student"
OLEDBString = ""
OLEDBFile = ""
DataSourceName = "student"
OtherAttributes = ""
UserName = "sa"
Password = ""
RecordSource = "SELECT * FROM Students"
Caption = "Adodc1"
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 9
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_Version = 393216
End
End
Attribute VB_Name = "Frm_StuList"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Sub Refresh_Stu()
Adodc1.RecordSource = "SELECT Student_Id As 编号, Student_Name As 姓名, Sex As 性别, " _
+ "Title As 职务, Score As 成绩 FROM Students ORDER BY Student_Id"
Adodc1.Refresh
End Sub
Private Sub Command1_Click()
With Frm_StuEdit
.Modify = False
'设置性别
.Combo1.ListIndex = 0
.Show 1
End With
'修改数据后刷新显示
Refresh_Stu
End Sub
Private Sub Command2_Click()
Dim TmpSex As String
Dim Pos As Integer
If Adodc1.Recordset.EOF = True Then
MsgBox "请选择学生信息"
Exit Sub
End If
'保存当前的记录位置
Pos = Adodc1.Recordset.AbsolutePosition
With Frm_StuEdit
'设置修改状态
.Modify = True
'设置OriStuId
.OriStuId = Adodc1.Recordset.Fields(0)
'读取姓名
.Text1 = Trim(Adodc1.Recordset.Fields(1))
'读取性别
TmpSex = Trim(Adodc1.Recordset.Fields(2))
If InCombo(TmpSex, .Combo1) = True Then
.Combo1.Text = TmpSex
End If
'读取职务
.Text3 = Trim(Adodc1.Recordset.Fields(3))
'读取成绩
.Text4 = Adodc1.Recordset.Fields(4)
.Show 1
End With
'修改数据后刷新显示
Refresh_Stu
'恢复到回来的位置
Adodc1.Recordset.Move Pos - 1
End Sub
Private Sub Command3_Click()
Dim StuId As Long
Dim Pos As Integer
If Adodc1.Recordset.EOF = True Then
MsgBox "请选择学生信息"
Exit Sub
End If
'保存当前的记录位置
Pos = Adodc1.Recordset.AbsolutePosition
'读取要删除数据的编号
StuId = Adodc1.Recordset.Fields(0)
If MsgBox("是否删除当前行?", vbYesNo, "请确认") = vbYes Then
MyStu.Delete (StuId)
'修改数据后刷新显示
Refresh_Stu
'将光标移动到前一个记录或后一个记录
If Pos - 2 >= 0 Then
Adodc1.Recordset.Move Pos - 2
Else
If Pos - 1 < Adodc1.Recordset.RecordCount Then
Adodc1.Recordset.Move Pos - 1
End If
End If
End If
End Sub
Private Sub Command4_Click()
End
End Sub
Private Sub Form_Load()
Refresh_Stu
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -