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

企业管理

开发平台:

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