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

企业管理

开发平台:

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