📄 change.frm
字号:
EndProperty
Height = 375
Index = 1
Left = 480
TabIndex = 9
Top = 480
Width = 615
End
End
Begin VB.Frame Frame1
Caption = "球员管理"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 10095
Left = 600
TabIndex = 0
Top = 480
Width = 9495
Begin VB.Data Data1
Caption = "Data1"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 285
Left = 4920
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 240
Visible = 0 'False
Width = 1455
End
Begin VB.Frame Frame3
Caption = "履历"
BeginProperty Font
Name = "宋体"
Size = 12
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 4695
Left = 480
TabIndex = 1
Top = 4920
Width = 8415
Begin VB.Data Data3
Caption = "Data3"
Connect = "Access"
DatabaseName = ""
DefaultCursorType= 0 '缺省游标
DefaultType = 2 '使用 ODBC
Exclusive = 0 'False
Height = 345
Left = 4560
Options = 0
ReadOnly = 0 'False
RecordsetType = 1 'Dynaset
RecordSource = ""
Top = 240
Visible = 0 'False
Width = 1575
End
Begin MSDBGrid.DBGrid DBGrid3
Bindings = "Change.frx":0000
Height = 2895
Left = 360
OleObjectBlob = "Change.frx":0014
TabIndex = 5
Top = 600
Width = 7695
End
Begin VB.CommandButton Command3
Caption = "删除"
Height = 375
Left = 6600
TabIndex = 4
Top = 3840
Width = 1455
End
Begin VB.CommandButton Command2
Caption = "修改"
Height = 375
Left = 4920
TabIndex = 3
Top = 3840
Width = 1335
End
Begin VB.CommandButton Command1
Caption = "添加"
Height = 375
Left = 3240
TabIndex = 2
Top = 3840
Width = 1335
End
End
Begin MSDBGrid.DBGrid DBGrid1
Bindings = "Change.frx":09D7
Height = 3975
Left = 480
OleObjectBlob = "Change.frx":09EB
TabIndex = 6
Top = 600
Width = 8415
End
End
Begin VB.Label Label1
Caption = "球员"
BeginProperty Font
Name = "宋体"
Size = 15
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Index = 0
Left = 11160
TabIndex = 23
Top = 600
Width = 615
End
End
Attribute VB_Name = "PlayerChange"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim ad As Boolean '添加状态
Dim md As Boolean '修改状态
Dim db As Database '数据库
Dim rs As Recordset '记录集
Private Sub Combo1_Click()
Text2(6) = GetID(Combo1)
End Sub
Private Sub Command1_Click()
On Error GoTo adderr
If ad Then
If Not judge() Then
MsgBox ("信息填写有误!")
Data3.Recordset.CancelUpdate
Else
Data3.Recordset.Update
Data3.Recordset.Bookmark = Data3.Recordset.LastModified
End If
Command1.Caption = "添加"
Command2.Enabled = True
For i = 1 To 4
Text2(i).Locked = True
Next i
DBGrid1.Enabled = True
DBGrid3.Enabled = True
ad = False
Else
Command1.Caption = "确定"
Data3.Recordset.AddNew
Command2.Enabled = False
For i = 1 To 4
Text2(i).Locked = False
Next i
DBGrid1.Enabled = False
DBGrid3.Enabled = False
Text2(5) = Text1
ad = True
End If
Exit Sub
adderr:
MsgBox ("修改数据无效!")
Call Form_Unload(1)
End Sub
Private Sub Command2_Click()
On Error GoTo mferr
If md Then
If Not judge() Then
MsgBox ("信息填写有误!")
Data3.Recordset.CancelUpdate
Else
Data3.Recordset.Update
Data3.Recordset.Bookmark = Data3.Recordset.LastModified
End If
md = False
Command2.Caption = "修改"
Command1.Enabled = True
For i = 1 To 4
Text2(i).Locked = True
Next i
Else
Data3.Recordset.Edit
md = True
Command2.Caption = "确认"
Command1.Enabled = False
For i = 1 To 4
Text2(i).Locked = False
Next i
End If
Exit Sub
mferr:
MsgBox ("修改数据无效!")
Call Form_Unload(1)
End Sub
Private Sub Command3_Click()
Data3.Recordset.Delete
Data3.Recordset.MoveNext
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Form_Load()
ad = False
md = False
Data1.DatabaseName = dbpath
Data3.DatabaseName = dbpath
Set db = OpenDatabase(dbpath)
Set rs = db.OpenRecordset("Team")
'将球队信息加入条目
Do Until rs.EOF
Combo1.AddItem (rs.Fields(2) & "(" & rs.Fields(1) & ")" & "-" & str$(rs.Fields(0)))
rs.MoveNext
Loop
Data1.RecordSource = "Select * from Player"
Data3.RecordSource = "Select * from Player_Team"
End Sub
Private Sub Form_Unload(Cancel As Integer)
On Error Resume Next
If ad Then Data3.Recordset.CancelUpdate
If md Then Data3.Recordset.CancelUpdate
End Sub
Private Sub Text1_Change()
Data3.RecordSource = "Select * from Player_Team where Player_ID=" & Text1
Data3.Refresh
End Sub
Private Function judge() As Boolean
'判断信息填写是否正确
judge = True
If Val(Text2(5)) = 0 Then
judge = False
MsgBox ("球员选择有误!")
End If
If Val(Text2(6)) = 0 Then
judge = False
MsgBox ("球队选择有误!")
End If
If Val(Text2(1)) = 0 Then
judge = False
MsgBox ("日期输入有误!")
End If
End Function
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -