📄
字号:
Dim ReportTitle As String '报表主标题
Dim Str_QueryCondi As String '用户录入查询条件
Dim Rec_BillID As New ADODB.Recordset '用户查询单据ID动态集
'以下为固定使用变量
Dim Dyymctbl As New DY_Dyymsz '打印页面窗体变量
Dim GridCode As String '显示网格网格代码
Dim GridInf() As Variant '整个网格设置信息
Dim Tsxx As String '系统提示信息
Dim Qslz As Long '网格隐藏(非操作显示)列数
Dim Sjhgd As Double '网格数据行高度
Dim Sfxshjwg As Boolean '是否显示合计网格
Dim GridBoolean() As Boolean '网格列信息(布尔型)
Dim GridStr() As String '网格列信息(字符型)
Dim GridInt() As Integer '网格列信息(整型)
Dim Szzls As Integer '数组总列数(网格列数-1)
Private Sub Form_Resize() '根据窗体大小来调整网格,标题栏大小(Fixed)
On Error Resume Next
With CxbbGrid
.Width = Me.Width - 160
.Height = Me.Height - .Top - 400
End With
With Pic_Title
.Width = Me.Width - 160
End With
GsToolbar.Left = Me.Width - GsToolbar.Width - 140
End Sub
Private Sub Form_Load() '窗体装入
'调入打印页面设置窗体
ReportTitle = "呆滞积压分析"
XtReportCode = "kf_alertdzjy"
Load Dyymctbl
'调整标题栏及网格、格式工具条位置(Fixed)
Pic_Title.Left = 40
Pic_Title.Top = SzToolbar.Top + SzToolbar.Height - 10
CxbbGrid.Left = Pic_Title.Left
CxbbGrid.Top = Pic_Title.Top + Pic_Title.Height + 20
'调 入 网 格(Fixed)
GridCode = "KF_alertdzjy"
Call BzWgcsh(CxbbGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
Qslz = GridInf(1)
Sjhgd = GridInf(2)
Sfxshjwg = GridInf(7)
Szzls = CxbbGrid.Cols - 1
End Sub
Private Sub Form_Unload(Cancel As Integer) '窗体卸载
'卸载条件窗体
KF_AlertDzjyQuery.UnloadCheck.Value = 1
Unload KF_AlertDzjyQuery
'卸载打印页面设置窗体
Unload Dyymctbl
End Sub
Private Sub CxbbGrid_BeforeMoveColumn(ByVal Col As Long, Position As Long) '网格列发生移动时自动交换网格索引信息
Call FnBln_RefreshArray(Col, Position, GridStr(), GridInf())
End Sub
Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button) '网格格式调整(Fixed)
Select Case Button.Key
Case "bcgs" '保存表格格式
Call Bcwggs(CxbbGrid, GridCode, GridStr())
Case "hfmrgs" '恢复默认格式
Call Hfmrgs(CxbbGrid, GridCode, GridStr())
Case "szxsxm" '设置显示项目
Call Szxsxm(CxbbGrid, GridCode)
End Select
End Sub
Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
Select Case Button.Key
Case "ymsz" '页面设置
Dyymctbl.Show 1
Case "yl" '预 览
Call bbyl(True)
Case "dy" '打 印
Call bbyl(False)
Case "cx" '查 询
KF_AlertDzjyQuery.Show 1
Case "bz" '帮 助
Call F1bz
Case "fh" '退 出
Unload Me
End Select
End Sub
Private Sub Timer1_Timer() '在窗体激活后调入查询程序
Timer1.Enabled = False
Xt_Wait.Show
Xt_Wait.Refresh
'加快显示速度
CxbbGrid.Redraw = False
'生成查询结果
Call Sub_Query
CxbbGrid.Redraw = True
Xt_Wait.Hide
End Sub
Private Sub Sub_Query() '生成查询结果
Dim strBeginDate As String '起始日期字符串
Dim strEndDate As String '终止日期字符串
Dim strKind As String '物料分类字符串
Dim strNumber As String '物料编码字符串
Dim dblConCircle As Double '呆滞积压标准
Dim dblConCircle1 As Double '呆滞积压标准
Dim strJudgeType As String '判断标准
Dim strQueryType As String '查询标准
Dim strSQL As String
Dim temp_recordset As New ADODB.Recordset
Dim Rec_Query As New ADODB.Recordset '查询结果动态集
Dim jsqte As Integer '临时动态计数器
Dim intRecNum As Integer '组合查询条件计数器
With KF_AlertDzjyQuery
strBeginDate = Trim(.LrText(0).Text)
strEndDate = Trim(.LrText(1).Text)
strKind = Trim(.LrText(2).Tag)
strNumber = Trim(.LrText(3).Tag)
If Trim(.LrText(4).Text) <> "" Then
dblConCircle = Val(Trim(.LrText(4).Text))
Else
dblConCircle = 0
End If
If Trim(.LrText(5).Text) <> "" Then
dblConCircle1 = Val(Trim(.LrText(5).Text))
Else
dblConCircle1 = 0
End If
strJudgeType = Trim(.cmbquan.Text)
strQueryType = Trim(.cmbtype.Text)
End With
'执行存储过程kf_DZJY_Judge
Cw_DataEnvi.DataConnect.Execute ("KF_SP_DZJY_Judge '" & strNumber & "','" & CDate(strBeginDate) & "','" & CDate(strEndDate) & "','" & strKind & "'," & dblConCircle & ",'" & strJudgeType & "'")
strSQL = "SELECT * FROM ##DZJY_Temp WHERE 1=1"
For intRecNum = 1 To 3
Select Case intRecNum
Case 1 '物料编码
If strNumber <> "" Then
strSQL = strSQL & " and mnumber='" & strNumber & "'"
End If
Case 2 '周转率
If dblConCircle <> 0 And dblConCircle1 <> 0 Then
strSQL = strSQL & " and concircle between " & dblConCircle & " and " & dblConCircle1
ElseIf dblConCircle <> 0 And dblConCircle1 = 0 Then
strSQL = strSQL & " and concircle>= " & dblConCircle
ElseIf dblConCircle = 0 And dblConCircle1 <> 0 Then
strSQL = strSQL & " and concircle<= " & dblConCircle1
End If
Case 3 '查询类型
If strQueryType <> "全部" Then
strSQL = strSQL & " and state='" & strQueryType & "'"
End If
End Select
Next intRecNum
strSQL = strSQL & " order by mnumber"
Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(strSQL)
With Rec_Query
CxbbGrid.Rows = CxbbGrid.FixedRows
CxbbGrid.Rows = CxbbGrid.FixedRows + .RecordCount
jsqte = CxbbGrid.FixedRows
CxbbGrid.ExplorerBar = flexExMove
Do While Not .EOF
If jsqte >= CxbbGrid.Rows Then
CxbbGrid.AddItem ""
End If
CxbbGrid.TextMatrix(jsqte, Sydz("001", GridStr(), Szzls)) = Trim(.Fields("mnumber")) '物料编码
CxbbGrid.TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = Trim(.Fields("mname")) '物料名称
CxbbGrid.TextMatrix(jsqte, Sydz("003", GridStr(), Szzls)) = Trim(.Fields("model") & "") '规格型号
CxbbGrid.TextMatrix(jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("primaryunit") & "") '计量单位
If .Fields("highstorage") = 0 Then
CxbbGrid.TextMatrix(jsqte, Sydz("005", GridStr(), Szzls)) = 0
Else
CxbbGrid.TextMatrix(jsqte, Sydz("005", GridStr(), Szzls)) = .Fields("highstorage") '最高储备
End If
If .Fields("safetystorage") = 0 Then
CxbbGrid.TextMatrix(jsqte, Sydz("006", GridStr(), Szzls)) = 0
Else
CxbbGrid.TextMatrix(jsqte, Sydz("006", GridStr(), Szzls)) = .Fields("safetystorage") '安全储备
End If
If .Fields("nowstorage") = 0 Then
CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = 0
Else
CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = .Fields("nowstorage") '现有量
End If
If .Fields("overstorage") = 0 Then
CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)) = 0
Else
CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)) = .Fields("overstorage") '剩余量
End If
If IsNull(.Fields("mcircle")) Then
CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)) = 0
Else
CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)) = .Fields("mcircle")
End If
If IsNull(.Fields("concircle")) Then
CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = 0
Else
CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = .Fields("concircle")
End If
If IsNull(.Fields("chacircle")) Then
CxbbGrid.TextMatrix(jsqte, Sydz("011", GridStr(), Szzls)) = 0
Else
CxbbGrid.TextMatrix(jsqte, Sydz("011", GridStr(), Szzls)) = .Fields("chacircle")
End If
CxbbGrid.TextMatrix(jsqte, Sydz("012", GridStr(), Szzls)) = .Fields("state")
If KF_AlertDzjyQuery.cmbquan.ListIndex = 0 Then
CxbbGrid.ColHidden(Sydz("005", GridStr(), Szzls)) = False
CxbbGrid.ColHidden(Sydz("006", GridStr(), Szzls)) = True
Else
CxbbGrid.ColHidden(Sydz("005", GridStr(), Szzls)) = True
CxbbGrid.ColHidden(Sydz("006", GridStr(), Szzls)) = False
End If
.MoveNext
CxbbGrid.RowHeight(jsqte) = Sjhgd
jsqte = jsqte + 1
Loop
End With
'-------------- End -----------------------------------
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 = ReportTitle
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 + -