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

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{BEEECC20-4D5F-4F8B-BFDC-5D9B6FBDE09D}#1.0#0"; "vsflex8.ocx"
  3. Begin VB.Form CL_MakeVoucherSub 
  4.    BorderStyle     =   3  'Fixed Dialog
  5.    Caption         =   "确认修改科目"
  6.    ClientHeight    =   5805
  7.    ClientLeft      =   45
  8.    ClientTop       =   330
  9.    ClientWidth     =   9375
  10.    HelpContextID   =   130407
  11.    Icon            =   "处理_生成凭证子窗体.frx":0000
  12.    LinkTopic       =   "Form1"
  13.    MaxButton       =   0   'False
  14.    MinButton       =   0   'False
  15.    ScaleHeight     =   5805
  16.    ScaleWidth      =   9375
  17.    ShowInTaskbar   =   0   'False
  18.    StartUpPosition =   2  '屏幕中心
  19.    Begin VB.ComboBox Combo1 
  20.       Height          =   315
  21.       Left            =   1020
  22.       Style           =   2  'Dropdown List
  23.       TabIndex        =   2
  24.       Top             =   5310
  25.       Width           =   2070
  26.    End
  27.    Begin VB.CommandButton cmd_Ok 
  28.       Caption         =   "确定(&O)"
  29.       Height          =   300
  30.       Left            =   6960
  31.       TabIndex        =   0
  32.       Top             =   5370
  33.       Width           =   1120
  34.    End
  35.    Begin VB.CommandButton cmd_Cancel 
  36.       Caption         =   "取消(&C)"
  37.       Height          =   300
  38.       Left            =   8190
  39.       TabIndex        =   1
  40.       Top             =   5370
  41.       Width           =   1120
  42.    End
  43.    Begin VB.TextBox Ydtext 
  44.       BackColor       =   &H00C0FFFF&
  45.       BorderStyle     =   0  'None
  46.       Height          =   300
  47.       Left            =   3270
  48.       MultiLine       =   -1  'True
  49.       TabIndex        =   8
  50.       Top             =   5340
  51.       Visible         =   0   'False
  52.       Width           =   1185
  53.    End
  54.    Begin VB.ComboBox YdCombo 
  55.       Height          =   315
  56.       Left            =   4500
  57.       Style           =   2  'Dropdown List
  58.       TabIndex        =   7
  59.       Top             =   5340
  60.       Visible         =   0   'False
  61.       Width           =   1695
  62.    End
  63.    Begin VB.Timer Timer1 
  64.       Interval        =   1
  65.       Left            =   5250
  66.       Top             =   5310
  67.    End
  68.    Begin VB.CommandButton Ydcommand 
  69.       Height          =   300
  70.       Left            =   6240
  71.       Picture         =   "处理_生成凭证子窗体.frx":1042
  72.       Style           =   1  'Graphical
  73.       TabIndex        =   6
  74.       Top             =   5520
  75.       Visible         =   0   'False
  76.       Width           =   300
  77.    End
  78.    Begin VSFlex8Ctl.VSFlexGrid vsFlex_PzMain 
  79.       Height          =   2475
  80.       Left            =   90
  81.       TabIndex        =   5
  82.       Top             =   6030
  83.       Width           =   4125
  84.       _cx             =   5080
  85.       _cy             =   5080
  86.       Appearance      =   1
  87.       BorderStyle     =   1
  88.       Enabled         =   -1  'True
  89.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  90.          Name            =   "MS Sans Serif"
  91.          Size            =   8.25
  92.          Charset         =   0
  93.          Weight          =   400
  94.          Underline       =   0   'False
  95.          Italic          =   0   'False
  96.          Strikethrough   =   0   'False
  97.       EndProperty
  98.       MousePointer    =   0
  99.       BackColor       =   -2147483643
  100.       ForeColor       =   -2147483640
  101.       BackColorFixed  =   -2147483633
  102.       ForeColorFixed  =   -2147483630
  103.       BackColorSel    =   -2147483635
  104.       ForeColorSel    =   -2147483634
  105.       BackColorBkg    =   -2147483636
  106.       BackColorAlternate=   -2147483643
  107.       GridColor       =   -2147483633
  108.       GridColorFixed  =   -2147483632
  109.       TreeColor       =   -2147483632
  110.       FloodColor      =   192
  111.       SheetBorder     =   -2147483642
  112.       FocusRect       =   1
  113.       HighLight       =   1
  114.       AllowSelection  =   -1  'True
  115.       AllowBigSelection=   -1  'True
  116.       AllowUserResizing=   0
  117.       SelectionMode   =   0
  118.       GridLines       =   1
  119.       GridLinesFixed  =   2
  120.       GridLineWidth   =   1
  121.       Rows            =   1
  122.       Cols            =   7
  123.       FixedRows       =   1
  124.       FixedCols       =   0
  125.       RowHeightMin    =   0
  126.       RowHeightMax    =   0
  127.       ColWidthMin     =   0
  128.       ColWidthMax     =   0
  129.       ExtendLastCol   =   0   'False
  130.       FormatString    =   ""
  131.       ScrollTrack     =   0   'False
  132.       ScrollBars      =   3
  133.       ScrollTips      =   0   'False
  134.       MergeCells      =   0
  135.       MergeCompare    =   0
  136.       AutoResize      =   -1  'True
  137.       AutoSizeMode    =   0
  138.       AutoSearch      =   0
  139.       AutoSearchDelay =   2
  140.       MultiTotals     =   -1  'True
  141.       SubtotalPosition=   1
  142.       OutlineBar      =   0
  143.       OutlineCol      =   0
  144.       Ellipsis        =   0
  145.       ExplorerBar     =   0
  146.       PicturesOver    =   0   'False
  147.       FillStyle       =   0
  148.       RightToLeft     =   0   'False
  149.       PictureType     =   0
  150.       TabBehavior     =   0
  151.       OwnerDraw       =   0
  152.       Editable        =   0
  153.       ShowComboButton =   1
  154.       WordWrap        =   0   'False
  155.       TextStyle       =   0
  156.       TextStyleFixed  =   0
  157.       OleDragMode     =   0
  158.       OleDropMode     =   0
  159.       DataMode        =   0
  160.       VirtualData     =   -1  'True
  161.       DataMember      =   ""
  162.       ComboSearch     =   3
  163.       AutoSizeMouse   =   -1  'True
  164.       FrozenRows      =   0
  165.       FrozenCols      =   0
  166.       AllowUserFreezing=   0
  167.       BackColorFrozen =   0
  168.       ForeColorFrozen =   0
  169.       WallPaperAlignment=   9
  170.       AccessibleName  =   ""
  171.       AccessibleDescription=   ""
  172.       AccessibleValue =   ""
  173.       AccessibleRole  =   24
  174.    End
  175.    Begin VSFlex8Ctl.VSFlexGrid vsFlex_PzChild 
  176.       Height          =   2475
  177.       Left            =   4290
  178.       TabIndex        =   4
  179.       Top             =   6030
  180.       Width           =   4935
  181.       _cx             =   5080
  182.       _cy             =   5080
  183.       Appearance      =   1
  184.       BorderStyle     =   1
  185.       Enabled         =   -1  'True
  186.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  187.          Name            =   "MS Sans Serif"
  188.          Size            =   8.25
  189.          Charset         =   0
  190.          Weight          =   400
  191.          Underline       =   0   'False
  192.          Italic          =   0   'False
  193.          Strikethrough   =   0   'False
  194.       EndProperty
  195.       MousePointer    =   0
  196.       BackColor       =   -2147483643
  197.       ForeColor       =   -2147483640
  198.       BackColorFixed  =   -2147483633
  199.       ForeColorFixed  =   -2147483630
  200.       BackColorSel    =   -2147483635
  201.       ForeColorSel    =   -2147483634
  202.       BackColorBkg    =   -2147483636
  203.       BackColorAlternate=   -2147483643
  204.       GridColor       =   -2147483633
  205.       GridColorFixed  =   -2147483632
  206.       TreeColor       =   -2147483632
  207.       FloodColor      =   192
  208.       SheetBorder     =   -2147483642
  209.       FocusRect       =   1
  210.       HighLight       =   1
  211.       AllowSelection  =   -1  'True
  212.       AllowBigSelection=   -1  'True
  213.       AllowUserResizing=   0
  214.       SelectionMode   =   0
  215.       GridLines       =   1
  216.       GridLinesFixed  =   2
  217.       GridLineWidth   =   1
  218.       Rows            =   1
  219.       Cols            =   29
  220.       FixedRows       =   1
  221.       FixedCols       =   0
  222.       RowHeightMin    =   0
  223.       RowHeightMax    =   0
  224.       ColWidthMin     =   0
  225.       ColWidthMax     =   0
  226.       ExtendLastCol   =   0   'False
  227.       FormatString    =   ""
  228.       ScrollTrack     =   0   'False
  229.       ScrollBars      =   3
  230.       ScrollTips      =   0   'False
  231.       MergeCells      =   0
  232.       MergeCompare    =   0
  233.       AutoResize      =   -1  'True
  234.       AutoSizeMode    =   0
  235.       AutoSearch      =   0
  236.       AutoSearchDelay =   2
  237.       MultiTotals     =   -1  'True
  238.       SubtotalPosition=   1
  239.       OutlineBar      =   0
  240.       OutlineCol      =   0
  241.       Ellipsis        =   0
  242.       ExplorerBar     =   0
  243.       PicturesOver    =   0   'False
  244.       FillStyle       =   0
  245.       RightToLeft     =   0   'False
  246.       PictureType     =   0
  247.       TabBehavior     =   0
  248.       OwnerDraw       =   0
  249.       Editable        =   0
  250.       ShowComboButton =   1
  251.       WordWrap        =   0   'False
  252.       TextStyle       =   0
  253.       TextStyleFixed  =   0
  254.       OleDragMode     =   0
  255.       OleDropMode     =   0
  256.       DataMode        =   0
  257.       VirtualData     =   -1  'True
  258.       DataMember      =   ""
  259.       ComboSearch     =   3
  260.       AutoSizeMouse   =   -1  'True
  261.       FrozenRows      =   0
  262.       FrozenCols      =   0
  263.       AllowUserFreezing=   0
  264.       BackColorFrozen =   0
  265.       ForeColorFrozen =   0
  266.       WallPaperAlignment=   9
  267.       AccessibleName  =   ""
  268.       AccessibleDescription=   ""
  269.       AccessibleValue =   ""
  270.       AccessibleRole  =   24
  271.    End
  272.    Begin VSFlex8Ctl.VSFlexGrid WglrGrid 
  273.       Height          =   5115
  274.       Left            =   90
  275.       TabIndex        =   3
  276.       Top             =   90
  277.       Width           =   9195
  278.       _cx             =   5080
  279.       _cy             =   5080
  280.       Appearance      =   1
  281.       BorderStyle     =   1
  282.       Enabled         =   -1  'True
  283.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  284.          Name            =   "宋体"
  285.          Size            =   9
  286.          Charset         =   134
  287.          Weight          =   400
  288.          Underline       =   0   'False
  289.          Italic          =   0   'False
  290.          Strikethrough   =   0   'False
  291.       EndProperty
  292.       MousePointer    =   0
  293.       BackColor       =   -2147483643
  294.       ForeColor       =   -2147483640
  295.       BackColorFixed  =   -2147483633
  296.       ForeColorFixed  =   -2147483630
  297.       BackColorSel    =   -2147483643
  298.       ForeColorSel    =   -2147483640
  299.       BackColorBkg    =   8421504
  300.       BackColorAlternate=   -2147483643
  301.       GridColor       =   -2147483633
  302.       GridColorFixed  =   -2147483632
  303.       TreeColor       =   -2147483632
  304.       FloodColor      =   192
  305.       SheetBorder     =   -2147483642
  306.       FocusRect       =   1
  307.       HighLight       =   1
  308.       AllowSelection  =   -1  'True
  309.       AllowBigSelection=   -1  'True
  310.       AllowUserResizing=   0
  311.       SelectionMode   =   0
  312.       GridLines       =   1
  313.       GridLinesFixed  =   2
  314.       GridLineWidth   =   1
  315.       Rows            =   5000
  316.       Cols            =   10
  317.       FixedRows       =   1
  318.       FixedCols       =   0
  319.       RowHeightMin    =   0
  320.       RowHeightMax    =   0
  321.       ColWidthMin     =   0
  322.       ColWidthMax     =   0
  323.       ExtendLastCol   =   0   'False
  324.       FormatString    =   ""
  325.       ScrollTrack     =   0   'False
  326.       ScrollBars      =   3
  327.       ScrollTips      =   0   'False
  328.       MergeCells      =   0
  329.       MergeCompare    =   0
  330.       AutoResize      =   -1  'True
  331.       AutoSizeMode    =   0
  332.       AutoSearch      =   0
  333.       AutoSearchDelay =   2
  334.       MultiTotals     =   -1  'True
  335.       SubtotalPosition=   1
  336.       OutlineBar      =   0
  337.       OutlineCol      =   0
  338.       Ellipsis        =   0
  339.       ExplorerBar     =   0
  340.       PicturesOver    =   0   'False
  341.       FillStyle       =   0
  342.       RightToLeft     =   0   'False
  343.       PictureType     =   0
  344.       TabBehavior     =   0
  345.       OwnerDraw       =   0
  346.       Editable        =   0
  347.       ShowComboButton =   1
  348.       WordWrap        =   0   'False
  349.       TextStyle       =   0
  350.       TextStyleFixed  =   0
  351.       OleDragMode     =   0
  352.       OleDropMode     =   0
  353.       DataMode        =   0
  354.       VirtualData     =   -1  'True
  355.       DataMember      =   ""
  356.       ComboSearch     =   3
  357.       AutoSizeMouse   =   -1  'True
  358.       FrozenRows      =   0
  359.       FrozenCols      =   0
  360.       AllowUserFreezing=   0
  361.       BackColorFrozen =   0
  362.       ForeColorFrozen =   0
  363.       WallPaperAlignment=   9
  364.       AccessibleName  =   ""
  365.       AccessibleDescription=   ""
  366.       AccessibleValue =   ""
  367.       AccessibleRole  =   24
  368.    End
  369.    Begin VB.Label Label2 
  370.       Caption         =   "凭证类型:"
  371.       Height          =   255
  372.       Left            =   120
  373.       TabIndex        =   10
  374.       Top             =   5370
  375.       Width           =   825
  376.    End
  377.    Begin VB.Label Lab_OperStatus 
  378.       BackColor       =   &H000080FF&
  379.       Caption         =   "1"
  380.       Height          =   345
  381.       Left            =   6600
  382.       TabIndex        =   9
  383.       Top             =   5430
  384.       Visible         =   0   'False
  385.       Width           =   345
  386.    End
  387. End
  388. Attribute VB_Name = "CL_MakeVoucherSub"
  389. Attribute VB_GlobalNameSpace = False
  390. Attribute VB_Creatable = False
  391. Attribute VB_PredeclaredId = True
  392. Attribute VB_Exposed = False
  393. '**************************************************************************
  394. '*    模 块 名 称 : 生成凭证子窗体
  395. '*    功 能 描 述 :
  396. '*    程序员姓名  : 杨波
  397. '*    最后修改人  : 杨波
  398. '*    最后修改时间: 2000/10/09
  399. '*    备        注: 一 .WglrGrid.TextMatrix(Yxxpdh, 6)中存放生成凭证的各种情况
  400. '**************************************************************************
  401.  
  402. '其它固定使用变量
  403. Dim Tsxx As String                              '系统信息提示(Fixed)
  404. Dim ReportTitle As String                       '报表主标题(Fixed)
  405.    
  406. '以下为固定使用变量(网格)
  407. Dim Cxnrrec As New ADODB.Recordset              '显示查询内容动态集
  408. Dim Dyymctbl As New DY_Dyymsz                   '打印页面窗体变量
  409. Dim GridCode As String                          '显示网格网格代码
  410. Dim GridInf() As Variant                        '整个网格设置信息
  411. Dim Pmbcsjhs As Long                            '屏幕网格保持数据行数(大于等于1)
  412. Dim Fzxwghs As Integer                          '辅助项网格行数(包括合计行)
  413. Dim Sfxshjwg As Boolean                         '是否显示合计网格
  414. Dim Qslz As Long                                '网格隐藏(非操作显示)列数
  415. Dim Sjhgd As Double                             '网格数据行高度
  416. Dim GridBoolean() As Boolean                    '网格列信息(布尔型)
  417. Dim GridStr()  As String                        '网格列信息(字符型)
  418. Dim GridInt() As Integer                        '网格列信息(整型)
  419. Dim Sfblbzkd As Boolean                         '是否保留帮助宽度(字段提供帮助时,是否为按钮保留空间)
  420. Dim Dqlrwgh As Long                             '当前录入数据网格行
  421. Dim Dqlrwgl As Long                             '当前录入数据网格列
  422. Dim Dqlkwgh As Long                             '刚刚离开网格行(不一定为录入行)
  423. Dim Dqlkwgl As Long                             '刚刚离开网格列
  424. Dim Dqtoprow As Long                            '当前录入状态时最上端可视行
  425. Dim Dqleftcol As Long                           '当前录入状态时最左端可视列
  426. Dim Zdlrqnr As String                           '字段录入修改前内容(用来判断内容是否修改)
  427. Dim Wbkbhlock As Boolean                        '文本框改变值锁
  428. Dim Changelock As Boolean                       '网格行列改变控制锁(用来区别用户改变.程序改变)
  429. Dim Gdtlock As Boolean                          '滚动条滚动控制(用来区别用户改变.程序改变)
  430. Dim Yxxpdlock As Boolean                        '字段有效性判断锁(内容不修改不需进行字段有效性判断)
  431. Dim Hyxxpdlock As Boolean                       '行有效性判断锁(字段内容不修改不需进行行有效性判断)
  432. Dim Valilock As Boolean                         '文本框失去焦点是否进行有效性控制(TRUE 为锁定*限用网格录入)
  433. Dim Shsfts As Boolean                           '删除记录行是否提示
  434. Dim Szzls As Integer                            '网格信息数组最大下标值(网格列数-1)
  435. Private Sub cmd_Cancel_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  436.     Unload Me
  437. End Sub
  438. Private Sub cmd_Ok_Click()
  439.     
  440.     Dim count As Long                       '循环变量
  441.     Dim countrow As Integer                 '循环变量
  442.     Dim PzCount As Integer                  '循环变量
  443.     Dim Note As String                      '摘要
  444.     Dim InoutMainIdValue As Integer         '单据主表ID
  445.     Dim InoutSubIdValue As Integer          '单据子表ID
  446.     Dim WuLiaoCodeValue As String           '物料科目编码
  447.     Dim WuliaoNameValue As String           '物料科目名称
  448.     Dim DuifangCodeValue As String          '对方科目编码
  449.     Dim DuifangNameValue As String          '对方科目名称
  450.     Dim ChaYiCodeValue As String            '差异科目编码
  451.     Dim ChaYiNameValue As String            '差异科目名称
  452.     Dim WuLiaoCodeValue1 As String          '物料科目编码
  453.     Dim DuifangCodeValue1 As String         '对方科目编码
  454.     Dim ChaYiCodeValue1 As String           '差异科目编码
  455.     Dim Money As Double                     '金额
  456.     Dim WuLiaoMoney As Double               '物料科目金额
  457.     Dim DuiFangMoney As Double              '对方料日金额
  458.     Dim JieFangMoney As Double              '借方金额
  459.     Dim DaiFangMoney As Double              '贷方金额
  460.     Dim IsInoutMainID As Boolean            '判断单据主表ID是否相同
  461.     Dim PzBillNum As Integer                '凭证单据号
  462.     
  463.     '存货科目、差异科目、对方科目不能全部为空
  464.     For count = WglrGrid.FixedRows To WglrGrid.Rows - WglrGrid.FixedRows
  465.         If WglrGrid.TextMatrix(count, Sydz("007", GridStr(), Szzls)) = "" And WglrGrid.TextMatrix(count, Sydz("008", GridStr(), Szzls)) = "" And WglrGrid.TextMatrix(count, Sydz("009", GridStr(), Szzls)) = "" Then
  466.             Tsxx = "存货科目、差异科目、对方科目不能全部为空!"
  467.             Call Xtxxts(Tsxx, 0, 4)
  468.             Exit Sub
  469.         End If
  470.         Hyxxpdlock = False
  471.         If Not Sjhzyxxpd(count) Then
  472.             Exit Sub
  473.         End If
  474.     Next count
  475.     
  476.     '凭证类别不能为空
  477.     If Trim(Combo1.Text) = "" Then
  478.         Tsxx = "请选择凭证类型"
  479.         Call Xtxxts(Tsxx, 0, 4)
  480.         Exit Sub
  481.     End If
  482.     
  483.     vouchz = Trim(Mid(Trim(Combo1.Text), 1, 2))
  484.     
  485.     '凭证为“生成”
  486.     If CL_MakeVoucher.PzType = 0 Then
  487.     
  488.         With WglrGrid
  489.             
  490.             '向vsflex_pzmain中加入记录
  491.             IsInoutMainID = False
  492.             
  493.             For count = .FixedRows To .Rows - .FixedRows
  494.                 '根据单据类型填充主子表ID
  495.                 Select Case .TextMatrix(count, 4)
  496.                     Case "1301", "1302", "1303"
  497.                         InoutMainIdValue = Trim(.TextMatrix(count, 2))
  498.                         InoutSubIdValue = Trim(.TextMatrix(count, 3))
  499.                     Case Else
  500.                         InoutMainIdValue = Trim(.TextMatrix(count, 0))
  501.                         InoutSubIdValue = Trim(.TextMatrix(count, 1))
  502.                 End Select
  503.                 
  504.                 '合并主表ID相同的单据
  505.                 For countrow = vsFlex_PzMain.FixedRows To vsFlex_PzMain.Rows - vsFlex_PzMain.FixedRows
  506.                     If Trim(vsFlex_PzMain.TextMatrix(countrow, 0)) = InoutMainIdValue And Trim(vsFlex_PzMain.TextMatrix(countrow, 5)) = InoutSubIdValue Then
  507.                         IsInoutMainID = True
  508.                         Exit For
  509.                     End If
  510.                 Next countrow
  511.                 
  512.                 If IsInoutMainID = False Then
  513.                     vsFlex_PzMain.AddItem ""
  514.                     vsFlex_PzMain.TextMatrix(vsFlex_PzMain.Rows - 1, 0) = InoutMainIdValue
  515.                     vsFlex_PzMain.TextMatrix(vsFlex_PzMain.Rows - 1, 1) = Xtrq
  516.                     vsFlex_PzMain.TextMatrix(vsFlex_PzMain.Rows - 1, 2) = 1
  517.                     vsFlex_PzMain.TextMatrix(vsFlex_PzMain.Rows - 1, 4) = Trim(.TextMatrix(count, 6))
  518.                     vsFlex_PzMain.TextMatrix(vsFlex_PzMain.Rows - 1, 5) = InoutSubIdValue
  519.                     vsFlex_PzMain.TextMatrix(vsFlex_PzMain.Rows - 1, 6) = Trim(.TextMatrix(count, 4))
  520.                 Else
  521.                     IsInoutMainID = False
  522.                 End If
  523.                 
  524.             Next count
  525.             
  526.             For PzCount = vsFlex_PzMain.FixedRows To vsFlex_PzMain.Rows - 1
  527.                 
  528.                 InoutMainIdValue = Trim(vsFlex_PzMain.TextMatrix(PzCount, 0))
  529.                 InoutSubIdValue = Trim(vsFlex_PzMain.TextMatrix(PzCount, 5))
  530.                 
  531.                 '非计划价法的出入库单,计划价法出库单,无差异的计划价法入库单,非计划价的调整单,不进行差异处理的计划价调整单
  532.                 If Trim(.TextMatrix(PzCount, 6)) = "1" Or Trim(.TextMatrix(PzCount, 6)) = "4" Then
  533.                     Call InOutMakePz(InoutMainIdValue, InoutSubIdValue)
  534.                 End If
  535.                 
  536.                 '有差异的计划价法入库单
  537.                 If Trim(.TextMatrix(PzCount, 6)) = "2" Then
  538.                     Call InPlanMakePz(InoutMainIdValue, InoutSubIdValue)
  539.                 End If
  540.                 
  541.                 '进行差异处理的计划价调整单
  542.                 If Trim(.TextMatrix(PzCount, 6)) = "3" Then
  543.                     Call PlanAdjustPz(InoutMainIdValue, InoutSubIdValue)
  544.                 End If
  545.                 
  546.                 '差异结转单
  547.                 If Trim(.TextMatrix(PzCount, 6)) = "5" Then
  548.                     Call EvaluPz(InoutMainIdValue)
  549.                 End If
  550.                 
  551.             Next PzCount
  552.             
  553.         End With
  554.         
  555.         CL_PzFrm.lbl_Tag = 0
  556.         
  557.     End If
  558.     
  559.     Dim Same As Boolean
  560.     
  561.     '合并生成凭证
  562.     If CL_MakeVoucher.PzType = 1 Then
  563.         
  564.         With WglrGrid
  565.             
  566.             '向vsflex_pzmain中加入记录,物料科目、对方科目、差异科目都相同合并
  567.             For count = .FixedRows To .Rows - .FixedRows
  568.             
  569.                 WuLiaoCodeValue = Trim(.TextMatrix(count, Sydz("007", GridStr(), Szzls)))
  570.                 ChaYiCodeValue = Trim(.TextMatrix(count, Sydz("008", GridStr(), Szzls)))
  571.                 DuifangCodeValue = Trim(.TextMatrix(count, Sydz("009", GridStr(), Szzls)))
  572.                 
  573.                 For countrow = vsFlex_PzMain.FixedRows To vsFlex_PzMain.Rows - vsFlex_PzMain.FixedRows
  574.                     
  575.                     WuLiaoCodeValue1 = Trim(vsFlex_PzMain.TextMatrix(countrow, 0))
  576.                     ChaYiCodeValue1 = Trim(vsFlex_PzMain.TextMatrix(countrow, 1))
  577.                     DuifangCodeValue1 = Trim(vsFlex_PzMain.TextMatrix(countrow, 2))
  578.                     
  579.                     If WuLiaoCodeValue = WuLiaoCodeValue1 And ChaYiCodeValue = ChaYiCodeValue1 And DuifangCodeValue = DuifangCodeValue1 Then
  580.                         Same = True
  581.                         Exit For
  582.                     End If
  583.                     Same = False
  584.                 Next countrow
  585.                 
  586.                 If Not Same Then
  587.                     vsFlex_PzMain.AddItem ""
  588.                     vsFlex_PzMain.TextMatrix(countrow, 0) = WuLiaoCodeValue
  589.                     vsFlex_PzMain.TextMatrix(countrow, 1) = ChaYiCodeValue
  590.                     vsFlex_PzMain.TextMatrix(countrow, 2) = DuifangCodeValue
  591.                     vsFlex_PzMain.TextMatrix(countrow, 4) = Trim(.TextMatrix(count, Sydz("011", GridStr(), Szzls)))
  592.                 End If
  593.                 
  594.             Next count
  595.             
  596.             '根据物料科目、对方科目、差异科目计算借方、贷方金额
  597.             For countrow = vsFlex_PzMain.FixedRows To vsFlex_PzMain.Rows - vsFlex_PzMain.FixedRows
  598.                 
  599.                 WuLiaoCodeValue1 = Trim(vsFlex_PzMain.TextMatrix(countrow, 0))
  600.                 ChaYiCodeValue1 = Trim(vsFlex_PzMain.TextMatrix(countrow, 1))
  601.                 DuifangCodeValue1 = Trim(vsFlex_PzMain.TextMatrix(countrow, 2))
  602.                 Note = Trim(.TextMatrix(countrow, Sydz("010", GridStr(), Szzls)))
  603.                 
  604.                 WuLiaoMoney = 0
  605.                 DuiFangMoney = 0
  606.                 JieFangMoney = 0
  607.                 DaiFangMoney = 0
  608.                 
  609.                 For count = .FixedRows To .Rows - .FixedRows
  610.                 
  611.                     WuLiaoCodeValue = Trim(.TextMatrix(count, Sydz("007", GridStr(), Szzls)))
  612.                     ChaYiCodeValue = Trim(.TextMatrix(count, Sydz("008", GridStr(), Szzls)))
  613.                     DuifangCodeValue = Trim(.TextMatrix(count, Sydz("009", GridStr(), Szzls)))
  614.                     
  615.                     If WuLiaoCodeValue = WuLiaoCodeValue1 And ChaYiCodeValue = ChaYiCodeValue1 And DuifangCodeValue = DuifangCodeValue1 Then
  616.                         WuliaoNameValue = Trim(.TextMatrix(count, Sydz("004", GridStr(), Szzls)))
  617.                         ChaYiNameValue = Trim(.TextMatrix(count, Sydz("005", GridStr(), Szzls)))
  618.                         DuifangNameValue = Trim(.TextMatrix(count, Sydz("006", GridStr(), Szzls)))
  619.                         
  620.                         Select Case WglrGrid.TextMatrix(count, 6)
  621.                             Case "3", "5"
  622.                                 
  623.                                 If Trim(WglrGrid.TextMatrix(count, 4)) = "1303" Then
  624.                                     JieFangMoney = JieFangMoney + Format(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  625.                                     DaiFangMoney = DaiFangMoney + Format(WglrGrid.TextMatrix(count, Sydz("015", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  626.                                 Else
  627.                                     JieFangMoney = JieFangMoney + Format(WglrGrid.TextMatrix(count, Sydz("016", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  628.                                     DaiFangMoney = DaiFangMoney + Format(WglrGrid.TextMatrix(count, Sydz("017", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  629.                                 End If
  630.                                 
  631.                                 If JieFangMoney <> 0 Then
  632.                                     DuiFangMoney = JieFangMoney
  633.                                 Else
  634.                                     DuiFangMoney = DaiFangMoney
  635.                                 End If
  636.        
  637.                             Case Else
  638.                                 
  639.                                 If Trim(.TextMatrix(count, Sydz("011", GridStr(), Szzls))) And Trim(.TextMatrix(count, 5)) = "计划价法" Then
  640.                                     WuLiaoMoney = WuLiaoMoney + Format(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  641.                                     DuiFangMoney = DuiFangMoney + Format(Val(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls))) + Val(WglrGrid.TextMatrix(count, Sydz("016", GridStr(), Szzls))) - Val(WglrGrid.TextMatrix(count, Sydz("017", GridStr(), Szzls))), "#####." + String(Xtjexsws, "0"))
  642.                                 Else
  643.                                     WuLiaoMoney = WuLiaoMoney + Format(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  644.                                     DuiFangMoney = DuiFangMoney + Format(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  645.                                 End If
  646.                                 
  647.                                 If Not Trim(.TextMatrix(count, Sydz("011", GridStr(), Szzls))) Then
  648.                                     WuLiaoMoney = WuLiaoMoney + Format(WglrGrid.TextMatrix(count, Sydz("015", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  649.                                     DuiFangMoney = DuiFangMoney + Format(WglrGrid.TextMatrix(count, Sydz("015", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  650.                                 End If
  651.                                 
  652.                                 JieFangMoney = JieFangMoney + Format(WglrGrid.TextMatrix(count, Sydz("016", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  653.                                 DaiFangMoney = DaiFangMoney + Format(WglrGrid.TextMatrix(count, Sydz("017", GridStr(), Szzls)), "#####." + String(Xtjexsws, "0"))
  654.                         End Select
  655.                     End If
  656.                     
  657.                 Next count
  658.                 
  659.                 If WuLiaoCodeValue1 <> "" Then
  660.                     vsFlex_PzChild.AddItem ""
  661.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  662.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = WuLiaoCodeValue1
  663.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = WuliaoNameValue
  664.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "1"
  665.                     If Trim(vsFlex_PzMain.TextMatrix(countrow, 4)) Then
  666.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = WuLiaoMoney
  667.                     Else
  668.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 5) = WuLiaoMoney
  669.                     End If
  670.                 End If
  671.                 
  672.                 If DuifangCodeValue1 <> "" Then
  673.                     vsFlex_PzChild.AddItem ""
  674.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  675.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = DuifangCodeValue1
  676.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = DuifangNameValue
  677.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "2"
  678.                     If Trim(vsFlex_PzMain.TextMatrix(countrow, 4)) Then
  679.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 5) = DuiFangMoney
  680.                     Else
  681.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = DuiFangMoney
  682.                     End If
  683.                 End If
  684.                 
  685.                 If ChaYiCodeValue1 <> "" Then
  686.                     vsFlex_PzChild.AddItem ""
  687.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  688.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = ChaYiCodeValue1
  689.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = ChaYiNameValue
  690.                     If Val(JieFangMoney) <> 0 Then
  691.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = JieFangMoney
  692.                     End If
  693.                     If Val(DaiFangMoney) <> 0 Then
  694.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 5) = DaiFangMoney
  695.                     End If
  696.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "3"
  697.                 End If
  698.                 
  699.             Next countrow
  700.             
  701.         End With
  702.         CL_PzFrm.lbl_Tag = 1
  703.     End If
  704.     
  705.     Me.Hide
  706.     
  707.     CL_PzFrm.LoadMassage = 0
  708.     CL_PzFrm.Show 1
  709.     
  710. End Sub
  711. Private Sub InOutMakePz(InoutMainIdValue As Integer, InoutSubIdValue As Integer)
  712.     
  713.     Dim count As Integer                    '循环变量
  714.     Dim Note As String                      '摘要
  715.     Dim WuLiaoCodeValue As String           '存货科目代码
  716.     Dim WuliaoNameValue As String           '存货科目名称
  717.     Dim ISinout As Boolean                  '收发记录标志
  718.     Dim Money As Double                     '金额
  719.     Dim countrow As Integer                 '循环变量
  720.     Dim IsPzInoutMainID As Boolean
  721.     Dim DuifangCodeValue As String          '对方科目编码
  722.     Dim DuifangNameValue As String          '对方科目名称
  723.     
  724.     With WglrGrid
  725.     
  726.         '计算物料科目的借贷金额
  727.         For count = .FixedRows To .Rows - 1
  728.                     
  729.             If Trim(.TextMatrix(count, 0)) = InoutMainIdValue And Trim(.TextMatrix(count, 1)) = InoutSubIdValue Then
  730.             
  731.                 Note = Trim(.TextMatrix(count, Sydz("010", GridStr(), Szzls)))
  732.                 WuLiaoCodeValue = Trim(.TextMatrix(count, Sydz("007", GridStr(), Szzls)))
  733.                 WuliaoNameValue = Trim(.TextMatrix(count, Sydz("004", GridStr(), Szzls)))
  734.                 ISinout = Trim(.TextMatrix(count, Sydz("011", GridStr(), Szzls)))
  735.                 
  736.                 If ISinout Then
  737.                     Money = Val(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls)))
  738.                 Else
  739.                     Money = Val(WglrGrid.TextMatrix(count, Sydz("015", GridStr(), Szzls)))
  740.                 End If
  741.                 
  742.                 For countrow = vsFlex_PzChild.FixedRows To vsFlex_PzChild.Rows - 1
  743.                     If Trim(vsFlex_PzChild.TextMatrix(countrow, 0)) = InoutMainIdValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 28)) = InoutSubIdValue Then
  744.                         If Trim(vsFlex_PzChild.TextMatrix(countrow, 2)) = WuLiaoCodeValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 6)) = "1" Then
  745.                             IsPzInoutMainID = True
  746.                             If ISinout Then
  747.                                 vsFlex_PzChild.TextMatrix(countrow, 4) = Val(vsFlex_PzChild.TextMatrix(countrow, 4)) + Money
  748.                             Else
  749.                                 vsFlex_PzChild.TextMatrix(countrow, 5) = Val(vsFlex_PzChild.TextMatrix(countrow, 5)) + Money
  750.                             End If
  751.                             Exit For
  752.                         Else
  753.                             IsPzInoutMainID = False
  754.                         End If
  755.                     Else
  756.                         IsPzInoutMainID = False
  757.                     End If
  758.                 Next countrow
  759.                         
  760.                 If IsPzInoutMainID = False Then
  761.                     vsFlex_PzChild.AddItem ""
  762.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 0) = InoutMainIdValue
  763.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  764.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = WuLiaoCodeValue
  765.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = WuliaoNameValue
  766.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "1"
  767.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 28) = InoutSubIdValue
  768.                     
  769.                     If ISinout Then
  770.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = Money
  771.                     Else
  772.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 5) = Money
  773.                     End If
  774.                 End If
  775.             End If
  776.                         
  777.         Next count
  778.         
  779.         '计算对方科目的借贷金额
  780.         For count = .FixedRows To .Rows - 1
  781.     
  782.             If Trim(.TextMatrix(count, 0)) = InoutMainIdValue And Trim(.TextMatrix(count, 1)) = InoutSubIdValue Then
  783.             
  784.                 Note = Trim(.TextMatrix(count, Sydz("010", GridStr(), Szzls)))
  785.                 DuifangCodeValue = Trim(.TextMatrix(count, Sydz("009", GridStr(), Szzls)))
  786.                 DuifangNameValue = Trim(.TextMatrix(count, Sydz("006", GridStr(), Szzls)))
  787.                 ISinout = Trim(.TextMatrix(count, Sydz("011", GridStr(), Szzls)))
  788.                 
  789.                 If ISinout Then
  790.                     Money = Trim(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls)))
  791.                 Else
  792.                     Money = Trim(WglrGrid.TextMatrix(count, Sydz("015", GridStr(), Szzls)))
  793.                 End If
  794.                         
  795.                 For countrow = vsFlex_PzChild.FixedRows To vsFlex_PzChild.Rows - 1
  796.                     If Trim(vsFlex_PzChild.TextMatrix(countrow, 0)) = InoutMainIdValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 28)) = InoutSubIdValue Then
  797.                         If Trim(vsFlex_PzChild.TextMatrix(countrow, 2)) = DuifangCodeValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 6)) = "2" Then
  798.                             IsPzInoutMainID = True
  799.                             If ISinout Then
  800.                                 vsFlex_PzChild.TextMatrix(countrow, 5) = Val(vsFlex_PzChild.TextMatrix(countrow, 5)) + Money
  801.                             Else
  802.                                 vsFlex_PzChild.TextMatrix(countrow, 4) = Val(vsFlex_PzChild.TextMatrix(countrow, 4)) + Money
  803.                             End If
  804.                             Exit For
  805.                         Else
  806.                             IsPzInoutMainID = False
  807.                         End If
  808.                     Else
  809.                         IsPzInoutMainID = False
  810.                     End If
  811.                 Next countrow
  812.                         
  813.                 If IsPzInoutMainID = False Then
  814.                     vsFlex_PzChild.AddItem ""
  815.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 0) = InoutMainIdValue
  816.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  817.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = DuifangCodeValue
  818.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = DuifangNameValue
  819.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "2"
  820.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 28) = InoutSubIdValue
  821.                     If ISinout Then
  822.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 5) = Money
  823.                     Else
  824.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = Money
  825.                     End If
  826.                 End If
  827.             End If
  828.                         
  829.         Next count
  830.     End With
  831.     
  832. End Sub
  833. Private Sub InPlanMakePz(InoutMainIdValue As Integer, InoutSubIdValue As Integer)
  834.     
  835.     Dim count As Integer                    '循环变量
  836.     Dim Note As String                      '摘要
  837.     Dim WuLiaoCodeValue As String           '存货科目代码
  838.     Dim WuliaoNameValue As String           '存货科目名称
  839.     Dim ISinout As Boolean                  '收发记录标志
  840.     Dim Money As Double                     '金额
  841.     Dim countrow As Integer                 '循环变量
  842.     Dim IsPzInoutMainID As Boolean
  843.     Dim DuifangCodeValue As String          '对方科目代码
  844.     Dim DuifangNameValue As String          '对方科目名称
  845.     Dim ChaYiCodeValue As String            '差异科目代码
  846.     Dim ChaYiNameValue As String            '差异科目名称
  847.     Dim JieFangMoney As Double              '借方金额
  848.     Dim DaiFangMoney As Double              '贷方金额
  849.     
  850.     With WglrGrid
  851.         '计算物料科目的借贷金额
  852.         For count = .FixedRows To .Rows - 1
  853.                     
  854.             If Trim(.TextMatrix(count, 0)) = InoutMainIdValue And Trim(.TextMatrix(count, 1)) = InoutSubIdValue Then
  855.             
  856.                 Note = Trim(.TextMatrix(count, Sydz("010", GridStr(), Szzls)))
  857.                 WuLiaoCodeValue = Trim(.TextMatrix(count, Sydz("007", GridStr(), Szzls)))
  858.                 WuliaoNameValue = Trim(.TextMatrix(count, Sydz("004", GridStr(), Szzls)))
  859.                 ISinout = Trim(.TextMatrix(count, Sydz("011", GridStr(), Szzls)))
  860.                 Money = Trim(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls)))
  861.                 If ISinout Then
  862.                     For countrow = vsFlex_PzChild.FixedRows To vsFlex_PzChild.Rows - 1
  863.                         If Trim(vsFlex_PzChild.TextMatrix(countrow, 0)) = InoutMainIdValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 28)) = InoutSubIdValue Then
  864.                             If Trim(vsFlex_PzChild.TextMatrix(countrow, 2)) = WuLiaoCodeValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 6)) = "1" Then
  865.                                 IsPzInoutMainID = True
  866.                                 vsFlex_PzChild.TextMatrix(countrow, 4) = Val(vsFlex_PzChild.TextMatrix(countrow, 4)) + Money
  867.                                 Exit For
  868.                             Else
  869.                                 IsPzInoutMainID = False
  870.                             End If
  871.                         Else
  872.                             IsPzInoutMainID = False
  873.                         End If
  874.                     Next countrow
  875.                             
  876.                     If IsPzInoutMainID = False Then
  877.                         vsFlex_PzChild.AddItem ""
  878.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 0) = InoutMainIdValue
  879.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  880.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = WuLiaoCodeValue
  881.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = WuliaoNameValue
  882.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "1"
  883.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = Money
  884.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 28) = InoutSubIdValue
  885.                     End If
  886.                 End If
  887.             End If
  888.                         
  889.         Next count
  890.         
  891.         '计算对方科目的借贷金额
  892.         For count = .FixedRows To .Rows - 1
  893.     
  894.             If Trim(.TextMatrix(count, 0)) = InoutMainIdValue And Trim(.TextMatrix(count, 1)) = InoutSubIdValue Then
  895.             
  896.                 Note = Trim(.TextMatrix(count, Sydz("010", GridStr(), Szzls)))
  897.                 DuifangCodeValue = Trim(.TextMatrix(count, Sydz("009", GridStr(), Szzls)))
  898.                 DuifangNameValue = Trim(.TextMatrix(count, Sydz("006", GridStr(), Szzls)))
  899.                 ISinout = Trim(.TextMatrix(count, Sydz("011", GridStr(), Szzls)))
  900.                 Money = Val(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls))) + Val(WglrGrid.TextMatrix(count, Sydz("016", GridStr(), Szzls))) - Val(WglrGrid.TextMatrix(count, Sydz("017", GridStr(), Szzls)))
  901.                         
  902.                 If ISinout Then
  903.                     For countrow = vsFlex_PzChild.FixedRows To vsFlex_PzChild.Rows - 1
  904.                         If Trim(vsFlex_PzChild.TextMatrix(countrow, 0)) = InoutMainIdValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 28)) = InoutSubIdValue Then
  905.                             If Trim(vsFlex_PzChild.TextMatrix(countrow, 2)) = DuifangCodeValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 6)) = "2" Then
  906.                                 IsPzInoutMainID = True
  907.                                 vsFlex_PzChild.TextMatrix(countrow, 5) = Val(vsFlex_PzChild.TextMatrix(countrow, 5)) + Money
  908.                             Else
  909.                                 IsPzInoutMainID = False
  910.                             End If
  911.                         Else
  912.                             IsPzInoutMainID = False
  913.                         End If
  914.                     Next countrow
  915.                             
  916.                     If IsPzInoutMainID = False Then
  917.                         vsFlex_PzChild.AddItem ""
  918.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 0) = InoutMainIdValue
  919.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  920.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = DuifangCodeValue
  921.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = DuifangNameValue
  922.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "2"
  923.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 5) = Money
  924.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 28) = InoutSubIdValue
  925.                     End If
  926.                 End If
  927.             End If
  928.                         
  929.         Next count
  930.         
  931.         '计算差异科目的借贷金额
  932.         For count = .FixedRows To .Rows - 1
  933.         
  934.             If Trim(.TextMatrix(count, 0)) = InoutMainIdValue And Trim(.TextMatrix(count, 1)) = InoutSubIdValue Then
  935.                         
  936.                 Note = Trim(.TextMatrix(count, Sydz("010", GridStr(), Szzls)))
  937.                 ChaYiCodeValue = Trim(.TextMatrix(count, Sydz("008", GridStr(), Szzls)))
  938.                 ChaYiNameValue = Trim(.TextMatrix(count, Sydz("005", GridStr(), Szzls)))
  939.                 JieFangMoney = Trim(WglrGrid.TextMatrix(count, Sydz("016", GridStr(), Szzls)))
  940.                 DaiFangMoney = Trim(WglrGrid.TextMatrix(count, Sydz("017", GridStr(), Szzls)))
  941.                             
  942.                 For countrow = vsFlex_PzChild.FixedRows To vsFlex_PzChild.Rows - 1
  943.                     If Trim(vsFlex_PzChild.TextMatrix(countrow, 0)) = InoutMainIdValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 28)) = InoutSubIdValue Then
  944.                         If Trim(.TextMatrix(count, Sydz("008", GridStr(), Szzls))) <> "" Then
  945.                             If Trim(vsFlex_PzChild.TextMatrix(countrow, 2)) = DuifangCodeValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 6)) = "3" Then
  946.                                 IsPzInoutMainID = True
  947.                                 vsFlex_PzChild.TextMatrix(countrow, 4) = Val(vsFlex_PzChild.TextMatrix(countrow, 4)) + JieFangMoney
  948.                                 vsFlex_PzChild.TextMatrix(countrow, 5) = Val(vsFlex_PzChild.TextMatrix(countrow, 5)) + DaiFangMoney
  949.                                 Exit For
  950.                             Else
  951.                                 IsPzInoutMainID = False
  952.                             End If
  953.                         Else
  954.                             IsPzInoutMainID = True
  955.                         End If
  956.                     Else
  957.                         IsPzInoutMainID = False
  958.                     End If
  959.                 Next countrow
  960.                             
  961.                 If IsPzInoutMainID = False Then
  962.                     vsFlex_PzChild.AddItem ""
  963.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 0) = InoutMainIdValue
  964.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  965.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = ChaYiCodeValue
  966.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = ChaYiNameValue
  967.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 28) = InoutSubIdValue
  968.                     If Val(JieFangMoney) <> 0 Then
  969.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = JieFangMoney
  970.                     End If
  971.                     If Val(DaiFangMoney) <> 0 Then
  972.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 5) = DaiFangMoney
  973.                     End If
  974.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "3"
  975.                 End If
  976.             End If
  977.                             
  978.         Next count
  979.     End With
  980.     
  981. End Sub
  982. Private Sub PlanAdjustPz(InoutMainIdValue As Integer, InoutSubIdValue As Integer)
  983.     
  984.     Dim count As Integer                    '循环变量
  985.     Dim Note As String                      '摘要
  986.     Dim ISinout As Boolean                  '收发记录标志
  987.     Dim Money As Double                     '金额
  988.     Dim countrow As Integer                 '循环变量
  989.     Dim IsPzInoutMainID As Boolean
  990.     Dim DuifangCodeValue As String          '对方科目代码
  991.     Dim DuifangNameValue As String          '对方科目名称
  992.     Dim ChaYiCodeValue As String            '差异科目代码
  993.     Dim ChaYiNameValue As String            '差异科目名称
  994.     Dim JieFangMoney As Double              '借方金额
  995.     Dim DaiFangMoney As Double              '贷方金额
  996.     
  997.     With WglrGrid
  998.         
  999.         '计算对方科目的借贷金额
  1000.         For count = .FixedRows To .Rows - 1
  1001.             
  1002.             If Trim(.TextMatrix(count, 2)) = InoutMainIdValue And Trim(.TextMatrix(count, 3)) = InoutSubIdValue Then
  1003.             
  1004.                 Note = Trim(.TextMatrix(count, Sydz("010", GridStr(), Szzls)))
  1005.                 DuifangCodeValue = Trim(.TextMatrix(count, Sydz("009", GridStr(), Szzls)))
  1006.                 DuifangNameValue = Trim(.TextMatrix(count, Sydz("006", GridStr(), Szzls)))
  1007.                 ISinout = Trim(.TextMatrix(count, Sydz("011", GridStr(), Szzls)))
  1008.                 
  1009.                 If Trim(.TextMatrix(count, 4)) = "1303" Then
  1010.                     If ISinout Then
  1011.                         Money = Val(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls)))
  1012.                     Else
  1013.                         Money = Val(WglrGrid.TextMatrix(count, Sydz("015", GridStr(), Szzls)))
  1014.                     End If
  1015.                 Else
  1016.                     If ISinout Then
  1017.                         Money = Val(WglrGrid.TextMatrix(count, Sydz("016", GridStr(), Szzls)))
  1018.                     Else
  1019.                         Money = Val(WglrGrid.TextMatrix(count, Sydz("017", GridStr(), Szzls)))
  1020.                     End If
  1021.                 End If
  1022.                 
  1023.                 For countrow = vsFlex_PzChild.FixedRows To vsFlex_PzChild.Rows - 1
  1024.                     If Trim(vsFlex_PzChild.TextMatrix(countrow, 0)) = InoutMainIdValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 28)) = InoutSubIdValue Then
  1025.                         If Trim(vsFlex_PzChild.TextMatrix(countrow, 2)) = DuifangCodeValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 6)) = "2" Then
  1026.                             IsPzInoutMainID = True
  1027.                             If ISinout Then
  1028.                                 vsFlex_PzChild.TextMatrix(countrow, 5) = Val(vsFlex_PzChild.TextMatrix(countrow, 5)) + Money
  1029.                             Else
  1030.                                 vsFlex_PzChild.TextMatrix(countrow, 4) = Val(vsFlex_PzChild.TextMatrix(countrow, 4)) + Money
  1031.                             End If
  1032.                         Else
  1033.                             IsPzInoutMainID = False
  1034.                         End If
  1035.                     Else
  1036.                         IsPzInoutMainID = False
  1037.                     End If
  1038.                 Next countrow
  1039.                         
  1040.                 If IsPzInoutMainID = False Then
  1041.                     vsFlex_PzChild.AddItem ""
  1042.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 0) = InoutMainIdValue
  1043.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  1044.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = DuifangCodeValue
  1045.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = DuifangNameValue
  1046.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "2"
  1047.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 28) = InoutSubIdValue
  1048.                     If ISinout Then
  1049.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 5) = Money
  1050.                     Else
  1051.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = Money
  1052.                     End If
  1053.                 End If
  1054.                 
  1055.                 
  1056.             End If
  1057.                         
  1058.         Next count
  1059.         
  1060.         '计算差异科目的借贷金额
  1061.         For count = .FixedRows To .Rows - 1
  1062.         
  1063.             If Trim(.TextMatrix(count, 2)) = InoutMainIdValue And Trim(.TextMatrix(count, 3)) = InoutSubIdValue Then
  1064.                         
  1065.                 Note = Trim(.TextMatrix(count, Sydz("010", GridStr(), Szzls)))
  1066.                 ChaYiCodeValue = Trim(.TextMatrix(count, Sydz("008", GridStr(), Szzls)))
  1067.                 ChaYiNameValue = Trim(.TextMatrix(count, Sydz("005", GridStr(), Szzls)))
  1068.                 ISinout = Trim(.TextMatrix(count, Sydz("011", GridStr(), Szzls)))
  1069.                 
  1070.                 If Trim(.TextMatrix(count, 4)) = "1303" Then
  1071.                     If ISinout Then
  1072.                         JieFangMoney = Val(WglrGrid.TextMatrix(count, Sydz("013", GridStr(), Szzls)))
  1073.                     Else
  1074.                         DaiFangMoney = Val(WglrGrid.TextMatrix(count, Sydz("015", GridStr(), Szzls)))
  1075.                     End If
  1076.                 Else
  1077.                     If ISinout Then
  1078.                         JieFangMoney = Val(WglrGrid.TextMatrix(count, Sydz("016", GridStr(), Szzls)))
  1079.                     Else
  1080.                         DaiFangMoney = Val(WglrGrid.TextMatrix(count, Sydz("017", GridStr(), Szzls)))
  1081.                     End If
  1082.                 End If
  1083.                           
  1084.                 For countrow = vsFlex_PzChild.FixedRows To vsFlex_PzChild.Rows - 1
  1085.                     If Trim(vsFlex_PzChild.TextMatrix(countrow, 0)) = InoutMainIdValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 28)) = InoutSubIdValue Then
  1086.                         If Trim(.TextMatrix(count, Sydz("008", GridStr(), Szzls))) <> "" Then
  1087.                             If Trim(vsFlex_PzChild.TextMatrix(countrow, 2)) = DuifangCodeValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 6)) = "3" Then
  1088.                                 IsPzInoutMainID = True
  1089.                                 If ISinout Then
  1090.                                     vsFlex_PzChild.TextMatrix(countrow, 4) = Val(vsFlex_PzChild.TextMatrix(countrow, 4)) + JieFangMoney
  1091.                                 Else
  1092.                                     vsFlex_PzChild.TextMatrix(countrow, 5) = Val(vsFlex_PzChild.TextMatrix(countrow, 5)) + DaiFangMoney
  1093.                                 End If
  1094.                                 Exit For
  1095.                             Else
  1096.                                 IsPzInoutMainID = False
  1097.                             End If
  1098.                         Else
  1099.                             IsPzInoutMainID = True
  1100.                         End If
  1101.                     Else
  1102.                         IsPzInoutMainID = False
  1103.                     End If
  1104.                 Next countrow
  1105.                             
  1106.                 If IsPzInoutMainID = False Then
  1107.                     vsFlex_PzChild.AddItem ""
  1108.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 0) = InoutMainIdValue
  1109.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  1110.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = ChaYiCodeValue
  1111.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = ChaYiNameValue
  1112.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 28) = InoutSubIdValue
  1113.                     If Val(JieFangMoney) <> 0 Then
  1114.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = JieFangMoney
  1115.                     End If
  1116.                     If Val(DaiFangMoney) <> 0 Then
  1117.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 5) = DaiFangMoney
  1118.                     End If
  1119.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "3"
  1120.                 End If
  1121.             End If
  1122.                             
  1123.         Next count
  1124.         
  1125.         
  1126.     End With
  1127.     
  1128. End Sub
  1129. Private Sub EvaluPz(InoutMainIdValue As Integer)
  1130.     Dim count As Integer                    '循环变量
  1131.     Dim Note As String                      '摘要
  1132.     Dim ISinout As Boolean                  '收发记录标志
  1133.     Dim Money As Double                     '金额
  1134.     Dim countrow As Integer                 '循环变量
  1135.     Dim IsPzInoutMainID As Boolean
  1136.     Dim DuifangCodeValue As String          '对方科目代码
  1137.     Dim DuifangNameValue As String          '对方科目名称
  1138.     Dim ChaYiCodeValue As String            '差异科目代码
  1139.     Dim ChaYiNameValue As String            '差异科目名称
  1140.     Dim JieFangMoney As Double              '借方金额
  1141.     Dim DaiFangMoney As Double              '贷方金额
  1142.     
  1143.     With WglrGrid
  1144.         '计算对方科目的借贷金额
  1145.         For count = .FixedRows To .Rows - 1
  1146.     
  1147.             If Trim(.TextMatrix(count, 0)) = InoutMainIdValue Then
  1148.             
  1149.                 Note = Trim(.TextMatrix(count, Sydz("010", GridStr(), Szzls)))
  1150.                 DuifangCodeValue = Trim(.TextMatrix(count, Sydz("009", GridStr(), Szzls)))
  1151.                 DuifangNameValue = Trim(.TextMatrix(count, Sydz("006", GridStr(), Szzls)))
  1152.                 Money = Val(WglrGrid.TextMatrix(count, Sydz("017", GridStr(), Szzls)))
  1153.                 
  1154.                 For countrow = vsFlex_PzChild.FixedRows To vsFlex_PzChild.Rows - 1
  1155.                     If Trim(vsFlex_PzChild.TextMatrix(countrow, 0)) = InoutMainIdValue Then
  1156.                         If Trim(vsFlex_PzChild.TextMatrix(countrow, 2)) = DuifangCodeValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 6)) = "2" Then
  1157.                             IsPzInoutMainID = True
  1158.                             vsFlex_PzChild.TextMatrix(countrow, 4) = Val(vsFlex_PzChild.TextMatrix(countrow, 4)) + Money
  1159.                         Else
  1160.                             IsPzInoutMainID = False
  1161.                         End If
  1162.                     Else
  1163.                         IsPzInoutMainID = False
  1164.                     End If
  1165.                 Next countrow
  1166.                         
  1167.                 If IsPzInoutMainID = False Then
  1168.                     vsFlex_PzChild.AddItem ""
  1169.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 0) = InoutMainIdValue
  1170.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  1171.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = DuifangCodeValue
  1172.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = DuifangNameValue
  1173.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "2"
  1174.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = Money
  1175.                 End If
  1176.             End If
  1177.                         
  1178.         Next count
  1179.         
  1180.         '计算差异科目的借贷金额
  1181.         For count = .FixedRows To .Rows - 1
  1182.         
  1183.             If Trim(.TextMatrix(count, 0)) = InoutMainIdValue Then
  1184.                         
  1185.                 Note = Trim(.TextMatrix(count, Sydz("010", GridStr(), Szzls)))
  1186.                 ChaYiCodeValue = Trim(.TextMatrix(count, Sydz("008", GridStr(), Szzls)))
  1187.                 ChaYiNameValue = Trim(.TextMatrix(count, Sydz("005", GridStr(), Szzls)))
  1188.                 JieFangMoney = Val(WglrGrid.TextMatrix(count, Sydz("016", GridStr(), Szzls)))
  1189.                 DaiFangMoney = Val(WglrGrid.TextMatrix(count, Sydz("017", GridStr(), Szzls)))
  1190.                 
  1191.                 For countrow = vsFlex_PzChild.FixedRows To vsFlex_PzChild.Rows - 1
  1192.                     If Trim(vsFlex_PzChild.TextMatrix(countrow, 0)) = InoutMainIdValue Then
  1193.                         If Trim(.TextMatrix(count, Sydz("008", GridStr(), Szzls))) <> "" Then
  1194.                             If Trim(vsFlex_PzChild.TextMatrix(countrow, 2)) = DuifangCodeValue And Trim(vsFlex_PzChild.TextMatrix(countrow, 6)) = "3" Then
  1195.                                 IsPzInoutMainID = True
  1196.                                 vsFlex_PzChild.TextMatrix(countrow, 5) = Val(vsFlex_PzChild.TextMatrix(countrow, 5)) + DaiFangMoney
  1197.                                 Exit For
  1198.                             Else
  1199.                                 IsPzInoutMainID = False
  1200.                             End If
  1201.                         Else
  1202.                             IsPzInoutMainID = True
  1203.                         End If
  1204.                     Else
  1205.                         IsPzInoutMainID = False
  1206.                     End If
  1207.                 Next countrow
  1208.                             
  1209.                 If IsPzInoutMainID = False Then
  1210.                     vsFlex_PzChild.AddItem ""
  1211.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 0) = InoutMainIdValue
  1212.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 1) = Note
  1213.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 2) = ChaYiCodeValue
  1214.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 3) = ChaYiNameValue
  1215.                     If Val(JieFangMoney) <> 0 Then
  1216.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 4) = JieFangMoney
  1217.                     End If
  1218.                     If Val(DaiFangMoney) <> 0 Then
  1219.                         vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 5) = DaiFangMoney
  1220.                     End If
  1221.                     vsFlex_PzChild.TextMatrix(vsFlex_PzChild.Rows - 1, 6) = "3"
  1222.                 End If
  1223.             End If
  1224.                             
  1225.         Next count
  1226.         
  1227.         
  1228.     End With
  1229. End Sub
  1230. Private Sub Form_KeyPress(KeyAscii As Integer)      '限制录入字符"'"
  1231.     Select Case KeyAscii
  1232.         Case 39           '屏蔽字符"'"
  1233.             KeyAscii = 0
  1234.     End Select
  1235.     
  1236. End Sub
  1237. Private Sub Form_Load()                              '窗 体 装 入
  1238.   
  1239.     '初始化各种锁值(Fixed)
  1240.     Changelock = False             '网格行列改变控制锁
  1241.     Gdtlock = False                '滚动条滚动控制
  1242.     Yxxpdlock = True               '字段有效性判断锁
  1243.     Hyxxpdlock = True              '行有效性判断锁
  1244.     Wbkbhlock = False              '文本框内容改变锁
  1245.      
  1246.     '调 入 网 格(Fixed)
  1247.     GridCode = "Chhs_MakeVoucherSub"      '网格属性编码
  1248.     Call BzWgcsh(WglrGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
  1249.     
  1250.     Qslz = GridInf(1)
  1251.     Sjhgd = GridInf(2)
  1252.     Pmbcsjhs = GridInf(3)
  1253.     Fzxwghs = GridInf(4)
  1254.     Sfblbzkd = GridInf(5)
  1255.     Shsfts = GridInf(6)
  1256.     Sfxshjwg = GridInf(7)
  1257.     Szzls = WglrGrid.Cols - 1
  1258.     
  1259.     '填充列表框
  1260.     Call Fill_Combo
  1261.       
  1262.     '生成查询结果
  1263.     Call Sub_Query
  1264.     
  1265.     '填写辅助表
  1266.     vsFlex_PzMain.TextMatrix(0, 0) = "InoutMainID"
  1267.     vsFlex_PzMain.TextMatrix(0, 1) = "制单日期"
  1268.     vsFlex_PzMain.TextMatrix(0, 2) = "随符单据数"
  1269.     vsFlex_PzMain.TextMatrix(0, 3) = "生成凭证"
  1270.     vsFlex_PzMain.TextMatrix(0, 4) = "生成凭证的各种情况"
  1271.         
  1272.     With vsFlex_PzChild
  1273.         .TextMatrix(0, 0) = "InoutMainID"
  1274.         .TextMatrix(0, 1) = "摘要"
  1275.         .TextMatrix(0, 2) = "科目编码"
  1276.         .TextMatrix(0, 3) = "科目名称"
  1277.         .TextMatrix(0, 4) = "借方"
  1278.         .TextMatrix(0, 5) = "贷方"
  1279.         .TextMatrix(0, 6) = "科目标志"
  1280.         .TextMatrix(0, 7) = "结算方式代码"
  1281.         .TextMatrix(0, 8) = "结算方式"
  1282.         .TextMatrix(0, 9) = "票号"
  1283.         .TextMatrix(0, 10) = "发生日期"
  1284.         .TextMatrix(0, 11) = "数量"
  1285.         .TextMatrix(0, 12) = "单价"
  1286.         .TextMatrix(0, 13) = "外币金额"
  1287.         .TextMatrix(0, 14) = "汇率"
  1288.         .TextMatrix(0, 15) = "部门代码"
  1289.         .TextMatrix(0, 16) = "部门"
  1290.         .TextMatrix(0, 17) = "客户代码"
  1291.         .TextMatrix(0, 18) = "客户"
  1292.         .TextMatrix(0, 19) = "个人"
  1293.         .TextMatrix(0, 20) = "个人代码"
  1294.         .TextMatrix(0, 21) = "项目"
  1295.         .TextMatrix(0, 22) = "项目代码"
  1296.         .TextMatrix(0, 23) = "项目数量1"
  1297.         .TextMatrix(0, 24) = "项目数量2"
  1298.         .TextMatrix(0, 25) = "供应商代码"
  1299.         .TextMatrix(0, 26) = "供应商"
  1300.         .TextMatrix(0, 27) = "经办人"
  1301.     End With
  1302.     
  1303. End Sub
  1304. Private Sub Sub_Query()                              '生成查询结果
  1305.     Dim SqlStr As String                           '临时使用字符串
  1306.     Dim Rectemp As New ADODB.Recordset             '临时使用动态集
  1307.     Dim Jsqte As Long                              '临时计数器
  1308.     '禁止网格刷新动作,为加快网格显示速度(Fixed)
  1309.     WglrGrid.Redraw = False
  1310.     '本张单据查询字符串
  1311.     If Trim(CL_MakeVoucher.ListId) = "" Then
  1312.         Exit Sub
  1313.     Else
  1314.         SqlStr = "SELECT * FROM Chhs_V_List WHERE KjYear='" & PGKjYear & "' and Period='" & PGNowmon & "' and startflag=0 and " & CL_MakeVoucher.ListId
  1315.         Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1316.     End If
  1317.       
  1318.     With Rectemp
  1319.      
  1320.         WglrGrid.Rows = WglrGrid.FixedRows
  1321.      
  1322.         If .EOF Then
  1323.             WglrGrid.Redraw = True
  1324.             Exit Sub
  1325.         End If
  1326.      
  1327.         Jsqte = WglrGrid.FixedRows
  1328.         
  1329.         Do While Not .EOF
  1330.         
  1331.             WglrGrid.AddItem ""
  1332.             
  1333.             If Trim(.Fields("BillCode")) = "1307" Then
  1334.                 WglrGrid.TextMatrix(Jsqte, 0) = Val(.Fields("ListId"))
  1335.             Else
  1336.                 WglrGrid.TextMatrix(Jsqte, 0) = Val(.Fields("InoutMainId"))                                             '主表ID
  1337.             End If
  1338.             
  1339.             WglrGrid.TextMatrix(Jsqte, 1) = Val(.Fields("InOutSubId"))                                                  '子表ID
  1340.             WglrGrid.TextMatrix(Jsqte, 2) = Val(.Fields("InoutAdjustMainId"))                                           '调整单主表ID
  1341.             WglrGrid.TextMatrix(Jsqte, 3) = Val(.Fields("InoutAdjustSubId"))                                            '调整单子表ID
  1342.             WglrGrid.TextMatrix(Jsqte, 4) = Trim(.Fields("BillCode"))                                                   '单据类型
  1343.             WglrGrid.TextMatrix(Jsqte, 5) = Trim(.Fields("PriceMode"))                                                  '记价方式
  1344.             WglrGrid.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Trim(.Fields("BillNum") & "")                   '单据号
  1345.             WglrGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = .Fields("WhName")                               '仓库编码
  1346.             WglrGrid.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls)) = .Fields("MName")                                '材料编码
  1347.             WglrGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("MateAcctName") & "")              '物料科目编码
  1348.             WglrGrid.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls)) = Trim(.Fields("DiffAcctName") & "")              '差异科目编码
  1349.             WglrGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = Trim(.Fields("DfAcctName") & "")                '对方科目编码
  1350.             WglrGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = Trim(.Fields("MateAcct") & "")                  '物料科目编码
  1351.             WglrGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Trim(.Fields("DiffAcct") & "")                  '差异科目编码
  1352.             WglrGrid.TextMatrix(Jsqte, Sydz("009", GridStr(), Szzls)) = Trim(.Fields("DfAcct") & "")                    '对方科目编码
  1353.             WglrGrid.TextMatrix(Jsqte, Sydz("010", GridStr(), Szzls)) = Trim(.Fields("BillName") & "")                  '入库日期
  1354.             WglrGrid.TextMatrix(Jsqte, Sydz("011", GridStr(), Szzls)) = Trim(.Fields("InoutFlag") & "")                 '收发标志
  1355.             WglrGrid.TextMatrix(Jsqte, Sydz("012", GridStr(), Szzls)) = .Fields("InQuan")                               '收入数量
  1356.             WglrGrid.TextMatrix(Jsqte, Sydz("013", GridStr(), Szzls)) = .Fields("InMoney")                              '收入金额
  1357.             WglrGrid.TextMatrix(Jsqte, Sydz("014", GridStr(), Szzls)) = .Fields("OutQuan")                              '发出数量
  1358.             WglrGrid.TextMatrix(Jsqte, Sydz("015", GridStr(), Szzls)) = .Fields("OutMoney")                             '发出金额
  1359.             WglrGrid.TextMatrix(Jsqte, Sydz("016", GridStr(), Szzls)) = .Fields("JfDiff")                               '借方差异
  1360.             WglrGrid.TextMatrix(Jsqte, Sydz("017", GridStr(), Szzls)) = .Fields("DfDiff")                               '贷方差异
  1361.             '<<]
  1362.        
  1363.             WglrGrid.RowHeight(Jsqte) = Sjhgd
  1364.             .MoveNext
  1365.             Jsqte = Jsqte + 1
  1366.         Loop
  1367.         
  1368.     End With
  1369.             
  1370.     '将网格刷新解禁(Fixed)
  1371.     WglrGrid.Redraw = True
  1372.        
  1373. End Sub
  1374. Private Sub Wbkcl()                                                 '文本框录入之前处理(根据实际情况)
  1375.  
  1376.     Dim xswbrr As String
  1377.  
  1378.     With WglrGrid
  1379.         Zdlrqnr = Trim(.Text)
  1380.         xswbrr = Trim(.Text)
  1381.     
  1382.         If GridBoolean(.Col, 3) Then   '列表框录入
  1383.     
  1384.             '填充列表框程序
  1385.             Call FillCombo(YdCombo, GridStr(.Col, 5), xswbrr, 0)
  1386.         Else
  1387.             Wbkbhlock = True
  1388.        
  1389.             '====以下为用户自定义
  1390.             Ydtext.Text = xswbrr
  1391.             '====以上为用户自定义
  1392.          
  1393.             Wbkbhlock = False
  1394.             Ydtext.SelStart = Len(Ydtext.Text)
  1395.         End If
  1396.     End With
  1397.     
  1398. End Sub
  1399. Private Function sjzdyxxpd(Dqpdwgh As Long, Dqpdwgl As Long)        '录入数据字段有效性判断,同时进行字段录入事后处理
  1400.     
  1401.     Dim Str_JudgeText As String            '临时有效性判断字段内容
  1402.     Dim Coljsq As Long                     '临时列计数器
  1403.     Dim Rectemp As New ADODB.Recordset     '临时使用动态集
  1404.     Dim SqlStr As String
  1405.     
  1406.     With WglrGrid
  1407.     
  1408.         '非录入状态有效性为合法
  1409.         If Yxxpdlock Or .Row < .FixedRows Then
  1410.            sjzdyxxpd = True
  1411.            Exit Function
  1412.         End If
  1413.  
  1414.         Str_JudgeText = Trim(.TextMatrix(Dqpdwgh, Dqpdwgl))
  1415.         Select Case GridStr(Dqpdwgl, 1)
  1416.          
  1417.         '以下为自定义部分[
  1418.         
  1419.         '1.放置字段有效性判断程序
  1420.             Case "007", "008", "009"
  1421.                 If Len(Str_JudgeText) <> 0 Then
  1422.                     SqlStr = "SELECT Ccode,Cname FROM Cwzz_Acccode WHERE EndFlag=1 and Ccode='" & Trim(Str_JudgeText) & "' and StopFlag=0 "
  1423.                     Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
  1424.                     If Not Rectemp.EOF Then
  1425.                         If GridStr(Dqpdwgl, 1) = "007" Then
  1426.                             WglrGrid.TextMatrix(Dqpdwgh, Sydz("004", GridStr(), Szzls)) = Trim(Rectemp.Fields("Cname"))
  1427.                         ElseIf GridStr(Dqpdwgl, 1) = "008" Then
  1428.                             WglrGrid.TextMatrix(Dqpdwgh, Sydz("005", GridStr(), Szzls)) = Trim(Rectemp.Fields("Cname"))
  1429.                         Else
  1430.                             WglrGrid.TextMatrix(Dqpdwgh, Sydz("006", GridStr(), Szzls)) = Trim(Rectemp.Fields("Cname"))
  1431.                         End If
  1432.                         Dqpdwgl = Sydz(GridStr(Dqpdwgl, 1), GridStr(), Szzls)
  1433.                     Else
  1434.                         Tsxx = "此科目不存在!"
  1435.                         Dqpdwgl = Sydz(GridStr(Dqpdwgl, 1), GridStr(), Szzls)
  1436.                         GoTo Lrcwcl
  1437.                     End If
  1438.                 Else
  1439.                     If GridStr(Dqpdwgl, 1) = "007" Then
  1440.                         WglrGrid.TextMatrix(Dqpdwgh, Sydz("004", GridStr(), Szzls)) = ""
  1441.                     ElseIf GridStr(Dqpdwgl, 1) = "008" Then
  1442.                         WglrGrid.TextMatrix(Dqpdwgh, Sydz("005", GridStr(), Szzls)) = ""
  1443.                     Else
  1444.                         WglrGrid.TextMatrix(Dqpdwgh, Sydz("006", GridStr(), Szzls)) = ""
  1445.                     End If
  1446.                 End If
  1447.                     
  1448.                 '2.放置字段事后处理程序
  1449.                 
  1450.             '以上为自定义部分]
  1451.             
  1452.         End Select
  1453.      
  1454.         sjzdyxxpd = True
  1455.         Yxxpdlock = True
  1456.         Exit Function
  1457.     
  1458.     End With
  1459.   
  1460. Lrcwcl:    '录入错误处理
  1461.     With WglrGrid
  1462.         Call Xtxxts(Tsxx, 0, 1)
  1463.         Changelock = True
  1464.         .Select Dqpdwgh, Dqpdwgl
  1465.         Changelock = False
  1466.         Call xswbk
  1467.         sjzdyxxpd = False
  1468.         Exit Function
  1469.     End With
  1470.     
  1471. End Function
  1472. Private Function Sjhzyxxpd(ByVal Yxxpdh As Long) As Boolean                  '录入数据行有效性判断,同时进行行处理
  1473.  
  1474.     Dim Lrywlz As Long                     '录入错误列值(Fixed)
  1475.     Dim Rectemp As New ADODB.Recordset     '临时使用动态集
  1476.     Dim SqlStr As String                   '临时查询字符串
  1477.     Dim Str_Ccode As String                '临时索引编码
  1478.     Dim count As Integer
  1479.     With WglrGrid
  1480.         If Yxxpdh > (.Rows - 1) Then Exit Function
  1481.         '行没有发生变化则不进行有效性判断
  1482.         If Hyxxpdlock Then
  1483.             Sjhzyxxpd = True
  1484.             Exit Function
  1485.         End If
  1486.     
  1487.         '以下为自定义部分[
  1488.     
  1489.         '1.1首先进行单个不能为空或不能为零判断(Fixed)
  1490.         For Jsqte = Qslz To .Cols - 1
  1491.             '字段不能为空
  1492.             If GridInt(Jsqte, 5) = 1 Then
  1493.                 If Len(Trim(.TextMatrix(Yxxpdh, Jsqte))) = 0 Then
  1494.                     Tsxx = GridStr(Jsqte, 2)
  1495.                     Lrywlz = Jsqte
  1496.                     GoTo Lrcwcl
  1497.                     Exit For
  1498.                 End If
  1499.             End If
  1500.             
  1501.             '字段不能为零
  1502.             If GridInt(Jsqte, 5) = 2 Then
  1503.                 If Val(Trim(.TextMatrix(Yxxpdh, Jsqte))) = 0 Then
  1504.                     Tsxx = GridStr(Jsqte, 2)
  1505.                     Lrywlz = Jsqte
  1506.                     GoTo Lrcwcl
  1507.                     Exit For
  1508.                 End If
  1509.             End If
  1510.         Next Jsqte
  1511.     
  1512.     
  1513.         '1.2进行其他有效性判断,编写格式同1.1
  1514.                 
  1515.         '2.放置行处理程序(当数据行通过有效性判断)
  1516.         
  1517.         '存货科目编码、对方科目编码、差异科目编码都为空,不进行行有效性判断
  1518.         If WglrGrid.TextMatrix(Yxxpdh, Sydz("007", GridStr(), Szzls)) = "" And WglrGrid.TextMatrix(Yxxpdh, Sydz("008", GridStr(), Szzls)) = "" And WglrGrid.TextMatrix(Yxxpdh, Sydz("009", GridStr(), Szzls)) = "" Then
  1519.             Sjhzyxxpd = True
  1520.             Hyxxpdlock = True
  1521.             Exit Function
  1522.         End If
  1523.         
  1524.         '非计划价法的出入库单,计划价法出库单,无差异的计划价法入库单
  1525.         If (WglrGrid.TextMatrix(Yxxpdh, 5) <> "计划价法" And InStr(1, "1212,1202,1203,1204,1205,1206,1304,1305", Trim(WglrGrid.TextMatrix(Yxxpdh, 4)))) _
  1526.            Or (WglrGrid.TextMatrix(Yxxpdh, 5) = "计划价法" And InStr(1, "1212,1202,1203,1304,1305", Trim(WglrGrid.TextMatrix(Yxxpdh, 4))) _
  1527.            And Val(WglrGrid.TextMatrix(Yxxpdh, Sydz("016", GridStr(), Szzls))) = 0 And Val(WglrGrid.TextMatrix(Yxxpdh, Sydz("017", GridStr(), Szzls))) = 0) _
  1528.            Or (WglrGrid.TextMatrix(Yxxpdh, 5) = "计划价法" And InStr(1, "1204,1205,1206", Trim(WglrGrid.TextMatrix(Yxxpdh, 4)))) Then
  1529.             
  1530.             If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("007", GridStr(), Szzls))) = "" Then
  1531.                 Lrywlz = Sydz("007", GridStr(), Szzls)
  1532.                 Tsxx = "存货科目不能为空!"
  1533.                 GoTo Lrcwcl
  1534.             End If
  1535.             
  1536.             If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("008", GridStr(), Szzls))) <> "" Then
  1537.                 Lrywlz = Sydz("008", GridStr(), Szzls)
  1538.                 Tsxx = "不能输入差异科目!"
  1539.                 GoTo Lrcwcl
  1540.             End If
  1541.             
  1542.             If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("009", GridStr(), Szzls))) = "" Then
  1543.                 Lrywlz = Sydz("009", GridStr(), Szzls)
  1544.                 Tsxx = "对方科目不能为空!"
  1545.                 GoTo Lrcwcl
  1546.             End If
  1547.             WglrGrid.TextMatrix(Yxxpdh, 6) = "1"
  1548.             
  1549.         End If
  1550.            
  1551.         '有差异的计划价法入库单
  1552.         If WglrGrid.TextMatrix(Yxxpdh, 5) = "计划价法" And InStr(1, "1212,1202,1203,1304,1305", Trim(WglrGrid.TextMatrix(Yxxpdh, 4))) _
  1553.            And (Val(WglrGrid.TextMatrix(Yxxpdh, Sydz("016", GridStr(), Szzls))) <> 0 Or Val(WglrGrid.TextMatrix(Yxxpdh, Sydz("017", GridStr(), Szzls))) <> 0) Then
  1554.             
  1555.             If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("007", GridStr(), Szzls))) = "" Then
  1556.                 Lrywlz = Sydz("007", GridStr(), Szzls)
  1557.                 Tsxx = "存货科目不能为空!"
  1558.                 GoTo Lrcwcl
  1559.             End If
  1560.             
  1561.             If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("008", GridStr(), Szzls))) = "" Then
  1562.                 Lrywlz = Sydz("008", GridStr(), Szzls)
  1563.                 Tsxx = "差异科目不能为空!"
  1564.                 GoTo Lrcwcl
  1565.             End If
  1566.             
  1567.             If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("009", GridStr(), Szzls))) = "" Then
  1568.                 Lrywlz = Sydz("009", GridStr(), Szzls)
  1569.                 Tsxx = "对方科目不能为空!"
  1570.                 GoTo Lrcwcl
  1571.             End If
  1572.             WglrGrid.TextMatrix(Yxxpdh, 6) = "2"
  1573.         End If
  1574.         
  1575.         '进行差异处理的计划价调整单
  1576.         If InStr(1, "1301,1302,1303", Trim(WglrGrid.TextMatrix(Yxxpdh, 4))) Then
  1577.             If WglrGrid.TextMatrix(Yxxpdh, 5) = "计划价法" Then
  1578.                 If Qmclcy Then
  1579.                     If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("007", GridStr(), Szzls))) <> "" Then
  1580.                         Lrywlz = Sydz("007", GridStr(), Szzls)
  1581.                         Tsxx = "不能输入存货科目!"
  1582.                         GoTo Lrcwcl
  1583.                     End If
  1584.                     
  1585.                     If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("008", GridStr(), Szzls))) = "" Then
  1586.                         Lrywlz = Sydz("008", GridStr(), Szzls)
  1587.                         Tsxx = "差异科目不能为空!"
  1588.                         GoTo Lrcwcl
  1589.                     End If
  1590.             
  1591.                     If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("009", GridStr(), Szzls))) = "" Then
  1592.                         Lrywlz = Sydz("009", GridStr(), Szzls)
  1593.                         Tsxx = "对方科目不能为空!"
  1594.                         GoTo Lrcwcl
  1595.                     End If
  1596.                     
  1597.                     WglrGrid.TextMatrix(Yxxpdh, 6) = "3"
  1598.                 Else
  1599.                     '不进行差异处理的计划价调整单
  1600.                     If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("007", GridStr(), Szzls))) = "" Then
  1601.                         Lrywlz = Sydz("007", GridStr(), Szzls)
  1602.                         Tsxx = "存货科目不能为空!"
  1603.                         GoTo Lrcwcl
  1604.                     End If
  1605.             
  1606.                     If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("008", GridStr(), Szzls))) <> "" Then
  1607.                         Lrywlz = Sydz("008", GridStr(), Szzls)
  1608.                         Tsxx = "不能输入差异科目!"
  1609.                         GoTo Lrcwcl
  1610.                     End If
  1611.             
  1612.                     If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("009", GridStr(), Szzls))) = "" Then
  1613.                         Lrywlz = Sydz("009", GridStr(), Szzls)
  1614.                         Tsxx = "对方科目不能为空!"
  1615.                         GoTo Lrcwcl
  1616.                     End If
  1617.                     
  1618.                     WglrGrid.TextMatrix(Yxxpdh, 6) = "4"
  1619.                 End If
  1620.             Else
  1621.                 '非计划价的调整单
  1622.                 If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("007", GridStr(), Szzls))) = "" Then
  1623.                     Lrywlz = Sydz("007", GridStr(), Szzls)
  1624.                     Tsxx = "存货科目不能为空!"
  1625.                     GoTo Lrcwcl
  1626.                 End If
  1627.             
  1628.                 If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("008", GridStr(), Szzls))) <> "" Then
  1629.                     Lrywlz = Sydz("008", GridStr(), Szzls)
  1630.                     Tsxx = "不能输入差异科目!"
  1631.                     GoTo Lrcwcl
  1632.                 End If
  1633.             
  1634.                 If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("009", GridStr(), Szzls))) = "" Then
  1635.                     Lrywlz = Sydz("009", GridStr(), Szzls)
  1636.                     Tsxx = "对方科目不能为空!"
  1637.                     GoTo Lrcwcl
  1638.                 End If
  1639.                 
  1640.                 WglrGrid.TextMatrix(Yxxpdh, 6) = "4"
  1641.             End If
  1642.         End If
  1643.         
  1644.         '差异结转单
  1645.         If InStr(1, "1307", Trim(WglrGrid.TextMatrix(Yxxpdh, 4))) Then
  1646.             If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("007", GridStr(), Szzls))) <> "" Then
  1647.                 Lrywlz = Sydz("007", GridStr(), Szzls)
  1648.                 Tsxx = "不能输入存货科目!"
  1649.                 GoTo Lrcwcl
  1650.             End If
  1651.         
  1652.             If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("008", GridStr(), Szzls))) = "" Then
  1653.                 Lrywlz = Sydz("008", GridStr(), Szzls)
  1654.                 Tsxx = "差异科目不能为空!"
  1655.                 GoTo Lrcwcl
  1656.             End If
  1657.         
  1658.             If Trim(WglrGrid.TextMatrix(Yxxpdh, Sydz("009", GridStr(), Szzls))) = "" Then
  1659.                 Lrywlz = Sydz("009", GridStr(), Szzls)
  1660.                 Tsxx = "对方科目不能为空!"
  1661.                 GoTo Lrcwcl
  1662.             End If
  1663.             
  1664.             WglrGrid.TextMatrix(Yxxpdh, 6) = "5"
  1665.         End If
  1666.          
  1667.     End With
  1668.     '以上为自定义部分]
  1669.     Sjhzyxxpd = True
  1670.     Hyxxpdlock = True
  1671.     Exit Function
  1672. Swcwcl:
  1673.     Cw_DataEnvi.DataConnect.RollbackTrans
  1674.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  1675.     Call Xtxxts(Tsxx, 0, 1)
  1676.     Exit Function
  1677. Lrcwcl:      '录入错误处理
  1678.     With WglrGrid
  1679.         Call Xtxxts(Tsxx, 0, 1)
  1680.         Changelock = True
  1681.         .Select Yxxpdh, Lrywlz
  1682.         Changelock = False
  1683.         Call xswbk
  1684.         Sjhzyxxpd = False
  1685.         Exit Function
  1686.     End With
  1687.     
  1688. End Function
  1689. '===================以 下 程 序 为 通 用 部 分 ,一 般 不 需 更 改(程序动作部分)======================='
  1690. Private Sub Lrzdbz()                                                      '录入字段帮助
  1691.   
  1692.     If Not Ydcommand.Visible Then
  1693.         Exit Sub
  1694.     End If
  1695.    
  1696.     With WglrGrid
  1697.      
  1698.         Valilock = True
  1699.     
  1700.         '处理通用部分
  1701.         Changelock = True        '调入另外窗体必须加锁
  1702.         Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(Ydtext.Text))
  1703.         Changelock = False
  1704.         
  1705.         If Len(Xtfhcs) <> 0 Then
  1706.             If GridInt(.Col, 7) = 0 Then
  1707.                 Ydtext.Text = Xtfhcs
  1708.             Else
  1709.                 Ydtext.Text = Xtfhcsfz
  1710.             End If
  1711.         End If
  1712.         
  1713.         Valilock = False
  1714.   
  1715.         If Ydtext.Visible Then
  1716.             Ydtext.SetFocus
  1717.         End If
  1718.     End With
  1719.     
  1720. End Sub
  1721. Private Sub Form_Resize()                                                '窗体大小发生变化时,重新显示文本框
  1722.    
  1723.     Call Cxxswbk
  1724.    
  1725. End Sub
  1726. Private Function Fun_Drfrmyxxpd() As Boolean                             '调入其它窗体或功能产生的有效性判断(包括数据回写)
  1727.   
  1728.     Fun_Drfrmyxxpd = True
  1729.     
  1730.     With WglrGrid
  1731.    
  1732.         '如果当前网格处于编辑状态,则先进行数据回写再进行有效性判断
  1733.   
  1734.         If Ydtext.Visible Or YdCombo.Visible Then
  1735.             Call Lrsjhx
  1736.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1737.                 Fun_Drfrmyxxpd = False
  1738.                 Exit Function
  1739.             End If
  1740.         End If
  1741.    
  1742.         '进行行有效性判断
  1743.         If Not Sjhzyxxpd(.Row) Then
  1744.             Fun_Drfrmyxxpd = False
  1745.             Exit Function
  1746.         End If
  1747.     End With
  1748.   
  1749. End Function
  1750. Private Sub WglrGrid_EnterCell()                                          '显示当前数据行相关信息
  1751.     With WglrGrid
  1752.         If .Row >= .FixedRows Then
  1753.             '[>>
  1754.                 '此处可以填写显示与此网格行相关信息
  1755.             '<<]
  1756.         End If
  1757.     End With
  1758.    
  1759. End Sub
  1760. Private Sub WglrGrid_GotFocus()                                           '网格得到焦点
  1761.     '网格得到焦点,如果当前选择行为非数据行
  1762.     '则调整当前焦点至有效数据行
  1763.     With WglrGrid
  1764.         If .Row < .FixedRows And .Rows > .FixedRows Then
  1765.             Changelock = True
  1766.             .Select .FixedRows, .Col
  1767.             Changelock = False
  1768.         End If
  1769.         If .Col < Qslz Then
  1770.             Changelock = True
  1771.             .Select .Row, Qslz
  1772.             Changelock = False
  1773.         End If
  1774.     End With
  1775. End Sub
  1776. Private Sub WglrGrid_LostFocus()                                          '录入网格失去焦点
  1777.     '用以屏蔽调用其它窗体时发生网格失去焦点事件
  1778.     If Changelock Then
  1779.         Exit Sub
  1780.     End If
  1781.     '引发网格RowcolChange事件
  1782.     With WglrGrid
  1783.         If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1784.             .Select 0, 0
  1785.         End If
  1786.     End With
  1787. End Sub
  1788. Private Sub WglrGrid_AfterScroll(ByVal OldTopRow As Long, ByVal OldLeftCol As Long, ByVal NewTopRow As Long, ByVal NewLeftCol As Long)                                             '限制用户在录入过程中滚动鼠标
  1789.     If Gdtlock Then
  1790.         Exit Sub
  1791.     End If
  1792.  
  1793.     With WglrGrid
  1794.         If Ydtext.Visible Or YdCombo.Visible Then
  1795.             Gdtlock = True
  1796.             .TopRow = Dqtoprow
  1797.             .LeftCol = Dqleftcol
  1798.             Gdtlock = False
  1799.             Exit Sub
  1800.         End If
  1801.     End With
  1802.     
  1803. End Sub
  1804. Private Sub WglrGrid_LeaveCell()                                    '离开单元格
  1805.     If Changelock Then
  1806.         Exit Sub
  1807.     End If
  1808.     '记录刚刚离开网格单元的行列值
  1809.     Dqlkwgh = WglrGrid.Row
  1810.     Dqlkwgl = WglrGrid.Col
  1811.     '判断是否需要录入数据回写
  1812.     If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1813.         Exit Sub
  1814.     End If
  1815.     
  1816.     Call Lrsjhx
  1817.     
  1818. End Sub
  1819. Private Sub WglrGrid_RowColChange()                                '网格录入行列发生变化时,进行有效性判断
  1820.    
  1821.     Valilock = True       '屏蔽文本框失去焦点进行有效性判断
  1822.     
  1823.     With WglrGrid
  1824.         If Changelock Then
  1825.             Exit Sub
  1826.         End If
  1827.         If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1828.             Exit Sub
  1829.         End If
  1830.         If .Row <> Dqlkwgh Then
  1831.             If Not Sjhzyxxpd(Dqlkwgh) Then
  1832.                 Exit Sub
  1833.             End If
  1834.         End If
  1835.    End With
  1836.    
  1837.    Call fhyxh
  1838.    Call Xldql
  1839.    
  1840. End Sub
  1841. Private Sub WglrGrid_DblClick()                                    '鼠标双击网格显示文本框
  1842.   
  1843.     With WglrGrid
  1844.         Call xswbk
  1845.     End With
  1846.     
  1847. End Sub
  1848. Private Sub Ycwbk()                                                '隐藏文本框,帮助按钮,列表组合框
  1849.     
  1850.     'Valilock = True
  1851.     Ydtext.Visible = False
  1852.     YdCombo.Visible = False
  1853.     Ydcommand.Visible = False
  1854.     
  1855. End Sub
  1856. Private Sub YdCombo_KeyDown(KeyCode As Integer, Shift As Integer)        '列表框移动
  1857.     
  1858.     With WglrGrid
  1859.         Select Case KeyCode
  1860.             Case vbKeyEscape                'ESC 键放弃录入
  1861.                 Valilock = True
  1862.                 .SetFocus
  1863.                 Call Ycwbk
  1864.                 Valilock = False
  1865.                 
  1866.             Case vbKeyReturn                '回 车 键 =13
  1867.                 KeyCode = 0
  1868.                 .SetFocus
  1869.                 Call Lrsjhx
  1870.                 Rowjsq = .Row
  1871.                 Coljsq = .Col + 1
  1872.                 If Coljsq > .Cols - 1 Then
  1873.                     If Rowjsq < .Rows - 1 Then
  1874.                         Rowjsq = Rowjsq + 1
  1875.                     End If
  1876.                     Coljsq = Qslz
  1877.                 End If
  1878.                 Do While Rowjsq <= .Rows - 1
  1879.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1880.                         Coljsq = Coljsq + 1
  1881.                         If Coljsq > .Cols - 1 Then
  1882.                             Rowjsq = Rowjsq + 1
  1883.                             Coljsq = Qslz
  1884.                         End If
  1885.                     Else
  1886.                         Exit Do
  1887.                     End If
  1888.                 Loop
  1889.                 .Select Rowjsq, Coljsq
  1890.                 
  1891.             Case vbKeyLeft                  '左 箭 头 =37
  1892.                 If .Col - 1 = Qslz Then
  1893.                     If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1894.                         GoTo jzzx
  1895.                     End If
  1896.                 End If
  1897.                 If .Col > Qslz Then
  1898.                     KeyCode = 0
  1899.                     .SetFocus
  1900.                     Call Lrsjhx
  1901.                     Coljsq = .Col - 1
  1902.                     Do While Coljsq > Qslz
  1903.                         If Coljsq - 1 = Qslz Then
  1904.                             If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1905.                                 GoTo jzzx
  1906.                             End If
  1907.                         End If
  1908.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1909.                             Coljsq = Coljsq - 1
  1910.                         Else
  1911.                             Exit Do
  1912.                         End If
  1913.                     Loop
  1914.                     .Select .Row, Coljsq
  1915.                 End If
  1916.             Case vbKeyRight                 '右 箭 头 =39
  1917.                 KeyCode = 0
  1918.                 .SetFocus
  1919.                 Call Lrsjhx
  1920.                 Rowjsq = .Row
  1921.                 Coljsq = .Col + 1
  1922.                 If Coljsq > .Cols - 1 Then
  1923.                     If Rowjsq < .Rows - 1 Then
  1924.                         Rowjsq = Rowjsq + 1
  1925.                     End If
  1926.                     Coljsq = Qslz
  1927.                 End If
  1928.                 Do While Rowjsq <= .Rows - 1
  1929.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1930.                         Coljsq = Coljsq + 1
  1931.                         If Coljsq > .Cols - 1 Then
  1932.                             Rowjsq = Rowjsq + 1
  1933.                             Coljsq = Qslz
  1934.                         End If
  1935.                     Else
  1936.                         Exit Do
  1937.                     End If
  1938.                 Loop
  1939.                 .Select Rowjsq, Coljsq
  1940.         Case Else
  1941.     End Select
  1942.    
  1943. jzzx:
  1944.    
  1945.     End With
  1946.     
  1947. End Sub
  1948. Private Sub YdCombo_LostFocus()                    '列表框失去焦点
  1949.     
  1950.     With WglrGrid                                    '因为选中网格会先发生Rowcolchange事件置Valiock
  1951.         If Not Valilock Then                           '为TRUE
  1952.             Call Lrsjhx
  1953.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1954.                 Exit Sub
  1955.             End If
  1956.         End If
  1957.     End With
  1958.     
  1959. End Sub
  1960. Private Sub Ydcommand_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  1961.     
  1962.     Call Lrzdbz
  1963.     
  1964. End Sub
  1965. Private Sub ydtext_KeyDown(KeyCode As Integer, Shift As Integer)
  1966.    
  1967.     Dim Rowjsq As Long, Coljsq As Long
  1968.    
  1969.     With WglrGrid
  1970.         Select Case KeyCode
  1971.             Case vbKeyF2
  1972.                 Call Lrzdbz
  1973.             Case vbKeyEscape                'ESC 键放弃录入
  1974.                 Valilock = True
  1975.                 Call Ycwbk
  1976.                 .SetFocus
  1977.             Case vbKeyReturn                '回 车 键 =13
  1978.                 KeyCode = 0
  1979.                 .SetFocus
  1980.                 Call Lrsjhx
  1981.                 Rowjsq = .Row
  1982.                 Coljsq = .Col + 1
  1983.                 If Coljsq > .Cols - 1 Then
  1984.                     If Rowjsq < .Rows - 1 Then
  1985.                         Rowjsq = Rowjsq + 1
  1986.                     End If
  1987.                     Coljsq = Qslz
  1988.                 End If
  1989.                 Do While Rowjsq <= .Rows - 1
  1990.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1991.                         Coljsq = Coljsq + 1
  1992.                         If Coljsq > .Cols - 1 Then
  1993.                             Rowjsq = Rowjsq + 1
  1994.                             Coljsq = Qslz
  1995.                         End If
  1996.                     Else
  1997.                         Exit Do
  1998.                     End If
  1999.                 Loop
  2000.                 If Rowjsq <= .Rows - 1 Then
  2001.                     .Select Rowjsq, Coljsq
  2002.                 End If
  2003.                 
  2004.             Case vbKeyUp                    '上 箭 头 =38
  2005.                 KeyCode = 0
  2006.                 .SetFocus
  2007.                 Call Lrsjhx
  2008.                 If .Row > .FixedRows Then
  2009.                     .Row = .Row - 1
  2010.                 End If
  2011.                 
  2012.             Case vbKeyDown                  '下 箭 头 =40
  2013.                 KeyCode = 0
  2014.                 .SetFocus
  2015.                 Call Lrsjhx
  2016.                 If .Row < .Rows - 1 Then
  2017.                     .Row = .Row + 1
  2018.                 End If
  2019.             Case vbKeyLeft                  '左 箭 头 =37
  2020.                 If .Col - 1 = Qslz Then
  2021.                     If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  2022.                         GoTo jzzx
  2023.                     End If
  2024.                 End If
  2025.                 If Ydtext.SelStart = 0 And .Col > Qslz Then
  2026.                     KeyCode = 0
  2027.                     .SetFocus
  2028.                     Call Lrsjhx
  2029.                     Coljsq = .Col - 1
  2030.                     Do While Coljsq > Qslz
  2031.                         If Coljsq - 1 = Qslz Then
  2032.                             If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  2033.                                 GoTo jzzx
  2034.                             End If
  2035.                         End If
  2036.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  2037.                             Coljsq = Coljsq - 1
  2038.                         Else
  2039.                             Exit Do
  2040.                         End If
  2041.                     Loop
  2042.                     .Select .Row, Coljsq
  2043.                 End If
  2044. jzzx:
  2045.            
  2046.            
  2047.             Case vbKeyRight                 '右 箭 头 =39
  2048.                 wblong = Len(Ydtext.Text)
  2049.                 If (Ydtext.SelStart = wblong Or Ydtext.SelLength = wblong) Then
  2050.                     KeyCode = 0
  2051.                     .SetFocus
  2052.                     Call Lrsjhx
  2053.                     Rowjsq = .Row
  2054.                     Coljsq = .Col + 1
  2055.                     If Coljsq > .Cols - 1 Then
  2056.                         If Rowjsq < .Rows - 1 Then
  2057.                             Rowjsq = Rowjsq + 1
  2058.                         End If
  2059.                         Coljsq = Qslz
  2060.                     End If
  2061.                     Do While Rowjsq <= .Rows - 1
  2062.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  2063.                             Coljsq = Coljsq + 1
  2064.                             If Coljsq > .Cols - 1 Then
  2065.                                 Rowjsq = Rowjsq + 1
  2066.                                 Coljsq = Qslz
  2067.                             End If
  2068.                         Else
  2069.                             Exit Do
  2070.                         End If
  2071.                     Loop
  2072.                     .Select Rowjsq, Coljsq
  2073.                 End If
  2074.             Case Else
  2075.         End Select
  2076.     End With
  2077.     
  2078. End Sub
  2079. Private Sub ydtext_KeyPress(KeyAscii As Integer)         '录入字符事中控制
  2080.   
  2081.     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  2082. End Sub
  2083. Private Sub ydtext_Change()                              '录入事中变化处理
  2084.     '防止程序改变但不进行处理
  2085.     If Wbkbhlock Then
  2086.          Exit Sub
  2087.     End If
  2088.     With WglrGrid
  2089.         '限制字段录入长度
  2090.         Wbkbhlock = True
  2091.         
  2092.         Select Case GridInt(.Col, 1)
  2093.             Case 8, 11   '金额型
  2094.                 Call Sjgskz(Ydtext, Xtjezws - Xtjexsws - 1, Xtjexsws)
  2095.             Case 9, 12   '数量型
  2096.                 Call Sjgskz(Ydtext, Xtslzws - Xtslxsws - 1, Xtslxsws)
  2097.             Case 10      '单价型
  2098.                 Call Sjgskz(Ydtext, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  2099.             Case Else    '其他类型
  2100.                 If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
  2101.                     Call Sjgskz(Ydtext, GridInt(.Col, 3), GridInt(.Col, 4))
  2102.                 End If
  2103.         End Select
  2104.         
  2105.         Wbkbhlock = False
  2106.     End With
  2107.     
  2108. End Sub
  2109. Private Sub ydtext_LostFocus()            '如果由于选中网格之外的控件而发生有效性判断(选中网格会先发生Rowcolchange事件置Valiock为TRUE)
  2110.   
  2111.     With WglrGrid
  2112.         If Not Valilock Then
  2113.             Call Lrsjhx
  2114.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  2115.                 Exit Sub
  2116.             End If
  2117.             If Not Sjhzyxxpd(Dqlrwgh) Then
  2118.                 Exit Sub
  2119.             End If
  2120.         End If
  2121.     End With
  2122.   
  2123. End Sub
  2124. Private Sub xswbk()                       '在当前选中单元显示文本框,列表框,帮助按钮(通用)
  2125.   
  2126.     Dim Wbkpy As Integer, Wbkpy1 As Integer '文本框偏移量
  2127.   
  2128.     '显示文本框前返回有效行列(解决滚动条问题)
  2129.     Call Xldqh
  2130.     Call Xldql
  2131.   
  2132.     '隐藏文本框,帮助按钮,列表组合框
  2133.     Call Ycwbk
  2134.   
  2135.     With WglrGrid
  2136.         Dqlrwgh = .Row
  2137.         Dqlrwgl = .Col
  2138.         If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  2139.             Exit Sub
  2140.         End If
  2141.      
  2142.         Wbkpy = 30
  2143.         Wbkpy1 = 15
  2144.     
  2145.         On Error Resume Next
  2146.         
  2147.         If GridBoolean(.Col, 3) Then
  2148.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  2149.             YdCombo.Top = .CellTop + .Top + Wbkpy
  2150.             YdCombo.Width = .CellWidth - Wbkpy1
  2151.             Call Wbkcl
  2152.             YdCombo.Visible = True
  2153.             YdCombo.SetFocus
  2154.             Ydcommand.Visible = False
  2155.             Ydtext.Visible = False
  2156.         Else
  2157.             If GridBoolean(.Col, 2) Then
  2158.                 Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  2159.                 Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  2160.                 Ydcommand.Visible = True
  2161.             Else
  2162.                 Ydcommand.Visible = False
  2163.             End If
  2164.      
  2165.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  2166.             Ydtext.Top = .CellTop + .Top + Wbkpy
  2167.             
  2168.             If Ydcommand.Visible Then
  2169.                 If Sfblbzkd Then
  2170.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  2171.                 Else
  2172.                     Ydtext.Width = .CellWidth - Wbkpy1
  2173.                 End If
  2174.             Else
  2175.                 Ydtext.Width = .CellWidth - Wbkpy1
  2176.             End If
  2177.             
  2178.             Ydtext.Height = .CellHeight - Wbkpy1
  2179.       
  2180.             If GridInt(.Col, 2) <> 0 Then
  2181.                 Ydtext.MaxLength = GridInt(.Col, 2)
  2182.             Else
  2183.                 Ydtext.MaxLength = 3000
  2184.             End If
  2185.       
  2186.             Call Wbkcl
  2187.       
  2188.             Ydtext.Visible = True
  2189.             Ydtext.SetFocus
  2190.         End If
  2191.     
  2192.         Dqtoprow = .TopRow
  2193.         Dqleftcol = .LeftCol
  2194.     
  2195.         '重置锁值
  2196.         Valilock = False
  2197.         Wbkbhlock = False
  2198.     End With
  2199.  
  2200. End Sub
  2201. Private Sub Cxxswbk()                                                  'Formresize中重新显示文本框,列表框,帮助按钮(通用)
  2202.                    
  2203.     Dim Wbkpy As Integer, Wbkpy1 As Integer
  2204.     
  2205.     Wbkpy = 30
  2206.     Wbkpy1 = 15
  2207.     
  2208.     With WglrGrid
  2209.         If YdCombo.Visible Then
  2210.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  2211.             YdCombo.Top = .CellTop + .Top + Wbkpy
  2212.             YdCombo.Width = .CellWidth - Wbkpy1
  2213.         End If
  2214.         If Ydcommand.Visible Then
  2215.             Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  2216.             Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  2217.         End If
  2218.         If Ydtext.Visible Then
  2219.             If Ydcommand.Visible Then
  2220.                 If Sfblbzkd Then
  2221.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  2222.                 Else
  2223.                     Ydtext.Width = .CellWidth - Wbkpy1
  2224.                 End If
  2225.             Else
  2226.                 Ydtext.Width = .CellWidth - Wbkpy1
  2227.             End If
  2228.       
  2229.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  2230.             Ydtext.Top = .CellTop + .Top + Wbkpy
  2231.             Ydtext.Height = .CellHeight - Wbkpy1
  2232.         End If
  2233.     End With
  2234. End Sub
  2235. Private Sub Lrsjhx()                                                             '文本框录入数据回写
  2236.   
  2237.     With WglrGrid
  2238.         If YdCombo.Visible Then
  2239.             .Text = Trim(YdCombo.Text)
  2240.         End If
  2241.         If Ydtext.Visible Then
  2242.             .Text = Trim(Ydtext.Text)
  2243.         End If
  2244.    
  2245.         '(如果字段录入内容发生变化,则打开有效性判断锁)
  2246.         If Zdlrqnr <> Trim(.Text) Then
  2247.             Yxxpdlock = False
  2248.             Hyxxpdlock = False
  2249.         End If
  2250.    
  2251.         '隐藏文本框,帮助按钮,列表组合框
  2252.         Call Ycwbk
  2253.    
  2254.     End With
  2255.     
  2256. End Sub
  2257. Private Sub WglrGrid_KeyDown(KeyCode As Integer, Shift As Integer)              '网格快捷键
  2258.   
  2259.     Select Case KeyCode
  2260.         Case vbKeyF2                   '按F2键参照
  2261.             Call xswbk
  2262.             Call Lrzdbz
  2263.     End Select
  2264. End Sub
  2265. Private Sub WglrGrid_KeyPress(KeyAscii As Integer)                              '网格接受键盘录入
  2266.     
  2267.     With WglrGrid
  2268.   
  2269.         '屏 蔽 回 车 键
  2270.         If KeyAscii = vbKeyReturn Then
  2271.             KeyAscii = 0
  2272.             Rowjsq = .Row
  2273.             Coljsq = .Col + 1
  2274.             If Coljsq > .Cols - 1 Then
  2275.                 If Rowjsq < .Rows - 1 Then
  2276.                     Rowjsq = Rowjsq + 1
  2277.                 End If
  2278.                 Coljsq = Qslz
  2279.             End If
  2280.             Do While Rowjsq <= .Rows - 1
  2281.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  2282.                     Coljsq = Coljsq + 1
  2283.                     If Coljsq > .Cols - 1 Then
  2284.                         Rowjsq = Rowjsq + 1
  2285.                         Coljsq = Qslz
  2286.                     End If
  2287.                 Else
  2288.                     Exit Do
  2289.                 End If
  2290.             Loop
  2291.           
  2292.             If Rowjsq <= .Rows - 1 Then
  2293.                 .Select Rowjsq, Coljsq
  2294.             End If
  2295.        
  2296.             Exit Sub
  2297.        
  2298.         End If
  2299.      
  2300.         '接受用户录入
  2301.         Select Case KeyAscii
  2302.             Case 0 To 32             '用户输入KeyAscii为0-32的键 如空格
  2303.                 '显示录入载体
  2304.                 Call xswbk
  2305.             Case Else
  2306.                 
  2307.                 '防止非编辑字段SendKeys()出现死循环
  2308.                 If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  2309.                     Exit Sub
  2310.                 End If
  2311.                 
  2312.                 '如果此字段为列表框录入则调入相应列表框
  2313.                 If GridBoolean(.Col, 3) Then
  2314.                    '列表框录入
  2315.                     Call xswbk
  2316.                 Else
  2317.                     Ydtext.Text = ""
  2318.             
  2319.                     '录入限制
  2320.                     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  2321.                     If KeyAscii = 0 Then
  2322.                         Exit Sub
  2323.                     End If
  2324.                     Call xswbk
  2325.                     Ydtext.Text = ""
  2326.                     Valilock = True
  2327.                     SendKeys Chr(KeyAscii), True
  2328.                     DoEvents
  2329.                     Valilock = False
  2330.                 End If
  2331.         End Select
  2332.     End With
  2333. End Sub
  2334. Private Sub fhyxh()                                                     '返回录入数据有效行,同时让得到焦点网格可见
  2335.     
  2336.     With WglrGrid
  2337.         If .Row >= .FixedRows Then
  2338.             Call Xldqh
  2339.         End If
  2340.     End With
  2341. End Sub
  2342. Private Sub Xldqh()                                                      '显露当前行
  2343.     
  2344.     Dim Toprowte As Long
  2345.     With WglrGrid
  2346.         Toprowte = 0
  2347.         Do While .CellTop + .RowHeight(.Row) + Fzxwghs * Sjhgd > .Height And .TopRow <> Toprowte
  2348.             Toprowte = .TopRow
  2349.             .TopRow = .TopRow + 1
  2350.         Loop
  2351.         Toprowte = 0
  2352.         Do While .CellTop < .FixedRows * .RowHeight(0) And .TopRow <> Toprowte
  2353.             Toprowte = .TopRow
  2354.             If .TopRow > 1 Then
  2355.                 .TopRow = .TopRow - 1
  2356.             End If
  2357.         Loop
  2358.     End With
  2359. End Sub
  2360. Private Sub Xldql()                                                                  '显露当前列
  2361.     
  2362.     Dim Leftcolte As Long
  2363.     With WglrGrid
  2364.         If .Col >= Qslz And .Col >= .FixedCols Then
  2365.             If .LeftCol > .Col Then
  2366.                 .LeftCol = .Col
  2367.             End If
  2368.             Leftcolte = 0
  2369.             Do While .CellLeft + .CellWidth > .Width And .LeftCol <> Leftcolte
  2370.                 Leftcolte = .LeftCol
  2371.                 .LeftCol = .LeftCol + 1
  2372.             Loop
  2373.         End If
  2374.     End With
  2375. End Sub
  2376. Private Sub WglrGrid_BeforeMoveColumn(ByVal Col As Long, Position As Long)           '网格列发生移动时自动交换网格索引信息
  2377.     
  2378.     Call FnBln_RefreshArray(Col, Position, GridStr(), GridInf())
  2379.     
  2380. End Sub
  2381. '填补列表
  2382. Private Sub Fill_Combo()
  2383.     Dim MRecord As New ADODB.Recordset
  2384.     
  2385.     Set MRecord = Cw_DataEnvi.DataConnect.Execute("select * from Cwzz_VouchClass ")
  2386.     
  2387.     Do While Not MRecord.EOF
  2388.         With Combo1
  2389.             .AddItem MRecord.Fields("VouchClassCode") + MRecord.Fields("VouchClassName")
  2390.         End With
  2391.         MRecord.MoveNext
  2392.     Loop
  2393.     
  2394.     Set MRecord = Nothing
  2395.     
  2396. End Sub