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

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{65A39231-6133-11D1-BAA2-444553540000}#1.0#0"; "VSLIGHT6.OCX"
  3. Object = "{C5DE3F80-3376-11D2-BAA4-04F205C10000}#1.0#0"; "VSFLEX6D.OCX"
  4. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "MSCOMCTL.OCX"
  5. Begin VB.Form XJ_XJLLB 
  6.    Caption         =   "现金流量表"
  7.    ClientHeight    =   5940
  8.    ClientLeft      =   60
  9.    ClientTop       =   345
  10.    ClientWidth     =   9645
  11.    LinkTopic       =   "Form1"
  12.    ScaleHeight     =   5940
  13.    ScaleWidth      =   9645
  14.    StartUpPosition =   2  '屏幕中心
  15.    WindowState     =   2  'Maximized
  16.    Begin VB.Timer Timer1 
  17.       Enabled         =   0   'False
  18.       Interval        =   1
  19.       Left            =   7080
  20.       Top             =   90
  21.    End
  22.    Begin VB.PictureBox Pic_Title 
  23.       Height          =   1125
  24.       Left            =   0
  25.       Picture         =   "现金流量表.frx":0000
  26.       ScaleHeight     =   1065
  27.       ScaleWidth      =   11535
  28.       TabIndex        =   1
  29.       Top             =   570
  30.       Width           =   11595
  31.       Begin VB.ComboBox Combo1 
  32.          Height          =   300
  33.          Left            =   6180
  34.          TabIndex        =   10
  35.          Text            =   "Combo1"
  36.          Top             =   720
  37.          Width           =   2445
  38.       End
  39.       Begin VB.Label Label2 
  40.          BackStyle       =   0  'Transparent
  41.          Caption         =   "编制单位:沧化集团"
  42.          Height          =   255
  43.          Left            =   750
  44.          TabIndex        =   9
  45.          Top             =   780
  46.          Width           =   3525
  47.       End
  48.       Begin VB.Label tsLabel 
  49.          BackColor       =   &H80000018&
  50.          BackStyle       =   0  'Transparent
  51.          Caption         =   "现金流量表"
  52.          BeginProperty Font 
  53.             Name            =   "隶书"
  54.             Size            =   15.75
  55.             Charset         =   134
  56.             Weight          =   400
  57.             Underline       =   0   'False
  58.             Italic          =   0   'False
  59.             Strikethrough   =   0   'False
  60.          EndProperty
  61.          ForeColor       =   &H00000000&
  62.          Height          =   360
  63.          Index           =   4
  64.          Left            =   390
  65.          TabIndex        =   6
  66.          Top             =   90
  67.          Width           =   2355
  68.       End
  69.       Begin VB.Label Lab_TitleMess 
  70.          BackStyle       =   0  'Transparent
  71.          Caption         =   "会计期间:"
  72.          Height          =   225
  73.          Index           =   0
  74.          Left            =   5160
  75.          TabIndex        =   5
  76.          Top             =   780
  77.          Width           =   915
  78.       End
  79.       Begin VB.Label Lab_TitleText 
  80.          BackStyle       =   0  'Transparent
  81.          ForeColor       =   &H00FF0000&
  82.          Height          =   225
  83.          Index           =   0
  84.          Left            =   2040
  85.          TabIndex        =   4
  86.          Top             =   480
  87.          Width           =   735
  88.       End
  89.       Begin VB.Label Lab_TitleText 
  90.          BackStyle       =   0  'Transparent
  91.          ForeColor       =   &H00FF0000&
  92.          Height          =   225
  93.          Index           =   1
  94.          Left            =   3840
  95.          TabIndex        =   3
  96.          Top             =   480
  97.          Width           =   1755
  98.       End
  99.       Begin VB.Label Lab_TitleText 
  100.          BackStyle       =   0  'Transparent
  101.          ForeColor       =   &H00FF0000&
  102.          Height          =   225
  103.          Index           =   2
  104.          Left            =   7290
  105.          TabIndex        =   2
  106.          Top             =   240
  107.          Width           =   1875
  108.       End
  109.    End
  110.    Begin MSComctlLib.Toolbar GsToolbar 
  111.       Height          =   525
  112.       Left            =   6990
  113.       TabIndex        =   0
  114.       Top             =   -30
  115.       Width           =   2595
  116.       _ExtentX        =   4577
  117.       _ExtentY        =   926
  118.       ButtonWidth     =   1455
  119.       ButtonHeight    =   926
  120.       Appearance      =   1
  121.       Style           =   1
  122.       ImageList       =   "ImageList1"
  123.       _Version        =   393216
  124.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  125.          NumButtons      =   3
  126.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  127.             Caption         =   "保存格式"
  128.             Key             =   "bcgs"
  129.             ImageKey        =   "bcgs"
  130.          EndProperty
  131.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  132.             Caption         =   "默认列宽"
  133.             Key             =   "hfmrgs"
  134.             ImageKey        =   "mrlk"
  135.          EndProperty
  136.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  137.             Caption         =   "显示项目"
  138.             Key             =   "szxsxm"
  139.             ImageKey        =   "xsxm"
  140.          EndProperty
  141.       EndProperty
  142.    End
  143.    Begin VSFlex6DAOCtl.vsFlexGrid CxbbGrid 
  144.       Height          =   6885
  145.       Left            =   30
  146.       TabIndex        =   7
  147.       Top             =   1710
  148.       Width           =   11715
  149.       _ExtentX        =   20664
  150.       _ExtentY        =   12144
  151.       _ConvInfo       =   1
  152.       Appearance      =   1
  153.       BorderStyle     =   1
  154.       Enabled         =   -1  'True
  155.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  156.          Name            =   "宋体"
  157.          Size            =   9
  158.          Charset         =   134
  159.          Weight          =   400
  160.          Underline       =   0   'False
  161.          Italic          =   0   'False
  162.          Strikethrough   =   0   'False
  163.       EndProperty
  164.       MousePointer    =   0
  165.       BackColor       =   16777215
  166.       ForeColor       =   -2147483640
  167.       BackColorFixed  =   -2147483624
  168.       ForeColorFixed  =   -2147483630
  169.       BackColorSel    =   -2147483635
  170.       ForeColorSel    =   -2147483634
  171.       BackColorBkg    =   -2147483636
  172.       BackColorAlternate=   16777215
  173.       GridColor       =   -2147483633
  174.       GridColorFixed  =   -2147483632
  175.       TreeColor       =   -2147483632
  176.       FloodColor      =   192
  177.       SheetBorder     =   -2147483642
  178.       FocusRect       =   1
  179.       HighLight       =   1
  180.       AllowSelection  =   -1  'True
  181.       AllowBigSelection=   -1  'True
  182.       AllowUserResizing=   3
  183.       SelectionMode   =   0
  184.       GridLines       =   1
  185.       GridLinesFixed  =   2
  186.       GridLineWidth   =   1
  187.       Rows            =   50
  188.       Cols            =   10
  189.       FixedRows       =   1
  190.       FixedCols       =   0
  191.       RowHeightMin    =   250
  192.       RowHeightMax    =   0
  193.       ColWidthMin     =   0
  194.       ColWidthMax     =   0
  195.       ExtendLastCol   =   0   'False
  196.       FormatString    =   ""
  197.       ScrollTrack     =   0   'False
  198.       ScrollBars      =   3
  199.       ScrollTips      =   0   'False
  200.       MergeCells      =   0
  201.       MergeCompare    =   0
  202.       AutoResize      =   -1  'True
  203.       AutoSizeMode    =   0
  204.       AutoSearch      =   0
  205.       MultiTotals     =   -1  'True
  206.       SubtotalPosition=   1
  207.       OutlineBar      =   0
  208.       OutlineCol      =   0
  209.       Ellipsis        =   0
  210.       ExplorerBar     =   0
  211.       PicturesOver    =   0   'False
  212.       FillStyle       =   0
  213.       RightToLeft     =   0   'False
  214.       PictureType     =   0
  215.       TabBehavior     =   0
  216.       OwnerDraw       =   0
  217.       Editable        =   0   'False
  218.       ShowComboButton =   -1  'True
  219.       WordWrap        =   0   'False
  220.       TextStyle       =   0
  221.       TextStyleFixed  =   0
  222.       OleDragMode     =   0
  223.       OleDropMode     =   0
  224.       DataMode        =   0
  225.       VirtualData     =   -1  'True
  226.    End
  227.    Begin MSComctlLib.Toolbar SzToolbar 
  228.       Align           =   1  'Align Top
  229.       Height          =   555
  230.       Left            =   0
  231.       TabIndex        =   8
  232.       Top             =   0
  233.       Width           =   9645
  234.       _ExtentX        =   17013
  235.       _ExtentY        =   979
  236.       ButtonWidth     =   820
  237.       ButtonHeight    =   926
  238.       AllowCustomize  =   0   'False
  239.       Appearance      =   1
  240.       Style           =   1
  241.       ImageList       =   "ImageList1"
  242.       _Version        =   393216
  243.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  244.          NumButtons      =   6
  245.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  246.             Caption         =   "设置"
  247.             Key             =   "ymsz"
  248.             ImageKey        =   "sz"
  249.          EndProperty
  250.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  251.             Caption         =   "打印"
  252.             Key             =   "dy"
  253.             ImageKey        =   "dy"
  254.          EndProperty
  255.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  256.             Caption         =   "预览"
  257.             Key             =   "yl"
  258.             ImageKey        =   "yl"
  259.          EndProperty
  260.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  261.             Style           =   3
  262.          EndProperty
  263.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  264.             Caption         =   "帮助"
  265.             Key             =   "bz"
  266.             ImageKey        =   "bz"
  267.          EndProperty
  268.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  269.             Caption         =   "退出"
  270.             Key             =   "fh"
  271.             ImageKey        =   "tc"
  272.          EndProperty
  273.       EndProperty
  274.       BorderStyle     =   1
  275.       Begin MSComctlLib.ImageList ImageList1 
  276.          Left            =   5820
  277.          Top             =   0
  278.          _ExtentX        =   1005
  279.          _ExtentY        =   1005
  280.          BackColor       =   -2147483643
  281.          ImageWidth      =   16
  282.          ImageHeight     =   16
  283.          MaskColor       =   12632256
  284.          _Version        =   393216
  285.          BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  286.             NumListImages   =   32
  287.             BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  288.                Picture         =   "现金流量表.frx":340C4
  289.                Key             =   "sz"
  290.             EndProperty
  291.             BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  292.                Picture         =   "现金流量表.frx":3445E
  293.                Key             =   "dy"
  294.             EndProperty
  295.             BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  296.                Picture         =   "现金流量表.frx":347F8
  297.                Key             =   "yl"
  298.             EndProperty
  299.             BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  300.                Picture         =   "现金流量表.frx":34B92
  301.                Key             =   "xg"
  302.             EndProperty
  303.             BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  304.                Picture         =   "现金流量表.frx":34F2C
  305.                Key             =   "zh"
  306.             EndProperty
  307.             BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  308.                Picture         =   "现金流量表.frx":352C6
  309.                Key             =   "sh"
  310.             EndProperty
  311.             BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  312.                Picture         =   "现金流量表.frx":35660
  313.                Key             =   "bc"
  314.             EndProperty
  315.             BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  316.                Picture         =   "现金流量表.frx":359FA
  317.                Key             =   "fq"
  318.             EndProperty
  319.             BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  320.                Picture         =   "现金流量表.frx":35D94
  321.                Key             =   "bz"
  322.             EndProperty
  323.             BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  324.                Picture         =   "现金流量表.frx":3612E
  325.                Key             =   "tc"
  326.             EndProperty
  327.             BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  328.                Picture         =   "现金流量表.frx":364C8
  329.                Key             =   "bcgs"
  330.             EndProperty
  331.             BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  332.                Picture         =   "现金流量表.frx":36862
  333.                Key             =   "mrlk"
  334.             EndProperty
  335.             BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  336.                Picture         =   "现金流量表.frx":36BFC
  337.                Key             =   "xsxm"
  338.             EndProperty
  339.             BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  340.                Picture         =   "现金流量表.frx":36F96
  341.                Key             =   "first"
  342.             EndProperty
  343.             BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  344.                Picture         =   "现金流量表.frx":37330
  345.                Key             =   "prev"
  346.             EndProperty
  347.             BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  348.                Picture         =   "现金流量表.frx":376CA
  349.                Key             =   "next"
  350.             EndProperty
  351.             BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  352.                Picture         =   "现金流量表.frx":37A64
  353.                Key             =   "last"
  354.             EndProperty
  355.             BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  356.                Picture         =   "现金流量表.frx":37DFE
  357.                Key             =   "xx"
  358.             EndProperty
  359.             BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  360.                Picture         =   "现金流量表.frx":38198
  361.                Key             =   "define"
  362.             EndProperty
  363.             BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  364.                Picture         =   "现金流量表.frx":38532
  365.                Key             =   "exec"
  366.             EndProperty
  367.             BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  368.                Picture         =   "现金流量表.frx":388CC
  369.                Key             =   "xz"
  370.             EndProperty
  371.             BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  372.                Picture         =   "现金流量表.frx":38C66
  373.                Key             =   "sc"
  374.             EndProperty
  375.             BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  376.                Picture         =   "现金流量表.frx":39000
  377.                Key             =   "sx"
  378.             EndProperty
  379.             BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  380.                Picture         =   "现金流量表.frx":3939A
  381.                Key             =   "cx"
  382.             EndProperty
  383.             BeginProperty ListImage25 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  384.                Picture         =   "现金流量表.frx":39734
  385.                Key             =   "zd"
  386.             EndProperty
  387.             BeginProperty ListImage26 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  388.                Picture         =   "现金流量表.frx":39ACE
  389.                Key             =   "dz"
  390.             EndProperty
  391.             BeginProperty ListImage27 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  392.                Picture         =   "现金流量表.frx":39E68
  393.                Key             =   "ph"
  394.             EndProperty
  395.             BeginProperty ListImage28 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  396.                Picture         =   "现金流量表.frx":3A202
  397.                Key             =   "fz"
  398.             EndProperty
  399.             BeginProperty ListImage29 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  400.                Picture         =   "现金流量表.frx":3A59C
  401.                Key             =   "dw"
  402.             EndProperty
  403.             BeginProperty ListImage30 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  404.                Picture         =   "现金流量表.frx":3A936
  405.                Key             =   "hf"
  406.             EndProperty
  407.             BeginProperty ListImage31 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  408.                Picture         =   "现金流量表.frx":3ACD0
  409.                Key             =   "pz"
  410.             EndProperty
  411.             BeginProperty ListImage32 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  412.                Picture         =   "现金流量表.frx":3B06A
  413.                Key             =   "check"
  414.             EndProperty
  415.          EndProperty
  416.       End
  417.    End
  418. End
  419. Attribute VB_Name = "XJ_XJLLB"
  420. Attribute VB_GlobalNameSpace = False
  421. Attribute VB_Creatable = False
  422. Attribute VB_PredeclaredId = True
  423. Attribute VB_Exposed = False
  424. Dim Dyymctbl As New DY_Dyymsz            '打印页面窗体变量
  425. Private Sub Combo1_Click()
  426.     Call Sub_xjllsc
  427. End Sub
  428. Private Sub Form_Load()      '计算现金流量表
  429.     Dim RecAdoYear As New ADODB.Recordset  '定义数据库
  430.     If RecAdoYear.State = 1 Then RecAdoYear.Close
  431.     RecAdoYear.Open "select period,year  from cwzz_cashflowdata group by period ,year", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  432.     Do While Not RecAdoYear.EOF()
  433.         Combo1.AddItem Trim(RecAdoYear.Fields!Year) + "-" + Trim(RecAdoYear.Fields!Period)
  434.         RecAdoYear.MoveNext
  435.     Loop
  436.     Combo1.Text = Format(XT_login.CzrqText.Text, "yyyy-mm")
  437.     '调入打印页面设置窗体
  438.     
  439.     XtReportCode = "c_xjllb"
  440.     Load Dyymctbl
  441.     ReportTitle = "现金流量表"
  442.     
  443.     '调整标题栏及网格、格式工具条位置
  444.     Pic_Title.Left = 40
  445.     Pic_Title.Top = SzToolbar.Top + SzToolbar.Height - 10
  446.     CxbbGrid.Left = Pic_Title.Left
  447.     CxbbGrid.Top = Pic_Title.Top + Pic_Title.Height + 20
  448.     CxbbGrid.ColHidden(0) = True
  449.     Call Sub_xjllsc
  450. End Sub
  451. Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
  452.     Select Case Button.Key
  453.     Case "ymsz"                                           '页面设置
  454.         Dyymctbl.Show 1
  455.     Case "yl"                                          '预 览
  456.         Call bbyl(True)
  457.     Case "dy"                                          '打 印
  458.         Call bbyl(False)
  459.     Case "fh"                                             '退  出
  460.         Unload Me
  461.     End Select
  462. End Sub
  463. Private Sub bbyl(bbylte As Boolean)                    '报表打印预览
  464.     Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
  465.     Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
  466.     Bbxbtgs = 1                                          '报 表 小 标 题 行 数
  467.     Bbbwhgs = 0                                          '报 表 表 尾 行 数
  468.     ReDim Bbxbt(1 To Bbxbtgs)
  469.     ReDim bbxbtzzxs(1 To Bbxbtgs)
  470.     If Bbbwhgs <> 0 Then
  471.         ReDim Bbbwh(1 To Bbbwhgs)
  472.         ReDim Bbbwhzzxs(1 To Bbbwhgs)
  473.     End If
  474.     Bbzbt = "现金流量表" 'ReportTitle
  475.     Bbxbt(1) = "编制单位:沧化集团" + Space(23) + "会计期间:" + Combo1.Text
  476.     bbxbtzzxs(1) = 0                                    '报表行组织形式(0-居左 1-居中 2-居右)
  477.     Call Scyxsjb(CxbbGrid)                               '生成报表数据
  478.     Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
  479.     If Not bbylte Then
  480.         Unload DY_Tybbyldy
  481.     End If
  482. End Sub
  483. Private Sub Form_Unload(Cancel As Integer)                                  '窗体卸载
  484.     '卸载打印页面设置窗体
  485.     Unload Dyymctbl
  486. End Sub
  487. Sub Sub_xjllsc()                                               '现金流量表生成
  488.     
  489.     Dim First As Double, Second As Double, SumValue As Double, SumValueYear As Double, OperateFirst As String, OperateSecond As String
  490.     Dim Jsqte As Integer, FirstFlag As Boolean, OperateFlag As Boolean   '定义变量
  491.     Dim RecTemp As New ADODB.Recordset, RecAdo As New ADODB.Recordset, recData As New ADODB.Recordset, RecAdoYear As New ADODB.Recordset '定义数据库
  492.     Dim i As Integer   '定义网各行
  493.     On Error Resume Next
  494.     CxbbGrid.Clear
  495.     SumValue = 0
  496.     FirstFlag = False
  497.     OperateFlag = False
  498.     If RecTemp.State = 1 Then RecTemp.Close
  499.     RecTemp.Open "select * from cwzz_cashflowitem order by logicid", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic  '取出现金流量项目
  500.     CxbbGrid.Rows = 1
  501.     CxbbGrid.Cols = 5
  502.     CxbbGrid.FormatString = "编  码|项  目|行  次|本月数|本年累计"
  503.     CxbbGrid.FixedAlignment(1) = flexAlignCenterCenter
  504.     CxbbGrid.FixedAlignment(2) = flexAlignCenterCenter
  505.     CxbbGrid.FixedAlignment(3) = flexAlignCenterCenter
  506.     CxbbGrid.FixedAlignment(4) = flexAlignCenterCenter
  507.     i = 1
  508.     Do While Not RecTemp.EOF()    '循环查找数据
  509.         If i >= CxbbGrid.Rows - 1 Then
  510.             CxbbGrid.AddItem ""
  511.             CxbbGrid.ColWidth(1) = 5000
  512.             CxbbGrid.ColWidth(2) = 600
  513.             CxbbGrid.ColWidth(3) = 2500
  514.             CxbbGrid.ColWidth(4) = 2500
  515.             CxbbGrid.ColAlignment(2) = flexAlignCenterCenter
  516.         End If
  517.         CxbbGrid.TextMatrix(i, 0) = RecTemp.Fields!CASHFLOWCODE
  518.         CxbbGrid.TextMatrix(i, 1) = RecTemp.Fields!CASHFLOWNAME
  519.         If RecTemp.Fields!RowNo = 0 Then
  520.             CxbbGrid.TextMatrix(i, 2) = ""
  521.         Else
  522.             CxbbGrid.TextMatrix(i, 2) = RecTemp.Fields!RowNo
  523.         End If
  524.         If Trim(RecTemp.Fields!DataSource) = "" Then   '如果为空
  525.             If RecAdo.State = 1 Then RecAdo.Close
  526.             RecAdo.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & Trim(RecTemp.Fields!CASHFLOWCODE) & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  527.             If RecAdo.EOF = False Then
  528.                 If IsNull(RecAdo.Fields!fpje) = False Then
  529.                     CxbbGrid.TextMatrix(i, 3) = Format(RecAdo.Fields!fpje, "#,###.00")
  530.                 Else
  531.                     CxbbGrid.TextMatrix(i, 3) = ""
  532.                 End If
  533.             End If
  534.             If RecAdoYear.State = 1 Then RecAdoYear.Close
  535.             RecAdoYear.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & Trim(RecTemp.Fields!CASHFLOWCODE) & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period<='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  536.             If RecAdoYear.EOF = False Then
  537.                 If IsNull(RecAdoYear.Fields!fpje) = False Then
  538.                     CxbbGrid.TextMatrix(i, 4) = Format(RecAdoYear.Fields!fpje, "#,###.00")
  539.                 Else
  540.                     CxbbGrid.TextMatrix(i, 4) = ""
  541.                 End If
  542.             End If
  543.         Else                                                         '从网格中直接取数
  544.             SumValue = 0
  545.             FirstFlag = False
  546.             OperateFlag = False
  547.             For Jsqte = 1 To Len(Trim(RecTemp.Fields!DataSource))
  548.                 If Mid(Trim(RecTemp.Fields!DataSource), Jsqte, 1) >= "0" And Mid(Trim(RecTemp.Fields!DataSource), Jsqte, 1) <= "9" Then
  549.                     If Not FirstFlag Then
  550.                         First = First & Mid(Trim(RecTemp.Fields!DataSource), Jsqte, 1)
  551.                     Else
  552.                         Second = Second & Mid(Trim(RecTemp.Fields!DataSource), Jsqte, 1)
  553.                     End If
  554.                 Else
  555.                     If Not OperateFlag Then
  556.                         OperateFirst = Mid(Trim(RecTemp.Fields!DataSource), Jsqte, 1)
  557.                     Else
  558.                         OperateSecond = Mid(RecTemp.Fields!DataSource, Jsqte, 1)
  559.                         
  560.                     End If
  561.                     If FirstFlag = False Then FirstFlag = True
  562.                     If OperateFlag Then
  563.                         Dim FirstFpje, SecondFpje, FirstFpjeYear, SecondFpjeYear
  564.                         Select Case OperateFirst
  565.                         Case "+"
  566.                             
  567.                             If FirstFlag Then
  568.                                 If RecAdo.State = 1 Then RecAdo.Close
  569.                                 RecAdo.Open "select * from cwzz_cashflowitem where rowno='" & First & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  570.                                 If RecAdo.EOF = False Then
  571.                                     If Trim(RecAdo.Fields!CASHFLOWCODE) <> "" Then
  572.                                         First = RecAdo.Fields!CASHFLOWCODE
  573.                                     End If
  574.                                 End If
  575.                                 
  576.                                 If recData.State = 1 Then recData.Close
  577.                                 recData.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & First & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  578.                                 If recData.EOF = False Then
  579.                                     If IsNull(recData.Fields!fpje) = False Then
  580.                                         FirstFpje = recData.Fields!fpje
  581.                                     End If
  582.                                 End If
  583.                                 If RecAdoYear.State = 1 Then RecAdoYear.Close
  584.                                 RecAdoYear.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & First & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period<='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  585.                                 If RecAdoYear.EOF = False Then
  586.                                     If IsNull(RecAdoYear.Fields!fpje) = False Then
  587.                                         FirstFpjeYear = RecAdoYear.Fields!fpje
  588.                                     End If
  589.                                 End If
  590.                                 If RecAdo.State = 1 Then RecAdo.Close
  591.                                 RecAdo.Open "select * from cwzz_cashflowitem where rowno='" & Second & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  592.                                 Second = RecAdo.Fields!CASHFLOWCODE
  593.                                 If recData.State = 1 Then recData.Close
  594.                                 recData.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & Second & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  595.                                 If recData.EOF = False Then
  596.                                     If IsNull(recData.Fields!fpje) = False Then
  597.                                         SecondFpje = recData.Fields!fpje
  598.                                     Else
  599.                                         SecondFpje = 0
  600.                                     End If
  601.                                 End If
  602.                                 If RecAdoYear.State = 1 Then RecAdoYear.Close
  603.                                 RecAdoYear.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & Second & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period<='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  604.                                 If RecAdoYear.EOF = False Then
  605.                                     If IsNull(RecAdoYear.Fields!fpje) = False Then
  606.                                         SecondFpjeYear = RecAdoYear.Fields!fpje
  607.                                     Else
  608.                                         SecondFpjeYear = 0
  609.                                     End If
  610.                                 End If
  611.                                 SumValue = SumValue + Val(FirstFpje) + Val(SecondFpje)
  612.                                 SumValueYear = SumValueYear + Val(FirstFpjeYear) + Val(SecondFpjeYear)
  613.                                 First = 0
  614.                                 Second = 0
  615.                                 FirstFpje = 0
  616.                                 SecondFpje = 0
  617.                                 FirstFpjeYear = 0
  618.                                 SecondFpjeYear = 0
  619.                             End If
  620.                             If FirstFlag = False Then FirstFlag = True
  621.                         Case "-"
  622.                             
  623.                             If FirstFlag Then
  624.                                 If RecAdo.State = 1 Then RecAdo.Close
  625.                                 RecAdo.Open "select * from cwzz_cashflowitem where rowno='" & First & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  626.                                 If RecAdo.EOF = False Then
  627.                                     If Trim(RecAdo.Fields!CASHFLOWCODE) <> "" Then
  628.                                         First = RecAdo.Fields!CASHFLOWCODE
  629.                                     End If
  630.                                 End If
  631.                                 
  632.                                 If recData.State = 1 Then recData.Close
  633.                                 recData.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & First & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  634.                                 If recData.EOF = False Then
  635.                                     If IsNull(recData.Fields!fpje) = False Then
  636.                                         FirstFpje = recData.Fields!fpje
  637.                                     End If
  638.                                 End If
  639.                                 If RecAdoYear.State = 1 Then RecAdoYear.Close
  640.                                 RecAdoYear.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & First & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period<='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  641.                                 If RecAdoYear.EOF = False Then
  642.                                     If IsNull(RecAdoYear.Fields!fpje) = False Then
  643.                                         FirstFpjeYear = RecAdoYear.Fields!fpje
  644.                                     End If
  645.                                 End If
  646.                                 If RecAdo.State = 1 Then RecAdo.Close
  647.                                 RecAdo.Open "select * from cwzz_cashflowitem where rowno='" & Second & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  648.                                 Second = RecAdo.Fields!CASHFLOWCODE
  649.                                 If recData.State = 1 Then recData.Close
  650.                                 recData.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & Second & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  651.                                 If recData.EOF = False Then
  652.                                     If IsNull(recData.Fields!fpje) = False Then
  653.                                         SecondFpje = recData.Fields!fpje
  654.                                     Else
  655.                                         SecondFpje = 0
  656.                                     End If
  657.                                 End If
  658.                                 If RecAdoYear.State = 1 Then RecAdoYear.Close
  659.                                 RecAdoYear.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & Second & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period<='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  660.                                 If RecAdoYear.EOF = False Then
  661.                                     If IsNull(RecAdoYear.Fields!fpje) = False Then
  662.                                         SecondFpjeYear = RecAdoYear.Fields!fpje
  663.                                     Else
  664.                                         SecondFpjeYear = 0
  665.                                     End If
  666.                                 End If
  667.                                 SumValue = SumValue + Val(FirstFpje) - Val(SecondFpje)
  668.                                 SumValueYear = SumValueYear + Val(FirstFpjeYear) - Val(SecondFpjeYear)
  669.                                 First = 0
  670.                                 Second = 0
  671.                                 FirstFpje = 0
  672.                                 SecondFpje = 0
  673.                                 FirstFpjeYear = 0
  674.                                 SecondFpjeYear = 0
  675.                             End If
  676.                             If FirstFlag = False Then FirstFlag = True
  677.                         End Select
  678.                     End If
  679.                     If OperateFlag Then OperateFirst = OperateSecond
  680.                     If OperateFlag = False Then OperateFlag = True
  681.                 End If
  682.             Next Jsqte
  683.             If RecAdo.State = 1 Then RecAdo.Close                       '最后一行数据处理
  684.             If Second <> 0 Then
  685.                 RecAdo.Open "select * from cwzz_cashflowitem where rowno='" & Second & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  686.             Else
  687.                 If First <> "" Then
  688.                     RecAdo.Open "select * from cwzz_cashflowitem where rowno='" & First & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  689.                 End If
  690.             End If
  691.             If RecAdo.EOF = False Then
  692.                 Second = RecAdo.Fields!CASHFLOWCODE
  693.             End If
  694.             If recData.State = 1 Then recData.Close
  695.             recData.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & Second & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  696.             If recData.EOF = False Then
  697.                 If IsNull(recData.Fields!fpje) = False Then
  698.                     SecondFpje = recData.Fields!fpje
  699.                 Else
  700.                     SecondFpje = 0
  701.                 End If
  702.             End If
  703.             If RecAdoYear.State = 1 Then RecAdoYear.Close
  704.             RecAdoYear.Open "select sum(fpje) as fpje from cwzz_cashflowdata where cashflowid='" & Second & "'and year='" & Format(Combo1.Text, "yyyy") & "' and period<='" & Format(Combo1.Text, "mm") & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  705.             If RecAdoYear.EOF = False Then
  706.                 If IsNull(RecAdoYear.Fields!fpje) = False Then
  707.                     SecondFpjeYear = RecAdoYear.Fields!fpje
  708.                 Else
  709.                     SecondFpjeYear = 0
  710.                 End If
  711.             End If
  712.             '完整数据
  713.             If OperateFirst = "+" Then SumValue = SumValue + Val(FirstFpje) + Val(SecondFpje): SumValueYear = SumValueYear + Val(FirstFpjeYear) + Val(SecondFpjeYear)
  714.             If OperateFirst = "-" Then SumValue = SumValue + Val(FirstFpje) - Val(SecondFpje): SumValueYear = SumValueYear + Val(FirstFpjeYear) - Val(SecondFpjeYear)
  715.             If SumValue = 0 Then
  716.                 CxbbGrid.TextMatrix(i, 3) = ""
  717.             Else
  718.                 CxbbGrid.TextMatrix(i, 3) = Format(SumValue, "#,###.00")
  719.             End If
  720.             If SumValueYear = 0 Then
  721.                 CxbbGrid.TextMatrix(i, 4) = ""
  722.             Else
  723.                 CxbbGrid.TextMatrix(i, 4) = Format(SumValueYear, "#,###.00")
  724.             End If
  725.         End If
  726.         SumValue = 0
  727.         SumValueYear = 0
  728.         First = 0
  729.         Second = 0
  730.         i = i + 1
  731.         RecTemp.MoveNext
  732.     Loop
  733. End Sub
  734.