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