📄 frm_cgreport.frm
字号:
Left = 135
TabIndex = 13
Top = 855
Width = 1035
End
Begin VB.Label Label2
Caption = "起始时间:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 270
Left = 135
TabIndex = 12
Top = 345
Width = 1035
End
Begin VB.Label Label1
Caption = "日期:"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 270
Left = 435
TabIndex = 4
Top = 1965
Width = 570
End
End
Begin MSHierarchicalFlexGridLib.MSHFlexGrid msglist
Height = 4695
Left = 120
TabIndex = 0
Top = 255
Width = 7965
_ExtentX = 14049
_ExtentY = 8281
_Version = 393216
FixedCols = 0
AllowBigSelection= 0 'False
FocusRect = 0
SelectionMode = 1
AllowUserResizing= 1
BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
Name = "宋体"
Size = 11.25
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
_NumberOfBands = 1
_Band(0).Cols = 2
End
Begin VB.Label Label4
Caption = "查 询"
BeginProperty Font
Name = "宋体"
Size = 10.5
Charset = 134
Weight = 400
Underline = 0 'False
Italic = 0 'False
Strikethrough = 0 'False
EndProperty
Height = 285
Left = 8415
TabIndex = 17
Top = 2850
Width = 720
End
End
Attribute VB_Name = "frm_cgreport"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
Const UNIT = 0.03937 * 1440
Private Sub comb_lx_Click()
If comb_lx.ListIndex = 0 Or comb_lx.ListIndex = 1 Then
dtptime(1).Enabled = False
Else
dtptime(1).Enabled = True
End If
End Sub
Private Sub Command1_Click(Index As Integer)
Dim TxtSQL As String
Dim msgtext As String
Dim rpt As New report
Dim txt As clsText
Select Case Index
Case 0
Select Case comb_lx.ListIndex '时间段类型
Case 0 '时间段类型 --日报表
TxtSQL = "select b.p_id,b.p_name,b.unit,format(avg(b.unit_price),'0.000') as price,sum(b.qty) as qty,format(sum(b.price),'0.000') as finalprice"
TxtSQL = TxtSQL & " from ps_head_b as a,order_detail_b as b"
TxtSQL = TxtSQL & " where a.ps_id=b.order_id"
TxtSQL = TxtSQL & " and a.p_flag=false "
Select Case comb_lxx.ListIndex
Case 0
TxtSQL = TxtSQL & " and a.ps_type='采购入库'"
Case 1
TxtSQL = TxtSQL & " and a.ps_type='盘盈入库'"
Case 2
TxtSQL = TxtSQL & " and a.ps_type='其它入库'"
Case 3
TxtSQL = TxtSQL & " and a.ps_type='退库单'"
Case 4
TxtSQL = TxtSQL & " and a.ps_type='报损单'"
Case 5
TxtSQL = TxtSQL & " and a.ps_type='仓库盘点报损'"
Case 6
TxtSQL = TxtSQL & " and a.ps_type='仓库盘点报溢'"
End Select
TxtSQL = TxtSQL & " and format(a.ps_date,'yyyy-MM-dd')='" & Format(dtptime(0).Value, "yyyy-MM-dd") & "'"
TxtSQL = TxtSQL & " group by p_id,p_name,unit"
TxtSQL = TxtSQL & " order by p_id"
Case 1 '时间段类型 --月报表
TxtSQL = "select b.p_id,b.p_name,b.unit,format(avg(b.unit_price),'0.000') as price,sum(b.qty)as qty,format(sum(b.price),'0.000') as finalprice"
TxtSQL = TxtSQL & " from ps_head_b as a,order_detail_b as b"
TxtSQL = TxtSQL & " where a.ps_id=b.order_id"
TxtSQL = TxtSQL & " and a.p_flag=false "
Select Case comb_lxx.ListIndex
Case 0
TxtSQL = TxtSQL & " and a.ps_type='采购入库'"
Case 1
TxtSQL = TxtSQL & " and a.ps_type='盘盈入库'"
Case 2
TxtSQL = TxtSQL & " and a.ps_type='其它入库'"
Case 3
TxtSQL = TxtSQL & " and a.ps_type='退库单'"
Case 4
TxtSQL = TxtSQL & " and a.ps_type='报损单'"
Case 5
TxtSQL = TxtSQL & " and a.ps_type='仓库盘点报损'"
Case 6
TxtSQL = TxtSQL & " and a.ps_type='仓库盘点报溢'"
End Select
TxtSQL = TxtSQL & " and format(a.ps_date,'yyyy-MM')='" & Format(dtptime(0).Value, "yyyy-MM") & "'"
TxtSQL = TxtSQL & " group by p_id,p_name,unit"
TxtSQL = TxtSQL & " order by p_id"
Case 2 '时间段类型 --时间段报表
TxtSQL = "select b.p_id,b.p_name,b.unit,format(avg(b.unit_price),'0.00') as price,sum(b.qty) as qty,format(sum(b.price),'0.000') as finalprice"
TxtSQL = TxtSQL & " from ps_head_b as a,order_detail_b as b"
TxtSQL = TxtSQL & " where a.ps_id=b.order_id"
TxtSQL = TxtSQL & " and a.p_flag=false "
Select Case comb_lxx.ListIndex
Case 0
TxtSQL = TxtSQL & " and a.ps_type='采购入库'"
Case 1
TxtSQL = TxtSQL & " and a.ps_type='盘盈入库'"
Case 2
TxtSQL = TxtSQL & " and a.ps_type='其它入库'"
Case 3
TxtSQL = TxtSQL & " and a.ps_type='退库单'"
Case 4
TxtSQL = TxtSQL & " and a.ps_type='报损单'"
Case 5
TxtSQL = TxtSQL & " and a.ps_type='仓库盘点报损'"
Case 6
TxtSQL = TxtSQL & " and a.ps_type='仓库盘点报溢'"
End Select
TxtSQL = TxtSQL & " and format(a.ps_date,'yyyy-MM-dd')>='" & Format(dtptime(0).Value, "yyyy-MM-dd") & "'"
TxtSQL = TxtSQL & " and format(a.ps_date,'yyyy-MM-dd')<='" & Format(dtptime(1).Value, "yyyy-MM-dd") & "'"
TxtSQL = TxtSQL & " group by p_id,p_name,unit"
TxtSQL = TxtSQL & " order by p_id"
End Select
Dim mrc As New ADODB.Recordset
mrc.Open TxtSQL, cnn, adOpenForwardOnly, adLockOptimistic
msglist.Clear
msglist.rows = 2
If Not mrc.EOF Then
Set msglist.DataSource = mrc
Dim i As Integer
Dim tem2 As Double
Dim tem3 As Long
tem2 = 0
tem3 = 0
For i = 1 To msglist.rows - 1
tem3 = tem3 + Val("" & msglist.TextMatrix(i, 4)) '数量
tem2 = tem2 + Val("" & msglist.TextMatrix(i, 5)) '金额
Next
msglist.rows = msglist.rows + 1
msglist.TextMatrix(i, 1) = "合计"
msglist.TextMatrix(i, 4) = tem3
msglist.TextMatrix(i, 5) = Format(tem2, "0.000")
End If
If mrc.State = adStateOpen Then mrc.Close
Set mrc = Nothing
showtitle
Case 1
rpt.SetPrinter 10000, 15839.97, Portrait
Set txt = New clsText
With txt
.stringX = comb_lxx.text
.fontsize = 15
.FontBold = True
.Align = tymiddle
End With
rpt.Title.AddText "title1", txt
Set txt = Nothing
Set txt = New clsText
With txt
.stringX = " "
.fontsize = 12
.FontBold = True
.Align = tymiddle
End With
rpt.Title.AddText "title2", txt
Set txt = Nothing
Set txt = New clsText
With txt
Dim str As String
str = "时段:" & comb_lx.text
Select Case comb_lx.ListIndex
Case 0 '日报表
str = str & " 日期:" & dtptime(0).Value
Case 1 '月报表
str = str & " 月份:" & Format(dtptime(0).Value, "yyyy-mm")
Case 2 '时段报表
str = str & " 时间: 从 " & dtptime(0).Value & " 到 " & dtptime(1).Value
End Select
.stringX = str
.fontsize = 10
.FontBold = False
.Align = tyLeft
End With
rpt.Title.AddText "title3", txt
Set txt = Nothing
rpt.AttachFlexGrid msglist
rpt.Preview
Case 2
' .TextMatrix(0, 0) = "编号"
' .TextMatrix(0, 1) = "产品名称"
' .TextMatrix(0, 2) = "单位"
' .TextMatrix(0, 3) = "单价"
' .TextMatrix(0, 4) = "数量"
' .TextMatrix(0, 5) = "金额"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -