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

企业管理

开发平台:

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