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

企业管理

开发平台:

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