⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setclass.frm

📁 一个VB做的考试日程安排管理系统
💻 FRM
字号:
VERSION 5.00
Object = "{CFA7AFF4-3242-4269-9172-7389D695AE01}#1.0#0"; "StoneXP.ocx"
Object = "{DAAC6951-59A4-4C08-9D6E-FE3919B64861}#1.0#0"; "FlexCell.ocx"
Begin VB.Form setclass 
   BorderStyle     =   0  'None
   Caption         =   "教室设定"
   ClientHeight    =   4200
   ClientLeft      =   0
   ClientTop       =   0
   ClientWidth     =   5775
   Icon            =   "setclass.frx":0000
   LinkTopic       =   "setclass"
   MaxButton       =   0   'False
   ScaleHeight     =   4200
   ScaleWidth      =   5775
   ShowInTaskbar   =   0   'False
   StartUpPosition =   1  '所有者中心
   Begin StoneXP.XPButton XPButton4 
      Height          =   375
      Left            =   4680
      TabIndex        =   5
      Top             =   3240
      Width           =   975
      _ExtentX        =   1720
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "删 除"
      MouseIcon       =   "setclass.frx":F84A
      MousePointer    =   99
   End
   Begin StoneXP.XPButton XPButton3 
      Height          =   375
      Left            =   4680
      TabIndex        =   4
      Top             =   2760
      Width           =   975
      _ExtentX        =   1720
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "修 改"
      MouseIcon       =   "setclass.frx":FB64
      MousePointer    =   99
   End
   Begin FlexCell.Grid Grid1 
      Height          =   4215
      Left            =   0
      TabIndex        =   3
      Top             =   0
      Width           =   4575
      _ExtentX        =   8070
      _ExtentY        =   7435
      Appearance      =   0
      Cols            =   5
      Rows            =   30
      ScrollBars      =   2
   End
   Begin StoneXP.XPButton XPButton1 
      Height          =   375
      Left            =   4680
      TabIndex        =   1
      Top             =   1800
      Width           =   975
      _ExtentX        =   1720
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "增 加"
      MouseIcon       =   "setclass.frx":FE7E
      MousePointer    =   99
   End
   Begin StoneXP.XPButton XPButton2 
      Height          =   375
      Left            =   4680
      TabIndex        =   2
      Top             =   2280
      Width           =   975
      _ExtentX        =   1720
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "保 存"
      MouseIcon       =   "setclass.frx":10198
      MousePointer    =   99
   End
   Begin StoneXP.XPButton XPButton5 
      Height          =   375
      Left            =   4680
      TabIndex        =   0
      Top             =   3720
      Width           =   975
      _ExtentX        =   1720
      _ExtentY        =   661
      BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
         Name            =   "宋体"
         Size            =   9
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      Caption         =   "退 出"
      MouseIcon       =   "setclass.frx":104B2
      MousePointer    =   99
   End
   Begin VB.Menu cz 
      Caption         =   "操作"
      Visible         =   0   'False
      Begin VB.Menu renovate 
         Caption         =   "刷新"
      End
   End
End
Attribute VB_Name = "setclass"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Dim i As Integer
Private Declare Function GetKeyState Lib "user32" _
   (ByVal nVirtKey As Long) As Integer
Dim gcolor1, gcolor2 As String
Dim m, n As Integer

Private Sub Form_Load()
Grid1.SetRegisterInformation "CNwinndy", "W]vyY-nonvk-u\nty-Zbl_e-`hms^" '进行注册
With Grid1
    .AllowUserResizing = True
    .DisplayFocusRect = False
    .ExtendLastCol = True
    .Appearance = Flat
    .FixedRowColStyle = Flat
    .ScrollBarStyle = Flat
    
    .DefaultFont.Name = "Tahoma"
    .DefaultFont.SIZE = 8
    .BackColorFixed = RGB(84, 201, 134) 'RGB(90, 158, 214)
    .BackColorFixedSel = RGB(84, 201, 134) 'RGB(110, 180, 230)
    .BackColorBkg = RGB(84, 201, 134) 'RGB(90, 158, 214)
    .BackColorScrollBar = RGB(231, 235, 247)
    .BackColor1 = RGB(231, 235, 247)
    .BackColor2 = RGB(239, 243, 255)
    .GridColor = RGB(148, 190, 231)
    .Column(0).Width = 0
    .Column(1).Width = 100
    .Column(2).Width = 60
    .Column(3).Width = 60
    .Column(4).Width = 60
End With
Me.BackColor = RGB(84, 201, 134)
kstable = "教室"
Call callmain
End Sub

Private Sub callmain()
kssave = False
ksedit = True
ksdel = True
Set ks1 = cnn.Execute("select * from " & kstable)
Grid1.Rows = 1 '清除所有记录
i = 4
Grid1.Cols = i + 1 '必须+1,因为实际上为4行,但第一行是隐藏的
For i = 0 To i - 1  '显示数据的字段名
Grid1.Cell(0, i + 1).Text = ks1.Fields(i).Name  '读取表中的各字段名
Next
n = i
i = 1
Do While Not ks1.EOF
 Grid1.Rows = Grid1.Rows + 1
 For j = 1 To n '设定读取列
 If ks1.Fields(j - 1) = Null Then '空值的处理
 Grid1.Cell(i, j).Text = ""
 Else
 Grid1.Cell(i, j).Text = ks1.Fields(j - 1)
 End If
 Next
  i = i + 1
 ks1.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()
kssave = True
Set ks1 = cnn.Execute("select * from " & kstable)
Grid1.Rows = 1 '清除所有记录
Grid1.Rows = 21 '默认为2行
Grid1.Column(3).CellType = cellComboBox
Grid1.ComboBox(3).Clear
For i = 1 To 10
Grid1.ComboBox(3).AddItem i
Next
For i = 0 To 1   '显示数据的字段名
Grid1.Cell(0, i + 1).Text = ks1.Fields(i).Name  '读取表中的各字段名
Next
Grid1.Column(1).Locked = False
Grid1.Cell(1, 1).SetFocus
XPButton2.Default = True
End Sub

Private Sub XPButton2_Click()
If kssave = False Then
MsgBox "不支持保存操作!", vbInformation, "当前不支持"
Exit Sub
End If
If m <> 0 And n <> 0 Then
Grid1.Range(m, 1, m, 4).BackColor = gcolor1
Grid1.Range(n, 1, n, 4).BackColor = gcolor2
End If
For i = 1 To Grid1.Rows - 1
 For j = i + 1 To Grid1.Rows - 1
  If Grid1.Cell(i, 1).Text <> "" Then
  If Grid1.Cell(i, 1).Text = Grid1.Cell(j, 1).Text Then
  MsgBox "第" & i & "行与" & j & "行的数据出现重复,请修改!", vbInformation, "重复错误"
  m = i
  n = j
  gcolor1 = Grid1.Cell(m, 1).BackColor
  gcolor2 = Grid1.Cell(n, 1).BackColor
  Grid1.Range(i, 1, i, 4).BackColor = RGB(90, 158, 214)
  Grid1.Range(j, 1, j, 4).BackColor = RGB(90, 158, 214)
  Exit Sub
  End If
  End If
 Next
Next
For i = 1 To Grid1.Rows - 1
 For j = 1 To Grid1.Cols - 1
 If Grid1.Cell(i, 1).Text <> "" Then
   If Grid1.Cell(i, j).Text = "" Then
   MsgBox "第" & i & "行的数据请填完整!", vbInformation, "错误提示"
   Grid1.Cell(i, j).SetFocus
   Exit Sub
   End If
 Else
 Exit For
 End If
 Next
Next
For i = 1 To Grid1.Rows - 1
If Grid1.Cell(i, 1).Text <> "" Then
Set ks1 = cnn.Execute("select 教室号 from 教室 where 教室号='" & Grid1.Cell(i, 1).Text & "'")
If ks1.EOF = True Then
Set ks2 = cnn.Execute("insert into 教室 values('" & Grid1.Cell(i, 1).Text & "','" & Grid1.Cell(i, 2).Text & "','" & Grid1.Cell(i, 3).Text & "','" & Grid1.Cell(i, 4).Text & "','0')")
Else
MsgBox "第" & i & "行的教室号已存在,系统自动跳过!", vbInformation, "提示"
End If
End If
Next
MsgBox "资料已保存!", vbInformation, "完成"
Call callmain
End Sub

Private Sub XPButton3_Click()
If ksedit = False Then
MsgBox "当前修改操作不被允许!", vbInformation, "非使用对象"
Exit Sub
End If
For i = 1 To Grid1.Rows - 1
  sql = "update 教室 set "
            For j = 1 To Grid1.Cols - 2
            sql = sql & ks1.Fields(j - 1).Name & "='" & Grid1.Cell(i, j).Text & "',"
            Next
  sql = sql & ks1.Fields(j - 1).Name & "='" & Grid1.Cell(i, j).Text & "' where 教室号='" & Grid1.Cell(i, 1).Text & "'"
  Set ks2 = cnn.Execute(sql) '用qy2更新数据集,这样可实现批量更新
Next
MsgBox "已完成修改!", vbInformation, "操作完成"
End Sub

Private Sub XPButton4_Click()
If ksdel = 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
Set ks1 = cnn.Execute("delete from " & kstable & " where " & ks1.Fields(0).Name & "='" & Grid1.Cell(hang, 1).Text & "'")
MsgBox "目标己删除,请刷新数据!", vbInformation, "删除成功"
Call callmain
End Sub

Private Sub XPButton5_Click()
Unload Me
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -