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