📄 frm_stu.frm
字号:
VERSION 5.00
Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Object = "{0ECD9B60-23AA-11D0-B351-00A0C9055D8E}#6.0#0"; "MSHFLXGD.OCX"
Begin VB.Form Frm_stu
BorderStyle = 1 'Fixed Single
Caption = "学生信息设置"
ClientHeight = 4275
ClientLeft = 45
ClientTop = 330
ClientWidth = 6165
LinkTopic = "Form1"
MaxButton = 0 'False
ScaleHeight = 4275
ScaleWidth = 6165
StartUpPosition = 2 '屏幕中心
Begin MSAdodcLib.Adodc Adodc1
Height = 495
Left = 885
Top = 4335
Width = 2865
_ExtentX = 5054
_ExtentY = 873
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= 1
Appearance = 1
BackColor = -2147483643
ForeColor = -2147483640
Orientation = 0
Enabled = -1
Connect = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_dpgl;Data Source=."
OLEDBString = "Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Initial Catalog=db_dpgl;Data Source=."
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = ""
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
Begin VB.TextBox Text1
Height = 345
Index = 1
Left = 2910
TabIndex = 5
Top = 975
Width = 1395
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid MS1
Height = 2790
Left = 60
TabIndex = 3
Top = 1410
Width = 5850
_ExtentX = 10319
_ExtentY = 4921
_Version = 393216
_NumberOfBands = 1
_Band(0).Cols = 2
End
Begin VB.TextBox Text1
Height = 345
Index = 0
Left = 735
TabIndex = 1
Top = 975
Width = 1395
End
Begin MSComctlLib.Toolbar Toolbar1
Align = 1 'Align Top
Height = 795
Left = 0
TabIndex = 4
Top = 0
Width = 6165
_ExtentX = 10874
_ExtentY = 1402
ButtonWidth = 1296
ButtonHeight = 1349
Appearance = 1
Style = 1
ImageList = "ImageList1"
_Version = 393216
BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
NumButtons = 8
BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = " 添加 "
Key = "add"
ImageIndex = 1
EndProperty
BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "修改"
Key = "modify"
ImageIndex = 2
EndProperty
BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "删除"
Key = "del"
ImageIndex = 3
EndProperty
BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "保存"
Key = "save"
ImageIndex = 4
EndProperty
BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "取消"
Key = "cancel"
ImageIndex = 5
EndProperty
BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
Style = 3
EndProperty
BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
Caption = "退出"
Key = "exit"
ImageIndex = 6
EndProperty
EndProperty
BorderStyle = 1
Begin MSComctlLib.ImageList ImageList1
Left = 5325
Top = 135
_ExtentX = 1005
_ExtentY = 1005
BackColor = -2147483643
ImageWidth = 32
ImageHeight = 32
MaskColor = 12632256
_Version = 393216
BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
NumListImages = 6
BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Frm_stu.frx":0000
Key = ""
EndProperty
BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Frm_stu.frx":0C54
Key = ""
EndProperty
BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Frm_stu.frx":18A8
Key = ""
EndProperty
BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Frm_stu.frx":24FC
Key = ""
EndProperty
BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Frm_stu.frx":625C
Key = ""
EndProperty
BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
Picture = "Frm_stu.frx":6EB0
Key = ""
EndProperty
EndProperty
End
End
Begin VB.Label Label2
Caption = "姓名"
Height = 270
Left = 2475
TabIndex = 2
Top = 1035
Width = 405
End
Begin VB.Label Label1
Caption = "学号"
Height = 300
Left = 135
TabIndex = 0
Top = 1035
Width = 450
End
End
Attribute VB_Name = "Frm_stu"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs1 As New ADODB.Recordset
Public blnAdd As Boolean
Dim mybookmark
Private Sub MS1_RowColChange()
MS1_Click
End Sub
Private Sub MS1_SelChange()
MS1_Click
End Sub
Private Sub Text1_Change(index As Integer)
If index = 0 Then
If Len(Text1(0).Text) > 10 Then
MsgBox "学号过长!", , "学生订票管理系统"
Text1(0).Text = Left("" & Text1(0).Text & "", 10)
End If
End If
End Sub
Private Sub Form_Load()
Dim rs As New ADODB.Recordset
Text1(0).Text = "": Text1(1).Text = ""
Text1(0).Locked = True
tlbState False
rs.Open "select * from tb_stu ", cnn, adOpenStatic
Set MS1.DataSource = rs
rs.Close
End Sub
Private Sub MS1_Click()
Text1(0).Text = MS1.TextMatrix(MS1.Row, 1)
Text1(1).Text = MS1.TextMatrix(MS1.Row, 2)
End Sub
Private Sub Text1_GotFocus(index As Integer)
Text1(index).BackColor = &HFFFF00
Text1(index).SelStart = 0
Text1(index).SelLength = Len(Text1(index))
End Sub
Private Sub Text1_LostFocus(index As Integer)
Text1(index).BackColor = &H80000005
End Sub
Private Sub Toolbar1_ButtonClick(ByVal Button As MSComctlLib.Button)
Dim rs As New ADODB.Recordset
Dim rs1 As New ADODB.Recordset
Dim rs2 As New ADODB.Recordset
Select Case Button.Key
Case "add"
blnAdd = True
tlbState True
Text1(0).Locked = False
Text1(1).Locked = False
Text1(0).SetFocus
Text1(0).Text = ""
Text1(1).Text = ""
Case "modify"
blnAdd = False
Text1(0).Text = MS1.TextMatrix(MS1.Row, 1)
Text1(1).Text = MS1.TextMatrix(MS1.Row, 2)
tlbState True
Text1(1).Locked = False
Text1(0).SetFocus
Case "del"
If MS1.TextMatrix(MS1.Row, 1) = "" Then
MsgBox "系统没有要删除的数据!", , "学生订票管理系统"
Else
Adodc1.RecordSource = "select * from tb_stu where 学号='" & MS1.TextMatrix(MS1.Row, 1) & "'"
Adodc1.Refresh
If Adodc1.Recordset.RecordCount > 0 Then Adodc1.Recordset.Delete
rs.Open "select * from tb_stu ", cnn, adOpenStatic
Set MS1.DataSource = rs
rs.Close
End If
Case "save"
On Error GoTo SaveErr
If Text1(0).Text = "" Or Text1(1).Text = "" Then
MsgBox "系统不允许信息为空!", , "学生订票管理系统"
Exit Sub
End If
If blnAdd = True Then
rs2.Open "select * from tb_stu where 学号='" & Text1(0).Text & "'", cnn, adOpenKeyset, adLockOptimistic
If rs2.RecordCount > 0 Then
MsgBox "该学号已存在!", , "学生订票管理系统"
Exit Sub
End If
cnn.Execute ("insert into tb_stu values('" + Text1(0).Text + "','" & Text1(1).Text & "')")
tlbState False
Text1(1).Locked = True
rs1.Open "select * from tb_stu ", cnn, adOpenStatic
Set MS1.DataSource = rs1
rs1.Close
Else
cnn.Execute ("update tb_stu set 学号='" + Text1(0).Text + "',学生姓名='" & Text1(1).Text & "'where 学号='" + Text1(0).Text + "'")
rs1.Open "select * from tb_stu ", cnn, adOpenStatic
Set MS1.DataSource = rs1
rs1.Close
tlbState False
Text1(0).Locked = True
Text1(1).Locked = True
Text1(0).Text = ""
Text1(1).Text = ""
End If
Exit Sub
SaveErr:
MsgBox Err.Description
Case "cancel"
tlbState False
Text1(0).Locked = True
Text1(1).Locked = True
Text1(0).Text = ""
Text1(1).Text = ""
Case "exit"
Unload Me
Frm_main.Show
End Select
End Sub
Sub tlbState(state As Boolean)
With Toolbar1
If state = True Then
.Buttons(1).Enabled = False
.Buttons(2).Enabled = False
.Buttons(3).Enabled = False
.Buttons(5).Enabled = True
.Buttons(6).Enabled = True
Else
.Buttons(1).Enabled = True
.Buttons(2).Enabled = True
.Buttons(3).Enabled = True
.Buttons(5).Enabled = False
.Buttons(6).Enabled = False
End If
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -