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

企业管理

开发平台:

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 JZ_FrmTranList 
  5.    BackColor       =   &H00E9F4FA&
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "结转生产成本"
  8.    ClientHeight    =   6480
  9.    ClientLeft      =   675
  10.    ClientTop       =   720
  11.    ClientWidth     =   9225
  12.    Icon            =   "结转凭证_结转成本.frx":0000
  13.    KeyPreview      =   -1  'True
  14.    LinkTopic       =   "Form4"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   6480
  18.    ScaleWidth      =   9225
  19.    StartUpPosition =   2  '屏幕中心
  20.    Begin VB.PictureBox Pic_Title 
  21.       AutoRedraw      =   -1  'True
  22.       BackColor       =   &H00FFFFFF&
  23.       Height          =   1155
  24.       Left            =   0
  25.       Picture         =   "结转凭证_结转成本.frx":1042
  26.       ScaleHeight     =   1095
  27.       ScaleMode       =   0  'User
  28.       ScaleWidth      =   9264.57
  29.       TabIndex        =   6
  30.       Top             =   570
  31.       Width           =   9245
  32.       Begin VB.ComboBox Combo_KJQJ 
  33.          Height          =   300
  34.          Left            =   1620
  35.          Style           =   2  'Dropdown List
  36.          TabIndex        =   7
  37.          Top             =   750
  38.          Width           =   2025
  39.       End
  40.       Begin MSComctlLib.ImageList ImageList1 
  41.          Left            =   4800
  42.          Top             =   300
  43.          _ExtentX        =   1005
  44.          _ExtentY        =   1005
  45.          BackColor       =   -2147483643
  46.          ImageWidth      =   16
  47.          ImageHeight     =   16
  48.          MaskColor       =   12632256
  49.          _Version        =   393216
  50.          BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  51.             NumListImages   =   22
  52.             BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  53.                Picture         =   "结转凭证_结转成本.frx":35106
  54.                Key             =   "sz"
  55.             EndProperty
  56.             BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  57.                Picture         =   "结转凭证_结转成本.frx":354A0
  58.                Key             =   "dy"
  59.             EndProperty
  60.             BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  61.                Picture         =   "结转凭证_结转成本.frx":3583A
  62.                Key             =   "yl"
  63.             EndProperty
  64.             BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  65.                Picture         =   "结转凭证_结转成本.frx":35BD4
  66.                Key             =   "xg"
  67.             EndProperty
  68.             BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  69.                Picture         =   "结转凭证_结转成本.frx":35F6E
  70.                Key             =   "zh"
  71.             EndProperty
  72.             BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  73.                Picture         =   "结转凭证_结转成本.frx":36308
  74.                Key             =   "sh"
  75.             EndProperty
  76.             BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  77.                Picture         =   "结转凭证_结转成本.frx":366A2
  78.                Key             =   "bc"
  79.             EndProperty
  80.             BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  81.                Picture         =   "结转凭证_结转成本.frx":36A3C
  82.                Key             =   "fq"
  83.             EndProperty
  84.             BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  85.                Picture         =   "结转凭证_结转成本.frx":36DD6
  86.                Key             =   "bz"
  87.             EndProperty
  88.             BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  89.                Picture         =   "结转凭证_结转成本.frx":37170
  90.                Key             =   "tc"
  91.             EndProperty
  92.             BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  93.                Picture         =   "结转凭证_结转成本.frx":3750A
  94.                Key             =   "bcgs"
  95.             EndProperty
  96.             BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  97.                Picture         =   "结转凭证_结转成本.frx":378A4
  98.                Key             =   "mrlk"
  99.             EndProperty
  100.             BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  101.                Picture         =   "结转凭证_结转成本.frx":37C3E
  102.                Key             =   "xsxm"
  103.             EndProperty
  104.             BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  105.                Picture         =   "结转凭证_结转成本.frx":37FD8
  106.                Key             =   "first"
  107.             EndProperty
  108.             BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  109.                Picture         =   "结转凭证_结转成本.frx":38372
  110.                Key             =   "prev"
  111.             EndProperty
  112.             BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  113.                Picture         =   "结转凭证_结转成本.frx":3870C
  114.                Key             =   "next"
  115.             EndProperty
  116.             BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  117.                Picture         =   "结转凭证_结转成本.frx":38AA6
  118.                Key             =   "last"
  119.             EndProperty
  120.             BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  121.                Picture         =   "结转凭证_结转成本.frx":38E40
  122.                Key             =   "xx"
  123.             EndProperty
  124.             BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  125.                Picture         =   "结转凭证_结转成本.frx":391DA
  126.                Key             =   "define"
  127.             EndProperty
  128.             BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  129.                Picture         =   "结转凭证_结转成本.frx":39574
  130.                Key             =   "exec"
  131.             EndProperty
  132.             BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  133.                Picture         =   "结转凭证_结转成本.frx":3990E
  134.                Key             =   "xz"
  135.             EndProperty
  136.             BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  137.                Picture         =   "结转凭证_结转成本.frx":39CA8
  138.                Key             =   "sc"
  139.             EndProperty
  140.          EndProperty
  141.       End
  142.       Begin VB.Label tsLabel 
  143.          AutoSize        =   -1  'True
  144.          BackStyle       =   0  'Transparent
  145.          Caption         =   "会计期间:"
  146.          Height          =   180
  147.          Index           =   0
  148.          Left            =   720
  149.          TabIndex        =   13
  150.          Top             =   810
  151.          Width           =   810
  152.       End
  153.       Begin VB.Label Lab_Row 
  154.          Alignment       =   2  'Center
  155.          Appearance      =   0  'Flat
  156.          AutoSize        =   -1  'True
  157.          BackColor       =   &H80000005&
  158.          BackStyle       =   0  'Transparent
  159.          ForeColor       =   &H00FF0000&
  160.          Height          =   180
  161.          Left            =   8625
  162.          TabIndex        =   12
  163.          Top             =   810
  164.          Width           =   90
  165.       End
  166.       Begin VB.Label tsLabel 
  167.          AutoSize        =   -1  'True
  168.          BackStyle       =   0  'Transparent
  169.          Caption         =   "(第"
  170.          Height          =   180
  171.          Index           =   11
  172.          Left            =   8160
  173.          TabIndex        =   11
  174.          Top             =   810
  175.          Width           =   270
  176.       End
  177.       Begin VB.Label tsLabel 
  178.          AutoSize        =   -1  'True
  179.          BackStyle       =   0  'Transparent
  180.          Caption         =   "行)"
  181.          Height          =   180
  182.          Index           =   12
  183.          Left            =   8775
  184.          TabIndex        =   10
  185.          Top             =   810
  186.          Width           =   270
  187.       End
  188.       Begin VB.Label tsLabel 
  189.          AutoSize        =   -1  'True
  190.          BackStyle       =   0  'Transparent
  191.          Caption         =   "当前记录"
  192.          Height          =   180
  193.          Index           =   13
  194.          Left            =   7350
  195.          TabIndex        =   9
  196.          Top             =   810
  197.          Width           =   720
  198.       End
  199.       Begin VB.Label tsLabel 
  200.          AutoSize        =   -1  'True
  201.          BackColor       =   &H80000018&
  202.          BackStyle       =   0  'Transparent
  203.          Caption         =   "结转生产成本"
  204.          BeginProperty Font 
  205.             Name            =   "宋体"
  206.             Size            =   12
  207.             Charset         =   134
  208.             Weight          =   700
  209.             Underline       =   0   'False
  210.             Italic          =   0   'False
  211.             Strikethrough   =   0   'False
  212.          EndProperty
  213.          ForeColor       =   &H00000000&
  214.          Height          =   240
  215.          Index           =   6
  216.          Left            =   360
  217.          TabIndex        =   8
  218.          Top             =   240
  219.          Width           =   1530
  220.       End
  221.    End
  222.    Begin VB.CommandButton Ydcommand 
  223.       Height          =   300
  224.       Left            =   5190
  225.       Picture         =   "结转凭证_结转成本.frx":3A042
  226.       Style           =   1  'Graphical
  227.       TabIndex        =   5
  228.       Top             =   150
  229.       Visible         =   0   'False
  230.       Width           =   300
  231.    End
  232.    Begin VB.Timer Timer1 
  233.       Interval        =   1
  234.       Left            =   7320
  235.       Top             =   960
  236.    End
  237.    Begin VB.ComboBox YdCombo 
  238.       Height          =   300
  239.       Left            =   8148
  240.       Style           =   2  'Dropdown List
  241.       TabIndex        =   4
  242.       Top             =   983
  243.       Visible         =   0   'False
  244.       Width           =   1149
  245.    End
  246.    Begin VB.TextBox Ydtext 
  247.       BackColor       =   &H00C0FFFF&
  248.       BorderStyle     =   0  'None
  249.       Height          =   338
  250.       Left            =   9640
  251.       MultiLine       =   -1  'True
  252.       TabIndex        =   3
  253.       Top             =   615
  254.       Visible         =   0   'False
  255.       Width           =   1179
  256.    End
  257.    Begin VSFlex8Ctl.VSFlexGrid WglrGrid 
  258.       Height          =   4695
  259.       Left            =   0
  260.       TabIndex        =   2
  261.       Top             =   1770
  262.       Width           =   9225
  263.       _cx             =   5080
  264.       _cy             =   5080
  265.       Appearance      =   1
  266.       BorderStyle     =   1
  267.       Enabled         =   -1  'True
  268.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  269.          Name            =   "宋体"
  270.          Size            =   9
  271.          Charset         =   134
  272.          Weight          =   400
  273.          Underline       =   0   'False
  274.          Italic          =   0   'False
  275.          Strikethrough   =   0   'False
  276.       EndProperty
  277.       MousePointer    =   0
  278.       BackColor       =   -2147483643
  279.       ForeColor       =   -2147483640
  280.       BackColorFixed  =   -2147483633
  281.       ForeColorFixed  =   -2147483630
  282.       BackColorSel    =   -2147483635
  283.       ForeColorSel    =   -2147483634
  284.       BackColorBkg    =   -2147483632
  285.       BackColorAlternate=   -2147483643
  286.       GridColor       =   -2147483633
  287.       GridColorFixed  =   -2147483632
  288.       TreeColor       =   -2147483632
  289.       FloodColor      =   192
  290.       SheetBorder     =   -2147483642
  291.       FocusRect       =   1
  292.       HighLight       =   1
  293.       AllowSelection  =   -1  'True
  294.       AllowBigSelection=   -1  'True
  295.       AllowUserResizing=   0
  296.       SelectionMode   =   0
  297.       GridLines       =   1
  298.       GridLinesFixed  =   2
  299.       GridLineWidth   =   1
  300.       Rows            =   5000
  301.       Cols            =   10
  302.       FixedRows       =   1
  303.       FixedCols       =   0
  304.       RowHeightMin    =   0
  305.       RowHeightMax    =   0
  306.       ColWidthMin     =   0
  307.       ColWidthMax     =   0
  308.       ExtendLastCol   =   0   'False
  309.       FormatString    =   ""
  310.       ScrollTrack     =   0   'False
  311.       ScrollBars      =   3
  312.       ScrollTips      =   0   'False
  313.       MergeCells      =   0
  314.       MergeCompare    =   0
  315.       AutoResize      =   -1  'True
  316.       AutoSizeMode    =   0
  317.       AutoSearch      =   0
  318.       AutoSearchDelay =   2
  319.       MultiTotals     =   -1  'True
  320.       SubtotalPosition=   1
  321.       OutlineBar      =   0
  322.       OutlineCol      =   0
  323.       Ellipsis        =   0
  324.       ExplorerBar     =   0
  325.       PicturesOver    =   0   'False
  326.       FillStyle       =   0
  327.       RightToLeft     =   0   'False
  328.       PictureType     =   0
  329.       TabBehavior     =   0
  330.       OwnerDraw       =   0
  331.       Editable        =   0
  332.       ShowComboButton =   1
  333.       WordWrap        =   0   'False
  334.       TextStyle       =   0
  335.       TextStyleFixed  =   0
  336.       OleDragMode     =   0
  337.       OleDropMode     =   0
  338.       DataMode        =   0
  339.       VirtualData     =   -1  'True
  340.       DataMember      =   ""
  341.       ComboSearch     =   3
  342.       AutoSizeMouse   =   -1  'True
  343.       FrozenRows      =   0
  344.       FrozenCols      =   0
  345.       AllowUserFreezing=   0
  346.       BackColorFrozen =   0
  347.       ForeColorFrozen =   0
  348.       WallPaperAlignment=   9
  349.       AccessibleName  =   ""
  350.       AccessibleDescription=   ""
  351.       AccessibleValue =   ""
  352.       AccessibleRole  =   24
  353.    End
  354.    Begin MSComctlLib.Toolbar Tlb_Action 
  355.       Align           =   1  'Align Top
  356.       Height          =   555
  357.       Left            =   0
  358.       TabIndex        =   14
  359.       Top             =   0
  360.       Width           =   9225
  361.       _ExtentX        =   16272
  362.       _ExtentY        =   979
  363.       ButtonWidth     =   820
  364.       ButtonHeight    =   926
  365.       AllowCustomize  =   0   'False
  366.       Appearance      =   1
  367.       Style           =   1
  368.       ImageList       =   "ImageList1"
  369.       _Version        =   393216
  370.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  371.          NumButtons      =   9
  372.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  373.             Caption         =   "设置"
  374.             Key             =   "ymsz"
  375.             ImageKey        =   "sz"
  376.             BeginProperty ButtonMenus {66833FEC-8583-11D1-B16A-00C0F0283628} 
  377.                NumButtonMenus  =   1
  378.                BeginProperty ButtonMenu1 {66833FEE-8583-11D1-B16A-00C0F0283628} 
  379.                EndProperty
  380.             EndProperty
  381.          EndProperty
  382.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  383.             Caption         =   "打印"
  384.             Key             =   "dy"
  385.             ImageKey        =   "dy"
  386.          EndProperty
  387.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  388.             Caption         =   "预览"
  389.             Key             =   "yl"
  390.             ImageKey        =   "yl"
  391.          EndProperty
  392.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  393.             Style           =   3
  394.          EndProperty
  395.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  396.             Enabled         =   0   'False
  397.             Object.Visible         =   0   'False
  398.             Caption         =   "定义"
  399.             Key             =   "define"
  400.             ImageKey        =   "define"
  401.          EndProperty
  402.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  403.             Caption         =   "结转"
  404.             Key             =   "run"
  405.             ImageKey        =   "exec"
  406.          EndProperty
  407.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  408.             Style           =   3
  409.          EndProperty
  410.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  411.             Caption         =   "帮助"
  412.             Key             =   "bz"
  413.             ImageKey        =   "bz"
  414.          EndProperty
  415.          BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  416.             Caption         =   "退出"
  417.             Key             =   "fh"
  418.             ImageKey        =   "tc"
  419.          EndProperty
  420.       EndProperty
  421.       BorderStyle     =   1
  422.       Begin MSComctlLib.Toolbar GsToolbar 
  423.          Height          =   525
  424.          Left            =   6600
  425.          TabIndex        =   15
  426.          Top             =   0
  427.          Width           =   2595
  428.          _ExtentX        =   4577
  429.          _ExtentY        =   926
  430.          ButtonWidth     =   1455
  431.          ButtonHeight    =   926
  432.          AllowCustomize  =   0   'False
  433.          Appearance      =   1
  434.          Style           =   1
  435.          ImageList       =   "ImageList1"
  436.          _Version        =   393216
  437.          BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  438.             NumButtons      =   3
  439.             BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  440.                Caption         =   "保存格式"
  441.                Key             =   "bcgs"
  442.                ImageKey        =   "bcgs"
  443.             EndProperty
  444.             BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  445.                Caption         =   "默认列宽"
  446.                Key             =   "hfmrgs"
  447.                ImageKey        =   "mrlk"
  448.             EndProperty
  449.             BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  450.                Caption         =   "显示项目"
  451.                Key             =   "szxsxm"
  452.                ImageKey        =   "xsxm"
  453.             EndProperty
  454.          EndProperty
  455.       End
  456.    End
  457.    Begin VB.Label Lab_Pzclzt 
  458.       BackColor       =   &H0000FFFF&
  459.       Caption         =   "2"
  460.       ForeColor       =   &H00808080&
  461.       Height          =   322
  462.       Left            =   9012
  463.       TabIndex        =   1
  464.       Top             =   553
  465.       Visible         =   0   'False
  466.       Width           =   403
  467.    End
  468.    Begin VB.Label Lab_OperStatus 
  469.       BackColor       =   &H000080FF&
  470.       Caption         =   "1"
  471.       Height          =   353
  472.       Left            =   8684
  473.       TabIndex        =   0
  474.       Top             =   553
  475.       Visible         =   0   'False
  476.       Width           =   343
  477.    End
  478.    Begin VB.Line Line1 
  479.       BorderColor     =   &H000000FF&
  480.       Index           =   0
  481.       X1              =   4234
  482.       X2              =   7211
  483.       Y1              =   1108
  484.       Y2              =   1108
  485.    End
  486.    Begin VB.Line Line1 
  487.       BorderColor     =   &H000000FF&
  488.       Index           =   1
  489.       X1              =   4234
  490.       X2              =   7211
  491.       Y1              =   1153
  492.       Y2              =   1153
  493.    End
  494. End
  495. Attribute VB_Name = "JZ_FrmTranList"
  496. Attribute VB_GlobalNameSpace = False
  497. Attribute VB_Creatable = False
  498. Attribute VB_PredeclaredId = True
  499. Attribute VB_Exposed = False
  500. '*********************************************************************************************************
  501. '*    模 块 名 称 :结转凭证
  502. '*    功 能 描 述 :结转凭证
  503. '*    程序员姓名  :xjl
  504. '*    最后修改人  :xjl
  505. '*    最后修改时间:2002/1/22
  506. '*    备        注:程序中所有依实际情况自定义部分均用[>>  <<]括起
  507. '*********************************************************************************************************
  508.  
  509. '[以下为根据实际情况设置变量
  510. Dim Rec_AutoTranItem As New ADODB.Recordset     '转帐项目动态集
  511. Dim jsqte  As Long                              '临时计数器
  512. Dim SqlStr As String                            '临时的SQL字符串
  513. Dim RecTemp As New ADODB.Recordset              '临时使用动态集
  514. Dim Combo_CostCellCode() As String              '成本中心COMBO
  515. Dim IsShowBill As Boolean
  516. Public PrivateMm As Integer
  517. Public PrivateYear As Integer
  518. Dim Tranjsq As Integer
  519. Dim TranNum() As String
  520. Dim OperationNum As Integer
  521. Public TranClassCode As String
  522. Public Object As String
  523. Dim Str_RightEdit As String                     '编辑权限索引
  524. Dim Bln_DeleteFlag As Boolean                   '转帐后是否删除临时表
  525. ']
  526.  
  527. '以下为固定使用变量(网格)
  528. Dim Cxnrrec As New ADODB.Recordset              '显示查询内容动态集
  529. Dim Dyymctbl As New DY_Dyymsz                   '打印页面窗体变量
  530. Dim GridCode As String                          '显示网格网格代码
  531. Dim GridInf() As Variant                        '整个网格设置信息
  532. Dim ReportTitle As String                       '报表主标题
  533. Dim Tsxx As String                              '系统提示信息
  534. Dim Pmbcsjhs As Long                            '屏幕网格保持数据行数(大于等于1)
  535. Dim Fzxwghs As Integer                          '辅助项网格行数(包括合计行)
  536. Dim Sfxshjwg As Boolean                         '是否显示合计网格
  537. Dim Qslz As Long                                '网格隐藏(非操作显示)列数
  538. Dim Sjhgd As Double                             '网格数据行高度
  539. Dim GridBoolean() As Boolean                    '网格列信息(布尔型)
  540. Dim GridStr()  As String                        '网格列信息(字符型)
  541. Dim GridInt() As Integer                        '网格列信息(整型)
  542. Dim Sfblbzkd As Boolean                         '是否保留帮助宽度(字段提供帮助时,是否为按钮保留空间)
  543. Dim Dqlrwgh As Long                             '当前录入数据网格行
  544. Dim Dqlrwgl As Long                             '当前录入数据网格列
  545. Dim Dqlkwgh As Long                             '刚刚离开网格行(不一定为录入行)
  546. Dim Dqlkwgl As Long                             '刚刚离开网格列
  547. Dim Dqtoprow As Long                            '当前录入状态时最上端可视行
  548. Dim Dqleftcol As Long                           '当前录入状态时最左端可视列
  549. Dim Zdlrqnr As String                           '字段录入修改前内容(用来判断内容是否修改)
  550. Dim Wbkbhlock As Boolean                        '文本框改变值锁
  551. Dim Changelock As Boolean                       '网格行列改变控制锁(用来区别用户改变.程序改变)
  552. Dim Gdtlock As Boolean                          '滚动条滚动控制(用来区别用户改变.程序改变)
  553. Dim Yxxpdlock As Boolean                        '字段有效性判断锁(内容不修改不需进行字段有效性判断)
  554. Dim Hyxxpdlock As Boolean                       '行有效性判断锁(字段内容不修改不需进行行有效性判断)
  555. Dim Valilock As Boolean                         '文本框失去焦点是否进行有效性控制(TRUE 为锁定*限用网格录入)
  556. Dim Shsfts As Boolean                           '删除记录行是否提示
  557. Dim Szzls As Integer                            '网格信息数组最大下标值(网格列数-1)
  558. Private Sub Combo_KJQJ_Click()                      '选择会计期间
  559.     PrivateYear = Mid(Trim(CStr(Combo_KJQJ.List(Combo_KJQJ.ListIndex))), 1, 4)
  560.     PrivateMm = Right(Trim(CStr(Combo_KJQJ.List(Combo_KJQJ.ListIndex))), 2)
  561.     Lab_OperStatus.Caption = "1"
  562.     If IsShowBill = False Then
  563.         Exit Sub
  564.     End If
  565.     '显示数据
  566.     Call Sub_Query
  567. End Sub
  568. Private Sub Form_KeyPress(KeyAscii As Integer)       '控制焦点转移
  569.     Dim jdzygs As Integer
  570.     jdzygs = 3
  571.     Select Case KeyAscii
  572.         Case vbKeyReturn
  573.             If Kjjdzy(jdzygs) Then
  574.             KeyAscii = 0
  575.             End If
  576.         Case 39           '屏蔽字符"'"
  577.             KeyAscii = 0
  578.     End Select
  579. End Sub
  580. Private Sub Form_Load()                              '窗体装入
  581.     
  582.     '初始化各种锁值
  583.     Changelock = False             '网格行列改变控制锁
  584.     Gdtlock = False                '滚动条滚动控制
  585.     Yxxpdlock = True               '字段有效性判断锁
  586.     Hyxxpdlock = True              '行有效性判断锁
  587.     Wbkbhlock = False              '文本框内容改变锁
  588.     IsShowBill = False             '显示查询信息控制
  589.     PrivateYear = Xtyear           '会计年度
  590.     PrivateMm = Xtmm               '会计期间
  591.     
  592.     '报表主标题及报表编码
  593.     If TranClassCode = "01" Then
  594.         ReportTitle = "结转生产成本"
  595.         Str_RightEdit = "CB_CostCarryForward_Edit"
  596.     Else
  597.         ReportTitle = "结转产成品"
  598.         Str_RightEdit = "CB_CostManuFactured_Edit"
  599.     End If
  600.     XtReportCode = "CB_CostCarryForward"
  601.     Load Dyymctbl
  602.     
  603.     '调 入 网 格
  604.     GridCode = "CB_CostCarryForward"          '网格属性编码
  605.     Call BzWgcsh(WglrGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
  606.     
  607.     Qslz = GridInf(1)
  608.     Sjhgd = GridInf(2)
  609.     Pmbcsjhs = GridInf(3)
  610.     Fzxwghs = GridInf(4)
  611.     Sfblbzkd = GridInf(5)
  612.     Shsfts = GridInf(6)
  613.     Sfxshjwg = GridInf(7)
  614.     Szzls = WglrGrid.Cols - 1
  615.     For jsqte = WglrGrid.FixedRows To WglrGrid.Rows - 1
  616.         WglrGrid.RowHeight(jsqte) = Sjhgd
  617.     Next jsqte
  618.                 
  619.     '填充会计期间列表框(年度默认为用户选择年度)
  620.     Call Sub_FillPeriod(Combo_KJQJ, PrivateYear, PrivateMm)
  621.     
  622.     '判断是否为空
  623.     SqlStr = "Select Count(*) From Cb_CostObject"
  624.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  625.     If RecTemp.Fields(0) <= 0 Then
  626.         Call Sub_OperStatus("10")
  627.     End If
  628.     
  629.     '填充网格
  630.     Call Sub_Query
  631.     
  632.     '设置操作状态为浏览
  633.     Lab_OperStatus.Caption = "1"
  634.     IsShowBill = True
  635. End Sub
  636. Private Sub Form_Unload(Cancel As Integer)           '窗体卸载
  637.     '卸载打印页面窗体
  638.     Unload Dyymctbl
  639.     Set Rec_AutoTranItem = Nothing
  640.     Set RecTemp = Nothing
  641. End Sub
  642. Private Sub Sub_Query()                              '根据当前单据号显示整张单据内容
  643.     '禁止网格刷新动作,为加快网格显示速度(Fixed)
  644.     WglrGrid.Redraw = False
  645.     SqlStr = "Select A.Objectcode,ObjectName,UnitName,Quantity,ThmonCost,TranEngSign,TranEngSign1 From Cb_ObjectComplete A " _
  646.                 & "Left Outer Join (Select ObjectCode,ObjectName,UnitName From Cb_CostObject A " _
  647.                 & "Left Outer Join Gy_UnitSet B On A.MeasureUnitCode=B.UnitCode) B On A.ObjectCode=B.ObjectCode " _
  648.                 & "Where Year='" + CStr(PrivateYear) + "' And Period='" + CStr(PrivateMm) + "'"
  649.                 
  650.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  651.     With RecTemp
  652.         WglrGrid.Rows = WglrGrid.FixedRows
  653.      
  654.         If .EOF Then
  655.             WglrGrid.Redraw = True
  656.             Exit Sub
  657.         End If
  658.      
  659.         jsqte = WglrGrid.FixedRows
  660.         Do While Not .EOF
  661.             WglrGrid.AddItem ""
  662.             '[>>显示
  663.             WglrGrid.TextMatrix(jsqte, 0) = "*"                                                                 '行标识
  664.             WglrGrid.TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = Trim(.Fields("Objectcode"))             '对象编码
  665.             WglrGrid.TextMatrix(jsqte, Sydz("003", GridStr(), Szzls)) = Trim(.Fields("ObjectName") & "")        '对象名称
  666.             WglrGrid.TextMatrix(jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("UnitName") & "")          '计量单位
  667.             WglrGrid.TextMatrix(jsqte, Sydz("005", GridStr(), Szzls)) = Trim(.Fields("Quantity") & "")          '数量
  668.             WglrGrid.TextMatrix(jsqte, Sydz("006", GridStr(), Szzls)) = Trim(.Fields("ThmonCost") & "")         '实际成本
  669.             If TranClassCode = "01" Then
  670.                 If Trim(.Fields("TranEngSign") & "") = "" Or Trim(.Fields("TranEngSign") & "") = False Then
  671.                     WglrGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = False                           '结转标志(生产成本)
  672.                 Else
  673.                     WglrGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = True                            '结转标志(生产成本)
  674.                 End If
  675.             Else
  676.                 If Trim(.Fields("TranEngSign1") & "") = "" Or Trim(.Fields("TranEngSign1") & "") = False Then
  677.                     WglrGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = False                           '结转标志(产成品)
  678.                 Else
  679.                     WglrGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = True                            '结转标志(产成品)
  680.                 End If
  681.             End If
  682.             '<<]
  683.             WglrGrid.RowHeight(jsqte) = Sjhgd
  684.             .MoveNext
  685.             jsqte = jsqte + 1
  686.         Loop
  687.     End With
  688.     
  689.     '将网格刷新解禁(Fixed)
  690.     WglrGrid.Redraw = True
  691.     
  692. End Sub
  693. Private Sub Tlb_Action_ButtonClick(ByVal Button As MSComctlLib.Button)             '用户点击工具条
  694.      
  695.     '屏蔽文本框,下拉组合框有效性判断,即在网格单元内录入数据时,点帮助信息等,不执行文本框等验证,即不执行YdText或YdCombo的LostFocus事件.
  696.     Valilock = True
  697.     
  698.     '屏蔽网格失去焦点产生的有效性判断
  699.     Changelock = True
  700.     Select Case Button.Key
  701.         Case "ymsz"                                          '页面设置
  702.             Dyymctbl.Show 1
  703.         Case "yl"                                            '预 览
  704.              Call bbyl(True)
  705.         Case "dy"                                            '打 印
  706.              Call bbyl(False)
  707.         Case "define"                                        '定 义
  708.             
  709.         Case "run"                                           '结 转
  710.             
  711.             '判断用户是否有此功能执行权限,如有则写上机日志(进入)
  712.             If Not Security_Log(Str_RightEdit, Xtczybm, 1, True) Then
  713.                 Exit Sub
  714.             End If
  715.         
  716.             Select Case TranClassCode
  717.             Case "01"
  718.                 Call Run1       '结转生产成本
  719.             Case "02"
  720.                 Call Run2       '结转产成品
  721.             End Select
  722.             
  723.         Case "bz"                                            '帮 助
  724.             Call F1bz
  725.         Case "fh"                                            '退 出
  726.             Unload Me
  727.     End Select
  728.     '解 锁
  729.     Valilock = False
  730.     Changelock = False
  731. End Sub
  732. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)                     '支持热键操作,更确切地讲,是工具栏热键
  733.     If Shift = 2 Then   'Ctrl的位屏蔽值=2
  734.         Select Case UCase(Chr(KeyCode))
  735.             Case "P"                   'Ctrl+P 打印
  736.                 If Tlb_Action.Buttons("dy").Enabled Then Call bbyl(False)
  737.         End Select
  738.     End If
  739. End Sub
  740. Private Sub xswbk()                       '在当前选中单元显示文本框,列表框,帮助按钮(通用)
  741.     Dim Wbkpy As Integer, Wbkpy1 As Integer '文本框偏移量
  742.     
  743.     '如果单据操作状态为浏览状态则不能显示录入载体
  744.     If Trim(Lab_OperStatus.Caption) = "1" Then Exit Sub
  745.     
  746.     '显示文本框前返回有效行列(解决滚动条问题)
  747.     Call Xldqh
  748.     Call Xldql
  749.     
  750.     '隐藏文本框,帮助按钮,列表组合框
  751.     Call Ycwbk
  752.     
  753.     With WglrGrid
  754.         Dqlrwgh = .Row
  755.         Dqlrwgl = .Col
  756.         If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then Exit Sub
  757.         Wbkpy = 30
  758.         Wbkpy1 = 15
  759.         If GridBoolean(.Col, 3) Then        '若是下拉列表录入
  760.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  761.             YdCombo.Top = .CellTop + .Top + Wbkpy
  762.             YdCombo.Width = .CellWidth - Wbkpy1
  763.             Call Wbkcl                          '主要是在下拉列表框可用之前填充下拉列表框
  764.             YdCombo.Visible = True
  765.             YdCombo.SetFocus
  766.             Ydcommand.Visible = False
  767.             Ydtext.Visible = False
  768.         Else
  769.             If GridBoolean(.Col, 2) Then        '是否提供帮助
  770.                 Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  771.                 Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  772.                 Ydcommand.Visible = True
  773.             Else
  774.                 Ydcommand.Visible = False
  775.             End If
  776.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  777.             Ydtext.Top = .CellTop + .Top + Wbkpy
  778.             If Ydcommand.Visible Then
  779.                 If Sfblbzkd Then
  780.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  781.                 Else
  782.                     Ydtext.Width = .CellWidth - Wbkpy1
  783.                 End If
  784.             Else
  785.                 Ydtext.Width = .CellWidth - Wbkpy1
  786.             End If
  787.             Ydtext.Height = .CellHeight - Wbkpy1
  788.             If GridInt(.Col, 2) <> 0 Then
  789.                 Ydtext.MaxLength = GridInt(.Col, 2)
  790.             Else
  791.                 Ydtext.MaxLength = 3000
  792.             End If
  793.             ' 主要是Zdlrqnr = Trim(.Text)即将网格单元的内容赋予文本框,并且记录网格编辑之前的内容
  794.             '为是否对该单元的内容进行字段有效判断加锁Yxxpdlock = False
  795.             Call Wbkcl
  796.             Ydtext.Visible = True
  797.             Ydtext.SetFocus
  798.         End If
  799.         Dqtoprow = .TopRow
  800.         Dqleftcol = .LeftCol
  801.         
  802.         '重置锁值
  803.         Valilock = False
  804.         Wbkbhlock = False
  805.     End With
  806. End Sub
  807. Private Sub Lrsjhx()                                                   '文本框录入数据回写
  808.     With WglrGrid
  809.         If YdCombo.Visible Then .Text = Trim(YdCombo.Text)
  810.         If Ydtext.Visible Then .Text = Trim(Ydtext.Text)
  811.         
  812.         '(如果字段录入内容发生变化,则打开有效性判断锁)
  813.         If Zdlrqnr <> Trim(.Text) Then
  814.             Yxxpdlock = False
  815.             Hyxxpdlock = False
  816.         End If
  817.         '如果字段录入内容不为空则写数据行有效性标志
  818.         If Len(Trim(.Text)) <> 0 Then
  819.             Call Xyxhbz(.Row)
  820.         End If
  821.         '隐藏文本框,帮助按钮,列表组合框
  822.         Call Ycwbk
  823.     End With
  824. End Sub
  825. Private Sub Wbkcl()                                                 '文本框录入之前处理(根据实际情况)
  826.     Dim xswbrr As String
  827.     With WglrGrid
  828.         Zdlrqnr = Trim(.Text)
  829.         xswbrr = Trim(.Text)
  830.         If GridBoolean(.Col, 3) Then   '列表框录入
  831.             
  832.             '填充列表框程序
  833.             Call FillCombo(YdCombo, GridStr(.Col, 5), xswbrr, 0)
  834.         Else
  835.             Wbkbhlock = True
  836.             
  837.             '====以下为用户自定义
  838.             Ydtext.Text = xswbrr
  839.             '====以上为用户自定义
  840.             
  841.             Wbkbhlock = False
  842.             Ydtext.SelStart = Len(Ydtext.Text)
  843.         End If
  844.     End With
  845. End Sub
  846. Private Function sjzdyxxpd(Dqpdwgh As Long, Dqpdwgl As Long)        '录入数据字段有效性判断,同时进行字段录入事后处理
  847.     Dim Str_JudgeText As String  '临时有效性判断字段内容
  848.     Dim Coljsq As Long           '临时列计数器
  849.     With WglrGrid
  850.         '非录入状态有效性为合法
  851.         If Yxxpdlock Or .Row < .FixedRows Then
  852.             sjzdyxxpd = True
  853.             Exit Function
  854.         End If
  855.         Str_JudgeText = Trim(.TextMatrix(Dqpdwgh, Dqpdwgl))
  856.     End With
  857.     
  858.     Select Case GridStr(Dqpdwgl, 1)
  859.         '以下为自定义部分[
  860.         '以上为自定义部分]
  861.     End Select
  862.     
  863.      '根据转帐性质,判断按转帐科目号取项目大类还是按来源科目取项目大类
  864.     '字段录入正确后为零字段清空
  865.     Call Qkwlzd(Dqpdwgh, Dqpdwgl)
  866.     sjzdyxxpd = True
  867.     Yxxpdlock = True
  868.     Exit Function
  869. Lrcwcl:    '录入错误处理
  870.     With WglrGrid
  871.         Call Xtxxts(Tsxx, 0, 1)
  872.         Changelock = True
  873.         .Select Dqpdwgh, Dqpdwgl
  874.         If GridBoolean(.Col, 1) = True Then
  875.             Changelock = False
  876.             Call xswbk
  877.             sjzdyxxpd = False
  878.         End If
  879.     End With
  880.     Exit Function
  881. End Function
  882. Private Function Sjhzyxxpd(ByVal Yxxpdh As Long) As Boolean                  '录入数据行有效性判断,同时进行行处理
  883.     Dim Lrywlz As Long
  884.     Dim RecTemp As New ADODB.Recordset     '临时使用动态集
  885.     Dim Bln_AssVali As Boolean             '辅助核算错误
  886.     Dim Bj As Boolean                       '辅助项有效性标志
  887.     Dim Rowjsq As Long
  888.     With WglrGrid
  889.     
  890.         '判断行是否为空和无效数据行清除
  891.         If Yxxpdh > (.Rows - .FixedRows) Then Exit Function
  892.         If .TextMatrix(Yxxpdh, 0) <> "*" Then
  893.             Sjhzyxxpd = True
  894.             Exit Function
  895.         Else
  896.             If pdhwk(Yxxpdh) And Yxxpdh + 1 <= .Rows - 1 Then
  897.                 If .TextMatrix(Yxxpdh + 1, 0) <> "*" Then
  898.                     Changelock = True
  899.                     .RemoveItem Yxxpdh
  900.                     If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
  901.                     .AddItem ""
  902.                     .RowHeight(.Rows - 1) = Sjhgd
  903.                     End If
  904.                     Changelock = False
  905.                     Sjhzyxxpd = True
  906.                     Exit Function
  907.                 End If
  908.             End If
  909.         End If
  910.         
  911.         '行没有发生变化则不进行有效性判断
  912.         If Hyxxpdlock Then
  913.             Sjhzyxxpd = True
  914.             Exit Function
  915.         End If
  916.   
  917.         '以下为自定义部分[
  918.         '1.放置行有效性判断程序
  919.         '首先进行为空判断(固定不变)
  920.         For jsqte = Qslz To .Cols - 1
  921.             If (GridInt(jsqte, 5) = 1 And Len(Trim(.TextMatrix(Yxxpdh, jsqte))) = 0) Or (GridInt(jsqte, 5) = 2 And Val(Trim(.TextMatrix(Yxxpdh, jsqte))) = 0) Then
  922.                 Tsxx = GridStr(jsqte, 2)
  923.                 Lrywlz = jsqte
  924.                 GoTo Lrcwcl
  925.                 Exit For
  926.             End If
  927.         Next jsqte
  928.                 
  929.         '2.放置行处理程序
  930.       
  931.         '以上为自定义部分]
  932.     End With
  933.     Sjhzyxxpd = True
  934.     Hyxxpdlock = True
  935.     Exit Function
  936. Lrcwcl:      '录入错误处理
  937.     With WglrGrid
  938.         Call Xtxxts(Tsxx, 0, 1)
  939.         
  940.         Changelock = True
  941.         .Select Yxxpdh, Lrywlz
  942.         Changelock = False
  943.         Sjhzyxxpd = False
  944.         Exit Function
  945.     End With
  946. End Function
  947. Private Function Fun_AllowEdit() As Boolean                      '判断当前定义是否允许编辑或删除
  948.     Fun_AllowEdit = True
  949. End Function
  950. '===================以 下 程 序 为 通 用 部 分 ,一 般 不 需 更 改======================='
  951. Private Sub Lrzdbz()                                             '录入字段帮助
  952.     If Not Ydcommand.Visible Then
  953.         Exit Sub
  954.     End If
  955.     Valilock = True         '为防止按ydText中帮助按纽时,引起ydText的LostFocus事件。
  956.     With WglrGrid
  957.         '[>>会计科目编码帮助单独处理
  958.         Select Case .Col
  959.             Case Sydz("002", GridStr(), Szzls), Sydz("006", GridStr(), Szzls)
  960.                 Xtcdcs = Trim(Ydtext.Text)
  961.                 PZ_FrmKjkmcz.Show 1
  962.                 If Len(Xtfhcs) <> 0 Then
  963.                     Ydtext.Text = Xtfhcs
  964.                 End If
  965.             Case Sydz("010", GridStr(), Szzls)
  966.                 AutoTran_AssMy.Show 1
  967.             Case Else
  968.                 '处理通用部分
  969.                 Changelock = True        '调入另外窗体必须加锁,为不必执行网格的离开焦点造成的RowColChange事件
  970.                                         '?没有必要,因为,文本框和命令按纽之间转换焦点,不会执行RowColChange
  971.                 Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(Combo_CostCellCode(Combo_CostCell.ListIndex)))
  972.                 Changelock = False
  973.                 If Len(Xtfhcs) <> 0 Then
  974.                     If GridInt(.Col, 7) = 0 Then
  975.                         Ydtext.Text = Xtfhcs
  976.                     Else
  977.                         Ydtext.Text = Xtfhcsfz
  978.                     End If
  979.                 End If
  980.         End Select
  981.         '[>>处理完毕
  982.         Valilock = False
  983.         If Ydtext.Visible Then
  984.             Ydtext.SetFocus
  985.         End If
  986.     End With
  987. End Sub
  988. Private Sub Form_Resize()                                        '窗体大小发生变化时,重新显示文本框
  989.     Call Cxxswbk
  990. End Sub
  991. Private Function Fun_Drfrmyxxpd() As Boolean                     '调入其它窗体或功能产生的有效性判断(包括数据回写)
  992.     '因为点工具栏的按纽时文本框或网格均没有失去焦点事件发生,为保证该操作之前进行录入数据的有效性判断而设。
  993.     Fun_Drfrmyxxpd = True
  994.     With WglrGrid
  995.         '如果当前网格处于编辑状态,则先进行数据回写再进行有效性判断
  996.         If Ydtext.Visible Or YdCombo.Visible Then
  997.             Call Lrsjhx
  998.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  999.                 Fun_Drfrmyxxpd = False
  1000.                 Exit Function
  1001.             End If
  1002.         End If
  1003.         '进行行有效性判断
  1004.         If Not Sjhzyxxpd(.Row) Then
  1005.             Fun_Drfrmyxxpd = False
  1006.             Exit Function
  1007.         End If
  1008.     End With
  1009. End Function
  1010. Private Sub WglrGrid_DblClick()
  1011.     With WglrGrid
  1012.         If .Row < .FixedRows Then
  1013.             Exit Sub
  1014.         End If
  1015.         If GridStr(.Col, 1) <> "001" Then
  1016.             Exit Sub
  1017.         Else
  1018.             If .TextMatrix(.Row, Sydz("001", GridStr(), Szzls)) = "√" Then
  1019.                 .TextMatrix(.Row, Sydz("001", GridStr(), Szzls)) = ""
  1020.             Else
  1021.                 .TextMatrix(.Row, Sydz("001", GridStr(), Szzls)) = "√"
  1022.             End If
  1023.         End If
  1024.     End With
  1025. End Sub
  1026. Private Sub WglrGrid_EnterCell()                                   '显示当前数据行相关信息
  1027.     With WglrGrid
  1028.         If .Row >= .FixedRows Then
  1029.             Lab_Row = Trim(Str(.Row - .FixedRows + 1))
  1030.         End If
  1031.     End With
  1032. End Sub
  1033. Private Sub WglrGrid_GotFocus()                                    '网格得到焦点
  1034.     '网格得到焦点,如果当前选择行为非数据行
  1035.     '则调整当前焦点至有效数据行
  1036.     With WglrGrid
  1037.         
  1038.         If .Row < .FixedRows And .Rows > .FixedRows Then
  1039.             Changelock = True
  1040.             .Select .FixedRows, .Col
  1041.             Changelock = False
  1042.         End If
  1043.         
  1044.         If .Col < Qslz Then     '
  1045.             Changelock = True
  1046.             .Select .Row, Qslz
  1047.             Changelock = False
  1048.         End If
  1049.         
  1050.     End With
  1051. End Sub
  1052. Private Sub WglrGrid_AfterScroll(ByVal OldTopRow As Long, ByVal OldLeftCol As Long, ByVal NewTopRow As Long, ByVal NewLeftCol As Long)                                      '限制用户在录入过程中滚动鼠标
  1053.     If Gdtlock Then
  1054.         Exit Sub
  1055.     End If
  1056.     With WglrGrid
  1057.         If Ydtext.Visible Or YdCombo.Visible Then
  1058.             Gdtlock = True
  1059.             .TopRow = Dqtoprow
  1060.             .LeftCol = Dqleftcol
  1061.             Gdtlock = False
  1062.             Exit Sub
  1063.         End If
  1064.     End With
  1065. End Sub
  1066. Private Sub Ycwbk()                      '隐藏文本框,帮助按钮,列表组合框
  1067.     Valilock = True
  1068.     Ydtext.Visible = False
  1069.     YdCombo.Visible = False
  1070.     Ydcommand.Visible = False
  1071. End Sub
  1072. Private Sub YdCombo_KeyDown(KeyCode As Integer, Shift As Integer)        '列表框的光标移动
  1073.     With WglrGrid
  1074.         Select Case KeyCode
  1075.             Case vbKeyEscape                'ESC 键放弃录入
  1076.                 Valilock = True
  1077.                 .SetFocus
  1078.                 Call Ycwbk
  1079.                 Valilock = False
  1080.             Case vbKeyReturn                '回 车 键 =13
  1081.                 KeyCode = 0
  1082.                 .SetFocus
  1083.                 Call Lrsjhx
  1084.                 Rowjsq = .Row
  1085.                 Coljsq = .Col + 1
  1086.                 If Coljsq > .Cols - 1 Then
  1087.                     If Rowjsq < .Rows - 1 Then
  1088.                         Rowjsq = Rowjsq + 1
  1089.                     End If
  1090.                     Coljsq = Qslz
  1091.                 End If
  1092.                 Do While Rowjsq <= .Rows - 1
  1093.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1094.                         Coljsq = Coljsq + 1
  1095.                         If Coljsq > .Cols - 1 Then
  1096.                             Rowjsq = Rowjsq + 1
  1097.                             Coljsq = Qslz
  1098.                         End If
  1099.                     Else
  1100.                         Exit Do
  1101.                     End If
  1102.                 Loop
  1103.                 .Select Rowjsq, Coljsq
  1104.             Case vbKeyLeft                  '左 箭 头 =37
  1105.                 If .Col - 1 = Qslz Then
  1106.                     If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1107.                         GoTo jzzx
  1108.                     End If
  1109.                 End If
  1110.                 If .Col > Qslz Then
  1111.                     KeyCode = 0
  1112.                     .SetFocus
  1113.                     Call Lrsjhx
  1114.                     Coljsq = .Col - 1
  1115.                     Do While Coljsq > Qslz
  1116.                         If Coljsq - 1 = Qslz Then
  1117.                             If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1118.                                 GoTo jzzx
  1119.                             End If
  1120.                         End If
  1121.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1122.                             Coljsq = Coljsq - 1
  1123.                         Else
  1124.                             Exit Do
  1125.                         End If
  1126.                     Loop
  1127.                     .Select .Row, Coljsq
  1128.                 End If
  1129.             Case vbKeyRight                 '右 箭 头 =39
  1130.                 KeyCode = 0
  1131.                 .SetFocus
  1132.                 Call Lrsjhx
  1133.                 Rowjsq = .Row
  1134.                 Coljsq = .Col + 1
  1135.                 If Coljsq > .Cols - 1 Then
  1136.                     If Rowjsq < .Rows - 1 Then
  1137.                         Rowjsq = Rowjsq + 1
  1138.                     End If
  1139.                     Coljsq = Qslz
  1140.                 End If
  1141.                 Do While Rowjsq <= .Rows - 1
  1142.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1143.                         Coljsq = Coljsq + 1
  1144.                         If Coljsq > .Cols - 1 Then
  1145.                             Rowjsq = Rowjsq + 1
  1146.                             Coljsq = Qslz
  1147.                         End If
  1148.                     Else
  1149.                         Exit Do
  1150.                     End If
  1151.                 Loop
  1152.                 .Select Rowjsq, Coljsq
  1153.              Case Else
  1154.         End Select
  1155.     End With
  1156. jzzx:
  1157. End Sub
  1158. Private Sub YdCombo_LostFocus()                     '下拉列表框失去焦点
  1159.     With WglrGrid                                   '因为选中网格会先发生Rowcolchange事件置Valiock
  1160.         If Not Valilock Then                        '为TRUE
  1161.             Call Lrsjhx
  1162.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1163.                 Exit Sub
  1164.             End If
  1165.         End If
  1166.     End With
  1167. End Sub
  1168. Private Sub Ydcommand_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  1169.     Call Lrzdbz
  1170. End Sub
  1171. Private Sub ydtext_KeyDown(KeyCode As Integer, Shift As Integer)    '录入文本框的焦点发生移动或特殊击键动作,回车、帮助、ESC键、上下左右箭头
  1172.     Dim Rowjsq As Long, Coljsq As Long
  1173.     With WglrGrid
  1174.         Select Case KeyCode
  1175.             Case vbKeyF2
  1176.                  Call Lrzdbz
  1177.             Case vbKeyEscape                'ESC 键放弃录入
  1178.                 Valilock = True
  1179.                 Call Ycwbk
  1180.                 .SetFocus
  1181.             Case vbKeyReturn                '回 车 键 =13
  1182.                 KeyCode = 0
  1183.                 .SetFocus
  1184.                 Call Lrsjhx
  1185.                 Rowjsq = .Row
  1186.                 Coljsq = .Col + 1
  1187.                 If Coljsq > .Cols - 1 Then
  1188.                     If Rowjsq < .Rows - 1 Then
  1189.                         Rowjsq = Rowjsq + 1
  1190.                     End If
  1191.                     Coljsq = Qslz
  1192.                 End If
  1193.                 Do While Rowjsq <= .Rows - 1
  1194.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1195.                         Coljsq = Coljsq + 1
  1196.                         If Coljsq > .Cols - 1 Then
  1197.                             Rowjsq = Rowjsq + 1
  1198.                             Coljsq = Qslz
  1199.                         End If
  1200.                     Else
  1201.                         Exit Do
  1202.                     End If
  1203.                 Loop
  1204.                 .Select Rowjsq, Coljsq
  1205.             Case vbKeyUp                    '上 箭 头 =38
  1206.                 KeyCode = 0
  1207.                 .SetFocus
  1208.                 Call Lrsjhx
  1209.                 If .Row > .FixedRows Then
  1210.                     .Row = .Row - 1
  1211.                 End If
  1212.             Case vbKeyDown                  '下 箭 头 =40
  1213.                 KeyCode = 0
  1214.                 .SetFocus
  1215.                 Call Lrsjhx
  1216.                 If .Row < .Rows - 1 Then
  1217.                     .Row = .Row + 1
  1218.                 End If
  1219.             Case vbKeyLeft                  '左 箭 头 =37
  1220.                 If .Col - 1 = Qslz Then
  1221.                     If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1222.                         GoTo jzzx
  1223.                     End If
  1224.                 End If
  1225.                 If Ydtext.SelStart = 0 And .Col > Qslz Then
  1226.                     KeyCode = 0
  1227.                     .SetFocus
  1228.                     Call Lrsjhx
  1229.                     Coljsq = .Col - 1
  1230.                     Do While Coljsq > Qslz
  1231.                         If Coljsq - 1 = Qslz Then
  1232.                             If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1233.                                 GoTo jzzx
  1234.                             End If
  1235.                         End If
  1236.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1237.                             Coljsq = Coljsq - 1
  1238.                         Else
  1239.                             Exit Do
  1240.                         End If
  1241.                     Loop
  1242.                     .Select .Row, Coljsq
  1243.                 End If
  1244. jzzx:
  1245.             Case vbKeyRight                 '右 箭 头 =39
  1246.                 wblong = Len(Ydtext.Text)
  1247.                 If (Ydtext.SelStart = wblong Or Ydtext.SelLength = wblong) Then
  1248.                     KeyCode = 0
  1249.                     .SetFocus
  1250.                     Call Lrsjhx
  1251.                     Rowjsq = .Row
  1252.                     Coljsq = .Col + 1
  1253.                     If Coljsq > .Cols - 1 Then
  1254.                         If Rowjsq < .Rows - 1 Then
  1255.                             Rowjsq = Rowjsq + 1
  1256.                         End If
  1257.                         Coljsq = Qslz
  1258.                     End If
  1259.                     Do While Rowjsq <= .Rows - 1
  1260.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1261.                             Coljsq = Coljsq + 1
  1262.                             If Coljsq > .Cols - 1 Then
  1263.                                 Rowjsq = Rowjsq + 1
  1264.                                 Coljsq = Qslz
  1265.                             End If
  1266.                         Else
  1267.                             Exit Do
  1268.                         End If
  1269.                      Loop
  1270.                      .Select Rowjsq, Coljsq
  1271.                 End If
  1272.             Case Else
  1273.         End Select
  1274.     End With
  1275. End Sub
  1276. Private Sub ydtext_KeyPress(KeyAscii As Integer)         '录入字符事中控制
  1277.     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)    '参数:文本框控件,字段数据类型,输入字符
  1278.     If KeyAscii <> 0 Then
  1279.         Call Xyxhbz(Dqlrwgh)
  1280.     End If
  1281. End Sub
  1282. Private Sub ydtext_Change() '录入事中变化处理
  1283.     '防止程序改变但不进行处理
  1284.     If Wbkbhlock Then
  1285.         Exit Sub
  1286.     End If
  1287.     With WglrGrid
  1288.         '限制字段录入长度
  1289.         Wbkbhlock = True
  1290.         Select Case GridInt(.Col, 1)
  1291.             Case 8
  1292.                 Call Sjgskz(Ydtext, Xtjezws - Xtjexsws - 1, Xtjexsws)
  1293.             Case 9
  1294.                 Call Sjgskz(Ydtext, Xtslzws - Xtslxsws - 1, Xtslxsws)
  1295.             Case 10
  1296.                 Call Sjgskz(Ydtext, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  1297.             Case Else
  1298.                 If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
  1299.                     Call Sjgskz(Ydtext, GridInt(.Col, 3), GridInt(.Col, 4))
  1300.                 End If
  1301.         End Select
  1302.         Wbkbhlock = False
  1303.     End With
  1304. End Sub
  1305. Private Sub ydtext_LostFocus()            '如果由于选中网格之外的控件而发生有效性判断(选中网格会先发生Rowcolchange事件置Valiock为TRUE)
  1306.     With WglrGrid
  1307.         If Valilock = False Then
  1308.             Call Lrsjhx
  1309.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then Exit Sub
  1310.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1311.                 Exit Sub
  1312.             End If
  1313.         End If
  1314.     End With
  1315. End Sub
  1316. Private Sub Qkwlzd(sjh As Long, Sjl As Long)                            '清空为零字段
  1317.     If Not GridBoolean(Sjl, 5) Then Exit Sub
  1318.     With WglrGrid
  1319.         If Val(Trim(.TextMatrix(sjh, Sjl))) = 0 Then .TextMatrix(sjh, Sjl) = ""
  1320.     End With
  1321. End Sub
  1322. Private Sub fhyxh()                                                     '返回录入数据有效行,同时让得到焦点网格可见
  1323.     With WglrGrid
  1324.         If .Row >= .FixedRows Then
  1325.             If .TextMatrix(.Row, 0) <> "*" Then     '点击网格空区域时执行此语句
  1326.                 For Rowjsq = .FixedRows To .Rows - 1        '为找到最后一数据行的下一行
  1327.                     If .TextMatrix(Rowjsq, 0) <> "*" Then
  1328.                     Exit For
  1329.                     End If
  1330.                 Next Rowjsq
  1331.                 If Rowjsq <= .Rows - 1 Then
  1332.                     Changelock = True
  1333.                     .Select Rowjsq, .Col
  1334.                     Changelock = False
  1335.                 Else
  1336.                     Changelock = True
  1337.                     .Select .Rows - 1, .Col
  1338.                     Changelock = False
  1339.                 End If
  1340.             End If
  1341.             Call Xldqh
  1342.         End If
  1343.     End With
  1344. End Sub
  1345. Private Sub Xldqh()                                                      '显露当前行
  1346.     Dim Toprowte As Long
  1347.     With WglrGrid
  1348.         Toprowte = 0
  1349.         Do While .CellTop + .RowHeight(.Row) + Fzxwghs * Sjhgd > .Height And .TopRow <> Toprowte
  1350.             Toprowte = .TopRow
  1351.             .TopRow = .TopRow + 1
  1352.         Loop
  1353.         Toprowte = 0
  1354.         Do While .CellTop < .FixedRows * .RowHeight(0) And .TopRow <> Toprowte
  1355.             Toprowte = .TopRow
  1356.             .TopRow = .TopRow - 1
  1357.         Loop
  1358.     End With
  1359. End Sub
  1360. Private Sub Xldql()                                                     '显露当前列
  1361.     Dim Leftcolte As Long
  1362.     With WglrGrid
  1363.         If .Col >= Qslz Then
  1364.             If .LeftCol > .Col Then
  1365.                 .LeftCol = .Col
  1366.             End If
  1367.             Leftcolte = 0
  1368.             Do While .CellLeft + .CellWidth > .Width And .LeftCol <> Leftcolte
  1369.                 Leftcolte = .LeftCol
  1370.                 .LeftCol = .LeftCol + 1
  1371.             Loop
  1372.         End If
  1373.     End With
  1374.     
  1375. End Sub
  1376. Private Function pdhwk(sjh As Long)                                     '判断网格行是否为空行(所有录入字段均为空*非录入字段除外)
  1377.     With WglrGrid
  1378.         For Coljsq = Qslz To .Cols - 1
  1379.             If Len(Trim(.TextMatrix(sjh, Coljsq))) <> 0 And GridBoolean(Coljsq, 1) Then
  1380.                 pdhwk = False
  1381.                 Exit Function
  1382.             End If
  1383.         Next Coljsq
  1384.         pdhwk = True
  1385.     End With
  1386. End Function
  1387. Private Sub Xyxhbz(sjh As Long)                                         '写行有效性标志,并判断是否增行
  1388.     With WglrGrid
  1389.         If .TextMatrix(sjh, 0) = "*" Then
  1390.             Exit Sub
  1391.         End If
  1392.         .TextMatrix(sjh, 0) = "*"
  1393.         If sjh >= .Rows - Fzxwghs - 1 Then
  1394.             .AddItem ""
  1395.             .RowHeight(.Rows - 1) = Sjhgd
  1396.         End If
  1397.     End With
  1398. End Sub
  1399. Private Sub Sub_OperStatus(Str_Status As String)                 '工具条依据不同状态所进行的变化
  1400.     With Tlb_Action
  1401.         Select Case Str_Status
  1402.             Case "10"   '浏览
  1403.                 '工具条
  1404.                 '.Buttons("dy").Enabled = False     '打印
  1405.                 '.Buttons("yl").Enabled = False     '预览
  1406.                 .Buttons("run").Enabled = False
  1407.             Case "11"   '浏览
  1408.                  '工具条
  1409.             Case "30"   '修改
  1410.                 '工具条
  1411.         End Select
  1412.     End With
  1413. End Sub
  1414. Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)   '表格格式设置(通用)
  1415.     Select Case Button.Key
  1416.         Case "bcgs"                              '保存表格格式
  1417.             Call Bcwggs(WglrGrid, GridCode, GridStr())
  1418.         Case "hfmrgs"                            '恢复默认格式
  1419.             Call Hfmrgs(WglrGrid, GridCode, GridStr())
  1420.         Case "szxsxm"                            '设置显示项目
  1421.             Call Szxsxm(WglrGrid, GridCode)
  1422.     End Select
  1423. End Sub
  1424. Private Sub bbyl(bbylte As Boolean)                                     '打印预览(通用)
  1425.     Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
  1426.     Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
  1427.     Bbxbtgs = 1                                          '报 表 小 标 题 行 数
  1428.     Bbbwhgs = 0                                          '报 表 表 尾 行 数
  1429.     ReDim Bbxbt(1 To Bbxbtgs)
  1430.     ReDim bbxbtzzxs(1 To Bbxbtgs)
  1431.     If Bbbwhgs <> 0 Then
  1432.         ReDim Bbbwh(1 To Bbbwhgs)
  1433.         ReDim Bbbwhzzxs(1 To Bbbwhgs)
  1434.     End If
  1435.     Bbzbt = ReportTitle
  1436.     
  1437.     '判断是否为空
  1438.     SqlStr = "Select Count(*) From Cb_CostObject"
  1439.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1440.     If RecTemp.Fields(0) <= 0 Then
  1441.         Bbxbt(1) = ""
  1442.     Else
  1443.         Bbxbt(1) = Mid(CStr(Combo_KJQJ.List(Combo_KJQJ.ListIndex)), 1, 4) + "年" + Right(CStr(Combo_KJQJ.List(Combo_KJQJ.ListIndex)), 2) + "月"
  1444.     End If
  1445.   
  1446.     bbxbtzzxs(1) = 1                                     '报表行组织形式(0-居左 1-居中 2-居右)
  1447.     Call Scyxsjb(WglrGrid)                               '生成报表数据
  1448.     Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
  1449.     If Not bbylte Then
  1450.         Unload DY_Tybbyldy
  1451.     End If
  1452. End Sub
  1453. '************以下为文本框录入处理程序(固定不变部分)*************'
  1454. Private Sub Wbklrwbcl(Index As Integer)    '文本框录入事后处理程序
  1455.   '以下为依据实际情况自定义部分[
  1456.   
  1457.       '在此填写文本框录入事后处理程序
  1458.    
  1459.   ']以上为依据实际情况自定义部分
  1460. End Sub
  1461. Private Sub Cxxswbk()                                                  'Formresize中重新显示文本框,列表框,帮助按钮(通用)
  1462.     Dim Wbkpy As Integer, Wbkpy1 As Integer
  1463.     Wbkpy = 30
  1464.     Wbkpy1 = 15
  1465.     With WglrGrid
  1466.         If YdCombo.Visible Then
  1467.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  1468.             YdCombo.Top = .CellTop + .Top + Wbkpy
  1469.             YdCombo.Width = .CellWidth - Wbkpy1
  1470.         End If
  1471.         If Ydcommand.Visible Then
  1472.             Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  1473.             Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  1474.         End If
  1475.         If Ydtext.Visible Then
  1476.             If Ydcommand.Visible Then
  1477.                 If Sfblbzkd Then
  1478.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  1479.                 Else
  1480.                     Ydtext.Width = .CellWidth - Wbkpy1
  1481.                 End If
  1482.             Else
  1483.                 Ydtext.Width = .CellWidth - Wbkpy1
  1484.             End If
  1485.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  1486.             Ydtext.Top = .CellTop + .Top + Wbkpy
  1487.             Ydtext.Height = .CellHeight - Wbkpy1
  1488.         End If
  1489.     End With
  1490. End Sub
  1491. '=================以下自定义部分=================
  1492. Sub Run2()                          '结转产成品
  1493.     Dim Rec_SubTemp As New ADODB.Recordset
  1494.     Dim lng_OperationNum As Long
  1495.     Dim i As Integer
  1496.     Dim CF_Count As Integer
  1497.     Dim IdCount As Integer
  1498.     
  1499.     Bln_DeleteFlag = True
  1500.     Changelock = False
  1501.     CF_Count = 0
  1502.     If CF_Judge = False Then                 '结转之前判断
  1503.         Exit Sub
  1504.     End If
  1505.     
  1506.     On Error GoTo Err1
  1507.     Screen.MousePointer = 11
  1508.     Cw_DataEnvi.DataConnect.BeginTrans
  1509.     IdCount = 0
  1510.     For jsq = 1 To Tranjsq
  1511.         
  1512.         '有无可结转的数据
  1513.         SqlStr = "Select Sum(ThmonConsumeMoney) As ThmonConsumeMoney From Cb_Fn_CFProduceCost('" + CStr(TranNum(jsq)) + "'," + CStr(PrivateYear) + "," + CStr(PrivateMm) + ") "
  1514.         Set Rec_SubTemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1515.         If Not IsNull(Rec_SubTemp.Fields("ThmonConsumeMoney")) Or Rec_SubTemp.Fields("ThmonConsumeMoney") = 0 Then
  1516.             '写临时凭证主表
  1517.             lng_OperationNum = CreatBillID("0102")
  1518.             Call Save_TempPz_Main(OperationNum, lng_OperationNum)
  1519.             
  1520.             '写临时凭证子表
  1521.             SqlStr = "Select '成本结转' As Digest,0 As Jfje,Sum(ThmonConsumeMoney) As Dfje,0 As ye,0 As Jfsl,Sum(ThmonConsumeAmount) As Dfsl,Ccode1 As Ccode " _
  1522.                         & "From Cb_Fn_CFProduceCost('" + CStr(TranNum(jsq)) + "'," + CStr(PrivateYear) + "," + CStr(PrivateMm) + ") Group By Ccode1  Having Sum(ThmonConsumeMoney)<>0 Union " _
  1523.                         & "Select '成本结转',Sum(ThmonConsumeMoney),0,0,Sum(ThmonConsumeAmount),0,B.Ccode From Cb_Fn_CFProduceCost('" + CStr(TranNum(jsq)) + "'," + CStr(PrivateYear) + "," + CStr(PrivateMm) + ") A " _
  1524.                         & "Left Outer Join Cb_CostObject B On A.ObjectCode=b.ObjectCode " _
  1525.                         & "Group By B.Ccode"
  1526.                         
  1527.             Set Rec_SubTemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1528.             i = 1
  1529.             Do Until Rec_SubTemp.EOF
  1530.                 Call Save_TempPz_Ass(Rec_SubTemp, lng_OperationNum, i)
  1531.                 Rec_SubTemp.MoveNext
  1532.                 i = i + 1
  1533.             Loop
  1534.             If IdCount = 0 Then
  1535.                 ReDim Glo_ObjectId1.OId(IdCount)
  1536.                 ReDim Glo_ObjectId1.ONum(IdCount)
  1537.                 Glo_ObjectId1.OId(IdCount) = TranNum(jsq)
  1538.                 Glo_ObjectId1.ONum(IdCount) = lng_OperationNum
  1539.             End If
  1540.             If IdCount > 0 Then
  1541.                 ReDim Preserve Glo_ObjectId1.OId(IdCount)
  1542.                 ReDim Preserve Glo_ObjectId1.ONum(IdCount)
  1543.                 Glo_ObjectId1.OId(IdCount) = TranNum(jsq)
  1544.                 Glo_ObjectId1.ONum(IdCount) = lng_OperationNum
  1545.             End If
  1546.             IdCount = IdCount + 1
  1547.             CF_Count = CF_Count + 1
  1548.         Else
  1549.             Tsxx = "对象没有可结转的数据!"
  1550.             Call Xtxxts(Tsxx, 0, 3)
  1551.         End If
  1552.         
  1553.     Next
  1554.     
  1555.     Cw_DataEnvi.DataConnect.CommitTrans
  1556.     Screen.MousePointer = 0
  1557.     If CF_Count > 0 Then
  1558.         AutoTran_PzFrm.OperationNumPz = OperationNum
  1559.         AutoTran_PzFrm.vouchsourcePz = "成本核算"
  1560.         AutoTran_PzFrm.HelpContextID = "0705003"
  1561.         AutoTran_PzFrm.Show 1
  1562.     End If
  1563.     
  1564.     Call WriteVouchId(OperationNum, 2)  '写数据
  1565.     Call Clean                        '删除信息
  1566.     Call Sub_Query                    '查询信息
  1567.     Exit Sub
  1568. Err1:
  1569.     Cw_DataEnvi.DataConnect.RollbackTrans
  1570.     Screen.MousePointer = 0
  1571.     Exit Sub
  1572. End Sub
  1573. Sub Run1()                              '结转生产成本
  1574.     Dim jsq As Integer
  1575.     Dim Rec_SubTemp As New ADODB.Recordset
  1576.     Dim lng_OperationNum As Long
  1577.     Dim i As Integer
  1578.     Dim CF_Count As Integer
  1579.     Dim IdCount As Integer
  1580.     
  1581.     Bln_DeleteFlag = True
  1582.     Changelock = False
  1583.     CF_Count = 0
  1584.     If CF_Judge = False Then                 '结转之前判断
  1585.         Exit Sub
  1586.     End If
  1587.     
  1588.     On Error GoTo Err1
  1589.     Screen.MousePointer = 11
  1590.     Cw_DataEnvi.DataConnect.BeginTrans
  1591.     IdCount = 0
  1592.     For jsq = 1 To Tranjsq
  1593.         
  1594.         '有无可结转的数据
  1595.         SqlStr = "Select Sum(Isnull(ThmonConsumeMoney,0)) As ThmonConsumeMoney From Cb_Fn_CFProduceCost('" + CStr(TranNum(jsq)) + "'," + CStr(PrivateYear) + "," + CStr(PrivateMm) + ") "
  1596.         Set Rec_SubTemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1597.         If Not IsNull(Rec_SubTemp.Fields("ThmonConsumeMoney")) Or Rec_SubTemp.Fields("ThmonConsumeMoney") = 0 Then
  1598.             '写临时凭证主表
  1599.             lng_OperationNum = CreatBillID("0102")
  1600.             Call Save_TempPz_Main(OperationNum, lng_OperationNum)
  1601.             
  1602.             '写临时凭证子表
  1603.             SqlStr = "Select '成本结转' As Digest,0 As Jfje,isnull(ThmonConsumeMoney,0) As Dfje,0 As ye,0 As Jfsl,isnull(ThmonConsumeAmount,0) As Dfsl,Ccode2 As Ccode From Cb_Fn_CFProduceCost('" + CStr(TranNum(jsq)) + "'," + CStr(CStr(PrivateYear)) + "," + CStr(PrivateMm) + ") Where isnull(ThmonConsumeMoney,0)<>0" _
  1604.                         & "Union " _
  1605.                         & "Select '成本结转',Sum(Isnull(ThmonConsumeMoney,0)),0,0,Sum(Isnull(ThmonConsumeAmount,0)),0,Ccode1 From Cb_Fn_CFProduceCost('" + CStr(TranNum(jsq)) + "'," + CStr(PrivateYear) + "," + CStr(PrivateMm) + ") Group By Ccode1 Having Sum(Isnull(ThmonConsumeMoney,0))<>0"
  1606.     
  1607.             Set Rec_SubTemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1608.             i = 1
  1609.             Do Until Rec_SubTemp.EOF
  1610.                 Call Save_TempPz_Ass(Rec_SubTemp, lng_OperationNum, i)
  1611.                 Rec_SubTemp.MoveNext
  1612.                 i = i + 1
  1613.             Loop
  1614.             
  1615.             If IdCount = 0 Then
  1616.                 ReDim Glo_ObjectId1.OId(IdCount)
  1617.                 ReDim Glo_ObjectId1.ONum(IdCount)
  1618.                 Glo_ObjectId1.OId(IdCount) = TranNum(jsq)
  1619.                 Glo_ObjectId1.ONum(IdCount) = lng_OperationNum
  1620.             End If
  1621.             If IdCount > 0 Then
  1622.                 ReDim Preserve Glo_ObjectId1.OId(IdCount)
  1623.                 ReDim Preserve Glo_ObjectId1.ONum(IdCount)
  1624.                 Glo_ObjectId1.OId(IdCount) = TranNum(jsq)
  1625.                 Glo_ObjectId1.ONum(IdCount) = lng_OperationNum
  1626.             End If
  1627.             IdCount = IdCount + 1
  1628.             CF_Count = CF_Count + 1
  1629.             
  1630.         Else
  1631.             Tsxx = "对象没有可结转的数据!"
  1632.             Call Xtxxts(Tsxx, 0, 3)
  1633.         End If
  1634.         
  1635.     Next
  1636.     
  1637.     Cw_DataEnvi.DataConnect.CommitTrans
  1638.     Screen.MousePointer = 0
  1639.     If CF_Count > 0 Then
  1640.         AutoTran_PzFrm.OperationNumPz = OperationNum
  1641.         AutoTran_PzFrm.vouchsourcePz = "成本核算"
  1642.         AutoTran_PzFrm.HelpContextID = "0705003"
  1643.         AutoTran_PzFrm.Show 1
  1644.     End If
  1645.     Call WriteVouchId(OperationNum, 1)     '写数据
  1646.     Call Clean                           '删除数据
  1647.     Call Sub_Query                       '查询信息
  1648.     Exit Sub
  1649. Err1:
  1650.     Cw_DataEnvi.DataConnect.RollbackTrans
  1651.     Screen.MousePointer = 0
  1652. End Sub
  1653. Private Function CF_Judge() As Boolean            '结转之前的判断
  1654.     Dim jsq As Long             '临时计数器
  1655.     '提示已转过的凭证是否再转一次
  1656.         
  1657.     If WglrGrid.Rows <= WglrGrid.FixedRows Then
  1658.         Exit Function
  1659.     End If
  1660.     With WglrGrid
  1661.         For jsq = .FixedRows To .Rows - 1
  1662.             If .TextMatrix(jsq, Sydz("001", GridStr(), Szzls)) = "√" Then
  1663.                 If .TextMatrix(jsq, Sydz("007", GridStr(), Szzls)) <> "" Then
  1664.                 If .TextMatrix(jsq, Sydz("007", GridStr(), Szzls)) = True Then
  1665.                     Tsxx = "第" & WglrGrid.TextMatrix(jsq, Sydz("002", GridStr(), Szzls)) & "号已转过凭证,再转一次吗?"
  1666.                     If Xtxxts(Tsxx, 1, 4) = 7 Then
  1667.                         .TextMatrix(jsq, Sydz("001", GridStr(), Szzls)) = ""
  1668.                     End If
  1669.                 End If
  1670.                 End If
  1671.             End If
  1672.         Next jsq
  1673.     End With
  1674.     
  1675.     '判断选择的转帐过程共几个,保存在TranJsq中。将每个转帐过程编号赋值到TranNum()数组中,
  1676.     ReDim TranNum(1)                            '转帐过程数组附初值
  1677.     Tranjsq = 0
  1678.     With WglrGrid
  1679.         For jsq = .FixedRows To .Rows - 1
  1680.             If .TextMatrix(jsq, Sydz("001", GridStr(), Szzls)) = "√" Then
  1681.                 If Tranjsq = 0 Then
  1682.                     TranNum(1) = .TextMatrix(jsq, Sydz("002", GridStr(), Szzls))
  1683.                 End If
  1684.                 If Tranjsq > 0 Then
  1685.                     ReDim Preserve TranNum(UBound(TranNum) + 1)
  1686.                     TranNum(Tranjsq + 1) = .TextMatrix(jsq, Sydz("002", GridStr(), Szzls))
  1687.                 End If
  1688.                 Tranjsq = Tranjsq + 1
  1689.             End If
  1690.         Next jsq
  1691.     End With
  1692.     
  1693.     If Tranjsq = 0 Then
  1694.         Tsxx = "没有选择结帐对象!"
  1695.         Call Xtxxts(Tsxx, 0, 4)
  1696.         Tran_Pd = False
  1697.         Exit Function
  1698.     End If
  1699.     
  1700.     OperationNum = CreatBillID("0102")
  1701.     CF_Judge = True
  1702. End Function
  1703. '====================单据ID处理==================
  1704. Public Function CreatBillID(BillCode As String) As Integer
  1705.     '参数说明: BillCode 单据编码
  1706.     Dim BillType As String
  1707.     Dim aDo_re As New Recordset
  1708.     Set aDo_re = Cw_DataEnvi.DataConnect.Execute("select * from Gy_BillNumber where BillCode='" & Trim(BillCode) & "'")
  1709.     If aDo_re.RecordCount > 0 Then
  1710.         CreatBillID = aDo_re!IDNow
  1711.         BillType = aDo_re!BillType
  1712.     End If
  1713.     aDo_re.Close
  1714.     Cw_DataEnvi.DataConnect.Execute "update  Gy_BillNumber set IDNow=IDNow+1 where BillType='" & Trim(BillType) & "'"
  1715. End Function
  1716. Private Sub Save_TempPz_Main(OperationNum1 As Integer, VouchIdTemp_Id As Long)   '将有效数据写入临时凭证主表。(先写辅表再写主表,为了防止在主表中写入没有发生额的空凭证记录)
  1717.     Dim Rec_VouchMainTemp As New ADODB.Recordset           '临时凭证主表记录集
  1718.     
  1719.     '打开临时凭证主表,用于存放有效凭证的凭证号等信息
  1720.     If Rec_VouchMainTemp.State = 1 Then Rec_VouchMainTemp.Close
  1721.     Rec_VouchMainTemp.Open "select * from Cwzz_AccVouchMainTemp Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1722.     With Rec_VouchMainTemp
  1723.         
  1724.         .AddNew
  1725.         .Fields("VouchId") = VouchIdTemp_Id                  '转帐过程序号
  1726.         .Fields("Year") = PrivateYear                        '取选中的年份
  1727.         .Fields("period") = PrivateMm                        '取选中的会计期间
  1728.         .Fields("Ddate") = Xtrq                              '取系统日期
  1729.         .Fields("VouchClassCode") = "转"                     '所转转帐过程的凭证类别
  1730.         .Fields("Doc") = 0
  1731.         .Fields("Bill") = Xtczy
  1732.         .Fields("VouchSource") = "成本核算"                  '凭证来源
  1733.         .Fields("OperationClass") = ""                       '业务类型
  1734.         .Fields("BillType") = ""
  1735.         .Fields("OperationNo") = OperationNum1               '存放批号
  1736.         .Fields("DeleteFlag") = 1
  1737.         
  1738.         .Update
  1739.     End With
  1740. End Sub
  1741. Private Sub Save_TempPz_Ass(Rec_Record As ADODB.Recordset, VouchIdTemp_Id As Long, serialnum As Integer) '写临时凭证辅表
  1742.     'VouchIdTemp_Id临时凭证主表、辅表对应关系Id号
  1743.     Dim Rec_VouchTemp As New ADODB.Recordset            '临时凭证辅表记录集
  1744.     
  1745.     '打开临时凭证辅表,用于存放转帐凭证内容
  1746.     Rec_VouchTemp.Open "select * from Cwzz_AccVouchsubTemp where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1747.     With Rec_VouchTemp
  1748.     
  1749.         .AddNew
  1750.         .Fields("SerialID") = serialnum
  1751.         .Fields("VouchId") = VouchIdTemp_Id
  1752.         .Fields("Digest") = Rec_Record.Fields("Digest")
  1753.         .Fields("Jfje") = Rec_Record.Fields("Jfje")
  1754.         .Fields("Dfje") = Rec_Record.Fields("dfje")
  1755.         .Fields("Balance") = 0
  1756.         .Fields("Jfsl") = Rec_Record.Fields("jfsl")
  1757.         .Fields("Dfsl") = Rec_Record.Fields("dfsl")
  1758.         .Fields("Ccode") = Rec_Record.Fields("Ccode")
  1759.         .Update
  1760.         
  1761.     End With
  1762. End Sub
  1763. Private Sub Clean()               '删除临时数据表数据
  1764.     If Bln_DeleteFlag = True Then
  1765.         If RecTemp.State = 1 Then RecTemp.Close
  1766.         '删除临时凭证主从表
  1767.         Cw_DataEnvi.DataConnect.Execute "Delete From Cwzz_AccVouchSubTemp Where VouchId in (select VouchId from Cwzz_AccVouchMainTemp where OperationNo='" & OperationNum & "')"
  1768.         Cw_DataEnvi.DataConnect.Execute "Delete From Cwzz_AccVouchMainTemp Where OperationNo='" & OperationNum & "'"
  1769.     End If
  1770. End Sub
  1771. Private Sub WriteVouchId(op As Integer, i As Integer)                         '回写正式凭证ID到单据表和明细帐表中
  1772.     Dim SqlStr As String                    'SQL语句
  1773.     Dim RecTemp As New ADODB.Recordset      '临时记录集
  1774.     Dim VId As Integer                      'VouchId
  1775.     Dim SId As Integer                      'SureVouchId
  1776.     Dim l As Integer
  1777.     If i = 1 Then
  1778.         '结转生产成本
  1779.         SqlStr = "Select * From Cwzz_AccVouchMainTemp Where SureVouchId>0 And OperationNo='" & op & "' Order By BillNo"
  1780.         Set RecTemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1781.         Do Until RecTemp.EOF
  1782.             VId = RecTemp.Fields("VouchId")
  1783.             SId = RecTemp.Fields("SureVouchId")
  1784.             
  1785.             SqlStr = "Select * From Cwzz_AccVouchMain Where VouchId='" + CStr(Trim(SId)) + "'"
  1786.             Set Cxnrrec = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1787.             If Not Cxnrrec.EOF Then
  1788.                 For i = 0 To UBound(Glo_ObjectId1.OId)
  1789.                     If Glo_ObjectId1.ONum(i) = VId Then
  1790.                         If Cxnrrec.State = 1 Then Cxnrrec.Close
  1791.                         SqlStr = "Select * From Cb_ObjectComplete Where ObjectCode='" + CStr(Glo_ObjectId1.OId(i)) + "' And Year=" + CStr(PrivateYear) + " And Period=" + CStr(PrivateMm) + ""
  1792.                         Cxnrrec.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1793.                         Cxnrrec.Fields("TranEngSign") = "1"
  1794.                         Cxnrrec.Update
  1795.                         Exit For
  1796.                     End If
  1797.                 Next
  1798.             End If
  1799.             RecTemp.MoveNext
  1800.         Loop
  1801.     Else
  1802.         '结转产成品
  1803.         SqlStr = "Select * From Cwzz_AccVouchMainTemp Where SureVouchId>0 And OperationNo='" & op & "' Order By BillNo"
  1804.         Set RecTemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1805.         Do Until RecTemp.EOF
  1806.             VId = RecTemp.Fields("VouchId")
  1807.             SId = RecTemp.Fields("SureVouchId")
  1808.             
  1809.             SqlStr = "Select * From Cwzz_AccVouchMain Where VouchId='" + CStr(Trim(SId)) + "'"
  1810.             Set Cxnrrec = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1811.             If Not Cxnrrec.EOF Then
  1812.                 For i = 0 To UBound(Glo_ObjectId1.OId)
  1813.                     If Glo_ObjectId1.ONum(i) = VId Then
  1814.                         If Cxnrrec.State = 1 Then Cxnrrec.Close
  1815.                         SqlStr = "Select * From Cb_ObjectComplete Where ObjectCode='" + CStr(Glo_ObjectId1.OId(i)) + "' And Year=" + CStr(PrivateYear) + " And Period=" + CStr(PrivateMm) + ""
  1816.                         Cxnrrec.Open SqlStr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1817.                         Cxnrrec.Fields("TranEngSign1") = "1"
  1818.                         Cxnrrec.Update
  1819.                         Exit For
  1820.                     End If
  1821.                 Next
  1822.             End If
  1823.             RecTemp.MoveNext
  1824.         Loop
  1825.     End If
  1826. End Sub