资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:91k
源码类别:
企业管理
开发平台:
Visual Basic
- VERSION 5.00
- Object = "{BEEECC20-4D5F-4F8B-BFDC-5D9B6FBDE09D}#1.0#0"; "vsflex8.ocx"
- Object = "{831FDD16-0C5C-11D2-A9FC-0000F8754DA1}#2.0#0"; "mscomctl.ocx"
- Begin VB.Form HX_FrmHxgl
- BorderStyle = 1 'Fixed Single
- Caption = "核销管理"
- ClientHeight = 7560
- ClientLeft = 495
- ClientTop = 585
- ClientWidth = 11070
- HelpContextID = 5001
- Icon = "核销处理_单据核销查询结果.frx":0000
- KeyPreview = -1 'True
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 7560
- ScaleWidth = 11070
- StartUpPosition = 1 '所有者中心
- Begin VB.Timer Timer1
- Enabled = 0 'False
- Interval = 1
- Left = 9960
- Top = 120
- End
- Begin VSFlex8Ctl.VSFlexGrid CxbbGrid
- Height = 3405
- Left = 60
- TabIndex = 0
- Top = 600
- Width = 10965
- _cx = 5080
- _cy = 5080
- Appearance = 1
- BorderStyle = 1
- Enabled = -1 'True
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- MousePointer = 0
- BackColor = 16777215
- ForeColor = -2147483640
- BackColorFixed = 13826538
- ForeColorFixed = -2147483630
- BackColorSel = -2147483635
- ForeColorSel = -2147483634
- BackColorBkg = -2147483636
- BackColorAlternate= 16777215
- GridColor = -2147483633
- GridColorFixed = -2147483632
- TreeColor = -2147483632
- FloodColor = 192
- SheetBorder = -2147483642
- FocusRect = 1
- HighLight = 1
- AllowSelection = -1 'True
- AllowBigSelection= -1 'True
- AllowUserResizing= 0
- SelectionMode = 0
- GridLines = 1
- GridLinesFixed = 2
- GridLineWidth = 1
- Rows = 50
- Cols = 10
- FixedRows = 1
- FixedCols = 1
- RowHeightMin = 0
- RowHeightMax = 0
- ColWidthMin = 0
- ColWidthMax = 0
- ExtendLastCol = 0 'False
- FormatString = ""
- ScrollTrack = 0 'False
- ScrollBars = 3
- ScrollTips = 0 'False
- MergeCells = 0
- MergeCompare = 0
- AutoResize = -1 'True
- AutoSizeMode = 0
- AutoSearch = 0
- AutoSearchDelay = 2
- MultiTotals = -1 'True
- SubtotalPosition= 1
- OutlineBar = 0
- OutlineCol = 0
- Ellipsis = 0
- ExplorerBar = 0
- PicturesOver = 0 'False
- FillStyle = 0
- RightToLeft = 0 'False
- PictureType = 0
- TabBehavior = 0
- OwnerDraw = 0
- Editable = 0
- ShowComboButton = 1
- WordWrap = 0 'False
- TextStyle = 0
- TextStyleFixed = 0
- OleDragMode = 0
- OleDropMode = 0
- DataMode = 0
- VirtualData = -1 'True
- DataMember = ""
- ComboSearch = 3
- AutoSizeMouse = -1 'True
- FrozenRows = 0
- FrozenCols = 0
- AllowUserFreezing= 0
- BackColorFrozen = 0
- ForeColorFrozen = 0
- WallPaperAlignment= 9
- AccessibleName = ""
- AccessibleDescription= ""
- AccessibleValue = ""
- AccessibleRole = 24
- End
- Begin VSFlex8Ctl.VSFlexGrid CxbbGrid1
- Height = 3405
- Left = 60
- TabIndex = 1
- Top = 4080
- Width = 10965
- _cx = 5080
- _cy = 5080
- Appearance = 1
- BorderStyle = 1
- Enabled = -1 'True
- BeginProperty Font {0BE35203-8F91-11CE-9DE3-00AA004BB851}
- Name = "宋体"
- Size = 9
- Charset = 134
- Weight = 400
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- MousePointer = 0
- BackColor = 16777215
- ForeColor = -2147483640
- BackColorFixed = 13826538
- ForeColorFixed = -2147483630
- BackColorSel = -2147483635
- ForeColorSel = -2147483634
- BackColorBkg = -2147483636
- BackColorAlternate= 16777215
- GridColor = -2147483633
- GridColorFixed = -2147483632
- TreeColor = -2147483632
- FloodColor = 192
- SheetBorder = -2147483642
- FocusRect = 1
- HighLight = 1
- AllowSelection = -1 'True
- AllowBigSelection= -1 'True
- AllowUserResizing= 0
- SelectionMode = 0
- GridLines = 1
- GridLinesFixed = 2
- GridLineWidth = 1
- Rows = 50
- Cols = 10
- FixedRows = 1
- FixedCols = 1
- RowHeightMin = 0
- RowHeightMax = 0
- ColWidthMin = 0
- ColWidthMax = 0
- ExtendLastCol = 0 'False
- FormatString = ""
- ScrollTrack = 0 'False
- ScrollBars = 3
- ScrollTips = 0 'False
- MergeCells = 0
- MergeCompare = 0
- AutoResize = -1 'True
- AutoSizeMode = 0
- AutoSearch = 0
- AutoSearchDelay = 2
- MultiTotals = -1 'True
- SubtotalPosition= 1
- OutlineBar = 0
- OutlineCol = 0
- Ellipsis = 0
- ExplorerBar = 0
- PicturesOver = 0 'False
- FillStyle = 0
- RightToLeft = 0 'False
- PictureType = 0
- TabBehavior = 0
- OwnerDraw = 0
- Editable = 0
- ShowComboButton = 1
- WordWrap = 0 'False
- TextStyle = 0
- TextStyleFixed = 0
- OleDragMode = 0
- OleDropMode = 0
- DataMode = 0
- VirtualData = -1 'True
- DataMember = ""
- ComboSearch = 3
- AutoSizeMouse = -1 'True
- FrozenRows = 0
- FrozenCols = 0
- AllowUserFreezing= 0
- BackColorFrozen = 0
- ForeColorFrozen = 0
- WallPaperAlignment= 9
- AccessibleName = ""
- AccessibleDescription= ""
- AccessibleValue = ""
- AccessibleRole = 24
- End
- Begin MSComctlLib.Toolbar SzToolbar
- Align = 1 'Align Top
- Height = 555
- Left = 0
- TabIndex = 2
- Top = 0
- Width = 11070
- _ExtentX = 19526
- _ExtentY = 979
- ButtonWidth = 820
- ButtonHeight = 926
- AllowCustomize = 0 'False
- Appearance = 1
- Style = 1
- ImageList = "ImageList2"
- _Version = 393216
- BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
- NumButtons = 10
- BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "全选"
- Key = "qbxz"
- ImageKey = "qx1"
- EndProperty
- BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "全消"
- Key = "qbqx"
- ImageKey = "qx"
- EndProperty
- BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "自动"
- Key = "zd"
- ImageKey = "zd"
- EndProperty
- BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "查询"
- Key = "cx"
- ImageKey = "cx"
- EndProperty
- BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "核销"
- Key = "hx"
- ImageKey = "hx"
- EndProperty
- BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "帮助"
- Key = "bz"
- ImageKey = "bz"
- EndProperty
- BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "退出"
- Key = "fh"
- ImageKey = "tc"
- EndProperty
- EndProperty
- BorderStyle = 1
- Begin MSComctlLib.ImageList ImageList2
- Left = 9000
- Top = 0
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 16
- ImageHeight = 16
- MaskColor = 12632256
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 46
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":1042
- Key = "sz"
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":13DC
- Key = "dy"
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":1776
- Key = "yl"
- EndProperty
- BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":1B10
- Key = "xg"
- EndProperty
- BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":1EAA
- Key = "zh"
- EndProperty
- BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":2244
- Key = "sh"
- EndProperty
- BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":25DE
- Key = "bc"
- EndProperty
- BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":2978
- Key = "fq"
- EndProperty
- BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":2D12
- Key = "bz"
- EndProperty
- BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":30AC
- Key = "tc"
- EndProperty
- BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":3446
- Key = "bcgs"
- EndProperty
- BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":37E0
- Key = "mrlk"
- EndProperty
- BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":3B7A
- Key = "xsxm"
- EndProperty
- BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":3F14
- Key = "first"
- EndProperty
- BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":42AE
- Key = "prev"
- EndProperty
- BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":4648
- Key = "next"
- EndProperty
- BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":49E2
- Key = "last"
- EndProperty
- BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":4D7C
- Key = "xx"
- EndProperty
- BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":5116
- Key = "define"
- EndProperty
- BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":54B0
- Key = "exec"
- EndProperty
- BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":584A
- Key = "xz"
- EndProperty
- BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":5BE4
- Key = "sc"
- EndProperty
- BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":5F7E
- Key = "sx"
- EndProperty
- BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":6318
- Key = "cx"
- EndProperty
- BeginProperty ListImage25 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":66B2
- Key = "zd"
- EndProperty
- BeginProperty ListImage26 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":6A4C
- Key = "dz"
- EndProperty
- BeginProperty ListImage27 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":6DE6
- Key = "ph"
- EndProperty
- BeginProperty ListImage28 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":7180
- Key = "fz"
- EndProperty
- BeginProperty ListImage29 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":751A
- Key = "dw"
- EndProperty
- BeginProperty ListImage30 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":78B4
- Key = "hf"
- EndProperty
- BeginProperty ListImage31 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":7C4E
- Key = "pz"
- EndProperty
- BeginProperty ListImage32 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":7FE8
- Key = "check"
- EndProperty
- BeginProperty ListImage33 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":8382
- Key = "qs"
- EndProperty
- BeginProperty ListImage34 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":871C
- Key = "fullcheck"
- EndProperty
- BeginProperty ListImage35 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":8AB6
- Key = "qq"
- EndProperty
- BeginProperty ListImage36 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":8E50
- Key = "bcw"
- EndProperty
- BeginProperty ListImage37 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":91EA
- Key = "ye"
- EndProperty
- BeginProperty ListImage38 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":9584
- Key = ""
- EndProperty
- BeginProperty ListImage39 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":991E
- Key = "frist"
- EndProperty
- BeginProperty ListImage40 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":9CB8
- Key = "dj"
- EndProperty
- BeginProperty ListImage41 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":A052
- Key = "xj"
- EndProperty
- BeginProperty ListImage42 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":A3EC
- Key = "qx"
- EndProperty
- BeginProperty ListImage43 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":A786
- Key = "qx1"
- EndProperty
- BeginProperty ListImage44 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":AB20
- Key = "gz"
- EndProperty
- BeginProperty ListImage45 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":AEBA
- Key = "js"
- EndProperty
- BeginProperty ListImage46 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "核销处理_单据核销查询结果.frx":B254
- Key = "hx"
- EndProperty
- EndProperty
- End
- End
- End
- Attribute VB_Name = "HX_FrmHxgl"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '***************************************************************************************************
- '* 模 块 名 称 :核销管理
- '* 功 能 描 述 :包括付款结算,预付款冲应付款,应付冲应收三种核销方式
- '* 1.付款结算:用应付明细帐中的付款(未核销)和退款(未核销)与应付款(未核销)进行核销结算
- '* 2.预付款冲应付款:用应付明细帐中的预付款(未核销)与应付款(未核销)进行核销结算
- '* 3.应付冲应收:用应付明细帐中的应付款(未核销)与应收款(未核销)进行核销结算
- '* 程序员姓名 :张建忠
- '* 最后修改人 :张建忠
- '* 最后修改时间:2001/12/28
- '* 备 注:程序中所有依实际情况自定义部分均用[>> <<]括起
- '***************************************************************************************************
- Dim ReportTitle As String '报表主标题
- Dim Str_QueryCondi As String '用户录入查询条件
- Dim Tsxx As String '系统提示信息
- Dim Bln_Foreign As Boolean '按原币核销标识
- Dim Int_Hxlx As Integer '核销类型
- Dim Str_CusCode As String '往来客户编码
- Dim Str_SupplierCode As String '往来供应商编码
- '以下为固定使用变量(网格1)
- Dim GridCode As String '显示网格网格代码
- Dim GridInf() As Variant '整个网格设置信息
- Dim Qslz As Long '网格隐藏(非操作显示)列数
- Dim Sjhgd As Double '网格数据行高度
- Dim GridBoolean() As Boolean '网格列信息(布尔型)
- Dim GridStr() As String '网格列信息(字符型)
- Dim GridInt() As Integer '网格列信息(整型)
- Dim Szzls As Integer '数组总列数(网格列数-1)
- '以下为固定使用变量(网格2)
- Dim GridCode1 As String '显示网格网格代码
- Dim GridInf1() As Variant '整个网格设置信息
- Dim Qslz1 As Long '网格隐藏(非操作显示)列数
- Dim Sjhgd1 As Double '网格数据行高度
- Dim GridBoolean1() As Boolean '网格列信息(布尔型)
- Dim GridStr1() As String '网格列信息(字符型)
- Dim GridInt1() As Integer '网格列信息(整型)
- Dim Szzls1 As Integer '数组总列数(网格列数-1)
- Private Sub Form_Load() '窗体装入
- '调 入 网 格1
- GridCode = "Ar_HxglYsk"
- Call BzWgcsh(CxbbGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
- Qslz = GridInf(1)
- Sjhgd = GridInf(2)
- Szzls = CxbbGrid.Cols - 1
- '调 入 网 格 2
- GridCode1 = "Ar_HxglDk"
- Call BzWgcsh(CxbbGrid1, GridCode1, GridInf1(), GridBoolean1(), GridInt1(), GridStr1())
- Qslz1 = GridInf1(1)
- Sjhgd1 = GridInf1(2)
- Szzls1 = CxbbGrid1.Cols - 1
- '对网格进行特殊设置
- CxbbGrid.Editable = True
- CxbbGrid1.Editable = True
- End Sub
- Private Sub Form_Unload(Cancel As Integer) '窗体卸载
- '卸载条件窗体
- HX_FrmHxCxtj.UnloadCheck.Value = 1
- Unload HX_FrmHxCxtj
- End Sub
- Private Sub SzToolbar_ButtonClick(ByVal Button As MSComctlLib.Button)
- Select Case Button.Key
- Case "qbxz" '全 选
- Call Sub_SelectAll
- Case "qbqx" '全 消
- Call Sub_AbandonAll
- Case "zd" '自 动
- Call Sub_AutoSelect
- Case "cx" '查 询
- HX_FrmHxCxtj.Show 1
- Case "hx" '手工核销
- Call Sub_Sghx
- Case "sx" '刷 新
- Call Timer1_Timer
- Case "bz" '帮 助
- Call F1bz
- Case "fh" '退 出
- Unload Me
- End Select
- End Sub
- Private Sub Timer1_Timer()
- Timer1.Enabled = False
- '加快显示速度
- CxbbGrid.Redraw = False
- '判断用户选择哪种核销
- Call Sub_Query1
- With HX_FrmHxCxtj
- '记录核销类型
- Int_Hxlx = .Combo_Jshxlx.ListIndex
- Select Case .Combo_Jshxlx.ListIndex
- Case 0 '付款结算
- Call Sub_Query2(1)
- Case 1 '预付款冲应付款
- Call Sub_Query2(2)
- Case 2 '应付冲应收款
- Call Sub_Query3
- End Select
- End With
- CxbbGrid.Redraw = True
- End Sub
- Private Sub Sub_Query1() '生成查询结果(应付款)
- Dim Rec_Query As New ADODB.Recordset '查询结果动态集
- Dim Sqlstr As String '查询字符串
- Dim Coljsq As Long '网格列计数器
- Dim Jsqte As Long '临时动态计数器
- Bln_Foreign = False
- '以下为自定义部分[
- With HX_FrmHxCxtj
- Str_QueryCondi = " Where 1=1 "
- For Jsqte = 1 To 4
- Select Case Jsqte
- Case 1 '单据日期范围(起始)
- If Trim(.LrText(1).Text) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " And BillDate>=' " & Trim(.LrText(1).Text) & "'"
- End If
- Case 2 '单据日期范围(终止)
- If Trim(.LrText(2).Text) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " And BillDate<= ' " & Trim(.LrText(2).Text) & "'"
- End If
- Case 3 '往来供应商
- If Trim(.LrText(0).Tag) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " and PSCode = '" & Trim(.LrText(0).Tag) & "'"
- Str_SupplierCode = Trim(.LrText(0).Tag)
- Else
- Str_SupplierCode = ""
- End If
- Case 4 '原币名称
- If GetComboKey(.Imgebo_ForeignCurr, 0) <> "Zhbwb" Then
- Str_QueryCondi = Str_QueryCondi & " and ForeignCurrCode='" & Trim(GetComboKey(.Imgebo_ForeignCurr, 0)) & "'"
- Bln_Foreign = True
- End If
- End Select
- Next Jsqte
- End With
- '生成应付款查询结果
- Sqlstr = "SELECT * From Ap_V_AccMxList " & Str_QueryCondi & " And RpFlag='AP' And YbYsje<>0 And OverStatus=0 " & " ORDER BY KJYear,Period,BillDate,AccListId"
- Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- With Rec_Query
- CxbbGrid.Rows = CxbbGrid.FixedRows
- CxbbGrid.Rows = CxbbGrid.FixedRows + .RecordCount
- Jsqte = CxbbGrid.FixedRows
- Do While Not .EOF
- If Jsqte >= CxbbGrid.Rows Then
- CxbbGrid.AddItem ""
- End If
- CxbbGrid.TextMatrix(Jsqte, 0) = .Fields("AccListID") '应收/应付明细帐ID
- CxbbGrid.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Jsqte - CxbbGrid.FixedRows + 1 '行值
- CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = False '选中
- CxbbGrid.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls)) = .Fields("BillDate") '单据日期
- CxbbGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("BillItemName") & "") '单据类型
- CxbbGrid.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls)) = Trim(.Fields("BillCode") & "") '单据编号
- If Bln_Foreign Then
- If .Fields("YbYsje") <> 0 Then '原币应收/应付金额
- CxbbGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = .Fields("YbYsje")
- End If
- If .Fields("YbYsje") - .Fields("YbCancelje") <> 0 Then
- CxbbGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = .Fields("YbYsje") - .Fields("YbCancelje") '原币未核销金额
- CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .Fields("YbYsje") - .Fields("YbCancelje") '本次核销金额
- End If
- Else
- If .Fields("BbYsje") <> 0 Then '本币应收/应付金额
- CxbbGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = .Fields("BbYsje")
- End If
- If .Fields("Bbysje") - .Fields("BbCancelje") <> 0 Then
- CxbbGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = .Fields("Bbysje") - .Fields("BbCancelje") '本币未核销金额
- CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .Fields("Bbysje") - .Fields("BbCancelje") '本次核销金额
- End If
- End If
- CxbbGrid.RowHeight(Jsqte) = Sjhgd
- Jsqte = Jsqte + 1
- .MoveNext
- Loop
- End With
- ']以上为用户自定义部分
- End Sub
- Private Sub Sub_Query2(Opti As Integer) '生成查询结果(付款,预付款)
- Dim Rec_Query As New ADODB.Recordset '查询结果动态集
- Dim Sqlstr As String '查询字符串
- Dim Coljsq As Long '网格列计数器
- Dim Jsqte As Long '临时动态计数器
- Bln_Foreign = False
- '以下为自定义部分[
- With HX_FrmHxCxtj
- Str_QueryCondi = " Where 1=1 "
- For Jsqte = 1 To 4
- Select Case Jsqte
- Case 1 '单据日期范围(起始)
- If Trim(.LrText(1).Text) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " And BillDate>=' " & Trim(.LrText(1).Text) & "'"
- End If
- Case 2 '单据日期范围(终止)
- If Trim(.LrText(2).Text) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " And BillDate<= ' " & Trim(.LrText(2).Text) & "'"
- End If
- Case 3 '往来供应商
- If Trim(.LrText(0).Tag) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " and PSCode = '" & Trim(.LrText(0).Tag) & "'"
- End If
- Case 4 '原币名称
- If GetComboKey(.Imgebo_ForeignCurr, 0) <> "Zhbwb" Then
- Str_QueryCondi = Str_QueryCondi & " and ForeignCurrCode='" & Trim(GetComboKey(.Imgebo_ForeignCurr, 0)) & "'"
- Bln_Foreign = True
- End If
- End Select
- Next Jsqte
- End With
- If Opti = 1 Then
- '生成付款查询结果
- Sqlstr = "SELECT * From AP_V_AccMxList " & Str_QueryCondi & " And RpFlag='AP' And (AP_V_AccMxList.BillItemCode='90' OR AP_V_AccMxList.BillItemCode='92') And AP_V_AccMxList.OverStatus=0 " & " ORDER BY KJYear,Period,BillDate,AccListId"
- Else
- '生成预付款查询结果
- Sqlstr = "SELECT * From AP_V_AccMxList " & Str_QueryCondi & " And RpFlag='AP' And (AP_V_AccMxList.BillItemCode='91' OR AP_V_AccMxList.BillItemCode='92') And AP_V_AccMxList.OverStatus=0 " & " ORDER BY KJYear,Period,BillDate,AccListId"
- End If
- Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- With Rec_Query
- CxbbGrid1.Rows = CxbbGrid1.FixedRows
- CxbbGrid1.Rows = CxbbGrid1.FixedRows + .RecordCount
- Jsqte = CxbbGrid1.FixedRows
- Do While Not .EOF
- If Jsqte >= CxbbGrid1.Rows Then
- CxbbGrid1.AddItem ""
- End If
- CxbbGrid1.TextMatrix(Jsqte, 0) = .Fields("AccListID") '应收/应付明细帐ID
- CxbbGrid1.TextMatrix(Jsqte, Sydz("001", GridStr1(), Szzls1)) = Jsqte - CxbbGrid1.FixedRows + 1 '行值
- CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = False '选中
- CxbbGrid1.TextMatrix(Jsqte, Sydz("003", GridStr1(), Szzls1)) = .Fields("BillDate") '单据日期
- CxbbGrid1.TextMatrix(Jsqte, Sydz("004", GridStr1(), Szzls1)) = Trim(.Fields("BillItemName") & "") '单据类型
- CxbbGrid1.TextMatrix(Jsqte, Sydz("005", GridStr1(), Szzls1)) = Trim(.Fields("BillCode") & "") '单据编号
- If Bln_Foreign Then
- If .Fields("YbSsje") <> 0 Then '原币收回/付款金额
- CxbbGrid1.TextMatrix(Jsqte, Sydz("006", GridStr1(), Szzls1)) = Trim(Str(.Fields("YbSsje")))
- End If
- If .Fields("YbSsje") - .Fields("YbCancelje") <> 0 Then
- CxbbGrid1.TextMatrix(Jsqte, Sydz("007", GridStr1(), Szzls1)) = Trim(Str(.Fields("YbSsje") - .Fields("YbCancelje"))) '原币已核销金额
- CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)) = Trim(Str(.Fields("YbSsje") - .Fields("YbCancelje"))) '本次核销金额
- End If
- Else
- If .Fields("BbSsje") <> 0 Then '收回/付款金额
- CxbbGrid1.TextMatrix(Jsqte, Sydz("006", GridStr1(), Szzls1)) = Trim(Str(.Fields("BbSsje")))
- End If
- If .Fields("BbSsje") - .Fields("BbCancelje") <> 0 Then
- CxbbGrid1.TextMatrix(Jsqte, Sydz("007", GridStr1(), Szzls1)) = Trim(Str(.Fields("BbSsje") - .Fields("BbCancelje"))) '已核销金额
- CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)) = Trim(Str(.Fields("BbSsje") - .Fields("BbCancelje"))) '本次核销金额
- End If
- End If
- CxbbGrid1.RowHeight(Jsqte) = Sjhgd1
- Jsqte = Jsqte + 1
- .MoveNext
- Loop
- End With
- ']以上为用户自定义部分
- End Sub
- Private Sub Sub_Query3() '生成查询结果(应收款)
- Dim Rec_Query As New ADODB.Recordset '查询结果动态集
- Dim Sqlstr As String '查询字符串
- Dim Coljsq As Long '网格列计数器
- Dim Jsqte As Long '临时动态计数器
- Bln_Foreign = False
- '以下为自定义部分[
- With HX_FrmHxCxtj
- Str_QueryCondi = " Where 1=1 "
- For Jsqte = 1 To 4
- Select Case Jsqte
- Case 1 '单据日期范围(起始)
- If Trim(.LrText(1).Text) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " And BillDate>=' " & Trim(.LrText(1).Text) & "'"
- End If
- Case 2 '单据日期范围(终止)
- If Trim(.LrText(2).Text) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " And BillDate<= ' " & Trim(.LrText(2).Text) & "'"
- End If
- Case 3 '往来客户
- If Trim(.LrText(3).Tag) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " and PSCode = '" & Trim(.LrText(3).Tag) & "'"
- Str_CusCode = Trim(.LrText(3).Tag)
- Else
- Str_CusCode = ""
- End If
- Case 4 '原币名称
- If GetComboKey(.Imgebo_ForeignCurr, 0) <> "Zhbwb" Then
- Str_QueryCondi = Str_QueryCondi & " and ForeignCurrCode='" & Trim(GetComboKey(.Imgebo_ForeignCurr, 0)) & "'"
- Bln_Foreign = True
- End If
- End Select
- Next Jsqte
- End With
- '生成应付款查询结果
- Sqlstr = "SELECT * From AP_V_AccMxList " & Str_QueryCondi & " And RpFlag='AR' And YbYsje<>0 And OverStatus=0 " & " ORDER BY KJYear,Period,BillDate,AccListId"
- Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- With Rec_Query
- CxbbGrid1.Rows = CxbbGrid1.FixedRows
- CxbbGrid1.Rows = CxbbGrid1.FixedRows + .RecordCount
- Jsqte = CxbbGrid1.FixedRows
- Do While Not .EOF
- If Jsqte >= CxbbGrid1.Rows Then
- CxbbGrid1.AddItem ""
- End If
- CxbbGrid1.TextMatrix(Jsqte, 0) = .Fields("AccListID") '应收/应付明细帐ID
- CxbbGrid1.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Jsqte - CxbbGrid1.FixedRows + 1 '行值
- CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = False '选中
- CxbbGrid1.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls)) = .Fields("BillDate") '单据日期
- CxbbGrid1.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("BillItemName") & "") '单据类型
- CxbbGrid1.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls)) = Trim(.Fields("BillCode") & "") '单据编号
- If Bln_Foreign Then
- If .Fields("YbYsje") <> 0 Then '原币应收/应付金额
- CxbbGrid1.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = .Fields("YbYsje")
- End If
- If .Fields("YbYsje") - .Fields("YbCancelje") <> 0 Then
- CxbbGrid1.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = .Fields("YbYsje") - .Fields("YbCancelje") '原币未核销金额
- CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .Fields("YbYsje") - .Fields("YbCancelje") '本次核销金额
- End If
- Else: Print
- If .Fields("BbYsje") <> 0 Then '本币应收/应付金额
- CxbbGrid1.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = .Fields("BbYsje")
- End If
- If .Fields("Bbysje") - .Fields("BbCancelje") <> 0 Then
- CxbbGrid1.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = .Fields("Bbysje") - .Fields("BbCancelje") '本币未核销金额
- CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .Fields("Bbysje") - .Fields("BbCancelje") '本次核销金额
- End If
- End If
- CxbbGrid1.RowHeight(Jsqte) = Sjhgd
- Jsqte = Jsqte + 1
- .MoveNext
- Loop
- End With
- ']以上为用户自定义部分
- End Sub
- '============================金额输入过程控制============================'
- '输入本次核销金额(网格1)
- Private Sub CxbbGrid_BeforeEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)
- With CxbbGrid
- If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
- Cancel = True
- End If
- If GridInt(.Col, 2) <> 0 Then
- CxbbGrid.EditMaxLength = GridInt(.Col, 2)
- Else
- CxbbGrid.EditMaxLength = 3000
- End If
- End With
- End Sub
- Private Sub CxbbGrid_KeyPressEdit(ByVal Row As Long, ByVal Col As Long, KeyAscii As Integer)
- Call Sub_Lrxszxz(CxbbGrid, KeyAscii)
- End Sub
- Private Sub CxbbGrid_ChangeEdit()
- With CxbbGrid
- Select Case GridInt(.Col, 1)
- Case 8, 11
- Call Sub_Sjgskz(CxbbGrid, Xtjezws - Xtjexsws - 1, Xtjexsws)
- Case 9, 12
- Call Sub_Sjgskz(CxbbGrid, Xtslzws - Xtslxsws - 1, Xtslxsws)
- Case 10
- Call Sub_Sjgskz(CxbbGrid, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
- Case Else
- If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
- Call Sub_Sjgskz(CxbbGrid, GridInt(.Col, 3), GridInt(.Col, 4))
- End If
- End Select
- End With
- End Sub
- Private Sub CxbbGrid_AfterEdit(ByVal Row As Long, ByVal Col As Long) '事后判断用户录入有效性
- With CxbbGrid
- Select Case Col
- Case Sydz("008", GridStr(), Szzls)
- '本次核销金额不能大于单据未核销金额或等于0,如大于则自动取未核销金额填入
- If (Val(.TextMatrix(Row, Col)) > Val(.TextMatrix(Row, Sydz("007", GridStr(), Szzls)))) Or Val(.TextMatrix(Row, Col)) = 0 Then
- .TextMatrix(Row, Col) = .TextMatrix(Row, Sydz("007", GridStr(), Szzls))
- End If
- End Select
- End With
- End Sub
- '输入本次核销金额(网格2)
- Private Sub CxbbGrid1_BeforeEdit(ByVal Row As Long, ByVal Col As Long, Cancel As Boolean)
- With CxbbGrid1
- If Not GridBoolean1(.Col, 1) Or .Row < .FixedRows Then
- Cancel = True
- End If
- If GridInt1(.Col, 2) <> 0 Then
- CxbbGrid1.EditMaxLength = GridInt1(.Col, 2)
- Else
- CxbbGrid1.EditMaxLength = 3000
- End If
- End With
- End Sub
- Private Sub CxbbGrid1_KeyPressEdit(ByVal Row As Long, ByVal Col As Long, KeyAscii As Integer)
- Call Sub_Lrxszxz(CxbbGrid1, KeyAscii)
- End Sub
- Private Sub CxbbGrid1_ChangeEdit()
- With CxbbGrid1
- Select Case GridInt1(.Col, 1)
- Case 8, 11
- Call Sub_Sjgskz(CxbbGrid1, Xtjezws - Xtjexsws - 1, Xtjexsws)
- Case 9, 12
- Call Sub_Sjgskz(CxbbGrid1, Xtslzws - Xtslxsws - 1, Xtslxsws)
- Case 10
- Call Sub_Sjgskz(CxbbGrid1, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
- Case Else
- If GridInt1(.Col, 3) <> 0 Or GridInt1(.Col, 4) <> 0 Then
- Call Sub_Sjgskz(CxbbGrid1, GridInt1(.Col, 3), GridInt1(.Col, 4))
- End If
- End Select
- End With
- End Sub
- Private Sub CxbbGrid1_AfterEdit(ByVal Row As Long, ByVal Col As Long) '事后判断用户录入有效性
- With CxbbGrid1
- Select Case Col
- Case Sydz("008", GridStr1(), Szzls1)
- '本次核销金额不能大于单据未核销金额或等于0,如大于则自动取未核销金额填入
- If (Val(.TextMatrix(Row, Col)) > Val(.TextMatrix(Row, Sydz("007", GridStr1(), Szzls1)))) Or Val(.TextMatrix(Row, Col)) = 0 Then
- .TextMatrix(Row, Col) = .TextMatrix(Row, Sydz("007", GridStr1(), Szzls1))
- End If
- End Select
- End With
- End Sub
- '公用数值控制函数
- Private Sub Sub_Lrxszxz(WglrGrid As VSFlexGrid, lrzfasc As Integer) '网格录入带有小数位及正负号数值字段
- 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
- lrzfasc = 0
- End If
- End Sub
- Private Sub Sub_Sjgskz(WglrGrid As VSFlexGrid, zsws As Integer, xsws As Integer) '保证数值录入字段录入格式
- Dim xsdwz%, bccrd%
- xsdwz = InStr(1, WglrGrid.EditText, ".")
- bccrd = WglrGrid.EditSelStart
- If xsdwz = 0 Then
- WglrGrid.EditText = Mid(WglrGrid.EditText, 1, zsws)
- WglrGrid.EditSelStart = bccrd
- Exit Sub
- End If
- If zsws > xsdwz - 1 Then
- Zswstr = Mid(WglrGrid.EditText, 1, xsdwz - 1)
- Else
- Zswstr = Mid(WglrGrid.EditText, 1, zsws)
- End If
- xswstr = Mid(WglrGrid.EditText, xsdwz + 1, xsws)
- WglrGrid.EditText = Zswstr + "." + xswstr
- WglrGrid.EditSelStart = bccrd
- End Sub
- '以下为网格选中操作
- Private Sub CxbbGrid_DblClick()
- With CxbbGrid
- CxbbGrid.EditCell '调用网格编辑方法
- If .Row < .FixedRows Or .Col <> Sydz("002", GridStr(), Szzls) Then
- Exit Sub
- End If
- If CxbbGrid.TextMatrix(.Row, Sydz("002", GridStr(), Szzls)) Then
- CxbbGrid.TextMatrix(.Row, Sydz("002", GridStr(), Szzls)) = False
- Else
- CxbbGrid.TextMatrix(.Row, Sydz("002", GridStr(), Szzls)) = True
- End If
- End With
- End Sub
- Private Sub CxbbGrid_KeyPress(KeyAscii As Integer) '用户按空格表示切换,按回车表示选中
- With CxbbGrid
- If .Row < .FixedRows Or .Col <> Sydz("002", GridStr(), Szzls) Then
- Exit Sub
- End If
- If Chr(KeyAscii) = " " Then
- Call CxbbGrid_DblClick
- End If
- If KeyAscii = vbKeyReturn Then
- CxbbGrid.TextMatrix(.Row, Sydz("002", GridStr(), Szzls)) = True
- End If
- End With
- End Sub
- Private Sub CxbbGrid1_DblClick()
- CxbbGrid1.EditCell '调用网格编辑方法
- With CxbbGrid1
- If .Row < .FixedRows Or .Col <> Sydz("002", GridStr1(), Szzls1) Then
- Exit Sub
- End If
- If CxbbGrid1.TextMatrix(.Row, Sydz("002", GridStr1(), Szzls1)) Then
- CxbbGrid1.TextMatrix(.Row, Sydz("002", GridStr1(), Szzls1)) = False
- Else
- CxbbGrid1.TextMatrix(.Row, Sydz("002", GridStr1(), Szzls1)) = True
- End If
- End With
- End Sub
- Private Sub CxbbGrid1_KeyPress(KeyAscii As Integer) '用户按空格表示切换,按回车表示选中
- With CxbbGrid1
- If .Row < .FixedRows Or .Col <> Sydz("002", GridStr1(), Szzls1) Then
- Exit Sub
- End If
- If Chr(KeyAscii) = " " Then
- Call CxbbGrid1_DblClick
- End If
- If KeyAscii = vbKeyReturn Then
- CxbbGrid1.TextMatrix(.Row, Sydz("002", GridStr1(), Szzls1)) = True
- End If
- End With
- End Sub
- Private Sub Sub_SelectAll() '全选
- With CxbbGrid
- For Jsqte = .FixedRows To .Rows - 1
- CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True
- Next Jsqte
- End With
- With CxbbGrid1
- For Jsqte = .FixedRows To .Rows - 1
- CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = True
- Next Jsqte
- End With
- End Sub
- Private Sub Sub_AbandonAll() '全消
- With CxbbGrid
- For Jsqte = .FixedRows To .Rows - 1
- CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = False
- Next Jsqte
- End With
- With CxbbGrid1
- For Jsqte = .FixedRows To .Rows - 1
- CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = False
- Next Jsqte
- End With
- End Sub
- Private Sub Sub_AutoSelect() '自动
- Dim Dbl_Yskhj As Double '网格(应付款)未核销金额合计
- Dim Dbl_Dkhj As Double '网格(付款、退款、预付款、应收款)未核销金额合计
- '先判断以哪方金额为核销基准(以金额小的一方)
- With CxbbGrid
- For Jsqte = .FixedRows To .Rows - 1
- Dbl_Yskhj = Dbl_Yskhj + Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- Next Jsqte
- End With
- With CxbbGrid1
- For Jsqte = .FixedRows To .Rows - 1
- Dbl_Dkhj = Dbl_Dkhj + Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- Next Jsqte
- End With
- If Dbl_Yskhj >= Dbl_Dkhj Then
- With CxbbGrid1
- For Jsqte = .FixedRows To .Rows - 1
- CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True
- .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))
- Next Jsqte
- End With
- With CxbbGrid
- For Jsqte = .FixedRows To .Rows - 1
- If Dbl_Dkhj <> 0 Then
- CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True
- If Dbl_Dkhj > Val(.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))) Then
- .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))
- Else
- .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Dbl_Dkhj
- End If
- Dbl_Dkhj = Dbl_Dkhj - Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- End If
- Next Jsqte
- End With
- Else
- With CxbbGrid
- For Jsqte = .FixedRows To .Rows - 1
- CxbbGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True
- .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))
- Next Jsqte
- End With
- With CxbbGrid1
- For Jsqte = .FixedRows To .Rows - 1
- If Dbl_Yskhj <> 0 Then
- CxbbGrid1.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True
- If Dbl_Yskhj > Val(.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))) Then
- .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = .TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))
- Else
- .TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Dbl_Yskhj
- End If
- Dbl_Yskhj = Dbl_Yskhj - Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- End If
- Next Jsqte
- End With
- End If
- End Sub
- Private Sub Sub_Sghx() '手工核销
- Select Case Int_Hxlx
- Case 0, 1 '付款结算、预付款冲应付款
- If Fun_Dkjs(Int_Hxlx) Then
- Call Timer1_Timer
- End If
- Case 2
- If Fun_YsCYf Then
- Call Timer1_Timer
- End If
- End Select
- End Sub
- Private Function Fun_Dkjs(Int_Hxlx As Integer) As Boolean '付款结算
- '函数参数:Int_Hxlx 核销类型 0-付款结算 1-预付款冲应付款
- Dim Rec_AccList As New ADODB.Recordset '应收/应付明细帐
- Dim Rec_Cancel As New ADODB.Recordset '应收/应付核销情况表
- Dim RecTemp As New ADODB.Recordset '临时动态集
- Dim Dbl_Phjg As Double '平衡结果
- Dim Dbl_Phjg1 As Double '平衡结果1
- Dim Jsqte As Long '临时计数器
- Dim Bln_Select As Boolean '是否选中核销单据
- Dim Sqlstr As String '查询连接串
- Dim Bln_ConVertFlag As Boolean '折算方式
- Dim Lng_CancelNo As Long '核销过程序号
- Dim Dbl_CWbje As Double '核销原币金额
- Dim Dbl_CBbje As Double '核销本币金额
- Bln_Select = False
- '让录入充分完成
- CxbbGrid.Col = 0
- CxbbGrid1.Col = 0
- Dbl_Phjg = 0
- Dbl_Phjg1 = 0
- '先判断用户输入核销金额是否平衡
- With CxbbGrid
- For Jsqte = .FixedRows To .Rows - 1
- If .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True Then
- Bln_Select = True
- Dbl_Phjg = Dbl_Phjg + Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- End If
- Next Jsqte
- End With
- With CxbbGrid1
- For Jsqte = .FixedRows To .Rows - 1
- If .TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = True Then
- Bln_Select = True
- Dbl_Phjg1 = Dbl_Phjg1 + Val(.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
- End If
- Next Jsqte
- End With
- If Not Bln_Select Then
- Tsxx = "请先选中核销记录!"
- Call Xtxxts(Tsxx, 0, 4)
- Exit Function
- End If
- If Abs(Dbl_Phjg - Dbl_Phjg1) >= 0.001 Then
- Tsxx = "核销金额不平衡,不能进行核销!"
- Call Xtxxts(Tsxx, 0, 4)
- Exit Function
- End If
- '开始进行核销
- On Error GoTo Swcwcl
- Cw_DataEnvi.DataConnect.BeginTrans
- '取最大核销过程序号
- Sqlstr = "Select Max(CancelNo) as MaxCancelNo From RP_Cancel Where RpFlag='AP'"
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If Not IsNull(RecTemp.Fields("MaxCancelNo")) Then
- Lng_CancelNo = RecTemp.Fields("MaxCancelNo") + 1
- Else
- Lng_CancelNo = 1
- End If
- '1.核销应收/应付款明细帐
- With CxbbGrid
- For Jsqte = .FixedRows To .Rows - 1
- If .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True Then
- With Rec_AccList
- If Rec_AccList.State = 1 Then .Close
- Sqlstr = "Select RP_Acclist.* From RP_AccList" & _
- " Where AcclistID = " & Val(CxbbGrid.TextMatrix(Jsqte, 0))
- Rec_AccList.Open Sqlstr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- Sqlstr = "Select Gy_ForeignCurrency.ConVertFlag From Gy_ForeignCurrency Where Gy_ForeignCurrency.ForeignCurrCode='" & Trim(.Fields("ForeignCurrCode")) & "'"
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If RecTemp.Fields("ConVertFlag") Then
- Bln_ConVertFlag = True
- Else
- Bln_ConVertFlag = False
- End If
- If Bln_Foreign Then
- '按原币核销
- .Fields("YbCancelje") = .Fields("YbCancelje") + Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- Dbl_CWbje = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- If Not Bln_ConVertFlag Then
- .Fields("BbCancelje") = Format(.Fields("YbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CBbje = Format(Dbl_CWbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Else
- .Fields("BbCancelje") = Format(.Fields("YbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CBbje = Format(Dbl_CWbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- End If
- If .Fields("YbCancelje") = .Fields("YbYsje") Then
- .Fields("OverStatus") = 1
- End If
- Else
- '按本币核销
- .Fields("BbCancelje") = .Fields("BbCancelje") + Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- Dbl_CBbje = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- If Bln_ConVertFlag Then
- .Fields("YbCancelje") = Format(.Fields("BbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CWbje = Format(Dbl_CBbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Else
- .Fields("YbCancelje") = Format(.Fields("BbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CWbje = Format(Dbl_CBbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- End If
- If .Fields("BbCancelje") = .Fields("BbYsje") Then
- .Fields("OverStatus") = 1
- End If
- End If
- .Update
- If Rec_Cancel.State = 1 Then Rec_Cancel.Close
- Rec_Cancel.Open "Select * From RP_Cancel Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- Rec_Cancel.AddNew
- Rec_Cancel.Fields("RPFlag") = "AP" '应收/应付帐标识
- If Int_Hxlx = 0 Then
- Rec_Cancel.Fields("CancelItemCode") = "A0" '核销处理过程编码(A0:付款结算)
- Else
- Rec_Cancel.Fields("CancelItemCode") = "A1" '核销处理过程编码(A1:预付款冲应付款)
- End If
- Rec_Cancel.Fields("SupplierCode") = Str_SupplierCode '往来供应商编码
- Rec_Cancel.Fields("CancelNo") = Lng_CancelNo '核销过程序号
- Rec_Cancel.Fields("CancelDate") = Xtrq '核销日期
- Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode") '单据类型编码
- Rec_Cancel.Fields("BillID") = .Fields("BillID") '单据ID
- Rec_Cancel.Fields("BillCode") = .Fields("BillCode") '单据编号
- Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
- Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0 '记帐汇率
- Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje '原币核销金额
- Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje '本币核销金额
- Rec_Cancel.Fields("Ybye") = .Fields("YbYsje") - .Fields("YbCancelje") '原币剩余金额
- Rec_Cancel.Fields("Bbye") = .Fields("BbYsje") - .Fields("BbCancelje") '本币剩余金额
- Rec_Cancel.Fields("Canceler") = Xtczy
- Rec_Cancel.Update
- '如果为采购发票,则填写回款金额
- If Trim(.Fields("BillItemCode")) = "70" Or Trim(.Fields("BillItemCode")) = "71" Then
- Sqlstr = "Update Cg_InvoiceMain SET CwComingValue=CwComingValue+" & Dbl_CBbje & ",CwComingValueFor=CwComingValueFor+" & Dbl_CWbje & " Where InvoiceMainID=" & .Fields("BillId")
- Cw_DataEnvi.DataConnect.Execute (Sqlstr)
- End If
- End With
- End If
- Next Jsqte
- End With
- '1.核销付款明细帐
- With CxbbGrid1
- For Jsqte = .FixedRows To .Rows - 1
- If .TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = True Then
- With Rec_AccList
- If Rec_AccList.State = 1 Then .Close
- Sqlstr = "Select RP_Acclist.* From RP_AccList" & _
- " Where AcclistID = " & Val(CxbbGrid1.TextMatrix(Jsqte, 0))
- Rec_AccList.Open Sqlstr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- Sqlstr = "Select Gy_ForeignCurrency.ConVertFlag From Gy_ForeignCurrency where Gy_ForeignCurrency.ForeignCurrCode='" & Trim(.Fields("ForeignCurrCode")) & "'"
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If RecTemp.Fields("ConvertFlag") Then
- Bln_ConVertFlag = True
- Else
- Bln_ConVertFlag = False
- End If
- If Bln_Foreign Then
- '按原币核销
- .Fields("YbCancelje") = .Fields("YbCancelje") + Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
- Dbl_CWbje = Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
- If Not Bln_ConVertFlag Then
- .Fields("BbCancelje") = Format(.Fields("YbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CBbje = Format(Dbl_CWbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Else
- .Fields("BbCancelje") = Format(.Fields("YbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CBbje = Format(Dbl_CWbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- End If
- If .Fields("YbCancelje") = .Fields("YbSsje") Then
- .Fields("OverStatus") = 1
- End If
- Else
- '按本币核销
- .Fields("BbCancelje") = .Fields("BbCancelje") + Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
- Dbl_CBbje = Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
- If Bln_ConVertFlag Then
- .Fields("YbCancelje") = Format(.Fields("BbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CWbje = Format(Dbl_CBbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Else
- .Fields("YbCancelje") = Format(.Fields("BbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CWbje = Format(Dbl_CBbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- End If
- If .Fields("BbCancelje") = .Fields("BbSsje") Then
- .Fields("OverStatus") = 1
- End If
- End If
- .Update
- If Rec_Cancel.State = 1 Then Rec_Cancel.Close
- Rec_Cancel.Open "Select * From RP_Cancel Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- Rec_Cancel.AddNew
- Rec_Cancel.Fields("RPFlag") = "AP" '应收/应付帐标识
- If Int_Hxlx = 0 Then
- Rec_Cancel.Fields("CancelItemCode") = "A0" '核销处理过程编码(A0:付款结算)
- Else
- Rec_Cancel.Fields("CancelItemCode") = "A1" '核销处理过程编码(A1:预付款冲应付款)
- End If
- Rec_Cancel.Fields("SupplierCode") = Str_SupplierCode '往来供应商编码
- Rec_Cancel.Fields("CancelNo") = Lng_CancelNo '核销过程序号
- Rec_Cancel.Fields("CancelDate") = Xtrq '核销日期
- Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode") '单据类型编码
- Rec_Cancel.Fields("BillID") = .Fields("BillID") '单据ID
- Rec_Cancel.Fields("BillCode") = .Fields("BillCode") '单据编号
- Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
- Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0 '记帐汇率
- Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje '原币核销金额
- Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje '本币核销金额
- Rec_Cancel.Fields("YbYe") = .Fields("YbSsje") - .Fields("YbCancelje") '原币剩余金额
- Rec_Cancel.Fields("BbYe") = .Fields("BbSsje") - .Fields("BbCancelje") '本币剩余金额
- Rec_Cancel.Fields("Canceler") = Xtczy
- Rec_Cancel.Update
- End With
- End If
- Next Jsqte
- End With
- Cw_DataEnvi.DataConnect.CommitTrans
- Fun_Dkjs = True
- Exit Function
- Swcwcl:
- Cw_DataEnvi.DataConnect.RollbackTrans
- Tsxx = "核销过程中出现未知错误,程序自动恢复核销前状态!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End Function
- Private Function Fun_YsCYf() As Boolean '应付冲应收
- Dim Rec_AccList As New ADODB.Recordset '应收/应付明细帐
- Dim Rec_AccList1 As New ADODB.Recordset '应收/应付明细帐1
- Dim Rec_Cancel As New ADODB.Recordset '应收/应付核销情况表
- Dim RecTemp As New ADODB.Recordset '临时动态集
- Dim Rec_AccSum As New ADODB.Recordset '应收应付总帐动态集
- Dim Dbl_YsSelect As Double '选中应收帐款记录核销金额合计
- Dim Dbl_YfSelect As Double '选中应付帐款记录核销金额合计
- Dim Jsqte As Long '临时计数器
- Dim Bln_Select As Boolean '是否选中核销单据
- Dim Sqlstr As String '查询连接串
- Dim Bln_ConVertFlag As Boolean '折算方式
- Dim Lng_CancelNo As Long '核销过程序号
- Dim Dbl_CWbje As Double '核销原币金额
- Dim Dbl_CBbje As Double '核销本币金额
- Dim Int_Dqyear As Integer '用户选择会计年度
- Dim Int_DqPeriod As Integer '用户选择会计期间
- Dim Lng_BillID As Long '单据ID
- Dim Str_BillCode As String '单据编码
- Dim Lng_CancelId As Long '临时使用核销ID
- '因为应付冲应收直接生成明细帐,所以业务操作日期必须在当前会计期间内
- '判断用户所选业务日期与当前会计期间是否一致
- Sqlstr = "Select Top 1 * FROM Gy_Kjrlb Where ApJzbz=0 Order By Kjyear,Period"
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- With RecTemp
- If Not .EOF Then
- If Not (Xtrq >= .Fields("Qsrq") And Xtrq <= .Fields("Zzrq")) Then
- Tsxx = "业务日期应在当前会计期间范围内!"
- Call Xtxxts(Tsxx, 0, 4)
- Exit Function
- Else
- Int_Dqyear = .Fields("Kjyear")
- Int_DqPeriod = .Fields("Period")
- End If
- Else
- Tsxx = "所有会计期间已结帐完毕!"
- Call Xtxxts(Tsxx, 0, 4)
- Exit Function
- End If
- End With
- Bln_Select = False
- '让录入充分完成
- CxbbGrid.Col = 0
- CxbbGrid1.Col = 0
- '初始化合计值
- Dbl_YsSelect = 0
- Dbl_YfSelect = 0
- '先判断用户输入核销金额是否平衡
- With CxbbGrid
- For Jsqte = .FixedRows To .Rows - 1
- If .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True Then
- Bln_Select = True
- Dbl_YsSelect = Dbl_YsSelect + Val(.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- End If
- Next Jsqte
- End With
- With CxbbGrid1
- For Jsqte = .FixedRows To .Rows - 1
- If .TextMatrix(Jsqte, Sydz("002", GridStr1(), Szzls1)) = True Then
- Bln_Select = True
- Dbl_YfSelect = Dbl_YfSelect + Val(.TextMatrix(Jsqte, Sydz("008", GridStr1(), Szzls1)))
- End If
- Next Jsqte
- End With
- If Not Bln_Select Then
- Tsxx = "请先选中核销记录!"
- Call Xtxxts(Tsxx, 0, 4)
- Exit Function
- End If
- If Abs(Dbl_YsSelect - Dbl_YfSelect) >= 0.001 Then
- Tsxx = "核销金额不平衡,不能进行核销!"
- Call Xtxxts(Tsxx, 0, 4)
- Exit Function
- End If
- '开始进行核销
- On Error GoTo Swcwcl
- Cw_DataEnvi.DataConnect.BeginTrans
- '生成应付冲应收单据ID和单据编号
- Lng_BillID = CreatBillID("0306")
- Str_BillCode = CreatBillCode("0306", True)
- '取最大核销过程序号
- Sqlstr = "Select Max(CancelNo) as MaxCancelNo From RP_Cancel Where RpFlag='AP'"
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If Not IsNull(RecTemp.Fields("MaxCancelNo")) Then
- Lng_CancelNo = RecTemp.Fields("MaxCancelNo") + 1
- Else
- Lng_CancelNo = 1
- End If
- '1.核销应付明细帐
- With CxbbGrid
- For Jsqte = .FixedRows To .Rows - 1
- If .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True Then
- With Rec_AccList
- If Rec_AccList.State = 1 Then .Close
- Sqlstr = "Select RP_Acclist.* From RP_AccList" & _
- " Where AcclistID = " & Val(CxbbGrid.TextMatrix(Jsqte, 0))
- Rec_AccList.Open Sqlstr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- Sqlstr = "Select Gy_ForeignCurrency.ConVertFlag From Gy_ForeignCurrency Where Gy_ForeignCurrency.ForeignCurrCode='" & Trim(.Fields("ForeignCurrCode")) & "'"
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If RecTemp.Fields("ConVertFlag") Then
- Bln_ConVertFlag = True
- Else
- Bln_ConVertFlag = False
- End If
- If Bln_Foreign Then
- '按原币核销
- .Fields("YbCancelje") = .Fields("YbCancelje") + Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- Dbl_CWbje = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- If Not Bln_ConVertFlag Then
- .Fields("BbCancelje") = Format(.Fields("YbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CBbje = Format(Dbl_CWbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Else
- .Fields("BbCancelje") = Format(.Fields("YbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CBbje = Format(Dbl_CWbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- End If
- If .Fields("YbCancelje") = .Fields("YbYsje") Then
- .Fields("OverStatus") = 1
- End If
- Else
- '按本币核销
- .Fields("BbCancelje") = .Fields("BbCancelje") + Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- Dbl_CBbje = Val(CxbbGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- If Bln_ConVertFlag Then
- .Fields("YbCancelje") = Format(.Fields("BbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CWbje = Format(Dbl_CBbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Else
- .Fields("BbCancelje") = Format(.Fields("BbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CWbje = Format(Dbl_CBbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- End If
- If .Fields("BbCancelje") = .Fields("BbYsje") Then
- .Fields("OverStatus") = 1
- End If
- End If
- .Update
- If Rec_Cancel.State = 1 Then Rec_Cancel.Close
- Rec_Cancel.Open "Select * From RP_Cancel Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- Rec_Cancel.AddNew
- Rec_Cancel.Fields("RPFlag") = "AP" '应收/应付帐标识
- Rec_Cancel.Fields("CancelItemCode") = "A2" '核销处理过程编码(A2:应付冲应收)
- Rec_Cancel.Fields("SupplierCode") = Str_SupplierCode '往来供应商编码
- Rec_Cancel.Fields("CancelNo") = Lng_CancelNo '核销过程序号
- Rec_Cancel.Fields("CancelDate") = Xtrq '核销日期
- Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode") '单据类型编码
- Rec_Cancel.Fields("BillID") = .Fields("BillID") '单据ID
- Rec_Cancel.Fields("BillCode") = .Fields("BillCode") '单据编号
- Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
- Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0 '记帐汇率
- Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje '原币核销金额
- Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje '本币核销金额
- Rec_Cancel.Fields("Ybye") = .Fields("YbYsje") - .Fields("YbCancelje") '原币剩余金额
- Rec_Cancel.Fields("Bbye") = .Fields("BbYsje") - .Fields("BbCancelje") '本币剩余金额
- Rec_Cancel.Fields("Canceler") = Xtczy
- Rec_Cancel.Update
- Lng_CancelId = Rec_Cancel.Fields("CancelId") '记录核销记录ID
- '如果为采购发票,则填写回款金额
- If Trim(.Fields("BillItemCode")) = "70" Or Trim(.Fields("BillItemCode")) = "71" Then
- Sqlstr = "Update Cg_InvoiceMain SET CwComingValue=CwComingValue+" & Dbl_CBbje & ",CwComingValueFor=CwComingValueFor+" & Dbl_CWbje & " Where InvoiceMainID=" & .Fields("BillId")
- Cw_DataEnvi.DataConnect.Execute (Sqlstr)
- End If
- End With
- '在应收/应付明细帐中加入付款明细帐,同时进行自动核销
- With Rec_AccList1
- If .State = 1 Then .Close
- .Open "Select * From RP_AccList Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- .AddNew
- .Fields("RPFlag") = Rec_AccList.Fields("RPFlag") '应收应付标识
- .Fields("PSCode") = Rec_AccList.Fields("PSCode") '往来单位编码
- .Fields("KJYear") = Int_Dqyear '会计年度
- .Fields("Period") = Int_DqPeriod '会计期间
- .Fields("BillItemCode") = "A2" '单据类型(应付冲应收)
- .Fields("BillID") = Lng_BillID '单据ID
- .Fields("BillCode") = Str_BillCode '单据编码
- .Fields("BillDate") = Xtrq '单据日期
- .Fields("BbSsje") = Dbl_CBbje '收回/付款本币金额
- .Fields("ForeignCurrCode") = Rec_AccList.Fields("ForeignCurrCode") '原币编码
- .Fields("AccRate") = Rec_AccList.Fields("AccRate") + 0 '记帐汇率
- .Fields("YbSsje") = Dbl_CWbje '原币收回/付款金额
- .Fields("AccCode") = Rec_AccList.Fields("AccCode") '单据科目编码
- .Fields("AccCodeArAp") = Rec_AccList.Fields("AccCodeArAp") '应收科目编码
- .Fields("DeptCode") = Rec_AccList.Fields("DeptCode") '部门
- .Fields("PersonCode") = Rec_AccList.Fields("PersonCode") '经办人
- .Fields("Digest") = "应付冲应收" '摘要
- .Fields("Maker") = Xtczy '制单人
- .Fields("Checker") = Xtczy '审核人
- '自动核销
- .Fields("YbCancelje") = Dbl_CWbje '原币核销金额
- .Fields("BbCancelje") = Dbl_CBbje '本币核销金额
- .Fields("OverStatus") = 1 '核销完毕
- .Update
- '记录新生成明细帐ID,以在生成凭证时回写凭证号
- Sqlstr = "Update Rp_Cancel Set YFId=" & .Fields("AccListId") & " Where CancelID=" & Lng_CancelId
- Cw_DataEnvi.DataConnect.Execute (Sqlstr)
- End With
- '登记应收/应付总帐
- Str_PSCode = Trim(Rec_AccList.Fields("PSCode") & "")
- Str_DeptCode = Trim(Rec_AccList.Fields("DeptCode") & "")
- Str_PersonCode = Trim(Rec_AccList.Fields("PersonCode") & "")
- Str_ForeignCurrCode = Trim(Rec_AccList.Fields("ForeignCurrCode") & "")
- With Rec_AccSum
- If .State = 1 Then .Close
- .Open "Select * From RP_AccSum Where RpFlag='" & Trim(Rec_AccList.Fields("RPFlag")) & "' And PSCode='" & Str_PSCode & _
- "' 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
- If Not Rec_AccSum.EOF Then
- .Fields("YbSsje") = .Fields("YbSsje") + Dbl_CWbje '本期收回/付款原币金额
- .Fields("YbQmye") = .Fields("YbQcye") + .Fields("YbYsje") - .Fields("YbSsje") '本期期末原币余额
- .Fields("BbSsje") = .Fields("BbSsje") + Dbl_CBbje '本期收回/付款本币金额
- .Fields("BbQmye") = .Fields("BbQcye") + .Fields("BbYsje") - .Fields("BbSsje") '本期期末本币余额
- .Update
- Else
- .AddNew
- .Fields("RPFlag") = Rec_AccList.Fields("RPFlag") '应收应付标识
- .Fields("PSCode") = Str_PSCode '往来单位编码
- .Fields("DeptCode") = Str_DeptCode '部门编码
- .Fields("PersonCode") = Str_PersonCode '个人编码
- .Fields("ForeignCurrCode") = Str_ForeignCurrCode '原币编码
- .Fields("KJYear") = Int_Dqyear '会计年度
- .Fields("Period") = Int_DqPeriod '会计期间
- .Fields("YbSsje") = Dbl_CWbje '本期收回/付款原币金额
- .Fields("YbQmye") = -Dbl_CWbje '本期期末原币余额
- .Fields("BbSsje") = Dbl_CBbje '本期收回/付款本币金额
- .Fields("BbQmye") = -Dbl_CBbje '本期期末本币余额
- .Update
- End If
- End With
- End If
- Next Jsqte
- End With
- '1.核销应收明细帐
- With CxbbGrid1
- For Jsqte = .FixedRows To .Rows - 1
- If .TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = True Then
- With Rec_AccList
- If Rec_AccList.State = 1 Then .Close
- Sqlstr = "Select RP_Acclist.* From RP_AccList" & _
- " Where AcclistID = " & Val(CxbbGrid1.TextMatrix(Jsqte, 0))
- Rec_AccList.Open Sqlstr, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- Sqlstr = "Select Gy_ForeignCurrency.ConVertFlag From Gy_ForeignCurrency Where Gy_ForeignCurrency.ForeignCurrCode='" & Trim(.Fields("ForeignCurrCode")) & "'"
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If RecTemp.Fields("ConVertFlag") Then
- Bln_ConVertFlag = True
- Else
- Bln_ConVertFlag = False
- End If
- If Bln_Foreign Then
- '按原币核销
- .Fields("YbCancelje") = .Fields("YbCancelje") + Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- Dbl_CWbje = Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- If Not Bln_ConVertFlag Then
- .Fields("BbCancelje") = Format(.Fields("YbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CBbje = Format(Dbl_CWbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Else
- .Fields("BbCancelje") = Format(.Fields("YbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CBbje = Format(Dbl_CWbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- End If
- If .Fields("YbCancelje") = .Fields("YbYsje") Then
- .Fields("OverStatus") = 1
- End If
- Else
- '按本币核销
- .Fields("BbCancelje") = .Fields("BbCancelje") + Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- Dbl_CBbje = Val(CxbbGrid1.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)))
- If Bln_ConVertFlag Then
- .Fields("YbCancelje") = Format(.Fields("BbCancelje") * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CWbje = Format(Dbl_CBbje * .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Else
- .Fields("BbCancelje") = Format(.Fields("BbCancelje") / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- Dbl_CWbje = Format(Dbl_CBbje / .Fields("AccRate"), "##." + String(Xtjexsws, "0"))
- End If
- If .Fields("BbCancelje") = .Fields("BbYsje") Then
- .Fields("OverStatus") = 1
- End If
- End If
- .Update
- If Rec_Cancel.State = 1 Then Rec_Cancel.Close
- Rec_Cancel.Open "Select * From RP_Cancel Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- Rec_Cancel.AddNew
- Rec_Cancel.Fields("RPFlag") = "AP" '应收/应付帐标识
- Rec_Cancel.Fields("CancelItemCode") = "A2" '核销处理过程编码(A2:应付冲应收)
- Rec_Cancel.Fields("CusCode") = Str_CusCode '往来客户编码
- Rec_Cancel.Fields("CancelNo") = Lng_CancelNo '核销过程序号
- Rec_Cancel.Fields("CancelDate") = Xtrq '核销日期
- Rec_Cancel.Fields("BillItemCode") = .Fields("BillItemCode") '单据类型编码
- Rec_Cancel.Fields("BillID") = .Fields("BillID") '单据ID
- Rec_Cancel.Fields("BillCode") = .Fields("BillCode") '单据编号
- Rec_Cancel.Fields("ForeignCurrCode") = .Fields("ForeignCurrCode") '原币编码
- Rec_Cancel.Fields("AccRate") = .Fields("AccRate") + 0 '记帐汇率
- Rec_Cancel.Fields("YbCancelJe") = Dbl_CWbje '原币核销金额
- Rec_Cancel.Fields("BbCancelJe") = Dbl_CBbje '本币核销金额
- Rec_Cancel.Fields("Ybye") = .Fields("YbYsje") - .Fields("YbCancelje") '原币剩余金额
- Rec_Cancel.Fields("Bbye") = .Fields("BbYsje") - .Fields("BbCancelje") '本币剩余金额
- Rec_Cancel.Fields("Canceler") = Xtczy
- Rec_Cancel.Update
- Lng_CancelId = Rec_Cancel.Fields("CancelId") '记录核销记录ID
- '如果为销售发票,则填写回款金额
- If Trim(.Fields("BillItemCode")) = "10" Or Trim(.Fields("BillItemCode")) = "11" Then
- Sqlstr = "Update XS_InvoiceBillMain SET ComingValue=ComingValue+" & Dbl_CBbje & ",ComingValueFor=ComingValueFor+" & Dbl_CWbje & " Where InvoiceBillMainID=" & .Fields("BillId")
- Cw_DataEnvi.DataConnect.Execute (Sqlstr)
- End If
- End With
- '在应收/应付明细帐中加入收款明细帐,同时进行自动核销
- With Rec_AccList1
- If .State = 1 Then .Close
- .Open "Select * From RP_AccList Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- .AddNew
- .Fields("RPFlag") = Rec_AccList.Fields("RPFlag") '应收应付标识
- .Fields("PSCode") = Rec_AccList.Fields("PSCode") '往来单位编码
- .Fields("KJYear") = Int_Dqyear '会计年度
- .Fields("Period") = Int_DqPeriod '会计期间
- .Fields("BillItemCode") = "A2" '单据类型(应付冲应收)
- .Fields("BillID") = Lng_BillID '单据ID
- .Fields("BillCode") = Str_BillCode '单据编码
- .Fields("BillDate") = Xtrq '单据日期
- .Fields("BbSsje") = Dbl_CBbje '收回/付款本币金额
- .Fields("ForeignCurrCode") = Rec_AccList.Fields("ForeignCurrCode") '原币编码
- .Fields("AccRate") = Rec_AccList.Fields("AccRate") + 0 '记帐汇率
- .Fields("YbSsje") = Dbl_CWbje '原币收回/付款金额
- .Fields("AccCode") = Rec_AccList.Fields("AccCode") '单据科目编码
- .Fields("AccCodeArAp") = Rec_AccList.Fields("AccCodeArAp") '应收科目编码
- .Fields("DeptCode") = Rec_AccList.Fields("DeptCode") '部门
- .Fields("PersonCode") = Rec_AccList.Fields("PersonCode") '经办人
- .Fields("Digest") = "应付冲应收" '摘要
- .Fields("Maker") = Xtczy '制单人
- .Fields("Checker") = Xtczy '审核人
- '自动核销
- .Fields("YbCancelje") = Dbl_CWbje '原币核销金额
- .Fields("BbCancelje") = Dbl_CBbje '本币核销金额
- .Fields("OverStatus") = 1 '核销完毕
- .Update
- '记录新生成明细帐ID,以在生成凭证时回写凭证号
- Sqlstr = "Update Rp_Cancel Set YFId=" & .Fields("AccListId") & " Where CancelID=" & Lng_CancelId
- Cw_DataEnvi.DataConnect.Execute (Sqlstr)
- End With
- '登记应收/应付总帐
- Str_PSCode = Trim(Rec_AccList.Fields("PSCode") & "")
- Str_DeptCode = Trim(Rec_AccList.Fields("DeptCode") & "")
- Str_PersonCode = Trim(Rec_AccList.Fields("PersonCode") & "")
- Str_ForeignCurrCode = Trim(Rec_AccList.Fields("ForeignCurrCode") & "")
- With Rec_AccSum
- If .State = 1 Then .Close
- .Open "Select * From RP_AccSum Where RpFlag='" & Trim(Rec_AccList.Fields("RPFlag")) & "' And PSCode='" & Str_PSCode & _
- "' 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
- If Not Rec_AccSum.EOF Then
- .Fields("YbSsje") = .Fields("YbSsje") + Dbl_CWbje '本期收回/付款原币金额
- .Fields("YbQmye") = .Fields("YbQcye") + .Fields("YbYsje") - .Fields("YbSsje") '本期期末原币余额
- .Fields("BbSsje") = .Fields("BbSsje") + Dbl_CBbje '本期收回/付款本币金额
- .Fields("BbQmye") = .Fields("BbQcye") + .Fields("BbYsje") - .Fields("BbSsje") '本期期末本币余额
- .Update
- Else
- .AddNew
- .Fields("RPFlag") = Rec_AccList.Fields("RPFlag") '应收应付标识
- .Fields("PSCode") = Str_PSCode '往来单位编码
- .Fields("DeptCode") = Str_DeptCode '部门编码
- .Fields("PersonCode") = Str_PersonCode '个人编码
- .Fields("ForeignCurrCode") = Str_ForeignCurrCode '原币编码
- .Fields("KJYear") = Int_Dqyear '会计年度
- .Fields("Period") = Int_DqPeriod '会计期间
- .Fields("YbSsje") = Dbl_CWbje '本期收回/付款原币金额
- .Fields("YbQmye") = -Dbl_CWbje '本期期末原币余额
- .Fields("BbSsje") = Dbl_CBbje '本期收回/付款本币金额
- .Fields("BbQmye") = -Dbl_CBbje '本期期末本币余额
- .Update
- End If
- End With
- End If
- Next Jsqte
- End With
- Cw_DataEnvi.DataConnect.CommitTrans
- Fun_YsCYf = True
- Exit Function
- Swcwcl:
- Cw_DataEnvi.DataConnect.RollbackTrans
- Tsxx = "核销过程中出现未知错误,程序自动恢复核销前状态!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End Function