Set ks1 = cnn.Execute("select * from 日程设定 order by 序号 asc")
'通过SQL的查询语句将日程设定的日期和时间写入表格
For i = 1 To Grid1.Cols - 1
Grid1.Column(i).Width = 120
Grid1.Cell(0, i).Text = ks1.Fields(0) & vbCrLf & ks1.Fields(1)
ks1.MoveNext
Next
m = 1 '变量初始化
n = 0
X = 1
Set ks2 = cnn.Execute("SELECT DISTINCT 系名 from 课程")
Do While Not ks2.EOF
For i = 1 To 4 '通过固定的1-4年级和系名来确定可以存在的年级
Set ks3 = cnn.Execute("select count(*) from 课程 where 系名='" & ks2.Fields(0) & "' and 年级='" & i & "'")
If ks3.Fields(0) > 0 Then
Grid1.Rows = Grid1.Rows + 1
Grid1.RowHeight(Grid1.Rows - 1) = 120
Grid1.Cell(Grid1.Rows - 1, 0).Text = ks2.Fields(0) & vbCrLf & i & "年级"
Set ks3 = cnn.Execute("select * from 生成 where 系名='" & ks2.Fields(0) & "' and 年级='" & i & "' order by
序号 asc")
'这里开始查询对应班级的考试安排情况
For n = 1 To len1 '由于每个系并不一定就是一个考场教室,所以在用逗号分开的各教室号在次区别开来
If Mid(ks3.Fields(3), n, 1) = "," Then
str1 = Mid(ks3.Fields(3), m, Y - 1)
m = n + 1
Y = 0
'查找并合并对应的监考教师并写入表格
Set ks4 = cnn.Execute("select * from 监考教师 where 日期='" & ks3.Fields(0) & "' and 时间='" & ks3.Fields
(1) & "' and 教室号='" & str1 & "'")
sstr1 = sstr1 & str1 & "(" & ks4.Fields(1) & "),"
End If
Y = Y + 1
Next
str1 = Mid(ks3.Fields(3), m, Y - 1)
m = n + 1
Y = 0
Set ks4 = cnn.Execute("select * from 监考教师 where 日期='" & ks3.Fields(0) & "' and 时间='" & ks3.Fields(1) & "' and 教室号='" & str1 & "'")
sstr1 = sstr1 & str1 & "(" & ks4.Fields(1) & ")"
Grid1.Cell(Grid1.Rows - 1, j).Text = ks3.Fields(2) & vbCrLf & "教室:" & ks3.Fields(3) & vbCrLf & "监考:" & sstr1
sstr1 = ""
ks3.MoveNext
Loop
End If
Next
ks2.MoveNext
Loop
Grid1.Range(0, 0, Grid1.Rows - 1, Grid1.Cols - 1).WrapText = True
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub Form_Resize()
If Me.WindowState <> 1 Then
Grid1.Left = (Me.Width - Grid1.Width) / 2
Grid1.Width = (Me.Width / 2) + Grid1.Left
Grid1.Left = (Me.Width - Grid1.Width) / 2
Grid1.Top = 600
Grid1.Height = Me.Height - Grid1.Top - 600
XPButton1.Left = (Me.Width - XPButton1.Width) / 2
End If
End Sub
Private Sub Grid1_AfterReorderColumn(ByVal OriginalPosition As Long, ByVal NewPosition As Long)
End Sub
Private Sub print_Click()
On Error GoTo finish
'设置打印区域
Grid1.PageSetup.PrintFixedRow = True '设定是否允许打印第0行
Grid1.PageSetup.PrintFixedColumn = True '是否打印第0列
Grid1.PageSetup.PrintRows = Grid1.Rows - 1 '需要打印的总行数
Grid1.PageSetup.PrintColumns = Grid1.Cols - 1 '需要打印的总列数
Grid1.PageSetup.PrintGridlines = True '是否显示中间的分隔线,即表格线
'Grid1.AutoRedraw = True
Grid1.PageSetup.Orientation = cellLandscape '采用横幅打印还是竖行打印
'Grid1.PrintDialog
Grid1.PrintPreview '打印预览
Grid1.Refresh
Exit Sub
finish:
MsgBox Err.Description
End Sub
Private Sub XPButton1_Click()
Call print_Click
End Sub
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
.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 = 40
.Column(3).Width = 100
.Column(4).Width = 40
End With
Me.BackColor = RGB(84, 201, 134)
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 IsNull(ks1.Fields(j - 1)) 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 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(1).CellType = cellComboBox
www.751com.cn
Grid1.ComboBox(2).AddItem i
Next
For i = 0 To 3 '显示数据的字段名
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
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
上一页 [1] [2] [3] [4] [5] [6] [7] [8] [9] 下一页