?? 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 + -