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

企业管理

开发平台:

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