📄 querystgood.frm
字号:
VERSION 5.00
Object = "{5E9E78A0-531B-11CF-91F6-C2863C385E30}#1.0#0"; "MSFLXGRD.OCX"
Begin VB.Form querystgood
Caption = "Form1"
ClientHeight = 7920
ClientLeft = 60
ClientTop = 345
ClientWidth = 10935
LinkTopic = "Form1"
LockControls = -1 'True
MDIChild = -1 'True
ScaleHeight = 7920
ScaleWidth = 10935
Begin VB.CommandButton Command4
Caption = "关闭(&C)"
Height = 495
Left = 4200
TabIndex = 14
Top = 1680
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "打印预览(&P)"
Height = 495
Left = 3000
TabIndex = 13
Top = 1680
Width = 1215
End
Begin VB.CommandButton Command2
Caption = "清除(&E)"
Height = 495
Left = 1800
TabIndex = 12
Top = 1680
Width = 1215
End
Begin VB.CommandButton Command1
Caption = "查询(&Q)"
Height = 495
Left = 600
TabIndex = 11
Top = 1680
Width = 1215
End
Begin MSFlexGridLib.MSFlexGrid MSFlexGrid1
Height = 4815
Left = 240
TabIndex = 10
Top = 2520
Width = 10575
_ExtentX = 18653
_ExtentY = 8493
_Version = 393216
ForeColor = 16711680
ForeColorSel = 65280
End
Begin VB.TextBox Text5
Height = 495
Left = 9120
TabIndex = 9
Top = 1560
Width = 1695
End
Begin VB.Frame Frame2
Height = 855
Left = 240
TabIndex = 7
Top = 1440
Width = 5535
End
Begin VB.Frame Frame1
Height = 1335
Left = 240
TabIndex = 0
Top = 0
Width = 10575
Begin VB.OptionButton Option1
Caption = "按性别"
Height = 375
Index = 5
Left = 9240
TabIndex = 20
Top = 240
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "按日期"
Height = 375
Index = 4
Left = 7200
TabIndex = 19
Top = 240
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "按奖励级别"
Height = 375
Index = 3
Left = 5400
TabIndex = 18
Top = 240
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "按学号"
Height = 375
Index = 2
Left = 3720
TabIndex = 17
Top = 240
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "按姓名 "
Height = 375
Index = 1
Left = 1920
TabIndex = 16
Top = 240
Width = 1335
End
Begin VB.OptionButton Option1
Caption = "按班级"
Height = 375
Index = 0
Left = 360
TabIndex = 15
Top = 240
Width = 1335
End
Begin VB.ComboBox Combo2
Height = 300
Left = 9240
TabIndex = 6
Top = 720
Width = 975
End
Begin VB.ComboBox Combo1
Height = 300
Left = 5520
TabIndex = 5
Top = 720
Width = 1215
End
Begin VB.TextBox Text4
Height = 375
Left = 7200
TabIndex = 4
Top = 720
Width = 1695
End
Begin VB.TextBox Text3
Height = 375
Left = 3720
TabIndex = 3
Top = 720
Width = 1575
End
Begin VB.TextBox Text2
Height = 375
Left = 1920
TabIndex = 2
Top = 720
Width = 1455
End
Begin VB.TextBox Text1
Height = 375
Left = 360
TabIndex = 1
Top = 720
Width = 1215
End
End
Begin VB.Label Label1
Caption = "记录总数"
Height = 495
Left = 8160
TabIndex = 8
Top = 1680
Width = 855
End
End
Attribute VB_Name = "querystgood"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Public Sub showtitle()
Dim i As Integer
With MSFlexGrid1
.Cols = 13
.TextMatrix(0, 1) = "编号"
.TextMatrix(0, 2) = "学号"
.TextMatrix(0, 3) = "姓名"
.TextMatrix(0, 4) = "性别"
.TextMatrix(0, 5) = "班级"
.TextMatrix(0, 6) = "日期"
.TextMatrix(0, 7) = "省级"
.TextMatrix(0, 8) = "市级"
.TextMatrix(0, 9) = "县级"
.TextMatrix(0, 10) = "校级"
.TextMatrix(0, 11) = "其它"
.TextMatrix(0, 12) = "详细描述"
.FixedRows = 1
For i = 0 To 12
.ColAlignment(i) = 0
Next i
.FillStyle = flexFillRepeat
.col = 0
.row = 0
.RowSel = 1
.ColSel = .Cols - 1
.CellAlignment = 4
.ColWidth(0) = 200
.ColWidth(1) = 700
.ColWidth(2) = 1400
.ColWidth(3) = 900
.ColWidth(4) = 600
.ColWidth(5) = 800
.ColWidth(6) = 1000
.ColWidth(7) = 1000
.ColWidth(8) = 800
.ColWidth(9) = 900
.ColWidth(10) = 1200
.ColWidth(11) = 800
.ColWidth(12) = 4200
.FixedRows = 1
End With
End Sub
Public Sub showData()
Dim i As Integer
Dim j As Integer
Set dream = ExecuteSQL(txtSQL, Msgtext)
If dream.EOF = False Then
With MSFlexGrid1
.Rows = 1
Do While Not dream.EOF
.Rows = .Rows + 1
For i = 1 To dream.Fields.Count
Select Case dream.Fields(i - 1).Type
Case adDBDate
.TextMatrix(.Rows - 1, i) = Format(dream.Fields(i - 1) & "", "yy-mm-dd")
Case Else
.TextMatrix(.Rows - 1, i) = dream.Fields(i - 1) & " "
End Select
Next i
dream.MoveNext
Loop
End With
End If
dream.Close
End Sub
Private Sub Command1_Click()
MSFlexGrid1.Clear 'use to clear old records
Dim dd(6) As Boolean
UserName = ""
txtSQL = "select * from studgood where "
If Option1(0).Value Then
If Trim(Text1.Text) = " " Then
sMeg = "班级不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Text1.SetFocus
Exit Sub
Else
dd(0) = True
If dd(0) Then
UserName = Trim(Text1.Text) '
txtSQL = txtSQL & "班级 = '" & UserName & "' "
Else
txtSQL = txtSQL & "班级 = '" & UserName & "%' "
End If
End If
ElseIf Option1(1).Value Then
If Trim(Text2.Text) = "" Then
sMeg = "姓名不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Text2.SetFocus
Exit Sub
Else
dd(1) = True
If dd(1) Then
txtSQL = txtSQL & " 姓名 = '" & Text2.Text & "'"
Else
txtSQL = txtSQL & " 姓名 like '" & Text2.Text & "%'"
End If
End If
'End If
'----------------------------
ElseIf Option1(2).Value Then
If Trim(Text3.Text) = "" Then
sMeg = "学号不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Text3.SetFocus
Exit Sub
Else
dd(2) = True
If dd(2) Then
txtSQL = txtSQL & " 学号 = '" & Text3.Text & "'"
Else
txtSQL = txtSQL & " 学号 like '" & Text3.Text & "%'"
End If
End If
ElseIf Option1(3).Value Then
If Trim(Combo1.Text) = " " Then
sMeg = "请选择奖励级别!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Combo1.SetFocus
Exit Sub
Else
dd(3) = True
If dd(3) Then
txtSQL = txtSQL & "奖励级别 = '" & Combo1.Text & " ' "
Else
txtSQL = txtSQL & "奖励级别 like '" & Combo1.Text & "%'"
End If
End If
ElseIf Option1(4).Value Then
If Trim(Text5.Text) = "" Then
sMeg = "日期不能为空"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Text5.SetFocus
Exit Sub
Else
dd(4) = True
If dd(4) Then
txtSQL = txtSQL & " 日期= '" & Text5.Text & "'"
Else
txtSQL = txtSQL & " 日期 like '" & Text5.Text & "%'"
End If
End If
ElseIf Option1(5).Value Then
If Trim(Combo2.Text) = "" Then
sMeg = "请选择性别!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Text6.SetFocus
Exit Sub
Else
dd(5) = True
If dd(5) Then
txtSQL = txtSQL & " 性别= '" & Combo2.Text & "'"
Else
txtSQL = txtSQL & " 性别 like '" & Combo2.Text & "%'"
End If
End If
End If
If Not (dd(0) Or dd(1) Or dd(2) Or dd(3) Or dd(4) Or dd(5)) Then
MsgBox "请设置查询条件!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
txtSQL = txtSQL & " order by 编号 "
Set dream = ExecuteSQL(txtSQL, Msgtext)
If dream.EOF = True Then 'exsit record ?
MsgBox "没有此记录!", 48, "警告"
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1.Text = ""
Text5.Text = ""
Combo2.Text = ""
Else
With MSFlexGrid1
.Rows = 1
' .CellAlignmet = 4
.TextMatrix(0, 1) = "编号"
.TextMatrix(0, 2) = "学号"
.TextMatrix(0, 3) = "姓名"
.TextMatrix(0, 4) = "性别"
.TextMatrix(0, 5) = "班级"
.TextMatrix(0, 6) = "日期"
.TextMatrix(0, 7) = "省级"
.TextMatrix(0, 8) = "市级"
.TextMatrix(0, 9) = "县级"
.TextMatrix(0, 10) = "校级"
.TextMatrix(0, 11) = "其它"
.TextMatrix(0, 12) = "详细描述"
Do While Not dream.EOF
.Rows = .Rows + 1
.CellAlignment = 0
.TextMatrix(.Rows - 1, 1) = dream.Fields(0)
.TextMatrix(.Rows - 1, 2) = dream.Fields(1)
.TextMatrix(.Rows - 1, 3) = dream.Fields(2)
.TextMatrix(.Rows - 1, 4) = dream.Fields(3)
.TextMatrix(.Rows - 1, 5) = dream.Fields(4)
.TextMatrix(.Rows - 1, 6) = Format(dream.Fields(5), "yyyy-mm-dd")
.TextMatrix(.Rows - 1, 7) = dream.Fields(6)
.TextMatrix(.Rows - 1, 8) = dream.Fields(7)
.TextMatrix(.Rows - 1, 9) = dream.Fields(8)
.TextMatrix(.Rows - 1, 10) = dream.Fields(9)
.TextMatrix(.Rows - 1, 11) = dream.Fields(10)
'.TextMatrix(.Rows - 1, 12) = dream.Fields(11)
dream.MoveNext
Loop
End With
End If
dream.Close
End Sub
Private Sub Command2_Click()
showtitle
txtSQL = "select *from studgood order by 编号"
showData
Text1.Text = ""
Text2.Text = ""
Text3.Text = ""
Combo1 = ""
Text5.Text = ""
Combo2 = ""
End Sub
Private Sub Command4_Click()
Unload Me
End Sub
Private Sub Form_Load()
Combo1.AddItem "省级"
Combo1.AddItem "市级"
Combo1.AddItem "县级"
Combo1.AddItem "校级"
Combo1.AddItem "其它"
Combo2.AddItem "女"
Combo2.AddItem "男"
querystgood.Height = 7990
querystgood.Width = 11160
'dispaly records
showtitle
txtSQL = "select *from studgood order by 编号" 'sort
showData
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -