?? form5.frm
字號:
VERSION 5.00
Object = "{DAAC6951-59A4-4C08-9D6E-FE3919B64861}#1.0#0"; "FlexCell.ocx"
Object = "{74848F95-A02A-4286-AF0C-A3C755E4A5B3}#1.0#0"; "actskn43.ocx"
Begin VB.Form Form5
BorderStyle = 0 'None
Caption = "課程管理"
ClientHeight = 5025
ClientLeft = 0
ClientTop = 0
ClientWidth = 5760
Icon = "Form5.frx":0000
LinkTopic = "Form5"
MaxButton = 0 'False
ScaleHeight = 5025
ScaleWidth = 5760
ShowInTaskbar = 0 'False
StartUpPosition = 1 '所有者中心
Begin VB.CommandButton XPButton5
Caption = "退 出"
Height = 375
Left = 4080
TabIndex = 4
Top = 4440
Width = 975
End
Begin VB.CommandButton XPButton4
Caption = "刪 除"
Height = 375
Left = 3000
TabIndex = 3
Top = 4440
Width = 975
End
Begin VB.CommandButton XPButton2
Caption = "保 存"
Height = 375
Left = 1920
TabIndex = 2
Top = 4440
Width = 975
End
Begin VB.CommandButton XPButton1
Caption = "新 增"
Height = 375
Left = 840
TabIndex = 1
Top = 4440
Width = 975
End
Begin FlexCell.Grid Grid1
Height = 4215
Left = 0
TabIndex = 0
Top = 0
Width = 5775
_ExtentX = 10186
_ExtentY = 7435
Appearance = 0
Cols = 5
Rows = 30
End
Begin ACTIVESKINLibCtl.Skin PKSkn
Left = 0
OleObjectBlob = "Form5.frx":000C
Top = 0
End
Begin VB.Menu cz
Caption = "操作"
Visible = 0 'False
Begin VB.Menu renovate
Caption = "刷新"
End
End
End
Attribute VB_Name = "Form5"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i, n As Integer
Private Declare Function GetKeyState Lib "user32" _
(ByVal nVirtKey As Long) As Integer
Private Sub Form_Load()
Grid1.SetRegisterInformation "CNwinndy", "W]vyY-nonvk-u\nty-Zbl_e-`hms^" '進行注冊
pkskn.LoadSkin App.Path & "\chizh.skn"
pkskn.ApplySkinByName hWnd, "窗體"
pkskn.ApplySkin hWnd
With Grid1
.AllowUserResizing = True
.DisplayFocusRect = False
.ExtendLastCol = True
.Appearance = Flat
.FixedRowColStyle = Flat
.ScrollBarStyle = Flat
.DefaultFont.Name = "Tahoma"
.DefaultFont.SIZE = 8
.BackColorFixed = RGB(123, 124, 125) 'RGB(90, 158, 214)
.BackColorFixedSel = RGB(123, 124, 125) 'RGB(110, 180, 230)
.BackColorBkg = RGB(123, 124, 125) 'RGB(90, 158, 214)
.BackColorScrollBar = RGB(123, 124, 125) 'RGB(231, 235, 247)
.BackColor1 = RGB(231, 235, 247)
.BackColor2 = RGB(239, 243, 255)
.GridColor = RGB(123, 124, 125) 'RGB(148, 190, 231)
.Column(0).Width = 0
.Column(1).Width = 100
.Column(2).Width = 100
.Column(3).Width = 100
End With
Call callmain
End Sub
Private Sub callmain()
kcsave = False
kcdel = True
Set kc1 = cnn.Execute("select * from " & kctable)
Select Case kctable
Case "課程名"
Grid1.Rows = 1 '清除所有記錄
Grid1.Cols = kc1.Fields.Count + 1 '必須+1,因為實際上為4行,但第一行是隱藏的
Case "教學時間段"
Grid1.Rows = 1 '清除所有記錄
Set kc2 = cnn.Execute("select count(*) from " & kctable)
If kc2.Fields(0) < nknumber Then
MsgBox "您的時間段設定還差" & nknumber - kc2.Fields(0) & "個"
Grid1.Rows = 1
Grid1.Rows = nknumber - kc2.Fields(0) + 1
Grid1.Cols = kc1.Fields.Count '必須+1,因為實際上為4行,但第一行是隱藏的
End If
End Select
For i = 0 To Grid1.Cols - 2 '顯示數據的字段名
Grid1.Cell(0, i + 1).Text = kc1.Fields(i).Name '讀取表中的各字段名
Next
i = 1
Do While Not kc1.EOF
Grid1.Rows = Grid1.Rows + 1
For j = 1 To Grid1.Cols - 1 '設定讀取列
If kc1.Fields(j - 1) = Null Then '空值的處理
Grid1.Cell(i, j).Text = ""
Else
Grid1.Cell(i, j).Text = kc1.Fields(j - 1)
End If
Next
i = i + 1
kc1.MoveNext '讀取下一記錄
Loop
Grid1.Column(1).Locked = True
End Sub
Private Sub Form_Unload(Cancel As Integer)
Call XPButton5_Click
End Sub
Private Sub Grid1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
PopupMenu cz
End If
End Sub
Private Sub Grid1_RowColChange(ByVal Row As Long, ByVal Col As Long)
hang = Row
End Sub
Private Sub Grid1_Validate(Cancel As Boolean) '設定TAB鍵切換
Dim nActiveRow As Long, nActiveCol As Long
Const VK_TAB = 9
If GetKeyState(VK_TAB) < 0 Then
nActiveRow = Grid1.ActiveCell.Row
nActiveCol = Grid1.ActiveCell.Col
If nActiveCol < Grid1.Cols - 1 Then
Grid1.Range(nActiveRow, nActiveCol + 1, _
nActiveRow, nActiveCol + 1).Selected
End If
Cancel = True
End If
End Sub
Private Sub renovate_Click()
Call callmain
End Sub
Private Sub XPButton1_Click()
kcsave = True
kcdel = False
Set kc1 = cnn.Execute("select * from " & kctable)
Grid1.Rows = 1 '清除所有記錄
Grid1.Rows = 9 '默認為2行
If kctable = "教學時間段" Then
Set kc2 = cnn.Execute("select count(*) from " & kctable)
If kc2.Fields(0) < nknumber Then
Grid1.Rows = 1
Grid1.Rows = nknumber - kc2.Fields(0) + 1
End If
End If
For i = 0 To 1 '顯示數據的字段名
Grid1.Cell(0, i + 1).Text = kc1.Fields(i).Name '讀取表中的各字段名
Next
Grid1.Column(1).Locked = False
Grid1.Cell(1, 1).SetFocus
XPButton2.Default = True
End Sub
Private Sub XPButton2_Click()
If kcsave = False Then
MsgBox "不支持保存操作!", vbInformation, "當前不支持"
Exit Sub
End If
For i = 1 To Grid1.Rows - 1
If Grid1.Cell(i, 1).Text <> "" Then
Set kc2 = cnn.Execute("select * from " & kctable & " where " & kc1.Fields(0).Name & "='" & Grid1.Cell(i, 1).Text & "' and " & kc1.Fields(1).Name & "='" & Grid1.Cell(i, 2).Text & "'")
If kc2.EOF = True Then
'---------------------為教師的時間占用作標記
If kctable = "課程名" Then
Dim num As Integer
num = 7 * nknumber
For j = 1 To num
sql = sql & "0"
Next
Set kc2 = cnn.Execute("insert into 占用 values('" & Grid1.Cell(i, 2).Text & "','" & sql & "')")
End If
Set kc2 = cnn.Execute("insert into " & kctable & "( " & kc1.Fields(0).Name & "," & kc1.Fields(1).Name & ") values('" & Grid1.Cell(i, 1).Text & "','" & Grid1.Cell(i, 2).Text & "')")
'------------------
Else
MsgBox "發現重復內容,跳過!", vbInformation, "跳過"
End If
End If
Next
MsgBox "提交成功!", vbInformation, ""
Call callmain
End Sub
Private Sub XPButton4_Click()
If kcdel = False Then
MsgBox "當前刪除操作不被允許!", vbInformation, "非使用對象"
Exit Sub
End If
If hang = 0 Then
Exit Sub
End If
If Grid1.Cell(hang, 1).Text = "" Then
Exit Sub
End If
If kctable = "課程名" Then
Dim num As Integer
num = 7 * nknumber
For j = 1 To num
sql = sql & "0"
Next
Set kc1 = cnn.Execute("select 占用 from 占用 where 教師姓名='" & Grid1.Cell(hang, 2).Text & "'")
If kc1.Fields(0) <> sql Then
MsgBox "該教師的資源仍被占用,請先釋放該教師的所有資源!", vbInformation, "提示"
Exit Sub
Else
Set kc1 = cnn.Execute("delete from 占用 where 教師姓名='" & Grid1.Cell(hang, 2).Text & "'")
Set kc1 = cnn.Execute("delete from 課程名 where 教師姓名='" & Grid1.Cell(hang, 2).Text & "'")
End If
Else
Set kc1 = cnn.Execute("delete from " & kctable & " where " & kc1.Fields(0).Name & "='" & Grid1.Cell(hang, 1).Text & "' and " & kc1.Fields(1).Name & "='" & Grid1.Cell(hang, 2).Text & "'")
End If
MsgBox "目標己刪除,請刷新數據!", vbInformation, "刪除成功"
Call callmain
End Sub
Private Sub XPButton5_Click()
If kctable = "教學時間段" Then
Set kc2 = cnn.Execute("select count(*) from 教學時間段")
If kc2.Fields(0) < nknumber Then
MsgBox "時間段目前數量少于設定數量,請添加", vbInformation, "提示"
Exit Sub
End If
Unload Me
Dim fo2 As CTranslucentForm
Set fo2 = New CTranslucentForm
fo2.hWnd = Form1.hWnd
fo2.Alpha = 90 / 100 * 255
Load Form1
Form1.Show '執行完以上操作就可以進入登陸窗體form1
Else
Unload Me
End If
End Sub
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -