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

企业管理

开发平台:

Visual Basic

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