?? tjkc.frm
字號:
VERSION 5.00
Object = "{67397AA1-7FB1-11D0-B148-00A0C922E820}#6.0#0"; "MSADODC.OCX"
Begin VB.Form tjkc
BackColor = &H00C0C0C0&
BorderStyle = 3 'Fixed Dialog
Caption = "課程錄入"
ClientHeight = 3120
ClientLeft = 2880
ClientTop = 2010
ClientWidth = 4380
Icon = "tjkc.frx":0000
LinkTopic = "Form1"
MaxButton = 0 'False
MinButton = 0 'False
ScaleHeight = 3120
ScaleWidth = 4380
ShowInTaskbar = 0 'False
Begin VB.CommandButton Command3
Caption = "關閉"
Height = 375
Left = 2880
TabIndex = 8
Top = 2280
Width = 975
End
Begin VB.CommandButton Command2
Caption = "刪除(&D)"
Height = 375
Left = 1560
TabIndex = 7
Top = 2280
Width = 975
End
Begin VB.TextBox Text3
BackColor = &H00FFFFFF&
Height = 375
Left = 1320
TabIndex = 6
Top = 1680
Width = 2535
End
Begin VB.TextBox Text2
BackColor = &H00FFFFFF&
Height = 375
Left = 1320
TabIndex = 4
Top = 960
Width = 2535
End
Begin VB.TextBox Text1
BackColor = &H00FFFFFF&
Height = 375
Left = 1320
TabIndex = 2
Top = 240
Width = 2535
End
Begin VB.CommandButton Command1
Caption = "添加(&A)"
Height = 375
Left = 240
TabIndex = 0
Top = 2280
Width = 975
End
Begin MSAdodcLib.Adodc Adodc1
Height = 375
Left = 2640
Top = 600
Visible = 0 'False
Width = 1200
_ExtentX = 2117
_ExtentY = 661
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 = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=cj.mdb;Persist Security Info=False"
OLEDBString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=cj.mdb;Persist Security Info=False"
OLEDBFile = ""
DataSourceName = ""
OtherAttributes = ""
UserName = ""
Password = ""
RecordSource = "課程表"
Caption = ""
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.Label Label3
BackColor = &H00C0C0C0&
Caption = "授課老師:"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 495
Left = 240
TabIndex = 5
Top = 1800
Width = 1095
End
Begin VB.Label Label2
BackColor = &H00C0C0C0&
Caption = "課程名稱:"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 3
Top = 1080
Width = 1215
End
Begin VB.Label Label1
BackColor = &H00C0C0C0&
Caption = "課程號:"
BeginProperty Font
Name = "宋體"
Size = 9
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 375
Left = 240
TabIndex = 1
Top = 360
Width = 1095
End
End
Attribute VB_Name = "tjkc"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs As ADODB.Recordset
Dim SD As Boolean
Private Function checkclass() As Boolean '檢測添加的課程是否重復
On Error GoTo errh
Set rs = cn.Execute("SELECT 課程號 FROM 課程表 WHERE 課程號='" & Trim(Text1.Text) & "'")
' Adodc2.RecordSource = "select * from 課程 where 課程號='" & Trim(Text1.Text) & "' and 課程名稱='" & Trim(Text2.Text) & "' "
If rs.EOF Then
rs.Close
checkclass = True
Exit Function
End If
checkclass = False
rs.Close
Exit Function
errh:
rs.Close
MsgBox Err.Description
End Function
Private Sub Command1_Click()
On Error GoTo errh
If Text1.Text <> "" Then
If Text2.Text <> "" Then
If Text3.Text <> "" Then
If checkclass Then
Adodc1.Recordset.AddNew
Adodc1.Recordset.Fields("課程號").Value = Text1.Text
Adodc1.Recordset.Fields("課程名稱").Value = Text2.Text
Adodc1.Recordset.Fields("授課老師").Value = Text3.Text
Adodc1.Recordset.Update
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
MsgBox "添加成功!"
'Adodc1.Refresh
Else
MsgBox "課程重復,請另外輸入一門課程!"
Text1.SetFocus
End If
Else
MsgBox "該項不能為空,請輸入授課老師姓名!"
End If
Else
MsgBox "該項不能為空,請輸入課程名稱!"
End If
Else
MsgBox "該項不能為空,請輸入課程號!"
End If
'MsgBox("你的操作將關系到所有選這門課的學生,所有這門課的紀錄將被刪除,你確信嗎?", vbOKCancel, "警告") = vbOK Then
'Adodc1.Recordset.Delete adAffectAllChapters
'
'Adodc1.Recordset.UpdateBatch adAffectAllChapters
'DataGrid1.ReBind
Exit Sub
errh:
MsgBox Err.Description
End Sub
Private Sub Command15_Click()
Unload Me
End Sub
Private Sub Command2_Click()
On Error GoTo errh
If MsgBox("你的操作將會刪除當前的紀錄,你確信嗎?", vbOKCancel, "警告") = vbOK Then
If Text1.Text <> "" Then
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM 課程表 WHERE 課程號='" & Trim(Text1.Text) & "' ", cn, adOpenDynamic, adLockOptimistic, adCmdText
If rs.EOF Then
rs.Close
MsgBox "沒有該課程,無法刪除!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Exit Sub
End If
rs.Delete
rs.Update
rs.Close
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Text1.SetFocus
MsgBox "刪除成功!"
Else
MsgBox "該項不能為空,請輸入課程號!"
End If
End If
Exit Sub
errh:
rs.Close
MsgBox Err.Description
End Sub
Private Sub Command3_Click()
Unload Me
End Sub
Private Sub Form_Load()
On Error GoTo errh
MakeCenter tjkc
Exit Sub
errh:
MsgBox Err.Description
End Sub
'Private Sub Form_Unload(Cancel As Integer)
'On Error Resume Next
' Adodc1.Recordset.Close
'End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -