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

企业管理

开发平台:

Visual Basic

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