上传用户: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 HX_FrmHxgl 
  5.    BorderStyle     =   1  'Fixed Single
  6.    Caption         =   "核销管理"
  7.    ClientHeight    =   7560
  8.    ClientLeft      =   495
  9.    ClientTop       =   585
  10.    ClientWidth     =   11070
  11.    HelpContextID   =   5001
  12.    Icon            =   "核销处理_单据核销查询结果.frx":0000
  13.    KeyPreview      =   -1  'True
  14.    LinkTopic       =   "Form1"
  15.    MaxButton       =   0   'False
  16.    MinButton       =   0   'False
  17.    ScaleHeight     =   7560
  18.    ScaleWidth      =   11070
  19.    StartUpPosition =   1  '所有者中心
  20.    Begin VB.Timer Timer1 
  21.       Enabled         =   0   'False
  22.       Interval        =   1
  23.       Left            =   9960
  24.       Top             =   120
  25.    End
  26.    Begin VSFlex8Ctl.VSFlexGrid CxbbGrid 
  27.       Height          =   3405
  28.       Left            =   60
  29.       TabIndex        =   0
  30.       Top             =   600
  31.       Width           =   10965
  32.       _cx             =   5080
  33.       _cy             =   5080
  34.       Appearance      =   1
  35.       BorderStyle     =   1
  36.       Enabled         =   -1  'True
  37.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  38.          Name            =   "宋体"
  39.          Size            =   9
  40.          Charset         =   134
  41.          Weight          =   400
  42.          Underline       =   0   'False
  43.          Italic          =   0   'False
  44.          Strikethrough   =   0   'False
  45.       EndProperty
  46.       MousePointer    =   0
  47.       BackColor       =   16777215
  48.       ForeColor       =   -2147483640
  49.       BackColorFixed  =   13826538
  50.       ForeColorFixed  =   -2147483630
  51.       BackColorSel    =   -2147483635
  52.       ForeColorSel    =   -2147483634
  53.       BackColorBkg    =   -2147483636
  54.       BackColorAlternate=   16777215
  55.       GridColor       =   -2147483633
  56.       GridColorFixed  =   -2147483632
  57.       TreeColor       =   -2147483632
  58.       FloodColor      =   192
  59.       SheetBorder     =   -2147483642
  60.       FocusRect       =   1
  61.       HighLight       =   1
  62.       AllowSelection  =   -1  'True
  63.       AllowBigSelection=   -1  'True
  64.       AllowUserResizing=   0
  65.       SelectionMode   =   0
  66.       GridLines       =   1
  67.       GridLinesFixed  =   2
  68.       GridLineWidth   =   1
  69.       Rows            =   50
  70.       Cols            =   10
  71.       FixedRows       =   1
  72.       FixedCols       =   1
  73.       RowHeightMin    =   0
  74.       RowHeightMax    =   0
  75.       ColWidthMin     =   0
  76.       ColWidthMax     =   0
  77.       ExtendLastCol   =   0   'False
  78.       FormatString    =   ""
  79.       ScrollTrack     =   0   'False
  80.       ScrollBars      =   3
  81.       ScrollTips      =   0   'False
  82.       MergeCells      =   0
  83.       MergeCompare    =   0
  84.       AutoResize      =   -1  'True
  85.       AutoSizeMode    =   0
  86.       AutoSearch      =   0
  87.       AutoSearchDelay =   2
  88.       MultiTotals     =   -1  'True
  89.       SubtotalPosition=   1
  90.       OutlineBar      =   0
  91.       OutlineCol      =   0
  92.       Ellipsis        =   0
  93.       ExplorerBar     =   0
  94.       PicturesOver    =   0   'False
  95.       FillStyle       =   0
  96.       RightToLeft     =   0   'False
  97.       PictureType     =   0
  98.       TabBehavior     =   0
  99.       OwnerDraw       =   0
  100.       Editable        =   0
  101.       ShowComboButton =   1
  102.       WordWrap        =   0   'False
  103.       TextStyle       =   0
  104.       TextStyleFixed  =   0
  105.       OleDragMode     =   0
  106.       OleDropMode     =   0
  107.       DataMode        =   0
  108.       VirtualData     =   -1  'True
  109.       DataMember      =   ""
  110.       ComboSearch     =   3
  111.       AutoSizeMouse   =   -1  'True
  112.       FrozenRows      =   0
  113.       FrozenCols      =   0
  114.       AllowUserFreezing=   0
  115.       BackColorFrozen =   0
  116.       ForeColorFrozen =   0
  117.       WallPaperAlignment=   9
  118.       AccessibleName  =   ""
  119.       AccessibleDescription=   ""
  120.       AccessibleValue =   ""
  121.       AccessibleRole  =   24
  122.    End
  123.    Begin VSFlex8Ctl.VSFlexGrid CxbbGrid1 
  124.       Height          =   3405
  125.       Left            =   60
  126.       TabIndex        =   1
  127.       Top             =   4080
  128.       Width           =   10965
  129.       _cx             =   5080
  130.       _cy             =   5080
  131.       Appearance      =   1
  132.       BorderStyle     =   1
  133.       Enabled         =   -1  'True
  134.       BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851} 
  135.          Name            =   "宋体"
  136.          Size            =   9
  137.          Charset         =   134
  138.          Weight          =   400
  139.          Underline       =   0   'False
  140.          Italic          =   0   'False
  141.          Strikethrough   =   0   'False
  142.       EndProperty
  143.       MousePointer    =   0
  144.       BackColor       =   16777215
  145.       ForeColor       =   -2147483640
  146.       BackColorFixed  =   13826538
  147.       ForeColorFixed  =   -2147483630
  148.       BackColorSel    =   -2147483635
  149.       ForeColorSel    =   -2147483634
  150.       BackColorBkg    =   -2147483636
  151.       BackColorAlternate=   16777215
  152.       GridColor       =   -2147483633
  153.       GridColorFixed  =   -2147483632
  154.       TreeColor       =   -2147483632
  155.       FloodColor      =   192
  156.       SheetBorder     =   -2147483642
  157.       FocusRect       =   1
  158.       HighLight       =   1
  159.       AllowSelection  =   -1  'True
  160.       AllowBigSelection=   -1  'True
  161.       AllowUserResizing=   0
  162.       SelectionMode   =   0
  163.       GridLines       =   1
  164.       GridLinesFixed  =   2
  165.       GridLineWidth   =   1
  166.       Rows            =   50
  167.       Cols            =   10
  168.       FixedRows       =   1
  169.       FixedCols       =   1
  170.       RowHeightMin    =   0
  171.       RowHeightMax    =   0
  172.       ColWidthMin     =   0
  173.       ColWidthMax     =   0
  174.       ExtendLastCol   =   0   'False
  175.       FormatString    =   ""
  176.       ScrollTrack     =   0   'False
  177.       ScrollBars      =   3
  178.       ScrollTips      =   0   'False
  179.       MergeCells      =   0
  180.       MergeCompare    =   0
  181.       AutoResize      =   -1  'True
  182.       AutoSizeMode    =   0
  183.       AutoSearch      =   0
  184.       AutoSearchDelay =   2
  185.       MultiTotals     =   -1  'True
  186.       SubtotalPosition=   1
  187.       OutlineBar      =   0
  188.       OutlineCol      =   0
  189.       Ellipsis        =   0
  190.       ExplorerBar     =   0
  191.       PicturesOver    =   0   'False
  192.       FillStyle       =   0
  193.       RightToLeft     =   0   'False
  194.       PictureType     =   0
  195.       TabBehavior     =   0
  196.       OwnerDraw       =   0
  197.       Editable        =   0
  198.       ShowComboButton =   1
  199.       WordWrap        =   0   'False
  200.       TextStyle       =   0
  201.       TextStyleFixed  =   0
  202.       OleDragMode     =   0
  203.       OleDropMode     =   0
  204.       DataMode        =   0
  205.       VirtualData     =   -1  'True
  206.       DataMember      =   ""
  207.       ComboSearch     =   3
  208.       AutoSizeMouse   =   -1  'True
  209.       FrozenRows      =   0
  210.       FrozenCols      =   0
  211.       AllowUserFreezing=   0
  212.       BackColorFrozen =   0
  213.       ForeColorFrozen =   0
  214.       WallPaperAlignment=   9
  215.       AccessibleName  =   ""
  216.       AccessibleDescription=   ""
  217.       AccessibleValue =   ""
  218.       AccessibleRole  =   24
  219.    End
  220.    Begin MSComctlLib.Toolbar SzToolbar 
  221.       Align           =   1  'Align Top
  222.       Height          =   555
  223.       Left            =   0
  224.       TabIndex        =   2
  225.       Top             =   0
  226.       Width           =   11070
  227.       _ExtentX        =   19526
  228.       _ExtentY        =   979
  229.       ButtonWidth     =   820
  230.       ButtonHeight    =   926
  231.       AllowCustomize  =   0   'False
  232.       Appearance      =   1
  233.       Style           =   1
  234.       ImageList       =   "ImageList2"
  235.       _Version        =   393216
  236.       BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628} 
  237.          NumButtons      =   10
  238.          BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  239.             Caption         =   "全选"
  240.             Key             =   "qbxz"
  241.             ImageKey        =   "qx1"
  242.          EndProperty
  243.          BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  244.             Caption         =   "全消"
  245.             Key             =   "qbqx"
  246.             ImageKey        =   "qx"
  247.          EndProperty
  248.          BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  249.             Caption         =   "自动"
  250.             Key             =   "zd"
  251.             ImageKey        =   "zd"
  252.          EndProperty
  253.          BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  254.             Style           =   3
  255.          EndProperty
  256.          BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  257.             Caption         =   "查询"
  258.             Key             =   "cx"
  259.             ImageKey        =   "cx"
  260.          EndProperty
  261.          BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  262.             Style           =   3
  263.          EndProperty
  264.          BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  265.             Caption         =   "核销"
  266.             Key             =   "hx"
  267.             ImageKey        =   "hx"
  268.          EndProperty
  269.          BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  270.             Style           =   3
  271.          EndProperty
  272.          BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  273.             Caption         =   "帮助"
  274.             Key             =   "bz"
  275.             ImageKey        =   "bz"
  276.          EndProperty
  277.          BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628} 
  278.             Caption         =   "退出"
  279.             Key             =   "fh"
  280.             ImageKey        =   "tc"
  281.          EndProperty
  282.       EndProperty
  283.       BorderStyle     =   1
  284.       Begin MSComctlLib.ImageList ImageList2 
  285.          Left            =   9000
  286.          Top             =   0
  287.          _ExtentX        =   1005
  288.          _ExtentY        =   1005
  289.          BackColor       =   -2147483643
  290.          ImageWidth      =   16
  291.          ImageHeight     =   16
  292.          MaskColor       =   12632256
  293.          _Version        =   393216
  294.          BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628} 
  295.             NumListImages   =   46
  296.             BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  297.                Picture         =   "核销处理_单据核销查询结果.frx":1042
  298.                Key             =   "sz"
  299.             EndProperty
  300.             BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  301.                Picture         =   "核销处理_单据核销查询结果.frx":13DC
  302.                Key             =   "dy"
  303.             EndProperty
  304.             BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  305.                Picture         =   "核销处理_单据核销查询结果.frx":1776
  306.                Key             =   "yl"
  307.             EndProperty
  308.             BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  309.                Picture         =   "核销处理_单据核销查询结果.frx":1B10
  310.                Key             =   "xg"
  311.             EndProperty
  312.             BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  313.                Picture         =   "核销处理_单据核销查询结果.frx":1EAA
  314.                Key             =   "zh"
  315.             EndProperty
  316.             BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  317.                Picture         =   "核销处理_单据核销查询结果.frx":2244
  318.                Key             =   "sh"
  319.             EndProperty
  320.             BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  321.                Picture         =   "核销处理_单据核销查询结果.frx":25DE
  322.                Key             =   "bc"
  323.             EndProperty
  324.             BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  325.                Picture         =   "核销处理_单据核销查询结果.frx":2978
  326.                Key             =   "fq"
  327.             EndProperty
  328.             BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  329.                Picture         =   "核销处理_单据核销查询结果.frx":2D12
  330.                Key             =   "bz"
  331.             EndProperty
  332.             BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  333.                Picture         =   "核销处理_单据核销查询结果.frx":30AC
  334.                Key             =   "tc"
  335.             EndProperty
  336.             BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  337.                Picture         =   "核销处理_单据核销查询结果.frx":3446
  338.                Key             =   "bcgs"
  339.             EndProperty
  340.             BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  341.                Picture         =   "核销处理_单据核销查询结果.frx":37E0
  342.                Key             =   "mrlk"
  343.             EndProperty
  344.             BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  345.                Picture         =   "核销处理_单据核销查询结果.frx":3B7A
  346.                Key             =   "xsxm"
  347.             EndProperty
  348.             BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  349.                Picture         =   "核销处理_单据核销查询结果.frx":3F14
  350.                Key             =   "first"
  351.             EndProperty
  352.             BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  353.                Picture         =   "核销处理_单据核销查询结果.frx":42AE
  354.                Key             =   "prev"
  355.             EndProperty
  356.             BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  357.                Picture         =   "核销处理_单据核销查询结果.frx":4648
  358.                Key             =   "next"
  359.             EndProperty
  360.             BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  361.                Picture         =   "核销处理_单据核销查询结果.frx":49E2
  362.                Key             =   "last"
  363.             EndProperty
  364.             BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  365.                Picture         =   "核销处理_单据核销查询结果.frx":4D7C
  366.                Key             =   "xx"
  367.             EndProperty
  368.             BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  369.                Picture         =   "核销处理_单据核销查询结果.frx":5116
  370.                Key             =   "define"
  371.             EndProperty
  372.             BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  373.                Picture         =   "核销处理_单据核销查询结果.frx":54B0
  374.                Key             =   "exec"
  375.             EndProperty
  376.             BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  377.                Picture         =   "核销处理_单据核销查询结果.frx":584A
  378.                Key             =   "xz"
  379.             EndProperty
  380.             BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  381.                Picture         =   "核销处理_单据核销查询结果.frx":5BE4
  382.                Key             =   "sc"
  383.             EndProperty
  384.             BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  385.                Picture         =   "核销处理_单据核销查询结果.frx":5F7E
  386.                Key             =   "sx"
  387.             EndProperty
  388.             BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  389.                Picture         =   "核销处理_单据核销查询结果.frx":6318
  390.                Key             =   "cx"
  391.             EndProperty
  392.             BeginProperty ListImage25 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  393.                Picture         =   "核销处理_单据核销查询结果.frx":66B2
  394.                Key             =   "zd"
  395.             EndProperty
  396.             BeginProperty ListImage26 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  397.                Picture         =   "核销处理_单据核销查询结果.frx":6A4C
  398.                Key             =   "dz"
  399.             EndProperty
  400.             BeginProperty ListImage27 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  401.                Picture         =   "核销处理_单据核销查询结果.frx":6DE6
  402.                Key             =   "ph"
  403.             EndProperty
  404.             BeginProperty ListImage28 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  405.                Picture         =   "核销处理_单据核销查询结果.frx":7180
  406.                Key             =   "fz"
  407.             EndProperty
  408.             BeginProperty ListImage29 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  409.                Picture         =   "核销处理_单据核销查询结果.frx":751A
  410.                Key             =   "dw"
  411.             EndProperty
  412.             BeginProperty ListImage30 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  413.                Picture         =   "核销处理_单据核销查询结果.frx":78B4
  414.                Key             =   "hf"
  415.             EndProperty
  416.             BeginProperty ListImage31 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  417.                Picture         =   "核销处理_单据核销查询结果.frx":7C4E
  418.                Key             =   "pz"
  419.             EndProperty
  420.             BeginProperty ListImage32 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  421.                Picture         =   "核销处理_单据核销查询结果.frx":7FE8
  422.                Key             =   "check"
  423.             EndProperty
  424.             BeginProperty ListImage33 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  425.                Picture         =   "核销处理_单据核销查询结果.frx":8382
  426.                Key             =   "qs"
  427.             EndProperty
  428.             BeginProperty ListImage34 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  429.                Picture         =   "核销处理_单据核销查询结果.frx":871C
  430.                Key             =   "fullcheck"
  431.             EndProperty
  432.             BeginProperty ListImage35 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  433.                Picture         =   "核销处理_单据核销查询结果.frx":8AB6
  434.                Key             =   "qq"
  435.             EndProperty
  436.             BeginProperty ListImage36 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  437.                Picture         =   "核销处理_单据核销查询结果.frx":8E50
  438.                Key             =   "bcw"
  439.             EndProperty
  440.             BeginProperty ListImage37 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  441.                Picture         =   "核销处理_单据核销查询结果.frx":91EA
  442.                Key             =   "ye"
  443.             EndProperty
  444.             BeginProperty ListImage38 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  445.                Picture         =   "核销处理_单据核销查询结果.frx":9584
  446.                Key             =   ""
  447.             EndProperty
  448.             BeginProperty ListImage39 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  449.                Picture         =   "核销处理_单据核销查询结果.frx":991E
  450.                Key             =   "frist"
  451.             EndProperty
  452.             BeginProperty ListImage40 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  453.                Picture         =   "核销处理_单据核销查询结果.frx":9CB8
  454.                Key             =   "dj"
  455.             EndProperty
  456.             BeginProperty ListImage41 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  457.                Picture         =   "核销处理_单据核销查询结果.frx":A052
  458.                Key             =   "xj"
  459.             EndProperty
  460.             BeginProperty ListImage42 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  461.                Picture         =   "核销处理_单据核销查询结果.frx":A3EC
  462.                Key             =   "qx"
  463.             EndProperty
  464.             BeginProperty ListImage43 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  465.                Picture         =   "核销处理_单据核销查询结果.frx":A786
  466.                Key             =   "qx1"
  467.             EndProperty
  468.             BeginProperty ListImage44 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  469.                Picture         =   "核销处理_单据核销查询结果.frx":AB20
  470.                Key             =   "gz"
  471.             EndProperty
  472.             BeginProperty ListImage45 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  473.                Picture         =   "核销处理_单据核销查询结果.frx":AEBA
  474.                Key             =   "js"
  475.             EndProperty
  476.             BeginProperty ListImage46 {2C247F27-8591-11D1-B16A-00C0F0283628} 
  477.                Picture         =   "核销处理_单据核销查询结果.frx":B254
  478.                Key             =   "hx"
  479.             EndProperty
  480.          EndProperty
  481.       End
  482.    End
  483. End
  484. Attribute VB_Name = "HX_FrmHxgl"
  485. Attribute VB_GlobalNameSpace = False
  486. Attribute VB_Creatable = False
  487. Attribute VB_PredeclaredId = True
  488. Attribute VB_Exposed = False
  489. '***************************************************************************************************
  490. '*    模 块 名 称 :核销管理
  491. '*    功 能 描 述 :包括付款结算,预付款冲应付款,应付冲应收三种核销方式
  492. '*                 1.付款结算:用应付明细帐中的付款(未核销)和退款(未核销)与应付款(未核销)进行核销结算
  493. '*                 2.预付款冲应付款:用应付明细帐中的预付款(未核销)与应付款(未核销)进行核销结算
  494. '*                 3.应付冲应收:用应付明细帐中的应付款(未核销)与应收款(未核销)进行核销结算
  495. '*    程序员姓名  :张建忠
  496. '*    最后修改人  :张建忠
  497. '*    最后修改时间:2001/12/28
  498. '*    备        注:程序中所有依实际情况自定义部分均用[>>  <<]括起
  499. '***************************************************************************************************
  500. Dim ReportTitle As String                '报表主标题
  501. Dim Str_QueryCondi As String             '用户录入查询条件
  502. Dim Tsxx As String                       '系统提示信息
  503. Dim Bln_Foreign As Boolean               '按原币核销标识
  504. Dim Int_Hxlx As Integer                  '核销类型
  505. Dim Str_CusCode As String                '往来客户编码
  506. Dim Str_SupplierCode As String           '往来供应商编码
  507. '以下为固定使用变量(网格1)
  508. Dim GridCode As String                   '显示网格网格代码
  509. Dim GridInf() As Variant                 '整个网格设置信息
  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 Szzls As Integer                     '数组总列数(网格列数-1)
  516. '以下为固定使用变量(网格2)
  517. Dim GridCode1 As String                  '显示网格网格代码
  518. Dim GridInf1() As Variant                '整个网格设置信息
  519. Dim Qslz1 As Long                        '网格隐藏(非操作显示)列数
  520. Dim Sjhgd1 As Double                     '网格数据行高度
  521. Dim GridBoolean1() As Boolean            '网格列信息(布尔型)
  522. Dim GridStr1()  As String                '网格列信息(字符型)
  523. Dim GridInt1() As Integer                '网格列信息(整型)
  524. Dim Szzls1 As Integer                    '数组总列数(网格列数-1)
  525. Private Sub Form_Load()                                                   '窗体装入
  526.     
  527.     '调 入 网 格1
  528.     GridCode = "Ar_HxglYsk"
  529.     Call BzWgcsh(CxbbGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
  530.     
  531.     Qslz = GridInf(1)
  532.     Sjhgd = GridInf(2)
  533.     Szzls = CxbbGrid.Cols - 1
  534.     
  535.     '调 入 网 格 2
  536.     GridCode1 = "Ar_HxglDk"
  537.     Call BzWgcsh(CxbbGrid1, GridCode1, GridInf1(), GridBoolean1(), GridInt1(), GridStr1())
  538.     
  539.     Qslz1 = GridInf1(1)
  540.     Sjhgd1 = GridInf1(2)
  541.     Szzls1 = CxbbGrid1.Cols - 1
  542.     
  543.     '对网格进行特殊设置
  544.     CxbbGrid.Editable = True
  545.     CxbbGrid1.Editable = True
  546.     
  547. End Sub
  548. Private Sub Form_Unload(Cancel As Integer)                                '窗体卸载
  549.     '卸载条件窗体
  550.     HX_FrmHxCxtj.UnloadCheck.Value = 1
  551.     Unload HX_FrmHxCxtj
  552. End Sub
  553. Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
  554.     Select Case Button.Key
  555.     Case "qbxz"                                          '全 选
  556.         Call Sub_SelectAll
  557.     Case "qbqx"                                          '全 消
  558.         Call Sub_AbandonAll
  559.     Case "zd"                                            '自 动
  560.         Call Sub_AutoSelect
  561.     Case "cx"                                            '查 询
  562.         HX_FrmHxCxtj.Show 1
  563.     Case "hx"                                            '手工核销
  564.         Call Sub_Sghx
  565.     Case "sx"                                            '刷 新
  566.         Call Timer1_Timer
  567.     Case "bz"                                            '帮 助
  568.         Call F1bz
  569.     Case "fh"                                            '退 出
  570.         Unload Me
  571.     End Select
  572. End Sub
  573. Private Sub Timer1_Timer()
  574.     Timer1.Enabled = False
  575.     
  576.     '加快显示速度
  577.     CxbbGrid.Redraw = False
  578.     
  579.     '判断用户选择哪种核销
  580.     Call Sub_Query1
  581.     
  582.     With HX_FrmHxCxtj
  583.         
  584.         '记录核销类型
  585.         Int_Hxlx = .Combo_Jshxlx.ListIndex
  586.         
  587.         Select Case .Combo_Jshxlx.ListIndex
  588.         Case 0              '付款结算
  589.             Call Sub_Query2(1)
  590.         Case 1              '预付款冲应付款
  591.             Call Sub_Query2(2)
  592.         Case 2              '应付冲应收款
  593.             Call Sub_Query3
  594.         End Select
  595.     End With
  596.     
  597.     CxbbGrid.Redraw = True
  598.     
  599. End Sub
  600. Private Sub Sub_Query1()                                        '生成查询结果(应付款)
  601.     Dim Rec_Query As New ADODB.Recordset        '查询结果动态集
  602.     Dim Sqlstr As String                        '查询字符串
  603.     Dim Coljsq As Long                          '网格列计数器
  604.     Dim Jsqte As Long                           '临时动态计数器
  605.     
  606.     Bln_Foreign = False
  607.     
  608.     '以下为自定义部分[
  609.     With HX_FrmHxCxtj
  610.         
  611.         Str_QueryCondi = " Where 1=1 "
  612.         For Jsqte = 1 To 4
  613.             Select Case Jsqte
  614.                 
  615.             Case 1   '单据日期范围(起始)
  616.                 If Trim(.LrText(1).Text) <> "" Then
  617.                     Str_QueryCondi = Str_QueryCondi & " And BillDate>=' " & Trim(.LrText(1).Text) & "'"
  618.                 End If
  619.             Case 2   '单据日期范围(终止)
  620.                 If Trim(.LrText(2).Text) <> "" Then
  621.                     Str_QueryCondi = Str_QueryCondi & " And BillDate<= ' " & Trim(.LrText(2).Text) & "'"
  622.                 End If
  623.                 
  624.             Case 3   '往来供应商
  625.                 If Trim(.LrText(0).Tag) <> "" Then
  626.                     Str_QueryCondi = Str_QueryCondi & " and PSCode = '" & Trim(.LrText(0).Tag) & "'"
  627.                     Str_SupplierCode = Trim(.LrText(0).Tag)
  628.                 Else
  629.                     Str_SupplierCode = ""
  630.                 End If
  631.                 
  632.             Case 4  '原币名称
  633.                 If GetComboKey(.Imgebo_ForeignCurr, 0) <> "Zhbwb" Then
  634.                     Str_QueryCondi = Str_QueryCondi & " and ForeignCurrCode='" & Trim(GetComboKey(.Imgebo_ForeignCurr, 0)) & "'"
  635.                     Bln_Foreign = True
  636.                 End If
  637.                 
  638.             End Select
  639.         Next Jsqte
  640.     End With
  641.     
  642.     '生成应付款查询结果
  643.     Sqlstr = "SELECT * From Ap_V_AccMxList " & Str_QueryCondi & " And RpFlag='AP' And YbYsje<>0 And OverStatus=0 " & " ORDER BY KJYear,Period,BillDate,AccListId"
  644.     
  645.     Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  646.     With Rec_Query
  647.         CxbbGrid.Rows = CxbbGrid.FixedRows
  648.         CxbbGrid.Rows = CxbbGrid.FixedRows + .RecordCount
  649.         Jsqte = CxbbGrid.FixedRows
  650.         
  651.         Do While Not .EOF
  652.             If Jsqte >= CxbbGrid.Rows Then
  653.                 CxbbGrid.AddItem ""
  654.             End If
  655.             
  656.             CxbbGrid.TextMatrix(Jsqte, 0) = .Fields("AccListID")                                               '应收/应付明细帐ID
  657.             
  658.             CxbbGrid.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Jsqte - CxbbGrid.FixedRows + 1         '行值
  659.             CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = False                                  '选中
  660.             CxbbGrid.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls)) = .Fields("BillDate")                    '单据日期
  661.             CxbbGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("BillItemName") & "")     '单据类型
  662.             CxbbGrid.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls)) = Trim(.Fields("BillCode") & "")         '单据编号
  663.             If Bln_Foreign Then
  664.                 If .Fields("YbYsje") <> 0 Then                                                                  '原币应收/应付金额
  665.                     CxbbGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = .Fields("YbYsje")
  666.                 End If
  667.                 If .Fields("YbYsje") - .Fields("YbCancelje") <> 0 Then
  668.                     CxbbGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = .Fields("YbYsje") - .Fields("YbCancelje")  '原币未核销金额
  669.                     CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .Fields("YbYsje") - .Fields("YbCancelje")  '本次核销金额
  670.                 End If
  671.             Else
  672.                 If .Fields("BbYsje") <> 0 Then                                                                  '本币应收/应付金额
  673.                     CxbbGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = .Fields("BbYsje")
  674.                 End If
  675.                 If .Fields("Bbysje") - .Fields("BbCancelje") <> 0 Then
  676.                     CxbbGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = .Fields("Bbysje") - .Fields("BbCancelje")  '本币未核销金额
  677.                     CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .Fields("Bbysje") - .Fields("BbCancelje")  '本次核销金额
  678.                 End If
  679.             End If
  680.             
  681.             CxbbGrid.RowHeight(Jsqte) = Sjhgd
  682.             
  683.             Jsqte = Jsqte + 1
  684.             .MoveNext
  685.             
  686.         Loop
  687.         
  688.     End With
  689.     
  690.     ']以上为用户自定义部分
  691.     
  692. End Sub
  693. Private Sub Sub_Query2(Opti As Integer)                              '生成查询结果(付款,预付款)
  694.     Dim Rec_Query As New ADODB.Recordset        '查询结果动态集
  695.     Dim Sqlstr As String                        '查询字符串
  696.     Dim Coljsq As Long                          '网格列计数器
  697.     Dim Jsqte As Long                           '临时动态计数器
  698.     
  699.     Bln_Foreign = False
  700.     
  701.     '以下为自定义部分[
  702.     With HX_FrmHxCxtj
  703.         
  704.         Str_QueryCondi = " Where 1=1 "
  705.         For Jsqte = 1 To 4
  706.             Select Case Jsqte
  707.                 
  708.             Case 1   '单据日期范围(起始)
  709.                 If Trim(.LrText(1).Text) <> "" Then
  710.                     Str_QueryCondi = Str_QueryCondi & " And BillDate>=' " & Trim(.LrText(1).Text) & "'"
  711.                 End If
  712.             Case 2   '单据日期范围(终止)
  713.                 If Trim(.LrText(2).Text) <> "" Then
  714.                     Str_QueryCondi = Str_QueryCondi & " And BillDate<= ' " & Trim(.LrText(2).Text) & "'"
  715.                 End If
  716.                 
  717.             Case 3  '往来供应商
  718.                 If Trim(.LrText(0).Tag) <> "" Then
  719.                     Str_QueryCondi = Str_QueryCondi & " and PSCode = '" & Trim(.LrText(0).Tag) & "'"
  720.                 End If
  721.                 
  722.             Case 4  '原币名称
  723.                 If GetComboKey(.Imgebo_ForeignCurr, 0) <> "Zhbwb" Then
  724.                     Str_QueryCondi = Str_QueryCondi & " and ForeignCurrCode='" & Trim(GetComboKey(.Imgebo_ForeignCurr, 0)) & "'"
  725.                     Bln_Foreign = True
  726.                 End If
  727.                 
  728.             End Select
  729.         Next Jsqte
  730.     End With
  731.     
  732.     If Opti = 1 Then
  733.         '生成付款查询结果
  734.         Sqlstr = "SELECT * From AP_V_AccMxList " & Str_QueryCondi & " And RpFlag='AP' And (AP_V_AccMxList.BillItemCode='90' OR AP_V_AccMxList.BillItemCode='92') And AP_V_AccMxList.OverStatus=0 " & " ORDER BY KJYear,Period,BillDate,AccListId"
  735.     Else
  736.         '生成预付款查询结果
  737.         Sqlstr = "SELECT * From AP_V_AccMxList " & Str_QueryCondi & " And RpFlag='AP' And (AP_V_AccMxList.BillItemCode='91' OR AP_V_AccMxList.BillItemCode='92') And AP_V_AccMxList.OverStatus=0 " & " ORDER BY KJYear,Period,BillDate,AccListId"
  738.     End If
  739.     
  740.     Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  741.     With Rec_Query
  742.         CxbbGrid1.Rows = CxbbGrid1.FixedRows
  743.         CxbbGrid1.Rows = CxbbGrid1.FixedRows + .RecordCount
  744.         Jsqte = CxbbGrid1.FixedRows
  745.         
  746.         Do While Not .EOF
  747.             If Jsqte >= CxbbGrid1.Rows Then
  748.                 CxbbGrid1.AddItem ""
  749.             End If
  750.             
  751.             CxbbGrid1.TextMatrix(Jsqte, 0) = .Fields("AccListID")                                                 '应收/应付明细帐ID
  752.             
  753.             CxbbGrid1.TextMatrix(Jsqte, Sydz("001", GridStr1(), Szzls1)) = Jsqte - CxbbGrid1.FixedRows + 1        '行值
  754.             CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = False                                  '选中
  755.             CxbbGrid1.TextMatrix(Jsqte, Sydz("003", GridStr1(), Szzls1)) = .Fields("BillDate")                    '单据日期
  756.             CxbbGrid1.TextMatrix(Jsqte, Sydz("004", GridStr1(), Szzls1)) = Trim(.Fields("BillItemName") & "")     '单据类型
  757.             CxbbGrid1.TextMatrix(Jsqte, Sydz("005", GridStr1(), Szzls1)) = Trim(.Fields("BillCode") & "")         '单据编号
  758.             If Bln_Foreign Then
  759.                 If .Fields("YbSsje") <> 0 Then                                                                     '原币收回/付款金额
  760.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("006", GridStr1(), Szzls1)) = Trim(Str(.Fields("YbSsje")))
  761.                 End If
  762.                 If .Fields("YbSsje") - .Fields("YbCancelje") <> 0 Then
  763.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("007", GridStr1(), Szzls1)) = Trim(Str(.Fields("YbSsje") - .Fields("YbCancelje")))  '原币已核销金额
  764.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)) = Trim(Str(.Fields("YbSsje") - .Fields("YbCancelje")))  '本次核销金额
  765.                 End If
  766.             Else
  767.                 If .Fields("BbSsje") <> 0 Then                                                                     '收回/付款金额
  768.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("006", GridStr1(), Szzls1)) = Trim(Str(.Fields("BbSsje")))
  769.                 End If
  770.                 If .Fields("BbSsje") - .Fields("BbCancelje") <> 0 Then
  771.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("007", GridStr1(), Szzls1)) = Trim(Str(.Fields("BbSsje") - .Fields("BbCancelje")))  '已核销金额
  772.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)) = Trim(Str(.Fields("BbSsje") - .Fields("BbCancelje")))  '本次核销金额
  773.                 End If
  774.             End If
  775.             
  776.             CxbbGrid1.RowHeight(Jsqte) = Sjhgd1
  777.             
  778.             Jsqte = Jsqte + 1
  779.             .MoveNext
  780.             
  781.         Loop
  782.         
  783.     End With
  784.     
  785.     ']以上为用户自定义部分
  786.     
  787. End Sub
  788. Private Sub Sub_Query3()                                        '生成查询结果(应收款)
  789.     Dim Rec_Query As New ADODB.Recordset        '查询结果动态集
  790.     Dim Sqlstr As String                        '查询字符串
  791.     Dim Coljsq As Long                          '网格列计数器
  792.     Dim Jsqte As Long                       '临时动态计数器
  793.     
  794.     Bln_Foreign = False
  795.     
  796.     '以下为自定义部分[
  797.     With HX_FrmHxCxtj
  798.         
  799.         Str_QueryCondi = " Where 1=1 "
  800.         For Jsqte = 1 To 4
  801.             Select Case Jsqte
  802.                 
  803.             Case 1   '单据日期范围(起始)
  804.                 If Trim(.LrText(1).Text) <> "" Then
  805.                     Str_QueryCondi = Str_QueryCondi & " And BillDate>=' " & Trim(.LrText(1).Text) & "'"
  806.                 End If
  807.             Case 2   '单据日期范围(终止)
  808.                 If Trim(.LrText(2).Text) <> "" Then
  809.                     Str_QueryCondi = Str_QueryCondi & " And BillDate<= ' " & Trim(.LrText(2).Text) & "'"
  810.                 End If
  811.                 
  812.             Case 3  '往来客户
  813.                 If Trim(.LrText(3).Tag) <> "" Then
  814.                     Str_QueryCondi = Str_QueryCondi & " and PSCode = '" & Trim(.LrText(3).Tag) & "'"
  815.                     Str_CusCode = Trim(.LrText(3).Tag)
  816.                 Else
  817.                     Str_CusCode = ""
  818.                 End If
  819.                 
  820.             Case 4  '原币名称
  821.                 If GetComboKey(.Imgebo_ForeignCurr, 0) <> "Zhbwb" Then
  822.                     Str_QueryCondi = Str_QueryCondi & " and ForeignCurrCode='" & Trim(GetComboKey(.Imgebo_ForeignCurr, 0)) & "'"
  823.                     Bln_Foreign = True
  824.                 End If
  825.                 
  826.             End Select
  827.         Next Jsqte
  828.     End With
  829.     
  830.     '生成应付款查询结果
  831.     Sqlstr = "SELECT * From AP_V_AccMxList " & Str_QueryCondi & " And RpFlag='AR' And YbYsje<>0 And OverStatus=0 " & " ORDER BY KJYear,Period,BillDate,AccListId"
  832.     
  833.     Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  834.     With Rec_Query
  835.         CxbbGrid1.Rows = CxbbGrid1.FixedRows
  836.         CxbbGrid1.Rows = CxbbGrid1.FixedRows + .RecordCount
  837.         Jsqte = CxbbGrid1.FixedRows
  838.         
  839.         Do While Not .EOF
  840.             If Jsqte >= CxbbGrid1.Rows Then
  841.                 CxbbGrid1.AddItem ""
  842.             End If
  843.             
  844.             CxbbGrid1.TextMatrix(Jsqte, 0) = .Fields("AccListID")                                               '应收/应付明细帐ID
  845.             
  846.             CxbbGrid1.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Jsqte - CxbbGrid1.FixedRows + 1         '行值
  847.             CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = False                                  '选中
  848.             CxbbGrid1.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls)) = .Fields("BillDate")                    '单据日期
  849.             CxbbGrid1.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("BillItemName") & "")     '单据类型
  850.             CxbbGrid1.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls)) = Trim(.Fields("BillCode") & "")         '单据编号
  851.             If Bln_Foreign Then
  852.                 If .Fields("YbYsje") <> 0 Then                                                                  '原币应收/应付金额
  853.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = .Fields("YbYsje")
  854.                 End If
  855.                 If .Fields("YbYsje") - .Fields("YbCancelje") <> 0 Then
  856.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = .Fields("YbYsje") - .Fields("YbCancelje")  '原币未核销金额
  857.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .Fields("YbYsje") - .Fields("YbCancelje")  '本次核销金额
  858.                 End If
  859.             Else: Print
  860.                 If .Fields("BbYsje") <> 0 Then                                                                  '本币应收/应付金额
  861.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = .Fields("BbYsje")
  862.                 End If
  863.                 If .Fields("Bbysje") - .Fields("BbCancelje") <> 0 Then
  864.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = .Fields("Bbysje") - .Fields("BbCancelje")  '本币未核销金额
  865.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .Fields("Bbysje") - .Fields("BbCancelje")  '本次核销金额
  866.                 End If
  867.             End If
  868.             
  869.             CxbbGrid1.RowHeight(Jsqte) = Sjhgd
  870.             
  871.             Jsqte = Jsqte + 1
  872.             .MoveNext
  873.             
  874.         Loop
  875.         
  876.     End With
  877.     
  878.     ']以上为用户自定义部分
  879.     
  880. End Sub
  881. '============================金额输入过程控制============================'
  882. '输入本次核销金额(网格1)
  883. Private Sub CxbbGrid_BeforeEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)
  884.     With CxbbGrid
  885.         If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
  886.             Cancel = True
  887.         End If
  888.         If GridInt(.Col, 2) <> 0 Then
  889.             CxbbGrid.EditMaxLength = GridInt(.Col, 2)
  890.         Else
  891.             CxbbGrid.EditMaxLength = 3000
  892.         End If
  893.     End With
  894. End Sub
  895. Private Sub CxbbGrid_KeyPressEdit(ByVal Row As Long, ByVal Col As Long, KeyAscii As Integer)
  896.     Call Sub_Lrxszxz(CxbbGrid, KeyAscii)
  897. End Sub
  898. Private Sub CxbbGrid_ChangeEdit()
  899.     With CxbbGrid
  900.         Select Case GridInt(.Col, 1)
  901.         Case 8, 11
  902.             Call Sub_Sjgskz(CxbbGrid, Xtjezws - Xtjexsws - 1, Xtjexsws)
  903.         Case 9, 12
  904.             Call Sub_Sjgskz(CxbbGrid, Xtslzws - Xtslxsws - 1, Xtslxsws)
  905.         Case 10
  906.             Call Sub_Sjgskz(CxbbGrid, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  907.         Case Else
  908.             If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
  909.                 Call Sub_Sjgskz(CxbbGrid, GridInt(.Col, 3), GridInt(.Col, 4))
  910.             End If
  911.         End Select
  912.     End With
  913. End Sub
  914. Private Sub CxbbGrid_AfterEdit(ByVal Row As Long, ByVal Col As Long)                                  '事后判断用户录入有效性
  915.     With CxbbGrid
  916.         Select Case Col
  917.         Case Sydz("008", GridStr(), Szzls)
  918.             
  919.             '本次核销金额不能大于单据未核销金额或等于0,如大于则自动取未核销金额填入
  920.             
  921.             If (Val(.TextMatrix(Row, Col)) > Val(.TextMatrix(Row, Sydz("007", GridStr(), Szzls)))) Or Val(.TextMatrix(Row, Col)) = 0 Then
  922.                 .TextMatrix(Row, Col) = .TextMatrix(Row, Sydz("007", GridStr(), Szzls))
  923.             End If
  924.         End Select
  925.     End With
  926. End Sub
  927. '输入本次核销金额(网格2)
  928. Private Sub CxbbGrid1_BeforeEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)
  929.     With CxbbGrid1
  930.         If Not GridBoolean1(.Col, 1) Or .Row < .FixedRows Then
  931.             Cancel = True
  932.         End If
  933.         If GridInt1(.Col, 2) <> 0 Then
  934.             CxbbGrid1.EditMaxLength = GridInt1(.Col, 2)
  935.         Else
  936.             CxbbGrid1.EditMaxLength = 3000
  937.         End If
  938.     End With
  939. End Sub
  940. Private Sub CxbbGrid1_KeyPressEdit(ByVal Row As Long, ByVal Col As Long, KeyAscii As Integer)
  941.     Call Sub_Lrxszxz(CxbbGrid1, KeyAscii)
  942. End Sub
  943. Private Sub CxbbGrid1_ChangeEdit()
  944.     With CxbbGrid1
  945.         Select Case GridInt1(.Col, 1)
  946.         Case 8, 11
  947.             Call Sub_Sjgskz(CxbbGrid1, Xtjezws - Xtjexsws - 1, Xtjexsws)
  948.         Case 9, 12
  949.             Call Sub_Sjgskz(CxbbGrid1, Xtslzws - Xtslxsws - 1, Xtslxsws)
  950.         Case 10
  951.             Call Sub_Sjgskz(CxbbGrid1, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
  952.         Case Else
  953.             If GridInt1(.Col, 3) <> 0 Or GridInt1(.Col, 4) <> 0 Then
  954.                 Call Sub_Sjgskz(CxbbGrid1, GridInt1(.Col, 3), GridInt1(.Col, 4))
  955.             End If
  956.         End Select
  957.     End With
  958. End Sub
  959. Private Sub CxbbGrid1_AfterEdit(ByVal Row As Long, ByVal Col As Long)                                  '事后判断用户录入有效性
  960.     With CxbbGrid1
  961.         Select Case Col
  962.         Case Sydz("008", GridStr1(), Szzls1)
  963.             
  964.             '本次核销金额不能大于单据未核销金额或等于0,如大于则自动取未核销金额填入
  965.             
  966.             If (Val(.TextMatrix(Row, Col)) > Val(.TextMatrix(Row, Sydz("007", GridStr1(), Szzls1)))) Or Val(.TextMatrix(Row, Col)) = 0 Then
  967.                 .TextMatrix(Row, Col) = .TextMatrix(Row, Sydz("007", GridStr1(), Szzls1))
  968.             End If
  969.         End Select
  970.     End With
  971. End Sub
  972. '公用数值控制函数
  973. Private Sub Sub_Lrxszxz(WglrGrid As VSFlexGrid, lrzfasc As Integer)                               '网格录入带有小数位及正负号数值字段
  974.     If Not ((Chr(lrzfasc) >= "0" And Chr(lrzfasc) <= "9") Or (Chr(lrzfasc) = "." And InStr(1, WglrGrid.EditText, ".") = 0) Or lrzfasc = vbKeyBack Or (Chr(lrzfasc) = "-" And WglrGrid.EditSelStart = 0)) Then
  975.         lrzfasc = 0
  976.     End If
  977. End Sub
  978. Private Sub Sub_Sjgskz(WglrGrid As VSFlexGrid, zsws As Integer, xsws As Integer)                  '保证数值录入字段录入格式
  979.     Dim xsdwz%, bccrd%
  980.     xsdwz = InStr(1, WglrGrid.EditText, ".")
  981.     bccrd = WglrGrid.EditSelStart
  982.     If xsdwz = 0 Then
  983.         WglrGrid.EditText = Mid(WglrGrid.EditText, 1, zsws)
  984.         WglrGrid.EditSelStart = bccrd
  985.         Exit Sub
  986.     End If
  987.     If zsws > xsdwz - 1 Then
  988.         Zswstr = Mid(WglrGrid.EditText, 1, xsdwz - 1)
  989.     Else
  990.         Zswstr = Mid(WglrGrid.EditText, 1, zsws)
  991.     End If
  992.     xswstr = Mid(WglrGrid.EditText, xsdwz + 1, xsws)
  993.     WglrGrid.EditText = Zswstr + "." + xswstr
  994.     WglrGrid.EditSelStart = bccrd
  995. End Sub
  996. '以下为网格选中操作
  997. Private Sub CxbbGrid_DblClick()
  998.     With CxbbGrid
  999.         
  1000.         CxbbGrid.EditCell   '调用网格编辑方法
  1001.         
  1002.         If .Row < .FixedRows Or .Col <> Sydz("002", GridStr(), Szzls) Then
  1003.             Exit Sub
  1004.         End If
  1005.         If CxbbGrid.TextMatrix(.Row, Sydz("002", GridStr(), Szzls)) Then
  1006.             CxbbGrid.TextMatrix(.Row, Sydz("002", GridStr(), Szzls)) = False
  1007.         Else
  1008.             CxbbGrid.TextMatrix(.Row, Sydz("002", GridStr(), Szzls)) = True
  1009.         End If
  1010.     End With
  1011. End Sub
  1012. Private Sub CxbbGrid_KeyPress(KeyAscii As Integer)      '用户按空格表示切换,按回车表示选中
  1013.     With CxbbGrid
  1014.         If .Row < .FixedRows Or .Col <> Sydz("002", GridStr(), Szzls) Then
  1015.             Exit Sub
  1016.         End If
  1017.         If Chr(KeyAscii) = " " Then
  1018.             Call CxbbGrid_DblClick
  1019.         End If
  1020.         
  1021.         If KeyAscii = vbKeyReturn Then
  1022.             CxbbGrid.TextMatrix(.Row, Sydz("002", GridStr(), Szzls)) = True
  1023.         End If
  1024.     End With
  1025. End Sub
  1026. Private Sub CxbbGrid1_DblClick()
  1027.     
  1028.     CxbbGrid1.EditCell   '调用网格编辑方法
  1029.     
  1030.     With CxbbGrid1
  1031.         If .Row < .FixedRows Or .Col <> Sydz("002", GridStr1(), Szzls1) Then
  1032.             Exit Sub
  1033.         End If
  1034.         If CxbbGrid1.TextMatrix(.Row, Sydz("002", GridStr1(), Szzls1)) Then
  1035.             CxbbGrid1.TextMatrix(.Row, Sydz("002", GridStr1(), Szzls1)) = False
  1036.         Else
  1037.             CxbbGrid1.TextMatrix(.Row, Sydz("002", GridStr1(), Szzls1)) = True
  1038.         End If
  1039.     End With
  1040. End Sub
  1041. Private Sub CxbbGrid1_KeyPress(KeyAscii As Integer)      '用户按空格表示切换,按回车表示选中
  1042.     With CxbbGrid1
  1043.         If .Row < .FixedRows Or .Col <> Sydz("002", GridStr1(), Szzls1) Then
  1044.             Exit Sub
  1045.         End If
  1046.         If Chr(KeyAscii) = " " Then
  1047.             Call CxbbGrid1_DblClick
  1048.         End If
  1049.         
  1050.         If KeyAscii = vbKeyReturn Then
  1051.             CxbbGrid1.TextMatrix(.Row, Sydz("002", GridStr1(), Szzls1)) = True
  1052.         End If
  1053.     End With
  1054. End Sub
  1055. Private Sub Sub_SelectAll()                            '全选
  1056.     With CxbbGrid
  1057.         For Jsqte = .FixedRows To .Rows - 1
  1058.             CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True
  1059.         Next Jsqte
  1060.     End With
  1061.     With CxbbGrid1
  1062.         For Jsqte = .FixedRows To .Rows - 1
  1063.             CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = True
  1064.         Next Jsqte
  1065.     End With
  1066. End Sub
  1067. Private Sub Sub_AbandonAll()                            '全消
  1068.     With CxbbGrid
  1069.         For Jsqte = .FixedRows To .Rows - 1
  1070.             CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = False
  1071.         Next Jsqte
  1072.     End With
  1073.     With CxbbGrid1
  1074.         For Jsqte = .FixedRows To .Rows - 1
  1075.             CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = False
  1076.         Next Jsqte
  1077.     End With
  1078. End Sub
  1079. Private Sub Sub_AutoSelect()                            '自动
  1080.     Dim Dbl_Yskhj As Double             '网格(应付款)未核销金额合计
  1081.     Dim Dbl_Dkhj As Double              '网格(付款、退款、预付款、应收款)未核销金额合计
  1082.     
  1083.     '先判断以哪方金额为核销基准(以金额小的一方)
  1084.     With CxbbGrid
  1085.         For Jsqte = .FixedRows To .Rows - 1
  1086.             Dbl_Yskhj = Dbl_Yskhj + Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1087.         Next Jsqte
  1088.     End With
  1089.     
  1090.     With CxbbGrid1
  1091.         For Jsqte = .FixedRows To .Rows - 1
  1092.             Dbl_Dkhj = Dbl_Dkhj + Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1093.         Next Jsqte
  1094.     End With
  1095.     
  1096.     If Dbl_Yskhj >= Dbl_Dkhj Then
  1097.         
  1098.         With CxbbGrid1
  1099.             For Jsqte = .FixedRows To .Rows - 1
  1100.                 CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True
  1101.                 .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))
  1102.             Next Jsqte
  1103.         End With
  1104.         
  1105.         With CxbbGrid
  1106.             For Jsqte = .FixedRows To .Rows - 1
  1107.                 If Dbl_Dkhj <> 0 Then
  1108.                     CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True
  1109.                     If Dbl_Dkhj > Val(.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))) Then
  1110.                         .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))
  1111.                     Else
  1112.                         .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Dbl_Dkhj
  1113.                     End If
  1114.                     Dbl_Dkhj = Dbl_Dkhj - Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1115.                 End If
  1116.             Next Jsqte
  1117.         End With
  1118.         
  1119.     Else
  1120.         
  1121.         With CxbbGrid
  1122.             For Jsqte = .FixedRows To .Rows - 1
  1123.                 CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True
  1124.                 .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))
  1125.             Next Jsqte
  1126.         End With
  1127.         
  1128.         With CxbbGrid1
  1129.             For Jsqte = .FixedRows To .Rows - 1
  1130.                 If Dbl_Yskhj <> 0 Then
  1131.                     CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True
  1132.                     If Dbl_Yskhj > Val(.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))) Then
  1133.                         .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))
  1134.                     Else
  1135.                         .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Dbl_Yskhj
  1136.                     End If
  1137.                     Dbl_Yskhj = Dbl_Yskhj - Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1138.                 End If
  1139.             Next Jsqte
  1140.         End With
  1141.         
  1142.     End If
  1143.     
  1144. End Sub
  1145. Private Sub Sub_Sghx()                                      '手工核销
  1146.     Select Case Int_Hxlx
  1147.     Case 0, 1      '付款结算、预付款冲应付款
  1148.         If Fun_Dkjs(Int_Hxlx) Then
  1149.             Call Timer1_Timer
  1150.         End If
  1151.     Case 2
  1152.         If Fun_YsCYf Then
  1153.             Call Timer1_Timer
  1154.         End If
  1155.     End Select
  1156. End Sub
  1157. Private Function Fun_Dkjs(Int_Hxlx As Integer) As Boolean                       '付款结算
  1158.     
  1159.     '函数参数:Int_Hxlx 核销类型 0-付款结算 1-预付款冲应付款
  1160.     
  1161.     Dim Rec_AccList As New ADODB.Recordset        '应收/应付明细帐
  1162.     Dim Rec_Cancel As New ADODB.Recordset         '应收/应付核销情况表
  1163.     Dim RecTemp As New ADODB.Recordset            '临时动态集
  1164.     Dim Dbl_Phjg As Double                        '平衡结果
  1165.     Dim Dbl_Phjg1 As Double                       '平衡结果1
  1166.     Dim Jsqte As Long                             '临时计数器
  1167.     Dim Bln_Select As Boolean                     '是否选中核销单据
  1168.     Dim Sqlstr As String                          '查询连接串
  1169.     Dim Bln_ConVertFlag As Boolean                '折算方式
  1170.     Dim Lng_CancelNo As Long                      '核销过程序号
  1171.     Dim Dbl_CWbje As Double                       '核销原币金额
  1172.     Dim Dbl_CBbje As Double                       '核销本币金额
  1173.     
  1174.     
  1175.     Bln_Select = False
  1176.     
  1177.     '让录入充分完成
  1178.     CxbbGrid.Col = 0
  1179.     CxbbGrid1.Col = 0
  1180.     
  1181.     Dbl_Phjg = 0
  1182.     Dbl_Phjg1 = 0
  1183.     
  1184.     '先判断用户输入核销金额是否平衡
  1185.     With CxbbGrid
  1186.         For Jsqte = .FixedRows To .Rows - 1
  1187.             If .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True Then
  1188.                 Bln_Select = True
  1189.                 Dbl_Phjg = Dbl_Phjg + Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1190.             End If
  1191.         Next Jsqte
  1192.     End With
  1193.     
  1194.     With CxbbGrid1
  1195.         For Jsqte = .FixedRows To .Rows - 1
  1196.             If .TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = True Then
  1197.                 Bln_Select = True
  1198.                 Dbl_Phjg1 = Dbl_Phjg1 + Val(.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
  1199.             End If
  1200.         Next Jsqte
  1201.     End With
  1202.     
  1203.     If Not Bln_Select Then
  1204.         Tsxx = "请先选中核销记录!"
  1205.         Call Xtxxts(Tsxx, 0, 4)
  1206.         Exit Function
  1207.     End If
  1208.     
  1209.     If Abs(Dbl_Phjg - Dbl_Phjg1) >= 0.001 Then
  1210.         Tsxx = "核销金额不平衡,不能进行核销!"
  1211.         Call Xtxxts(Tsxx, 0, 4)
  1212.         Exit Function
  1213.     End If
  1214.     
  1215.     '开始进行核销
  1216.     
  1217.     On Error GoTo Swcwcl
  1218.     
  1219.     Cw_DataEnvi.DataConnect.BeginTrans
  1220.     
  1221.     '取最大核销过程序号
  1222.     Sqlstr = "Select Max(CancelNo) as MaxCancelNo From RP_Cancel Where RpFlag='AP'"
  1223.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1224.     
  1225.     If Not IsNull(RecTemp.Fields("MaxCancelNo")) Then
  1226.         Lng_CancelNo = RecTemp.Fields("MaxCancelNo") + 1
  1227.     Else
  1228.         Lng_CancelNo = 1
  1229.     End If
  1230.     
  1231.     '1.核销应收/应付款明细帐
  1232.     With CxbbGrid
  1233.         For Jsqte = .FixedRows To .Rows - 1
  1234.             If .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True Then
  1235.                 With Rec_AccList
  1236.                     If Rec_AccList.State = 1 Then .Close
  1237.                     
  1238.                     Sqlstr = "Select RP_Acclist.* From RP_AccList" & _
  1239.                     " Where AcclistID = " & Val(CxbbGrid.TextMatrix(Jsqte, 0))
  1240.                     
  1241.                     Rec_AccList.Open Sqlstr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1242.                     
  1243.                     Sqlstr = "Select Gy_ForeignCurrency.ConVertFlag From Gy_ForeignCurrency Where Gy_ForeignCurrency.ForeignCurrCode='" & Trim(.Fields("ForeignCurrCode")) & "'"
  1244.                     
  1245.                     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1246.                     
  1247.                     If RecTemp.Fields("ConVertFlag") Then
  1248.                         Bln_ConVertFlag = True
  1249.                     Else
  1250.                         Bln_ConVertFlag = False
  1251.                     End If
  1252.                     
  1253.                     If Bln_Foreign Then
  1254.                         
  1255.                         '按原币核销
  1256.                         .Fields("YbCancelje") = .Fields("YbCancelje") + Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1257.                         Dbl_CWbje = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1258.                         
  1259.                         If Not Bln_ConVertFlag Then
  1260.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1261.                             Dbl_CBbje = Format(Dbl_CWbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1262.                         Else
  1263.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1264.                             Dbl_CBbje = Format(Dbl_CWbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1265.                         End If
  1266.                         
  1267.                         If .Fields("YbCancelje") = .Fields("YbYsje") Then
  1268.                             .Fields("OverStatus") = 1
  1269.                         End If
  1270.                         
  1271.                     Else
  1272.                         
  1273.                         '按本币核销
  1274.                         .Fields("BbCancelje") = .Fields("BbCancelje") + Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1275.                         Dbl_CBbje = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1276.                         If Bln_ConVertFlag Then
  1277.                             .Fields("YbCancelje") = Format(.Fields("BbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1278.                             Dbl_CWbje = Format(Dbl_CBbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1279.                         Else
  1280.                             .Fields("YbCancelje") = Format(.Fields("BbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1281.                             Dbl_CWbje = Format(Dbl_CBbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1282.                         End If
  1283.                         
  1284.                         If .Fields("BbCancelje") = .Fields("BbYsje") Then
  1285.                             .Fields("OverStatus") = 1
  1286.                         End If
  1287.                     End If
  1288.                     
  1289.                     .Update
  1290.                     
  1291.                     If Rec_Cancel.State = 1 Then Rec_Cancel.Close
  1292.                     Rec_Cancel.Open "Select * From RP_Cancel Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1293.                     Rec_Cancel.AddNew
  1294.                     
  1295.                     Rec_Cancel.Fields("RPFlag") = "AP"                                '应收/应付帐标识
  1296.                     If Int_Hxlx = 0 Then
  1297.                         Rec_Cancel.Fields("CancelItemCode") = "A0"                    '核销处理过程编码(A0:付款结算)
  1298.                     Else
  1299.                         Rec_Cancel.Fields("CancelItemCode") = "A1"                    '核销处理过程编码(A1:预付款冲应付款)
  1300.                     End If
  1301.                     Rec_Cancel.Fields("SupplierCode") = Str_SupplierCode              '往来供应商编码
  1302.                     Rec_Cancel.Fields("CancelNo") = Lng_CancelNo                      '核销过程序号
  1303.                     Rec_Cancel.Fields("CancelDate") = Xtrq                            '核销日期
  1304.                     Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode")       '单据类型编码
  1305.                     Rec_Cancel.Fields("BillID") = .Fields("BillID")                   '单据ID
  1306.                     Rec_Cancel.Fields("BillCode") = .Fields("BillCode")               '单据编号
  1307.                     Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
  1308.                     Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0             '记帐汇率
  1309.                     Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje                       '原币核销金额
  1310.                     Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje                       '本币核销金额
  1311.                     Rec_Cancel.Fields("Ybye") = .Fields("YbYsje") - .Fields("YbCancelje")  '原币剩余金额
  1312.                     Rec_Cancel.Fields("Bbye") = .Fields("BbYsje") - .Fields("BbCancelje")  '本币剩余金额
  1313.                     Rec_Cancel.Fields("Canceler") = Xtczy
  1314.                     Rec_Cancel.Update
  1315.                     
  1316.                     '如果为采购发票,则填写回款金额
  1317.                     If Trim(.Fields("BillItemCode")) = "70" Or Trim(.Fields("BillItemCode")) = "71" Then
  1318.                         Sqlstr = "Update Cg_InvoiceMain SET CwComingValue=CwComingValue+" & Dbl_CBbje & ",CwComingValueFor=CwComingValueFor+" & Dbl_CWbje & " Where InvoiceMainID=" & .Fields("BillId")
  1319.                         Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1320.                     End If
  1321.                     
  1322.                     
  1323.                 End With
  1324.             End If
  1325.         Next Jsqte
  1326.     End With
  1327.     
  1328.     '1.核销付款明细帐
  1329.     
  1330.     With CxbbGrid1
  1331.         For Jsqte = .FixedRows To .Rows - 1
  1332.             If .TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = True Then
  1333.                 With Rec_AccList
  1334.                     If Rec_AccList.State = 1 Then .Close
  1335.                     
  1336.                     Sqlstr = "Select RP_Acclist.* From RP_AccList" & _
  1337.                     " Where AcclistID = " & Val(CxbbGrid1.TextMatrix(Jsqte, 0))
  1338.                     
  1339.                     Rec_AccList.Open Sqlstr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1340.                     
  1341.                     Sqlstr = "Select Gy_ForeignCurrency.ConVertFlag From Gy_ForeignCurrency where Gy_ForeignCurrency.ForeignCurrCode='" & Trim(.Fields("ForeignCurrCode")) & "'"
  1342.                     
  1343.                     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1344.                     
  1345.                     If RecTemp.Fields("ConvertFlag") Then
  1346.                         Bln_ConVertFlag = True
  1347.                     Else
  1348.                         Bln_ConVertFlag = False
  1349.                     End If
  1350.                     
  1351.                     If Bln_Foreign Then
  1352.                         
  1353.                         '按原币核销
  1354.                         .Fields("YbCancelje") = .Fields("YbCancelje") + Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
  1355.                         Dbl_CWbje = Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
  1356.                         
  1357.                         If Not Bln_ConVertFlag Then
  1358.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1359.                             Dbl_CBbje = Format(Dbl_CWbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1360.                         Else
  1361.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1362.                             Dbl_CBbje = Format(Dbl_CWbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1363.                         End If
  1364.                         
  1365.                         If .Fields("YbCancelje") = .Fields("YbSsje") Then
  1366.                             .Fields("OverStatus") = 1
  1367.                         End If
  1368.                         
  1369.                     Else
  1370.                         
  1371.                         '按本币核销
  1372.                         .Fields("BbCancelje") = .Fields("BbCancelje") + Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
  1373.                         Dbl_CBbje = Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
  1374.                         If Bln_ConVertFlag Then
  1375.                             .Fields("YbCancelje") = Format(.Fields("BbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1376.                             Dbl_CWbje = Format(Dbl_CBbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1377.                         Else
  1378.                             .Fields("YbCancelje") = Format(.Fields("BbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1379.                             Dbl_CWbje = Format(Dbl_CBbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1380.                         End If
  1381.                         
  1382.                         If .Fields("BbCancelje") = .Fields("BbSsje") Then
  1383.                             .Fields("OverStatus") = 1
  1384.                         End If
  1385.                         
  1386.                     End If
  1387.                     
  1388.                     .Update
  1389.                     
  1390.                     If Rec_Cancel.State = 1 Then Rec_Cancel.Close
  1391.                     Rec_Cancel.Open "Select * From RP_Cancel Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1392.                     Rec_Cancel.AddNew
  1393.                     
  1394.                     Rec_Cancel.Fields("RPFlag") = "AP"                                '应收/应付帐标识
  1395.                     If Int_Hxlx = 0 Then
  1396.                         Rec_Cancel.Fields("CancelItemCode") = "A0"                    '核销处理过程编码(A0:付款结算)
  1397.                     Else
  1398.                         Rec_Cancel.Fields("CancelItemCode") = "A1"                    '核销处理过程编码(A1:预付款冲应付款)
  1399.                     End If
  1400.                     Rec_Cancel.Fields("SupplierCode") = Str_SupplierCode              '往来供应商编码
  1401.                     Rec_Cancel.Fields("CancelNo") = Lng_CancelNo                      '核销过程序号
  1402.                     Rec_Cancel.Fields("CancelDate") = Xtrq                            '核销日期
  1403.                     Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode")       '单据类型编码
  1404.                     Rec_Cancel.Fields("BillID") = .Fields("BillID")                   '单据ID
  1405.                     Rec_Cancel.Fields("BillCode") = .Fields("BillCode")               '单据编号
  1406.                     Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
  1407.                     Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0             '记帐汇率
  1408.                     Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje                       '原币核销金额
  1409.                     Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje                       '本币核销金额
  1410.                     Rec_Cancel.Fields("YbYe") = .Fields("YbSsje") - .Fields("YbCancelje")  '原币剩余金额
  1411.                     Rec_Cancel.Fields("BbYe") = .Fields("BbSsje") - .Fields("BbCancelje")  '本币剩余金额
  1412.                     Rec_Cancel.Fields("Canceler") = Xtczy
  1413.                     
  1414.                     Rec_Cancel.Update
  1415.                 End With
  1416.             End If
  1417.         Next Jsqte
  1418.     End With
  1419.     
  1420.     Cw_DataEnvi.DataConnect.CommitTrans
  1421.     
  1422.     Fun_Dkjs = True
  1423.     
  1424.     Exit Function
  1425. Swcwcl:
  1426.     Cw_DataEnvi.DataConnect.RollbackTrans
  1427.     Tsxx = "核销过程中出现未知错误,程序自动恢复核销前状态!"
  1428.     Call Xtxxts(Tsxx, 0, 1)
  1429.     Exit Function
  1430. End Function
  1431. Private Function Fun_YsCYf() As Boolean                                  '应付冲应收
  1432.     
  1433.     Dim Rec_AccList As New ADODB.Recordset        '应收/应付明细帐
  1434.     Dim Rec_AccList1 As New ADODB.Recordset       '应收/应付明细帐1
  1435.     Dim Rec_Cancel As New ADODB.Recordset         '应收/应付核销情况表
  1436.     Dim RecTemp As New ADODB.Recordset            '临时动态集
  1437.     Dim Rec_AccSum As New ADODB.Recordset         '应收应付总帐动态集
  1438.     Dim Dbl_YsSelect As Double                    '选中应收帐款记录核销金额合计
  1439.     Dim Dbl_YfSelect As Double                    '选中应付帐款记录核销金额合计
  1440.     Dim Jsqte As Long                             '临时计数器
  1441.     Dim Bln_Select As Boolean                     '是否选中核销单据
  1442.     Dim Sqlstr As String                          '查询连接串
  1443.     Dim Bln_ConVertFlag As Boolean                '折算方式
  1444.     Dim Lng_CancelNo As Long                      '核销过程序号
  1445.     Dim Dbl_CWbje As Double                       '核销原币金额
  1446.     Dim Dbl_CBbje As Double                       '核销本币金额
  1447.     Dim Int_Dqyear As Integer                     '用户选择会计年度
  1448.     Dim Int_DqPeriod As Integer                   '用户选择会计期间
  1449.     
  1450.     Dim Lng_BillID As Long                        '单据ID
  1451.     Dim Str_BillCode As String                    '单据编码
  1452.     Dim Lng_CancelId As Long                      '临时使用核销ID
  1453.     
  1454.     '因为应付冲应收直接生成明细帐,所以业务操作日期必须在当前会计期间内
  1455.     '判断用户所选业务日期与当前会计期间是否一致
  1456.     Sqlstr = "Select Top 1 * FROM Gy_Kjrlb Where ApJzbz=0 Order By Kjyear,Period"
  1457.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1458.     With RecTemp
  1459.         If Not .EOF Then
  1460.            If Not (Xtrq >= .Fields("Qsrq") And Xtrq <= .Fields("Zzrq")) Then
  1461.               Tsxx = "业务日期应在当前会计期间范围内!"
  1462.               Call Xtxxts(Tsxx, 0, 4)
  1463.               Exit Function
  1464.            Else
  1465.               Int_Dqyear = .Fields("Kjyear")
  1466.               Int_DqPeriod = .Fields("Period")
  1467.            End If
  1468.         Else
  1469.            Tsxx = "所有会计期间已结帐完毕!"
  1470.            Call Xtxxts(Tsxx, 0, 4)
  1471.            Exit Function
  1472.         End If
  1473.     End With
  1474.     
  1475.     Bln_Select = False
  1476.     
  1477.     '让录入充分完成
  1478.     CxbbGrid.Col = 0
  1479.     CxbbGrid1.Col = 0
  1480.     
  1481.     '初始化合计值
  1482.     Dbl_YsSelect = 0
  1483.     Dbl_YfSelect = 0
  1484.     
  1485.     '先判断用户输入核销金额是否平衡
  1486.     With CxbbGrid
  1487.         For Jsqte = .FixedRows To .Rows - 1
  1488.             If .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True Then
  1489.                 Bln_Select = True
  1490.                 Dbl_YsSelect = Dbl_YsSelect + Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1491.             End If
  1492.         Next Jsqte
  1493.     End With
  1494.     
  1495.     With CxbbGrid1
  1496.         For Jsqte = .FixedRows To .Rows - 1
  1497.             If .TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = True Then
  1498.                 Bln_Select = True
  1499.                 Dbl_YfSelect = Dbl_YfSelect + Val(.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
  1500.             End If
  1501.         Next Jsqte
  1502.     End With
  1503.     
  1504.     If Not Bln_Select Then
  1505.         Tsxx = "请先选中核销记录!"
  1506.         Call Xtxxts(Tsxx, 0, 4)
  1507.         Exit Function
  1508.     End If
  1509.     
  1510.     If Abs(Dbl_YsSelect - Dbl_YfSelect) >= 0.001 Then
  1511.         Tsxx = "核销金额不平衡,不能进行核销!"
  1512.         Call Xtxxts(Tsxx, 0, 4)
  1513.         Exit Function
  1514.     End If
  1515.     
  1516.     '开始进行核销
  1517.     
  1518.     On Error GoTo Swcwcl
  1519.     
  1520.     Cw_DataEnvi.DataConnect.BeginTrans
  1521.     
  1522.      '生成应付冲应收单据ID和单据编号
  1523.     Lng_BillID = CreatBillID("0306")
  1524.     Str_BillCode = CreatBillCode("0306", True)
  1525.     
  1526.     '取最大核销过程序号
  1527.     Sqlstr = "Select Max(CancelNo) as MaxCancelNo From RP_Cancel Where RpFlag='AP'"
  1528.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1529.     
  1530.     If Not IsNull(RecTemp.Fields("MaxCancelNo")) Then
  1531.         Lng_CancelNo = RecTemp.Fields("MaxCancelNo") + 1
  1532.     Else
  1533.         Lng_CancelNo = 1
  1534.     End If
  1535.     
  1536.     '1.核销应付明细帐
  1537.     With CxbbGrid
  1538.         For Jsqte = .FixedRows To .Rows - 1
  1539.             If .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True Then
  1540.                 With Rec_AccList
  1541.                     If Rec_AccList.State = 1 Then .Close
  1542.                     
  1543.                     Sqlstr = "Select RP_Acclist.* From RP_AccList" & _
  1544.                     " Where AcclistID = " & Val(CxbbGrid.TextMatrix(Jsqte, 0))
  1545.                     
  1546.                     Rec_AccList.Open Sqlstr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1547.                     
  1548.                     Sqlstr = "Select Gy_ForeignCurrency.ConVertFlag From Gy_ForeignCurrency Where Gy_ForeignCurrency.ForeignCurrCode='" & Trim(.Fields("ForeignCurrCode")) & "'"
  1549.                     
  1550.                     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1551.                     
  1552.                     If RecTemp.Fields("ConVertFlag") Then
  1553.                         Bln_ConVertFlag = True
  1554.                     Else
  1555.                         Bln_ConVertFlag = False
  1556.                     End If
  1557.                     
  1558.                     If Bln_Foreign Then
  1559.                         
  1560.                         '按原币核销
  1561.                         .Fields("YbCancelje") = .Fields("YbCancelje") + Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1562.                         Dbl_CWbje = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1563.                         
  1564.                         If Not Bln_ConVertFlag Then
  1565.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1566.                             Dbl_CBbje = Format(Dbl_CWbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1567.                         Else
  1568.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1569.                             Dbl_CBbje = Format(Dbl_CWbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1570.                         End If
  1571.                         
  1572.                         If .Fields("YbCancelje") = .Fields("YbYsje") Then
  1573.                             .Fields("OverStatus") = 1
  1574.                         End If
  1575.                         
  1576.                     Else
  1577.                         
  1578.                         '按本币核销
  1579.                         .Fields("BbCancelje") = .Fields("BbCancelje") + Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1580.                         Dbl_CBbje = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1581.                         If Bln_ConVertFlag Then
  1582.                             .Fields("YbCancelje") = Format(.Fields("BbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1583.                             Dbl_CWbje = Format(Dbl_CBbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1584.                         Else
  1585.                             .Fields("BbCancelje") = Format(.Fields("BbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1586.                             Dbl_CWbje = Format(Dbl_CBbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1587.                         End If
  1588.                         
  1589.                         If .Fields("BbCancelje") = .Fields("BbYsje") Then
  1590.                             .Fields("OverStatus") = 1
  1591.                         End If
  1592.                     End If
  1593.                     
  1594.                     .Update
  1595.                     
  1596.                     If Rec_Cancel.State = 1 Then Rec_Cancel.Close
  1597.                     Rec_Cancel.Open "Select * From RP_Cancel Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1598.                     Rec_Cancel.AddNew
  1599.                     
  1600.                     Rec_Cancel.Fields("RPFlag") = "AP"                                '应收/应付帐标识
  1601.                     Rec_Cancel.Fields("CancelItemCode") = "A2"                        '核销处理过程编码(A2:应付冲应收)
  1602.                     Rec_Cancel.Fields("SupplierCode") = Str_SupplierCode              '往来供应商编码
  1603.                     Rec_Cancel.Fields("CancelNo") = Lng_CancelNo                      '核销过程序号
  1604.                     Rec_Cancel.Fields("CancelDate") = Xtrq                            '核销日期
  1605.                     Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode")       '单据类型编码
  1606.                     Rec_Cancel.Fields("BillID") = .Fields("BillID")                   '单据ID
  1607.                     Rec_Cancel.Fields("BillCode") = .Fields("BillCode")               '单据编号
  1608.                     Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
  1609.                     Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0             '记帐汇率
  1610.                     Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje                       '原币核销金额
  1611.                     Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje                       '本币核销金额
  1612.                     Rec_Cancel.Fields("Ybye") = .Fields("YbYsje") - .Fields("YbCancelje")  '原币剩余金额
  1613.                     Rec_Cancel.Fields("Bbye") = .Fields("BbYsje") - .Fields("BbCancelje")  '本币剩余金额
  1614.                     Rec_Cancel.Fields("Canceler") = Xtczy
  1615.                     Rec_Cancel.Update
  1616.                     
  1617.                     Lng_CancelId = Rec_Cancel.Fields("CancelId")                      '记录核销记录ID
  1618.                     
  1619.                     '如果为采购发票,则填写回款金额
  1620.                     If Trim(.Fields("BillItemCode")) = "70" Or Trim(.Fields("BillItemCode")) = "71" Then
  1621.                         Sqlstr = "Update Cg_InvoiceMain SET CwComingValue=CwComingValue+" & Dbl_CBbje & ",CwComingValueFor=CwComingValueFor+" & Dbl_CWbje & " Where InvoiceMainID=" & .Fields("BillId")
  1622.                         Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1623.                     End If
  1624.                     
  1625.                 End With
  1626.                 
  1627.                  '在应收/应付明细帐中加入付款明细帐,同时进行自动核销
  1628.                 With Rec_AccList1
  1629.                     If .State = 1 Then .Close
  1630.                     .Open "Select * From RP_AccList Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1631.                     .AddNew
  1632.                         .Fields("RPFlag") = Rec_AccList.Fields("RPFlag")                       '应收应付标识
  1633.                         .Fields("PSCode") = Rec_AccList.Fields("PSCode")                       '往来单位编码
  1634.                         .Fields("KJYear") = Int_Dqyear                                         '会计年度
  1635.                         .Fields("Period") = Int_DqPeriod                                       '会计期间
  1636.                         .Fields("BillItemCode") = "A2"                                         '单据类型(应付冲应收)
  1637.                         .Fields("BillID") = Lng_BillID                                         '单据ID
  1638.                         .Fields("BillCode") = Str_BillCode                                     '单据编码
  1639.                         .Fields("BillDate") = Xtrq                                             '单据日期
  1640.                         .Fields("BbSsje") = Dbl_CBbje                                          '收回/付款本币金额
  1641.                         .Fields("ForeignCurrCode") = Rec_AccList.Fields("ForeignCurrCode")     '原币编码
  1642.                         .Fields("AccRate") = Rec_AccList.Fields("AccRate") + 0                 '记帐汇率
  1643.                         .Fields("YbSsje") = Dbl_CWbje                                          '原币收回/付款金额
  1644.                         .Fields("AccCode") = Rec_AccList.Fields("AccCode")                     '单据科目编码
  1645.                         .Fields("AccCodeArAp") = Rec_AccList.Fields("AccCodeArAp")             '应收科目编码
  1646.                         .Fields("DeptCode") = Rec_AccList.Fields("DeptCode")                   '部门
  1647.                         .Fields("PersonCode") = Rec_AccList.Fields("PersonCode")               '经办人
  1648.                         .Fields("Digest") = "应付冲应收"                                       '摘要
  1649.                         .Fields("Maker") = Xtczy                                               '制单人
  1650.                         .Fields("Checker") = Xtczy                                             '审核人
  1651.                         
  1652.                         '自动核销
  1653.                         .Fields("YbCancelje") = Dbl_CWbje                                      '原币核销金额
  1654.                         .Fields("BbCancelje") = Dbl_CBbje                                      '本币核销金额
  1655.                         .Fields("OverStatus") = 1                                              '核销完毕
  1656.                     
  1657.                     .Update
  1658.                     
  1659.                     '记录新生成明细帐ID,以在生成凭证时回写凭证号
  1660.                     Sqlstr = "Update Rp_Cancel Set YFId=" & .Fields("AccListId") & "  Where CancelID=" & Lng_CancelId
  1661.                     Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1662.                     
  1663.                  End With
  1664.                  
  1665.                  '登记应收/应付总帐
  1666.                  
  1667.                  Str_PSCode = Trim(Rec_AccList.Fields("PSCode") & "")
  1668.                  Str_DeptCode = Trim(Rec_AccList.Fields("DeptCode") & "")
  1669.                  Str_PersonCode = Trim(Rec_AccList.Fields("PersonCode") & "")
  1670.                  Str_ForeignCurrCode = Trim(Rec_AccList.Fields("ForeignCurrCode") & "")
  1671.                  
  1672.                  With Rec_AccSum
  1673.                      If .State = 1 Then .Close
  1674.                     .Open "Select * From RP_AccSum Where RpFlag='" & Trim(Rec_AccList.Fields("RPFlag")) & "' And PSCode='" & Str_PSCode & _
  1675.                     "' And DeptCode='" & Str_DeptCode & "' And PersonCode='" & Str_PersonCode & "' And ForeignCurrCode='" & Str_ForeignCurrCode & "' And kjYear=" & Int_Dqyear & " And Period=" & Int_DqPeriod, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1676.                     
  1677.                     If Not Rec_AccSum.EOF Then
  1678.                        .Fields("YbSsje") = .Fields("YbSsje") + Dbl_CWbje                                      '本期收回/付款原币金额
  1679.                        .Fields("YbQmye") = .Fields("YbQcye") + .Fields("YbYsje") - .Fields("YbSsje")          '本期期末原币余额
  1680.                        .Fields("BbSsje") = .Fields("BbSsje") + Dbl_CBbje                                      '本期收回/付款本币金额
  1681.                        .Fields("BbQmye") = .Fields("BbQcye") + .Fields("BbYsje") - .Fields("BbSsje")          '本期期末本币余额
  1682.                        .Update
  1683.                     Else
  1684.                        .AddNew
  1685.                        .Fields("RPFlag") = Rec_AccList.Fields("RPFlag")                                       '应收应付标识
  1686.                        .Fields("PSCode") = Str_PSCode                                                         '往来单位编码
  1687.                        .Fields("DeptCode") = Str_DeptCode                                                     '部门编码
  1688.                        .Fields("PersonCode") = Str_PersonCode                                                 '个人编码
  1689.                        .Fields("ForeignCurrCode") = Str_ForeignCurrCode                                       '原币编码
  1690.                        .Fields("KJYear") = Int_Dqyear                                                         '会计年度
  1691.                        .Fields("Period") = Int_DqPeriod                                                       '会计期间
  1692.                        .Fields("YbSsje") = Dbl_CWbje                                                          '本期收回/付款原币金额
  1693.                        .Fields("YbQmye") = -Dbl_CWbje                                                         '本期期末原币余额
  1694.                        .Fields("BbSsje") = Dbl_CBbje                                                          '本期收回/付款本币金额
  1695.                        .Fields("BbQmye") = -Dbl_CBbje                                                         '本期期末本币余额
  1696.                        .Update
  1697.                 
  1698.                      End If
  1699.                 End With
  1700.             End If
  1701.         Next Jsqte
  1702.     End With
  1703.     
  1704.     '1.核销应收明细帐
  1705.     With CxbbGrid1
  1706.         For Jsqte = .FixedRows To .Rows - 1
  1707.             If .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True Then
  1708.                 With Rec_AccList
  1709.                     If Rec_AccList.State = 1 Then .Close
  1710.                     
  1711.                     Sqlstr = "Select RP_Acclist.* From RP_AccList" & _
  1712.                     " Where AcclistID = " & Val(CxbbGrid1.TextMatrix(Jsqte, 0))
  1713.                     
  1714.                     Rec_AccList.Open Sqlstr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1715.                     
  1716.                     Sqlstr = "Select Gy_ForeignCurrency.ConVertFlag From Gy_ForeignCurrency Where Gy_ForeignCurrency.ForeignCurrCode='" & Trim(.Fields("ForeignCurrCode")) & "'"
  1717.                     
  1718.                     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1719.                     
  1720.                     If RecTemp.Fields("ConVertFlag") Then
  1721.                         Bln_ConVertFlag = True
  1722.                     Else
  1723.                         Bln_ConVertFlag = False
  1724.                     End If
  1725.                     
  1726.                     If Bln_Foreign Then
  1727.                         
  1728.                         '按原币核销
  1729.                         .Fields("YbCancelje") = .Fields("YbCancelje") + Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1730.                         Dbl_CWbje = Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1731.                         
  1732.                         If Not Bln_ConVertFlag Then
  1733.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1734.                             Dbl_CBbje = Format(Dbl_CWbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1735.                         Else
  1736.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1737.                             Dbl_CBbje = Format(Dbl_CWbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1738.                         End If
  1739.                         
  1740.                         If .Fields("YbCancelje") = .Fields("YbYsje") Then
  1741.                             .Fields("OverStatus") = 1
  1742.                         End If
  1743.                         
  1744.                     Else
  1745.                         
  1746.                         '按本币核销
  1747.                         .Fields("BbCancelje") = .Fields("BbCancelje") + Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1748.                         Dbl_CBbje = Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
  1749.                         If Bln_ConVertFlag Then
  1750.                             .Fields("YbCancelje") = Format(.Fields("BbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1751.                             Dbl_CWbje = Format(Dbl_CBbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1752.                         Else
  1753.                             .Fields("BbCancelje") = Format(.Fields("BbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1754.                             Dbl_CWbje = Format(Dbl_CBbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1755.                         End If
  1756.                         
  1757.                         If .Fields("BbCancelje") = .Fields("BbYsje") Then
  1758.                             .Fields("OverStatus") = 1
  1759.                         End If
  1760.                     End If
  1761.                     
  1762.                     .Update
  1763.                     
  1764.                     If Rec_Cancel.State = 1 Then Rec_Cancel.Close
  1765.                     Rec_Cancel.Open "Select * From RP_Cancel Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1766.                     Rec_Cancel.AddNew
  1767.                     
  1768.                     Rec_Cancel.Fields("RPFlag") = "AP"                                '应收/应付帐标识
  1769.                     Rec_Cancel.Fields("CancelItemCode") = "A2"                        '核销处理过程编码(A2:应付冲应收)
  1770.                     Rec_Cancel.Fields("CusCode") = Str_CusCode                        '往来客户编码
  1771.                     Rec_Cancel.Fields("CancelNo") = Lng_CancelNo                      '核销过程序号
  1772.                     Rec_Cancel.Fields("CancelDate") = Xtrq                            '核销日期
  1773.                     Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode")       '单据类型编码
  1774.                     Rec_Cancel.Fields("BillID") = .Fields("BillID")                   '单据ID
  1775.                     Rec_Cancel.Fields("BillCode") = .Fields("BillCode")               '单据编号
  1776.                     Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
  1777.                     Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0             '记帐汇率
  1778.                     Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje                       '原币核销金额
  1779.                     Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje                       '本币核销金额
  1780.                     Rec_Cancel.Fields("Ybye") = .Fields("YbYsje") - .Fields("YbCancelje")  '原币剩余金额
  1781.                     Rec_Cancel.Fields("Bbye") = .Fields("BbYsje") - .Fields("BbCancelje")  '本币剩余金额
  1782.                     Rec_Cancel.Fields("Canceler") = Xtczy
  1783.                     Rec_Cancel.Update
  1784.                     
  1785.                     Lng_CancelId = Rec_Cancel.Fields("CancelId")                      '记录核销记录ID
  1786.                     
  1787.                     '如果为销售发票,则填写回款金额
  1788.                     If Trim(.Fields("BillItemCode")) = "10" Or Trim(.Fields("BillItemCode")) = "11" Then
  1789.                         Sqlstr = "Update XS_InvoiceBillMain SET ComingValue=ComingValue+" & Dbl_CBbje & ",ComingValueFor=ComingValueFor+" & Dbl_CWbje & " Where InvoiceBillMainID=" & .Fields("BillId")
  1790.                         Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1791.                     End If
  1792.                     
  1793.                 End With
  1794.                 
  1795.                 '在应收/应付明细帐中加入收款明细帐,同时进行自动核销
  1796.                 With Rec_AccList1
  1797.                     If .State = 1 Then .Close
  1798.                     .Open "Select * From RP_AccList Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1799.                     .AddNew
  1800.                         .Fields("RPFlag") = Rec_AccList.Fields("RPFlag")                       '应收应付标识
  1801.                         .Fields("PSCode") = Rec_AccList.Fields("PSCode")                       '往来单位编码
  1802.                         .Fields("KJYear") = Int_Dqyear                                         '会计年度
  1803.                         .Fields("Period") = Int_DqPeriod                                       '会计期间
  1804.                         .Fields("BillItemCode") = "A2"                                         '单据类型(应付冲应收)
  1805.                         .Fields("BillID") = Lng_BillID                                         '单据ID
  1806.                         .Fields("BillCode") = Str_BillCode                                     '单据编码
  1807.                         .Fields("BillDate") = Xtrq                                             '单据日期
  1808.                         .Fields("BbSsje") = Dbl_CBbje                                          '收回/付款本币金额
  1809.                         .Fields("ForeignCurrCode") = Rec_AccList.Fields("ForeignCurrCode")     '原币编码
  1810.                         .Fields("AccRate") = Rec_AccList.Fields("AccRate") + 0                 '记帐汇率
  1811.                         .Fields("YbSsje") = Dbl_CWbje                                          '原币收回/付款金额
  1812.                         .Fields("AccCode") = Rec_AccList.Fields("AccCode")                     '单据科目编码
  1813.                         .Fields("AccCodeArAp") = Rec_AccList.Fields("AccCodeArAp")             '应收科目编码
  1814.                         .Fields("DeptCode") = Rec_AccList.Fields("DeptCode")                   '部门
  1815.                         .Fields("PersonCode") = Rec_AccList.Fields("PersonCode")               '经办人
  1816.                         .Fields("Digest") = "应付冲应收"                                       '摘要
  1817.                         .Fields("Maker") = Xtczy                                               '制单人
  1818.                         .Fields("Checker") = Xtczy                                             '审核人
  1819.                         
  1820.                         '自动核销
  1821.                         .Fields("YbCancelje") = Dbl_CWbje                                      '原币核销金额
  1822.                         .Fields("BbCancelje") = Dbl_CBbje                                      '本币核销金额
  1823.                         .Fields("OverStatus") = 1                                              '核销完毕
  1824.                         
  1825.                     .Update
  1826.                     
  1827.                     '记录新生成明细帐ID,以在生成凭证时回写凭证号
  1828.                     Sqlstr = "Update Rp_Cancel Set YFId=" & .Fields("AccListId") & "  Where CancelID=" & Lng_CancelId
  1829.                     Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1830.                     
  1831.                  End With
  1832.                  
  1833.                  '登记应收/应付总帐
  1834.                  
  1835.                  Str_PSCode = Trim(Rec_AccList.Fields("PSCode") & "")
  1836.                  Str_DeptCode = Trim(Rec_AccList.Fields("DeptCode") & "")
  1837.                  Str_PersonCode = Trim(Rec_AccList.Fields("PersonCode") & "")
  1838.                  Str_ForeignCurrCode = Trim(Rec_AccList.Fields("ForeignCurrCode") & "")
  1839.                  
  1840.                  With Rec_AccSum
  1841.                      If .State = 1 Then .Close
  1842.                     .Open "Select * From RP_AccSum Where RpFlag='" & Trim(Rec_AccList.Fields("RPFlag")) & "' And PSCode='" & Str_PSCode & _
  1843.                     "' And DeptCode='" & Str_DeptCode & "' And PersonCode='" & Str_PersonCode & "' And ForeignCurrCode='" & Str_ForeignCurrCode & "' And kjYear=" & Int_Dqyear & " And Period=" & Int_DqPeriod, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1844.                     
  1845.                     If Not Rec_AccSum.EOF Then
  1846.                        .Fields("YbSsje") = .Fields("YbSsje") + Dbl_CWbje                                      '本期收回/付款原币金额
  1847.                        .Fields("YbQmye") = .Fields("YbQcye") + .Fields("YbYsje") - .Fields("YbSsje")          '本期期末原币余额
  1848.                        .Fields("BbSsje") = .Fields("BbSsje") + Dbl_CBbje                                      '本期收回/付款本币金额
  1849.                        .Fields("BbQmye") = .Fields("BbQcye") + .Fields("BbYsje") - .Fields("BbSsje")          '本期期末本币余额
  1850.                        .Update
  1851.                     Else
  1852.                        .AddNew
  1853.                        .Fields("RPFlag") = Rec_AccList.Fields("RPFlag")                                       '应收应付标识
  1854.                        .Fields("PSCode") = Str_PSCode                                                         '往来单位编码
  1855.                        .Fields("DeptCode") = Str_DeptCode                                                     '部门编码
  1856.                        .Fields("PersonCode") = Str_PersonCode                                                 '个人编码
  1857.                        .Fields("ForeignCurrCode") = Str_ForeignCurrCode                                       '原币编码
  1858.                        .Fields("KJYear") = Int_Dqyear                                                         '会计年度
  1859.                        .Fields("Period") = Int_DqPeriod                                                       '会计期间
  1860.                        .Fields("YbSsje") = Dbl_CWbje                                                          '本期收回/付款原币金额
  1861.                        .Fields("YbQmye") = -Dbl_CWbje                                                         '本期期末原币余额
  1862.                        .Fields("BbSsje") = Dbl_CBbje                                                          '本期收回/付款本币金额
  1863.                        .Fields("BbQmye") = -Dbl_CBbje                                                         '本期期末本币余额
  1864.                        .Update
  1865.                 
  1866.                      End If
  1867.                 End With
  1868.                 
  1869.                 
  1870.             End If
  1871.         Next Jsqte
  1872.     End With
  1873.     
  1874.     Cw_DataEnvi.DataConnect.CommitTrans
  1875.     
  1876.     Fun_YsCYf = True
  1877.     
  1878.     Exit Function
  1879. Swcwcl:
  1880.     Cw_DataEnvi.DataConnect.RollbackTrans
  1881.     Tsxx = "核销过程中出现未知错误,程序自动恢复核销前状态!"
  1882.     Call Xtxxts(Tsxx, 0, 1)
  1883.     Exit Function
  1884. End Function