【VB开源代码栏目提醒】:网学会员鉴于大家对VB开源代码十分关注,论文会员在此为大家搜集整理了“B查询打印.frm”一文,供大家参考学习
VERSION 5.00
Object = "{CDE57A40-8B86-11D0-B3C6-00A0C90AEA82}#1.0#0"; "MSDATGRD.OCX"
Begin VB.Form frmsearchPrint
Caption = "查询打印"
ClientHeight = 5625
ClientLeft = 60
ClientTop = 345
ClientWidth = 9420
LinkTopic = "Form1"
ScaleHeight = 5625
ScaleWidth = 9420
StartUpPosition = 3 '窗口缺省
Begin VB.Frame Frame1
Caption = "课表信息"
Height = 5175
Index = 0
Left = 0
TabIndex = 0
Top = 0
Width = 9135
Begin VB.Frame Frame3
Caption = "查询"
Height = 1995
Left = 60
TabIndex = 1
Top = 3120
Width = 8835
Begin VB.CommandButton CmdExit
BackColor = &H00C0C0C0&
Caption = "退出"
Height = 495
Left = 6420
Style = 1 'Graphical
TabIndex = 11
Top = 1020
Width = 1095
End
Begin VB.CommandButton CmdQuery
Caption = "查询"
Height = 495
Left = 1260
TabIndex = 10
Top = 1020
Width = 1095
End
Begin VB.CommandButton CmdPrint
BackColor = &H00C0C0C0&
Caption = "打印"
Height = 495
Left = 3900
TabIndex = 9
Top = 1020
Width = 1095
End
Begin VB.ComboBox CboQuery
Height = 300
Index = 1
Left = 5700
TabIndex = 8
Top = 300
Width = 1815
End
Begin
VB.OptionButton Option2
Caption = "按教师
查询:"
Height = 255
Left = 4260
TabIndex = 7
Top = 300
Width = 1575
End
Begin VB.ComboBox CboQuery
Height = 315
Index = 0
Left = 1800
TabIndex = 6
Top = 240
Width = 1815
End
Begin VB.OptionButton Option1
Caption = "按班级查询:"
Height = 255
Left = 360
TabIndex = 5
Top = 240
Value = -1 'True
Width = 1695
End
Begin VB.Label Label7
Height = 255
Index = 0
Left = 3840
TabIndex = 3
Top = 1440
Width = 735
End
Begin VB.Label Label7
Height = 375
Index = 1
Left = 5580
TabIndex = 2
Top = 840
Width = 615
End
End
Begin MSDataGridLib.DataGrid DataGrid1
Height = 2535
Left = 120
TabIndex = 4
Top = 360
Width = 8835
_ExtentX = 15584
_ExtentY = 4471
_Version = 393216
BackColor = 12632256
HeadLines = 1
RowHeight = 15
BeginProperty HeadFont {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "MS Sans Serif"
Size = 8.25
Charset = 0
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
ColumnCount = 2
BeginProperty Column00
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
BeginProperty Column01
DataField = ""
Caption = ""
BeginProperty DataFormat {6D835690-900B-11D0-9484-00A0C91110ED}
Type = 0
Format = ""
HaveTrueFalseNull= 0
FirstDayOfWeek = 0
FirstWeekOfYear = 0
LCID = 2052
SubFormatType = 0
EndProperty
EndProperty
SplitCount = 1
BeginProperty Split0
BeginProperty Column00
EndProperty
BeginProperty Column01
EndProperty
EndProperty
End
End
End
Attribute VB_Name = "frmsearchPrint"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Dim rs As ADODB.Recordset
Dim SQL As String
Dim msg As String
Dim index As Integer
Dim flag As String '判断是新增记录还是修改记录
Private Sub Form_Load()
Call InitalComboBox '初始化ComboBox
CmdPrint.Enabled = False
End Sub
Private Sub InitalComboBox()
'初始化班级ComboBox
Dim rst As ADODB.Recordset
Dim strItem As String
SQL = " select className from 班级信息表"
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount > 0 Then
CboQuery(0).AddItem "全部"
Do While Not rst.EOF
strItem = Trim(rst.Fields("className"))
CboQuery(0).AddItem (strItem)
rst.MoveNext
Loop
rst.Close
CboQuery(0).ListIndex = 0
Else
MsgBox ("请先创建班级信息!") '如果没有班级信息不能使用
Exit Sub
End If
'初始化教师ComboBox
SQL = " select teacherID,teacherName from 教师信息表"
Set rst = SelectSQL(SQL, msg)
If rst.RecordCount > 0 Then
Do While Not rst.EOF
strItem = Trim(rst.Fields("teacherID") & rst.Fields("teacherName"))
CboQuery(1).AddItem (strItem)
rst.MoveNext
Loop
rst.Close
CboQuery(1).ListIndex = 0
End If
End Sub
Private Sub CmdQuery_Click()
Call LoadData '装载数据
End Sub
Private Sub LoadData()
'装载数据
Dim strValue As String
Dim strwhere As String
strwhere = ""
If Option1.Value = True Then '如果选择按班级查询
strValue = CboQuery(0).Text
If strValue = "全部" Then strValue = ""
strwhere = " where className like '" & strValue & "%'"
'构建按班级查询课表的SQL
SQL = "SELECT scheduleID,className,itemID,mondayN,tuesdayN,wednesdayN,thursdayN,fridayN,saturdayN,sundayN"
SQL = SQL & " FROM 排课信息表 " & strwhere & " ORDER BY cl