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

企业管理

开发平台:

Visual Basic

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