📄 -
字号:
Xt_Wait.Hide
End Sub
Private Sub Sub_Query() '生成查询结果(Define)
Dim Rec_Query As Recordset '查询结果动态集
Dim Coljsq As Long '网格列计数器
Dim Jsqte As Long '临时动态计数器
Dim Str As String
'以下为自定义部分[
With Tjfx_IncbFxCond
'生成查询条件
Str_QueryCondi = " where inoutflag=1 and " & .WhCode & " and kjyear= " & Xtyear
For Jsqte = 0 To 2
Select Case Jsqte
Case 0 '存货分类(Like)
If Trim(.LrText(0).Text) <> "" Then
Str_QueryCondi = Str_QueryCondi & " And a.invsortcode like '" & Trim(.LrText(0).Tag) & "%'"
End If
Case 1 '查询存货范围(起始)
If Trim(.LrText(1).Text) <> "" Then
Str_QueryCondi = Str_QueryCondi & " And a.mnumber>='" & Trim(.LrText(1).Text) & "'"
End If
Case 2 '查询存货范围(终止)
If Trim(.LrText(2).Text) <> "" Then
Str_QueryCondi = Str_QueryCondi & " And a.mnumber<= '" & Trim(.LrText(2).Text) & "'"
End If
End Select
Next Jsqte
End With
CxbbGrid.Rows = CxbbGrid.FixedRows
If Tjfx_IncbFxCond.Com_FxCond.ListIndex = 0 Then
SqlStr = "SELECT MNumber, MName,Sum(InMoney) as InMoney,Period From Chhs_v_List a" & _
Str_QueryCondi & " Group by MNumber,MName,Period " & _
" ORDER BY a.MNumber "
CxbbGrid.TextMatrix(0, Sydz("001", GridStr(), Szzls)) = "存货编码"
CxbbGrid.TextMatrix(0, Sydz("002", GridStr(), Szzls)) = "存货名称"
Else
SqlStr = "SELECT InOutClassCode, InOutClassName,Sum(InMoney) as InMoney,Period From Chhs_v_List a" & _
Str_QueryCondi & " Group by InOutClassCode, InOutClassName,Period " & _
" ORDER BY a.InOutClassCode "
CxbbGrid.TextMatrix(0, Sydz("001", GridStr(), Szzls)) = "入库类别编码"
CxbbGrid.TextMatrix(0, Sydz("002", GridStr(), Szzls)) = "入库类别名称"
End If
Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(SqlStr)
With Rec_Query
Do While Not .EOF
'[>>自定义填充内容
Str = Trim(.Fields(0) & "")
If Str = "" Then Str = "1"
Jsqte = CxbbGrid.FindRow(Str, , 0)
If Jsqte <= 0 Then
CxbbGrid.AddItem ""
Jsqte = CxbbGrid.Rows - 1
End If
CxbbGrid.TextMatrix(Jsqte, 0) = Str
CxbbGrid.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Trim(.Fields(0) & "")
CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = Trim(.Fields(1) & "")
If .Fields("period") = 1 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 2 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 3 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 4 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 5 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 6 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 7 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("009", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("009", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 8 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("010", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("010", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 9 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("011", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("011", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 10 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("012", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("012", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 11 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("013", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("013", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
If .Fields("period") = 12 Then
If .Fields("InMoney") <> 0 Then
CxbbGrid.TextMatrix(Jsqte, Sydz("014", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("014", GridStr(), Szzls))) + .Fields("InMoney")
End If
End If
'<<]
'设置数据行高度(Fixed)
CxbbGrid.RowHeight(Jsqte) = Sjhgd
.MoveNext
Loop
End With
'输入合计
With CxbbGrid
If .Rows = .FixedRows Then Exit Sub
'横向合计
For Jsqte = .FixedRows To .Rows - 1
For Coljsq = Sydz("003", GridStr(), Szzls) To .Cols - 2
.TextMatrix(Jsqte, .Cols - 1) = Val(.TextMatrix(Jsqte, .Cols - 1)) + Val(.TextMatrix(Jsqte, Coljsq))
Next Coljsq
Next Jsqte
'纵向合计
.SubtotalPosition = flexSTBelow
For Jsqte = Qslz To .Cols - 1
If GridBoolean(Jsqte, 4) Then
.Subtotal flexSTSum, -1, Jsqte, , &HF7F3EC, , , , , True
If Val(.TextMatrix(.Rows - 1, Jsqte)) = 0 Then
.TextMatrix(.Rows - 1, Jsqte) = ""
End If
End If
Next
Jsqte = .Rows - 1
.RowHeight(Jsqte) = Sjhgd
.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = ""
.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = "合计 "
End With
']以上为用户自定义部分
Set Rec_Query = Nothing
End Sub
Private Sub Sub_QueryFz() '横向输出入库类别 '生成查询结果(Define)
Dim Rec_Query As Recordset '查询结果动态集
Dim Coljsq As Long '网格列计数器
Dim Jsqte As Long '临时动态计数器
Dim Str As String
'以下为自定义部分[
CxbbGrid.Rows = CxbbGrid.FixedRows
SqlStr = "SELECT InoutClassCode,InOutClassName, Sum(InMoney) as InMoney,Period From Chhs_v_List a" & _
Str_QueryCondi & " Group by InoutClassCode,InOutClassName,Period " & _
" ORDER BY a.InOutClassCode "
Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(SqlStr)
With Rec_Query
Do While Not .EOF
'[>>自定义填充内容
Str = Trim(.Fields("InOutClassName") & "")
If Str = "" Then Str = "无入库类别"
Jsqte = CxbbGrid.FindRow(.Fields("period"), , Sydz("001", GridStr(), Szzls))
If Jsqte <= 0 Then
CxbbGrid.AddItem ""
Jsqte = CxbbGrid.Rows - 1
End If
CxbbGrid.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Trim(.Fields("period") & "")
For Coljsq = Sydz("003", GridStr(), Szzls) To CxbbGrid.Cols - 1
If Str = "无入库类别" Then
CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls))) + .Fields("InMoney")
Exit For
End If
If Trim(.Fields("InOutClassName") & "") = Trim(CxbbGrid.TextMatrix(0, Coljsq)) Then
CxbbGrid.TextMatrix(Jsqte, Coljsq) = Val(CxbbGrid.TextMatrix(Jsqte, Coljsq)) + .Fields("inmoney")
Exit For
End If
Next Coljsq
'<<]
'设置数据行高度(Fixed)
CxbbGrid.RowHeight(Jsqte) = Sjhgd
.MoveNext
Loop
End With
'输入合计
With CxbbGrid
If .Rows = .FixedRows Then Exit Sub
'横向合计
For Jsqte = .FixedRows To .Rows - 1
For Coljsq = Sydz("003", GridStr(), Szzls) To .Cols - 2
.TextMatrix(Jsqte, .Cols - 1) = Val(.TextMatrix(Jsqte, .Cols - 1)) + Val(.TextMatrix(Jsqte, Coljsq))
Next Coljsq
Next Jsqte
'纵向合计
.SubtotalPosition = flexSTBelow
For Jsqte = Qslz + 1 To .Cols - 1
.Subtotal flexSTSum, -1, Jsqte, , &HF7F3EC, , , , , True
If Val(.TextMatrix(.Rows - 1, Jsqte)) = 0 Then
.TextMatrix(.Rows - 1, Jsqte) = ""
End If
Next
Jsqte = .Rows - 1
.RowHeight(Jsqte) = Sjhgd
.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = "合计 "
End With
']以上为用户自定义部分
Set Rec_Query = Nothing
End Sub
Private Sub bbyl(bbylte As Boolean) '报表打印预览
Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
Bbxbtgs = 1 '报 表 小 标 题 行 数
Bbbwhgs = 0 '报 表 表 尾 行 数
ReDim Bbxbt(1 To Bbxbtgs)
ReDim bbxbtzzxs(1 To Bbxbtgs)
If Bbbwhgs <> 0 Then
ReDim Bbbwh(1 To Bbbwhgs)
ReDim Bbbwhzzxs(1 To Bbbwhgs)
End If
Bbzbt = Lab_Title(0)
Bbxbt(1) = ""
bbxbtzzxs(1) = 0 '报表行组织形式(0-居左 1-居中 2-居右)
Call Scyxsjb(CxbbGrid) '生成报表数据
Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
If Not bbylte Then
Unload DY_Tybbyldy
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -