?? xksz.frm
字號:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "msflxgrd.ocx"
Begin VB.Form 選課設置
Caption = "課程管理-選課設置"
ClientHeight = 3915
ClientLeft = 60
ClientTop = 345
ClientWidth = 5865
LinkTopic = "Form1"
ScaleHeight = 3915
ScaleWidth = 5865
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame2
Height = 1395
Left = 30
TabIndex = 3
Top = 2490
Width = 5805
Begin VB.TextBox Text2
Height = 315
Left = 3450
TabIndex = 12
Text = "Text2"
Top = 900
Width = 2265
End
Begin VB.TextBox Text1
Height = 285
Left = 660
TabIndex = 11
Text = "Text1"
Top = 900
Width = 1665
End
Begin VB.CommandButton Command5
Caption = "取消"
Height = 345
Left = 4830
TabIndex = 8
Top = 210
Width = 765
End
Begin VB.CommandButton Command4
Caption = "確定"
Height = 345
Left = 3675
TabIndex = 7
Top = 210
Width = 765
End
Begin VB.CommandButton Command3
Caption = "修改"
Height = 345
Left = 2520
TabIndex = 6
Top = 210
Width = 765
End
Begin VB.CommandButton Command2
Caption = "刪除"
Height = 345
Left = 1365
TabIndex = 5
Top = 210
Width = 765
End
Begin VB.CommandButton Command1
Caption = "選課"
Height = 345
Left = 210
TabIndex = 4
Top = 210
Width = 765
End
Begin VB.Label Label3
Caption = "課程名稱"
Height = 285
Left = 2640
TabIndex = 10
Top = 960
Width = 855
End
Begin VB.Label Label2
Caption = "學號"
Height = 255
Left = 150
TabIndex = 9
Top = 930
Width = 495
End
End
Begin VB.Frame Frame1
Caption = "學生選課瀏覽"
Height = 1995
Left = 30
TabIndex = 1
Top = 510
Width = 5835
Begin MSFlexGridLib.MSFlexGrid MSF1
Height = 1725
Left = 60
TabIndex = 2
Top = 210
Width = 5745
_ExtentX = 10134
_ExtentY = 3043
_Version = 393216
End
End
Begin VB.Label Label1
Alignment = 2 'Center
Caption = "學 生 選 課 設 置"
BeginProperty Font
Name = "黑體"
Size = 15.75
Charset = 134
Weight = 700
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 435
Left = 60
TabIndex = 0
Top = 30
Width = 5805
End
End
Attribute VB_Name = "選課設置"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim zt As String
Dim mrc As ADODB.Recordset
Dim kcdm As String
Dim kcdm1 As String
Public Sub commok()
Command1.Enabled = True
Command2.Enabled = True
Command3.Enabled = True
Command4.Enabled = True
Command5.Enabled = True
End Sub
Public Sub commnotok()
Command1.Enabled = False
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = False
Command5.Enabled = False
End Sub
Public Sub kcshowtitle()
MSF1.Clear
Dim i As Integer
With MSF1
.Cols = 4
.TextMatrix(0, 1) = "學號"
.TextMatrix(0, 2) = "課程號"
.TextMatrix(0, 3) = "課程名稱"
.ColWidth(0) = 200
.ColWidth(1) = 1000
.ColWidth(2) = 1000
.ColWidth(3) = 2000
.FixedRows = 1
.FillStyle = flexFillSingle
.Col = 0
.Row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
.Row = 1
End With
End Sub
Private Sub Command4_Click()
'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
'
' 課程添加模塊代碼
'
'&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&
If zt = "cmd1add" Then
If Text1.Text = "" Then
sssss = MsgBox("學號不能為空!", vbOKOnly + vbExclamation, "警告")
Text1.SetFocus
Exit Sub
End If
If Text2.Text = "" Then
sssss = MsgBox("課程名稱不能為空!", vbOKOnly + vbExclamation, "警告")
Text2.SetFocus
Exit Sub
End If
'判斷是否存在該學生
txtsql = "select * from 學生基本信息 where 學號='" & Trim(Text1.Text) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = True Then
sssss = MsgBox("不存在該學生!", vbOKOnly + vbExclamation, "警告")
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
mrc.Close
Exit Sub
End If
'判斷是否存在該課程
txtsql = "select * from 課程 where 課程名稱='" & Trim(Text2.Text) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = True Then
sssss = MsgBox("不存在該課程!", vbOKOnly + vbExclamation, "警告")
Text2.SetFocus
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
mrc.Close
Exit Sub
Else
kcdm = mrc.Fields(0)
End If
'判斷是否已存在該選課
txtsql = "select * from 學生選課 where 學號='" & Trim(Text1.Text) & "' and 課程號='" & Trim(kcdm) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = False Then
sssss = MsgBox("該學生已經選修該門課程!", vbOKOnly + vbExclamation, "警告")
Text1.SetFocus
Text1.SelStart = 0
Text1.SelLength = Len(Text1.Text)
Text2.Text = ""
mrc.Close
Exit Sub
End If
mrc.AddNew
mrc.Fields(0) = Trim(Text1.Text)
mrc.Fields(1) = Trim(kcdm)
mrc.Update
MsgBox "課程添加成功!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Text2.Text = ""
Me.commok
kcshowtitle
kcshowdata
End If
'***************************************************
'
' 院系修改模塊代碼
'
'***********************************************
If zt = "cmd3edit" Then
If Text2.Text = "" Then
MsgBox "必須輸入課程名稱!", vbOKOnly + vbExclamation, "警告"
Text2.SetFocus
Exit Sub
End If
'判斷是否存在該課程
txtsql = "select * from 課程 where 課程名稱='" & Trim(Text2.Text) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = True Then
sssss = MsgBox("不存在該課程!", vbOKOnly + vbExclamation, "警告")
Text2.SetFocus
Text2.SelStart = 0
Text2.SelLength = Len(Text2.Text)
mrc.Close
Exit Sub
Else
kcdm = mrc.Fields(0)
End If
'判斷是否改變課程名稱
txtsql = "select * from 學生選課 where 學號='" & Trim(Text1.Text) & "' and 課程號='" & Trim(kcdm) & "'"
Set mrc = ExecuteSQL(txtsql)
If mrc.EOF = False Then
MsgBox "必須輸入改變值!", vbOKOnly + vbExclamation, "警告"
Text2.SetFocus
Exit Sub
End If
txtsql = "select * from 學生選課 where 學號='" & Trim(Text1.Text) & "' and 課程號='" & Trim(kcdm1) & "'"
Set mrc = ExecuteSQL(txtsql)
mrc.Fields(0) = Trim(Text1.Text)
mrc.Fields(1) = Trim(kcdm)
mrc.Update
MsgBox "學生選課修改成功!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Text2.Text = ""
Me.commok
kcshowtitle
kcshowdata
End If
Command4.Enabled = False
zt = ""
End Sub
Private Sub Command5_Click()
Unload Me
End Sub
Private Sub Command1_Click()
zt = "cmd1add"
Text1.Enabled = True
Text1.SetFocus
Text1.Text = ""
Text2.Text = ""
'Text3.Text = ""
Command2.Enabled = False
Command3.Enabled = False
Command4.Enabled = True
End Sub
Private Sub Command2_Click()
'zt = "cmd2del"
If Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) = "" Then
sssss = MsgBox("你還沒有選擇記錄!", vbOKOnly + vbExclamation, "警告")
Else
If MsgBox("確定要刪除 課程名稱 為 " & Trim(Me.MSF1.TextMatrix(MSF1.Row, 3)) & " 的記錄嗎?", vbOKCancel + vbExclamation, "警告") = vbOK Then
txtsql = "select * from 學生成績 where 學號='" & Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) & "' and 課程代碼='" & Trim(Me.MSF1.TextMatrix(MSF1.Row, 2)) & "'"
Set mrc = ExecuteSQL(txtsql)
kcdm = Trim(Me.MSF1.TextMatrix(MSF1.Row, 2))
mrc.Delete
mrc.Close
'刪除學生成績表中的屬于該課程的記錄
txtsql = "select * from 學生成績 where 課程號='" & Trim(kcdm) & "'"
Set mrc = ExecuteSQL(txtsql)
If Not mrc.EOF Then
mrc.Delete
End If
mrc.Close
'*************************************
MsgBox "該學生的選課刪除成功!", vbOKOnly + vbExclamation, "警告"
Text1.Text = ""
Text2.Text = ""
kcshowtitle
kcshowdata
End If
End If
End Sub
Private Sub Command3_Click()
zt = "cmd3edit"
If Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) = "" Then
sssss = MsgBox("你還沒有選擇記錄!", vbOKOnly + vbExclamation, "警告")
Command2.Enabled = True
Command1.Enabled = True
'Text1.Enabled = False
Text2.Enabled = False
Command3.Enabled = True
Else
Text1.Enabled = False
Text2.Enabled = True
Text2.SetFocus
Command2.Enabled = False
Command1.Enabled = False
Command3.Enabled = False
End If
End Sub
Private Sub Form_Load()
Text1.Enabled = False
Me.commok
Command4.Enabled = False
'adodc1.ConnectionString = connstring
Text1.Text = ""
Text2.Text = ""
'txtsql = "select * from 課程"
Me.kcshowtitle
Me.kcshowdata
End Sub
Public Sub kcshowdata()
Dim j As Integer
Dim i As Integer
'Dim mrc As adodb.Recordset
txtsql = "select a.學號,a.課程號,b.課程名稱 from 學生選課 a,課程 b where a.課程號=b.課程代碼"
Set mrc = ExecuteSQL(txtsql)
'mrc.Refresh
If mrc.EOF = False Then
mrc.MoveFirst
With MSF1
.Rows = 15
.Row = 2
Do While Not mrc.EOF
.Rows = .Rows + 1
For i = 1 To mrc.Fields.Count
.TextMatrix(.Row - 1, i) = mrc.Fields(i - 1)
Next i
.Row = .Row + 1
mrc.MoveNext
Loop
End With
End If
End Sub
Private Sub MSF1_Click()
'Dim mrc As adodb.Recordset
If Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) = "" Then
Text1.Text = ""
Text2.Text = ""
Else
txtsql = "select a.學號,a.課程號,b.課程名稱 from 學生選課 a,課程 b where a.課程號=b.課程代碼 and a.學號='" & Trim(Me.MSF1.TextMatrix(MSF1.Row, 1)) & "' and a.課程號='" & Trim(Me.MSF1.TextMatrix(MSF1.Row, 2)) & "'"
Set mrc = ExecuteSQL(txtsql)
'mrc.Refresh
kcdm1 = Trim(Me.MSF1.TextMatrix(MSF1.Row, 2))
Text1.Text = mrc.Fields(0)
Text2.Text = mrc.Fields(2)
End If
Me.commok
End Sub
Private Sub Text1_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then
Text2.SetFocus
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -