-
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:35k
源码类别:

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{BEEECC20-4D5F-4F8B-BFDC-5D9B6FBDE09D}#1.0#0"; "vsflex8.ocx"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  4. Begin VB.Form KF_FrmBatchMate 
  5.    Caption         =   "批次物料汇总表"
  6.    ClientHeight    =   8595
  7.    ClientLeft      =   315
  8.    ClientTop       =   390
  9.    ClientWidth     =   11820
  10.    HelpContextID   =   1219005
  11.    Icon            =   "统计分析_批次物料汇总.frx":0000
  12.    KeyPreview      =   -1  'True
  13.    LinkTopic       =   "Form1"
  14.    MDIChild        =   -1  'True
  15.    ScaleHeight     =   8595
  16.    ScaleWidth      =   11820
  17.    WindowState     =   2  'Maximized
  18.    Begin MSComctlLib.ImageList ImageList1 
  19.       Left            =   5760
  20.       Top             =   0
  21.       _ExtentX        =   1005
  22.       _ExtentY        =   1005
  23.       BackColor       =   -2147483643
  24.       ImageWidth      =   16
  25.       ImageHeight     =   16
  26.       MaskColor       =   12632256
  27.       _Version        =   393216
  28.       BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  29.          NumListImages   =   18
  30.          BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  31.             Picture         =   "统计分析_批次物料汇总.frx":1042
  32.             Key             =   "sz"
  33.          EndProperty
  34.          BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  35.             Picture         =   "统计分析_批次物料汇总.frx":13DC
  36.             Key             =   "dy"
  37.          EndProperty
  38.          BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  39.             Picture         =   "统计分析_批次物料汇总.frx":1776
  40.             Key             =   "yl"
  41.          EndProperty
  42.          BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  43.             Picture         =   "统计分析_批次物料汇总.frx":1B10
  44.             Key             =   "cx"
  45.          EndProperty
  46.          BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  47.             Picture         =   "统计分析_批次物料汇总.frx":1EAA
  48.             Key             =   "dj"
  49.          EndProperty
  50.          BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  51.             Picture         =   "统计分析_批次物料汇总.frx":2244
  52.             Key             =   "sx"
  53.          EndProperty
  54.          BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  55.             Picture         =   "统计分析_批次物料汇总.frx":25DE
  56.             Key             =   "first"
  57.          EndProperty
  58.          BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  59.             Picture         =   "统计分析_批次物料汇总.frx":2978
  60.             Key             =   "prev"
  61.          EndProperty
  62.          BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  63.             Picture         =   "统计分析_批次物料汇总.frx":2D12
  64.             Key             =   "next"
  65.          EndProperty
  66.          BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  67.             Picture         =   "统计分析_批次物料汇总.frx":30AC
  68.             Key             =   "last"
  69.          EndProperty
  70.          BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  71.             Picture         =   "统计分析_批次物料汇总.frx":3446
  72.             Key             =   "bz"
  73.          EndProperty
  74.          BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  75.             Picture         =   "统计分析_批次物料汇总.frx":37E0
  76.             Key             =   "tc"
  77.          EndProperty
  78.          BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  79.             Picture         =   "统计分析_批次物料汇总.frx":3B7A
  80.             Key             =   "bcgs"
  81.          EndProperty
  82.          BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  83.             Picture         =   "统计分析_批次物料汇总.frx":3F14
  84.             Key             =   "mrlk"
  85.          EndProperty
  86.          BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  87.             Picture         =   "统计分析_批次物料汇总.frx":42AE
  88.             Key             =   "xsxm"
  89.          EndProperty
  90.          BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  91.             Picture         =   "统计分析_批次物料汇总.frx":4648
  92.             Key             =   "xz"
  93.          EndProperty
  94.          BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  95.             Picture         =   "统计分析_批次物料汇总.frx":49E2
  96.             Key             =   ""
  97.          EndProperty
  98.          BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  99.             Picture         =   "统计分析_批次物料汇总.frx":4D7C
  100.             Key             =   "sc"
  101.          EndProperty
  102.       EndProperty
  103.    End
  104.    Begin MSComctlLib.Toolbar GsToolbar 
  105.       Height          =   525
  106.       Left            =   9195
  107.       TabIndex        =   4
  108.       Top             =   30
  109.       Width           =   2595
  110.       _ExtentX        =   4577
  111.       _ExtentY        =   926
  112.       ButtonWidth     =   1455
  113.       ButtonHeight    =   926
  114.       AllowCustomize  =   0   'False
  115.       Appearance      =   1
  116.       Style           =   1
  117.       ImageList       =   "ImageList1"
  118.       _Version        =   393216
  119.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  120.          NumButtons      =   3
  121.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  122.             Caption         =   "保存格式"
  123.             Key             =   "bcgs"
  124.             ImageKey        =   "bcgs"
  125.          EndProperty
  126.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  127.             Caption         =   "默认列宽"
  128.             Key             =   "hfmrgs"
  129.             ImageKey        =   "mrlk"
  130.          EndProperty
  131.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  132.             Caption         =   "显示项目"
  133.             Key             =   "szxsxm"
  134.             ImageKey        =   "xsxm"
  135.          EndProperty
  136.       EndProperty
  137.    End
  138.    Begin VB.PictureBox Pic_Title 
  139.       BackColor       =   &H00FFFFFF&
  140.       Height          =   1065
  141.       Left            =   0
  142.       Picture         =   "统计分析_批次物料汇总.frx":5116
  143.       ScaleHeight     =   1005
  144.       ScaleWidth      =   11715
  145.       TabIndex        =   2
  146.       Top             =   570
  147.       Width           =   11775
  148.       Begin VB.Label Label1 
  149.          AutoSize        =   -1  'True
  150.          BackStyle       =   0  'Transparent
  151.          Caption         =   "日期范围:"
  152.          Height          =   195
  153.          Left            =   825
  154.          TabIndex        =   5
  155.          Top             =   705
  156.          Width           =   765
  157.       End
  158.       Begin VB.Label tsLabel 
  159.          AutoSize        =   -1  'True
  160.          BackColor       =   &H80000018&
  161.          BackStyle       =   0  'Transparent
  162.          Caption         =   "批次物料汇总表"
  163.          BeginProperty Font 
  164.             Name            =   "宋体"
  165.             Size            =   14.25
  166.             Charset         =   134
  167.             Weight          =   700
  168.             Underline       =   0   'False
  169.             Italic          =   0   'False
  170.             Strikethrough   =   0   'False
  171.          EndProperty
  172.          ForeColor       =   &H00000000&
  173.          Height          =   285
  174.          Index           =   4
  175.          Left            =   495
  176.          TabIndex        =   3
  177.          Top             =   150
  178.          Width           =   2100
  179.       End
  180.    End
  181.    Begin VB.Timer Timer1 
  182.       Enabled         =   0   'False
  183.       Interval        =   1
  184.       Left            =   7620
  185.       Top             =   90
  186.    End
  187.    Begin VSFlex8Ctl.VSFlexGrid CxbbGrid 
  188.       Height          =   6975
  189.       Left            =   0
  190.       TabIndex        =   0
  191.       Top             =   1680
  192.       Width           =   11775
  193.       _cx             =   5080
  194.       _cy             =   5080
  195.       Appearance      =   1
  196.       BorderStyle     =   1
  197.       Enabled         =   -1  'True
  198.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  199.          Name            =   "宋体"
  200.          Size            =   9
  201.          Charset         =   134
  202.          Weight          =   400
  203.          Underline       =   0   'False
  204.          Italic          =   0   'False
  205.          Strikethrough   =   0   'False
  206.       EndProperty
  207.       MousePointer    =   0
  208.       BackColor       =   16777215
  209.       ForeColor       =   -2147483640
  210.       BackColorFixed  =   13826538
  211.       ForeColorFixed  =   -2147483630
  212.       BackColorSel    =   -2147483635
  213.       ForeColorSel    =   -2147483634
  214.       BackColorBkg    =   -2147483636
  215.       BackColorAlternate=   16777215
  216.       GridColor       =   -2147483633
  217.       GridColorFixed  =   -2147483632
  218.       TreeColor       =   -2147483632
  219.       FloodColor      =   192
  220.       SheetBorder     =   -2147483642
  221.       FocusRect       =   1
  222.       HighLight       =   1
  223.       AllowSelection  =   -1  'True
  224.       AllowBigSelection=   -1  'True
  225.       AllowUserResizing=   0
  226.       SelectionMode   =   0
  227.       GridLines       =   1
  228.       GridLinesFixed  =   2
  229.       GridLineWidth   =   1
  230.       Rows            =   50
  231.       Cols            =   10
  232.       FixedRows       =   1
  233.       FixedCols       =   1
  234.       RowHeightMin    =   0
  235.       RowHeightMax    =   0
  236.       ColWidthMin     =   0
  237.       ColWidthMax     =   0
  238.       ExtendLastCol   =   0   'False
  239.       FormatString    =   ""
  240.       ScrollTrack     =   0   'False
  241.       ScrollBars      =   3
  242.       ScrollTips      =   0   'False
  243.       MergeCells      =   0
  244.       MergeCompare    =   0
  245.       AutoResize      =   -1  'True
  246.       AutoSizeMode    =   0
  247.       AutoSearch      =   0
  248.       AutoSearchDelay =   2
  249.       MultiTotals     =   -1  'True
  250.       SubtotalPosition=   1
  251.       OutlineBar      =   0
  252.       OutlineCol      =   0
  253.       Ellipsis        =   0
  254.       ExplorerBar     =   0
  255.       PicturesOver    =   0   'False
  256.       FillStyle       =   0
  257.       RightToLeft     =   0   'False
  258.       PictureType     =   0
  259.       TabBehavior     =   0
  260.       OwnerDraw       =   0
  261.       Editable        =   0
  262.       ShowComboButton =   1
  263.       WordWrap        =   0   'False
  264.       TextStyle       =   0
  265.       TextStyleFixed  =   0
  266.       OleDragMode     =   0
  267.       OleDropMode     =   0
  268.       DataMode        =   0
  269.       VirtualData     =   -1  'True
  270.       DataMember      =   ""
  271.       ComboSearch     =   3
  272.       AutoSizeMouse   =   -1  'True
  273.       FrozenRows      =   0
  274.       FrozenCols      =   0
  275.       AllowUserFreezing=   0
  276.       BackColorFrozen =   0
  277.       ForeColorFrozen =   0
  278.       WallPaperAlignment=   9
  279.       AccessibleName  =   ""
  280.       AccessibleDescription=   ""
  281.       AccessibleValue =   ""
  282.       AccessibleRole  =   24
  283.    End
  284.    Begin MSComctlLib.Toolbar SzToolbar 
  285.       Align           =   1  'Align Top
  286.       Height          =   555
  287.       Left            =   0
  288.       TabIndex        =   1
  289.       Top             =   0
  290.       Width           =   11820
  291.       _ExtentX        =   20849
  292.       _ExtentY        =   979
  293.       ButtonWidth     =   820
  294.       ButtonHeight    =   926
  295.       AllowCustomize  =   0   'False
  296.       Appearance      =   1
  297.       Style           =   1
  298.       ImageList       =   "ImageList1"
  299.       _Version        =   393216
  300.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  301.          NumButtons      =   9
  302.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  303.             Caption         =   "设置"
  304.             Key             =   "ymsz"
  305.             ImageKey        =   "sz"
  306.          EndProperty
  307.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  308.             Caption         =   "打印"
  309.             Key             =   "dy"
  310.             ImageKey        =   "dy"
  311.          EndProperty
  312.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  313.             Caption         =   "预览"
  314.             Key             =   "yl"
  315.             ImageKey        =   "yl"
  316.          EndProperty
  317.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  318.             Style           =   3
  319.          EndProperty
  320.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  321.             Caption         =   "查询"
  322.             Key             =   "cx"
  323.             ImageKey        =   "cx"
  324.          EndProperty
  325.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  326.             Object.Visible         =   0   'False
  327.             Caption         =   "刷新"
  328.             Key             =   "sx"
  329.             ImageKey        =   "sx"
  330.          EndProperty
  331.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  332.             Style           =   3
  333.          EndProperty
  334.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  335.             Caption         =   "帮助"
  336.             Key             =   "bz"
  337.             ImageKey        =   "bz"
  338.          EndProperty
  339.          BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  340.             Caption         =   "退出"
  341.             Key             =   "fh"
  342.             ImageKey        =   "tc"
  343.          EndProperty
  344.       EndProperty
  345.       BorderStyle     =   1
  346.    End
  347. End
  348. Attribute VB_Name = "KF_FrmBatchMate"
  349. Attribute VB_GlobalNameSpace = False
  350. Attribute VB_Creatable = False
  351. Attribute VB_PredeclaredId = True
  352. Attribute VB_Exposed = False
  353. '**************************************************************************
  354. '*    模 块 名 称 :批次物料汇总表
  355. '*    功 能 描 述 :
  356. '*    程序员姓名  : 赵宇光
  357. '*    最后修改人  : 赵宇光
  358. '*    最后修改时间:2001/12/17
  359. '*    备        注:程序中所有依实际情况自定义部分均用[>>  <<]括起
  360. '**************************************************************************
  361. Dim ReportTitle As String                '报表主标题
  362. '以下为固定使用变量
  363. Dim Dyymctbl As New DY_Dyymsz            '打印页面窗体变量
  364. Dim GridCode As String                   '显示网格网格代码
  365. Dim GridInf() As Variant                 '整个网格设置信息
  366. Dim Tsxx As String                       '系统提示信息
  367. Dim Qslz As Long                         '网格隐藏(非操作显示)列数
  368. Dim Sjhgd As Double                      '网格数据行高度
  369. Dim Sfxshjwg As Boolean                  '是否显示合计网格
  370. Dim GridBoolean() As Boolean             '网格列信息(布尔型)
  371. Dim GridStr()  As String                 '网格列信息(字符型)
  372. Dim GridInt() As Integer                 '网格列信息(整型)
  373. Dim Szzls As Integer                     '数组总列数(网格列数-1)
  374. Private Sub Form_Resize()                '根据窗体大小来调整网格,标题栏大小
  375.     On Error Resume Next
  376.     With CxbbGrid
  377.       .Width = Me.Width - 160
  378.       .Height = Me.Height - .Top - 400
  379.     End With
  380.     With Pic_Title
  381.       .Width = Me.Width - 160
  382.     End With
  383.     
  384.     GsToolbar.Left = Me.Width - GsToolbar.Width - 160
  385. End Sub
  386. Private Sub Form_Load()                                                   '窗体装入
  387.     
  388.      '调入打印页面设置窗体
  389.      
  390.      XtReportCode = "KF_batchmate"
  391.      Load Dyymctbl
  392.      ReportTitle = "批次物料汇总表"
  393.      
  394.     '调整标题栏及网格、格式工具条位置
  395.      Pic_Title.Left = 40
  396.      Pic_Title.Top = SzToolbar.Top + SzToolbar.Height - 10
  397.      CxbbGrid.Left = Pic_Title.Left
  398.      CxbbGrid.Top = Pic_Title.Top + Pic_Title.Height + 20
  399.     
  400.     '调 入 网 格
  401.      GridCode = "KF_batchmate"
  402.      Call BzWgcsh(CxbbGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
  403.      
  404.      Qslz = GridInf(1)
  405.      Sjhgd = GridInf(2)
  406.      Sfxshjwg = GridInf(7)
  407.      Szzls = CxbbGrid.Cols - 1
  408. End Sub
  409. Private Sub Form_Unload(Cancel As Integer)                                  '窗体卸载
  410.    '卸载条件窗体
  411.     KF_FrmBatchMateQuery.UnloadCheck.Value = 1
  412.     Unload KF_FrmBatchMateQuery
  413.    '卸载打印页面设置窗体
  414.    Unload Dyymctbl
  415. End Sub
  416. Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)       '网格格式调整
  417.     Select Case Button.Key
  418.         Case "bcgs"                                          '保存表格格式
  419.             Call Bcwggs(CxbbGrid, GridCode, GridStr())
  420.         Case "hfmrgs"                                        '恢复默认格式
  421.             Call Hfmrgs(CxbbGrid, GridCode, GridStr())
  422.         Case "szxsxm"                                        '设置显示项目
  423.             Call Szxsxm(CxbbGrid, GridCode)
  424.     End Select
  425. End Sub
  426. Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
  427.     Select Case Button.Key
  428.         Case "ymsz"                                          '页面设置
  429.             Dyymctbl.Show 1
  430.         Case "yl"                                            '预 览
  431.            Call bbyl(True)
  432.         Case "dy"                                            '打 印
  433.           Call bbyl(False)
  434.         Case "cx"                                            '查 询
  435.           KF_FrmBatchMateQuery.Show 1
  436.         Case "sx"                                            '刷 新
  437.           Call Timer1_Timer
  438.         Case "bz"                                            '帮 助
  439.           Call F1bz
  440.         Case "fh"                                            '退 出
  441.          Unload Me
  442.      End Select
  443. End Sub
  444. Private Sub Timer1_Timer()                                 '在窗体激活后调入查询程序
  445.    Timer1.Enabled = False
  446.    Xt_Wait.Show
  447.    Xt_Wait.Refresh
  448.    
  449.    '加快显示速度
  450.    CxbbGrid.Redraw = False
  451.    '生成查询结果
  452.    Call Sub_Query
  453.    
  454.    CxbbGrid.Redraw = True
  455.     
  456.    Xt_Wait.Hide
  457. End Sub
  458. Public Sub Adjust()
  459.     Dim R As New Recordset
  460.     
  461.     Set R = Cw_DataEnvi.DataConnect.Execute("select colindex,coltitle1 from wm_grid where grid_code='kf_stockin_list' order by colid")
  462.     
  463.     If Not R.EOF Then
  464.         R.MoveNext
  465.         For jsq = 0 To CxbbGrid.Cols - 1
  466.             Do While Not R.EOF
  467.                 If Trim(R.Fields("coltitle1")) = Trim(CxbbGrid.TextMatrix(0, jsq)) Then
  468.                     GridStr(jsq, 1) = R.Fields("colindex")
  469.                     Exit Do
  470.                 End If
  471.                 R.MoveNext
  472.             Loop
  473.             R.MoveFirst
  474.             R.MoveNext
  475.         Next jsq
  476.     End If
  477.     R.Close
  478.     Set R = Nothing
  479. End Sub
  480. Private Sub Sub_Query()                                    '生成查询结果
  481.     Dim Rec_Query As New ADODB.Recordset        '查询结果动态集
  482.     Dim Str_QueryCondi As String                '用户录入查询条件
  483.     Dim Sqlstr As String                        '查询字符串
  484.     Dim Coljsq As Long                          '网格列计数器
  485.     Dim jsqte As Integer                        '临时动态计数器
  486.     Dim Int_VouchID%                            '记录上一张单据标识
  487.     Dim S_COUNT As Single, S_MONEY As Single                    '每张单据借贷方合计
  488.     Dim Xtyear As Integer, Period As Integer
  489.     Dim Str_WH As String, Str_Sort As String, Str_Mate As String
  490.     Dim Str_Wl As String
  491.     Dim Rec_Mate As New Recordset
  492.     Dim Str_Batch As String
  493.     '以下为用户自定义部分[
  494.     Dim Rec_WH As New Recordset
  495.     Dim Rec_Unit As New Recordset
  496.     Dim Rec_QC As New Recordset
  497.     With KF_FrmBatchMateQuery
  498.      
  499.     '显示查询会计期间
  500.         Str_QueryCondi = "SELECT SUM(factreceiptquan) AS Expr1, SUM(factissuequan) AS Expr2, mnumber, WhCode, batchnum  From KF_V_MBatch "
  501.         Sqlstr = "select distinct WhCode,batchnum,mnumber from KF_V_MBatch where batchnum<>'' "
  502.         Str_Wl = "  union select  distinct WhCode,batchnum,mnumber from  kf_V_ledger  where  batchnum<>''  "
  503.      
  504.         For jsqte = 1 To 5
  505.             Select Case jsqte
  506.               
  507.                Case 1  '会计期间
  508.                 If Trim(.Combo_Kjqj2.Text) <> "" Then
  509.                    Xtyear = Val(Mid(Trim(.Combo_Kjqj2.Text), 1, 4))
  510.                    Period = Val(Mid(Trim(.Combo_Kjqj2.Text), 6))
  511.                    Sqlstr = Sqlstr & " and kjyear=" & Xtyear & " and Period between " & Val(Mid(Trim(.Combo_Kjqj1.Text), 6)) & " and " & Period
  512.                    Str_Wl = Str_Wl & " and kjyear=" & Xtyear & " and Period between " & Val(Mid(Trim(.Combo_Kjqj1.Text), 6)) & " and " & Period
  513.                    Str_QueryCondi = Str_QueryCondi & " where kjyear=" & Xtyear & " and Period between " & Val(Mid(Trim(.Combo_Kjqj1.Text), 6)) & " and " & Period
  514.                 End If
  515.               
  516.               Case 2   '仓库
  517.                  If Trim(.LrText(0).Text) <> "" Then
  518.                    Str_WH = " and WhCode='" & Trim(.LrText(0).Tag) & "'"
  519.                    Sqlstr = Sqlstr & " and WhCode='" & Trim(.LrText(0).Tag) & "'"
  520.                    Str_Wl = Str_Wl & " and WhCode='" & Trim(.LrText(0).Tag) & "'"
  521.                  Else
  522.                    Str_WH = ""
  523.                  End If
  524.              
  525.               Case 3   '物料分类
  526.                 If Trim(.LrText(1).Text) <> "" Then
  527.                     Str_Wl = Str_Wl & " and invsortcode LIKE '" & Trim(.LrText(1).Tag) & "%'"
  528.                     Sqlstr = Sqlstr & " and invsortcode LIKE '" & Trim(.LrText(1).Tag) & "%'"
  529.                     Str_Sort = " and invsortcode LIKE '" & Trim(.LrText(1).Tag) & "%'"
  530.                 Else
  531.                     Str_Sort = ""
  532.                 End If
  533.                 
  534.               Case 4   '材料
  535.                 If Trim(.LrText(2).Text) <> "" Then
  536.                   Str_Mate = " and mnumber='" & Trim(.LrText(2).Text) & "'"
  537.                   Sqlstr = Sqlstr & " and mnumber='" & Trim(.LrText(2).Text) & "'"
  538.                   Str_Wl = Str_Wl & " and mnumber='" & Trim(.LrText(2).Text) & "'"
  539.                 Else
  540.                   Str_Mate = ""
  541.                 End If
  542.                 
  543.              Case 5   '批次
  544.                 If Trim(.LrText(3).Text) <> "" Then
  545.                   Str_Batch = " and   batchnum='" & Trim(.LrText(3).Text) & "'"
  546.                   Sqlstr = Sqlstr & "  and batchnum='" & Trim(.LrText(3).Text) & "'"
  547.                   Str_Wl = Str_Wl & "  and batchnum='" & Trim(.LrText(3).Text) & "'"
  548.                 Else
  549.                   Str_Batch = ""
  550.                 End If
  551.             End Select
  552.         Next jsqte
  553.     End With
  554.  
  555.     Dim Str_Query As String
  556.     Label1 = "日期范围:   " & Trim(KF_FrmBatchMateQuery.Combo_Kjqj1.Text) & "----" & Trim(KF_FrmBatchMateQuery.Combo_Kjqj2.Text)
  557.     Str_Wl = Sqlstr + Str_Wl + " order by batchnum"
  558.     Set Rec_Mate = Cw_DataEnvi.DataConnect.Execute(Str_Wl)
  559.     
  560.     CxbbGrid.Rows = CxbbGrid.FixedRows
  561.     jsqte = CxbbGrid.FixedRows
  562.     Dim D_QC, D_In, D_Out, D_End As Double
  563.     D_QC = 0
  564.     D_In = 0
  565.     D_Out = 0
  566.     D_End = 0
  567.     Dim temp_batch As String
  568.     Dim S_QC, S_In, S_Out, S_End As Single
  569.     Dim judge_flag As Boolean
  570.     S_QC = 0
  571.     S_In = 0
  572.     S_Out = 0
  573.     S_End = 0
  574.     Do While Not Rec_Mate.EOF
  575.         judge_flag = True
  576.         temp_batch = Rec_Mate.Fields("batchnum")
  577.         Str_Query = ""
  578.         Str_Query = Str_QueryCondi & Str_WH & Str_Sort & Str_Mate & " and batchnum='" & Trim(Rec_Mate.Fields("batchnum")) & "' and WhCode='" & Trim(Rec_Mate.Fields("WhCode")) & "' and mnumber='" & Trim(Rec_Mate.Fields("mnumber")) & "'  GROUP BY mnumber, WhCode, batchnum"
  579.         Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Str_Query)
  580.   
  581.         Dim str_query1 As String
  582.         str_query1 = "select  SUM(startquan) AS Qc, mnumber, batchnum, WhCode From kf_V_ledger where  1=1" & Str_WH & Str_Sort & Str_Mate & " and  batchnum='" & Trim(Rec_Mate.Fields("batchnum")) & "' and period =" & Val(Mid(Trim(KF_FrmBatchMateQuery.Combo_Kjqj1.Text), 6)) & " GROUP BY mnumber, batchnum, WhCode"
  583.         If Rec_Query.EOF Then
  584.             Dim rec_start As New ADODB.Recordset
  585.             Set rec_start = Cw_DataEnvi.DataConnect.Execute(str_query1)
  586.             With rec_start
  587.                 If rec_start.EOF Then
  588.                     judge_flag = False
  589.                 Else
  590.                     Do While Not .EOF
  591.                         CxbbGrid.AddItem ""
  592.                         CxbbGrid.TextMatrix(jsqte, Sydz("001", GridStr(), Szzls)) = Trim(.Fields("batchnum"))
  593.                         CxbbGrid.TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = Trim(.Fields("mnumber"))
  594.                         
  595.                         Set Rec_WH = Cw_DataEnvi.DataConnect.Execute("SELECT whname from gy_warehouse where WhCode='" & Trim(.Fields("WhCode")) & "'")
  596.                         CxbbGrid.TextMatrix(jsqte, Sydz("006", GridStr(), Szzls)) = Trim(Rec_WH.Fields("whname"))
  597.                 
  598.                         
  599.                         Set Rec_Unit = Cw_DataEnvi.DataConnect.Execute("select mname,model ,PrimaryUnitName from gy_material where mnumber='" & Trim(.Fields("mnumber")) & "'")
  600.                         CxbbGrid.TextMatrix(jsqte, Sydz("003", GridStr(), Szzls)) = Trim(Rec_Unit.Fields("mname"))
  601.                         CxbbGrid.TextMatrix(jsqte, Sydz("004", GridStr(), Szzls)) = Trim(Rec_Unit.Fields("model"))
  602.                         CxbbGrid.TextMatrix(jsqte, Sydz("005", GridStr(), Szzls)) = Trim(Rec_Unit.Fields("PrimaryUnitName"))
  603.                         Set Rec_QC = Cw_DataEnvi.DataConnect.Execute("SELECT SUM(startquan) AS Qc, mnumber, batchnum, WhCode From kf_V_ledger where mnumber='" & Trim(.Fields("mnumber")) & "' and batchnum='" & Trim(.Fields("batchnum")) & "' and WhCode='" & Trim(.Fields("WhCode")) & "'and kjyear=" & Xtyear & " and period =" & Val(Mid(Trim(KF_FrmBatchMateQuery.Combo_Kjqj1.Text), 6)) & " GROUP BY mnumber, batchnum, WhCode")
  604.                         If Not Rec_QC.EOF Then
  605.                             If Val(Rec_QC.Fields("qc")) Then
  606.                                 CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = Val(Rec_QC.Fields("qc"))
  607.                             Else
  608.                                 CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = ""
  609.                             End If
  610.                         Else
  611.                             CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = ""
  612.                         End If
  613.                         S_QC = S_QC + Val(CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)))
  614.                         
  615.                         If Val(Val(CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls))) + Val(CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls))) - Val(CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)))) Then
  616.                             CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls))) + Val(CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls))) - Val(CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)))
  617.                         Else
  618.                             CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = ""
  619.                         End If
  620.                         
  621.                         S_End = S_End + Val(CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)))
  622.                         CxbbGrid.RowHeight(jsqte) = Sjhgd
  623.                         jsqte = jsqte + 1
  624.                         .MoveNext
  625.                     Loop
  626.                 End If
  627.             End With
  628.         Else
  629.             With Rec_Query
  630.                 Do While Not .EOF
  631.                     CxbbGrid.AddItem ""
  632.                     CxbbGrid.TextMatrix(jsqte, Sydz("001", GridStr(), Szzls)) = Trim(.Fields("batchnum"))
  633.                     CxbbGrid.TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = Trim(.Fields("mnumber"))
  634.                     
  635.                     Set Rec_WH = Cw_DataEnvi.DataConnect.Execute("SELECT whname from gy_warehouse where WhCode='" & Trim(.Fields("WhCode")) & "'")
  636.                     CxbbGrid.TextMatrix(jsqte, Sydz("006", GridStr(), Szzls)) = Trim(Rec_WH.Fields("whname"))
  637.                     If Val(.Fields("expr1")) <> 0 Then
  638.                         CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)) = Val(.Fields("expr1"))
  639.                     End If
  640.                     S_In = S_In + Val(.Fields("expr1"))
  641.                     If Val(.Fields("expr2")) <> 0 Then
  642.                         CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)) = Val(.Fields("expr2"))
  643.                     End If
  644.                     S_Out = S_Out + Val(.Fields("expr2"))
  645.                     
  646.                     Set Rec_Unit = Cw_DataEnvi.DataConnect.Execute("select mname,model ,PrimaryUnitName from gy_material where mnumber='" & Trim(.Fields("mnumber")) & "'")
  647.                     CxbbGrid.TextMatrix(jsqte, Sydz("003", GridStr(), Szzls)) = Trim(Rec_Unit.Fields("mname"))
  648.                     CxbbGrid.TextMatrix(jsqte, Sydz("004", GridStr(), Szzls)) = Trim(Rec_Unit.Fields("model"))
  649.                     CxbbGrid.TextMatrix(jsqte, Sydz("005", GridStr(), Szzls)) = Trim(Rec_Unit.Fields("PrimaryUnitName"))
  650.                     Set Rec_QC = Cw_DataEnvi.DataConnect.Execute("SELECT SUM(startquan) AS Qc, mnumber, batchnum, WhCode From kf_V_ledger where mnumber='" & Trim(.Fields("mnumber")) & "' and batchnum='" & Trim(.Fields("batchnum")) & "' and WhCode='" & Trim(.Fields("WhCode")) & "'and kjyear=" & Xtyear & " and period =" & Val(Mid(Trim(KF_FrmBatchMateQuery.Combo_Kjqj1.Text), 6)) & " GROUP BY mnumber, batchnum, WhCode")
  651.                     If Not Rec_QC.EOF Then
  652.                         If Val(Rec_QC.Fields("qc")) Then
  653.                             CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = Val(Rec_QC.Fields("qc"))
  654.                         Else
  655.                             CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = ""
  656.                         End If
  657.                     Else
  658.                         CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = ""
  659.                     End If
  660.                     S_QC = S_QC + Val(CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)))
  661.                     
  662.                     If Val(Val(CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls))) + Val(CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls))) - Val(CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)))) Then
  663.                         CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = Val(CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls))) + Val(CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls))) - Val(CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)))
  664.                     Else
  665.                         CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = ""
  666.                     End If
  667.                     
  668.                     S_End = S_End + Val(CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)))
  669.                     CxbbGrid.RowHeight(jsqte) = Sjhgd
  670.                     jsqte = jsqte + 1
  671.                     .MoveNext
  672.                 Loop
  673.             End With
  674.         End If
  675.         Rec_Mate.MoveNext
  676.         
  677.         If Rec_Mate.EOF Then
  678.             If judge_flag Then
  679.                 CxbbGrid.AddItem ""
  680.                 CxbbGrid.TextMatrix(jsqte, Sydz("001", GridStr(), Szzls)) = "小计"
  681.                 If S_QC <> 0 Then
  682.                     CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = S_QC
  683.                 End If
  684.                 If S_In <> 0 Then
  685.                     CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)) = S_In
  686.                 End If
  687.                 If S_Out <> 0 Then
  688.                     CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)) = S_Out
  689.                 End If
  690.                 If S_End <> 0 Then
  691.                     CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = S_End
  692.                 End If
  693.                 D_In = D_In + S_In
  694.                 D_Out = D_Out + S_Out
  695.                 D_QC = D_QC + S_QC
  696.                 D_End = D_End + S_End
  697.                 CxbbGrid.RowHeight(jsqte) = Sjhgd
  698.                 jsqte = jsqte + 1
  699.             End If
  700.         ElseIf temp_batch <> Rec_Mate.Fields("batchnum") Then
  701.             If judge_flag Then
  702.                 CxbbGrid.AddItem ""
  703.                 CxbbGrid.TextMatrix(jsqte, Sydz("001", GridStr(), Szzls)) = "小计"
  704.                 If S_QC <> 0 Then
  705.                     CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = S_QC
  706.                 End If
  707.                 If S_In <> 0 Then
  708.                     CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)) = S_In
  709.                 End If
  710.                 If S_Out <> 0 Then
  711.                     CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)) = S_Out
  712.                 End If
  713.                 If S_End <> 0 Then
  714.                     CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = S_End
  715.                 End If
  716.                 D_In = D_In + S_In
  717.                 D_Out = D_Out + S_Out
  718.                 D_QC = D_QC + S_QC
  719.                 D_End = D_End + S_End
  720.                 S_QC = 0
  721.                 S_In = 0
  722.                 S_Out = 0
  723.                 S_End = 0
  724.                 CxbbGrid.RowHeight(jsqte) = Sjhgd
  725.                 jsqte = jsqte + 1
  726.             End If
  727.         End If
  728.     Loop
  729.     CxbbGrid.MergeCells = flexMergeFree
  730.     For jsq = Qslz To CxbbGrid.Cols - 1
  731.         CxbbGrid.MergeCol(jsq) = False
  732.     Next jsq
  733.     CxbbGrid.MergeCol(Sydz("001", GridStr(), Szzls)) = True
  734.     CxbbGrid.AddItem ""
  735.     CxbbGrid.TextMatrix(jsqte, Qslz) = "合计"
  736.     If D_QC <> 0 Then
  737.         CxbbGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = D_QC
  738.     End If
  739.     If D_In <> 0 Then
  740.         CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)) = D_In
  741.     End If
  742.     If D_Out <> 0 Then
  743.         CxbbGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)) = D_Out
  744.     End If
  745.     If D_End <> 0 Then
  746.         CxbbGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = D_End
  747.     End If
  748.     CxbbGrid.RowHeight(CxbbGrid.Rows - 1) = Sjhgd
  749.  ']以上为用户自定义部分
  750.    
  751. End Sub
  752. Private Sub CxbbGrid_BeforeMoveColumn(ByVal Col As Long, Position As Long)
  753.     '如果结束列小于用户定义网格开始列,则结束列=用户定义网格开始列
  754.     '因为开始列以前的列都是隐藏列,由于要把当前开始移动列移动到隐藏列上
  755.     '所以控件自动把隐藏列变为显示列,这样在刷新数据时,会把隐藏列上的数据
  756.     '显示出来,并且,由于开始列以前的隐藏列在XT_Grid中,不对应逻辑值,所以在保存
  757.     '网格格式时会出错
  758.     If Col > Position Then
  759.       If Position < GridInf(1) Then Position = GridInf(1)
  760.     Else
  761.       If Col < GridInf(1) Then Col = GridInf(1)
  762.     End If
  763.     Call FnBln_RefreshArray(Col, Position, GridStr(), GridInf())
  764. End Sub
  765. Private Sub bbyl(bbylte As Boolean)                    '报表打印预览
  766.     Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
  767.     Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
  768.     Bbxbtgs = 2                                          '报 表 小 标 题 行 数
  769.     Bbbwhgs = 0                                          '报 表 表 尾 行 数
  770.     ReDim Bbxbt(1 To Bbxbtgs)
  771.     ReDim bbxbtzzxs(1 To Bbxbtgs)
  772.     If Bbbwhgs <> 0 Then
  773.        ReDim Bbbwh(1 To Bbbwhgs)
  774.        ReDim Bbbwhzzxs(1 To Bbbwhgs)
  775.     End If
  776.     Bbzbt = ReportTitle
  777.     
  778.     Bbxbt(2) = Space(5) + Fun_FormatOutPut(Trim(Label1), 30)
  779.     
  780.     Bbxbt(1) = " "
  781.     bbxbtzzxs(1) = 0                                     '报表行组织形式(0-居左 1-居中 2-居右)
  782.     Call Scyxsjb(CxbbGrid)                               '生成报表数据
  783.     Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
  784.     If Not bbylte Then
  785.        Unload DY_Tybbyldy
  786.     End If
  787. End Sub