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

企业管理

开发平台:

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