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

企业管理

开发平台:

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 Stand_FrmData 
  5.    BackColor       =   &H00C0C0C0&
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "标准表数据录入"
  8.    ClientHeight    =   6990
  9.    ClientLeft      =   660
  10.    ClientTop       =   1155
  11.    ClientWidth     =   10860
  12.    HelpContextID   =   221201201
  13.    Icon            =   "基础设置_标准表数据录入.frx":0000
  14.    KeyPreview      =   -1  'True
  15.    LinkTopic       =   "Form4"
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   6990
  19.    ScaleWidth      =   10860
  20.    StartUpPosition =   1  '所有者中心
  21.    Begin VB.PictureBox Pic_Title 
  22.       Height          =   765
  23.       Left            =   60
  24.       Picture         =   "基础设置_标准表数据录入.frx":1042
  25.       ScaleHeight     =   705
  26.       ScaleWidth      =   10725
  27.       TabIndex        =   7
  28.       Top             =   570
  29.       Width           =   10785
  30.       Begin VB.Label tsLabel 
  31.          AutoSize        =   -1  'True
  32.          BackColor       =   &H80000018&
  33.          BackStyle       =   0  'Transparent
  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          =   285
  45.          Index           =   4
  46.          Left            =   480
  47.          TabIndex        =   8
  48.          Top             =   180
  49.          Width           =   165
  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":35106
  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":35490
  183.                Key             =   "sz"
  184.             EndProperty
  185.             BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  186.                Picture         =   "基础设置_标准表数据录入.frx":3582A
  187.                Key             =   "dy"
  188.             EndProperty
  189.             BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  190.                Picture         =   "基础设置_标准表数据录入.frx":35BC4
  191.                Key             =   "yl"
  192.             EndProperty
  193.             BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  194.                Picture         =   "基础设置_标准表数据录入.frx":35F5E
  195.                Key             =   "xg"
  196.             EndProperty
  197.             BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  198.                Picture         =   "基础设置_标准表数据录入.frx":362F8
  199.                Key             =   "zh"
  200.             EndProperty
  201.             BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  202.                Picture         =   "基础设置_标准表数据录入.frx":36692
  203.                Key             =   "sh"
  204.             EndProperty
  205.             BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  206.                Picture         =   "基础设置_标准表数据录入.frx":36A2C
  207.                Key             =   "bc"
  208.             EndProperty
  209.             BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  210.                Picture         =   "基础设置_标准表数据录入.frx":36DC6
  211.                Key             =   "fq"
  212.             EndProperty
  213.             BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  214.                Picture         =   "基础设置_标准表数据录入.frx":37160
  215.                Key             =   "bz"
  216.             EndProperty
  217.             BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  218.                Picture         =   "基础设置_标准表数据录入.frx":374FA
  219.                Key             =   "tc"
  220.             EndProperty
  221.             BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  222.                Picture         =   "基础设置_标准表数据录入.frx":37894
  223.                Key             =   "bcgs"
  224.             EndProperty
  225.             BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  226.                Picture         =   "基础设置_标准表数据录入.frx":37C2E
  227.                Key             =   "mrlk"
  228.             EndProperty
  229.             BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  230.                Picture         =   "基础设置_标准表数据录入.frx":37FC8
  231.                Key             =   "xsxm"
  232.             EndProperty
  233.             BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  234.                Picture         =   "基础设置_标准表数据录入.frx":38362
  235.                Key             =   "first"
  236.             EndProperty
  237.             BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  238.                Picture         =   "基础设置_标准表数据录入.frx":386FC
  239.                Key             =   "prev"
  240.             EndProperty
  241.             BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  242.                Picture         =   "基础设置_标准表数据录入.frx":38A96
  243.                Key             =   "next"
  244.             EndProperty
  245.             BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  246.                Picture         =   "基础设置_标准表数据录入.frx":38E30
  247.                Key             =   "last"
  248.             EndProperty
  249.             BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  250.                Picture         =   "基础设置_标准表数据录入.frx":391CA
  251.                Key             =   "xx"
  252.             EndProperty
  253.             BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  254.                Picture         =   "基础设置_标准表数据录入.frx":39564
  255.                Key             =   "define"
  256.             EndProperty
  257.             BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  258.                Picture         =   "基础设置_标准表数据录入.frx":398FE
  259.                Key             =   "exec"
  260.             EndProperty
  261.             BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  262.                Picture         =   "基础设置_标准表数据录入.frx":39C98
  263.                Key             =   "xz"
  264.             EndProperty
  265.             BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  266.                Picture         =   "基础设置_标准表数据录入.frx":3A032
  267.                Key             =   "sc"
  268.             EndProperty
  269.             BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  270.                Picture         =   "基础设置_标准表数据录入.frx":3A3CC
  271.                Key             =   "sx"
  272.             EndProperty
  273.             BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  274.                Picture         =   "基础设置_标准表数据录入.frx":3A766
  275.                Key             =   "cx"
  276.             EndProperty
  277.             BeginProperty ListImage25 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  278.                Picture         =   "基础设置_标准表数据录入.frx":3AB00
  279.                Key             =   "zd"
  280.             EndProperty
  281.             BeginProperty ListImage26 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  282.                Picture         =   "基础设置_标准表数据录入.frx":3AE9A
  283.                Key             =   "dz"
  284.             EndProperty
  285.             BeginProperty ListImage27 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  286.                Picture         =   "基础设置_标准表数据录入.frx":3B234
  287.                Key             =   "ph"
  288.             EndProperty
  289.             BeginProperty ListImage28 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  290.                Picture         =   "基础设置_标准表数据录入.frx":3B5CE
  291.                Key             =   "fz"
  292.             EndProperty
  293.             BeginProperty ListImage29 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  294.                Picture         =   "基础设置_标准表数据录入.frx":3B968
  295.                Key             =   "dw"
  296.             EndProperty
  297.          EndProperty
  298.       End
  299.    End
  300.    Begin MSComctlLib.Toolbar Tlb_Action 
  301.       Align           =   1  'Align Top
  302.       Height          =   570
  303.       Left            =   0
  304.       TabIndex        =   2
  305.       Top             =   0
  306.       Width           =   10860
  307.       _ExtentX        =   19156
  308.       _ExtentY        =   1005
  309.       ButtonWidth     =   820
  310.       ButtonHeight    =   953
  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      =   8
  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             =   "bc"
  342.             ImageKey        =   "bc"
  343.          EndProperty
  344.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  345.             Style           =   3
  346.          EndProperty
  347.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  348.             Caption         =   "帮助"
  349.             Key             =   "bz"
  350.             ImageKey        =   "bz"
  351.          EndProperty
  352.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  353.             Caption         =   "退出"
  354.             Key             =   "fh"
  355.             ImageKey        =   "tc"
  356.          EndProperty
  357.       EndProperty
  358.       BorderStyle     =   1
  359.       Begin MSComctlLib.Toolbar GsToolbar 
  360.          Height          =   540
  361.          Left            =   9150
  362.          TabIndex        =   6
  363.          Top             =   0
  364.          Width           =   1695
  365.          _ExtentX        =   2990
  366.          _ExtentY        =   953
  367.          ButtonWidth     =   1455
  368.          ButtonHeight    =   953
  369.          AllowCustomize  =   0   'False
  370.          Appearance      =   1
  371.          Style           =   1
  372.          ImageList       =   "ImageList1"
  373.          _Version        =   393216
  374.          BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  375.             NumButtons      =   2
  376.             BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  377.                Caption         =   "保存格式"
  378.                Key             =   "bcgs"
  379.                ImageKey        =   "bcgs"
  380.             EndProperty
  381.             BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  382.                Caption         =   "默认列宽"
  383.                Key             =   "hfmrgs"
  384.                ImageKey        =   "mrlk"
  385.             EndProperty
  386.          EndProperty
  387.       End
  388.    End
  389.    Begin VB.Label Lab_OperStatus 
  390.       BackColor       =   &H000080FF&
  391.       Caption         =   "1"
  392.       Height          =   345
  393.       Left            =   10500
  394.       TabIndex        =   5
  395.       Top             =   1440
  396.       Visible         =   0   'False
  397.       Width           =   345
  398.    End
  399. End
  400. Attribute VB_Name = "Stand_FrmData"
  401. Attribute VB_GlobalNameSpace = False
  402. Attribute VB_Creatable = False
  403. Attribute VB_PredeclaredId = True
  404. Attribute VB_Exposed = False
  405. '**************************************************************************************
  406. '*    模 块 名 称 :标准表数据内容录入
  407. '*    功 能 描 述 :录入标准表的内容,采用固定行式录入方法,并手工填写几个数组。
  408. '*    程序员姓名  :田建秀
  409. '*    最后修改人  :田建秀
  410. '*    最后修改时间:2001/12/21
  411. '*    备        注:程序中所有依实际情况自定义部分均用[>> <<]括起
  412. '*
  413. '*    1.每次调入外部功能窗体,均要加锁ChangeLock=True,窗体关闭后解锁ChangeLock=false
  414. '*
  415. '*    3.Lab_OperStatus 用此标签来标识单据录入状态(默认值为1) 1-浏览 2-修改
  416. '*
  417. '***************************************************************************************
  418.  
  419. '以下为自定义变量
  420. '其它固定使用变量
  421. Dim Tsxx As String                              '系统信息提示(Fixed)
  422. Dim ReportTitle As String                       '报表主标题(Fixed)
  423. Dim Rsc As New ADODB.Recordset
  424. Dim Sql As String
  425. Dim i As Long
  426. Dim j As Long
  427. Dim HxList() As Long                            '横向项目的listid
  428. Dim VxList() As Long                        '纵向项目的listid
  429. Dim Length As Integer                           '结果项目的整个数据长度
  430. Dim DotLen As Integer                           '结果项目的小数位数
  431. Dim BzbNO As Integer
  432. '以下为固定使用变量(网格)
  433. Dim Cxnrrec As New ADODB.Recordset              '显示查询内容动态集
  434. Dim Dyymctbl As New DY_Dyymsz                   '打印页面窗体变量
  435. Dim GridCode As String                          '显示网格网格代码
  436.     Dim GridInf() As Variant                        '整个网格设置信息
  437. Dim Pmbcsjhs As Long                            '屏幕网格保持数据行数(大于等于1)
  438. Dim Fzxwghs As Integer                          '辅助项网格行数(包括合计行)
  439. Dim Sfxshjwg As Boolean                         '是否显示合计网格
  440. Dim Qslz As Long                                '网格隐藏(非操作显示)列数
  441. Dim Sjhgd As Double                             '网格数据行高度
  442. Dim GridBoolean() As Boolean                    '网格列信息(布尔型)
  443. Dim GridStr()  As String                        '网格列信息(字符型)
  444. Dim GridInt() As Integer                        '网格列信息(整型)
  445. Dim Sfblbzkd As Boolean                         '是否保留帮助宽度(字段提供帮助时,是否为按钮保留空间)
  446. Dim Dqlrwgh As Long                             '当前录入数据网格行
  447. Dim Dqlrwgl As Long                             '当前录入数据网格列
  448. Dim Dqlkwgh As Long                             '刚刚离开网格行(不一定为录入行)
  449. Dim Dqlkwgl As Long                             '刚刚离开网格列
  450. Dim Dqtoprow As Long                            '当前录入状态时最上端可视行
  451. Dim Dqleftcol As Long                           '当前录入状态时最左端可视列
  452. Dim Zdlrqnr As String                           '字段录入修改前内容(用来判断内容是否修改)
  453. Dim Wbkbhlock As Boolean                        '文本框改变值锁
  454. Dim Changelock As Boolean                       '网格行列改变控制锁(用来区别用户改变.程序改变)
  455. Dim Gdtlock As Boolean                          '滚动条滚动控制(用来区别用户改变.程序改变)
  456. Dim Yxxpdlock As Boolean                        '字段有效性判断锁(内容不修改不需进行字段有效性判断)
  457. Dim Hyxxpdlock As Boolean                       '行有效性判断锁(字段内容不修改不需进行行有效性判断)
  458. Dim Valilock As Boolean                         '文本框失去焦点是否进行有效性控制(TRUE 为锁定*限用网格录入)
  459. Dim Shsfts As Boolean                           '删除记录行是否提示
  460. Dim Szzls As Integer                            '网格信息数组最大下标值(网格列数-1)
  461. Private Sub Form_KeyPress(KeyAscii As Integer)      '限制录入字符"'"
  462.     Select Case KeyAscii
  463.         Case 39           '屏蔽字符"'"
  464.             KeyAscii = 0
  465.     End Select
  466.     
  467. End Sub
  468. Private Sub Form_Load()                              '窗 体 装 入
  469.   
  470.     '初始化各种锁值(Fixed)
  471.     Changelock = False             '网格行列改变控制锁
  472.     Gdtlock = False                '滚动条滚动控制
  473.     Yxxpdlock = True               '字段有效性判断锁
  474.     Hyxxpdlock = True              '行有效性判断锁
  475.     Wbkbhlock = False              '文本框内容改变锁
  476.     GsToolbar.Visible = False
  477.     '报表主标题及报表编码(Fixed)
  478.     ReportTitle = "标准表数据内容"
  479.     XtReportCode = "Pm_StandData"
  480.     Load Dyymctbl
  481.     With Stand_FrmFirst.CzxsGrid
  482.         TsLabel(4) = Trim(.TextMatrix(.Row, 4))
  483.     End With
  484.     '调 入 网 格(Fixed)
  485.     GridCode = "Pm_StandData"      '网格属性编码
  486.     Call BzWgcsh(WglrGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
  487.     
  488.     WglrGrid.TextMatrix(0, 0) = "ID"
  489.     Qslz = GridInf(1)
  490.     Sjhgd = GridInf(2)
  491.     Pmbcsjhs = GridInf(3)
  492.     Fzxwghs = GridInf(4)
  493.     Sfblbzkd = GridInf(5)
  494.     Shsfts = GridInf(6)
  495.     Sfxshjwg = GridInf(7)
  496.     With Stand_FrmFirst.CzxsGrid
  497.         BzbNO = Val(.TextMatrix(.Row, 0))
  498.         TsLabel(4).Caption = Trim(.TextMatrix(.Row, 4))
  499.         '求结果项目的小数位数、整数位数
  500.         If Rsc.State = 1 Then Rsc.Close
  501.         Sql = "select * from Rs_Items where FieldName='" & .TextMatrix(.Row, 3) & "'"
  502.         Set Rsc = Cw_DataEnvi.DataConnect.Execute(Sql)
  503.         If Not Rsc.EOF Then
  504.             Length = Rsc!FieldLength
  505.             DotLen = Rsc!FieldDotL
  506.         End If
  507.         '横向项目,列
  508.         Call RowCol(Trim(.TextMatrix(.Row, 1)), Rsc)
  509.     End With
  510.     With Me.WglrGrid
  511.         .Cols = .FixedCols + Rsc.RecordCount
  512.         ReDim GridInt(.Cols - 1, 1 To 7)
  513.         ReDim GridBoolean(.Cols - 1, 1 To 7)
  514.         ReDim GridStr(.Cols - 1, 1 To 7)
  515.         ReDim HxList(.Cols - 1)
  516.         For i = 0 To .FixedCols
  517.             HxList(i) = 0
  518.         Next
  519.         
  520.         For i = .FixedCols To .Cols - 1
  521.             .TextMatrix(0, i) = Trim(Rsc!ListName)
  522.             HxList(i) = Val(Trim(Rsc!ListID))
  523.             .ColAlignment(i) = 6
  524.             .FixedAlignment(i) = 4
  525.             GridInt(i, 1) = 5
  526.             GridInt(i, 2) = Length + 1
  527.             GridInt(i, 3) = Length - DotLen
  528.             GridInt(i, 4) = DotLen
  529.             GridInt(i, 5) = 0
  530.             GridInt(i, 6) = 0
  531.             GridInt(i, 7) = 0
  532.             GridBoolean(i, 1) = True
  533.             GridBoolean(i, 2) = False
  534.             GridBoolean(i, 3) = False
  535.             GridBoolean(i, 4) = False
  536.             GridBoolean(i, 5) = False
  537.             GridBoolean(i, 6) = False
  538.             GridStr(i, 1) = "00" & i
  539.             GridStr(i, 2) = ""
  540.             GridStr(i, 3) = ""
  541.             GridStr(i, 4) = ""
  542.             GridStr(i, 5) = ""
  543.             
  544.             Rsc.MoveNext
  545.          Next
  546.     End With
  547.     
  548.     With Stand_FrmFirst.CzxsGrid
  549.         
  550.         '纵向项目,行
  551.         If Trim(.TextMatrix(.Row, 2)) <> "" Then
  552.             Call RowCol(Trim(.TextMatrix(.Row, 2)), Rsc)
  553.             With Me.WglrGrid
  554.                 .Rows = .FixedRows + Rsc.RecordCount
  555.                 ReDim VxList(.Rows - 1)
  556.                 VxList(0) = 0
  557.                 For i = .FixedRows To .Rows - 1
  558.                     .TextMatrix(i, .FixedCols - 1) = Trim(Rsc!ListName)
  559.                     VxList(i) = Trim(Rsc!ListID)
  560.                     .RowHeight(i) = 270
  561.                     .FixedAlignment(i) = 4
  562.                     Rsc.MoveNext
  563.                 Next
  564.                 .TextMatrix(0, .FixedCols - 1) = Stand_FrmFirst.CzxsGrid.TextMatrix(Stand_FrmFirst.CzxsGrid.Row, 7)
  565.             End With
  566.             
  567.         Else
  568.             With Me.WglrGrid
  569.                 .Rows = 2
  570.                 .RowHeight(1) = 270
  571.                 .FixedAlignment(1) = 4
  572.                 .TextMatrix(0, .FixedCols - 1) = ""
  573.                 .TextMatrix(1, .FixedCols - 1) = Stand_FrmFirst.CzxsGrid.TextMatrix(Stand_FrmFirst.CzxsGrid.Row, 7)
  574.             End With
  575.         End If
  576.     End With
  577.     
  578.     Szzls = WglrGrid.Cols - 1
  579.     
  580.     '设置标题栏宽度、网格宽度高度(Fixed)
  581.     Pic_Title.Move 50, Pic_Title.Top, Me.Width - 150, Pic_Title.Height
  582.     WglrGrid.Move 50, Pic_Title.Top + Pic_Title.Height, Me.Width - 150
  583.     WglrGrid.Height = Me.Height - WglrGrid.Top - 380
  584.       
  585.     '生成查询结果
  586.     Call Sub_Query
  587.     
  588.     '设置状态为修改状态
  589.     Lab_OperStatus = "2"
  590.  
  591. End Sub
  592. Private Sub RowCol(FieldName As String, Rsc As ADODB.Recordset)
  593.     '用一函数,判断是否是部门。并返回列数、行数、结果项目的小数位数、整数位数。
  594.     If LCase(Trim(FieldName)) = "rs_basicinfo.deptcode" Then
  595.         Sql = "select DeptCode as ListId,DeptName as ListName from Gy_Department where CodeLevel=" & _
  596.             Val(Stand_FrmFirst.CzxsGrid.TextMatrix(Stand_FrmFirst.CzxsGrid.Row, 9)) & _
  597.             " and RsPmFlag=1 order by Deptcode"
  598.             
  599.     Else
  600.         Sql = "select ListName,ListId from Rs_CorMain c inner join Rs_CorSub s " & _
  601.               " on c.SortId=s.SortId inner join  Rs_Items i on " & _
  602.               " i.correlation=c.sortid and ltriM(rtrim(tablename)) + '.' + ltrim(rtrim(fieldname))='" & _
  603.               FieldName & "' order by s.listid "
  604.     End If
  605.     If Rsc.State = 1 Then Rsc.Close
  606.     Set Rsc = Cw_DataEnvi.DataConnect.Execute(Sql)
  607. End Sub
  608. Private Sub Form_Unload(Cancel As Integer)           '窗体卸载
  609.     If Not Fun_Drfrmyxxpd Then
  610.        Cancel = True
  611.        Exit Sub
  612.     End If
  613.     '卸载打印页面窗体
  614.     Unload Dyymctbl
  615.     Set Rsc = Nothing
  616. End Sub
  617. Private Sub Sub_Query()                              '生成查询结果
  618.     Dim Sqlstr As String                           '临时使用字符串
  619.     Dim RecTemp As New ADODB.Recordset             '临时使用动态集
  620.     Dim jsqte As Long                              '临时计数器
  621.     '禁止网格刷新动作,为加快网格显示速度(Fixed)
  622.     WglrGrid.Redraw = False
  623.     '查询字符串'
  624.     Sqlstr = "select * from PM_StandTblData where BzbNo=" & BzbNO
  625.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  626.     With RecTemp
  627.      
  628.         With WglrGrid
  629.             Do While Not RecTemp.EOF
  630.                 If Trim(Stand_FrmFirst.CzxsGrid.TextMatrix(Stand_FrmFirst.CzxsGrid.Row, 2)) <> "" Then
  631.                     '有纵向项目
  632.                     For i = .FixedRows To .Rows - 1
  633.                         For j = .FixedCols To .Cols - 1
  634.                             If VxList(i) = RecTemp!VxData And HxList(j) = RecTemp!HxData Then
  635.                                 .TextMatrix(i, j) = RecTemp!ResuData
  636.                                 Exit For
  637.                             End If
  638.                         Next
  639.                     Next
  640.                 Else
  641.                     '无纵向项目
  642.                     For j = .FixedCols To .Cols - 1
  643.                         If HxList(j) = Trim(RecTemp!HxData) Then
  644.                             .TextMatrix(.FixedRows, j) = RecTemp!ResuData
  645.                             Exit For
  646.                         End If
  647.                     Next
  648.                 End If
  649.                 RecTemp.MoveNext
  650.             Loop
  651.         End With
  652.     End With
  653.             
  654.     '将网格刷新解禁(Fixed)
  655.     WglrGrid.Redraw = True
  656.        
  657. End Sub
  658. Private Sub Tlb_Action_ButtonClick(ByVal Button As MSComctlLib.Button)             '用户点击工具条
  659.      
  660.     '屏蔽文本框,下拉组合框有效性判断
  661.      
  662.     Valilock = True
  663.      
  664.     '屏蔽网格失去焦点产生的有效性判断
  665.      
  666.     Changelock = True
  667.      
  668.     Select Case Button.Key
  669.         Case "ymsz"                                          '页面设置
  670.             Dyymctbl.Show 1
  671.         Case "yl"                                            '预 览
  672.             If Fun_Drfrmyxxpd Then
  673.                 Call bbyl(True)
  674.             End If
  675.         Case "dy"                                            '打 印
  676.             If Fun_Drfrmyxxpd Then
  677.                 Call bbyl(False)
  678.             End If
  679.         Case "bc"
  680.             Call Bclrsj
  681.         Case "bz"                                            '帮 助
  682.             Call F1bz
  683.         Case "fh"                                            '退 出
  684.             Unload Me
  685.             
  686.     End Select
  687.        
  688.     '解 锁
  689.     Valilock = False
  690.     Changelock = False
  691.         
  692. End Sub
  693. Private Sub Bclrsj()
  694.     Dim j As Long
  695.     If Ydtext.Visible = True Then
  696.         Call Xtxxts("处于录入状态,不能保存!", 0, 1)
  697.         Exit Sub
  698.     End If
  699.     Sql = ""
  700.     With WglrGrid
  701.         Sql = "delete PM_StandTblData where BzbNo=" & BzbNO
  702.         If Trim(Stand_FrmFirst.CzxsGrid.TextMatrix(Stand_FrmFirst.CzxsGrid.Row, 2)) = "" Then
  703.             For i = .FixedRows To .Rows - 1
  704.                 For j = .FixedCols To .Cols - 1
  705.                    If Trim(.TextMatrix(i, j)) <> "" Then
  706.                        Sql = Sql & " insert pm_StandTblData(BzbNO,HxData,ResuData)  values(" & _
  707.                             BzbNO & "," & HxList(j) & _
  708.                             "," & .TextMatrix(i, j) & " )"
  709.                    End If
  710.                 Next
  711.             Next
  712.         Else
  713.             For i = .FixedRows To .Rows - 1
  714.                 For j = .FixedCols To .Cols - 1
  715.                    If Trim(.TextMatrix(i, j)) <> "" Then
  716.                        Sql = Sql & " insert pm_StandTblData(BzbNO,HxData,VxData,ResuData)  values(" & _
  717.                             BzbNO & "," & HxList(j) & "," & VxList(i) & _
  718.                             "," & .TextMatrix(i, j) & " )"
  719.                    End If
  720.                 Next
  721.             Next
  722.         End If
  723.     End With
  724.     On Error GoTo Swcwcl
  725.     With Cw_DataEnvi.DataConnect
  726.         .BeginTrans
  727.         .Execute Sql
  728.         .CommitTrans
  729.     End With
  730.     Tsxx = "保存成功!"
  731.     Call Xtxxts(Tsxx, 0, 4)
  732.     Exit Sub
  733. Swcwcl:
  734.     Cw_DataEnvi.DataConnect.RollbackTrans
  735.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  736.     Call Xtxxts(Tsxx, 0, 1)
  737. End Sub
  738. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)        '支持热键操作
  739.   
  740.     If Shift = 2 Then
  741.         Select Case UCase(Chr(KeyCode))
  742.             Case "P"                   'Ctrl+P 打印
  743.                 If Tlb_Action.Buttons("dy").Enabled Then
  744.                     Call bbyl(False)
  745.                 End If
  746.         End Select
  747.     End If
  748.     
  749. End Sub
  750. Private Sub Wbkcl()                                                 '文本框录入之前处理(根据实际情况)
  751.  
  752.     Dim xswbrr As String
  753.  
  754.     With WglrGrid
  755.         Zdlrqnr = Trim(.Text)
  756.         xswbrr = Trim(.Text)
  757.     
  758.         If GridBoolean(.Col, 3) Then   '列表框录入
  759.     
  760.             '填充列表框程序
  761.             Call FillCombo(YdCombo, GridStr(.Col, 5), xswbrr, 0)
  762.         Else
  763.             Wbkbhlock = True
  764.        
  765.             '====以下为用户自定义
  766.             Ydtext.Text = xswbrr
  767.             '====以上为用户自定义
  768.          
  769.             Wbkbhlock = False
  770.             Ydtext.SelStart = Len(Ydtext.Text)
  771.         End If
  772.     End With
  773.     
  774. End Sub
  775. Private Function sjzdyxxpd(Dqpdwgh As Long, Dqpdwgl As Long)        '录入数据字段有效性判断,同时进行字段录入事后处理
  776.     
  777.     Dim Str_JudgeText As String            '临时有效性判断字段内容
  778.     Dim Coljsq As Long                     '临时列计数器
  779.     Dim RecTemp As New ADODB.Recordset     '临时使用动态集
  780.     Dim Dbl_Qcye As Double                 '临时期初余额
  781.  
  782.     With WglrGrid
  783.     
  784.         '非录入状态有效性为合法
  785.         If Yxxpdlock Or .Row < .FixedRows Then
  786.            sjzdyxxpd = True
  787.            Exit Function
  788.         End If
  789.  
  790.         Str_JudgeText = Trim(.TextMatrix(Dqpdwgh, Dqpdwgl))
  791.         Select Case GridStr(Dqpdwgl, 1)
  792.          
  793.             '以下为自定义部分[
  794.                 '1.放置字段有效性判断程序
  795.                     'Case "004"
  796.                     
  797.                 '2.放置字段事后处理程序
  798.                 
  799.             '以上为自定义部分]
  800.             
  801.         End Select
  802.      
  803.         '字段录入正确后为零字段清空
  804.         Call Qkwlzd(Dqpdwgh, Dqpdwgl)
  805.     
  806.         sjzdyxxpd = True
  807.         Yxxpdlock = True
  808.         Exit Function
  809.     
  810.     End With
  811.   
  812. Lrcwcl:    '录入错误处理
  813.     With WglrGrid
  814.         Call Xtxxts(Tsxx, 0, 1)
  815.         Changelock = True
  816.         .Select Dqpdwgh, Dqpdwgl
  817.         Changelock = False
  818.         Call xswbk
  819.         sjzdyxxpd = False
  820.         Exit Function
  821.     End With
  822.     
  823. End Function
  824. Private Function Sjhzyxxpd(ByVal Yxxpdh As Long) As Boolean                  '录入数据行有效性判断,同时进行行处理
  825.  
  826.     Dim Lrywlz As Long                     '录入错误列值(Fixed)
  827.     Dim RecTemp As New ADODB.Recordset     '临时使用动态集
  828.     Dim Sqlstr As String                   '临时查询字符串
  829.     Dim Str_Ccode As String                '临时索引编码
  830.     With WglrGrid
  831.         '行没有发生变化则不进行有效性判断
  832.         If Hyxxpdlock Then
  833.             Sjhzyxxpd = True
  834.             Exit Function
  835.         End If
  836.     
  837.         '以下为自定义部分[
  838.     
  839.         '1.1首先进行单个不能为空或不能为零判断(Fixed)
  840.         For jsqte = Qslz To .Cols - 1
  841.             '字段不能为空
  842.             If GridInt(jsqte, 5) = 1 Then
  843.                 If Len(Trim(.TextMatrix(Yxxpdh, jsqte))) = 0 Then
  844.                     Tsxx = GridStr(jsqte, 2)
  845.                     Lrywlz = jsqte
  846.                     GoTo Lrcwcl
  847.                     Exit For
  848.                 End If
  849.             End If
  850.             
  851.             '字段不能为零
  852.             If GridInt(jsqte, 5) = 2 Then
  853.                 If Val(Trim(.TextMatrix(Yxxpdh, jsqte))) = 0 Then
  854.                     Tsxx = GridStr(jsqte, 2)
  855.                     Lrywlz = jsqte
  856.                     GoTo Lrcwcl
  857.                     Exit For
  858.                 End If
  859.             End If
  860.         Next jsqte
  861.     
  862.     
  863.         '1.2进行其他有效性判断,编写格式同1.1
  864.                 
  865.         '2.放置行处理程序(当数据行通过有效性判断)
  866.    
  867.     End With
  868.     '以上为自定义部分]
  869.     Sjhzyxxpd = True
  870.     Hyxxpdlock = True
  871.     Exit Function
  872. Swcwcl:
  873.     Cw_DataEnvi.DataConnect.RollbackTrans
  874.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  875.     Call Xtxxts(Tsxx, 0, 1)
  876.     Exit Function
  877. Lrcwcl:      '录入错误处理
  878.     With WglrGrid
  879.         Call Xtxxts(Tsxx, 0, 1)
  880.         Changelock = True
  881.         .Select Yxxpdh, Lrywlz
  882.         Changelock = False
  883.         Call xswbk
  884.         Sjhzyxxpd = False
  885.         Exit Function
  886.     End With
  887.     
  888. End Function
  889. '===================以 下 程 序 为 通 用 部 分 ,一 般 不 需 更 改(程序动作部分)======================='
  890. Private Sub Lrzdbz()                                                      '录入字段帮助
  891.   
  892.     If Not Ydcommand.Visible Then
  893.         Exit Sub
  894.     End If
  895.    
  896.     With WglrGrid
  897.      
  898.         Valilock = True
  899.     
  900.         '处理通用部分
  901.         Changelock = True        '调入另外窗体必须加锁
  902.         Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(Ydtext.Text))
  903.         Changelock = False
  904.         
  905.         If Len(Xtfhcs) <> 0 Then
  906.             If GridInt(.Col, 7) = 0 Then
  907.                 Ydtext.Text = Xtfhcs
  908.             Else
  909.                 Ydtext.Text = Xtfhcsfz
  910.             End If
  911.         End If
  912.         
  913.         Valilock = False
  914.   
  915.         If Ydtext.Visible Then
  916.             Ydtext.SetFocus
  917.         End If
  918.     End With
  919.     
  920. End Sub
  921. Private Sub Form_Resize()                                                '窗体大小发生变化时,重新显示文本框
  922.    
  923.     Call Cxxswbk
  924.    
  925. End Sub
  926. Private Function Fun_Drfrmyxxpd() As Boolean                             '调入其它窗体或功能产生的有效性判断(包括数据回写)
  927.   
  928.     Fun_Drfrmyxxpd = True
  929.     
  930.     With WglrGrid
  931.    
  932.         '如果当前网格处于编辑状态,则先进行数据回写再进行有效性判断
  933.   
  934.         If Ydtext.Visible Or YdCombo.Visible Then
  935.             Call Lrsjhx
  936.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  937.                 Fun_Drfrmyxxpd = False
  938.                 Exit Function
  939.             End If
  940.         End If
  941.    
  942.         '进行行有效性判断
  943.         If Not Sjhzyxxpd(.Row) Then
  944.             Fun_Drfrmyxxpd = False
  945.             Exit Function
  946.         End If
  947.     End With
  948.   
  949. End Function
  950. Private Sub WglrGrid_EnterCell()                                          '显示当前数据行相关信息
  951.     With WglrGrid
  952.         If .Row >= .FixedRows Then
  953.             '[>>
  954.                 '此处可以填写显示与此网格行相关信息
  955.             '<<]
  956.         End If
  957.     End With
  958.    
  959. End Sub
  960. Private Sub WglrGrid_GotFocus()                                           '网格得到焦点
  961.     '网格得到焦点,如果当前选择行为非数据行
  962.     '则调整当前焦点至有效数据行
  963.     With WglrGrid
  964.         If .Row < .FixedRows And .Rows > .FixedRows Then
  965.             Changelock = True
  966.             .Select .FixedRows, .Col
  967.             Changelock = False
  968.         End If
  969.         If .Col < Qslz Then
  970.             Changelock = True
  971.             .Select .Row, Qslz
  972.             Changelock = False
  973.         End If
  974.     End With
  975. End Sub
  976. Private Sub WglrGrid_LostFocus()                                          '录入网格失去焦点
  977.     '用以屏蔽调用其它窗体时发生网格失去焦点事件
  978.     If Changelock Then
  979.         Exit Sub
  980.     End If
  981.     '引发网格RowcolChange事件
  982.     With WglrGrid
  983.         If Not (Ydtext.Visible Or YdCombo.Visible) Then
  984.             .Select 0, 0
  985.         End If
  986.     End With
  987. End Sub
  988. Private Sub WglrGrid_AfterScroll(ByVal OldTopRow As Long, ByVal OldLeftCol As Long, ByVal NewTopRow As Long, ByVal NewLeftCol As Long)                                             '限制用户在录入过程中滚动鼠标
  989.     If Gdtlock Then
  990.         Exit Sub
  991.     End If
  992.  
  993.     With WglrGrid
  994.         If Ydtext.Visible Or YdCombo.Visible Then
  995.             Gdtlock = True
  996.             .TopRow = Dqtoprow
  997.             .LeftCol = Dqleftcol
  998.             Gdtlock = False
  999.             Exit Sub
  1000.         End If
  1001.     End With
  1002.     
  1003. End Sub
  1004. Private Sub WglrGrid_LeaveCell()                                    '离开单元格
  1005.     If Changelock Then
  1006.         Exit Sub
  1007.     End If
  1008.     '记录刚刚离开网格单元的行列值
  1009.     Dqlkwgh = WglrGrid.Row
  1010.     Dqlkwgl = WglrGrid.Col
  1011.     '判断是否需要录入数据回写
  1012.     If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1013.         Exit Sub
  1014.     End If
  1015.     
  1016.     Call Lrsjhx
  1017.     
  1018. End Sub
  1019. Private Sub WglrGrid_RowColChange()                                '网格录入行列发生变化时,进行有效性判断
  1020.    
  1021.     Valilock = True       '屏蔽文本框失去焦点进行有效性判断
  1022.     
  1023.     With WglrGrid
  1024.         If Changelock Then
  1025.             Exit Sub
  1026.         End If
  1027.         If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1028.             Exit Sub
  1029.         End If
  1030.         If .Row <> Dqlkwgh Then
  1031.             If Not Sjhzyxxpd(Dqlkwgh) Then
  1032.                 Exit Sub
  1033.             End If
  1034.         End If
  1035.    End With
  1036.    
  1037.    Call fhyxh
  1038.    Call Xldql
  1039.    
  1040. End Sub
  1041. Private Sub WglrGrid_DblClick()                                    '鼠标双击网格显示文本框
  1042.   
  1043.     With WglrGrid
  1044.         Call xswbk
  1045.     End With
  1046.     
  1047. End Sub
  1048. Private Sub Ycwbk()                                                '隐藏文本框,帮助按钮,列表组合框
  1049.     
  1050.     Valilock = True
  1051.     Ydtext.Visible = False
  1052.     YdCombo.Visible = False
  1053.     Ydcommand.Visible = False
  1054.     
  1055. End Sub
  1056. Private Sub YdCombo_KeyDown(KeyCode As Integer, Shift As Integer)        '列表框移动
  1057.     
  1058.     With WglrGrid
  1059.         Select Case KeyCode
  1060.             Case vbKeyEscape                'ESC 键放弃录入
  1061.                 Valilock = True
  1062.                 .SetFocus
  1063.                 Call Ycwbk
  1064.                 Valilock = False
  1065.                 
  1066.             Case vbKeyReturn                '回 车 键 =13
  1067.                 KeyCode = 0
  1068.                 .SetFocus
  1069.                 Call Lrsjhx
  1070.                 Rowjsq = .Row
  1071.                 Coljsq = .Col + 1
  1072.                 If Coljsq > .Cols - 1 Then
  1073.                     If Rowjsq < .Rows - 1 Then
  1074.                         Rowjsq = Rowjsq + 1
  1075.                     End If
  1076.                     Coljsq = Qslz
  1077.                 End If
  1078.                 Do While Rowjsq <= .Rows - 1
  1079.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1080.                         Coljsq = Coljsq + 1
  1081.                         If Coljsq > .Cols - 1 Then
  1082.                             Rowjsq = Rowjsq + 1
  1083.                             Coljsq = Qslz
  1084.                         End If
  1085.                     Else
  1086.                         Exit Do
  1087.                     End If
  1088.                 Loop
  1089.                 .Select Rowjsq, Coljsq
  1090.                 
  1091.             Case vbKeyLeft                  '左 箭 头 =37
  1092.                 If .Col - 1 = Qslz Then
  1093.                     If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1094.                         GoTo jzzx
  1095.                     End If
  1096.                 End If
  1097.                 If .Col > Qslz Then
  1098.                     KeyCode = 0
  1099.                     .SetFocus
  1100.                     Call Lrsjhx
  1101.                     Coljsq = .Col - 1
  1102.                     Do While Coljsq > Qslz
  1103.                         If Coljsq - 1 = Qslz Then
  1104.                             If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1105.                                 GoTo jzzx
  1106.                             End If
  1107.                         End If
  1108.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1109.                             Coljsq = Coljsq - 1
  1110.                         Else
  1111.                             Exit Do
  1112.                         End If
  1113.                     Loop
  1114.                     .Select .Row, Coljsq
  1115.                 End If
  1116.             Case vbKeyRight                 '右 箭 头 =39
  1117.                 KeyCode = 0
  1118.                 .SetFocus
  1119.                 Call Lrsjhx
  1120.                 Rowjsq = .Row
  1121.                 Coljsq = .Col + 1
  1122.                 If Coljsq > .Cols - 1 Then
  1123.                     If Rowjsq < .Rows - 1 Then
  1124.                         Rowjsq = Rowjsq + 1
  1125.                     End If
  1126.                     Coljsq = Qslz
  1127.                 End If
  1128.                 Do While Rowjsq <= .Rows - 1
  1129.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1130.                         Coljsq = Coljsq + 1
  1131.                         If Coljsq > .Cols - 1 Then
  1132.                             Rowjsq = Rowjsq + 1
  1133.                             Coljsq = Qslz
  1134.                         End If
  1135.                     Else
  1136.                         Exit Do
  1137.                     End If
  1138.                 Loop
  1139.                 .Select Rowjsq, Coljsq
  1140.         Case Else
  1141.     End Select
  1142.    
  1143. jzzx:
  1144.    
  1145.     End With
  1146.     
  1147. End Sub
  1148. Private Sub YdCombo_LostFocus()                    '列表框失去焦点
  1149.     
  1150.     With WglrGrid                                    '因为选中网格会先发生Rowcolchange事件置Valiock
  1151.         If Not Valilock Then                           '为TRUE
  1152.             Call Lrsjhx
  1153.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1154.                 Exit Sub
  1155.             End If
  1156.         End If
  1157.     End With
  1158.     
  1159. End Sub
  1160. Private Sub Ydcommand_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  1161.     
  1162.     Call Lrzdbz
  1163.     
  1164. End Sub
  1165. Private Sub ydtext_KeyDown(KeyCode As Integer, Shift As Integer)
  1166.    
  1167.     Dim Rowjsq As Long, Coljsq As Long
  1168.    
  1169.     With WglrGrid
  1170.         Select Case KeyCode
  1171.             Case vbKeyF2
  1172.                 Call Lrzdbz
  1173.             Case vbKeyEscape                'ESC 键放弃录入
  1174.                 Valilock = True
  1175.                 Call Ycwbk
  1176.                 .SetFocus
  1177.             Case vbKeyReturn                '回 车 键 =13
  1178.                 KeyCode = 0
  1179.                 .SetFocus
  1180.                 Call Lrsjhx
  1181.                 Rowjsq = .Row
  1182.                 Coljsq = .Col + 1
  1183.                 If Coljsq > .Cols - 1 Then
  1184.                     If Rowjsq < .Rows - 1 Then
  1185.                         Rowjsq = Rowjsq + 1
  1186.                     End If
  1187.                     Coljsq = Qslz
  1188.                 End If
  1189.                 Do While Rowjsq <= .Rows - 1
  1190.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1191.                         Coljsq = Coljsq + 1
  1192.                         If Coljsq > .Cols - 1 Then
  1193.                             Rowjsq = Rowjsq + 1
  1194.                             Coljsq = Qslz
  1195.                         End If
  1196.                     Else
  1197.                         Exit Do
  1198.                     End If
  1199.                 Loop
  1200.                 If Rowjsq <= .Rows - 1 Then
  1201.                     .Select Rowjsq, Coljsq
  1202.                 End If
  1203.                 
  1204.             Case vbKeyUp                    '上 箭 头 =38
  1205.                 KeyCode = 0
  1206.                 .SetFocus
  1207.                 Call Lrsjhx
  1208.                 If .Row > .FixedRows Then
  1209.                     .Row = .Row - 1
  1210.                 End If
  1211.                 
  1212.             Case vbKeyDown                  '下 箭 头 =40
  1213.                 KeyCode = 0
  1214.                 .SetFocus
  1215.                 Call Lrsjhx
  1216.                 If .Row < .Rows - 1 Then
  1217.                     .Row = .Row + 1
  1218.                 End If
  1219.             Case vbKeyLeft                  '左 箭 头 =37
  1220.                 If .Col - 1 = Qslz Then
  1221.                     If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1222.                         GoTo jzzx
  1223.                     End If
  1224.                 End If
  1225.                 If Ydtext.SelStart = 0 And .Col > Qslz Then
  1226.                     KeyCode = 0
  1227.                     .SetFocus
  1228.                     Call Lrsjhx
  1229.                     Coljsq = .Col - 1
  1230.                     Do While Coljsq > Qslz
  1231.                         If Coljsq - 1 = Qslz Then
  1232.                             If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1233.                                 GoTo jzzx
  1234.                             End If
  1235.                         End If
  1236.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1237.                             Coljsq = Coljsq - 1
  1238.                         Else
  1239.                             Exit Do
  1240.                         End If
  1241.                     Loop
  1242.                     .Select .Row, Coljsq
  1243.                 End If
  1244. jzzx:
  1245.            
  1246.            
  1247.             Case vbKeyRight                 '右 箭 头 =39
  1248.                 wblong = Len(Ydtext.Text)
  1249.                 If (Ydtext.SelStart = wblong Or Ydtext.SelLength = wblong) Then
  1250.                     KeyCode = 0
  1251.                     .SetFocus
  1252.                     Call Lrsjhx
  1253.                     Rowjsq = .Row
  1254.                     Coljsq = .Col + 1
  1255.                     If Coljsq > .Cols - 1 Then
  1256.                         If Rowjsq < .Rows - 1 Then
  1257.                             Rowjsq = Rowjsq + 1
  1258.                         End If
  1259.                         Coljsq = Qslz
  1260.                     End If
  1261.                     Do While Rowjsq <= .Rows - 1
  1262.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1263.                             Coljsq = Coljsq + 1
  1264.                             If Coljsq > .Cols - 1 Then
  1265.                                 Rowjsq = Rowjsq + 1
  1266.                                 Coljsq = Qslz
  1267.                             End If
  1268.                         Else
  1269.                             Exit Do
  1270.                         End If
  1271.                     Loop
  1272.                     .Select Rowjsq, Coljsq
  1273.                 End If
  1274.             Case Else
  1275.         End Select
  1276.     End With
  1277.     
  1278. End Sub
  1279. Private Sub ydtext_KeyPress(KeyAscii As Integer)         '录入字符事中控制
  1280.   
  1281.     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  1282. End Sub
  1283. Private Sub ydtext_Change()                              '录入事中变化处理
  1284.     '防止程序改变但不进行处理
  1285.     If Wbkbhlock Then
  1286.          Exit Sub
  1287.     End If
  1288.     With WglrGrid
  1289.         '限制字段录入长度
  1290.         Wbkbhlock = True
  1291.         
  1292.         Call TextChangeLimit(Ydtext, GridInt(.Col, 1))  '去掉无效字符
  1293.         
  1294.         Select Case GridInt(.Col, 1)
  1295.             Case 8, 11   '金额型
  1296.                 Call Sjgskz(Ydtext, Xtjezws - Xtjexsws - 1, Xtjexsws)
  1297.             Case 9, 12   '数量型
  1298.                 Call Sjgskz(Ydtext, Xtslzws - Xtslxsws - 1, Xtslxsws)
  1299.             Case 10      '单价型
  1300.                 Call Sjgskz(Ydtext, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  1301.             Case Else    '其他类型
  1302.                 If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
  1303.                     Call Sjgskz(Ydtext, GridInt(.Col, 3), GridInt(.Col, 4))
  1304.                 End If
  1305.         End Select
  1306.         
  1307.         Wbkbhlock = False
  1308.     End With
  1309.     
  1310. End Sub
  1311. Private Sub ydtext_LostFocus()            '如果由于选中网格之外的控件而发生有效性判断(选中网格会先发生Rowcolchange事件置Valiock为TRUE)
  1312.   
  1313.     With WglrGrid
  1314.         If Not Valilock Then
  1315.             Call Lrsjhx
  1316.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1317.                 Exit Sub
  1318.             End If
  1319.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1320.                 Exit Sub
  1321.             End If
  1322.         End If
  1323.     End With
  1324.   
  1325. End Sub
  1326. Private Sub xswbk()                       '在当前选中单元显示文本框,列表框,帮助按钮(通用)
  1327.   
  1328.     Dim Wbkpy As Integer, Wbkpy1 As Integer '文本框偏移量
  1329.   
  1330.     '当某种条件成立时禁止文本框激活使单据处于录入状态
  1331.     If Not Fun_AllowInput Then
  1332.         Exit Sub
  1333.     End If
  1334.   
  1335.     '显示文本框前返回有效行列(解决滚动条问题)
  1336.     Call Xldqh
  1337.     Call Xldql
  1338.   
  1339.     '隐藏文本框,帮助按钮,列表组合框
  1340.     Call Ycwbk
  1341.   
  1342.     With WglrGrid
  1343.         Dqlrwgh = .Row
  1344.         Dqlrwgl = .Col
  1345.         If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  1346.             Exit Sub
  1347.         End If
  1348.      
  1349.         Wbkpy = 30
  1350.         Wbkpy1 = 15
  1351.     
  1352.         On Error Resume Next
  1353.         
  1354.         If GridBoolean(.Col, 3) Then
  1355.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  1356.             YdCombo.Top = .CellTop + .Top + Wbkpy
  1357.             YdCombo.Width = .CellWidth - Wbkpy1
  1358.             Call Wbkcl
  1359.             YdCombo.Visible = True
  1360.             YdCombo.SetFocus
  1361.             Ydcommand.Visible = False
  1362.             Ydtext.Visible = False
  1363.         Else
  1364.             If GridBoolean(.Col, 2) Then
  1365.                 Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  1366.                 Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  1367.                 Ydcommand.Visible = True
  1368.             Else
  1369.                 Ydcommand.Visible = False
  1370.             End If
  1371.      
  1372.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  1373.             Ydtext.Top = .CellTop + .Top + Wbkpy
  1374.             
  1375.             If Ydcommand.Visible Then
  1376.                 If Sfblbzkd Then
  1377.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  1378.                 Else
  1379.                     Ydtext.Width = .CellWidth - Wbkpy1
  1380.                 End If
  1381.             Else
  1382.                 Ydtext.Width = .CellWidth - Wbkpy1
  1383.             End If
  1384.             
  1385.             Ydtext.Height = .CellHeight - Wbkpy1
  1386.       
  1387.             If GridInt(.Col, 2) <> 0 Then
  1388.                 Ydtext.MaxLength = GridInt(.Col, 2)
  1389.             Else
  1390.                 Ydtext.MaxLength = 3000
  1391.             End If
  1392.       
  1393.             Call Wbkcl
  1394.       
  1395.             Ydtext.Visible = True
  1396.             Ydtext.SetFocus
  1397.         End If
  1398.     
  1399.         Dqtoprow = .TopRow
  1400.         Dqleftcol = .LeftCol
  1401.     
  1402.         '重置锁值
  1403.         Valilock = False
  1404.         Wbkbhlock = False
  1405.     End With
  1406.  
  1407. End Sub
  1408. Private Function Fun_AllowInput() As Boolean                           '当某种条件成立时禁止文本框激活使单据处于录入状态
  1409.    
  1410.     '如果单据操作状态为浏览状态则不能显示录入载体(通用)
  1411.     If Trim(Lab_OperStatus.Caption) = "1" Then
  1412.         Exit Function
  1413.     End If
  1414.    
  1415.     '[>>
  1416.     
  1417.         '此处可以填写禁止文本框激活使单据处于录入状态的理由
  1418.    
  1419.     '<<]
  1420.    
  1421.     Fun_AllowInput = True
  1422.     
  1423. End Function
  1424. Private Sub Cxxswbk()                                                  'Formresize中重新显示文本框,列表框,帮助按钮(通用)
  1425.                    
  1426.     Dim Wbkpy As Integer, Wbkpy1 As Integer
  1427.     
  1428.     Wbkpy = 30
  1429.     Wbkpy1 = 15
  1430.     
  1431.     With WglrGrid
  1432.         If YdCombo.Visible Then
  1433.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  1434.             YdCombo.Top = .CellTop + .Top + Wbkpy
  1435.             YdCombo.Width = .CellWidth - Wbkpy1
  1436.         End If
  1437.         If Ydcommand.Visible Then
  1438.             Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  1439.             Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  1440.         End If
  1441.         If Ydtext.Visible Then
  1442.             If Ydcommand.Visible Then
  1443.                 If Sfblbzkd Then
  1444.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  1445.                 Else
  1446.                     Ydtext.Width = .CellWidth - Wbkpy1
  1447.                 End If
  1448.             Else
  1449.                 Ydtext.Width = .CellWidth - Wbkpy1
  1450.             End If
  1451.       
  1452.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  1453.             Ydtext.Top = .CellTop + .Top + Wbkpy
  1454.             Ydtext.Height = .CellHeight - Wbkpy1
  1455.         End If
  1456.     End With
  1457. End Sub
  1458. Private Sub Lrsjhx()                                                             '文本框录入数据回写
  1459.   
  1460.     With WglrGrid
  1461.         If YdCombo.Visible Then
  1462.             .Text = Trim(YdCombo.Text)
  1463.         End If
  1464.         If Ydtext.Visible Then
  1465.             .Text = Trim(Ydtext.Text)
  1466.         End If
  1467.    
  1468.         '(如果字段录入内容发生变化,则打开有效性判断锁)
  1469.         If Zdlrqnr <> Trim(.Text) Then
  1470.             Yxxpdlock = False
  1471.             Hyxxpdlock = False
  1472.         End If
  1473.    
  1474.         '隐藏文本框,帮助按钮,列表组合框
  1475.         Call Ycwbk
  1476.    
  1477.     End With
  1478.     
  1479. End Sub
  1480. Private Sub WglrGrid_KeyDown(KeyCode As Integer, Shift As Integer)              '网格快捷键
  1481.   
  1482.     '如果单据操作状态为浏览状态则不能显示录入载体
  1483.     If Trim(Lab_OperStatus.Caption) = "1" Then
  1484.         Exit Sub
  1485.     End If
  1486.     Select Case KeyCode
  1487.         Case vbKeyF2                   '按F2键参照
  1488.             Call xswbk
  1489.             Call Lrzdbz
  1490.     End Select
  1491. End Sub
  1492. Private Sub WglrGrid_KeyPress(KeyAscii As Integer)                              '网格接受键盘录入
  1493.     '当某种条件成立时禁止文本框激活使单据处于录入状态
  1494.     If Not Fun_AllowInput Then
  1495.         Exit Sub
  1496.     End If
  1497.   
  1498.     With WglrGrid
  1499.   
  1500.         '屏 蔽 回 车 键
  1501.         If KeyAscii = vbKeyReturn Then
  1502.             KeyAscii = 0
  1503.             Rowjsq = .Row
  1504.             Coljsq = .Col + 1
  1505.             If Coljsq > .Cols - 1 Then
  1506.                 If Rowjsq < .Rows - 1 Then
  1507.                     Rowjsq = Rowjsq + 1
  1508.                 End If
  1509.                 Coljsq = Qslz
  1510.             End If
  1511.             Do While Rowjsq <= .Rows - 1
  1512.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1513.                     Coljsq = Coljsq + 1
  1514.                     If Coljsq > .Cols - 1 Then
  1515.                         Rowjsq = Rowjsq + 1
  1516.                         Coljsq = Qslz
  1517.                     End If
  1518.                 Else
  1519.                     Exit Do
  1520.                 End If
  1521.             Loop
  1522.           
  1523.             If Rowjsq <= .Rows - 1 Then
  1524.                 .Select Rowjsq, Coljsq
  1525.             End If
  1526.        
  1527.             Exit Sub
  1528.        
  1529.         End If
  1530.      
  1531.         '接受用户录入
  1532.         Select Case KeyAscii
  1533.             Case 0 To 32             '用户输入KeyAscii为0-32的键 如空格
  1534.                 '显示录入载体
  1535.                 Call xswbk
  1536.             Case Else
  1537.                 
  1538.                 '防止非编辑字段SendKeys()出现死循环
  1539.                 If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  1540.                     Exit Sub
  1541.                 End If
  1542.                 
  1543.                 '如果此字段为列表框录入则调入相应列表框
  1544.                 If GridBoolean(.Col, 3) Then
  1545.                    '列表框录入
  1546.                     Call xswbk
  1547.                 Else
  1548.                     Ydtext.Text = ""
  1549.             
  1550.                     '录入限制
  1551.                     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  1552.                     If KeyAscii = 0 Then
  1553.                         Exit Sub
  1554.                     End If
  1555.                     Call xswbk
  1556.                     Ydtext.Text = ""
  1557.                     Valilock = True
  1558.                     SendKeys Chr(KeyAscii), True
  1559.                     DoEvents
  1560.                     Valilock = False
  1561.                 End If
  1562.         End Select
  1563.     End With
  1564. End Sub
  1565. Private Sub Qkwlzd(sjh As Long, Sjl As Long)                            '清空为零字段
  1566.     
  1567.     If Not GridBoolean(Sjl, 5) Then
  1568.         Exit Sub
  1569.     End If
  1570.     
  1571.     With WglrGrid
  1572.         If Val(Trim(.TextMatrix(sjh, Sjl))) = 0 Then
  1573.             .TextMatrix(sjh, Sjl) = ""
  1574.         End If
  1575.     End With
  1576. End Sub
  1577. Private Sub fhyxh()                                                     '返回录入数据有效行,同时让得到焦点网格可见
  1578.     
  1579.     With WglrGrid
  1580.         If .Row >= .FixedRows Then
  1581.             Call Xldqh
  1582.         End If
  1583.     End With
  1584. End Sub
  1585. Private Sub Xldqh()                                                      '显露当前行
  1586.     
  1587.     Dim Toprowte As Long
  1588.     With WglrGrid
  1589.         Toprowte = 0
  1590.         Do While .CellTop + .RowHeight(.Row) + Fzxwghs * Sjhgd > .Height And .TopRow <> Toprowte
  1591.             Toprowte = .TopRow
  1592.             .TopRow = .TopRow + 1
  1593.         Loop
  1594.         Toprowte = 0
  1595.         Do While .CellTop < .FixedRows * .RowHeight(0) And .TopRow <> Toprowte
  1596.             Toprowte = .TopRow
  1597.             If .TopRow > 1 Then
  1598.                 .TopRow = .TopRow - 1
  1599.             End If
  1600.         Loop
  1601.     End With
  1602. End Sub
  1603. Private Sub Xldql()                                                                  '显露当前列
  1604.     
  1605.     Dim Leftcolte As Long
  1606.     With WglrGrid
  1607.         If .Col >= Qslz And .Col >= .FixedCols Then
  1608.             If .LeftCol > .Col Then
  1609.                 .LeftCol = .Col
  1610.             End If
  1611.             Leftcolte = 0
  1612.             Do While .CellLeft + .CellWidth > .Width And .LeftCol <> Leftcolte
  1613.                 Leftcolte = .LeftCol
  1614.                 .LeftCol = .LeftCol + 1
  1615.             Loop
  1616.         End If
  1617.     End With
  1618. End Sub
  1619. Private Sub WglrGrid_BeforeMoveColumn(ByVal Col As Long, Position As Long)           '网格列发生移动时自动交换网格索引信息
  1620.     Call FnBln_RefreshArray(Col, Position, GridStr(), GridInf())
  1621. End Sub
  1622. Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)   '表格格式设置(通用)
  1623.     
  1624.     Select Case Button.Key
  1625.         Case "bcgs"                                       '保存表格格式
  1626.             Call Bcwggs(WglrGrid, GridCode, GridStr())
  1627.         Case "hfmrgs"                                     '恢复默认格式
  1628.             Call Hfmrgs(WglrGrid, GridCode, GridStr())
  1629.     End Select
  1630. End Sub
  1631. Private Sub bbyl(bbylte As Boolean)                    '报表打印预览
  1632.     
  1633.     Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
  1634.     Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
  1635.     Bbxbtgs = 1                                          '报 表 小 标 题 行 数
  1636.     Bbbwhgs = 0                                          '报 表 表 尾 行 数
  1637.     ReDim Bbxbt(1 To Bbxbtgs)
  1638.     ReDim bbxbtzzxs(1 To Bbxbtgs)
  1639.     If Bbbwhgs <> 0 Then
  1640.         ReDim Bbbwh(1 To Bbbwhgs)
  1641.         ReDim Bbbwhzzxs(1 To Bbbwhgs)
  1642.     End If
  1643.     If Trim(TsLabel(4)) = "" Then
  1644.         Bbzbt = ReportTitle
  1645.     Else
  1646.         Bbzbt = Trim(TsLabel(4)) & "(标准表)"
  1647.     End If
  1648.     Call Scyxsjb(WglrGrid)                               '生成报表数据
  1649.     Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
  1650.     If Not bbylte Then
  1651.         Unload DY_Tybbyldy
  1652.     End If
  1653. End Sub