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

企业管理

开发平台:

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 Book_Total 
  5.    Caption         =   "资产统计报表"
  6.    ClientHeight    =   8595
  7.    ClientLeft      =   60
  8.    ClientTop       =   345
  9.    ClientWidth     =   11880
  10.    HelpContextID   =   505006
  11.    Icon            =   "资产统计报表.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    LockControls    =   -1  'True
  14.    MDIChild        =   -1  'True
  15.    ScaleHeight     =   8595
  16.    ScaleWidth      =   11880
  17.    WindowState     =   2  'Maximized
  18.    Begin VB.Timer Timer1 
  19.       Enabled         =   0   'False
  20.       Interval        =   1
  21.       Left            =   6540
  22.       Top             =   60
  23.    End
  24.    Begin VB.PictureBox Pic_Title 
  25.       BackColor       =   &H00FFFFFF&
  26.       Height          =   1125
  27.       Left            =   0
  28.       Picture         =   "资产统计报表.frx":1042
  29.       ScaleHeight     =   1065
  30.       ScaleWidth      =   11835
  31.       TabIndex        =   1
  32.       Top             =   570
  33.       Width           =   11895
  34.       Begin MSComctlLib.ImageList ImageList1 
  35.          Left            =   4980
  36.          Top             =   30
  37.          _ExtentX        =   1005
  38.          _ExtentY        =   1005
  39.          BackColor       =   -2147483643
  40.          ImageWidth      =   16
  41.          ImageHeight     =   16
  42.          MaskColor       =   12632256
  43.          _Version        =   393216
  44.          BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  45.             NumListImages   =   9
  46.             BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  47.                Picture         =   "资产统计报表.frx":35106
  48.                Key             =   "sz"
  49.             EndProperty
  50.             BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  51.                Picture         =   "资产统计报表.frx":354A0
  52.                Key             =   "dy"
  53.             EndProperty
  54.             BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  55.                Picture         =   "资产统计报表.frx":3583A
  56.                Key             =   "yl"
  57.             EndProperty
  58.             BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  59.                Picture         =   "资产统计报表.frx":35BD4
  60.                Key             =   "bz"
  61.             EndProperty
  62.             BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  63.                Picture         =   "资产统计报表.frx":35F6E
  64.                Key             =   "tc"
  65.             EndProperty
  66.             BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  67.                Picture         =   "资产统计报表.frx":36308
  68.                Key             =   "bcgs"
  69.             EndProperty
  70.             BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  71.                Picture         =   "资产统计报表.frx":366A2
  72.                Key             =   "mrlk"
  73.             EndProperty
  74.             BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  75.                Picture         =   "资产统计报表.frx":36A3C
  76.                Key             =   "cx"
  77.             EndProperty
  78.             BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  79.                Picture         =   "资产统计报表.frx":36DD6
  80.                Key             =   "xc"
  81.             EndProperty
  82.          EndProperty
  83.       End
  84.       Begin VB.Label Lbl_Year 
  85.          AutoSize        =   -1  'True
  86.          BackStyle       =   0  'Transparent
  87.          ForeColor       =   &H00000000&
  88.          Height          =   180
  89.          Left            =   5040
  90.          TabIndex        =   7
  91.          Top             =   840
  92.          Width           =   90
  93.       End
  94.       Begin VB.Label Label1 
  95.          AutoSize        =   -1  'True
  96.          BackStyle       =   0  'Transparent
  97.          Caption         =   "会计期间:"
  98.          Height          =   180
  99.          Left            =   4170
  100.          TabIndex        =   6
  101.          Top             =   840
  102.          Width           =   810
  103.       End
  104.       Begin VB.Label tsLabel 
  105.          AutoSize        =   -1  'True
  106.          BackColor       =   &H80000018&
  107.          BackStyle       =   0  'Transparent
  108.          Caption         =   "资产统计报表"
  109.          BeginProperty Font 
  110.             Name            =   "宋体"
  111.             Size            =   12
  112.             Charset         =   134
  113.             Weight          =   700
  114.             Underline       =   0   'False
  115.             Italic          =   0   'False
  116.             Strikethrough   =   0   'False
  117.          EndProperty
  118.          ForeColor       =   &H00000000&
  119.          Height          =   240
  120.          Index           =   4
  121.          Left            =   540
  122.          TabIndex        =   2
  123.          Top             =   270
  124.          Width           =   1530
  125.       End
  126.    End
  127.    Begin VSFlex8Ctl.VSFlexGrid CxbbGrid 
  128.       Height          =   6915
  129.       Left            =   0
  130.       TabIndex        =   0
  131.       Top             =   1740
  132.       Width           =   11895
  133.       _cx             =   5080
  134.       _cy             =   5080
  135.       Appearance      =   1
  136.       BorderStyle     =   1
  137.       Enabled         =   -1  'True
  138.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  139.          Name            =   "宋体"
  140.          Size            =   9
  141.          Charset         =   134
  142.          Weight          =   400
  143.          Underline       =   0   'False
  144.          Italic          =   0   'False
  145.          Strikethrough   =   0   'False
  146.       EndProperty
  147.       MousePointer    =   0
  148.       BackColor       =   -2147483643
  149.       ForeColor       =   -2147483640
  150.       BackColorFixed  =   -2147483633
  151.       ForeColorFixed  =   -2147483630
  152.       BackColorSel    =   -2147483635
  153.       ForeColorSel    =   -2147483634
  154.       BackColorBkg    =   -2147483636
  155.       BackColorAlternate=   -2147483643
  156.       GridColor       =   -2147483633
  157.       GridColorFixed  =   -2147483632
  158.       TreeColor       =   -2147483632
  159.       FloodColor      =   192
  160.       SheetBorder     =   -2147483642
  161.       FocusRect       =   1
  162.       HighLight       =   1
  163.       AllowSelection  =   -1  'True
  164.       AllowBigSelection=   -1  'True
  165.       AllowUserResizing=   0
  166.       SelectionMode   =   0
  167.       GridLines       =   1
  168.       GridLinesFixed  =   2
  169.       GridLineWidth   =   1
  170.       Rows            =   50
  171.       Cols            =   10
  172.       FixedRows       =   1
  173.       FixedCols       =   1
  174.       RowHeightMin    =   0
  175.       RowHeightMax    =   0
  176.       ColWidthMin     =   0
  177.       ColWidthMax     =   0
  178.       ExtendLastCol   =   0   'False
  179.       FormatString    =   ""
  180.       ScrollTrack     =   0   'False
  181.       ScrollBars      =   3
  182.       ScrollTips      =   0   'False
  183.       MergeCells      =   0
  184.       MergeCompare    =   0
  185.       AutoResize      =   -1  'True
  186.       AutoSizeMode    =   0
  187.       AutoSearch      =   0
  188.       AutoSearchDelay =   2
  189.       MultiTotals     =   -1  'True
  190.       SubtotalPosition=   1
  191.       OutlineBar      =   0
  192.       OutlineCol      =   0
  193.       Ellipsis        =   0
  194.       ExplorerBar     =   0
  195.       PicturesOver    =   0   'False
  196.       FillStyle       =   0
  197.       RightToLeft     =   0   'False
  198.       PictureType     =   0
  199.       TabBehavior     =   0
  200.       OwnerDraw       =   0
  201.       Editable        =   0
  202.       ShowComboButton =   1
  203.       WordWrap        =   0   'False
  204.       TextStyle       =   0
  205.       TextStyleFixed  =   0
  206.       OleDragMode     =   0
  207.       OleDropMode     =   0
  208.       DataMode        =   0
  209.       VirtualData     =   -1  'True
  210.       DataMember      =   ""
  211.       ComboSearch     =   3
  212.       AutoSizeMouse   =   -1  'True
  213.       FrozenRows      =   0
  214.       FrozenCols      =   0
  215.       AllowUserFreezing=   0
  216.       BackColorFrozen =   0
  217.       ForeColorFrozen =   0
  218.       WallPaperAlignment=   9
  219.       AccessibleName  =   ""
  220.       AccessibleDescription=   ""
  221.       AccessibleValue =   ""
  222.       AccessibleRole  =   24
  223.    End
  224.    Begin MSComctlLib.Toolbar GsToolbar 
  225.       Height          =   525
  226.       Left            =   10200
  227.       TabIndex        =   3
  228.       Top             =   30
  229.       Width           =   1665
  230.       _ExtentX        =   2937
  231.       _ExtentY        =   926
  232.       ButtonWidth     =   1455
  233.       ButtonHeight    =   926
  234.       Appearance      =   1
  235.       Style           =   1
  236.       ImageList       =   "ImageList1"
  237.       _Version        =   393216
  238.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  239.          NumButtons      =   2
  240.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  241.             Caption         =   "保存格式"
  242.             Key             =   "bcgs"
  243.             ImageKey        =   "bcgs"
  244.          EndProperty
  245.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  246.             Caption         =   "默认列宽"
  247.             Key             =   "hfmrgs"
  248.             ImageKey        =   "mrlk"
  249.          EndProperty
  250.       EndProperty
  251.    End
  252.    Begin MSComctlLib.Toolbar SzToolbar 
  253.       Align           =   1  'Align Top
  254.       Height          =   555
  255.       Left            =   0
  256.       TabIndex        =   4
  257.       Top             =   0
  258.       Width           =   11880
  259.       _ExtentX        =   20955
  260.       _ExtentY        =   979
  261.       ButtonWidth     =   820
  262.       ButtonHeight    =   926
  263.       AllowCustomize  =   0   'False
  264.       Appearance      =   1
  265.       Style           =   1
  266.       ImageList       =   "ImageList1"
  267.       _Version        =   393216
  268.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  269.          NumButtons      =   10
  270.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  271.             Caption         =   "设置"
  272.             Key             =   "ymsz"
  273.             ImageKey        =   "sz"
  274.          EndProperty
  275.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  276.             Caption         =   "打印"
  277.             Key             =   "dy"
  278.             ImageKey        =   "dy"
  279.          EndProperty
  280.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  281.             Caption         =   "预览"
  282.             Key             =   "yl"
  283.             ImageKey        =   "yl"
  284.          EndProperty
  285.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  286.             Style           =   3
  287.          EndProperty
  288.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  289.             Caption         =   "详查"
  290.             Key             =   "xc"
  291.             ImageKey        =   "xc"
  292.          EndProperty
  293.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  294.             Style           =   4
  295.          EndProperty
  296.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  297.             Caption         =   "查询"
  298.             Key             =   "cx"
  299.             ImageKey        =   "cx"
  300.          EndProperty
  301.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  302.             Style           =   4
  303.          EndProperty
  304.          BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  305.             Caption         =   "帮助"
  306.             Key             =   "bz"
  307.             ImageKey        =   "bz"
  308.          EndProperty
  309.          BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  310.             Caption         =   "退出"
  311.             Key             =   "fh"
  312.             ImageKey        =   "tc"
  313.          EndProperty
  314.       EndProperty
  315.       BorderStyle     =   1
  316.       Begin VB.TextBox Txt_Bit 
  317.          Height          =   270
  318.          Left            =   5070
  319.          TabIndex        =   5
  320.          Text            =   "Text1"
  321.          Top             =   1230
  322.          Visible         =   0   'False
  323.          Width           =   1035
  324.       End
  325.    End
  326. End
  327. Attribute VB_Name = "Book_Total"
  328. Attribute VB_GlobalNameSpace = False
  329. Attribute VB_Creatable = False
  330. Attribute VB_PredeclaredId = True
  331. Attribute VB_Exposed = False
  332. '******************************************************************
  333. '*    模 块 名 称 :资产统计报表
  334. '*    功 能 描 述 :
  335. '*    程序员姓名  :徐衍民
  336. '*    最后修改人  :徐衍民
  337. '*    最后修改时间:2001/12/18
  338. '*    备        注:
  339. '******************************************************************
  340. Dim ReportTitle As String                '报表主标题
  341. Dim Card_Str As String                   '用户录入查询条件
  342. Dim rstemp As ADODB.Recordset            '临时打开数据集变量
  343. Dim Period As String                     '会计期间
  344. Dim Year As String                       '会计年度
  345. '以下为固定使用变量
  346. Dim Dyymctbl As New DY_Dyymsz            '打印页面窗体变量
  347. Dim GridCode As String                   '显示网格网格代码
  348. Dim GridInf() As Variant                 '整个网格设置信息
  349. Dim Tsxx As String                       '系统提示信息
  350. Dim Qslz As Long                         '网格隐藏(非操作显示)列数
  351. Dim Sjhgd As Double                      '网格数据行高度
  352. Dim Sfxshjwg As Boolean                  '是否显示合计网格
  353. Dim GridBoolean() As Boolean             '网格列信息(布尔型)
  354. Dim GridStr()  As String                 '网格列信息(字符型)
  355. Dim GridInt() As Integer                 '网格列信息(整型)
  356. Dim Szzls As Integer                     '数组总列数(网格列数-1)
  357. Private Sub Form_Resize()                '根据窗体大小来调整网格,标题栏大小
  358.     
  359.     On Error Resume Next
  360.     
  361.     With CxbbGrid
  362.         .Width = Me.Width - 160
  363.         .Height = Me.Height - .Top - 400
  364.     End With
  365.     
  366.     With Pic_Title
  367.         .Width = Me.Width - 160
  368.     End With
  369.     
  370.     GsToolbar.Left = Me.Width - GsToolbar.Width - 160
  371. End Sub
  372. Private Sub Form_Load()                                                   '窗体装入
  373.      
  374.     '调入打印页面设置窗体
  375.     ReportTitle = "固定统计报表"
  376.     XtReportCode = "Gdzc_Book_Total"
  377.     Load Dyymctbl
  378.      
  379.     '调整标题栏及网格、格式工具条位置
  380.     Pic_Title.Left = 40
  381.     Pic_Title.Top = SzToolbar.Top + SzToolbar.Height - 10
  382.     CxbbGrid.Left = Pic_Title.Left
  383.     CxbbGrid.Top = Pic_Title.Top + Pic_Title.Height + 20
  384.     
  385.     '调 入 网 格
  386.     GridCode = "Gdzc_Book_Total"
  387.     Call BzWgcsh(CxbbGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
  388.      
  389.     Qslz = GridInf(1)
  390.     Sjhgd = GridInf(2)
  391.     Sfxshjwg = GridInf(7)
  392.     Szzls = CxbbGrid.Cols - 1
  393. End Sub
  394. Private Sub Form_Unload(Cancel As Integer)                                  '窗体卸载
  395.     
  396.     '卸载条件窗体
  397.     Book_Total_Search.UnloadCheck.Value = 1
  398.     Unload Book_Total_Search
  399.     '卸载打印页面设置窗体
  400.     Unload Dyymctbl
  401. End Sub
  402. Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)       '网格格式调整
  403.     
  404.     Select Case Button.Key
  405.         Case "bcgs"                                          '保存表格格式
  406.           Call Bcwggs(CxbbGrid, GridCode, GridStr)
  407.         Case "hfmrgs"                                        '恢复默认格式
  408.           Call Hfmrgs(CxbbGrid, GridCode, GridStr)
  409.     End Select
  410. End Sub
  411. Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
  412.     
  413.     Select Case Button.Key
  414.         Case "ymsz"                                          '页面设置
  415.             Dyymctbl.Show 1
  416.         Case "yl"                                            '预 览
  417.             Call bbyl(True)
  418.         Case "dy"                                            '打 印
  419.             Call bbyl(False)
  420.         Case "cx"                                            '查 询
  421.             Book_Total_Search.Show 1
  422.         Case "xc"                                            '详查
  423.             Book_Total_Detail.Year_Text = LeftChar(Book_Total_Search.Com_Year(1).Text)
  424.             Book_Total_Detail.Period_Text = RightChar(Book_Total_Search.Com_Year(1).Text)
  425.             Book_Total_Detail.Timer1.Enabled = True
  426.             Book_Total_Detail.Show
  427.         Case "fh"                                            '退 出
  428.             Unload Me
  429.         Case "bz"
  430.             SendKeys "{F1}"
  431.      End Select
  432.      
  433. End Sub
  434. Private Sub Timer1_Timer()                                 '在窗体激活后调入查询程序
  435.     
  436.     Timer1.Enabled = False
  437.     Xt_Wait.Show
  438.     Xt_Wait.Refresh
  439.     
  440.     '加快显示速度
  441.     CxbbGrid.Redraw = False
  442.     
  443.     '生成查询结果
  444.     Call Sub_Query
  445.     
  446.     CxbbGrid.Redraw = True
  447.      
  448.     Xt_Wait.Hide
  449.     
  450. End Sub
  451. Private Sub Sub_Query()                                    '生成查询结果
  452.     
  453.     Dim Rec_Query As New ADODB.Recordset        '查询结果动态集
  454.     Dim Sqlstr As String                        '查询字符串
  455.     Dim Coljsq As Long                          '网格列计数器
  456.     Dim Jsqte As Integer                        '临时动态计数器
  457.     Dim SqlStr1 As String                       '查询字符串
  458.     
  459.     '根据查询条件,为查询语句赋值
  460.     With Book_Total_Search
  461.         Year = LeftChar(.Com_Year(1).Text)              '最大会计年度
  462.         Period = RightChar(.Com_Year(1).Text)           '最大会计期间
  463.         If Trim(.Com_Year(0).Text) <> "" And Trim(.Com_Year(1).Text) <> "" Then
  464.             Lbl_Year.Caption = Trim(.Com_Year(0).Text) & "——" & Trim(.Com_Year(1).Text)       '显示会计期间
  465.         End If
  466.         Card_Str = "where 1=1"
  467.         For Jsqte = 1 To 3
  468.             Select Case Jsqte
  469.                 Case 1          '起始会计期间
  470.                     Card_Str = Card_Str & " and Gdzc_Total.year>=" & Val(LeftChar(Trim(.Com_Year(0).Text))) & " and Gdzc_Total.Period>=" & Val(RightChar(Trim(.Com_Year(0).Text)))
  471.                 Case 2          '终止会计期间
  472.                     Card_Str = Card_Str & " and Gdzc_Total.year<=" & Val(LeftChar(.Com_Year(1).Text)) & " and Gdzc_Total.Period<=" & Val(RightChar(.Com_Year(1).Text))
  473.                 Case 3
  474.                     If .CxOption(0).Value = True Then                  '按部门和资产类别
  475.                         CxbbGrid.ColHidden(0) = False
  476.                         CxbbGrid.ColHidden(1) = False
  477.                         Sqlstr = "SELECT Gy_Department.DeptName AS DeptName, Gdzc_Sort.FASortName AS FASortName, " _
  478.                             & "SUM(Gdzc_Total.FAValueInM) AS FAValueInM, SUM(Gdzc_Total.FAValueOutM) " _
  479.                             & "AS FAValueOutM, SUM(Gdzc_DetailedForm.DeprValue) AS DeprValue " _
  480.                             & "FROM Gdzc_Card RIGHT OUTER JOIN Gdzc_Total ON Gdzc_Card.DeptCode = Gdzc_Total.DeptCode LEFT OUTER JOIN " _
  481.                             & "Gdzc_Sort ON Gdzc_Total.FASortCode = Gdzc_Sort.FASortCode LEFT OUTER JOIN " _
  482.                             & "Gy_Department ON Gdzc_Total.DeptCode = Gy_Department.DeptCode RIGHT OUTER JOIN " _
  483.                             & "Gdzc_DetailedForm ON Gdzc_Card.CardCode = Gdzc_DetailedForm.CardCode AND " _
  484.                             & "Gdzc_Total.Period = Gdzc_DetailedForm.Period AND " _
  485.                             & "Gdzc_Total.[Year] = Gdzc_DetailedForm.[Year] AND " _
  486.                             & "Gdzc_Total.FASortCode = Gdzc_DetailedForm.FASortCode "
  487.                         Sqlstr = Sqlstr & Card_Str & " GROUP BY Gy_Department.DeptName, Gdzc_Sort.FASortName "
  488.                     ElseIf .CxOption(1).Value = True Then              '按部门
  489.                         CxbbGrid.ColHidden(1) = True
  490.                         CxbbGrid.ColHidden(0) = False
  491.                         Sqlstr = "SELECT SUM(Gdzc_Total.FAValueInM) AS FAValueInM, SUM(Gdzc_Total.FAValueOutM) " _
  492.                             & "AS FAValueOutM, Gy_Department.DeptName " _
  493.                             & "FROM Gdzc_Total INNER JOIN Gy_Department ON Gdzc_Total.DeptCode = Gy_Department.DeptCode "
  494.                         
  495.                         Sqlstr = Sqlstr & Card_Str & " GROUP BY Gy_Department.DeptName"
  496.                     Else                                               '按资产类别
  497.                         CxbbGrid.ColHidden(1) = False
  498.                         CxbbGrid.ColHidden(0) = True
  499.                         Sqlstr = "SELECT Gdzc_Sort.FASortName, SUM(Gdzc_Total.FAValueInM) AS FAValueInM, " _
  500.                             & "SUM(Gdzc_Total.FAValueOutM) As FAValueOutM " _
  501.                             & "FROM Gdzc_Sort RIGHT OUTER JOIN Gdzc_Total ON Gdzc_Sort.FASortCode = Gdzc_Total.FASortCode "
  502.                         
  503.                         Sqlstr = Sqlstr & Card_Str & " GROUP BY Gdzc_Sort.FASortName"
  504.                     End If
  505.             End Select
  506.         Next Jsqte
  507.     End With
  508.     
  509.     Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  510.     With Rec_Query
  511.     CxbbGrid.Rows = CxbbGrid.FixedRows
  512.     CxbbGrid.Rows = CxbbGrid.FixedRows + .RecordCount
  513.     Jsqte = CxbbGrid.FixedRows
  514.    
  515.     Do While Not .EOF
  516.         If Jsqte >= CxbbGrid.Rows Then
  517.             CxbbGrid.AddItem ""
  518.         End If
  519.         
  520.         If Book_Total_Search.CxOption(0).Value = True Or Book_Total_Search.CxOption(1).Value = True Then
  521.             CxbbGrid.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Trim(!DeptName & "")                                            '部门名称
  522.         End If
  523.         If Book_Total_Search.CxOption(0).Value = True Or Book_Total_Search.CxOption(2).Value = True Then
  524.             CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = Trim(!FASortName & "")                                          '资产类别
  525.         End If
  526.         
  527.         If Book_Total_Search.CxOption(0).Value = True Then                                                                              '按部门和资产类别
  528.             If Val(!DeprValue) <> 0 Then CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Trim(!DeprValue & "")              '期间折旧
  529.             SqlStr1 = "SELECT Gdzc_Total.FAValueEndM, Gdzc_Total.DeprSumEndM, Gy_Department.DeptName, " _
  530.                 & "Gdzc_Sort.FASortName FROM Gdzc_Total INNER JOIN " _
  531.                 & "Gdzc_Sort ON Gdzc_Total.FASortCode = Gdzc_Sort.FASortCode INNER JOIN Gy_Department ON Gdzc_Total.DeptCode = Gy_Department.DeptCode " _
  532.                 & "Where Gdzc_Total.Year =" & Val(Year) & " And Gdzc_Total.Period = " & Val(Period) & " and Gy_DepartMent.deptname='" & Trim(!DeptName & "") & "'" _
  533.                 & " and Gdzc_Sort.FASortName='" & Trim(!FASortName) & "'"
  534.         ElseIf Book_Total_Search.CxOption(1).Value = True Then                                                                          '按部门
  535.             SqlStr1 = "SELECT SUM(Gdzc_Variation.SumDeprNew) - SUM(Gdzc_Variation.SumDeprOld) " _
  536.                 & "AS Depr FROM Gdzc_Variation LEFT OUTER JOIN Gy_Department ON Gdzc_Variation.DeptNew = Gy_Department.DeptCode " _
  537.                 & "WHERE Gdzc_Variation.FAVariCode = '00501' and Gy_department.deptName='" & Trim(!DeptName) & "' and Gdzc_Variation.year>=" & Val(LeftChar(Book_Total_Search.Com_Year(0).Text)) & " and " _
  538.                 & "gdzc_variation.period>=" & Val(RightChar(Book_Total_Search.Com_Year(0).Text)) & " and Gdzc_Variation.year<=" & Val(LeftChar(Book_Total_Search.Com_Year(1).Text)) & " and " _
  539.                 & "gdzc_variation.period<=" & Val(RightChar(Book_Total_Search.Com_Year(1).Text))
  540.             Set rstemp = Cw_DataEnvi.DataConnect.Execute(SqlStr1)
  541.             If Not rstemp.EOF Then
  542.                 If Val(rstemp!Depr & "") <> 0 Then CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Trim(rstemp!Depr & "")   '期间折旧
  543.             End If
  544.             rstemp.Close
  545.             Set rstemp = Nothing
  546.             SqlStr1 = "SELECT SUM(Gdzc_Total.FAValueEndM) AS FAValueEndM, " _
  547.                 & "SUM(Gdzc_Total.DeprSumEndM) AS DeprSumEndM, Gy_Department.DeptName " _
  548.                 & "FROM Gy_Department RIGHT OUTER JOIN Gdzc_Total ON Gy_Department.DeptCode = Gdzc_Total.DeptCode " _
  549.                 & "Where Gdzc_Total.Year =" & Val(Year) & " And Gdzc_Total.Period = " & Val(Period) & " and Gy_department.deptName='" & Trim(!DeptName) & "' GROUP BY Gy_Department.DeptName"
  550.         Else
  551.             SqlStr1 = "SELECT SUM(Gdzc_DetailedForm.DeprValue) AS DeprValue, Gdzc_Sort.FASortName FROM Gdzc_Sort INNER JOIN " _
  552.                 & "Gdzc_DetailedForm ON Gdzc_Sort.FASortCode = Gdzc_DetailedForm.FASortCode " _
  553.                 & "where Gdzc_Sort.FASortName='" & Trim(!FASortName & "") & "' and Gdzc_DetailedForm.year>=" & Val(LeftChar(Book_Total_Search.Com_Year(0).Text)) & " and " _
  554.                 & "Gdzc_DetailedForm.period>=" & Val(RightChar(Book_Total_Search.Com_Year(0).Text)) & " and Gdzc_DetailedForm.year<=" & Val(LeftChar(Book_Total_Search.Com_Year(1).Text)) & " and " _
  555.                 & "Gdzc_DetailedForm.period<=" & Val(RightChar(Book_Total_Search.Com_Year(1).Text)) _
  556.                 & "GROUP BY Gdzc_Sort.FASortName"
  557.             Set rstemp = Cw_DataEnvi.DataConnect.Execute(SqlStr1)
  558.             If Not rstemp.EOF Then
  559.                 If Val(rstemp!DeprValue & "") <> 0 Then CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Trim(rstemp!DeprValue & "") '期间折旧
  560.             End If
  561.             rstemp.Close
  562.             Set rstemp = Nothing
  563.             SqlStr1 = "SELECT SUM(Gdzc_Total.FAValueEndM) AS FAValueEndM,SUM(Gdzc_Total.DeprSumEndM) AS DeprSumEndM, Gdzc_Sort.FASortName " _
  564.                 & "FROM Gdzc_Sort RIGHT OUTER JOIN Gdzc_Total ON Gdzc_Sort.FASortCode = Gdzc_Total.FASortCode " _
  565.                 & "Where Gdzc_Total.Year =" & Val(Year) & " And Gdzc_Total.Period = " & Val(Period) & " and Gdzc_sort.FASortName='" & Trim(!FASortName) & "' " _
  566.                 & "GROUP BY Gdzc_Sort.FASortName"
  567.         End If
  568.         Set rstemp = Cw_DataEnvi.DataConnect.Execute(SqlStr1)
  569.         If Not rstemp.EOF Then
  570.             CxbbGrid.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls)) = Trim(rstemp.Fields("FAValueEndM") & "")                                 '资产原值
  571.             CxbbGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Trim(rstemp.Fields("DeprSumEndM") & "")                                 '累计折旧
  572.             CxbbGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = Trim(rstemp.Fields("FAValueEndM") & "")                                 '计提原值
  573.             CxbbGrid.TextMatrix(Jsqte, Sydz("009", GridStr(), Szzls)) = Trim(Val(Val(rstemp!FAvalueEndM) - Val(rstemp!DeprSumEndM)) & "")       '资产净值
  574.         End If
  575.         rstemp.Close
  576.         Set rstemp = Nothing
  577.         CxbbGrid.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls)) = Trim(!FAValueInM & "")                                                      '原值增加
  578.         CxbbGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = Trim(!FAValueOutM & "")                                                     '原值减少
  579.         CxbbGrid.RowHeight(Jsqte) = Sjhgd
  580.         .MoveNext
  581.         Jsqte = Jsqte + 1
  582.     Loop
  583.    
  584.     End With
  585.     
  586.     '为零时清空单元格
  587.     Call Txt_Clear
  588.     
  589. End Sub
  590. Private Sub bbyl(bbylte As Boolean)                    '报表打印预览
  591.     
  592.     Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
  593.     Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
  594.     Bbxbtgs = 1                                          '报 表 小 标 题 行 数
  595.     Bbbwhgs = 0                                          '报 表 表 尾 行 数
  596.     ReDim Bbxbt(1 To Bbxbtgs)
  597.     ReDim bbxbtzzxs(1 To Bbxbtgs)
  598.     
  599.     If Bbbwhgs <> 0 Then
  600.         ReDim Bbbwh(1 To Bbbwhgs)
  601.         ReDim Bbbwhzzxs(1 To Bbbwhgs)
  602.     End If
  603.     
  604.     Bbzbt = ReportTitle
  605.     Bbxbt(1) = " "
  606.     bbxbtzzxs(1) = 1                                     '报表行组织形式(0-居左 1-居中 2-居右)
  607.     
  608.     Bbxbt(1) = Trim(Trim(Label1.Caption) & Trim(Lbl_Year.Caption))
  609.     Call Scyxsjb(CxbbGrid)                               '生成报表数据
  610.     Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
  611.   
  612.     If Not bbylte Then
  613.         Unload DY_Tybbyldy
  614.     End If
  615. End Sub
  616. '*****************************************************
  617. '[>>自定义函数
  618. '取右字符串
  619. Function RightChar(str As String) As String
  620.     If str = "" Then Exit Function
  621.     
  622.     Dim i As Integer
  623.     
  624.     i = InStrRev(str, ".")
  625.     RightChar = Mid(str, i + 1)
  626.     
  627. End Function
  628. '取左字符串
  629. Function LeftChar(str As String) As String
  630.     If str = "" Then Exit Function
  631.     
  632.     Dim i As Integer
  633.     
  634.     i = InStr(str, ".")
  635.     LeftChar = Mid(str, 1, i - 1)
  636.     
  637. End Function
  638. '为零时清空单元格
  639. Function Txt_Clear()
  640.     Dim Row_Integer, Col_Integer As Integer         '行数和列数变量
  641.     
  642.     For Row_Integer = CxbbGrid.FixedRows To CxbbGrid.Rows - 1
  643.         For Col_Integer = 2 To CxbbGrid.Cols - 1
  644.             If Val(CxbbGrid.TextMatrix(Row_Integer, Col_Integer)) = 0 Then
  645.                 CxbbGrid.TextMatrix(Row_Integer, Col_Integer) = ""
  646.             End If
  647.         Next Col_Integer
  648.     Next Row_Integer
  649.     
  650. End Function
  651. '<<]
  652. '****************************************************