📄 frmsfcl.frm
字号:
sMeg = "查询不能为空!"
MsgBox sMeg, vbOKOnly + vbExclamation, "警告"
Text2.SetFocus
Exit Sub
Else
dd(1) = True
If dd(0) Then
'组合查询语句
If Cbo_Operator(1).ListIndex = 0 Then
txtSQL = txtSQL & " and " & myquery(1) & " " & Cbo_Operator(1).Text & " '%" & Text2.Text & "%'"
Else
txtSQL = txtSQL & " and " & "" & myquery(1) & " " & Cbo_Operator(1).Text & " '" & Text2.Text & "'"
End If
Else
If Cbo_Operator(1).ListIndex = 0 Then
txtSQL = txtSQL & "" & myquery(1) & " " & Cbo_Operator(1).Text & " '%" & Text2.Text & "%'"
Else
txtSQL = txtSQL & " " & "" & myquery(1) & " " & Cbo_Operator(1).Text & " '" & Text2.Text & "'"
End If
'txtSQL = txtSQL & "" & Cbo_Category(1).Text & " " & Cbo_Operator(1) & " '" & Text2.Text & "'"
End If
End If
End If
'判断是否设置查询方式
If Not (dd(0) Or dd(1) Or dd(2)) Then
MsgBox "请设置查询方式!", vbOKOnly + vbExclamation, "警告"
Exit Sub
End If
'查询所有满足条件的内容
txtSQL = txtSQL '& " order by wenjian_id"
txtSQL1 = txtSQL & " and xingzhi='收文' order by wenjian_id"
txtSQL2 = txtSQL & " and xingzhi='发文' order by wenjian_id"
'执行查询语句
Set mrc = ExecuteSQL(txtSQL1, MsgText)
Label1.Caption = txtSQL1
'''''''''''''''''''''''''''''''''''''''''''''''''''''''判断并显示
''''''''''''''''收文信息
'将查询内容显示在表格控件中
With myflexgrid
.ForeColor = &HC00000
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "文件号"
.TextMatrix(0, 1) = "文件属性"
.TextMatrix(0, 2) = "文件名"
.TextMatrix(0, 3) = "发文单位"
.TextMatrix(0, 4) = "收文日期"
.TextMatrix(0, 5) = "份数"
.TextMatrix(0, 6) = "签收人"
.TextMatrix(0, 7) = "备注"
.TextMatrix(0, 8) = ""
'判断是否移动到数据集对象的最后一条记录
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = "" & mrc.Fields(0)
.TextMatrix(.Rows - 1, 1) = "" & mrc.Fields(1)
.TextMatrix(.Rows - 1, 2) = "" & mrc.Fields(2)
.TextMatrix(.Rows - 1, 3) = "" & mrc.Fields(3)
.TextMatrix(.Rows - 1, 4) = "" & Format(mrc.Fields(4), "yyyy-mm-dd")
.TextMatrix(.Rows - 1, 5) = "" & mrc.Fields(5)
.TextMatrix(.Rows - 1, 6) = "" & mrc.Fields(7)
.TextMatrix(.Rows - 1, 7) = "" & mrc.Fields(8)
.TextMatrix(.Rows - 1, 8) = ""
'移动到下一条记录
mrc.MoveNext
Loop
End With
''''''''''''''''''''''''''发文信息
Set mrc = ExecuteSQL(txtSQL2, MsgText)
Label1.Caption = txtSQL2
With myflexgrid1
.ForeColor = &HC00000
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "文件号"
.TextMatrix(0, 1) = "文件属性"
.TextMatrix(0, 2) = "文件名"
.TextMatrix(0, 3) = "收文单位"
.TextMatrix(0, 4) = "发文日期"
.TextMatrix(0, 5) = "份数"
.TextMatrix(0, 6) = "起草人"
.TextMatrix(0, 7) = "签发人"
.TextMatrix(0, 8) = "备注"
'判断是否移动到数据集对象的最后一条记录
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = "" & mrc.Fields(0)
.TextMatrix(.Rows - 1, 1) = "" & mrc.Fields(1)
.TextMatrix(.Rows - 1, 2) = "" & mrc.Fields(2)
.TextMatrix(.Rows - 1, 3) = "" & mrc.Fields(3)
.TextMatrix(.Rows - 1, 4) = "" & Format(mrc.Fields(4), "yyyy-mm-dd")
.TextMatrix(.Rows - 1, 5) = "" & mrc.Fields(5)
.TextMatrix(.Rows - 1, 6) = "" & mrc.Fields(6)
.TextMatrix(.Rows - 1, 7) = "" & mrc.Fields(7)
.TextMatrix(.Rows - 1, 8) = "" & mrc.Fields(8)
'移动到下一条记录
mrc.MoveNext
Loop
End With
''''''判断出错信息
If (myflexgrid.Rows = 1 And myflexgrid1.Rows = 1) Then GoTo OOPS
'关闭数据集
mrc.Close
Exit Sub
OOPS:
MsgBox "No Records Found"
End Sub
Private Sub cmdleft_Click()
myflexgrid.Height = 1575
End Sub
Private Sub Cmdshang_Click()
myflexgrid1.top = 300
myflexgrid1.left = 120
myflexgrid1.Width = 7000
myflexgrid1.Height = 4000
Label2.Caption = "发文"
Label3.Visible = False
myflexgrid.Visible = False
myflexgrid1.Visible = True
End Sub
Private Sub cmdxia_Click()
myflexgrid.top = 300
myflexgrid.left = 120
myflexgrid.Width = 7000
myflexgrid.Height = 4000
myflexgrid1.Visible = False
myflexgrid.Visible = True
Label2.Caption = "收文"
Label3.Visible = False
End Sub
Private Sub cmdzh_Click()
myflexgrid1.top = 2550
myflexgrid1.left = 120
myflexgrid1.Width = 7000
myflexgrid1.Height = 1815
myflexgrid.top = 300
myflexgrid.left = 120
myflexgrid.Width = 7000
myflexgrid.Height = 1815
Label2.Caption = "收文"
Label3.Caption = "发文"
myflexgrid1.Visible = True
myflexgrid.Visible = True
Label2.Visible = True
Label3.Visible = True
End Sub
'''''''''''''''''''''''''按钮显示所有记录
Private Sub Command1_Click()
Dim txtSQL As String
Dim MsgText As String
Dim dd(4) As Boolean
Dim mrc As ADODB.Recordset
'''''''''''''''''''''''''''''''''''''''''''显示所有记录
'收文信息
txtSQL = "select wenjian_id,xingzhi,filename,danwei,fdate,number,qianfaren,beizhu from gongwenguanli where xingzhi='收文'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
With myflexgrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "文件号"
.TextMatrix(0, 1) = "文件属性"
.TextMatrix(0, 2) = "文件名"
.TextMatrix(0, 3) = "发文单位"
.TextMatrix(0, 4) = "收文日期"
.TextMatrix(0, 5) = "份数"
.TextMatrix(0, 6) = "签收人"
.TextMatrix(0, 7) = "备注"
.TextMatrix(0, 8) = ""
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = "" & mrc.Fields(0)
.TextMatrix(.Rows - 1, 1) = "" & mrc.Fields(1)
.TextMatrix(.Rows - 1, 2) = "" & mrc.Fields(2)
.TextMatrix(.Rows - 1, 3) = "" & mrc.Fields(3)
.TextMatrix(.Rows - 1, 4) = "" & Format(mrc.Fields(4), "yyyy-mm-dd")
.TextMatrix(.Rows - 1, 5) = "" & mrc.Fields(5)
.TextMatrix(.Rows - 1, 6) = "" & mrc.Fields(6)
.TextMatrix(.Rows - 1, 7) = "" & mrc.Fields(7)
.TextMatrix(.Rows - 1, 8) = ""
'移动到下一条记录
mrc.MoveNext
Loop
End With
'发文信息
txtSQL = "select * from gongwenguanli where xingzhi='发文'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
With myflexgrid1
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "文件号"
.TextMatrix(0, 1) = "文件属性"
.TextMatrix(0, 2) = "文件名"
.TextMatrix(0, 3) = "收文单位"
.TextMatrix(0, 4) = "发文日期"
.TextMatrix(0, 5) = "份数"
.TextMatrix(0, 6) = "起草人"
.TextMatrix(0, 7) = "签发人"
.TextMatrix(0, 8) = "备注"
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = "" & mrc.Fields(0)
.TextMatrix(.Rows - 1, 1) = "" & mrc.Fields(1)
.TextMatrix(.Rows - 1, 2) = "" & mrc.Fields(2)
.TextMatrix(.Rows - 1, 3) = "" & mrc.Fields(3)
.TextMatrix(.Rows - 1, 4) = "" & Format(mrc.Fields(4), "yyyy-mm-dd")
.TextMatrix(.Rows - 1, 5) = "" & mrc.Fields(5)
.TextMatrix(.Rows - 1, 6) = "" & mrc.Fields(6)
.TextMatrix(.Rows - 1, 7) = "" & mrc.Fields(7)
.TextMatrix(.Rows - 1, 8) = "" & mrc.Fields(8)
'移动到下一条记录
mrc.MoveNext
Loop
End With
End Sub
Private Sub Command2_Click()
frmDatawen.Show
End Sub
'初始化网格
Private Sub Form_Load()
Dim txtSQL As String
Dim MsgText As String
Dim dd(4) As Boolean
Dim mrc As ADODB.Recordset
''''''''''''''''''''''''''''''''''收文信息
tt = 0
Label1.Visible = False
With myflexgrid
.ColWidth(0) = 1000
.ColWidth(1) = 600
.ColWidth(2) = 1400
.ColWidth(3) = 1000
.ColWidth(4) = 1000
.ColWidth(5) = 700
.ColWidth(6) = 800
.ColWidth(7) = 1000
.CellAlignment = 4
.TextMatrix(0, 0) = "文件号"
.TextMatrix(0, 1) = "文件属性"
.TextMatrix(0, 2) = "文件名"
.TextMatrix(0, 3) = "发文单位"
.TextMatrix(0, 4) = "收文日期"
.TextMatrix(0, 5) = "份数"
.TextMatrix(0, 6) = "签收人"
.TextMatrix(0, 7) = "备注"
End With
''''''''''''''''''''''''''''''''''发文文信息
With myflexgrid1
.ColWidth(0) = 1000
.ColWidth(1) = 600
.ColWidth(2) = 1400
.ColWidth(3) = 1000
.ColWidth(4) = 1000
.ColWidth(5) = 700
.ColWidth(6) = 800
.ColWidth(7) = 800
.ColWidth(8) = 1000
.CellAlignment = 4
.TextMatrix(0, 0) = "文件号"
.TextMatrix(0, 1) = "文件属性"
.TextMatrix(0, 2) = "文件名"
.TextMatrix(0, 3) = "收文单位"
.TextMatrix(0, 4) = "发文日期"
.TextMatrix(0, 5) = "份数"
.TextMatrix(0, 6) = "起草人"
.TextMatrix(0, 7) = "签发人"
.TextMatrix(0, 8) = "备注"
End With
'''''''''''''''''''''''''''''''''''''''''''''''下拉表
For i = 0 To 1
Cbo_Category(i).AddItem "文件号"
Cbo_Category(i).AddItem "文件名"
Cbo_Category(i).AddItem "单位"
Cbo_Category(i).AddItem "日期"
Cbo_Category(i).AddItem "签发/收人"
Cbo_Category(i).ListIndex = 0
Cbo_Operator(i).ListIndex = 0
Next i
'''''''''''''''''''''''''''''''''''''''''''显示所有记录
'收文信息
txtSQL = "select wenjian_id,xingzhi,filename,danwei,fdate,number,qianfaren,beizhu from gongwenguanli where xingzhi='收文'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
With myflexgrid
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "文件号"
.TextMatrix(0, 1) = "文件属性"
.TextMatrix(0, 2) = "文件名"
.TextMatrix(0, 3) = "发文单位"
.TextMatrix(0, 4) = "收文日期"
.TextMatrix(0, 5) = "份数"
.TextMatrix(0, 6) = "签收人"
.TextMatrix(0, 7) = "备注"
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = "" & mrc.Fields(0)
.TextMatrix(.Rows - 1, 1) = "" & mrc.Fields(1)
.TextMatrix(.Rows - 1, 2) = "" & mrc.Fields(2)
.TextMatrix(.Rows - 1, 3) = "" & mrc.Fields(3)
.TextMatrix(.Rows - 1, 4) = "" & Format(mrc.Fields(4), "yyyy-mm-dd")
.TextMatrix(.Rows - 1, 5) = "" & mrc.Fields(5)
.TextMatrix(.Rows - 1, 6) = "" & mrc.Fields(6)
.TextMatrix(.Rows - 1, 7) = "" & mrc.Fields(7)
'移动到下一条记录
mrc.MoveNext
Loop
End With
'发文信息
txtSQL = "select * from gongwenguanli where xingzhi='发文'"
Set mrc = ExecuteSQL(txtSQL, MsgText)
With myflexgrid1
.Rows = 1
.CellAlignment = 4
.TextMatrix(0, 0) = "文件号"
.TextMatrix(0, 1) = "文件属性"
.TextMatrix(0, 2) = "文件名"
.TextMatrix(0, 3) = "收文单位"
.TextMatrix(0, 4) = "发文日期"
.TextMatrix(0, 5) = "份数"
.TextMatrix(0, 6) = "起草人"
.TextMatrix(0, 7) = "签发人"
.TextMatrix(0, 8) = "备注"
Do While Not mrc.EOF
.Rows = .Rows + 1
.CellAlignment = 4
.TextMatrix(.Rows - 1, 0) = "" & mrc.Fields(0)
.TextMatrix(.Rows - 1, 1) = "" & mrc.Fields(1)
.TextMatrix(.Rows - 1, 2) = "" & mrc.Fields(2)
.TextMatrix(.Rows - 1, 3) = "" & mrc.Fields(3)
.TextMatrix(.Rows - 1, 4) = "" & Format(mrc.Fields(4), "yyyy-mm-dd")
.TextMatrix(.Rows - 1, 5) = "" & mrc.Fields(5)
.TextMatrix(.Rows - 1, 6) = "" & mrc.Fields(6)
.TextMatrix(.Rows - 1, 7) = "" & mrc.Fields(7)
.TextMatrix(.Rows - 1, 8) = "" & mrc.Fields(8)
'移动到下一条记录
mrc.MoveNext
Loop
End With
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -