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

企业管理

开发平台:

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   =   20501
  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/20
  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_CusCode = Trim(.LrText(0).Tag)
  628.                 Else
  629.                     Str_CusCode = ""
  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 Ar_V_AccMxList " & Str_QueryCondi & " And RpFlag='AR' 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 AR_V_AccMxList " & Str_QueryCondi & " And RpFlag='AR' And (AR_V_AccMxList.BillItemCode='30' OR AR_V_AccMxList.BillItemCode='32') And AR_V_AccMxList.OverStatus=0 " & " ORDER BY KJYear,Period,BillDate,AccListId"
  735.     Else
  736.         '生成预收款查询结果
  737.         Sqlstr = "SELECT * From AR_V_AccMxList " & Str_QueryCondi & " And RpFlag='AR' And (AR_V_AccMxList.BillItemCode='31' OR AR_V_AccMxList.BillItemCode='32') And AR_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_SupplierCode = Trim(.LrText(3).Tag)
  816.                 Else
  817.                     Str_SupplierCode = ""
  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='AP' 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
  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='AR'"
  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("AccListId") = .Fields("AccListId")             '应收/应付明细帐ID
  1296.                     Rec_Cancel.Fields("RPFlag") = "AR"                                '应收/应付帐标识
  1297.                     If Int_Hxlx = 0 Then
  1298.                         Rec_Cancel.Fields("CancelItemCode") = "50"                    '核销处理过程编码(50:到款结算)
  1299.                     Else
  1300.                         Rec_Cancel.Fields("CancelItemCode") = "51"                    '核销处理过程编码(51:预收款冲应收款)
  1301.                     End If
  1302.                     Rec_Cancel.Fields("CusCode") = Str_CusCode                        '往来客户编码
  1303.                     Rec_Cancel.Fields("CancelNo") = Lng_CancelNo                      '核销过程序号
  1304.                     Rec_Cancel.Fields("CancelDate") = Xtrq                            '核销日期
  1305.                     Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode")       '单据类型编码
  1306.                     Rec_Cancel.Fields("BillID") = .Fields("BillID")                   '单据ID
  1307.                     Rec_Cancel.Fields("BillCode") = .Fields("BillCode")               '单据编号
  1308.                     Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
  1309.                     Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0             '记帐汇率
  1310.                     Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje                       '原币核销金额
  1311.                     Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje                       '本币核销金额
  1312.                     Rec_Cancel.Fields("Ybye") = .Fields("YbYsje") - .Fields("YbCancelje")  '原币剩余金额
  1313.                     Rec_Cancel.Fields("Bbye") = .Fields("BbYsje") - .Fields("BbCancelje")  '本币剩余金额
  1314.                     Rec_Cancel.Fields("Canceler") = Xtczy
  1315.                     Rec_Cancel.Update
  1316.                     
  1317.                     '如果为销售发票,则填写回款金额
  1318.                     If Trim(.Fields("BillItemCode")) = "10" Or Trim(.Fields("BillItemCode")) = "11" Then
  1319.                         Sqlstr = "Update XS_InvoiceBillMain SET ComingValue=ComingValue+" & Dbl_CBbje & ",ComingValueFor=ComingValueFor+" & Dbl_CWbje & " Where InvoiceBillMainID=" & .Fields("BillId")
  1320.                         Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1321.                     End If
  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("AccListId") = .Fields("AccListId")             '应收/应付明细帐ID
  1395.                     Rec_Cancel.Fields("RPFlag") = "AR"                                '应收/应付帐标识
  1396.                     If Int_Hxlx = 0 Then
  1397.                         Rec_Cancel.Fields("CancelItemCode") = "50"                     '核销处理过程编码(50:到款结算)
  1398.                     Else
  1399.                         Rec_Cancel.Fields("CancelItemCode") = "51"                     '核销处理过程编码(51:预收款冲应收款)
  1400.                     End If
  1401.                     Rec_Cancel.Fields("CusCode") = Str_CusCode                         '往来客户编码
  1402.                     Rec_Cancel.Fields("CancelNo") = Lng_CancelNo                      '核销过程序号
  1403.                     Rec_Cancel.Fields("CancelDate") = Xtrq                            '核销日期
  1404.                     Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode")       '单据类型编码
  1405.                     Rec_Cancel.Fields("BillID") = .Fields("BillID")                   '单据ID
  1406.                     Rec_Cancel.Fields("BillCode") = .Fields("BillCode")               '单据编号
  1407.                     Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
  1408.                     Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0             '记帐汇率
  1409.                     Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje                       '原币核销金额
  1410.                     Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje                       '本币核销金额
  1411.                     Rec_Cancel.Fields("YbYe") = .Fields("YbSsje") - .Fields("YbCancelje")  '原币剩余金额
  1412.                     Rec_Cancel.Fields("BbYe") = .Fields("BbSsje") - .Fields("BbCancelje")  '本币剩余金额
  1413.                     Rec_Cancel.Fields("Canceler") = Xtczy
  1414.                     
  1415.                     Rec_Cancel.Update
  1416.                 End With
  1417.             End If
  1418.         Next jsqte
  1419.     End With
  1420.     
  1421.     Cw_DataEnvi.DataConnect.CommitTrans
  1422.     
  1423.     Fun_Dkjs = True
  1424.     
  1425.     Exit Function
  1426. Swcwcl:
  1427.     Cw_DataEnvi.DataConnect.RollbackTrans
  1428.     Tsxx = "核销过程中出现未知错误,程序自动恢复核销前状态!"
  1429.     Call Xtxxts(Tsxx, 0, 1)
  1430.     Exit Function
  1431. End Function
  1432. Private Function Fun_YsCYf() As Boolean                                  '应收冲应付
  1433.     
  1434.     Dim Rec_AccList As New ADODB.Recordset        '应收/应付明细帐
  1435.     Dim Rec_AccList1 As New ADODB.Recordset       '应收/应付明细帐1
  1436.     Dim Rec_Cancel As New ADODB.Recordset         '应收/应付核销情况表
  1437.     Dim RecTemp As New ADODB.Recordset            '临时动态集
  1438.     Dim Rec_AccSum As New ADODB.Recordset         '应收应付总帐动态集
  1439.     Dim Dbl_YsSelect As Double                    '选中应收帐款记录核销金额合计
  1440.     Dim Dbl_YfSelect As Double                    '选中应付帐款记录核销金额合计
  1441.     Dim jsqte As Long                             '临时计数器
  1442.     Dim Bln_Select As Boolean                     '是否选中核销单据
  1443.     Dim Sqlstr As String                          '查询连接串
  1444.     Dim Bln_ConVertFlag As Boolean                '折算方式
  1445.     Dim Lng_CancelNo As Long                      '核销过程序号
  1446.     Dim Dbl_CWbje As Double                       '核销原币金额
  1447.     Dim Dbl_CBbje As Double                       '核销本币金额
  1448.     Dim Int_Dqyear As Integer                     '用户选择会计年度
  1449.     Dim Int_DqPeriod As Integer                   '用户选择会计期间
  1450.     
  1451.     Dim Lng_BillID As Long                        '单据ID
  1452.     Dim Str_BillCode As String                    '单据编码
  1453.     Dim Lng_CancelId As Long                      '临时使用核销ID
  1454.     
  1455.     '因为应收冲应付直接生成明细帐,所以业务操作日期必须在当前会计期间内
  1456.     '判断用户所选业务日期与当前会计期间是否一致
  1457.     Sqlstr = "Select Top 1 * FROM Gy_Kjrlb Where ArJzbz=0 Order By Kjyear,Period"
  1458.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1459.     With RecTemp
  1460.         If Not .EOF Then
  1461.            If Not (Xtrq >= .Fields("Qsrq") And Xtrq <= .Fields("Zzrq")) Then
  1462.               Tsxx = "业务日期应在当前会计期间范围内!"
  1463.               Call Xtxxts(Tsxx, 0, 4)
  1464.               Exit Function
  1465.            Else
  1466.               Int_Dqyear = .Fields("Kjyear")
  1467.               Int_DqPeriod = .Fields("Period")
  1468.            End If
  1469.         Else
  1470.            Tsxx = "所有会计期间已结帐完毕!"
  1471.            Call Xtxxts(Tsxx, 0, 4)
  1472.            Exit Function
  1473.         End If
  1474.     End With
  1475.     
  1476.     Bln_Select = False
  1477.     
  1478.     '让录入充分完成
  1479.     CxbbGrid.Col = 0
  1480.     CxbbGrid1.Col = 0
  1481.     
  1482.     '初始化合计值
  1483.     Dbl_YsSelect = 0
  1484.     Dbl_YfSelect = 0
  1485.     
  1486.     '先判断用户输入核销金额是否平衡
  1487.     With CxbbGrid
  1488.         For jsqte = .FixedRows To .Rows - 1
  1489.             If .TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = True Then
  1490.                 Bln_Select = True
  1491.                 Dbl_YsSelect = Dbl_YsSelect + Val(.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)))
  1492.             End If
  1493.         Next jsqte
  1494.     End With
  1495.     
  1496.     With CxbbGrid1
  1497.         For jsqte = .FixedRows To .Rows - 1
  1498.             If .TextMatrix(jsqte, Sydz("002", GridStr1(), Szzls1)) = True Then
  1499.                 Bln_Select = True
  1500.                 Dbl_YfSelect = Dbl_YfSelect + Val(.TextMatrix(jsqte, Sydz("008", GridStr1(), Szzls1)))
  1501.             End If
  1502.         Next jsqte
  1503.     End With
  1504.     
  1505.     If Not Bln_Select Then
  1506.         Tsxx = "请先选中核销记录!"
  1507.         Call Xtxxts(Tsxx, 0, 4)
  1508.         Exit Function
  1509.     End If
  1510.     
  1511.     If Abs(Dbl_YsSelect - Dbl_YfSelect) >= 0.001 Then
  1512.         Tsxx = "核销金额不平衡,不能进行核销!"
  1513.         Call Xtxxts(Tsxx, 0, 4)
  1514.         Exit Function
  1515.     End If
  1516.     
  1517.     '开始进行核销
  1518.     
  1519.     On Error GoTo Swcwcl
  1520.     
  1521.     Cw_DataEnvi.DataConnect.BeginTrans
  1522.     
  1523.     '生成应收冲应付单据ID和单据编号
  1524.     Lng_BillID = CreatBillID("0208")
  1525.     Str_BillCode = CreatBillCode("0208", True)
  1526.     
  1527.     '取最大核销过程序号
  1528.     Sqlstr = "Select Max(CancelNo) as MaxCancelNo From RP_Cancel Where RpFlag='AR'"
  1529.     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1530.     
  1531.     If Not IsNull(RecTemp.Fields("MaxCancelNo")) Then
  1532.         Lng_CancelNo = RecTemp.Fields("MaxCancelNo") + 1
  1533.     Else
  1534.         Lng_CancelNo = 1
  1535.     End If
  1536.     
  1537.     '1.核销应收明细帐
  1538.     With CxbbGrid
  1539.         For jsqte = .FixedRows To .Rows - 1
  1540.             If .TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = True Then
  1541.                 With Rec_AccList
  1542.                     If Rec_AccList.State = 1 Then .Close
  1543.                     
  1544.                     Sqlstr = "Select RP_Acclist.* From RP_AccList" & _
  1545.                     " Where AcclistID = " & Val(CxbbGrid.TextMatrix(jsqte, 0))
  1546.                     
  1547.                     Rec_AccList.Open Sqlstr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1548.                     
  1549.                     Sqlstr = "Select Gy_ForeignCurrency.ConVertFlag From Gy_ForeignCurrency Where Gy_ForeignCurrency.ForeignCurrCode='" & Trim(.Fields("ForeignCurrCode")) & "'"
  1550.                     
  1551.                     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1552.                     
  1553.                     If RecTemp.Fields("ConVertFlag") Then
  1554.                         Bln_ConVertFlag = True
  1555.                     Else
  1556.                         Bln_ConVertFlag = False
  1557.                     End If
  1558.                     
  1559.                     If Bln_Foreign Then
  1560.                         
  1561.                         '按原币核销
  1562.                         .Fields("YbCancelje") = .Fields("YbCancelje") + Val(CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)))
  1563.                         Dbl_CWbje = Val(CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)))
  1564.                         
  1565.                         If Not Bln_ConVertFlag Then
  1566.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1567.                             Dbl_CBbje = Format(Dbl_CWbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1568.                         Else
  1569.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1570.                             Dbl_CBbje = Format(Dbl_CWbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1571.                         End If
  1572.                         
  1573.                         If .Fields("YbCancelje") = .Fields("YbYsje") Then
  1574.                             .Fields("OverStatus") = 1
  1575.                         End If
  1576.                         
  1577.                     Else
  1578.                         
  1579.                         '按本币核销
  1580.                         .Fields("BbCancelje") = .Fields("BbCancelje") + Val(CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)))
  1581.                         Dbl_CBbje = Val(CxbbGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)))
  1582.                         If Bln_ConVertFlag Then
  1583.                             .Fields("YbCancelje") = Format(.Fields("BbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1584.                             Dbl_CWbje = Format(Dbl_CBbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1585.                         Else
  1586.                             .Fields("YbCancelje") = Format(.Fields("BbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1587.                             Dbl_CWbje = Format(Dbl_CBbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1588.                         End If
  1589.                         
  1590.                         If .Fields("BbCancelje") = .Fields("BbYsje") Then
  1591.                             .Fields("OverStatus") = 1
  1592.                         End If
  1593.                     End If
  1594.                     
  1595.                     .Update
  1596.                     
  1597.                     If Rec_Cancel.State = 1 Then Rec_Cancel.Close
  1598.                     Rec_Cancel.Open "Select * From RP_Cancel Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1599.                     Rec_Cancel.AddNew
  1600.                     
  1601.                     Rec_Cancel.Fields("AccListId") = .Fields("AccListId")             '应收/应付明细帐ID
  1602.                     Rec_Cancel.Fields("RPFlag") = "AR"                                '应收/应付帐标识
  1603.                     Rec_Cancel.Fields("CancelItemCode") = "52"                        '核销处理过程编码(52:应收冲应付)
  1604.                     Rec_Cancel.Fields("CusCode") = Str_CusCode                        '往来客户编码
  1605.                     Rec_Cancel.Fields("CancelNo") = Lng_CancelNo                      '核销过程序号
  1606.                     Rec_Cancel.Fields("CancelDate") = Xtrq                            '核销日期
  1607.                     Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode")       '单据类型编码
  1608.                     Rec_Cancel.Fields("BillID") = .Fields("BillID")                   '单据ID
  1609.                     Rec_Cancel.Fields("BillCode") = .Fields("BillCode")               '单据编号
  1610.                     Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
  1611.                     Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0             '记帐汇率
  1612.                     Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje                       '原币核销金额
  1613.                     Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje                       '本币核销金额
  1614.                     Rec_Cancel.Fields("Ybye") = .Fields("YbYsje") - .Fields("YbCancelje")  '原币剩余金额
  1615.                     Rec_Cancel.Fields("Bbye") = .Fields("BbYsje") - .Fields("BbCancelje")  '本币剩余金额
  1616.                     Rec_Cancel.Fields("Canceler") = Xtczy
  1617.                     Rec_Cancel.Update
  1618.                     
  1619.                     Lng_CancelId = Rec_Cancel.Fields("CancelId")                      '记录核销记录ID
  1620.                     
  1621.                     '如果为销售发票,则填写回款金额
  1622.                     If Trim(.Fields("BillItemCode")) = "10" Or Trim(.Fields("BillItemCode")) = "11" Then
  1623.                         Sqlstr = "Update XS_InvoiceBillMain SET ComingValue=ComingValue+" & Dbl_CBbje & ",ComingValueFor=ComingValueFor+" & Dbl_CWbje & " Where InvoiceBillMainID=" & .Fields("BillId")
  1624.                         Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1625.                     End If
  1626.                                         
  1627.                 End With
  1628.                               
  1629.                 '在应收/应付明细帐中加入收款明细帐,同时进行自动核销
  1630.                 With Rec_AccList1
  1631.                     If .State = 1 Then .Close
  1632.                     .Open "Select * From RP_AccList Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1633.                     .AddNew
  1634.                         .Fields("RPFlag") = Rec_AccList.Fields("RPFlag")                       '应收应付标识
  1635.                         .Fields("PSCode") = Rec_AccList.Fields("PSCode")                       '往来单位编码
  1636.                         .Fields("KJYear") = Int_Dqyear                                         '会计年度
  1637.                         .Fields("Period") = Int_DqPeriod                                       '会计期间
  1638.                         .Fields("BillItemCode") = "52"                                         '单据类型(应收冲应付)
  1639.                         .Fields("BillID") = Lng_BillID                                         '单据ID
  1640.                         .Fields("BillCode") = Str_BillCode                                     '单据编码
  1641.                         .Fields("BillDate") = Xtrq                                             '单据日期
  1642.                         .Fields("BbSsje") = Dbl_CBbje                                          '收回/付款本币金额
  1643.                         .Fields("ForeignCurrCode") = Rec_AccList.Fields("ForeignCurrCode")     '原币编码
  1644.                         .Fields("AccRate") = Rec_AccList.Fields("AccRate") + 0                 '记帐汇率
  1645.                         .Fields("YbSsje") = Dbl_CWbje                                          '原币收回/付款金额
  1646.                         .Fields("AccCode") = Rec_AccList.Fields("AccCode")                     '单据科目编码
  1647.                         .Fields("AccCodeArAp") = Rec_AccList.Fields("AccCodeArAp")             '应收科目编码
  1648.                         .Fields("DeptCode") = Rec_AccList.Fields("DeptCode")                   '部门
  1649.                         .Fields("PersonCode") = Rec_AccList.Fields("PersonCode")               '经办人
  1650.                         .Fields("Digest") = "应收冲应付"                                       '摘要
  1651.                         .Fields("Maker") = Xtczy                                               '制单人
  1652.                         .Fields("Checker") = Xtczy                                             '审核人
  1653.                         
  1654.                         '自动核销
  1655.                         .Fields("YbCancelje") = Dbl_CWbje                                      '原币核销金额
  1656.                         .Fields("BbCancelje") = Dbl_CBbje                                      '本币核销金额
  1657.                         .Fields("OverStatus") = 1                                              '核销完毕
  1658.                         
  1659.                     .Update
  1660.                     
  1661.                     '记录新生成明细帐ID,以在生成凭证时回写凭证号
  1662.                     Sqlstr = "Update Rp_Cancel Set YFId=" & .Fields("AccListId") & "  Where CancelID=" & Lng_CancelId
  1663.                     Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1664.                     
  1665.                  End With
  1666.                  
  1667.                  '登记应收/应付总帐
  1668.                  
  1669.                  Str_PSCode = Trim(Rec_AccList.Fields("PSCode") & "")
  1670.                  Str_DeptCode = Trim(Rec_AccList.Fields("DeptCode") & "")
  1671.                  Str_PersonCode = Trim(Rec_AccList.Fields("PersonCode") & "")
  1672.                  Str_ForeignCurrCode = Trim(Rec_AccList.Fields("ForeignCurrCode") & "")
  1673.                  
  1674.                  With Rec_AccSum
  1675.                      If .State = 1 Then .Close
  1676.                     .Open "Select * From RP_AccSum Where RpFlag='" & Trim(Rec_AccList.Fields("RPFlag")) & "' And PSCode='" & Str_PSCode & _
  1677.                     "' 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
  1678.                     
  1679.                     If Not Rec_AccSum.EOF Then
  1680.                        .Fields("YbSsje") = .Fields("YbSsje") + Dbl_CWbje                                      '本期收回/付款原币金额
  1681.                        .Fields("YbQmye") = .Fields("YbQcye") + .Fields("YbYsje") - .Fields("YbSsje")          '本期期末原币余额
  1682.                        .Fields("BbSsje") = .Fields("BbSsje") + Dbl_CBbje                                      '本期收回/付款本币金额
  1683.                        .Fields("BbQmye") = .Fields("BbQcye") + .Fields("BbYsje") - .Fields("BbSsje")          '本期期末本币余额
  1684.                        .Update
  1685.                     Else
  1686.                        .AddNew
  1687.                        .Fields("RPFlag") = Rec_AccList.Fields("RPFlag")                                        '应收应付标识
  1688.                        .Fields("PSCode") = Str_PSCode                                                         '往来单位编码
  1689.                        .Fields("DeptCode") = Str_DeptCode                                                     '部门编码
  1690.                        .Fields("PersonCode") = Str_PersonCode                                                 '个人编码
  1691.                        .Fields("ForeignCurrCode") = Str_ForeignCurrCode                                       '原币编码
  1692.                        .Fields("KJYear") = Int_Dqyear                                                         '会计年度
  1693.                        .Fields("Period") = Int_DqPeriod                                                       '会计期间
  1694.                        .Fields("YbSsje") = Dbl_CWbje                                                          '本期收回/付款原币金额
  1695.                        .Fields("YbQmye") = -Dbl_CWbje                                                         '本期期末原币余额
  1696.                        .Fields("BbSsje") = Dbl_CBbje                                                          '本期收回/付款本币金额
  1697.                        .Fields("BbQmye") = -Dbl_CBbje                                                         '本期期末本币余额
  1698.                        .Update
  1699.                 
  1700.                      End If
  1701.                 End With
  1702.                 
  1703.             End If
  1704.         Next jsqte
  1705.     End With
  1706.     
  1707.     '1.核销应付明细帐
  1708.     With CxbbGrid1
  1709.         For jsqte = .FixedRows To .Rows - 1
  1710.             If .TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = True Then
  1711.                 With Rec_AccList
  1712.                     If Rec_AccList.State = 1 Then .Close
  1713.                     
  1714.                     Sqlstr = "Select RP_Acclist.* From RP_AccList" & _
  1715.                     " Where AcclistID = " & Val(CxbbGrid1.TextMatrix(jsqte, 0))
  1716.                     
  1717.                     Rec_AccList.Open Sqlstr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1718.                     
  1719.                     Sqlstr = "Select Gy_ForeignCurrency.ConVertFlag From Gy_ForeignCurrency Where Gy_ForeignCurrency.ForeignCurrCode='" & Trim(.Fields("ForeignCurrCode")) & "'"
  1720.                     
  1721.                     Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
  1722.                     
  1723.                     If RecTemp.Fields("ConVertFlag") Then
  1724.                         Bln_ConVertFlag = True
  1725.                     Else
  1726.                         Bln_ConVertFlag = False
  1727.                     End If
  1728.                     
  1729.                     If Bln_Foreign Then
  1730.                         
  1731.                         '按原币核销
  1732.                         .Fields("YbCancelje") = .Fields("YbCancelje") + Val(CxbbGrid1.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)))
  1733.                         Dbl_CWbje = Val(CxbbGrid1.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)))
  1734.                         
  1735.                         If Not Bln_ConVertFlag Then
  1736.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1737.                             Dbl_CBbje = Format(Dbl_CWbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1738.                         Else
  1739.                             .Fields("BbCancelje") = Format(.Fields("YbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1740.                             Dbl_CBbje = Format(Dbl_CWbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1741.                         End If
  1742.                         
  1743.                         If .Fields("YbCancelje") = .Fields("YbYsje") Then
  1744.                             .Fields("OverStatus") = 1
  1745.                         End If
  1746.                         
  1747.                     Else
  1748.                         
  1749.                         '按本币核销
  1750.                         .Fields("BbCancelje") = .Fields("BbCancelje") + Val(CxbbGrid1.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)))
  1751.                         Dbl_CBbje = Val(CxbbGrid1.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)))
  1752.                         If Bln_ConVertFlag Then
  1753.                             .Fields("YbCancelje") = Format(.Fields("BbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1754.                             Dbl_CWbje = Format(Dbl_CBbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1755.                         Else
  1756.                             .Fields("YbCancelje") = Format(.Fields("BbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1757.                             Dbl_CWbje = Format(Dbl_CBbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
  1758.                         End If
  1759.                         
  1760.                         If .Fields("BbCancelje") = .Fields("BbYsje") Then
  1761.                             .Fields("OverStatus") = 1
  1762.                         End If
  1763.                     End If
  1764.                     
  1765.                     .Update
  1766.                     
  1767.                     If Rec_Cancel.State = 1 Then Rec_Cancel.Close
  1768.                     Rec_Cancel.Open "Select * From RP_Cancel Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1769.                     Rec_Cancel.AddNew
  1770.                     
  1771.                     Rec_Cancel.Fields("AccListId") = .Fields("AccListId")             '应收/应付明细帐ID
  1772.                     Rec_Cancel.Fields("RPFlag") = "AR"                                '应收/应付帐标识
  1773.                     Rec_Cancel.Fields("CancelItemCode") = "52"                        '核销处理过程编码(52:应收冲应付)
  1774.                     Rec_Cancel.Fields("SupplierCode") = Str_SupplierCode              '往来供应商编码
  1775.                     Rec_Cancel.Fields("CancelNo") = Lng_CancelNo                      '核销过程序号
  1776.                     Rec_Cancel.Fields("CancelDate") = Xtrq                            '核销日期
  1777.                     Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode")       '单据类型编码
  1778.                     Rec_Cancel.Fields("BillID") = .Fields("BillID")                   '单据ID
  1779.                     Rec_Cancel.Fields("BillCode") = .Fields("BillCode")               '单据编号
  1780.                     Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
  1781.                     Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0             '记帐汇率
  1782.                     Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje                       '原币核销金额
  1783.                     Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje                       '本币核销金额
  1784.                     Rec_Cancel.Fields("Ybye") = .Fields("YbYsje") - .Fields("YbCancelje")  '原币剩余金额
  1785.                     Rec_Cancel.Fields("Bbye") = .Fields("BbYsje") - .Fields("BbCancelje")  '本币剩余金额
  1786.                     Rec_Cancel.Fields("Canceler") = Xtczy
  1787.                     Rec_Cancel.Update
  1788.                     
  1789.                     Lng_CancelId = Rec_Cancel.Fields("CancelId")                      '记录核销记录ID
  1790.                     
  1791.                     '如果为采购发票,则填写回款金额
  1792.                     If Trim(.Fields("BillItemCode")) = "70" Or Trim(.Fields("BillItemCode")) = "71" Then
  1793.                         Sqlstr = "Update Cg_InvoiceMain SET CwComingValue=CwComingValue+" & Dbl_CBbje & ",CwComingValueFor=CwComingValueFor+" & Dbl_CWbje & " Where InvoiceMainID=" & .Fields("BillId")
  1794.                         Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1795.                     End If
  1796.                              
  1797.                     
  1798.                 End With
  1799.                 
  1800.                  '在应收/应付明细帐中加入付款明细帐,同时进行自动核销
  1801.                 With Rec_AccList1
  1802.                     If .State = 1 Then .Close
  1803.                     .Open "Select * From RP_AccList Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
  1804.                     .AddNew
  1805.                         .Fields("RPFlag") = Rec_AccList.Fields("RPFlag")                       '应收应付标识
  1806.                         .Fields("PSCode") = Rec_AccList.Fields("PSCode")                       '往来单位编码
  1807.                         .Fields("KJYear") = Int_Dqyear                                         '会计年度
  1808.                         .Fields("Period") = Int_DqPeriod                                       '会计期间
  1809.                         .Fields("BillItemCode") = "52"                                         '单据类型(应收冲应付)
  1810.                         .Fields("BillID") = Lng_BillID                                         '单据ID
  1811.                         .Fields("BillCode") = Str_BillCode                                     '单据编码
  1812.                         .Fields("BillDate") = Xtrq                                             '单据日期
  1813.                         .Fields("BbSsje") = Dbl_CBbje                                          '收回/付款本币金额
  1814.                         .Fields("ForeignCurrCode") = Rec_AccList.Fields("ForeignCurrCode")     '原币编码
  1815.                         .Fields("AccRate") = Rec_AccList.Fields("AccRate") + 0                 '记帐汇率
  1816.                         .Fields("YbSsje") = Dbl_CWbje                                          '原币收回/付款金额
  1817.                         .Fields("AccCode") = Rec_AccList.Fields("AccCode")                     '单据科目编码
  1818.                         .Fields("AccCodeArAp") = Rec_AccList.Fields("AccCodeArAp")             '应收科目编码
  1819.                         .Fields("DeptCode") = Rec_AccList.Fields("DeptCode")                   '部门
  1820.                         .Fields("PersonCode") = Rec_AccList.Fields("PersonCode")               '经办人
  1821.                         .Fields("Digest") = "应收冲应付"                                       '摘要
  1822.                         .Fields("Maker") = Xtczy                                               '制单人
  1823.                         .Fields("Checker") = Xtczy                                             '审核人
  1824.                         
  1825.                         '自动核销
  1826.                         .Fields("YbCancelje") = Dbl_CWbje                                      '原币核销金额
  1827.                         .Fields("BbCancelje") = Dbl_CBbje                                      '本币核销金额
  1828.                         .Fields("OverStatus") = 1                                              '核销完毕
  1829.                     
  1830.                     .Update
  1831.                     
  1832.                     '记录新生成明细帐ID,以在生成凭证时回写凭证号
  1833.                     Sqlstr = "Update Rp_Cancel Set YFId=" & .Fields("AccListId") & "  Where CancelID=" & Lng_CancelId
  1834.                     Cw_DataEnvi.DataConnect.Execute (Sqlstr)
  1835.                     
  1836.                  End With
  1837.                  
  1838.                  '登记应收/应付总帐
  1839.                  
  1840.                  Str_PSCode = Trim(Rec_AccList.Fields("PSCode") & "")
  1841.                  Str_DeptCode = Trim(Rec_AccList.Fields("DeptCode") & "")
  1842.                  Str_PersonCode = Trim(Rec_AccList.Fields("PersonCode") & "")
  1843.                  Str_ForeignCurrCode = Trim(Rec_AccList.Fields("ForeignCurrCode") & "")
  1844.                  
  1845.                  With Rec_AccSum
  1846.                      If .State = 1 Then .Close
  1847.                     .Open "Select * From RP_AccSum Where RpFlag='" & Trim(Rec_AccList.Fields("RPFlag")) & "' And PSCode='" & Str_PSCode & _
  1848.                     "' 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
  1849.                     
  1850.                     If Not Rec_AccSum.EOF Then
  1851.                        .Fields("YbSsje") = .Fields("YbSsje") + Dbl_CWbje                                      '本期收回/付款原币金额
  1852.                        .Fields("YbQmye") = .Fields("YbQcye") + .Fields("YbYsje") - .Fields("YbSsje")          '本期期末原币余额
  1853.                        .Fields("BbSsje") = .Fields("BbSsje") + Dbl_CBbje                                      '本期收回/付款本币金额
  1854.                        .Fields("BbQmye") = .Fields("BbQcye") + .Fields("BbYsje") - .Fields("BbSsje")          '本期期末本币余额
  1855.                        .Update
  1856.                     Else
  1857.                        .AddNew
  1858.                        .Fields("RPFlag") = Rec_AccList.Fields("RPFlag")                                       '应收应付标识
  1859.                        .Fields("PSCode") = Str_PSCode                                                         '往来单位编码
  1860.                        .Fields("DeptCode") = Str_DeptCode                                                     '部门编码
  1861.                        .Fields("PersonCode") = Str_PersonCode                                                 '个人编码
  1862.                        .Fields("ForeignCurrCode") = Str_ForeignCurrCode                                       '原币编码
  1863.                        .Fields("KJYear") = Int_Dqyear                                                         '会计年度
  1864.                        .Fields("Period") = Int_DqPeriod                                                       '会计期间
  1865.                        .Fields("YbSsje") = Dbl_CWbje                                                          '本期收回/付款原币金额
  1866.                        .Fields("YbQmye") = -Dbl_CWbje                                                         '本期期末原币余额
  1867.                        .Fields("BbSsje") = Dbl_CBbje                                                          '本期收回/付款本币金额
  1868.                        .Fields("BbQmye") = -Dbl_CBbje                                                         '本期期末本币余额
  1869.                        .Update
  1870.                 
  1871.                      End If
  1872.                 End With
  1873.                 
  1874.             End If
  1875.         Next jsqte
  1876.     End With
  1877.     
  1878.     Cw_DataEnvi.DataConnect.CommitTrans
  1879.     
  1880.     Fun_YsCYf = True
  1881.     
  1882.     Exit Function
  1883. Swcwcl:
  1884.     Cw_DataEnvi.DataConnect.RollbackTrans
  1885.     Tsxx = "核销过程中出现未知错误,程序自动恢复核销前状态!"
  1886.     Call Xtxxts(Tsxx, 0, 1)
  1887.     Exit Function
  1888. End Function