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

企业管理

开发平台:

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