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

企业管理

开发平台:

Visual Basic

  1. VERSION 5.00
  2. Object = "{BEEECC20-4D5F-4F8B-BFDC-5D9B6FBDE09D}#1.0#0"; "vsflex8.ocx"
  3. Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
  4. Begin VB.Form BadDebt_FrmLossList 
  5.    BackColor       =   &H00C0C0C0&
  6.    BorderStyle     =   1  'Fixed Single
  7.    Caption         =   "坏帐损失列表"
  8.    ClientHeight    =   6645
  9.    ClientLeft      =   660
  10.    ClientTop       =   1155
  11.    ClientWidth     =   11025
  12.    HelpContextID   =   20701
  13.    Icon            =   "坏帐处理_坏帐损失查询列表.frx":0000
  14.    KeyPreview      =   -1  'True
  15.    LinkTopic       =   "Form4"
  16.    MaxButton       =   0   'False
  17.    MinButton       =   0   'False
  18.    ScaleHeight     =   6645
  19.    ScaleWidth      =   11025
  20.    StartUpPosition =   1  '所有者中心
  21.    Begin VB.PictureBox Pic_Title 
  22.       BackColor       =   &H00FFFFFF&
  23.       Height          =   1035
  24.       Left            =   30
  25.       Picture         =   "坏帐处理_坏帐损失查询列表.frx":1042
  26.       ScaleHeight     =   975
  27.       ScaleWidth      =   10875
  28.       TabIndex        =   7
  29.       Top             =   570
  30.       Width           =   10935
  31.       Begin VB.Label Lab_Cust 
  32.          AutoSize        =   -1  'True
  33.          BackStyle       =   0  'Transparent
  34.          Caption         =   "客户:"
  35.          Height          =   180
  36.          Left            =   240
  37.          TabIndex        =   9
  38.          Top             =   750
  39.          Width           =   450
  40.       End
  41.       Begin VB.Label tsLabel 
  42.          AutoSize        =   -1  'True
  43.          BackColor       =   &H80000018&
  44.          BackStyle       =   0  'Transparent
  45.          Caption         =   "坏帐损失列表"
  46.          BeginProperty Font 
  47.             Name            =   "宋体"
  48.             Size            =   14.25
  49.             Charset         =   134
  50.             Weight          =   700
  51.             Underline       =   0   'False
  52.             Italic          =   0   'False
  53.             Strikethrough   =   0   'False
  54.          EndProperty
  55.          ForeColor       =   &H00000000&
  56.          Height          =   285
  57.          Index           =   4
  58.          Left            =   480
  59.          TabIndex        =   8
  60.          Top             =   180
  61.          Width           =   1800
  62.       End
  63.    End
  64.    Begin VB.TextBox Ydtext 
  65.       BackColor       =   &H00C0FFFF&
  66.       BorderStyle     =   0  'None
  67.       Height          =   300
  68.       Left            =   8790
  69.       MultiLine       =   -1  'True
  70.       TabIndex        =   0
  71.       Top             =   1740
  72.       Visible         =   0   'False
  73.       Width           =   1185
  74.    End
  75.    Begin VB.ComboBox YdCombo 
  76.       Height          =   300
  77.       Left            =   8790
  78.       Style           =   2  'Dropdown List
  79.       TabIndex        =   3
  80.       Top             =   2130
  81.       Visible         =   0   'False
  82.       Width           =   1695
  83.    End
  84.    Begin VB.Timer Timer1 
  85.       Interval        =   1
  86.       Left            =   10020
  87.       Top             =   1710
  88.    End
  89.    Begin VB.CommandButton Ydcommand 
  90.       Height          =   300
  91.       Left            =   10530
  92.       Picture         =   "坏帐处理_坏帐损失查询列表.frx":1DF82
  93.       Style           =   1  'Graphical
  94.       TabIndex        =   1
  95.       Top             =   2130
  96.       Visible         =   0   'False
  97.       Width           =   300
  98.    End
  99.    Begin VSFlex8Ctl.VSFlexGrid WglrGrid 
  100.       Height          =   4965
  101.       Left            =   30
  102.       TabIndex        =   4
  103.       Top             =   1650
  104.       Width           =   8625
  105.       _cx             =   5080
  106.       _cy             =   5080
  107.       Appearance      =   1
  108.       BorderStyle     =   1
  109.       Enabled         =   -1  'True
  110.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  111.          Name            =   "宋体"
  112.          Size            =   9
  113.          Charset         =   134
  114.          Weight          =   400
  115.          Underline       =   0   'False
  116.          Italic          =   0   'False
  117.          Strikethrough   =   0   'False
  118.       EndProperty
  119.       MousePointer    =   0
  120.       BackColor       =   16777215
  121.       ForeColor       =   -2147483640
  122.       BackColorFixed  =   12632256
  123.       ForeColorFixed  =   -2147483630
  124.       BackColorSel    =   -2147483635
  125.       ForeColorSel    =   -2147483634
  126.       BackColorBkg    =   -2147483636
  127.       BackColorAlternate=   16777215
  128.       GridColor       =   -2147483633
  129.       GridColorFixed  =   -2147483632
  130.       TreeColor       =   -2147483632
  131.       FloodColor      =   192
  132.       SheetBorder     =   -2147483642
  133.       FocusRect       =   1
  134.       HighLight       =   1
  135.       AllowSelection  =   -1  'True
  136.       AllowBigSelection=   -1  'True
  137.       AllowUserResizing=   0
  138.       SelectionMode   =   0
  139.       GridLines       =   1
  140.       GridLinesFixed  =   2
  141.       GridLineWidth   =   1
  142.       Rows            =   50
  143.       Cols            =   10
  144.       FixedRows       =   1
  145.       FixedCols       =   1
  146.       RowHeightMin    =   0
  147.       RowHeightMax    =   0
  148.       ColWidthMin     =   0
  149.       ColWidthMax     =   0
  150.       ExtendLastCol   =   0   'False
  151.       FormatString    =   ""
  152.       ScrollTrack     =   0   'False
  153.       ScrollBars      =   3
  154.       ScrollTips      =   0   'False
  155.       MergeCells      =   0
  156.       MergeCompare    =   0
  157.       AutoResize      =   -1  'True
  158.       AutoSizeMode    =   0
  159.       AutoSearch      =   0
  160.       AutoSearchDelay =   2
  161.       MultiTotals     =   -1  'True
  162.       SubtotalPosition=   1
  163.       OutlineBar      =   0
  164.       OutlineCol      =   0
  165.       Ellipsis        =   0
  166.       ExplorerBar     =   0
  167.       PicturesOver    =   0   'False
  168.       FillStyle       =   0
  169.       RightToLeft     =   0   'False
  170.       PictureType     =   0
  171.       TabBehavior     =   0
  172.       OwnerDraw       =   0
  173.       Editable        =   0
  174.       ShowComboButton =   1
  175.       WordWrap        =   0   'False
  176.       TextStyle       =   0
  177.       TextStyleFixed  =   0
  178.       OleDragMode     =   0
  179.       OleDropMode     =   0
  180.       DataMode        =   0
  181.       VirtualData     =   -1  'True
  182.       DataMember      =   ""
  183.       ComboSearch     =   3
  184.       AutoSizeMouse   =   -1  'True
  185.       FrozenRows      =   0
  186.       FrozenCols      =   0
  187.       AllowUserFreezing=   0
  188.       BackColorFrozen =   0
  189.       ForeColorFrozen =   0
  190.       WallPaperAlignment=   9
  191.       AccessibleName  =   ""
  192.       AccessibleDescription=   ""
  193.       AccessibleValue =   ""
  194.       AccessibleRole  =   24
  195.       Begin MSComctlLib.ImageList ImageList1 
  196.          Left            =   9120
  197.          Top             =   780
  198.          _ExtentX        =   1005
  199.          _ExtentY        =   1005
  200.          BackColor       =   -2147483643
  201.          ImageWidth      =   16
  202.          ImageHeight     =   16
  203.          MaskColor       =   12632256
  204.          _Version        =   393216
  205.          BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  206.             NumListImages   =   32
  207.             BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  208.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":1E30C
  209.                Key             =   "sz"
  210.             EndProperty
  211.             BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  212.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":1E6A6
  213.                Key             =   "dy"
  214.             EndProperty
  215.             BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  216.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":1EA40
  217.                Key             =   "yl"
  218.             EndProperty
  219.             BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  220.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":1EDDA
  221.                Key             =   "xg"
  222.             EndProperty
  223.             BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  224.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":1F174
  225.                Key             =   "zh"
  226.             EndProperty
  227.             BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  228.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":1F50E
  229.                Key             =   "sh"
  230.             EndProperty
  231.             BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  232.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":1F8A8
  233.                Key             =   "bc"
  234.             EndProperty
  235.             BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  236.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":1FC42
  237.                Key             =   "fq"
  238.             EndProperty
  239.             BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  240.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":1FFDC
  241.                Key             =   "bz"
  242.             EndProperty
  243.             BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  244.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":20376
  245.                Key             =   "tc"
  246.             EndProperty
  247.             BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  248.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":20710
  249.                Key             =   "bcgs"
  250.             EndProperty
  251.             BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  252.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":20AAA
  253.                Key             =   "mrlk"
  254.             EndProperty
  255.             BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  256.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":20E44
  257.                Key             =   "xsxm"
  258.             EndProperty
  259.             BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  260.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":211DE
  261.                Key             =   "first"
  262.             EndProperty
  263.             BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  264.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":21578
  265.                Key             =   "prev"
  266.             EndProperty
  267.             BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  268.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":21912
  269.                Key             =   "next"
  270.             EndProperty
  271.             BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  272.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":21CAC
  273.                Key             =   "last"
  274.             EndProperty
  275.             BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  276.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":22046
  277.                Key             =   "xx"
  278.             EndProperty
  279.             BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  280.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":223E0
  281.                Key             =   "define"
  282.             EndProperty
  283.             BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  284.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":2277A
  285.                Key             =   "exec"
  286.             EndProperty
  287.             BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  288.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":22B14
  289.                Key             =   "xz"
  290.             EndProperty
  291.             BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  292.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":22EAE
  293.                Key             =   "sc"
  294.             EndProperty
  295.             BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  296.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":23248
  297.                Key             =   "sx"
  298.             EndProperty
  299.             BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  300.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":235E2
  301.                Key             =   "cx"
  302.             EndProperty
  303.             BeginProperty ListImage25 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  304.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":2397C
  305.                Key             =   "zd"
  306.             EndProperty
  307.             BeginProperty ListImage26 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  308.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":23D16
  309.                Key             =   "dz"
  310.             EndProperty
  311.             BeginProperty ListImage27 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  312.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":240B0
  313.                Key             =   "ph"
  314.             EndProperty
  315.             BeginProperty ListImage28 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  316.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":2444A
  317.                Key             =   "fz"
  318.             EndProperty
  319.             BeginProperty ListImage29 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  320.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":247E4
  321.                Key             =   "dw"
  322.             EndProperty
  323.             BeginProperty ListImage30 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  324.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":24B7E
  325.                Key             =   "qx"
  326.             EndProperty
  327.             BeginProperty ListImage31 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  328.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":24F18
  329.                Key             =   "qq"
  330.             EndProperty
  331.             BeginProperty ListImage32 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  332.                Picture         =   "坏帐处理_坏帐损失查询列表.frx":252B2
  333.                Key             =   "pz"
  334.             EndProperty
  335.          EndProperty
  336.       End
  337.    End
  338.    Begin MSComctlLib.Toolbar Tlb_Action 
  339.       Align           =   1  'Align Top
  340.       Height          =   555
  341.       Left            =   0
  342.       TabIndex        =   2
  343.       Top             =   0
  344.       Width           =   11025
  345.       _ExtentX        =   19447
  346.       _ExtentY        =   979
  347.       ButtonWidth     =   820
  348.       ButtonHeight    =   926
  349.       AllowCustomize  =   0   'False
  350.       Wrappable       =   0   'False
  351.       Appearance      =   1
  352.       Style           =   1
  353.       ImageList       =   "ImageList1"
  354.       _Version        =   393216
  355.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  356.          NumButtons      =   13
  357.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  358.             Caption         =   "设置"
  359.             Key             =   "ymsz"
  360.             Object.ToolTipText     =   "打印页面设置"
  361.             ImageKey        =   "sz"
  362.          EndProperty
  363.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  364.             Caption         =   "打印"
  365.             Key             =   "dy"
  366.             Object.ToolTipText     =   "打印当前单据或Ctrl+P"
  367.             ImageKey        =   "dy"
  368.          EndProperty
  369.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  370.             Caption         =   "预览"
  371.             Key             =   "yl"
  372.             ImageKey        =   "yl"
  373.          EndProperty
  374.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  375.             Style           =   3
  376.          EndProperty
  377.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  378.             Caption         =   "查询"
  379.             Key             =   "cx"
  380.             ImageKey        =   "cx"
  381.          EndProperty
  382.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  383.             Style           =   3
  384.          EndProperty
  385.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  386.             Caption         =   "全选"
  387.             Key             =   "qx"
  388.             ImageKey        =   "qx"
  389.          EndProperty
  390.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  391.             Caption         =   "全消"
  392.             Key             =   "qq"
  393.             ImageKey        =   "qq"
  394.          EndProperty
  395.          BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  396.             Style           =   3
  397.          EndProperty
  398.          BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  399.             Caption         =   "凭证"
  400.             Key             =   "pz"
  401.             ImageKey        =   "pz"
  402.          EndProperty
  403.          BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  404.             Style           =   3
  405.          EndProperty
  406.          BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  407.             Caption         =   "帮助"
  408.             Key             =   "bz"
  409.             ImageKey        =   "bz"
  410.          EndProperty
  411.          BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  412.             Caption         =   "退出"
  413.             Key             =   "fh"
  414.             ImageKey        =   "tc"
  415.          EndProperty
  416.       EndProperty
  417.       BorderStyle     =   1
  418.       Begin MSComctlLib.Toolbar GsToolbar 
  419.          Height          =   525
  420.          Left            =   9150
  421.          TabIndex        =   6
  422.          Top             =   0
  423.          Width           =   1695
  424.          _ExtentX        =   2990
  425.          _ExtentY        =   926
  426.          ButtonWidth     =   1455
  427.          ButtonHeight    =   926
  428.          AllowCustomize  =   0   'False
  429.          Appearance      =   1
  430.          Style           =   1
  431.          ImageList       =   "ImageList1"
  432.          _Version        =   393216
  433.          BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  434.             NumButtons      =   2
  435.             BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  436.                Caption         =   "保存格式"
  437.                Key             =   "bcgs"
  438.                ImageKey        =   "bcgs"
  439.             EndProperty
  440.             BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  441.                Caption         =   "默认列宽"
  442.                Key             =   "hfmrgs"
  443.                ImageKey        =   "mrlk"
  444.             EndProperty
  445.          EndProperty
  446.       End
  447.    End
  448.    Begin VB.Label Lab_OperStatus 
  449.       BackColor       =   &H000080FF&
  450.       Caption         =   "1"
  451.       Height          =   345
  452.       Left            =   10500
  453.       TabIndex        =   5
  454.       Top             =   1740
  455.       Visible         =   0   'False
  456.       Width           =   345
  457.    End
  458. End
  459. Attribute VB_Name = "BadDebt_FrmLossList"
  460. Attribute VB_GlobalNameSpace = False
  461. Attribute VB_Creatable = False
  462. Attribute VB_PredeclaredId = True
  463. Attribute VB_Exposed = False
  464. '**************************************************************************************
  465. '*    模 块 名 称 :坏帐损失处理
  466. '*    功 能 描 述 :此功能模块主要完成对发票(普通发票和专用发票)、其他应收款、代垫费用进行坏帐处理
  467. '*    程序员姓名  :陈恩宇
  468. '*    最后修改人  :陈恩宇
  469. '*    最后修改时间:2001/12/19
  470. '*    备        注:程序中所有依实际情况自定义部分均用[>> <<]括起
  471. '*
  472. '*    1.每次调入外部功能窗体,均要加锁ChangeLock=True,窗体关闭后解锁ChangeLock=false
  473. '*
  474. '*    3.Lab_OperStatus 用此标签来标识单据录入状态(默认值为1) 1-浏览 2-修改
  475. '*
  476. '***************************************************************************************
  477.  
  478. '以下为自定义变量
  479. Dim VouchRow As Long                     '每张凭证内分录的ID值
  480. Dim EffectVouchId As Long                '生成正式凭证的凭证ID
  481. Dim Jsq_Max As Long                      '网格的最大记录数
  482. Dim OperationNum    As Long              '本次转帐操作批号
  483. Dim YbJe As Double                       '原币金额
  484. Dim BbJe As Double                       '本币金额
  485. Dim Ybhj As Double                       '原币合计
  486. Dim Bbhj As Double                       '本币合计
  487. Dim Int_Kjyear As Integer                '当前会计年度
  488. Dim Int_Period As Integer                '会计期间
  489. Dim AccRate As Double                    '记帐汇率
  490. Dim BankBillNo As String                 '银行票号
  491. Dim SsCode As String                     '结算方式
  492. Dim ForeignCurrCode As String            '外币编码
  493. Dim BillDate As Date                     '单据日期
  494. Dim PersonName As String                 '经办人名称
  495. Dim CustName As String                   '客户
  496. Dim SuppName As String                   '供应商
  497.  
  498. '其它固定使用变量
  499. Dim Tsxx As String                              '系统信息提示(Fixed)
  500. Dim ReportTitle As String                       '报表主标题(Fixed)
  501.    
  502. '以下为固定使用变量(网格)
  503. Dim Cxnrrec As New ADODB.Recordset              '显示查询内容动态集
  504. Dim Dyymctbl As New DY_Dyymsz                   '打印页面窗体变量
  505. Dim GridCode As String                          '显示网格网格代码
  506. Dim GridInf() As Variant                        '整个网格设置信息
  507. Dim Pmbcsjhs As Long                            '屏幕网格保持数据行数(大于等于1)
  508. Dim Fzxwghs As Integer                          '辅助项网格行数(包括合计行)
  509. Dim Sfxshjwg As Boolean                         '是否显示合计网格
  510. Dim Qslz As Long                                '网格隐藏(非操作显示)列数
  511. Dim Sjhgd As Double                             '网格数据行高度
  512. Dim GridBoolean() As Boolean                    '网格列信息(布尔型)
  513. Dim GridStr()  As String                        '网格列信息(字符型)
  514. Dim GridInt() As Integer                        '网格列信息(整型)
  515. Dim Sfblbzkd As Boolean                         '是否保留帮助宽度(字段提供帮助时,是否为按钮保留空间)
  516. Dim Dqlrwgh As Long                             '当前录入数据网格行
  517. Dim Dqlrwgl As Long                             '当前录入数据网格列
  518. Dim Dqlkwgh As Long                             '刚刚离开网格行(不一定为录入行)
  519. Dim Dqlkwgl As Long                             '刚刚离开网格列
  520. Dim Dqtoprow As Long                            '当前录入状态时最上端可视行
  521. Dim Dqleftcol As Long                           '当前录入状态时最左端可视列
  522. Dim Zdlrqnr As String                           '字段录入修改前内容(用来判断内容是否修改)
  523. Dim Wbkbhlock As Boolean                        '文本框改变值锁
  524. Dim changelock As Boolean                       '网格行列改变控制锁(用来区别用户改变.程序改变)
  525. Dim Gdtlock As Boolean                          '滚动条滚动控制(用来区别用户改变.程序改变)
  526. Dim Yxxpdlock As Boolean                        '字段有效性判断锁(内容不修改不需进行字段有效性判断)
  527. Dim Hyxxpdlock As Boolean                       '行有效性判断锁(字段内容不修改不需进行行有效性判断)
  528. Dim Valilock As Boolean                         '文本框失去焦点是否进行有效性控制(TRUE 为锁定*限用网格录入)
  529. Dim Shsfts As Boolean                           '删除记录行是否提示
  530. Dim Szzls As Integer                            '网格信息数组最大下标值(网格列数-1)
  531. Private Sub Form_KeyPress(KeyAscii As Integer)      '限制录入字符"'"
  532.     Select Case KeyAscii
  533.         Case 39           '屏蔽字符"'"
  534.             KeyAscii = 0
  535.     End Select
  536.     
  537. End Sub
  538. Private Sub Form_Load()                              '窗 体 装 入
  539.   
  540.     '初始化各种锁值(Fixed)
  541.     changelock = False             '网格行列改变控制锁
  542.     Gdtlock = False                '滚动条滚动控制
  543.     Yxxpdlock = True               '字段有效性判断锁
  544.     Hyxxpdlock = True              '行有效性判断锁
  545.     Wbkbhlock = False              '文本框内容改变锁
  546.      
  547.     '报表主标题及报表编码(Fixed)
  548.     ReportTitle = "坏帐损失列表"
  549.     XtReportCode = "Ar_BadLossList"
  550.     Load Dyymctbl
  551.     
  552.     '调 入 网 格(Fixed)
  553.     GridCode = "Ar_BadLossList"      '网格属性编码
  554.     Call BzWgcsh(WglrGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
  555.     
  556.     Qslz = GridInf(1)
  557.     Sjhgd = GridInf(2)
  558.     Pmbcsjhs = GridInf(3)
  559.     Fzxwghs = GridInf(4)
  560.     Sfblbzkd = GridInf(5)
  561.     Shsfts = GridInf(6)
  562.     Sfxshjwg = GridInf(7)
  563.     Szzls = WglrGrid.Cols - 1
  564.     
  565.     '设置标题栏宽度、网格宽度高度(Fixed)
  566.     Pic_Title.Move 50, Pic_Title.Top, Me.Width - 150, Pic_Title.Height
  567.     WglrGrid.Move 50, Pic_Title.Top + Pic_Title.Height, Me.Width - 150
  568.     WglrGrid.Height = Me.Height - WglrGrid.Top - 380
  569.       
  570.     '设置状态为修改状态
  571.     Lab_OperStatus = "2"
  572.  
  573. End Sub
  574. Private Sub Form_Unload(Cancel As Integer)           '窗体卸载
  575.     If Not Fun_Drfrmyxxpd Then
  576.        Cancel = True
  577.        Exit Sub
  578.     End If
  579.     '卸载条件窗体
  580.     BadDebt_FrmLossQuery.UnloadCheck.Value = 1
  581.     Unload BadDebt_FrmLossQuery
  582.     
  583.     '卸载打印页面窗体
  584.     Unload Dyymctbl
  585. End Sub
  586. Private Sub Sub_Query(Int_QueryType As Integer)                                     '生成查询结果(Define)
  587.     
  588.     '过程参数:Int_QueryType 0-"点确定按钮"查询  1-"刷新"查询
  589.     Dim Rec_Query As New ADODB.Recordset        '查询结果动态集
  590.     Dim Coljsq As Long                          '网格列计数器
  591.     Dim jsqte As Integer                        '临时动态计数器
  592.     Dim TempForCur As String                    '临时币别代码
  593.     Dim BanTotal(6) As Single                   '计算应收总帐合计
  594.     Dim Rec_Bill As New ADODB.Recordset         '临时查询结果动态集
  595.     Dim BillID As Integer                       '单据号
  596.     
  597.     WglrGrid.Clear 1
  598.     
  599.     '禁止网格刷新动作,为加快网格显示速度(Fixed)
  600.     WglrGrid.Redraw = False
  601.     
  602.     '以下为自定义部分[
  603.  
  604.     If Int_QueryType = 0 Then   '0-"点确定按钮"查询
  605.         With BadDebt_FrmLossQuery
  606.             
  607.             '填充表头部门内容
  608.             BadDebt_FrmLossList.Lab_Cust.Caption = "客户: " & .LrText(0).Text
  609.             BadDebt_FrmLossList.Lab_Cust.Tag = Trim(.LrText(0).Tag)
  610.             
  611.             '生成查询条件
  612.             Str_QueryCondi = " where 1=1 and RPFlag = 'AR' and BillItemCode like '[1-2]%' and YbYsje>YbCancelJe"
  613.          
  614.             For jsqte = 1 To 4
  615.                 Select Case jsqte
  616.                     Case 1  '客户
  617.                         If Trim(.LrText(0).Text) <> "" Then
  618.                             Str_QueryCondi = Str_QueryCondi & " and PsCode = '" & Trim(.LrText(0).Tag) & "'"
  619.                         End If
  620.                     Case 2  '币别
  621.                         If Trim(.LrText(1).Text) <> "" Then
  622.                             Str_QueryCondi = Str_QueryCondi & " And ForeignCurrCode='" & Trim(.LrText(1).Tag) & "'"
  623.                         End If
  624.                     Case 3  '部门
  625.                         If Trim(.LrText(2).Text) <> "" Then
  626.                             Str_QueryCondi = Str_QueryCondi & " And DeptCode= '" & Trim(.LrText(2).Tag) & "'"
  627.                         End If
  628.                     Case 4 '经办人
  629.                         If Trim(.LrText(3).Text) <> "" Then
  630.                             Str_QueryCondi = Str_QueryCondi & " And PersonCode= '" & Trim(.LrText(3).Tag) & "'"
  631.                         End If
  632.                 
  633.                 End Select
  634.             Next jsqte
  635.         End With
  636.     Else
  637.         '1-"刷新"查询
  638.         
  639.     End If
  640.      
  641.     Sqlstr = "SELECT * FROM Ar_v_AccMxList " & Str_QueryCondi & "  Order By BillDate,BillCode"
  642.     Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  643.     With Rec_Query
  644.         
  645.         WglrGrid.Rows = WglrGrid.FixedRows
  646.         jsqte = WglrGrid.FixedRows
  647.         Do While Not .EOF
  648.             WglrGrid.AddItem ""
  649.             
  650.             '[>>自定义填充内容
  651.             WglrGrid.TextMatrix(jsqte, 0) = "*"
  652.             WglrGrid.TextMatrix(jsqte, Sydz("001", GridStr(), Szzls)) = False                                                     '选择
  653.             WglrGrid.TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = ""                                                        '摘要
  654.             WglrGrid.TextMatrix(jsqte, Sydz("003", GridStr(), Szzls)) = Trim((.Fields!BillItemName) & "")                         '单据类型名称
  655.             WglrGrid.TextMatrix(jsqte, Sydz("018", GridStr(), Szzls)) = Trim((.Fields!BillItemCode) & "")                         '单据类型编号
  656.             WglrGrid.TextMatrix(jsqte, Sydz("004", GridStr(), Szzls)) = Trim((.Fields!BillCode) & "")                             '单据号
  657.             WglrGrid.TextMatrix(jsqte, Sydz("005", GridStr(), Szzls)) = Format(.Fields!BillDate, "yyyy-mm-dd")                    '单据日期
  658.             
  659.             If Val(Trim((.Fields!VouchNo) & "")) <> 0 Then
  660.                 WglrGrid.TextMatrix(jsqte, Sydz("006", GridStr(), Szzls)) = Trim((.Fields("VouchClassCode") & "")) & "-" & Trim(.Fields!VouchNo) '凭证号
  661.             End If
  662.             
  663.             WglrGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = Trim((.Fields!DeptCode) & "")                             '部门编码
  664.             WglrGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)) = Trim((.Fields!DeptName) & "")                             '部门名称
  665.             WglrGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)) = Trim((.Fields!PersonCode) & "")                           '经办人编码
  666.             WglrGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = Trim((.Fields!PersonName) & "")                           '经办人
  667.             WglrGrid.TextMatrix(jsqte, Sydz("011", GridStr(), Szzls)) = Trim((.Fields!ForeignCurrCode) & "")                      '币别编码
  668.             WglrGrid.TextMatrix(jsqte, Sydz("012", GridStr(), Szzls)) = Trim((.Fields!ForeignCurrName) & "")                      '币别名称
  669.             
  670.             If Val(.Fields!YbYsje) - Val(.Fields!YbCancelje) > 0 Then
  671.                 WglrGrid.TextMatrix(jsqte, Sydz("013", GridStr(), Szzls)) = Val(.Fields!YbYsje) - Val(.Fields!YbCancelje)         '原币余额
  672.             End If
  673.             
  674.             WglrGrid.TextMatrix(jsqte, Sydz("014", GridStr(), Szzls)) = Val(.Fields!AccRate)                                      '记帐汇率
  675.             
  676.             WglrGrid.TextMatrix(jsqte, Sydz("015", GridStr(), Szzls)) = WglrGrid.TextMatrix(jsqte, Sydz("013", GridStr(), Szzls)) '原币坏帐余额
  677.             WglrGrid.TextMatrix(jsqte, Sydz("017", GridStr(), Szzls)) = Val(.Fields!BbYsje) - Val(.Fields!BbCancelje)             '本币坏帐余额
  678.             WglrGrid.TextMatrix(jsqte, Sydz("016", GridStr(), Szzls)) = Trim((.Fields!AccCodeArAp) & "")                          '应收科目编码
  679.             
  680.             '<<]
  681.             
  682.             '设置数据行高度(Fixed)
  683.             WglrGrid.RowHeight(jsqte) = Sjhgd
  684.             
  685.             '动态集指针加1,同时将计数器加1(Fixed)
  686.             .MoveNext
  687.             jsqte = jsqte + 1
  688.             
  689.         Loop
  690.         
  691.     End With
  692.     
  693.     '将网格刷新解禁(Fixed)
  694.     WglrGrid.Redraw = True
  695.     ']以上为用户自定义部分
  696. End Sub
  697. Private Sub Timer1_Timer()                                 '在窗体激活后调入查询程序
  698.     
  699.     Me.Timer1.Enabled = False
  700.     Me.Visible = True
  701.     Call Sub_Search
  702. End Sub
  703. Private Sub Sub_Search()                                    '首次加载调用查询条件
  704.     BadDebt_FrmLossQuery.Show 1
  705.     If UCase(Trim(BadDebt_FrmLossQuery.Tag)) = "TRUE" Then
  706.         '生成查询结果
  707.         Call Sub_Query(0)
  708.     Else
  709.         BadDebt_FrmLossQuery.UnloadCheck.Value = 1
  710.         Unload BadDebt_FrmLossQuery
  711.         Unload Me
  712.     End If
  713.     
  714. End Sub
  715. Private Sub Tlb_Action_ButtonClick(ByVal Button As MSComctlLib.Button)             '用户点击工具条
  716.      
  717.     '屏蔽文本框,下拉组合框有效性判断
  718.      
  719.     Valilock = True
  720.      
  721.     '屏蔽网格失去焦点产生的有效性判断
  722.      
  723.     changelock = True
  724.      
  725.     Select Case Button.Key
  726.         Case "ymsz"                                          '页面设置
  727.             Dyymctbl.Show 1
  728.         Case "yl"                                            '预 览
  729.             If Fun_Drfrmyxxpd Then
  730.                 Call bbyl(True)
  731.             End If
  732.         Case "dy"                                            '打 印
  733.             If Fun_Drfrmyxxpd Then
  734.                 Call bbyl(False)
  735.             End If
  736.         Case "cx"                                            '查 询
  737.             BadDebt_FrmLossQuery.Show 1
  738.              
  739.              '生成查询结果
  740.             If UCase(Trim(BadDebt_FrmLossQuery.Tag)) = "TRUE" Then Call Sub_Query(0)
  741.             
  742.         Case "qx"                                            '全 选
  743.             Call Sub_WgSelect(0)
  744.         Case "qq"                                            '全 消
  745.             Call Sub_WgSelect(1)
  746.         Case "pz"                                            '凭 证
  747.             If Fun_Drfrmyxxpd Then
  748.                 Call Sub_SaveBill
  749.             End If
  750.         Case "bz"                                            '帮 助
  751.             Call F1bz
  752.         Case "fh"                                            '退 出
  753.             Unload Me
  754.             
  755.     End Select
  756.        
  757.     '解 锁
  758.     Valilock = False
  759.     changelock = False
  760.         
  761. End Sub
  762. Private Sub Sub_WgSelect(Xzzt As Integer)
  763.     
  764.     Dim jsqte As Integer
  765.     Dim TmpJsq As Integer
  766.     
  767.     '非数据行退出
  768.     If WglrGrid.Rows = WglrGrid.FixedRows Then
  769.         Exit Sub
  770.     End If
  771.     
  772.     jsqte = WglrGrid.Rows - WglrGrid.FixedRows
  773.     
  774.     With WglrGrid
  775.         
  776.         Select Case Xzzt
  777.             Case 0  '当选择全选时选中所有记录
  778.                 For TmpJsq = .FixedRows To jsqte
  779.                     .TextMatrix(TmpJsq, Sydz("001", GridStr(), Szzls)) = True
  780.                 Next TmpJsq
  781.             Case 1  '当选择全选时放弃所有记录
  782.                 For TmpJsq = .FixedRows To jsqte
  783.                     .TextMatrix(TmpJsq, Sydz("001", GridStr(), Szzls)) = False
  784.                 Next TmpJsq
  785.             
  786.         End Select
  787.         
  788.     End With
  789.     
  790. End Sub
  791. Private Sub Form_KeyUp(KeyCode As Integer, Shift As Integer)        '支持热键操作
  792.   
  793.     If Shift = 2 Then
  794.         Select Case UCase(Chr(KeyCode))
  795.             Case "P"                   'Ctrl+P 打印
  796.                 If Tlb_Action.Buttons("dy").Enabled Then
  797.                     Call bbyl(False)
  798.                 End If
  799.         End Select
  800.     End If
  801.     
  802. End Sub
  803. Private Sub Wbkcl()                                                 '文本框录入之前处理(根据实际情况)
  804.  
  805.     Dim xswbrr As String
  806.  
  807.     With WglrGrid
  808.         Zdlrqnr = Trim(.Text)
  809.         xswbrr = Trim(.Text)
  810.     
  811.         If GridBoolean(.Col, 3) Then   '列表框录入
  812.     
  813.             '填充列表框程序
  814.             Call FillCombo(YdCombo, GridStr(.Col, 5), xswbrr, 0)
  815.         Else
  816.             Wbkbhlock = True
  817.        
  818.             '====以下为用户自定义
  819.             Ydtext.Text = xswbrr
  820.             '====以上为用户自定义
  821.          
  822.             Wbkbhlock = False
  823.             Ydtext.SelStart = Len(Ydtext.Text)
  824.         End If
  825.     End With
  826.     
  827. End Sub
  828. Private Function sjzdyxxpd(Dqpdwgh As Long, Dqpdwgl As Long)        '录入数据字段有效性判断,同时进行字段录入事后处理
  829.     
  830.     Dim Str_JudgeText As String            '临时有效性判断字段内容
  831.     Dim Coljsq As Long                     '临时列计数器
  832.     Dim RecTemp As New ADODB.Recordset     '临时使用动态集
  833.     Dim Dbl_Qcye As Double                 '临时期初余额
  834.     Dim ForCode As String                  '币别编码
  835.     Dim YbJe As Single                     '原币金额
  836.     Dim Rate As Single                     '记帐汇率
  837.     Dim Dbl_Bbje As Single                 '计算本币金额
  838.     Dim Bln_ConVertFlag As Boolean         '汇率记帐方式
  839.     Dim Dbl_AccRate As Double              '根据币别获取记帐汇率
  840.     
  841.     With WglrGrid
  842.     
  843.         '非录入状态有效性为合法
  844.         If Yxxpdlock Or .Row < .FixedRows Then
  845.            sjzdyxxpd = True
  846.            Exit Function
  847.         End If
  848.  
  849.         Str_JudgeText = Trim(.TextMatrix(Dqpdwgh, Dqpdwgl))
  850.         Select Case GridStr(Dqpdwgl, 1)
  851.          
  852.             '以下为自定义部分[
  853.                 '1.放置字段有效性判断程序
  854.                     
  855.                     Case "015"
  856.                         YbJe = Val(.TextMatrix(Dqpdwgh, Sydz("015", GridStr(), Szzls)))         '原币金额
  857.                         Rate = Val(.TextMatrix(Dqpdwgh, Sydz("014", GridStr(), Szzls)))         '记帐汇率
  858.                         ForCode = Trim(.TextMatrix(Dqpdwgh, Sydz("011", GridStr(), Szzls)))     '币别编码
  859.                         Call Sub_GetAccRate(ForCode, Bln_ConVertFlag, Dbl_AccRate)              '根据币别获取记帐汇率
  860.                         If YbJe > Val(.TextMatrix(Dqpdwgh, Sydz("013", GridStr(), Szzls))) Then
  861.                             Tsxx = "坏帐金额不能大于余额!"
  862.                             GoTo Lrcwcl
  863.                         End If
  864.                         
  865.                         If Bln_ConVertFlag Then
  866.                             If YbJe <> 0 And Rate <> 0 Then
  867.                                 Dbl_Bbje = Val(Format(Val(YbJe / Rate), "##." + String(Xtjexsws, "0")))
  868.                             Else
  869.                                 Dbl_Bbje = 0
  870.                             End If
  871.                         Else
  872.                             Dbl_Bbje = Val(Format(Val(YbJe * Rate), "##." + String(Xtjexsws, "0")))
  873.                         End If
  874.                             
  875.                         .TextMatrix(Dqpdwgh, Sydz("017", GridStr(), Szzls)) = Dbl_Bbje          '计算本币坏帐金额
  876.                     
  877.                 '2.放置字段事后处理程序
  878.                 
  879.             '以上为自定义部分]
  880.             
  881.         End Select
  882.      
  883.         '字段录入正确后为零字段清空
  884.         Call Qkwlzd(Dqpdwgh, Dqpdwgl)
  885.     
  886.         sjzdyxxpd = True
  887.         Yxxpdlock = True
  888.         Exit Function
  889.     
  890.     End With
  891.   
  892. Lrcwcl:    '录入错误处理
  893.     With WglrGrid
  894.         Call Xtxxts(Tsxx, 0, 1)
  895.         changelock = True
  896.         .Select Dqpdwgh, Dqpdwgl
  897.         changelock = False
  898.         Call xswbk
  899.         sjzdyxxpd = False
  900.         Exit Function
  901.     End With
  902.     
  903. End Function
  904. Private Function Sjhzyxxpd(ByVal Yxxpdh As Long) As Boolean                  '录入数据行有效性判断,同时进行行处理
  905.  
  906.     Dim Lrywlz As Long                     '录入错误列值(Fixed)
  907.     Dim RecTemp As New ADODB.Recordset     '临时使用动态集
  908.     Dim Sqlstr As String                   '临时查询字符串
  909.     Dim Str_Ccode As String                '临时索引编码
  910.     With WglrGrid
  911.         '行没有发生变化则不进行有效性判断
  912.         If Hyxxpdlock Then
  913.             Sjhzyxxpd = True
  914.             Exit Function
  915.         End If
  916.     
  917.         '以下为自定义部分[
  918.     
  919.         '1.1首先进行单个不能为空或不能为零判断(Fixed)
  920.         For jsqte = Qslz To .Cols - 1
  921.             '字段不能为空
  922.             If GridInt(jsqte, 5) = 1 Then
  923.                 If Len(Trim(.TextMatrix(Yxxpdh, jsqte))) = 0 Then
  924.                     Tsxx = GridStr(jsqte, 2)
  925.                     Lrywlz = jsqte
  926.                     GoTo Lrcwcl
  927.                     Exit For
  928.                 End If
  929.             End If
  930.             
  931.             '字段不能为零
  932.             If GridInt(jsqte, 5) = 2 Then
  933.                 If Val(Trim(.TextMatrix(Yxxpdh, jsqte))) = 0 Then
  934.                     Tsxx = GridStr(jsqte, 2)
  935.                     Lrywlz = jsqte
  936.                     GoTo Lrcwcl
  937.                     Exit For
  938.                 End If
  939.             End If
  940.         Next jsqte
  941.     
  942.     
  943.         '1.2进行其他有效性判断,编写格式同1.1
  944.                 
  945.         '2.放置行处理程序(当数据行通过有效性判断)
  946.            
  947.     End With
  948.     '以上为自定义部分]
  949.     Sjhzyxxpd = True
  950.     Hyxxpdlock = True
  951.     Exit Function
  952. Swcwcl:
  953.     Cw_DataEnvi.DataConnect.RollbackTrans
  954.     Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  955.     Call Xtxxts(Tsxx, 0, 1)
  956.     Exit Function
  957. Lrcwcl:      '录入错误处理
  958.     With WglrGrid
  959.         Call Xtxxts(Tsxx, 0, 1)
  960.         changelock = True
  961.         .Select Yxxpdh, Lrywlz
  962.         changelock = False
  963.         Call xswbk
  964.         Sjhzyxxpd = False
  965.         Exit Function
  966.     End With
  967.     
  968. End Function
  969. Private Function Sub_SaveBill() As Boolean                                   '保 存 单 据
  970.     
  971.     Dim RecTemp As New ADODB.Recordset                    '临时使用动态集
  972.     Dim Rec_VouchMain As New ADODB.Recordset              '单据主表动态集
  973.     Dim Rec_VouchSub As New ADODB.Recordset               '单据子表动态集
  974.     Dim Rowjsq As Long                                    '网格行计数器
  975.     Dim Coljsq As Long                                    '网格列计数器
  976.     Dim jsqte As Integer                                  '临时计数器
  977.     Dim Lng_RowCount As Long                              '有效数据行计数器
  978.     Dim Lrywlz As Long                                    '录入有误列值
  979.     Dim Rec_AccListAdd As New ADODB.Recordset             '临时动态集(追加明细帐)
  980.     Dim Rec_AccSum As New ADODB.Recordset                 '临时动态集(追加总帐)
  981.     Dim Str_PSCode As String                              '客户编码
  982.     Dim Str_DeptCode As String                            '部门编码
  983.     Dim Str_PersonCode As String                          '经办人编码
  984.     Dim Str_ForeignCurrCode As String                     '币别编码
  985.     
  986.     Sub_SaveBill = False
  987.     
  988.     '一.============先对单据内容进行有效性判断==============='
  989.     
  990.     '[>>下面将对所有有效数据行进行有效性判断
  991.     
  992.     Lng_RowCount = 0
  993.     
  994.     With WglrGrid
  995.         For Rowjsq = .FixedRows To .Rows - 1
  996.             '带*号者为有效数据行(Fixed)
  997.             If .TextMatrix(Rowjsq, 0) <> "*" Then
  998.                 Exit For
  999.             Else
  1000.                 If .TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)) = True Then
  1001.                     Lng_RowCount = Lng_RowCount + 1
  1002.                 End If
  1003.             End If
  1004.             
  1005.             '1.首先进行为空或为零判断(Fixed)
  1006.             
  1007.             For jsqte = Qslz To .Cols - 1
  1008.                 
  1009.                 '字段不能为空
  1010.                 If GridInt(jsqte, 5) = 1 Then
  1011.                     If Len(Trim(.TextMatrix(Rowjsq, jsqte))) = 0 Then
  1012.                         Tsxx = GridStr(jsqte, 2)
  1013.                         Lrywlz = jsqte
  1014.                         GoTo Lrcwcl
  1015.                         Exit For
  1016.                     End If
  1017.                 End If
  1018.                 
  1019.                 '字段不能为零
  1020.                 If GridInt(jsqte, 5) = 2 Then
  1021.                     If Val(Trim(.TextMatrix(Rowjsq, jsqte))) = 0 Then
  1022.                         Tsxx = GridStr(jsqte, 2)
  1023.                         Lrywlz = jsqte
  1024.                         GoTo Lrcwcl
  1025.                         Exit For
  1026.                     End If
  1027.                 End If
  1028.             Next jsqte
  1029.             
  1030.         Next Rowjsq
  1031.         
  1032.         '单据分录行数不能为零(Fixed)
  1033.         If Lng_RowCount = 0 Then
  1034.             Tsxx = "没有进行坏帐损失处理,不能保存!"
  1035.             Call Xtxxts(Tsxx, 0, 1)
  1036.             Exit Function
  1037.         End If
  1038.         
  1039.         '[>>
  1040.         '此处可以定义整张单据不能通过有效性检查的理由
  1041.         '<<]
  1042.     End With  '网格
  1043.     
  1044.      '判断单据日期是否有效,如果单据日期所在的会计期间已经结帐,则不能保存
  1045.     If Not Fun_GetPeriod(CDate(Format(Xtrq, "yyyy-mm-dd")), Int_Kjyear, Int_Period) Then
  1046.         Exit Function
  1047.     End If
  1048.     
  1049.     If Sub_Run = False Then
  1050.         Exit Function
  1051.     End If
  1052.     
  1053.     '二.=============如果以上有效性检查均顺利通过,则执行存盘动作============'
  1054.     
  1055.     '对存盘进行事务处理(Fixed)
  1056.     On Error GoTo Swcwcl
  1057.     Cw_DataEnvi.DataConnect.BeginTrans
  1058.     
  1059.     '判断单据状态以进行不同处理
  1060.     
  1061.     '1.对网格固定行进行处理
  1062.     If Trim(Lab_OperStatus) = "2" Then
  1063.         
  1064.     '打开单据子表动态集
  1065.     If Rec_VouchSub.State = 1 Then Rec_VouchSub.Close
  1066.     Rec_VouchSub.Open "Select * From RP_BadDebt Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1067.     
  1068.     '将网格中有效数据行写入单据子表
  1069.     For Rowjsq = WglrGrid.FixedRows To WglrGrid.Rows - 1
  1070.         If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
  1071.             Exit For
  1072.         End If
  1073.         If WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)) = True Then
  1074.             With Rec_VouchSub
  1075.                 .AddNew
  1076.                 .Fields("PsCode") = Trim(Me.Lab_Cust.Tag)                                                               '客户编码
  1077.                 .Fields("Digest") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls)))                    '摘要
  1078.                 .Fields("BillItemCode") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("018", GridStr(), Szzls)))              '单据类型
  1079.                 .Fields("BillCode") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))                  '单据号
  1080.                 .Fields("BillDate") = Format(WglrGrid.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)), "yyyy-mm-dd")  '单据日期
  1081.                 .Fields("DeptCode") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("007", GridStr(), Szzls)))                  '部门
  1082.                 .Fields("PersonCode") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("009", GridStr(), Szzls)))                '经办人
  1083.                 .Fields("DebtDate") = Format(Xtrq, "yyyy-mm-dd")                                                        '坏帐日期
  1084.                 .Fields("KjYear") = Int_Kjyear                                                                          '会计年度
  1085.                 .Fields("Period") = Int_Period                                                                          '会计期间
  1086.                 .Fields("ForeignCurrCode") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("011", GridStr(), Szzls)))           '币别
  1087.                 .Fields("AccRate") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("014", GridStr(), Szzls)))                    '原币坏帐金额
  1088.                 .Fields("YbYsje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("015", GridStr(), Szzls)))                     '汇率
  1089.                 .Fields("BbYsje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("017", GridStr(), Szzls)))                     '本币坏帐金额
  1090.                 
  1091.                 If Fun_GetAccInformation("AR_baddebtsMothed") = 1 Then
  1092.                     .Fields("AccCode") = Fun_GetInputCode("AR_BadDebtPrepAccCode")                                      '坏帐准备科目(备抵法)
  1093.                 Else
  1094.                     .Fields("AccCode") = Fun_GetInputCode("AR_BadDebtAccCode")                                          '坏帐损失科目(非备抵法)
  1095.                 End If
  1096.                 .Fields("AccCodeArAp") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("016", GridStr(), Szzls)))               '应收科目编码
  1097.                 '输出单据类型
  1098.                 .Fields("BadItemCode") = "60"
  1099.                 
  1100.                 '凭证信息
  1101.                 .Fields("VouchId") = EffectVouchId
  1102.                 .Fields("IfBuildVouch") = True
  1103.                 .Update
  1104.                 
  1105.             End With
  1106.             
  1107.             Dim Rec_AccList As New ADODB.Recordset
  1108.             Dim BillNo As String
  1109.             
  1110.             '根据坏帐损失回写明细帐核销数据(回写坏帐损失)
  1111.             BillNo = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))
  1112.             With Rec_AccList
  1113.                  If .State = 1 Then .Close
  1114.                 .Open "Select * from RP_AccList Where BillCode='" & BillNo & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1115.                 If Not Rec_AccList.EOF Then
  1116.                     .Fields("YbCancelje") = .Fields("YbCancelje") + Rec_VouchSub.Fields("YbYsje")               '原币核销金额
  1117.                     .Fields("BbCancelje") = .Fields("BbCancelje") + Rec_VouchSub.Fields("BbYsje")               '本币核销金额
  1118.                     If Val(.Fields("YbCancelje")) = Val(.Fields("YbYsje")) Then                                 '是否核销完毕标识
  1119.                         .Fields("OverStatus") = 1
  1120.                     End If
  1121.                     .Update
  1122.                 End If
  1123.             End With
  1124.             
  1125.             '根据确定的坏帐损失登记到应收明细帐(增加其他应收数据)
  1126.             With Rec_AccListAdd
  1127.                 If .State = 1 Then .Close
  1128.                 .Open "Select * From RP_AccList", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1129.                 .AddNew
  1130.                 .Fields("RPFlag") = "Ar"                                                                        '应收/应付标识
  1131.                 .Fields("PsCode") = Trim(Rec_VouchSub.Fields("PsCode"))                                         '客户编码
  1132.                 .Fields("BillDate") = Xtrq                                                                      '单据日期
  1133.                 .Fields("KjYear") = Int_Kjyear                                                                  '会计年度
  1134.                 .Fields("Period") = Int_Period                                                                  '会计期间
  1135.                 .Fields("BillItemCode") = "60"                                                                  '单据类型(坏帐损失)
  1136.                 .Fields("BillID") = 0                                                                           '凭证号
  1137.                 .Fields("BillCode") = 0                                                                         '单据号
  1138.                 .Fields("Digest") = "坏帐损失"                                                                  '摘要
  1139.                 .Fields("ForeignCurrCode") = Trim(Rec_VouchSub.Fields("ForeignCurrCode") & "")                  '币别
  1140.                 .Fields("AccRate") = Val(Rec_VouchSub.Fields("AccRate"))                                        '汇率
  1141.                 .Fields("YbYsje") = -Val(Rec_VouchSub.Fields("YbYsje"))                                         '原币应收金额
  1142.                 .Fields("BbYsje") = -Val(Rec_VouchSub.Fields("BbYsje"))                                         '本币应收金额
  1143.                 .Fields("DeptCode") = Trim(Rec_VouchSub.Fields("DeptCode") & "")                                '部门编码
  1144.                 .Fields("PersonCode") = Trim(Rec_VouchSub.Fields("PersonCode") & "")                            '经办人编码
  1145.                 .Fields("Maker") = Xtczy                                                                        '制单
  1146.                 .Fields("Checker") = Xtczy                                                                      '审核
  1147.                 .Fields("AccCode") = Trim(Rec_VouchSub.Fields("AccCode") & "")                                  '坏帐准备科目(损失科目)
  1148.                 .Fields("AccCodeArAp") = Trim(Rec_VouchSub.Fields("AccCodeArAp") & "")                          '应收科目编码
  1149.                 '因为核销追加核销标识
  1150.                 .Fields("OverStatus") = 1                                                                       '是否核销完毕标识
  1151.                 
  1152.                 '凭证信息
  1153.                 .Fields("VouchId") = EffectVouchId
  1154.                 .Fields("IfBuildVouch") = True
  1155.                 .Update
  1156.                 
  1157.             End With
  1158.             
  1159.             '根据确定的坏帐损失登记应收/应付总帐
  1160.             Str_PSCode = Trim(Rec_VouchSub.Fields("PSCode") & "")
  1161.             Str_DeptCode = Trim(Rec_VouchSub.Fields("DeptCode") & "")
  1162.             Str_PersonCode = Trim(Rec_VouchSub.Fields("PersonCode") & "")
  1163.             Str_ForeignCurrCode = Trim(Rec_VouchSub.Fields("ForeignCurrCode") & "")
  1164.             
  1165.             With Rec_AccSum
  1166.                 If .State = 1 Then .Close
  1167.                .Open "Select * From RP_AccSum Where RpFlag='Ar' And PSCode='" & Str_PSCode & _
  1168.                 "' And DeptCode='" & Str_DeptCode & "' And PersonCode='" & Str_PersonCode & "' And ForeignCurrCode='" & Str_ForeignCurrCode & "' And kjYear=" & Int_Kjyear & " And Period=" & Int_Period, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1169.                 
  1170.                 If Not Rec_AccSum.EOF Then
  1171.                    .Fields("YbYsje") = .Fields("YbYsje") - Rec_VouchSub.Fields("YbYsje")                 '本期应收/应付原币金额
  1172.                    .Fields("YbQmye") = .Fields("YbQcye") + .Fields("YbYsje") - .Fields("YbSsje")         '本期期末原币余额
  1173.                    .Fields("BbYsje") = .Fields("BbYsje") - Rec_VouchSub.Fields("BbYsje")                 '本期应收/应付本币金额
  1174.                    .Fields("BbQmye") = .Fields("BbQcye") + .Fields("BbYsje") - .Fields("BbSsje")         '本期期末本币余额
  1175.                    .Update
  1176.                 Else
  1177.                    .AddNew
  1178.                    .Fields("RPFlag") = "Ar"                                                              '应收应付标识
  1179.                    .Fields("PSCode") = Str_PSCode                                                        '往来单位编码
  1180.                    .Fields("DeptCode") = Str_DeptCode                                                    '部门编码
  1181.                    .Fields("PersonCode") = Str_PersonCode                                                '个人编码
  1182.                    .Fields("ForeignCurrCode") = Str_ForeignCurrCode                                      '原币编码
  1183.                    .Fields("KJYear") = Int_Kjyear                                                        '会计年度
  1184.                    .Fields("Period") = Int_Period                                                        '会计期间
  1185.                    .Fields("YbYsje") = -Rec_VouchSub.Fields("YbYsje")                                    '本期应收/应付原币金额
  1186.                    .Fields("YbQmye") = -Rec_VouchSub.Fields("YbYsje")                                    '本期期末原币余额
  1187.                    .Fields("BbYsje") = -Rec_VouchSub.Fields("BbYsje")                                    '本期应收/应付本币金额
  1188.                    .Fields("BbQmye") = -Rec_VouchSub.Fields("BbYsje")                                    '本期期末本币余额
  1189.                    .Update
  1190.             
  1191.                  End If
  1192.             End With
  1193.         
  1194.         End If
  1195.     Next Rowjsq
  1196.     End If
  1197.     Cw_DataEnvi.DataConnect.CommitTrans
  1198.     
  1199.     Call Sub_Query(0)
  1200.     
  1201.     Sub_SaveBill = True
  1202.     Tsxx = "数据存盘完毕!"
  1203.     Call Xtxxts(Tsxx, 0, 4)
  1204.     
  1205.     '设置单据改变后的状态
  1206.     Lab_OperStatus = "2"
  1207.     
  1208.     
  1209.     Exit Function
  1210.     
  1211. Swcwcl:       '数据存盘时出现错误
  1212.     Cw_DataEnvi.DataConnect.RollbackTrans
  1213.     With WglrGrid
  1214.         If Err.Number = -2147217887 Then
  1215.             Tsxx = "单据中第  " & Trim(Str(Rowjsq - .FixedRows + 1)) & " 条分录录入数据超出允许范围!"
  1216.             Call Xtxxts(Tsxx, 0, 1)
  1217.             changelock = True
  1218.             .Select Rowjsq, Qslz
  1219.             WglrGrid.SetFocus
  1220.             changelock = False
  1221.             Exit Function
  1222.         Else
  1223.             Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
  1224.             Call Xtxxts(Tsxx, 0, 1)
  1225.             Exit Function
  1226.         End If
  1227.     End With
  1228.     
  1229. Lrcwcl:        '录入错误处理(存盘前逐行有效性判断)
  1230.     With WglrGrid
  1231.         Call Xtxxts("(第 " & Trim(Str(Rowjsq - .FixedRows + 1)) & " 条单据分录)-" & Tsxx, 0, 1)
  1232.         changelock = True
  1233.         .Select Rowjsq, Lrywlz
  1234.         WglrGrid.SetFocus
  1235.         changelock = False
  1236.         Exit Function
  1237.     End With
  1238.     
  1239. End Function
  1240. '===================以 下 程 序 为 通 用 部 分 ,一 般 不 需 更 改(程序动作部分)======================='
  1241. Private Sub Lrzdbz()                                                      '录入字段帮助
  1242.   
  1243.     If Not Ydcommand.Visible Then
  1244.         Exit Sub
  1245.     End If
  1246.    
  1247.     With WglrGrid
  1248.      
  1249.         Valilock = True
  1250.     
  1251.         '处理通用部分
  1252.         changelock = True        '调入另外窗体必须加锁
  1253.         Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(Ydtext.Text))
  1254.         changelock = False
  1255.         
  1256.         If Len(Xtfhcs) <> 0 Then
  1257.             If GridInt(.Col, 7) = 0 Then
  1258.                 Ydtext.Text = Xtfhcs
  1259.             Else
  1260.                 Ydtext.Text = Xtfhcsfz
  1261.             End If
  1262.         End If
  1263.         
  1264.         Valilock = False
  1265.   
  1266.         If Ydtext.Visible Then
  1267.             Ydtext.SetFocus
  1268.         End If
  1269.     End With
  1270.     
  1271. End Sub
  1272. Private Sub Form_Resize()                                                '窗体大小发生变化时,重新显示文本框
  1273.    
  1274.     Call Cxxswbk
  1275.    
  1276. End Sub
  1277. Private Function Fun_Drfrmyxxpd() As Boolean                             '调入其它窗体或功能产生的有效性判断(包括数据回写)
  1278.   
  1279.     Fun_Drfrmyxxpd = True
  1280.     
  1281.     With WglrGrid
  1282.    
  1283.         '如果当前网格处于编辑状态,则先进行数据回写再进行有效性判断
  1284.   
  1285.         If Ydtext.Visible Or YdCombo.Visible Then
  1286.             Call Lrsjhx
  1287.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1288.                 Fun_Drfrmyxxpd = False
  1289.                 Exit Function
  1290.             End If
  1291.         End If
  1292.    
  1293.         '进行行有效性判断
  1294.         If Not Sjhzyxxpd(.Row) Then
  1295.             Fun_Drfrmyxxpd = False
  1296.             Exit Function
  1297.         End If
  1298.     End With
  1299.   
  1300. End Function
  1301. Private Sub WglrGrid_EnterCell()                                          '显示当前数据行相关信息
  1302.     With WglrGrid
  1303.         If .Row >= .FixedRows Then
  1304.             '[>>
  1305.                 '此处可以填写显示与此网格行相关信息
  1306.             '<<]
  1307.         End If
  1308.     End With
  1309.    
  1310. End Sub
  1311. Private Sub WglrGrid_GotFocus()                                           '网格得到焦点
  1312.     '网格得到焦点,如果当前选择行为非数据行
  1313.     '则调整当前焦点至有效数据行
  1314.     With WglrGrid
  1315.         If .Row < .FixedRows And .Rows > .FixedRows Then
  1316.             changelock = True
  1317.             .Select .FixedRows, .Col
  1318.             changelock = False
  1319.         End If
  1320.         If .Col < Qslz Then
  1321.             changelock = True
  1322.             .Select .Row, Qslz
  1323.             changelock = False
  1324.         End If
  1325.     End With
  1326. End Sub
  1327. Private Sub WglrGrid_LostFocus()                                          '录入网格失去焦点
  1328.     '用以屏蔽调用其它窗体时发生网格失去焦点事件
  1329.     If changelock Then
  1330.         Exit Sub
  1331.     End If
  1332.     '引发网格RowcolChange事件
  1333.     With WglrGrid
  1334.         If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1335.             .Select 0, 0
  1336.         End If
  1337.     End With
  1338. End Sub
  1339. Private Sub WglrGrid_AfterScroll(ByVal OldTopRow As Long, ByVal OldLeftCol As Long, ByVal NewTopRow As Long, ByVal NewLeftCol As Long)                                             '限制用户在录入过程中滚动鼠标
  1340.     If Gdtlock Then
  1341.         Exit Sub
  1342.     End If
  1343.  
  1344.     With WglrGrid
  1345.         If Ydtext.Visible Or YdCombo.Visible Then
  1346.             Gdtlock = True
  1347.             .TopRow = Dqtoprow
  1348.             .LeftCol = Dqleftcol
  1349.             Gdtlock = False
  1350.             Exit Sub
  1351.         End If
  1352.     End With
  1353.     
  1354. End Sub
  1355. Private Sub WglrGrid_LeaveCell()                                    '离开单元格
  1356.     If changelock Then
  1357.         Exit Sub
  1358.     End If
  1359.     '记录刚刚离开网格单元的行列值
  1360.     Dqlkwgh = WglrGrid.Row
  1361.     Dqlkwgl = WglrGrid.Col
  1362.     '判断是否需要录入数据回写
  1363.     If Not (Ydtext.Visible Or YdCombo.Visible) Then
  1364.         Exit Sub
  1365.     End If
  1366.     
  1367.     Call Lrsjhx
  1368.     
  1369. End Sub
  1370. Private Sub WglrGrid_RowColChange()                                '网格录入行列发生变化时,进行有效性判断
  1371.    
  1372.     Valilock = True       '屏蔽文本框失去焦点进行有效性判断
  1373.     
  1374.     With WglrGrid
  1375.         If changelock Then
  1376.             Exit Sub
  1377.         End If
  1378.         If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1379.             Exit Sub
  1380.         End If
  1381.         If .Row <> Dqlkwgh Then
  1382.             If Not Sjhzyxxpd(Dqlkwgh) Then
  1383.                 Exit Sub
  1384.             End If
  1385.         End If
  1386.    End With
  1387.    
  1388.    Call fhyxh
  1389.    Call Xldql
  1390.    
  1391. End Sub
  1392. Private Sub WglrGrid_DblClick()                                    '鼠标双击网格显示文本框
  1393.     
  1394.     If WglrGrid.Row < WglrGrid.FixedRows Then
  1395.         Exit Sub
  1396.     Else
  1397.         If WglrGrid.Col <> Sydz("001", GridStr(), Szzls) And WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = False Then Exit Sub
  1398.     End If
  1399.     
  1400.     With WglrGrid
  1401.         Call xswbk
  1402.     End With
  1403.     
  1404.     If Trim(WglrGrid.TextMatrix(WglrGrid.Row, 0)) = "*" Then
  1405.         If WglrGrid.Col = Sydz("001", GridStr(), Szzls) Then
  1406.             If WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) Then
  1407.                 WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = False
  1408.             Else
  1409.                 WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = True
  1410.             End If
  1411.         End If
  1412.     Else
  1413.         WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = True
  1414.     End If
  1415.     
  1416. End Sub
  1417. Private Sub Ycwbk()                                                '隐藏文本框,帮助按钮,列表组合框
  1418.     
  1419.     Valilock = True
  1420.     Ydtext.Visible = False
  1421.     YdCombo.Visible = False
  1422.     Ydcommand.Visible = False
  1423.     
  1424. End Sub
  1425. Private Sub YdCombo_KeyDown(KeyCode As Integer, Shift As Integer)        '列表框移动
  1426.     
  1427.     With WglrGrid
  1428.         Select Case KeyCode
  1429.             Case vbKeyEscape                'ESC 键放弃录入
  1430.                 Valilock = True
  1431.                 .SetFocus
  1432.                 Call Ycwbk
  1433.                 Valilock = False
  1434.                 
  1435.             Case vbKeyReturn                '回 车 键 =13
  1436.                 KeyCode = 0
  1437.                 .SetFocus
  1438.                 Call Lrsjhx
  1439.                 Rowjsq = .Row
  1440.                 Coljsq = .Col + 1
  1441.                 If Coljsq > .Cols - 1 Then
  1442.                     If Rowjsq < .Rows - 1 Then
  1443.                         Rowjsq = Rowjsq + 1
  1444.                     End If
  1445.                     Coljsq = Qslz
  1446.                 End If
  1447.                 Do While Rowjsq <= .Rows - 1
  1448.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1449.                         Coljsq = Coljsq + 1
  1450.                         If Coljsq > .Cols - 1 Then
  1451.                             Rowjsq = Rowjsq + 1
  1452.                             Coljsq = Qslz
  1453.                         End If
  1454.                     Else
  1455.                         Exit Do
  1456.                     End If
  1457.                 Loop
  1458.                 .Select Rowjsq, Coljsq
  1459.                 
  1460.             Case vbKeyLeft                  '左 箭 头 =37
  1461.                 If .Col - 1 = Qslz Then
  1462.                     If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1463.                         GoTo jzzx
  1464.                     End If
  1465.                 End If
  1466.                 If .Col > Qslz Then
  1467.                     KeyCode = 0
  1468.                     .SetFocus
  1469.                     Call Lrsjhx
  1470.                     Coljsq = .Col - 1
  1471.                     Do While Coljsq > Qslz
  1472.                         If Coljsq - 1 = Qslz Then
  1473.                             If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1474.                                 GoTo jzzx
  1475.                             End If
  1476.                         End If
  1477.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1478.                             Coljsq = Coljsq - 1
  1479.                         Else
  1480.                             Exit Do
  1481.                         End If
  1482.                     Loop
  1483.                     .Select .Row, Coljsq
  1484.                 End If
  1485.             Case vbKeyRight                 '右 箭 头 =39
  1486.                 KeyCode = 0
  1487.                 .SetFocus
  1488.                 Call Lrsjhx
  1489.                 Rowjsq = .Row
  1490.                 Coljsq = .Col + 1
  1491.                 If Coljsq > .Cols - 1 Then
  1492.                     If Rowjsq < .Rows - 1 Then
  1493.                         Rowjsq = Rowjsq + 1
  1494.                     End If
  1495.                     Coljsq = Qslz
  1496.                 End If
  1497.                 Do While Rowjsq <= .Rows - 1
  1498.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1499.                         Coljsq = Coljsq + 1
  1500.                         If Coljsq > .Cols - 1 Then
  1501.                             Rowjsq = Rowjsq + 1
  1502.                             Coljsq = Qslz
  1503.                         End If
  1504.                     Else
  1505.                         Exit Do
  1506.                     End If
  1507.                 Loop
  1508.                 .Select Rowjsq, Coljsq
  1509.         Case Else
  1510.     End Select
  1511.    
  1512. jzzx:
  1513.    
  1514.     End With
  1515.     
  1516. End Sub
  1517. Private Sub YdCombo_LostFocus()                    '列表框失去焦点
  1518.     
  1519.     With WglrGrid                                    '因为选中网格会先发生Rowcolchange事件置Valiock
  1520.         If Not Valilock Then                           '为TRUE
  1521.             Call Lrsjhx
  1522.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1523.                 Exit Sub
  1524.             End If
  1525.         End If
  1526.     End With
  1527.     
  1528. End Sub
  1529. Private Sub Ydcommand_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
  1530.     
  1531.     Call Lrzdbz
  1532.     
  1533. End Sub
  1534. Private Sub ydtext_KeyDown(KeyCode As Integer, Shift As Integer)
  1535.    
  1536.     Dim Rowjsq As Long, Coljsq As Long
  1537.    
  1538.     With WglrGrid
  1539.         Select Case KeyCode
  1540.             Case vbKeyF2
  1541.                 Call Lrzdbz
  1542.             Case vbKeyEscape                'ESC 键放弃录入
  1543.                 Valilock = True
  1544.                 Call Ycwbk
  1545.                 .SetFocus
  1546.             Case vbKeyReturn                '回 车 键 =13
  1547.                 KeyCode = 0
  1548.                 .SetFocus
  1549.                 Call Lrsjhx
  1550.                 Rowjsq = .Row
  1551.                 Coljsq = .Col + 1
  1552.                 If Coljsq > .Cols - 1 Then
  1553.                     If Rowjsq < .Rows - 1 Then
  1554.                         Rowjsq = Rowjsq + 1
  1555.                     End If
  1556.                     Coljsq = Qslz
  1557.                 End If
  1558.                 Do While Rowjsq <= .Rows - 1
  1559.                     If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1560.                         Coljsq = Coljsq + 1
  1561.                         If Coljsq > .Cols - 1 Then
  1562.                             Rowjsq = Rowjsq + 1
  1563.                             Coljsq = Qslz
  1564.                         End If
  1565.                     Else
  1566.                         Exit Do
  1567.                     End If
  1568.                 Loop
  1569.                 If Rowjsq <= .Rows - 1 Then
  1570.                     .Select Rowjsq, Coljsq
  1571.                 End If
  1572.                 
  1573.             Case vbKeyUp                    '上 箭 头 =38
  1574.                 KeyCode = 0
  1575.                 .SetFocus
  1576.                 Call Lrsjhx
  1577.                 If .Row > .FixedRows Then
  1578.                     .Row = .Row - 1
  1579.                 End If
  1580.                 
  1581.             Case vbKeyDown                  '下 箭 头 =40
  1582.                 KeyCode = 0
  1583.                 .SetFocus
  1584.                 Call Lrsjhx
  1585.                 If .Row < .Rows - 1 Then
  1586.                     .Row = .Row + 1
  1587.                 End If
  1588.             Case vbKeyLeft                  '左 箭 头 =37
  1589.                 If .Col - 1 = Qslz Then
  1590.                     If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1591.                         GoTo jzzx
  1592.                     End If
  1593.                 End If
  1594.                 If Ydtext.SelStart = 0 And .Col > Qslz Then
  1595.                     KeyCode = 0
  1596.                     .SetFocus
  1597.                     Call Lrsjhx
  1598.                     Coljsq = .Col - 1
  1599.                     Do While Coljsq > Qslz
  1600.                         If Coljsq - 1 = Qslz Then
  1601.                             If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
  1602.                                 GoTo jzzx
  1603.                             End If
  1604.                         End If
  1605.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1606.                             Coljsq = Coljsq - 1
  1607.                         Else
  1608.                             Exit Do
  1609.                         End If
  1610.                     Loop
  1611.                     .Select .Row, Coljsq
  1612.                 End If
  1613. jzzx:
  1614.            
  1615.            
  1616.             Case vbKeyRight                 '右 箭 头 =39
  1617.                 wblong = Len(Ydtext.Text)
  1618.                 If (Ydtext.SelStart = wblong Or Ydtext.SelLength = wblong) Then
  1619.                     KeyCode = 0
  1620.                     .SetFocus
  1621.                     Call Lrsjhx
  1622.                     Rowjsq = .Row
  1623.                     Coljsq = .Col + 1
  1624.                     If Coljsq > .Cols - 1 Then
  1625.                         If Rowjsq < .Rows - 1 Then
  1626.                             Rowjsq = Rowjsq + 1
  1627.                         End If
  1628.                         Coljsq = Qslz
  1629.                     End If
  1630.                     Do While Rowjsq <= .Rows - 1
  1631.                         If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1632.                             Coljsq = Coljsq + 1
  1633.                             If Coljsq > .Cols - 1 Then
  1634.                                 Rowjsq = Rowjsq + 1
  1635.                                 Coljsq = Qslz
  1636.                             End If
  1637.                         Else
  1638.                             Exit Do
  1639.                         End If
  1640.                     Loop
  1641.                     .Select Rowjsq, Coljsq
  1642.                 End If
  1643.             Case Else
  1644.         End Select
  1645.     End With
  1646.     
  1647. End Sub
  1648. Private Sub ydtext_KeyPress(KeyAscii As Integer)         '录入字符事中控制
  1649.   
  1650.     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  1651. End Sub
  1652. Private Sub ydtext_Change()                              '录入事中变化处理
  1653.     '防止程序改变但不进行处理
  1654.     If Wbkbhlock Then
  1655.          Exit Sub
  1656.     End If
  1657.     With WglrGrid
  1658.         '限制字段录入长度
  1659.         Wbkbhlock = True
  1660.         
  1661.         Select Case GridInt(.Col, 1)
  1662.             Case 8, 11   '金额型
  1663.                 Call Sjgskz(Ydtext, Xtjezws - Xtjexsws - 1, Xtjexsws)
  1664.             Case 9, 12   '数量型
  1665.                 Call Sjgskz(Ydtext, Xtslzws - Xtslxsws - 1, Xtslxsws)
  1666.             Case 10      '单价型
  1667.                 Call Sjgskz(Ydtext, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  1668.             Case Else    '其他类型
  1669.                 If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
  1670.                     Call Sjgskz(Ydtext, GridInt(.Col, 3), GridInt(.Col, 4))
  1671.                 End If
  1672.         End Select
  1673.         
  1674.         Wbkbhlock = False
  1675.     End With
  1676.     
  1677. End Sub
  1678. Private Sub ydtext_LostFocus()            '如果由于选中网格之外的控件而发生有效性判断(选中网格会先发生Rowcolchange事件置Valiock为TRUE)
  1679.   
  1680.     With WglrGrid
  1681.         If Not Valilock Then
  1682.             Call Lrsjhx
  1683.             If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
  1684.                 Exit Sub
  1685.             End If
  1686.             If Not Sjhzyxxpd(Dqlrwgh) Then
  1687.                 Exit Sub
  1688.             End If
  1689.         End If
  1690.     End With
  1691.   
  1692. End Sub
  1693. Private Sub xswbk()                       '在当前选中单元显示文本框,列表框,帮助按钮(通用)
  1694.   
  1695.     Dim Wbkpy As Integer, Wbkpy1 As Integer '文本框偏移量
  1696.   
  1697.     '当某种条件成立时禁止文本框激活使单据处于录入状态
  1698.     If Not Fun_AllowInput Then
  1699.         Exit Sub
  1700.     End If
  1701.   
  1702.     '显示文本框前返回有效行列(解决滚动条问题)
  1703.     Call Xldqh
  1704.     Call Xldql
  1705.   
  1706.     '隐藏文本框,帮助按钮,列表组合框
  1707.     Call Ycwbk
  1708.   
  1709.     With WglrGrid
  1710.         Dqlrwgh = .Row
  1711.         Dqlrwgl = .Col
  1712.         If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  1713.             Exit Sub
  1714.         End If
  1715.      
  1716.         Wbkpy = 30
  1717.         Wbkpy1 = 15
  1718.     
  1719.         On Error Resume Next
  1720.         
  1721.         If GridBoolean(.Col, 3) Then
  1722.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  1723.             YdCombo.Top = .CellTop + .Top + Wbkpy
  1724.             YdCombo.Width = .CellWidth - Wbkpy1
  1725.             Call Wbkcl
  1726.             YdCombo.Visible = True
  1727.             YdCombo.SetFocus
  1728.             Ydcommand.Visible = False
  1729.             Ydtext.Visible = False
  1730.         Else
  1731.             If GridBoolean(.Col, 2) Then
  1732.                 Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  1733.                 Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  1734.                 Ydcommand.Visible = True
  1735.             Else
  1736.                 Ydcommand.Visible = False
  1737.             End If
  1738.      
  1739.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  1740.             Ydtext.Top = .CellTop + .Top + Wbkpy
  1741.             
  1742.             If Ydcommand.Visible Then
  1743.                 If Sfblbzkd Then
  1744.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  1745.                 Else
  1746.                     Ydtext.Width = .CellWidth - Wbkpy1
  1747.                 End If
  1748.             Else
  1749.                 Ydtext.Width = .CellWidth - Wbkpy1
  1750.             End If
  1751.             
  1752.             Ydtext.Height = .CellHeight - Wbkpy1
  1753.       
  1754.             If GridInt(.Col, 2) <> 0 Then
  1755.                 Ydtext.MaxLength = GridInt(.Col, 2)
  1756.             Else
  1757.                 Ydtext.MaxLength = 3000
  1758.             End If
  1759.       
  1760.             Call Wbkcl
  1761.       
  1762.             Ydtext.Visible = True
  1763.             Ydtext.SetFocus
  1764.         End If
  1765.     
  1766.         Dqtoprow = .TopRow
  1767.         Dqleftcol = .LeftCol
  1768.     
  1769.         '重置锁值
  1770.         Valilock = False
  1771.         Wbkbhlock = False
  1772.     End With
  1773.  
  1774. End Sub
  1775. Private Function Fun_AllowInput() As Boolean                           '当某种条件成立时禁止文本框激活使单据处于录入状态
  1776.    
  1777.     '如果单据操作状态为浏览状态则不能显示录入载体(通用)
  1778.     If Trim(Lab_OperStatus.Caption) = "1" Then
  1779.         Exit Function
  1780.     End If
  1781.    
  1782.     '[>>
  1783.     
  1784.      '此处可以填写禁止文本框激活使单据处于录入状态的理由
  1785.     
  1786.     If WglrGrid.Row > WglrGrid.FixedRows Then
  1787.         If WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = False Then
  1788.             Exit Function
  1789.         End If
  1790.     End If
  1791.    
  1792.     '<<]
  1793.    
  1794.     Fun_AllowInput = True
  1795.     
  1796. End Function
  1797. Private Sub Cxxswbk()                                                  'Formresize中重新显示文本框,列表框,帮助按钮(通用)
  1798.                    
  1799.     Dim Wbkpy As Integer, Wbkpy1 As Integer
  1800.     
  1801.     Wbkpy = 30
  1802.     Wbkpy1 = 15
  1803.     
  1804.     With WglrGrid
  1805.         If YdCombo.Visible Then
  1806.             YdCombo.Left = .CellLeft + .Left + Wbkpy
  1807.             YdCombo.Top = .CellTop + .Top + Wbkpy
  1808.             YdCombo.Width = .CellWidth - Wbkpy1
  1809.         End If
  1810.         If Ydcommand.Visible Then
  1811.             Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
  1812.             Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
  1813.         End If
  1814.         If Ydtext.Visible Then
  1815.             If Ydcommand.Visible Then
  1816.                 If Sfblbzkd Then
  1817.                     Ydtext.Width = .CellWidth - Ydcommand.Width
  1818.                 Else
  1819.                     Ydtext.Width = .CellWidth - Wbkpy1
  1820.                 End If
  1821.             Else
  1822.                 Ydtext.Width = .CellWidth - Wbkpy1
  1823.             End If
  1824.       
  1825.             Ydtext.Left = .CellLeft + .Left + Wbkpy
  1826.             Ydtext.Top = .CellTop + .Top + Wbkpy
  1827.             Ydtext.Height = .CellHeight - Wbkpy1
  1828.         End If
  1829.     End With
  1830. End Sub
  1831. Private Sub Lrsjhx()                                                             '文本框录入数据回写
  1832.   
  1833.     With WglrGrid
  1834.         If YdCombo.Visible Then
  1835.             .Text = Trim(YdCombo.Text)
  1836.         End If
  1837.         If Ydtext.Visible Then
  1838.             .Text = Trim(Ydtext.Text)
  1839.         End If
  1840.    
  1841.         '(如果字段录入内容发生变化,则打开有效性判断锁)
  1842.         If Zdlrqnr <> Trim(.Text) Then
  1843.             Yxxpdlock = False
  1844.             Hyxxpdlock = False
  1845.         End If
  1846.    
  1847.         '隐藏文本框,帮助按钮,列表组合框
  1848.         Call Ycwbk
  1849.    
  1850.     End With
  1851.     
  1852. End Sub
  1853. Private Sub WglrGrid_KeyDown(KeyCode As Integer, Shift As Integer)              '网格快捷键
  1854.   
  1855.     '如果单据操作状态为浏览状态则不能显示录入载体
  1856.     If Trim(Lab_OperStatus.Caption) = "1" Then
  1857.         Exit Sub
  1858.     End If
  1859.     Select Case KeyCode
  1860.         Case vbKeyF2                   '按F2键参照
  1861.             Call xswbk
  1862.             Call Lrzdbz
  1863.     End Select
  1864. End Sub
  1865. Private Sub WglrGrid_KeyPress(KeyAscii As Integer)                              '网格接受键盘录入
  1866.     '当某种条件成立时禁止文本框激活使单据处于录入状态
  1867.     If Not Fun_AllowInput Then
  1868.         Exit Sub
  1869.     End If
  1870.   
  1871.     With WglrGrid
  1872.   
  1873.         '屏 蔽 回 车 键
  1874.         If KeyAscii = vbKeyReturn Then
  1875.             KeyAscii = 0
  1876.             Rowjsq = .Row
  1877.             Coljsq = .Col + 1
  1878.             If Coljsq > .Cols - 1 Then
  1879.                 If Rowjsq < .Rows - 1 Then
  1880.                     Rowjsq = Rowjsq + 1
  1881.                 End If
  1882.                 Coljsq = Qslz
  1883.             End If
  1884.             Do While Rowjsq <= .Rows - 1
  1885.                 If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
  1886.                     Coljsq = Coljsq + 1
  1887.                     If Coljsq > .Cols - 1 Then
  1888.                         Rowjsq = Rowjsq + 1
  1889.                         Coljsq = Qslz
  1890.                     End If
  1891.                 Else
  1892.                     Exit Do
  1893.                 End If
  1894.             Loop
  1895.           
  1896.             If Rowjsq <= .Rows - 1 Then
  1897.                 .Select Rowjsq, Coljsq
  1898.             End If
  1899.        
  1900.             Exit Sub
  1901.        
  1902.         End If
  1903.         
  1904.         '如果当前行小于固定行则退出
  1905.         If WglrGrid.Row < WglrGrid.FixedRows Then
  1906.             Exit Sub
  1907.         Else
  1908.             If WglrGrid.Col <> Sydz("001", GridStr(), Szzls) And WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = False Then Exit Sub
  1909.         End If
  1910.         '接受用户录入
  1911.         Select Case KeyAscii
  1912.             Case 0 To 32             '用户输入KeyAscii为0-32的键 如空格
  1913.                 '显示录入载体
  1914.                 Call xswbk
  1915.             Case Else
  1916.                 
  1917.                 '防止非编辑字段SendKeys()出现死循环
  1918.                 If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  1919.                     Exit Sub
  1920.                 End If
  1921.                 
  1922.                 '如果此字段为列表框录入则调入相应列表框
  1923.                 If GridBoolean(.Col, 3) Then
  1924.                    '列表框录入
  1925.                     Call xswbk
  1926.                 Else
  1927.                     Ydtext.Text = ""
  1928.             
  1929.                     '录入限制
  1930.                     Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
  1931.                     If KeyAscii = 0 Then
  1932.                         Exit Sub
  1933.                     End If
  1934.                     Call xswbk
  1935.                     Ydtext.Text = ""
  1936.                     Valilock = True
  1937.                     SendKeys Chr(KeyAscii), True
  1938.                     DoEvents
  1939.                     Valilock = False
  1940.                 End If
  1941.         End Select
  1942.     End With
  1943. End Sub
  1944. Private Sub Qkwlzd(sjh As Long, Sjl As Long)                            '清空为零字段
  1945.     
  1946.     If Not GridBoolean(Sjl, 5) Then
  1947.         Exit Sub
  1948.     End If
  1949.     
  1950.     With WglrGrid
  1951.         If Val(Trim(.TextMatrix(sjh, Sjl))) = 0 Then
  1952.             .TextMatrix(sjh, Sjl) = ""
  1953.         End If
  1954.     End With
  1955. End Sub
  1956. Private Sub fhyxh()                                                     '返回录入数据有效行,同时让得到焦点网格可见
  1957.     
  1958.     With WglrGrid
  1959.         If .Row >= .FixedRows Then
  1960.             Call Xldqh
  1961.         End If
  1962.     End With
  1963. End Sub
  1964. Private Sub Xldqh()                                                      '显露当前行
  1965.     
  1966.     Dim Toprowte As Long
  1967.     With WglrGrid
  1968.         Toprowte = 0
  1969.         Do While .CellTop + .RowHeight(.Row) + Fzxwghs * Sjhgd > .Height And .TopRow <> Toprowte
  1970.             Toprowte = .TopRow
  1971.             .TopRow = .TopRow + 1
  1972.         Loop
  1973.         Toprowte = 0
  1974.         Do While .CellTop < .FixedRows * .RowHeight(0) And .TopRow <> Toprowte
  1975.             Toprowte = .TopRow
  1976.             If .TopRow > 1 Then
  1977.                 .TopRow = .TopRow - 1
  1978.             End If
  1979.         Loop
  1980.     End With
  1981. End Sub
  1982. Private Sub Xldql()                                                                  '显露当前列
  1983.     
  1984.     Dim Leftcolte As Long
  1985.     With WglrGrid
  1986.         If .Col >= Qslz And .Col >= .FixedCols Then
  1987.             If .LeftCol > .Col Then
  1988.                 .LeftCol = .Col
  1989.             End If
  1990.             Leftcolte = 0
  1991.             Do While .CellLeft + .CellWidth > .Width And .LeftCol <> Leftcolte
  1992.                 Leftcolte = .LeftCol
  1993.                 .LeftCol = .LeftCol + 1
  1994.             Loop
  1995.         End If
  1996.     End With
  1997. End Sub
  1998. Private Sub WglrGrid_BeforeMoveColumn(ByVal Col As Long, Position As Long)           '网格列发生移动时自动交换网格索引信息
  1999.     Call FnBln_RefreshArray(Col, Position, GridStr(), GridInf())
  2000. End Sub
  2001. Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)   '表格格式设置(通用)
  2002.     
  2003.     Select Case Button.Key
  2004.         Case "bcgs"                                       '保存表格格式
  2005.             Call Bcwggs(WglrGrid, GridCode, GridStr())
  2006.         Case "hfmrgs"                                     '恢复默认格式
  2007.             Call Hfmrgs(WglrGrid, GridCode, GridStr())
  2008.     End Select
  2009. End Sub
  2010. Private Sub bbyl(bbylte As Boolean)                    '报表打印预览
  2011.     
  2012.     Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
  2013.     Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
  2014.     Bbxbtgs = 1                                          '报 表 小 标 题 行 数
  2015.     Bbbwhgs = 0                                          '报 表 表 尾 行 数
  2016.     ReDim Bbxbt(1 To Bbxbtgs)
  2017.     ReDim bbxbtzzxs(1 To Bbxbtgs)
  2018.     If Bbbwhgs <> 0 Then
  2019.         ReDim Bbbwh(1 To Bbbwhgs)
  2020.         ReDim Bbbwhzzxs(1 To Bbbwhgs)
  2021.     End If
  2022.     Bbzbt = ReportTitle
  2023.     Bbxbt(1) = Space(2) + Fun_FormatOutPut(Lab_Cust, 40)
  2024.     Call Scyxsjb(WglrGrid)                               '生成报表数据
  2025.     Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
  2026.     If Not bbylte Then
  2027.         Unload DY_Tybbyldy
  2028.     End If
  2029. End Sub
  2030. Private Function Sub_Run() As Boolean       '生成凭证
  2031.     Dim jsq As Integer                      '临时计数器
  2032.     Dim lng_OperationNum As Long            '临时凭证ID
  2033.     Dim TranVouchClassCode As String        '转帐凭证类别
  2034.     Dim Str_VouchModel As String            '转帐凭证模式
  2035.     
  2036.     Dim RecTemp As New ADODB.Recordset
  2037.     
  2038.     
  2039.     
  2040.    '【写临时凭证
  2041.    Sub_Run = False
  2042.     On Error GoTo ERR1
  2043.     Cw_DataEnvi.DataConnect.BeginTrans
  2044.     
  2045.     '取转帐凭证类型
  2046.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute("Select * from RP_TranVouch where BillItemCode='60'")
  2047.     If RecTemp.EOF = False Then
  2048.         TranVouchClassCode = RecTemp.Fields("VouchClassCode")
  2049.         Str_VouchModel = Trim(RecTemp.Fields("VouchModel"))
  2050.     Else
  2051.         TranVouchClassCode = ""
  2052.         Str_VouchModel = ""
  2053.     End If
  2054.     
  2055.     '将转帐过程的凭证类别放到数组TranVouchClass中
  2056.     OperationNum = CreatBillID("0102")                     '本次制作凭证的操作批号
  2057.     lng_OperationNum = CreatBillID("0102")                 '临时凭证ID号
  2058.              
  2059.     
  2060.     '写临时凭证主表
  2061.     VouchRow = 0
  2062.     Call Save_TempPz_Main(TranVouchClassCode, OperationNum, lng_OperationNum)  '参数是凭证类别,批号,凭证ID
  2063.              
  2064.     '根据应收明细帐记录,写临时凭证子表
  2065.     Call Save_TempPz_Ass_Pre(lng_OperationNum, Str_VouchModel)
  2066.     
  2067.     Cw_DataEnvi.DataConnect.CommitTrans
  2068.     '记录此次转帐的批号,做为凭证窗体调用的参数
  2069.     
  2070.     '】以上是写临时凭证记录
  2071.     
  2072.     
  2073.     AutoTran_PzFrm.OperationNumPz = OperationNum       '传递此次转帐批号
  2074.     
  2075.     AutoTran_PzFrm.Show 1  '临时转帐凭证窗体
  2076.     
  2077.     If CheckVouch = True Then   '检查是否生成了正式凭证
  2078.         Sub_Run = True
  2079.     End If
  2080.     
  2081.     Call Clean              '清理临时凭证表
  2082.     Exit Function
  2083. ERR1:
  2084.     Cw_DataEnvi.DataConnect.RollbackTrans
  2085.     Tsxx = Err.Description
  2086.     Tsxx = "转帐过程中出现未知错误,程序自动恢复保存前状态!"
  2087.     Call Xtxxts(Tsxx, 0, 1)
  2088.     Exit Function
  2089. End Function
  2090. Private Sub Save_TempPz_Ass_Pre(VouchTemp_Id As Long, VouchModel As String)
  2091.     'VouchTemp_Id 表示临时凭证的ID号,VouchModel 表示凭证的模板
  2092.     Dim RecTemp As New ADODB.Recordset      '临时记录集
  2093.     Dim RecInvoice As New ADODB.Recordset   '发票记录集
  2094.     Dim RecAccList As New ADODB.Recordset   '应收款明细帐
  2095.     
  2096.     Dim Digest As String                    '摘要
  2097.     Dim AccCode As String                   '单据科目编码
  2098.     Dim AccCodeArAp As String               '应收科目编码
  2099.     Dim DeptCode As String                  '部门编码
  2100.     Dim PersonCode As String                '经办人编码
  2101.     Dim CusCode As String                   '客户编码
  2102.     Dim SupplierCode As String              '供应商编码
  2103.     Dim ItemCode As String                  '项目编码
  2104.     
  2105.     Dim ParaXt As String                    '临时参数变量
  2106.     Dim YbYsje As Double                    '原币应收
  2107.     Dim BbYsje As Double                    '本币应收
  2108.     Dim BadDebtType As String               '坏帐类型
  2109.     
  2110.     CusCode = Trim(Me.Lab_Cust.Tag)         '客户编码
  2111.     SupplierCode = ""                       '供应商
  2112.     ItemCode = ""                           '项目
  2113.     SsCode = ""                             '结算方式
  2114.     BankBillNo = ""                         '票号
  2115.     CustName = ""
  2116.     SupplierName = ""                       '供应商
  2117.     
  2118.     '取坏帐损失还是坏帐准备科目
  2119.     ParaXt = "AR_baddebtsMothed"
  2120.     Sqlstr = "Select ItemValue from Gy_AccInformation Where ItemCode='" & ParaXt & "'"
  2121.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  2122.     If RecTemp.EOF = False Then
  2123.         If Trim(RecTemp.Fields("itemvalue")) = "1" Then  '
  2124.             BadDebtType = 1                    '第1种方式,备抵法
  2125.         Else
  2126.             BadDebtType = 0                    '第2种方法,不计提坏帐准备
  2127.         End If
  2128.     End If
  2129.     If BadDebtType = 1 Then
  2130.         AccCode = Fun_GetInputCode("AR_BadDebtPrepAccCode")                        '坏帐准备科目
  2131.     Else
  2132.         AccCode = Fun_GetInputCode("AR_BadDebtAccCode")                            '坏帐损失科目(非备抵法)
  2133.     End If
  2134.     
  2135.     '其它数据,从网格中取
  2136.     Ybhj = 0
  2137.     Bbhj = 0
  2138.     With WglrGrid
  2139.         For Rowjsq = 1 To .Rows - 1
  2140.             If WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)) = True Then
  2141.                 Digest = Trim(.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls)))
  2142.                 AccCodeArAp = Trim(.TextMatrix(Rowjsq, Sydz("016", GridStr(), Szzls))) '应收科目编码
  2143.                 DeptCode = Trim(.TextMatrix(Rowjsq, Sydz("007", GridStr(), Szzls)))    '部门
  2144.                 PersonCode = Trim(.TextMatrix(Rowjsq, Sydz("009", GridStr(), Szzls)))  '经办人
  2145.                 YbYsje = Val(.TextMatrix(Rowjsq, Sydz("015", GridStr(), Szzls)))       '原币坏帐金额
  2146.                 BbYsje = Val(.TextMatrix(Rowjsq, Sydz("017", GridStr(), Szzls)))       '本币坏帐金额
  2147.                 PersonName = .TextMatrix(Rowjsq, Sydz("010", GridStr(), Szzls))        '经办人姓名
  2148.                 ForeignCurrCode = Trim(.TextMatrix(Rowjsq, Sydz("011", GridStr(), Szzls))) '外币编码
  2149.                 If YbYsje <> 0 Or YbYsje <> 0 Then
  2150.                     Select Case VouchModel
  2151.                         Case "5"     '借坏帐,贷应收
  2152.                 
  2153.                             '写借应收帐款分录
  2154.                             VouchRow = VouchRow + 1
  2155.                             YbJe = YbYsje               '每笔坏帐金额
  2156.                             BbJe = BbYsje               '每笔坏帐金额
  2157.                             Ybhj = Ybhj + YbJe
  2158.                             Bbhj = Bbhj + BbJe
  2159.                             
  2160.                             '贷应收
  2161.                             Call Save_TempPz_Ass(VouchTemp_Id, VouchRow, Digest, AccCodeArAp, DeptCode, PersonCode, CusCode, SupplierCode, ItemCode, "贷")
  2162.                          Case Else                     '另一种凭证模式
  2163.                             '写借应收帐款分录
  2164.                             VouchRow = VouchRow + 1
  2165.                             YbJe = YbYsje               '每笔坏帐金额
  2166.                             BbJe = BbYsje               '每笔坏帐金额
  2167.                             Ybhj = Ybhj + YbJe
  2168.                             Bbhj = Bbhj + BbJe
  2169.                             
  2170.                             '贷应收
  2171.                             Call Save_TempPz_Ass(VouchTemp_Id, VouchRow, Digest, AccCodeArAp, DeptCode, PersonCode, CusCode, SupplierCode, ItemCode, "贷")
  2172.                      End Select
  2173.                 End If
  2174.             End If
  2175.         Next Rowjsq
  2176.     End With
  2177.     If Ybhj <> 0 Or Bbhj <> 0 Then
  2178.         VouchRow = VouchRow + 1
  2179.         YbJe = Ybhj
  2180.         BbJe = Bbhj
  2181.         Call Save_TempPz_Ass(VouchTemp_Id, VouchRow, Digest, AccCode, DeptCode, PersonCode, CusCode, SupplierCode, ItemCode, "借")
  2182.     End If
  2183. End Sub
  2184. Private Sub Save_TempPz_Main(TranVouchClass1 As String, OperationNum1 As Long, VouchIdTemp_Id As Long)    '将有效数据写入临时凭证主表
  2185.     Dim Rec_VouchMainTemp As New ADODB.Recordset            '临时凭证主表记录集
  2186.     
  2187.     '打开临时凭证主表,存放有效凭证的凭证号等主信息
  2188.     If Rec_VouchMainTemp.State = 1 Then Rec_VouchMainTemp.Close
  2189.     Rec_VouchMainTemp.Open "select * from Cwzz_AccVouchMainTemp Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  2190.     With Rec_VouchMainTemp
  2191.         .AddNew
  2192.         .Fields("VouchSource") = "应收系统"                  '凭证来源
  2193.         .Fields("OperationNo") = OperationNum1               '存放批号
  2194.         .Fields("VouchId") = VouchIdTemp_Id                  '临时凭证ID
  2195.         .Fields("Year") = Int_Kjyear                         '取选中的年份
  2196.         .Fields("period") = Int_Period                       '取选中的会计期间
  2197.         .Fields("Ddate") = Xtrq                              '取系统日期
  2198.         .Fields("VouchClassCode") = TranVouchClass1          '单据的凭证类别
  2199.         .Fields("Doc") = 0
  2200.         .Fields("Bill") = Xtczy
  2201.         .Fields("OperationClass") = ""                       '业务类型
  2202.         .Fields("BillType") = ""
  2203.         .Fields("BillNo") = 1                               '凭证个数
  2204.         .Fields("DeleteFlag") = IIf(Bln_DeleteFlag, 1, 0)
  2205.         
  2206.         .Update
  2207.     End With
  2208. End Sub
  2209. Private Sub Save_TempPz_Ass(VouchIdTemp_Id As Long, serialnum As Long, Str_Digest As String, Str_Kmh As String, str_Dept As String, Str_Per As String, Str_Cus As String, Str_Sup As String, Str_Item As String, str_TranOri As String) '写临时凭证辅表
  2210.     'VouchIdTemp_Id临时凭证主表、辅表对应关系Id号
  2211.     Dim Rec_VouchTemp As New ADODB.Recordset            '临时凭证辅表记录集
  2212.     Dim RecTemp As New ADODB.Recordset
  2213.     
  2214.     '打开临时凭证辅表,用于存放转帐凭证内容
  2215.     Rec_VouchTemp.Open "select * from Cwzz_AccVouchsubTemp where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  2216.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute("Select * from Cwzz_AccCode where Ccode='" & Str_Kmh & "'")
  2217.     With Rec_VouchTemp
  2218.         .AddNew
  2219.         
  2220.         '[公共信息
  2221.         If str_TranOri = "贷" Then                               '
  2222.             .Fields("WbDfje") = YbJe                             '贷方金额
  2223.             .Fields("Dfje") = BbJe
  2224.         Else
  2225.             .Fields("WbJfje") = YbJe                             '借方金额
  2226.             .Fields("Jfje") = BbJe
  2227.         End If
  2228.         .Fields("Digest") = Str_Digest                           '摘要
  2229.         If RecTemp.EOF = True Then
  2230.            .Fields("Ccode") = Null
  2231.         Else
  2232.             .Fields("Ccode") = Str_Kmh                           '转帐科目号
  2233.         End If
  2234.         .Fields("VouchId") = VouchIdTemp_Id                      '与主表的对应ID
  2235.         .Fields("serialID") = serialnum                          '序号ID
  2236.         
  2237.         
  2238.         '[辅助信息
  2239.         If RecTemp.EOF = False Then
  2240.             If RecTemp.Fields("QuantityFlag") = True Then
  2241.                 If str_TranOri = "贷" Then                       '数量
  2242.                     .Fields("Jfsl") = Sl
  2243.                 Else
  2244.                     .Fields("Dfsl") = Sl
  2245.                 End If
  2246.             End If
  2247.             If RecTemp.Fields("PersonFlag") = True Then
  2248.                 .Fields("PersonCode") = Str_Per                  '个人
  2249.             End If
  2250.             If RecTemp.Fields("DeptFlag") = True Then
  2251.                 .Fields("DeptCode") = str_Dept                   '部门
  2252.             End If
  2253.             If RecTemp.Fields("CusFlag") = True Then
  2254.                 .Fields("CusCode") = Str_Cus                     '客户
  2255.             End If
  2256.             If RecTemp.Fields("SupplierFlag") = True Then
  2257.                 .Fields("Suppliercode") = Str_Sup                '供应商
  2258.             End If
  2259.         End If
  2260.         '[币别信息
  2261.         .Fields("ForeignCurrCode") = ForeignCurrCode
  2262.         .Fields("AccRate") = AccRate
  2263.         
  2264.         '[银行结算信息
  2265.         If RecTemp.EOF = False Then
  2266.             If Trim(RecTemp.Fields("Cproperty")) = "银行" Then
  2267.                 .Fields("SScode") = SsCode
  2268.                 .Fields("BillNo") = BankBillNo
  2269.                 .Fields("Digest") = Str_Digest & CustName & SuppName   '摘要
  2270.             End If
  2271.             .Fields("BillDate") = BillDate
  2272.         End If
  2273.         ']银行结算信息
  2274.         
  2275.         .Fields("TranPerson") = PersonName
  2276.         
  2277.         .Update
  2278.     End With
  2279. End Sub
  2280. Private Function CheckVouch() As Boolean        '检验凭证是否保存
  2281.     Dim Rec_VouchMain As New ADODB.Recordset    '临时主凭证记录
  2282.     CheckVouch = False
  2283.     Sqlstr = "SELECT * FROM Cwzz_AccVouchMainTemp WHERE SureVouchId>0 and OperationNo='" & OperationNum & "' order by BillNo"
  2284.     Set Rec_VouchMain = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  2285.     If Rec_VouchMain.EOF = False Then
  2286.         CheckVouch = True
  2287.         EffectVouchId = Rec_VouchMain.Fields("SureVouchId")      '已生成的正式凭证的ID
  2288.     End If
  2289. End Function
  2290. Private Sub Clean()               '删除临时数据表数据
  2291.         '删除临时凭证主从表
  2292.         Cw_DataEnvi.DataConnect.Execute "Delete From Cwzz_AccVouchSubTemp Where VouchId in (select VouchId from Cwzz_AccVouchMainTemp where OperationNo='" & OperationNum & "')"
  2293.         Cw_DataEnvi.DataConnect.Execute "Delete From Cwzz_AccVouchMainTemp Where OperationNo='" & OperationNum & "'"
  2294. End Sub