+
资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:120k
源码类别:
企业管理
开发平台:
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 BadDebt_FrmReturnList
- BackColor = &H00E9F4FA&
- BorderStyle = 1 'Fixed Single
- Caption = "坏帐收回处理"
- ClientHeight = 6645
- ClientLeft = 675
- ClientTop = 720
- ClientWidth = 10980
- HelpContextID = 20702
- Icon = "坏帐处理_坏帐收回查询列表.frx":0000
- KeyPreview = -1 'True
- LinkTopic = "Form4"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 6645
- ScaleWidth = 10980
- StartUpPosition = 1 '所有者中心
- Begin VB.Timer Timer2
- Interval = 1
- Left = 2910
- Top = 810
- End
- Begin VB.TextBox LrText
- ForeColor = &H00000000&
- Height = 300
- Index = 0
- Left = 1020
- TabIndex = 0
- Text = "0"
- Top = 1500
- Width = 1650
- End
- Begin VB.CommandButton Ydcommand
- Height = 300
- Left = 10680
- Picture = "坏帐处理_坏帐收回查询列表.frx":1042
- Style = 1 'Graphical
- TabIndex = 4
- Top = 990
- Visible = 0 'False
- Width = 300
- End
- Begin VB.TextBox Ydtext
- BackColor = &H80000018&
- BorderStyle = 0 'None
- Height = 330
- Left = 7710
- MultiLine = -1 'True
- TabIndex = 2
- Top = 960
- Visible = 0 'False
- Width = 1185
- End
- Begin VB.Timer Timer1
- Enabled = 0 'False
- Interval = 1
- Left = 9690
- Top = 150
- End
- Begin VB.CommandButton Ydcommand1
- Height = 300
- Left = 10680
- Picture = "坏帐处理_坏帐收回查询列表.frx":13CC
- Style = 1 'Graphical
- TabIndex = 8
- Top = 600
- Visible = 0 'False
- Width = 300
- End
- Begin VB.ComboBox YdCombo
- Height = 300
- Left = 9000
- Style = 2 'Dropdown List
- TabIndex = 3
- Top = 960
- Visible = 0 'False
- Width = 1155
- End
- Begin MSComctlLib.ImageList ImageList1
- Left = 10410
- Top = 1350
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 16
- ImageHeight = 16
- MaskColor = 12632256
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 39
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":1756
- Key = "sz"
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":1AF0
- Key = "dy"
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":1E8A
- Key = "yl"
- EndProperty
- BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":2224
- Key = "xg"
- EndProperty
- BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":25BE
- Key = "zh"
- EndProperty
- BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":2958
- Key = "sh"
- EndProperty
- BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":2CF2
- Key = "bc"
- EndProperty
- BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":308C
- Key = "fq"
- EndProperty
- BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":3426
- Key = "bz"
- EndProperty
- BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":37C0
- Key = "tc"
- EndProperty
- BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":3B5A
- Key = "bcgs"
- EndProperty
- BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":3EF4
- Key = "mrlk"
- EndProperty
- BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":428E
- Key = "xsxm"
- EndProperty
- BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":4628
- Key = "first"
- EndProperty
- BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":49C2
- Key = "prev"
- EndProperty
- BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":4D5C
- Key = "next"
- EndProperty
- BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":50F6
- Key = "last"
- EndProperty
- BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":5490
- Key = "xx"
- EndProperty
- BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":582A
- Key = "define"
- EndProperty
- BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":5BC4
- Key = "exec"
- EndProperty
- BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":5F5E
- Key = "xz"
- EndProperty
- BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":62F8
- Key = "sc"
- EndProperty
- BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":6692
- Key = "sx"
- EndProperty
- BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":6A2C
- Key = "cx"
- EndProperty
- BeginProperty ListImage25 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":6DC6
- Key = "zd"
- EndProperty
- BeginProperty ListImage26 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":7160
- Key = "dz"
- EndProperty
- BeginProperty ListImage27 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":74FA
- Key = "ph"
- EndProperty
- BeginProperty ListImage28 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":7894
- Key = "fz"
- EndProperty
- BeginProperty ListImage29 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":7C2E
- Key = "dw"
- EndProperty
- BeginProperty ListImage30 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":7FC8
- Key = "hf"
- EndProperty
- BeginProperty ListImage31 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":8362
- Key = "pz"
- EndProperty
- BeginProperty ListImage32 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":86FC
- Key = "check"
- EndProperty
- BeginProperty ListImage33 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":8A96
- Key = "qs"
- EndProperty
- BeginProperty ListImage34 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":8E30
- Key = "fullcheck"
- EndProperty
- BeginProperty ListImage35 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":91CA
- Key = "qq"
- EndProperty
- BeginProperty ListImage36 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":9564
- Key = "bcw"
- EndProperty
- BeginProperty ListImage37 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":98FE
- Key = "ye"
- EndProperty
- BeginProperty ListImage38 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":9C98
- Key = "qx"
- EndProperty
- BeginProperty ListImage39 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "坏帐处理_坏帐收回查询列表.frx":A032
- Key = "qqi"
- EndProperty
- EndProperty
- End
- Begin VSFlex8Ctl.VSFlexGrid WglrGrid
- Height = 3345
- Left = 120
- TabIndex = 1
- Top = 2280
- Width = 10680
- _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 = 12640511
- ForeColorFixed = -2147483630
- BackColorSel = -2147483643
- ForeColorSel = -2147483640
- BackColorBkg = -2147483636
- BackColorAlternate= 16777215
- GridColor = -2147483633
- GridColorFixed = -2147483632
- TreeColor = -2147483632
- FloodColor = 192
- SheetBorder = -2147483642
- FocusRect = 1
- HighLight = 1
- AllowSelection = 0 'False
- AllowBigSelection= 0 'False
- AllowUserResizing= 0
- SelectionMode = 0
- GridLines = 1
- GridLinesFixed = 2
- GridLineWidth = 1
- Rows = 5000
- Cols = 10
- FixedRows = 1
- FixedCols = 0
- 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 = -1 'True
- 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
- Begin VSFlex8Ctl.VSFlexGrid HjGrid
- Height = 885
- Left = 0
- TabIndex = 13
- Top = 2400
- Width = 7545
- _cx = 5080
- _cy = 5080
- Appearance = 1
- BorderStyle = 0
- 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 = 14671839
- ForeColor = -2147483640
- BackColorFixed = -2147483633
- ForeColorFixed = -2147483630
- BackColorSel = -2147483643
- ForeColorSel = -2147483640
- BackColorBkg = 16777215
- BackColorAlternate= 14671839
- GridColor = -2147483633
- GridColorFixed = -2147483632
- TreeColor = -2147483632
- FloodColor = 192
- SheetBorder = -2147483642
- FocusRect = 1
- HighLight = 1
- AllowSelection = 0 'False
- AllowBigSelection= 0 'False
- AllowUserResizing= 0
- SelectionMode = 0
- GridLines = 1
- GridLinesFixed = 2
- GridLineWidth = 1
- Rows = 5000
- Cols = 10
- FixedRows = 1
- FixedCols = 0
- 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 = -1 'True
- 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
- End
- Begin MSComctlLib.Toolbar Tlb_Action
- Align = 1 'Align Top
- Height = 555
- Left = 0
- TabIndex = 14
- Top = 0
- Width = 10980
- _ExtentX = 19368
- _ExtentY = 979
- ButtonWidth = 820
- ButtonHeight = 926
- AllowCustomize = 0 'False
- Wrappable = 0 'False
- Appearance = 1
- Style = 1
- ImageList = "ImageList1"
- _Version = 393216
- BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
- NumButtons = 13
- BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Object.Visible = 0 'False
- Caption = "设置"
- Key = "ymsz"
- Object.ToolTipText = "打印页面设置"
- ImageKey = "sz"
- EndProperty
- BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "打印"
- Key = "dy"
- Object.ToolTipText = "打印当前单据或Ctrl+P"
- ImageKey = "dy"
- EndProperty
- BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "预览"
- Key = "yl"
- ImageKey = "yl"
- 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 = "qx"
- ImageKey = "qx"
- EndProperty
- BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "全消"
- Key = "qq"
- ImageKey = "qqi"
- EndProperty
- BeginProperty Button9 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button10 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "凭证"
- Key = "pz"
- ImageKey = "pz"
- EndProperty
- BeginProperty Button11 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Style = 3
- EndProperty
- BeginProperty Button12 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "帮助"
- Key = "bz"
- ImageKey = "bz"
- EndProperty
- BeginProperty Button13 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "退出"
- Key = "fh"
- ImageKey = "tc"
- EndProperty
- EndProperty
- BorderStyle = 1
- Begin MSComctlLib.Toolbar GsToolbar
- Height = 525
- Left = 9270
- TabIndex = 15
- Top = 0
- Width = 1695
- _ExtentX = 2990
- _ExtentY = 926
- ButtonWidth = 1455
- ButtonHeight = 926
- AllowCustomize = 0 'False
- Appearance = 1
- Style = 1
- ImageList = "ImageList1"
- _Version = 393216
- BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
- NumButtons = 2
- BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "保存格式"
- Key = "bcgs"
- ImageKey = "bcgs"
- EndProperty
- BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "默认列宽"
- Key = "hfmrgs"
- ImageKey = "mrlk"
- EndProperty
- EndProperty
- End
- End
- Begin VB.Label Lab_Title
- AutoSize = -1 'True
- BackColor = &H80000018&
- BackStyle = 0 'Transparent
- Caption = "单据标题自动调整"
- BeginProperty Font
- Name = "宋体"
- Size = 15
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000000&
- Height = 300
- Left = 4440
- TabIndex = 12
- Top = 840
- Width = 2520
- End
- Begin VB.Label Lab_BillId
- AutoSize = -1 'True
- BackColor = &H0080C0FF&
- Height = 270
- Left = 7680
- TabIndex = 11
- Top = 600
- Visible = 0 'False
- Width = 2490
- End
- Begin VB.Label Lab_Djclzt
- BackColor = &H0000FFFF&
- Caption = "1"
- ForeColor = &H00808080&
- Height = 255
- Left = 10320
- TabIndex = 10
- Top = 600
- Visible = 0 'False
- Width = 285
- End
- Begin VB.Label Lab_OperStatus
- BackColor = &H000080FF&
- Caption = "1"
- Height = 345
- Left = 10290
- TabIndex = 9
- Top = 960
- Visible = 0 'False
- Width = 345
- End
- Begin VB.Label Lab_Bill
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- ForeColor = &H00000000&
- Height = 225
- Left = 9030
- TabIndex = 7
- Top = 6330
- Width = 735
- End
- Begin VB.Label Lab_Checker
- Appearance = 0 'Flat
- BackColor = &H80000005&
- BackStyle = 0 'Transparent
- ForeColor = &H00000000&
- Height = 225
- Left = 7170
- TabIndex = 6
- Top = 6360
- Width = 735
- End
- Begin VB.Label TsLabel
- Alignment = 1 'Right Justify
- AutoSize = -1 'True
- BackStyle = 0 'Transparent
- Caption = "单据号:"
- Height = 180
- Index = 0
- Left = 240
- TabIndex = 5
- Top = 1560
- Width = 765
- End
- End
- Attribute VB_Name = "BadDebt_FrmReturnList"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '***********************************************************************************************************
- '* 模 块 名 称 :坏帐收回处理
- '* 功 能 描 述 :此功能模块主要完成对已经发生的坏帐进行坏帐收回处理
- '* 程序员姓名 :陈恩宇
- '* 最后修改人 :陈恩宇
- '* 最后修改时间:2001/12/20
- '* 备 注:程序中所有依实际情况自定义部分均用[>> <<]括起
- '*
- '* 1.每次调入外部功能窗体,均要加锁ChangeLock=True,窗体关闭后解锁ChangeLock=false
- '* TextValiLock=True TextValiLock=false
- '*
- '* 2.Lab_OperStatus 用此标签来标识单据录入状态(默认值为1) "1"-浏览 "2"-新增 "3"-修改
- '*
- '* 3.Lab_Djclzt 用此标签来标识单据处理状态(默认值为1) "1"-填制单据 "2"-查询单据列表 "3"-明细帐联查单据
- '*
- '* 4.原则:只要单据能够存盘(无论修改或新增)则其必须接受完整性及有效性规则检查
- '***********************************************************************************************************
- '[以下为根据实际情况设置变量
- '凭证制作需要的变量
- Dim VouchRow As Long '每张凭证内分录的ID值
- Dim EffectVouchId As Long '生成正式凭证的凭证ID
- Dim Jsq_Max As Long '网格的最大记录数
- Dim OperationNum As Long '本次转帐操作批号
- Dim YbJe As Double '原币金额
- Dim BbJe As Double '本币金额
- Dim Ybhj As Double '原币合计
- Dim Bbhj As Double '本币合计
- Dim Int_Kjyear As Integer '当前会计年度
- Dim Int_Period As Integer '会计期间
- Dim AccRate As Double '记帐汇率
- Dim BankBillNo As String '银行票号
- Dim SsCode As String '结算方式
- Dim ForeignCurrCode As String '外币编码
- Dim BillDate As Date '单据日期
- Dim PersonName As String '经办人名称
- Dim CustName As String '客户
- Dim SuppName As String '供应商
- '以上是凭证制作需要的变量
- Dim Bln_BillChange As Boolean '标识单据是否发生改动
- Dim Rec_Query As New ADODB.Recordset '单据组查询结果动态集(保存当前单据组ID)
- Public Str_QueryCondi As String '单据组查询条件(接收单据列表传递查询条件)
- ']
- '以下为固定使用变量(单据)
- Dim BillCode As String '单据设计编码(索引号)
- Dim Var_Bill() As Variant '用来返回单据设计信息
- Dim ReportTitle As String '报表主标题
- Dim Tsxx As String '系统提示信息
- '以下为固定使用变量(网格)
- Dim Cxnrrec As New ADODB.Recordset '显示查询内容动态集
- Dim Dyymctbl As New DY_Dyymsz '打印页面窗体变量
- Dim GridCode As String '显示网格网格代码
- Dim GridInf() As Variant '整个网格设置信息
- Dim Pmbcsjhs As Long '屏幕网格保持数据行数(大于等于1)
- Dim Fzxwghs As Integer '辅助项网格行数(包括合计行)
- Dim Sfxshjwg As Boolean '是否显示合计网格
- Dim Qslz As Long '网格隐藏(非操作显示)列数
- Dim Sjhgd As Double '网格数据行高度
- Dim GridBoolean() As Boolean '网格列信息(布尔型)
- Dim GridStr() As String '网格列信息(字符型)
- Dim GridInt() As Integer '网格列信息(整型)
- Dim Sfblbzkd As Boolean '是否保留帮助宽度(字段提供帮助时,是否为按钮保留空间)
- Dim Dqlrwgh As Long '当前录入数据网格行
- Dim Dqlrwgl As Long '当前录入数据网格列
- Dim Dqlkwgh As Long '刚刚离开网格行(不一定为录入行)
- Dim Dqlkwgl As Long '刚刚离开网格列
- Dim Dqtoprow As Long '当前录入状态时最上端可视行
- Dim Dqleftcol As Long '当前录入状态时最左端可视列
- Dim Zdlrqnr As String '字段录入修改前内容(用来判断内容是否修改)
- Dim Wbkbhlock As Boolean '文本框改变值锁
- Dim changelock As Boolean '网格行列改变控制锁(用来区别用户改变.程序改变)
- Dim Gdtlock As Boolean '滚动条滚动控制(用来区别用户改变.程序改变)
- Dim Yxxpdlock As Boolean '字段有效性判断锁(内容不修改不需进行字段有效性判断)
- Dim Hyxxpdlock As Boolean '行有效性判断锁(字段内容不修改不需进行行有效性判断)
- Dim Valilock As Boolean '文本框失去焦点是否进行有效性控制(TRUE 为锁定*限用网格录入)
- Dim Shsfts As Boolean '删除记录行是否提示
- Dim Szzls As Integer '网格信息数组最大下标值(网格列数-1)
- '以下为固定使用变量(文本框)
- Dim Textvar() As Variant '存储变体型文本框信息
- Dim Textboolean() As Boolean '存储布尔型文本框信息
- Dim Textint() As Integer '存储整型文本框信息
- Dim Textstr() As String '存储字符型文本框信息
- Dim Max_Text_Index As Integer '最大录入文本框索引值
- Dim TextGroupCode As String '文本框录入分组编码
- Dim TextValiLock As Boolean '文本框失去焦点是否进行有效性控制判断
- Dim TextValiJudgeLock() As Boolean '文本框录入有效性判断控制锁
- Dim TextChangeLock As Boolean '文本框内容变换控制锁
- Private Sub Form_KeyPress(KeyAscii As Integer) '控 制 焦 点 转 移
- Dim jdzygs As Integer
- jdzygs = 7 '在单据录入中,此焦点转移控制值一定小于等于文本框个数,否则网格回车键将不支持.
- Select Case KeyAscii
- Case vbKeyReturn
- If Kjjdzy(jdzygs) Then
- KeyAscii = 0
- End If
- Case 39 '屏蔽字符"'"
- KeyAscii = 0
- End Select
- End Sub
- Private Sub Form_Load() '窗 体 装 入
- '初始化各种锁值(Fixed)
- changelock = False '网格行列改变控制锁
- Gdtlock = False '滚动条滚动控制
- Yxxpdlock = True '字段有效性判断锁
- Hyxxpdlock = True '行有效性判断锁
- Wbkbhlock = False '文本框内容改变锁
- '调入单据信息(需要修改BillCode)
- BillCode = "0207"
- Call Sub_ReadBillInfo(BillCode, Me, Var_Bill())
- Lab_Title = Var_Bill(2)
- Lab_Title.Move (Me.Width - Lab_Title.Width) / 2, 800
- '报表编码
- XtReportCode = Var_Bill(5)
- Load Dyymctbl
- '以下为文本框处理程序(Fixed)
- TextGroupCode = Var_Bill(3)
- Call Drwbkxx(TextGroupCode, Textvar(), Textboolean(), Textint(), Textstr()) '读入文本框录入信息
- Call Wbkcsh
- '调入网格并记录一些网格信息(Fixed)
- GridCode = Var_Bill(4) '网格属性编码
- Call BzWgcsh(WglrGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
- Qslz = GridInf(1)
- Sjhgd = GridInf(2)
- Fzxwghs = GridInf(4)
- Sfblbzkd = GridInf(5)
- Shsfts = GridInf(6)
- Sfxshjwg = GridInf(7)
- Szzls = WglrGrid.Cols - 1
- Pmbcsjhs = Int((WglrGrid.Height - WglrGrid.FixedRows * WglrGrid.RowHeight(0)) / Sjhgd) - Fzxwghs - 1
- For jsqte = WglrGrid.FixedRows To WglrGrid.Rows - 1
- WglrGrid.RowHeight(jsqte) = Sjhgd
- Next jsqte
- '初始化合计网格(Fixed)
- Call Cshhjwg
- '单据变动置为False(Fixed)
- Bln_BillChange = False
- End Sub
- Private Sub Sub_Search()
- BadDebt_FrmReturnQuery.Show 1
- If UCase(Trim(BadDebt_FrmReturnQuery.Tag)) = "TRUE" Then
- '生成查询结果
- Call Sub_Query(0)
- Else
- BadDebt_FrmReturnQuery.UnloadCheck.Value = 1
- Unload BadDebt_FrmReturnQuery
- Unload Me
- End If
- End Sub
- Private Sub Form_Unload(Cancel As Integer) '窗体卸载
- '卸载条件窗体
- BadDebt_FrmReturnQuery.UnloadCheck.Value = 1
- Unload BadDebt_FrmReturnQuery
- '卸载打印页面窗体
- Unload Dyymctbl
- '判断单据是否发生变化,并返回相应标识
- If Bln_BillChange Then
- Xtfhcs = "1"
- Else
- Xtfhcs = "0"
- End If
- End Sub
- Private Sub Sub_Query(Int_QueryType As Integer) '生成查询结果(Define)
- '过程参数:Int_QueryType 0-"点确定按钮"查询 1-"刷新"查询
- Dim Rec_Query As New ADODB.Recordset '查询结果动态集
- Dim Coljsq As Long '网格列计数器
- Dim jsqte As Integer '临时动态计数器
- Dim TempForCur As String '临时币别代码
- Dim BanTotal(6) As Single '计算应收总帐合计
- Dim TmpYear As Integer
- Dim Rec_Bill As New ADODB.Recordset
- Dim BillID As Integer
- '录入文本框清除内容
- For jsqte = Max_Text_Index To 0 Step -1
- LrText(jsqte).Tag = ""
- LrText(jsqte).Text = ""
- Next jsqte
- '清空网格内容
- WglrGrid.Clear 1
- '禁止网格刷新动作,为加快网格显示速度(Fixed)
- WglrGrid.Redraw = False
- '以下为自定义部分[
- If Int_QueryType = 0 Then '0-"点确定按钮"查询
- With BadDebt_FrmReturnQuery
- '填充表头部门内容
- BadDebt_FrmReturnList.LrText(1).Text = Trim(.LrText(0).Text)
- BadDebt_FrmReturnList.LrText(1).Tag = Trim(.LrText(0).Tag)
- '生成查询条件
- Str_QueryCondi = " where 1=1 and BadItemCode='60' and YbYsje>YbSsje "
- For jsqte = 1 To 4
- Select Case jsqte
- Case 1 '客户
- If Trim(.LrText(0).Text) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " and PsCode = '" & Trim(.LrText(0).Tag) & "'"
- End If
- Case 2 '币别
- If Trim(.LrText(1).Text) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " And ForeignCurrCode='" & Trim(.LrText(1).Tag) & "'"
- End If
- Case 3 '部门
- If Trim(.LrText(2).Text) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " And DeptCode= '" & Trim(.LrText(2).Tag) & "'"
- End If
- Case 4 '经办人
- If Trim(.LrText(3).Text) <> "" Then
- Str_QueryCondi = Str_QueryCondi & " And PersonCode= '" & Trim(.LrText(3).Tag) & "'"
- End If
- End Select
- Next jsqte
- End With
- Else
- '1-"刷新"查询
- End If
- Sqlstr = "SELECT * FROM Ar_v_BadReturn " & Str_QueryCondi & " Order By BillDate"
- Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- With Rec_Query
- WglrGrid.Rows = WglrGrid.FixedRows
- jsqte = WglrGrid.FixedRows
- Do While Not .EOF
- WglrGrid.AddItem ""
- '[>>自定义填充内容
- WglrGrid.TextMatrix(jsqte, 0) = "*"
- WglrGrid.TextMatrix(jsqte, Sydz("001", GridStr(), Szzls)) = False '选中
- WglrGrid.TextMatrix(jsqte, Sydz("002", GridStr(), Szzls)) = Format(.Fields!DebtDate, "yyyy-mm-dd") '坏帐日期
- If Val(Trim((.Fields!VouchNo) & "")) <> 0 Then
- WglrGrid.TextMatrix(jsqte, Sydz("003", GridStr(), Szzls)) = Trim((.Fields("VouchClassCode") & "")) & "-" & Trim(.Fields!VouchNo) '凭证号
- End If
- WglrGrid.TextMatrix(jsqte, Sydz("004", GridStr(), Szzls)) = Trim((.Fields!ForeignCurrCode) & "") '币别编码
- WglrGrid.TextMatrix(jsqte, Sydz("005", GridStr(), Szzls)) = Trim((.Fields!ForeignCurrName) & "") '币别名称
- WglrGrid.TextMatrix(jsqte, Sydz("007", GridStr(), Szzls)) = Val(.Fields!AccRate) '记帐汇率
- If Val(.Fields!YbYsje) - Val(.Fields!YbSsje) > 0 Then
- WglrGrid.TextMatrix(jsqte, Sydz("006", GridStr(), Szzls)) = Val(.Fields!YbYsje) - Val(.Fields!YbSsje) '坏帐发生金额(原币)
- WglrGrid.TextMatrix(jsqte, Sydz("008", GridStr(), Szzls)) = Val(.Fields!YbYsje) - Val(.Fields!YbSsje) '坏帐收回金额
- WglrGrid.TextMatrix(jsqte, Sydz("009", GridStr(), Szzls)) = Val(.Fields!BbYsje) - Val(.Fields!BbSsje) '坏帐收回金额(本币)
- End If
- WglrGrid.TextMatrix(jsqte, Sydz("010", GridStr(), Szzls)) = Trim((.Fields!AccCodeArAp) & "") '坏帐科目编码
- WglrGrid.TextMatrix(jsqte, Sydz("011", GridStr(), Szzls)) = Trim((.Fields!BadDebtID) & "") '坏帐标识ID
- '<<]
- '设置数据行高度(Fixed)
- WglrGrid.RowHeight(jsqte) = Sjhgd
- '动态集指针加1,同时将计数器加1(Fixed)
- .MoveNext
- jsqte = jsqte + 1
- Loop
- End With
- '将网格刷新解禁(Fixed)
- WglrGrid.Redraw = True
- ']以上为用户自定义部分
- End Sub
- Private Sub Timer2_Timer()
- Me.Timer2.Enabled = False
- Me.Visible = True
- Call Sub_Search
- End Sub
- Private Sub Tlb_Action_ButtonClick(ByVal Button As MSComctlLib.Button) '用户点击工具条
- '屏蔽文本框,下拉组合框有效性判断
- Valilock = True
- '屏蔽网格失去焦点产生的有效性判断
- changelock = True
- Select Case Button.Key
- Case "yl" '预 览
- If Fun_Drfrmyxxpd Then
- BillGridPrint WglrGrid, LrText, GridStr(), Szzls, GridCode, TextGroupCode, XtReportCode, False, , False
- End If
- Case "dy" '打 印
- If Fun_Drfrmyxxpd Then
- Dim yhAnswer As Integer '打印提示
- '用户确认是否打印单据
- Tsxx = "请确认是否打印当前单据?"
- yhAnswer = Xtxxts(Tsxx, 2, 2)
- If yhAnswer = 2 Then
- Exit Sub
- End If
- BillGridPrint WglrGrid, LrText, GridStr(), Szzls, GridCode, TextGroupCode, XtReportCode, True, , False
- End If
- Case "cx" '查 询
- BadDebt_FrmReturnQuery.Show 1
- '根据查询条件调用查询函数
- If UCase(Trim(BadDebt_FrmReturnQuery.Tag)) = "TRUE" Then Call Sub_Query(0)
- Case "pz" '凭 证(保 存)
- If Fun_Drfrmyxxpd Then
- Call Sub_SaveBill
- End If
- Case "qx" '全 选
- Call Sub_WgSelect(0)
- Case "qq" '全 消
- Call Sub_WgSelect(1)
- Case "bz" '帮 助
- Call F1bz
- Case "fh" '退 出
- Unload Me
- End Select
- '解 锁
- Valilock = False
- changelock = False
- TextChangeLock = False
- End Sub
- Private Sub Sub_WgSelect(Xzzt As Integer)
- Dim jsqte As Integer
- Dim TmpJsq As Integer
- '非数据行退出
- If WglrGrid.Rows = WglrGrid.FixedRows Then
- Exit Sub
- End If
- jsqte = WglrGrid.Rows - WglrGrid.FixedRows
- With WglrGrid
- Select Case Xzzt
- Case 0 '当选择全选时选中所有记录
- For TmpJsq = .FixedRows To jsqte
- .TextMatrix(TmpJsq, Sydz("001", GridStr(), Szzls)) = True
- Next TmpJsq
- Case 1 '当选择全选时放弃所有记录
- For TmpJsq = .FixedRows To jsqte
- .TextMatrix(TmpJsq, Sydz("001", GridStr(), Szzls)) = False
- Next TmpJsq
- End Select
- End With
- End Sub
- Private Sub Sub_LrtextStatus(TextEnabled As Boolean) '设置录入文本框状态
- '录入文本框状态设置
- If TextEnabled Then
- For jsqte = Max_Text_Index To 0 Step -1
- '判断文本框是否可编辑
- If Textboolean(jsqte, 5) Then
- LrText(jsqte).Enabled = True
- Else
- LrText(jsqte).Enabled = False
- End If
- Next jsqte
- Else
- For jsqte = Max_Text_Index To 0 Step -1
- LrText(jsqte).Enabled = False
- Next jsqte
- End If
- End Sub
- Private Sub Wbkcl() '文本框录入之前处理(根据实际情况)
- Dim xswbrr As String
- With WglrGrid
- Zdlrqnr = Trim(.Text)
- xswbrr = Trim(.Text)
- If GridBoolean(.Col, 3) Then '列表框录入
- '填充列表框程序
- Call FillCombo(YdCombo, GridStr(.Col, 5), xswbrr, 0)
- Else
- Wbkbhlock = True
- '====以下为用户自定义
- Ydtext.Text = xswbrr
- '====以上为用户自定义
- Wbkbhlock = False
- Ydtext.SelStart = Len(Ydtext.Text)
- End If
- End With
- End Sub
- Private Function sjzdyxxpd(Dqpdwgh As Long, Dqpdwgl As Long) As Boolean '录入数据字段有效性判断,同时进行字段录入事后处理
- '函数参数:Dqpdwgh, Dqpdwgl 当前要判断网格单元所处行列值
- Dim Str_JudgeText As String '临时有效性判断字段内容
- Dim Coljsq As Long '临时列计数器
- Dim RecTemp As New ADODB.Recordset '临时使用动态集
- Dim Sqlstr As String '临时使用查询字符串
- Dim Rate As Double
- Dim ForCode As String
- Dim Dbl_Bbje As Double
- Dim Bln_ConVertFlag As Boolean
- Dim Dbl_AccRate As Double
- With WglrGrid
- '非录入状态或非数据行则其有效性为合法
- If Yxxpdlock Or .Row < .FixedRows Then
- sjzdyxxpd = True
- Exit Function
- End If
- '取得当前要判断字段内容
- Str_JudgeText = Trim(.TextMatrix(Dqpdwgh, Dqpdwgl))
- '根据不同字段进行相应的处理(依据其逻辑编号)
- Select Case GridStr(Dqpdwgl, 1)
- '[>>以下为自定义部分
- Case "008" '收回金额
- Rate = Val(.TextMatrix(Dqpdwgh, Sydz("007", GridStr(), Szzls)))
- ForCode = Trim(.TextMatrix(Dqpdwgh, Sydz("004", GridStr(), Szzls)))
- Call Sub_GetAccRate(ForCode, Bln_ConVertFlag, Dbl_AccRate) '取外币记帐汇率
- If (Not Trim(Str_JudgeText) = "") And (Not Trim(.TextMatrix(Dqpdwgh, Sydz("006", GridStr(), Szzls))) = "") Then
- '1.放置字段有效性判断
- If Val(Str_JudgeText) > Val(.TextMatrix(Dqpdwgh, Sydz("006", GridStr(), Szzls))) Then
- Tsxx = "收回金额不能大于坏帐金额!"
- GoTo Lrcwcl
- End If
- If Bln_ConVertFlag Then
- If YbJe <> 0 And Rate <> 0 Then
- Dbl_Bbje = Val(Format(Val(Str_JudgeText / Rate), "##." + String(Xtjexsws, "0")))
- Else
- Dbl_Bbje = 0
- End If
- Else
- Dbl_Bbje = Val(Format(Val(Str_JudgeText * Rate), "##." + String(Xtjexsws, "0")))
- End If
- .TextMatrix(Dqpdwgh, Sydz("009", GridStr(), Szzls)) = Dbl_Bbje
- Else
- '3.清空相关字段
- .TextMatrix(Dqpdwgh, Sydz("008", GridStr(), Szzls)) = "" '存货名称
- .TextMatrix(Dqpdwgh, Sydz("009", GridStr(), Szzls)) = "" '存货规格型号
- End If
- '<<以上为自定义部分]
- End Select
- '字段录入正确后为零字段清空(Fixed)
- Call Qkwlzd(Dqpdwgh, Dqpdwgl)
- '字段录入正确后进行数据合计(Fixed)
- For Coljsq = Qslz To .Cols - 1
- Call Sjhj(Coljsq)
- Next Coljsq
- '字段有效性判断通过,将字段有效性判断加锁直至再次改变(Fixed)
- sjzdyxxpd = True
- Yxxpdlock = True
- Exit Function
- End With
- Lrcwcl: '录入错误处理
- With WglrGrid
- '给出错误提示信息
- Call Xtxxts(Tsxx, 0, 1)
- '返回网格错误位置(ChangeLock避免再次引发RowColChange有效性判断),装入录入载体
- changelock = True
- .Select Dqpdwgh, Dqpdwgl
- changelock = False
- Call xswbk
- '函数返回False
- sjzdyxxpd = False
- Exit Function
- End With
- End Function
- Private Sub Sub_JoinCount(Lng_CountRow As Long, Lng_CountCol As Long) '当网格列值发生改变时,处理网格列之间的关联计算(可选)
- '过程参数:Lng_CountRow,Lng_CountCol 网格改变内容所处行列值
- With WglrGrid
- Select Case GridStr(Lng_CountCol, 1) '判断网格列对应逻辑编号
- '[>>以下为自定义部分
- '<<以上为自定义部分]
- End Select
- End With
- End Sub
- Private Function Sjhzyxxpd(ByVal Yxxpdh As Long) As Boolean '录入数据行有效性判断,同时进行行处理
- '函数参数:Yxxpdh 要进行有效性判断的网格数据行的行值
- Dim Lrywlz As Long '录入有误网格列值
- Dim RecTemp As New ADODB.Recordset '临时使用动态集
- With WglrGrid
- '判断行为空(行中所有可编辑列数据均为空或为零)和无效数据行则清除当前行
- If Yxxpdh > (.Rows - .FixedRows) Then Exit Function
- If .TextMatrix(Yxxpdh, 0) <> "*" Then
- Sjhzyxxpd = True
- Exit Function
- Else
- If pdhwk(Yxxpdh) And Yxxpdh + 1 <= .Rows - 1 Then
- '当要判断行处于网格末行时才允许删行,否则要进行有效性判断
- If .TextMatrix(Yxxpdh + 1, 0) <> "*" Then
- changelock = True
- .RemoveItem Yxxpdh
- If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
- .AddItem ""
- .RowHeight(.Rows - 1) = Sjhgd
- End If
- changelock = False
- Sjhzyxxpd = True
- Exit Function
- End If
- End If
- End If
- '行没有发生变化则不进行有效性判断
- If Hyxxpdlock Then
- Sjhzyxxpd = True
- Exit Function
- End If
- '[>>以下为自定义部分
- '1.放置行有效性判断程序
- '1.1首先进行单个不能为空或不能为零判断(Fixed)
- For jsqte = Qslz To .Cols - 1
- '字段不能为空
- If GridInt(jsqte, 5) = 1 Then
- If Len(Trim(.TextMatrix(Yxxpdh, jsqte))) = 0 Then
- Tsxx = GridStr(jsqte, 2)
- Lrywlz = jsqte
- GoTo Lrcwcl
- Exit For
- End If
- End If
- '字段不能为零
- If GridInt(jsqte, 5) = 2 Then
- If Val(Trim(.TextMatrix(Yxxpdh, jsqte))) = 0 Then
- Tsxx = GridStr(jsqte, 2)
- Lrywlz = jsqte
- GoTo Lrcwcl
- Exit For
- End If
- End If
- Next jsqte
- '1.2进行其他有效性判断,编写格式同1.1
- '2.放置行处理程序(当数据行通过有效性判断)
- '以上为自定义部分<<]
- End With 'WglrGrid
- '如果此行通过行有效性判断则加锁,直至此行数据再次发生变化
- Sjhzyxxpd = True
- Hyxxpdlock = True
- Exit Function
- Lrcwcl: '录入错误处理
- With WglrGrid
- '给出错误提示信息
- Call Xtxxts(Tsxx, 0, 1)
- '返回网格错误位置 (ChangeLock避免再次引发RowColChange有效性判断), 装入录入载体
- changelock = True
- .Select Yxxpdh, Lrywlz
- changelock = False
- Call xswbk
- '函数返回False
- Sjhzyxxpd = False
- Exit Function
- End With
- End Function
- Private Function Sub_SaveBill() As Boolean '保 存 单 据
- Dim RecTemp As New ADODB.Recordset '临时使用动态集
- Dim Rec_VouchMain As New ADODB.Recordset '单据主表动态集
- Dim Rec_VouchSub As New ADODB.Recordset '单据子表动态集
- Dim Rowjsq As Long '网格行计数器
- Dim Coljsq As Long '网格列计数器
- Dim jsqte As Integer '临时计数器
- Dim Lng_RowCount As Long '有效数据行计数器
- Dim Lrywlz As Long '录入有误列值
- Dim TotalShje As Single '汇总收回金额
- Dim Rec_BadDebt As New ADODB.Recordset '回写坏帐发生动态集
- Dim Rec_AccList As New ADODB.Recordset '回写应收明细帐
- Dim BadID As Integer '坏帐标识ID
- Dim Rec_AccListAdd As New ADODB.Recordset '临时使用动态集(追加记录)
- Dim Rec_AccSum As New ADODB.Recordset '临时动态集(追加总帐)
- Dim Str_PSCode As String '客户编码
- Dim Str_DeptCode As String '部门编码
- Dim Str_PersonCode As String '经办人编码
- Dim Str_ForeignCurrCode As String '币别编码
- Dim Rec_TempPd As New ADODB.Recordset '判断坏帐损失和收款单上的客户是否一致
- Sub_SaveBill = False
- '一.============先对单据内容进行有效性判断==============='
- '坏帐损失客户和收款单的客户是否相同,如果不一致,则不能进行坏帐收回处理
- If Trim((LrText(0).Text) & "") <> "" Then
- Set Rec_TempPd = Cw_DataEnvi.DataConnect.Execute("Select BillCode From RP_AccList Where BillCode='" & Trim((LrText(0).Text) & "") & "' and PsCode='" & Trim((LrText(1).Tag) & "") & "'")
- If Not Rec_TempPd.EOF Then
- If Trim(Rec_TempPd.Fields("BillCode") & "") = "" Then
- Tsxx = "收款单和坏帐损失的客户不一致,请重新输入收款单!!"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(0).SetFocus
- Exit Function
- End If
- End If
- End If
- '先进行字段不能为空或不能为零有效性判断(Fixed)
- For jsqte = 0 To Max_Text_Index
- If Textint(jsqte, 8) = 1 Then '字段不能为空
- If Len(Trim(LrText(jsqte).Text)) = 0 Then
- Tsxx = Textstr(jsqte, 7) & "不能为空!"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(jsqte).SetFocus
- Exit Function
- End If
- Else
- If Textint(jsqte, 8) = 2 Then '字段不能为零
- If Val(Trim(LrText(jsqte).Text)) = 0 Then
- Tsxx = Textstr(jsqte, 7) & "不能为零!"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(jsqte).SetFocus
- Exit Function
- End If
- End If
- End If
- Next jsqte
- '对需要进行事后判断的文本框录入内容进行有效性判断 (Fixed)
- For jsqte = 0 To Max_Text_Index
- If Textint(jsqte, 9) = 0 Or Textint(jsqte, 9) = 2 Then
- If Not TextYxxpd(jsqte) Then
- Call TextShow(jsqte)
- Exit Function
- End If
- End If
- Next jsqte
- '判断币别是否相同,如果不同,则不能进行坏帐收回处理
- With WglrGrid
- For Rowjsq = .FixedRows To .Rows - 1
- If .TextMatrix(Rowjsq, 0) = "*" And .TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)) = True Then
- If Trim(LrText(2).Tag) <> Trim(.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) Then
- Tsxx = "币别不相同,不能进行坏帐收回处理!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End If
- End If
- Next Rowjsq
- End With
- '判断收款金额是否大于收款余额
- TotalShje = 0
- For Rowjsq = WglrGrid.FixedRows To WglrGrid.Rows - 1
- '带*号者为有效数据行(Fixed)
- If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
- Exit For
- Else
- If WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)) = True Then
- TotalShje = TotalShje + WglrGrid.TextMatrix(Rowjsq, Sydz("008", GridStr(), Szzls))
- End If
- End If
- Next Rowjsq
- If Val(LrText(5).Tag) < Val(LrText(5).Text) Then
- Tsxx = "收款金额不能大于收款单上的金额!"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(5).SetFocus
- Exit Function
- End If
- If Val(LrText(5).Text) <> TotalShje Then
- Tsxx = "坏帐收回金额不等于收款金额!"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(5).SetFocus
- Exit Function
- End If
- '判断单据日期是否有效,如果单据日期所在的会计期间已经结帐,则不能保存
- If Not Fun_GetPeriod(CDate(Format(LrText(6).Text, "yyyy-mm-dd")), Int_Kjyear, Int_Period) Then
- LrText(6).SetFocus
- Exit Function
- End If
- '[>>
- '可在此区域写入其他对单据表头内容的有效性判断.
- '<<]
- '[>>下面将对所有有效数据行进行有效性判断
- Lng_RowCount = 0
- With WglrGrid
- For Rowjsq = .FixedRows To .Rows - 1
- '带*号者为有效数据行(Fixed)
- If .TextMatrix(Rowjsq, 0) <> "*" And .TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)) = True Then
- Exit For
- Else
- Lng_RowCount = Lng_RowCount + 1
- End If
- '1.首先进行为空或为零判断(Fixed)
- For jsqte = Qslz To .Cols - 1
- '字段不能为空
- If GridInt(jsqte, 5) = 1 Then
- If Len(Trim(.TextMatrix(Rowjsq, jsqte))) = 0 Then
- Tsxx = GridStr(jsqte, 2)
- Lrywlz = jsqte
- GoTo Lrcwcl
- Exit For
- End If
- End If
- '字段不能为零
- If GridInt(jsqte, 5) = 2 Then
- If Val(Trim(.TextMatrix(Rowjsq, jsqte))) = 0 Then
- Tsxx = GridStr(jsqte, 2)
- Lrywlz = jsqte
- GoTo Lrcwcl
- Exit For
- End If
- End If
- Next jsqte
- '2.判断存货编码是否存在(Define)
- Next Rowjsq
- '单据分录行数不能为零(Fixed)
- If Lng_RowCount = 0 Then
- Tsxx = "没有进行坏帐收回处理,不能保存!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End If
- '[>>
- '此处可以定义整张单据不能通过有效性检查的理由
- '<<]
- End With '网格
- If Sub_Run = False Then
- Exit Function
- End If
- '二.=============如果以上有效性检查均顺利通过,则执行存盘动作============'
- '对存盘进行事务处理(Fixed)
- On Error GoTo Swcwcl
- Cw_DataEnvi.DataConnect.BeginTrans
- '判断单据状态以进行不同处理
- '1.先对单据主表进行处理
- '2.对单据子表进行处理
- '打开单据子表动态集
- If Rec_VouchSub.State = 1 Then Rec_VouchSub.Close
- Rec_VouchSub.Open "Select * From RP_BadDebt Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- '将网格中有效数据行写入单据子表
- For Rowjsq = WglrGrid.FixedRows To WglrGrid.Rows - 1
- If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
- Exit For
- End If
- If WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)) = True Then
- With Rec_VouchSub
- .AddNew
- .Fields("PsCode") = Trim(LrText(1).Tag) '客户编码
- .Fields("BillCode") = Trim(LrText(0).Text) '结算单号
- .Fields("DeptCode") = Trim((LrText(3).Tag) & "") '部门
- .Fields("PersonCode") = Trim((LrText(4).Tag) & "") '经办人
- .Fields("BillDate") = Format(WglrGrid.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls)), "yyyy-mm-dd") '坏帐发生日期
- .Fields("DebtDate") = Format(LrText(6).Text, "yyyy-mm-dd") '坏帐收回日期
- .Fields("KjYear") = Int_Kjyear '会计年度
- .Fields("Period") = Int_Period '会计期间
- .Fields("ForeignCurrCode") = Trim((LrText(2).Tag) & "") '币别
- .Fields("AccRate") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("007", GridStr(), Szzls))) '原币坏帐金额
- .Fields("YbSsje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("008", GridStr(), Szzls))) '汇率
- .Fields("BbSsje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("009", GridStr(), Szzls))) '本币坏帐金额
- .Fields("Digest") = Trim((LrText(7).Text) & "") '摘要
- If Fun_GetAccInformation("AR_baddebtsMothed") = 1 Then
- .Fields("AccCode") = Fun_GetInputCode("AR_BadDebtPrepAccCode") '坏帐准备科目(备抵法)
- Else
- .Fields("AccCode") = Fun_GetInputCode("AR_BadDebtAccCode") '坏帐损失科目(非备抵法)
- End If
- .Fields("AccCodeArAp") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("010", GridStr(), Szzls))) '应收科目编码
- '输出单据类型
- .Fields("BadItemCode") = "61"
- .Update
- End With
- '将坏帐收回金额回写到坏帐文件
- BadID = WglrGrid.TextMatrix(Rowjsq, Sydz("011", GridStr(), Szzls))
- With Rec_BadDebt
- If .State = 1 Then .Close
- .Open "Select * From RP_BadDebt Where BadDebtId=" & BadID, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not Rec_BadDebt.EOF Then
- .Fields("YbSsje") = .Fields("YbSsje") + Rec_VouchSub.Fields("YbSsje") '原币坏帐收回金额
- .Fields("BbSsje") = .Fields("BbSsje") + Rec_VouchSub.Fields("BbSsje") '本币坏帐收回余额
- '判断是否全部收回坏帐
- If Val(.Fields("YbYsje")) = Val(.Fields("YbSsje")) Then
- .Fields("BackFlag") = 1
- End If
- .Update
- End If
- End With
- '将收回坏帐回写到应收明细帐(收款单)
- With Rec_AccList
- If .State = 1 Then .Close
- .Open "Select * From RP_AccList Where BillCode='" & Trim(LrText(0).Text) & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not Rec_AccList.EOF Then
- .Fields("YbCancelje") = .Fields("YbCancelje") + Rec_VouchSub.Fields("YbSsje") '核销原币金额
- .Fields("BbCancelje") = .Fields("BbCancelje") + Rec_VouchSub.Fields("BbSsje") '核销本币金额
- '判断是否全部收回坏帐
- If Val(.Fields("YbSsje")) = Val(.Fields("YbCancelje")) Then
- .Fields("OverStatus") = 1
- End If
- .Update
- End If
- End With
- '根据确定的坏帐收回记录登记到应收明细帐(其它应收)
- With Rec_AccListAdd
- If .State = 1 Then .Close
- .Open "Select * From RP_AccList", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- .AddNew
- .Fields("RPFlag") = "Ar" '应收/应付标识
- .Fields("PsCode") = Trim(Rec_VouchSub.Fields("PsCode")) '客户编码
- .Fields("BillDate") = Xtrq '单据日期
- .Fields("KjYear") = Int_Kjyear '会计年度
- .Fields("Period") = Int_Period '会计期间
- .Fields("BillItemCode") = "61" '单据类型(坏帐损失)
- .Fields("BillID") = 0 '凭证号
- .Fields("BillCode") = 0 '单据号
- .Fields("Digest") = "坏帐收回" '摘要
- .Fields("ForeignCurrCode") = Trim(Rec_VouchSub.Fields("ForeignCurrCode") & "") '币别
- .Fields("AccRate") = Val(Rec_VouchSub.Fields("AccRate")) '汇率
- .Fields("YbYsje") = Val(Rec_VouchSub.Fields("YbSsje")) '原币应收金额
- .Fields("BbYsje") = Val(Rec_VouchSub.Fields("BbSsje")) '本币应收金额
- .Fields("DeptCode") = Trim(Rec_VouchSub.Fields("DeptCode") & "") '部门编码
- .Fields("PersonCode") = Trim(Rec_VouchSub.Fields("PersonCode") & "") '经办人编码
- .Fields("Maker") = Xtczy '制单
- .Fields("Checker") = Xtczy '审核
- .Fields("AccCode") = Trim(Rec_VouchSub.Fields("AccCode") & "") '坏帐准备科目(损失科目)
- .Fields("AccCodeArAp") = Trim(Rec_VouchSub.Fields("AccCodeArAp") & "") '应收科目编码
- '防止重复核销追加核销标识
- .Fields("OverStatus") = 1 '是否核销完毕标识
- .Update
- End With
- '根据确定的坏帐损失登记应收/应付总帐
- Str_PSCode = Trim(Rec_VouchSub.Fields("PSCode") & "")
- Str_DeptCode = Trim(Rec_VouchSub.Fields("DeptCode") & "")
- Str_PersonCode = Trim(Rec_VouchSub.Fields("PersonCode") & "")
- Str_ForeignCurrCode = Trim(Rec_VouchSub.Fields("ForeignCurrCode") & "")
- With Rec_AccSum
- If .State = 1 Then .Close
- .Open "Select * From RP_AccSum Where RpFlag='Ar' And PSCode='" & Str_PSCode & _
- "' And DeptCode='" & Str_DeptCode & "' And PersonCode='" & Str_PersonCode & "' And ForeignCurrCode='" & Str_ForeignCurrCode & "' And kjYear=" & Int_Kjyear & " And Period=" & Int_Period, Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If Not Rec_AccSum.EOF Then
- .Fields("YbYsje") = .Fields("YbYsje") + Rec_VouchSub.Fields("YbSsje") '本期应收/应付原币金额
- .Fields("YbQmye") = .Fields("YbQcye") + .Fields("YbYsje") - .Fields("YbSsje") '本期期末原币余额
- .Fields("BbYsje") = .Fields("BbYsje") + Rec_VouchSub.Fields("BbSsje") '本期应收/应付本币金额
- .Fields("BbQmye") = .Fields("BbQcye") + .Fields("BbYsje") - .Fields("BbSsje") '本期期末本币余额
- .Update
- Else
- .AddNew
- .Fields("RPFlag") = "Ar" '应收应付标识
- .Fields("PSCode") = Str_PSCode '往来单位编码
- .Fields("DeptCode") = Str_DeptCode '部门编码
- .Fields("PersonCode") = Str_PersonCode '个人编码
- .Fields("ForeignCurrCode") = Str_ForeignCurrCode '原币编码
- .Fields("KJYear") = Int_Kjyear '会计年度
- .Fields("Period") = Int_Period '会计期间
- .Fields("YbSsje") = Rec_VouchSub.Fields("YbSsje") '本期应收/应付原币金额
- .Fields("YbQmye") = Rec_VouchSub.Fields("YbYsje") '本期期末原币余额
- .Fields("BbSsje") = Rec_VouchSub.Fields("BbSsje") '本期应收/应付本币金额
- .Fields("BbQmye") = Rec_VouchSub.Fields("BbYsje") '本期期末本币余额
- .Update
- End If
- End With
- End If
- Next Rowjsq
- Cw_DataEnvi.DataConnect.CommitTrans
- Call Sub_Query(0)
- Sub_SaveBill = True
- Tsxx = "数据存盘完毕!"
- Call Xtxxts(Tsxx, 0, 4)
- Exit Function
- Swcwcl: '数据存盘时出现错误
- Cw_DataEnvi.DataConnect.RollbackTrans
- With WglrGrid
- If Err.Number = -2147217887 Then
- Tsxx = "单据中第 " & Trim(Str(Rowjsq - .FixedRows + 1)) & " 条分录录入数据超出允许范围!"
- Call Xtxxts(Tsxx, 0, 1)
- changelock = True
- .Select Rowjsq, Qslz
- WglrGrid.SetFocus
- changelock = False
- Exit Function
- Else
- Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End If
- End With
- Lrcwcl: '录入错误处理(存盘前逐行有效性判断)
- With WglrGrid
- Call Xtxxts("(第 " & Trim(Str(Rowjsq - .FixedRows + 1)) & " 条单据分录)-" & Tsxx, 0, 1)
- changelock = True
- .Select Rowjsq, Lrywlz
- WglrGrid.SetFocus
- changelock = False
- Exit Function
- End With
- End Function
- '[>>===================以下为根据实际业务需要自定义过程区域=============================<<]
- '审核,弃审
- '**************************
- Private Sub GsToolbar_ButtonClick(ByVal Button As MSComctlLib.Button) '表格格式设置(通用)
- Select Case Button.Key
- Case "bcgs" '保存表格格式
- Call Bcwggs(WglrGrid, GridCode, GridStr())
- Case "hfmrgs" '恢复默认格式
- Call Hfmrgs(WglrGrid, GridCode, GridStr())
- End Select
- End Sub
- '[>>===================以上为根据实际业务需要自定义过程区域=============================<<]
- '===================以 下 程 序 为 通 用 部 分 ,一 般 不 需 更 改(程序动作部分)======================='
- Private Sub Sub_AdjustGrid()
- '调 整 网 格
- With WglrGrid
- '加 1 保持一行录入行
- If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
- .Rows = Pmbcsjhs + .FixedRows + Fzxwghs + 1
- For jsqte = .FixedRows To .Rows - 1
- .RowHeight(jsqte) = Sjhgd
- Next jsqte
- End If
- '判断是否有辅助行和录入行,如没有则加行
- Do While .TextMatrix(.Rows - 1 - Fzxwghs, 0) = "*"
- .AddItem ""
- .RowHeight(.Rows - 1) = Sjhgd
- Loop
- End With
- End Sub
- Private Sub Lrzdbz() '录入字段帮助
- If Not Ydcommand.Visible Then
- Exit Sub
- End If
- With WglrGrid
- Valilock = True
- '处理通用部分
- changelock = True '调入另外窗体必须加锁
- Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(Ydtext.Text))
- changelock = False
- If Len(Xtfhcs) <> 0 Then
- If GridInt(.Col, 7) = 0 Then
- Ydtext.Text = Xtfhcs
- Else
- Ydtext.Text = Xtfhcsfz
- End If
- End If
- Valilock = False
- If Ydtext.Visible Then
- Ydtext.SetFocus
- End If
- End With
- End Sub
- Private Sub Cshhjwg() '初始化合计网格(*对合计网格来说,录入网格为容器)
- With HjGrid
- '是否显示合计网格
- If Not Sfxshjwg Then
- .Visible = False
- Exit Sub
- Else
- .Visible = True
- End If
- '设置网格相关属性
- .Enabled = False
- .Appearance = flexFlat
- .BorderStyle = flexBorderNone
- .ScrollBars = flexScrollBarNone
- .Width = WglrGrid.Width
- .FixedRows = 0
- .Rows = 1
- .Cols = WglrGrid.Cols
- .LeftCol = WglrGrid.LeftCol
- .TextMatrix(0, Qslz) = "合 计"
- For jsqte = 0 To WglrGrid.Cols - 1
- .ColHidden(jsqte) = WglrGrid.ColHidden(jsqte)
- .ColWidth(jsqte) = WglrGrid.ColWidth(jsqte)
- .ColAlignment(jsqte) = WglrGrid.ColAlignment(jsqte)
- .ColFormat(jsqte) = WglrGrid.ColFormat(jsqte)
- Next jsqte
- .ColAlignment(Qslz) = flexAlignCenterTop
- For jsqte = .FixedRows To .Rows - 1
- .RowHeight(jsqte) = .Height / .Rows
- Next jsqte
- '程序自动调整网格高度(自动设置为网格剩余高度+辅助项网格行数(默认为1)*数据行高度)、并设置其位置信息
- .Height = Fzxwghs * Sjhgd + ((WglrGrid.Height - WglrGrid.FixedRows * WglrGrid.RowHeight(0)) Mod Sjhgd)
- .RowHeight(0) = .Height
- .Move 0, WglrGrid.Height - .Height, WglrGrid.Width, .Height
- End With
- End Sub
- Private Sub Form_Resize() '窗体大小发生变化时,重新显示文本框
- Call Cxxswbk
- End Sub
- Private Function Fun_Drfrmyxxpd() As Boolean '调入其它窗体或功能产生的有效性判断(包括数据回写)
- Fun_Drfrmyxxpd = True
- With WglrGrid
- '如果当前网格处于编辑状态,则先进行数据回写再进行有效性判断
- If Ydtext.Visible Or YdCombo.Visible Then
- Call Lrsjhx
- If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
- Fun_Drfrmyxxpd = False
- Exit Function
- End If
- End If
- '进行行有效性判断
- If Not Sjhzyxxpd(.Row) Then
- Fun_Drfrmyxxpd = False
- Exit Function
- End If
- End With
- End Function
- Private Sub WglrGrid_AfterUserResize(ByVal Row As Long, ByVal Col As Long) '调整列宽
- If HjGrid.Visible Then
- With HjGrid
- .ColWidth(Col) = WglrGrid.ColWidth(Col)
- End With
- End If
- End Sub
- Private Sub WglrGrid_EnterCell() '显示当前数据行相关信息
- With WglrGrid
- If .Row >= .FixedRows Then
- '[>>
- '此处可以填写显示与此网格行相关信息
- '<<]
- End If
- End With
- End Sub
- Private Sub WglrGrid_GotFocus() '网格得到焦点
- '网格得到焦点,如果当前选择行为非数据行
- '则调整当前焦点至有效数据行
- With WglrGrid
- If .Row < .FixedRows And .Rows > .FixedRows Then
- changelock = True
- .Select .FixedRows, .Col
- changelock = False
- End If
- If .Col < Qslz Then
- changelock = True
- .Select .Row, Qslz
- changelock = False
- End If
- End With
- End Sub
- Private Sub WglrGrid_LostFocus() '录入网格失去焦点
- '用以屏蔽调用其它窗体时发生网格失去焦点事件
- If changelock Then
- Exit Sub
- End If
- '引发网格RowcolChange事件
- With WglrGrid
- If Not (Ydtext.Visible Or YdCombo.Visible) Then
- .Select 0, 0
- End If
- End With
- End Sub
- Private Sub WglrGrid_AfterScroll(ByVal OldTopRow As Long, ByVal OldLeftCol As Long, ByVal NewTopRow As Long, ByVal NewLeftCol As Long) '限制用户在录入过程中滚动鼠标
- If Gdtlock Then
- Exit Sub
- End If
- With WglrGrid
- If Ydtext.Visible Or YdCombo.Visible Then
- Gdtlock = True
- .TopRow = Dqtoprow
- .LeftCol = Dqleftcol
- Gdtlock = False
- Exit Sub
- End If
- HjGrid.LeftCol = .LeftCol
- End With
- End Sub
- Private Sub WglrGrid_LeaveCell() '离开单元格
- If changelock Then
- Exit Sub
- End If
- '记录刚刚离开网格单元的行列值
- Dqlkwgh = WglrGrid.Row
- Dqlkwgl = WglrGrid.Col
- '判断是否需要录入数据回写
- If Not (Ydtext.Visible Or YdCombo.Visible) Then
- Exit Sub
- End If
- Call Lrsjhx
- End Sub
- Private Sub WglrGrid_RowColChange() '网格录入行列发生变化时,进行有效性判断
- Valilock = True '屏蔽文本框失去焦点进行有效性判断
- With WglrGrid
- If changelock Then
- Exit Sub
- End If
- If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
- Exit Sub
- End If
- If .Row <> Dqlkwgh Then
- If Not Sjhzyxxpd(Dqlkwgh) Then
- Exit Sub
- End If
- End If
- End With
- Call fhyxh
- Call Xldql
- End Sub
- Private Sub WglrGrid_DblClick() '鼠标双击网格显示文本框
- If WglrGrid.Row < WglrGrid.FixedRows Then
- Exit Sub
- Else
- If WglrGrid.Col <> Sydz("001", GridStr(), Szzls) And WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = False Then Exit Sub
- End If
- With WglrGrid
- Call xswbk
- End With
- If Trim(WglrGrid.TextMatrix(WglrGrid.Row, 0)) = "*" Then
- If WglrGrid.Col = Sydz("001", GridStr(), Szzls) Then
- If WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) Then
- WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = False
- Else
- WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = True
- End If
- End If
- Else
- WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = True
- End If
- End Sub
- Private Sub Ycwbk() '隐藏文本框,帮助按钮,列表组合框
- Valilock = True
- Ydtext.Visible = False
- YdCombo.Visible = False
- Ydcommand.Visible = False
- End Sub
- Private Sub YdCombo_KeyDown(KeyCode As Integer, Shift As Integer) '列表框移动
- With WglrGrid
- Select Case KeyCode
- Case vbKeyEscape 'ESC 键放弃录入
- Valilock = True
- .SetFocus
- Call Ycwbk
- Valilock = False
- Case vbKeyReturn '回 车 键 =13
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- Rowjsq = .Row
- Coljsq = .Col + 1
- If Coljsq > .Cols - 1 Then
- If Rowjsq < .Rows - 1 Then
- Rowjsq = Rowjsq + 1
- End If
- Coljsq = Qslz
- End If
- Do While Rowjsq <= .Rows - 1
- If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
- Coljsq = Coljsq + 1
- If Coljsq > .Cols - 1 Then
- Rowjsq = Rowjsq + 1
- Coljsq = Qslz
- End If
- Else
- Exit Do
- End If
- Loop
- .Select Rowjsq, Coljsq
- Case vbKeyLeft '左 箭 头 =37
- If .Col - 1 = Qslz Then
- If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
- GoTo jzzx
- End If
- End If
- If .Col > Qslz Then
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- Coljsq = .Col - 1
- Do While Coljsq > Qslz
- If Coljsq - 1 = Qslz Then
- If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
- GoTo jzzx
- End If
- End If
- If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
- Coljsq = Coljsq - 1
- Else
- Exit Do
- End If
- Loop
- .Select .Row, Coljsq
- End If
- Case vbKeyRight '右 箭 头 =39
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- Rowjsq = .Row
- Coljsq = .Col + 1
- If Coljsq > .Cols - 1 Then
- If Rowjsq < .Rows - 1 Then
- Rowjsq = Rowjsq + 1
- End If
- Coljsq = Qslz
- End If
- Do While Rowjsq <= .Rows - 1
- If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
- Coljsq = Coljsq + 1
- If Coljsq > .Cols - 1 Then
- Rowjsq = Rowjsq + 1
- Coljsq = Qslz
- End If
- Else
- Exit Do
- End If
- Loop
- .Select Rowjsq, Coljsq
- Case Else
- End Select
- jzzx:
- End With
- End Sub
- Private Sub YdCombo_LostFocus()
- With WglrGrid '因为选中网格会先发生Rowcolchange事件置Valiock
- If Not Valilock Then '为TRUE
- Call Lrsjhx
- If Not Sjhzyxxpd(Dqlrwgh) Then
- Exit Sub
- End If
- End If
- End With
- End Sub
- Private Sub Ydcommand_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
- Call Lrzdbz
- End Sub
- Private Sub ydtext_KeyDown(KeyCode As Integer, Shift As Integer)
- Dim Rowjsq As Long, Coljsq As Long
- With WglrGrid
- Select Case KeyCode
- Case vbKeyF2
- Call Lrzdbz
- Case vbKeyEscape 'ESC 键放弃录入
- Valilock = True
- Call Ycwbk
- .SetFocus
- Case vbKeyReturn '回 车 键 =13
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- Rowjsq = .Row
- Coljsq = .Col + 1
- If Coljsq > .Cols - 1 Then
- If Rowjsq < .Rows - 1 Then
- Rowjsq = Rowjsq + 1
- End If
- Coljsq = Qslz
- End If
- Do While Rowjsq <= .Rows - 1
- If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
- Coljsq = Coljsq + 1
- If Coljsq > .Cols - 1 Then
- Rowjsq = Rowjsq + 1
- Coljsq = Qslz
- End If
- Else
- Exit Do
- End If
- Loop
- If Rowjsq <= .Rows - 1 Then
- .Select Rowjsq, Coljsq
- End If
- Case vbKeyUp '上 箭 头 =38
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- If .Row > .FixedRows Then
- .Row = .Row - 1
- End If
- Case vbKeyDown '下 箭 头 =40
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- If .Row < .Rows - 1 Then
- .Row = .Row + 1
- End If
- Case vbKeyLeft '左 箭 头 =37
- If .Col - 1 = Qslz Then
- If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
- GoTo jzzx
- End If
- End If
- If Ydtext.SelStart = 0 And .Col > Qslz Then
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- Coljsq = .Col - 1
- Do While Coljsq > Qslz
- If Coljsq - 1 = Qslz Then
- If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
- GoTo jzzx
- End If
- End If
- If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
- Coljsq = Coljsq - 1
- Else
- Exit Do
- End If
- Loop
- .Select .Row, Coljsq
- End If
- jzzx:
- Case vbKeyRight '右 箭 头 =39
- wblong = Len(Ydtext.Text)
- If (Ydtext.SelStart = wblong Or Ydtext.SelLength = wblong) Then
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- Rowjsq = .Row
- Coljsq = .Col + 1
- If Coljsq > .Cols - 1 Then
- If Rowjsq < .Rows - 1 Then
- Rowjsq = Rowjsq + 1
- End If
- Coljsq = Qslz
- End If
- Do While Rowjsq <= .Rows - 1
- If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
- Coljsq = Coljsq + 1
- If Coljsq > .Cols - 1 Then
- Rowjsq = Rowjsq + 1
- Coljsq = Qslz
- End If
- Else
- Exit Do
- End If
- Loop
- .Select Rowjsq, Coljsq
- End If
- Case Else
- End Select
- End With
- End Sub
- Private Sub ydtext_KeyPress(KeyAscii As Integer) '录入字符事中控制
- Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
- If KeyAscii <> 0 Then
- Call Xyxhbz(Dqlrwgh)
- End If
- End Sub
- Private Sub ydtext_Change() '录入事中变化处理
- '防止程序改变但不进行处理
- If Wbkbhlock Then
- Exit Sub
- End If
- With WglrGrid
- '限制字段录入长度
- Wbkbhlock = True
- Call TextChangeLimit(Ydtext, GridInt(.Col, 1)) '去掉无效字符
- Select Case GridInt(.Col, 1)
- Case 8, 11 '金额型
- Call Sjgskz(Ydtext, Xtjezws - Xtjexsws - 1, Xtjexsws)
- Case 9, 12 '数量型
- Call Sjgskz(Ydtext, Xtslzws - Xtslxsws - 1, Xtslxsws)
- Case 10 '单价型
- Call Sjgskz(Ydtext, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
- Case Else '其他类型
- If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
- Call Sjgskz(Ydtext, GridInt(.Col, 3), GridInt(.Col, 4))
- End If
- End Select
- Wbkbhlock = False
- End With
- End Sub
- Private Sub ydtext_LostFocus() '如果由于选中网格之外的控件而发生有效性判断(选中网格会先发生Rowcolchange事件置Valiock为TRUE)
- With WglrGrid
- If Not Valilock Then
- Call Lrsjhx
- If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
- Exit Sub
- End If
- If Not Sjhzyxxpd(Dqlrwgh) Then
- Exit Sub
- End If
- End If
- End With
- End Sub
- Private Sub xswbk() '在当前选中单元显示文本框,列表框,帮助按钮(通用)
- Dim Wbkpy As Integer, Wbkpy1 As Integer '文本框偏移量
- '当某种条件成立时禁止文本框激活使单据处于录入状态
- If Not Fun_AllowInput Then
- Exit Sub
- End If
- '显示文本框前返回有效行列(解决滚动条问题)
- Call Xldqh
- Call Xldql
- '隐藏文本框,帮助按钮,列表组合框
- Call Ycwbk
- With WglrGrid
- Dqlrwgh = .Row
- Dqlrwgl = .Col
- If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
- Exit Sub
- End If
- Wbkpy = 30
- Wbkpy1 = 15
- On Error Resume Next
- If GridBoolean(.Col, 3) Then
- YdCombo.Left = .CellLeft + .Left + Wbkpy
- YdCombo.Top = .CellTop + .Top + Wbkpy
- YdCombo.Width = .CellWidth - Wbkpy1
- Call Wbkcl
- YdCombo.Visible = True
- YdCombo.SetFocus
- Ydcommand.Visible = False
- Ydtext.Visible = False
- Else
- If GridBoolean(.Col, 2) Then
- Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
- Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
- Ydcommand.Visible = True
- Else
- Ydcommand.Visible = False
- End If
- Ydtext.Left = .CellLeft + .Left + Wbkpy
- Ydtext.Top = .CellTop + .Top + Wbkpy
- If Ydcommand.Visible Then
- If Sfblbzkd Then
- Ydtext.Width = .CellWidth - Ydcommand.Width
- Else
- Ydtext.Width = .CellWidth - Wbkpy1
- End If
- Else
- Ydtext.Width = .CellWidth - Wbkpy1
- End If
- Ydtext.Height = .CellHeight - Wbkpy1
- If GridInt(.Col, 2) <> 0 Then
- Ydtext.MaxLength = GridInt(.Col, 2)
- Else
- Ydtext.MaxLength = 3000
- End If
- Call Wbkcl
- Ydtext.Visible = True
- Ydtext.SetFocus
- End If
- Dqtoprow = .TopRow
- Dqleftcol = .LeftCol
- '重置锁值
- Valilock = False
- Wbkbhlock = False
- End With
- End Sub
- Private Function Fun_AllowInput() As Boolean '当某种条件成立时禁止文本框激活使单据处于录入状态
- '如果单据操作状态为浏览状态则不能显示录入载体(通用)
- ' If Trim(Lab_OperStatus.Caption) = "1" Then
- ' Exit Function
- ' End If
- '[>>
- '此处可以填写禁止文本框激活使单据处于录入状态的理由
- If WglrGrid.Row >= WglrGrid.FixedRows Then
- If WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = False Then
- Exit Function
- End If
- End If
- '<<]
- Fun_AllowInput = True
- End Function
- Private Sub Cxxswbk() 'Formresize中重新显示文本框,列表框,帮助按钮(通用)
- Dim Wbkpy As Integer, Wbkpy1 As Integer
- Wbkpy = 30
- Wbkpy1 = 15
- With WglrGrid
- If YdCombo.Visible Then
- YdCombo.Left = .CellLeft + .Left + Wbkpy
- YdCombo.Top = .CellTop + .Top + Wbkpy
- YdCombo.Width = .CellWidth - Wbkpy1
- End If
- If Ydcommand.Visible Then
- Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
- Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
- End If
- If Ydtext.Visible Then
- If Ydcommand.Visible Then
- If Sfblbzkd Then
- Ydtext.Width = .CellWidth - Ydcommand.Width
- Else
- Ydtext.Width = .CellWidth - Wbkpy1
- End If
- Else
- Ydtext.Width = .CellWidth - Wbkpy1
- End If
- Ydtext.Left = .CellLeft + .Left + Wbkpy
- Ydtext.Top = .CellTop + .Top + Wbkpy
- Ydtext.Height = .CellHeight - Wbkpy1
- End If
- End With
- End Sub
- Private Sub Lrsjhx() '文本框录入数据回写
- With WglrGrid
- If YdCombo.Visible Then
- .Text = Trim(YdCombo.Text)
- End If
- If Ydtext.Visible Then
- .Text = Trim(Ydtext.Text)
- End If
- '(如果字段录入内容发生变化,则打开有效性判断锁)
- If Zdlrqnr <> Trim(.Text) Then
- Yxxpdlock = False
- Hyxxpdlock = False
- End If
- '如果字段录入内容不为空则写数据行有效性标志
- If Len(Trim(.Text)) <> 0 Then
- Call Xyxhbz(.Row)
- End If
- '隐藏文本框,帮助按钮,列表组合框
- Call Ycwbk
- End With
- End Sub
- Private Sub WglrGrid_KeyDown(KeyCode As Integer, Shift As Integer) '网格录入增行,删行快捷键
- '如果单据操作状态为浏览状态则不能显示录入载体
- If Trim(Lab_OperStatus.Caption) = "1" Then
- Exit Sub
- End If
- Select Case KeyCode
- Case vbKeyF2 '按F2键参照
- Call xswbk
- Call Lrzdbz
- Case vbKeyDelete '删行
- Call Scdqfl
- Case vbKeyInsert '增行
- Call zjlrfl
- End Select
- End Sub
- Private Sub WglrGrid_KeyPress(KeyAscii As Integer) '网格接受键盘录入
- '当某种条件成立时禁止文本框激活使单据处于录入状态
- If Not Fun_AllowInput Then
- Exit Sub
- End If
- With WglrGrid
- '屏 蔽 回 车 键
- If KeyAscii = vbKeyReturn Then
- KeyAscii = 0
- Rowjsq = .Row
- Coljsq = .Col + 1
- If Coljsq > .Cols - 1 Then
- If Rowjsq < .Rows - 1 Then
- Rowjsq = Rowjsq + 1
- End If
- Coljsq = Qslz
- End If
- Do While Rowjsq <= .Rows - 1
- If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
- Coljsq = Coljsq + 1
- If Coljsq > .Cols - 1 Then
- Rowjsq = Rowjsq + 1
- Coljsq = Qslz
- End If
- Else
- Exit Do
- End If
- Loop
- If Rowjsq <= .Rows - 1 Then
- .Select Rowjsq, Coljsq
- End If
- Exit Sub
- End If
- '如果当前行小于等于固定行则退出
- If WglrGrid.Row < WglrGrid.FixedRows Then
- Exit Sub
- Else
- If WglrGrid.Col <> Sydz("001", GridStr(), Szzls) And WglrGrid.TextMatrix(WglrGrid.Row, Sydz("001", GridStr(), Szzls)) = False Then Exit Sub
- End If
- '接受用户录入
- Select Case KeyAscii
- Case 0 To 32 '用户输入KeyAscii为0-32的键 如空格
- '显示录入载体
- Call xswbk
- Case Else
- '防止非编辑字段SendKeys()出现死循环
- If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
- Exit Sub
- End If
- '如果此字段为列表框录入则调入相应列表框
- If GridBoolean(.Col, 3) Then
- '列表框录入
- Call xswbk
- Else
- Ydtext.Text = ""
- '录入限制
- Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
- If KeyAscii = 0 Then
- Exit Sub
- End If
- '如果录入字符有效则写有效行数据标志
- Call Xyxhbz(.Row)
- Call xswbk
- Ydtext.Text = ""
- Valilock = True
- SendKeys Chr(KeyAscii), True
- DoEvents
- Valilock = False
- End If
- End Select
- End With
- End Sub
- Private Sub zjlrfl() '增加录入分录
- With WglrGrid
- If Not (Ydtext.Visible Or YdCombo.Visible) Then
- If Not Fun_Drfrmyxxpd Then
- Exit Sub
- End If
- Else
- Exit Sub
- End If
- If .Row < .FixedRows Then
- Exit Sub
- End If
- .AddItem "", .Row
- .RowHeight(.Row) = Sjhgd
- If .Row <> .Rows - 1 Then
- If .TextMatrix(.Row + 1, 0) = "*" Then
- .TextMatrix(.Row, 0) = "*"
- Else
- .RemoveItem .Rows - 1
- End If
- End If
- Call Xldqh
- Call Xldql
- Hyxxpdlock = False
- End With
- End Sub
- Private Sub Scdqfl() '删除当前分录
- Dim Answer As Integer, Scqwghz As Long, Scqwglz As Long, Hjlzte As Long, Sflrzt As Boolean
- With WglrGrid
- Scqwghz = .Row
- Scqwglz = .Col
- If .TextMatrix(.Row, 0) = "*" Then
- '判断是否为录入状态
- If Ydtext.Visible Or YdCombo.Visible Then
- Sflrzt = True
- Validate = True
- Call Lrsjhx
- Validate = False
- End If
- Call Xldqh
- changelock = True
- .Select .Row, 0
- changelock = False
- If Shsfts Then
- .Cell(flexcpBackColor, .Row, Qslz, .Row, .Cols - 1) = QBColor(12)
- Tsxx = "请确认是否删除当前记录?"
- yhAnswer = Xtxxts(Tsxx, 2, 2)
- If yhAnswer = 2 Then
- .Cell(flexcpBackColor, .Row, Qslz, .Row, .Cols - 1) = &H80000005
- changelock = True
- .Select Scqwghz, Scqwglz
- changelock = False
- '如为录入状态,则恢复录入
- If Sflrzt Then
- Call xswbk
- End If
- Exit Sub
- End If
- End If
- .RemoveItem .Row
- If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
- .AddItem ""
- .RowHeight(.Rows - 1) = Sjhgd
- End If
- changelock = True
- .Select .Row, Scqwglz
- changelock = False
- '重新计算合计数据
- For Hjlzte = Qslz To .Cols - 1
- Call Sjhj(Hjlzte)
- Next Hjlzte
- End If
- End With
- End Sub
- Private Sub Sjhj(Hjwgl As Long) '网格列数据合计
- Dim Hjjg As Double
- If Not GridBoolean(Hjwgl, 4) Then
- Exit Sub
- End If
- With WglrGrid
- Hjjg = 0
- For jsqte = .FixedRows To .Rows - 1
- If .TextMatrix(jsqte, 0) = "*" Then
- Hjjg = Hjjg + Val(.TextMatrix(jsqte, Hjwgl))
- End If
- Next jsqte
- If GridBoolean(Hjwgl, 5) And Hjjg = 0 Then
- HjGrid.TextMatrix(0, Hjwgl) = ""
- Else
- HjGrid.TextMatrix(0, Hjwgl) = Hjjg
- End If
- End With
- End Sub
- Private Sub Qkwlzd(sjh As Long, Sjl As Long) '清空为零字段
- If Not GridBoolean(Sjl, 5) Then
- Exit Sub
- End If
- With WglrGrid
- If Val(Trim(.TextMatrix(sjh, Sjl))) = 0 Then
- .TextMatrix(sjh, Sjl) = ""
- End If
- End With
- End Sub
- Private Sub fhyxh() '返回录入数据有效行,同时让得到焦点网格可见
- With WglrGrid
- If .Row >= .FixedRows Then
- If .TextMatrix(.Row, 0) <> "*" Then
- For Rowjsq = .FixedRows To .Rows - 1
- If .TextMatrix(Rowjsq, 0) <> "*" Then
- Exit For
- End If
- Next Rowjsq
- If Rowjsq <= .Rows - 1 Then
- changelock = True
- .Select Rowjsq, .Col
- changelock = False
- Else
- changelock = True
- .Select .Rows - 1, .Col
- changelock = False
- End If
- End If
- Call Xldqh
- End If
- End With
- End Sub
- Private Sub Xldqh() '显露当前行
- Dim Toprowte As Long
- With WglrGrid
- Toprowte = 0
- Do While .CellTop + .RowHeight(.Row) + Fzxwghs * Sjhgd > .Height And .TopRow <> Toprowte
- Toprowte = .TopRow
- .TopRow = .TopRow + 1
- Loop
- Toprowte = 0
- Do While .CellTop < .FixedRows * .RowHeight(0) And .TopRow <> Toprowte
- Toprowte = .TopRow
- If .TopRow > 1 Then
- .TopRow = .TopRow - 1
- End If
- Loop
- End With
- End Sub
- Private Sub Xldql() '显露当前列
- Dim Leftcolte As Long
- With WglrGrid
- If .Col >= Qslz And .Col >= .FixedCols Then
- If .LeftCol > .Col Then
- .LeftCol = .Col
- End If
- Leftcolte = 0
- Do While .CellLeft + .CellWidth > .Width And .LeftCol <> Leftcolte
- Leftcolte = .LeftCol
- .LeftCol = .LeftCol + 1
- Loop
- End If
- End With
- End Sub
- Private Function pdhwk(sjh As Long) '判断网格行是否为空行(所有录入字段均为空*非录入字段除外)
- With WglrGrid
- For Coljsq = Qslz To .Cols - 1
- If Len(Trim(.TextMatrix(sjh, Coljsq))) <> 0 And GridBoolean(Coljsq, 1) Then
- pdhwk = False
- Exit Function
- End If
- Next Coljsq
- pdhwk = True
- End With
- End Function
- Private Sub Xyxhbz(sjh As Long) '写行有效性标志,并判断是否增行
- With WglrGrid
- If .TextMatrix(sjh, 0) = "*" Then
- Exit Sub
- End If
- .TextMatrix(sjh, 0) = "*"
- If sjh >= .Rows - Fzxwghs - 1 Then
- .AddItem ""
- .RowHeight(.Rows - 1) = Sjhgd
- End If
- End With
- End Sub
- '*****************************以下为文本框录入处理程序(固定不变部分)*******************************'
- Private Sub Wbklrwbcl(Index As Integer) '文本框录入事后处理程序
- Dim RecTemp As New ADODB.Recordset
- Dim TempJsq As Integer
- '以下为依据实际情况自定义部分[
- '在此填写文本框录入事后处理程序
- If Trim(LrText(0).Text) <> "" Then
- Select Case Index
- Case 0
- Sqlstr = "SELECT a.*,b.DeptName,c.PersonName,d.ForeignCurrName,(a.YbSsje-a.YbCancelje) skje " & _
- " FROM RP_AccList a LEFT OUTER JOIN Gy_Department b ON a.DeptCode = b.DeptCode " & _
- " LEFT OUTER JOIN GY_Person c ON a.PersonCode=c.PersonCode LEFT OUTER JOIN GY_ForeignCurrency d " & _
- " ON a.ForeignCurrCode=d.ForeignCurrCode Where BillCode='" & Trim(LrText(0).Text) & "'and " & _
- " PsCode='" & Trim((LrText(1).Tag) & "") & "' and a.YbSsje>a.YbCancelje "
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If Not RecTemp.EOF Then
- LrText(2).Text = Trim(RecTemp.Fields("ForeignCurrName") & "") '币别编码
- LrText(2).Tag = Trim(RecTemp.Fields("ForeignCurrCode") & "") '币别
- LrText(3).Text = Trim(RecTemp.Fields("DeptName") & "") '部门名称
- LrText(3).Tag = Trim(RecTemp.Fields("DeptCode") & "") '部门编码
- LrText(4).Text = Trim(RecTemp.Fields("PersonName") & "") '经办人编码
- LrText(4).Tag = Trim(RecTemp.Fields("PersonCode") & "") '经办人
- LrText(5).Text = Val(RecTemp.Fields("skje")) '收款金额
- LrText(5).Tag = Val(RecTemp.Fields("skje")) '原始收款金额
- LrText(6).Text = Format(RecTemp.Fields("BillDate"), "yyyy-mm-dd") '收款日期
- Else
- '清空文本框
- For TempJsq = 2 To 6
- LrText(TempJsq).Text = ""
- LrText(TempJsq).Tag = ""
- Next TempJsq
- End If
- End Select
- Else
- '如果收款单为空,则清空文本框
- For TempJsq = 2 To 6
- LrText(TempJsq).Text = ""
- LrText(TempJsq).Tag = ""
- Next TempJsq
- End If
- ']以上为依据实际情况自定义部分
- End Sub
- Private Sub LrText_Change(Index As Integer)
- '屏蔽程序改变控制
- If TextChangeLock Then
- Exit Sub
- End If
- TextValiJudgeLock(Index) = False '打开有效性判断锁
- '限制字段录入长度
- TextChangeLock = True '加锁(防止执行Lrtext_Change)
- Call TextChangeLimit(LrText(Index), Textint(Index, 1)) '去掉无效字符
- Select Case Textint(Index, 1)
- Case 8, 11 '金额型
- Call Sjgskz(LrText(Index), Xtjezws - Xtjexsws - 1, Xtjexsws)
- Case 9, 12 '数量型
- Call Sjgskz(LrText(Index), Xtslzws - Xtslxsws - 1, Xtslxsws)
- Case 10 '单价型
- Call Sjgskz(LrText(Index), Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
- Case Else '其他小数类型控制
- If Textint(Index, 6) <> 0 Or Textint(Index, 7) <> 0 Then
- Call Sjgskz(LrText(Index), Textint(Index, 6), Textint(Index, 7))
- End If
- End Select
- TextChangeLock = False '解锁
- End Sub
- Private Sub LrText_GotFocus(Index As Integer) '文本框得到焦点,显示相应信息
- Call TextShow(Index)
- End Sub
- Private Sub LrText_KeyDown(Index As Integer, KeyCode As Integer, Shift As Integer) '字段按F2键提供帮助
- Select Case KeyCode
- Case vbKeyF2
- Call Text_Help(Index)
- End Select
- End Sub
- Private Sub LrText_KeyPress(Index As Integer, KeyAscii As Integer) '文本框录入事中控制
- Call InputFieldLimit(LrText(Index), Textint(Index, 1), KeyAscii)
- End Sub
- Private Sub LrText_LostFocus(Index As Integer) '文本框失去焦点进行有效性判断及相应处理
- If Textint(Index, 9) = 0 Or Textint(Index, 9) = 1 Then '事中判断
- Call TextYxxpd(Index)
- End If
- Select Case Index
- Case 0
- If Trim(LrText(0).Text) = "" Then
- Exit Sub
- Else
- Call Wbklrwbcl(Index)
- End If
- End Select
- End Sub
- Private Sub Ydcommand1_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single) '点击按钮
- Call Text_Help(Ydcommand1.Tag)
- End Sub
- Private Sub Text_Help(Index As Integer) '录入字段帮助
- If Not Ydcommand1.Visible Then
- Exit Sub
- End If
- TextValiLock = True
- If Index = 0 Then
- Call Drbmhelp(Textint(Index, 2), Textstr(Index, 4), Trim(LrText(1).Text & ""))
- Else
- Call Drbmhelp(Textint(Index, 2), Textstr(Index, 4), Trim(LrText(Index).Text))
- End If
- If Len(Xtfhcs) <> 0 Then
- If Textint(Index, 3) = 1 Then
- LrText(Index).Text = Xtfhcsfz
- LrText(Index).Tag = Xtfhcs
- Else
- LrText(Index).Text = Xtfhcs
- LrText(Index).Tag = Xtfhcsfz
- End If
- End If
- TextValiLock = False
- LrText(Index).SetFocus
- If Index = 0 And Len(Xtfhcs) <> 0 Then
- Call Wbklrwbcl(Index)
- End If
- End Sub
- Private Sub TextShow(Index As Integer) '文本框得到焦点,显示相应信息
- '如果文本框有帮助,则显示帮助按钮
- If Textboolean(Index, 1) Then
- Ydcommand1.Visible = True
- Ydcommand1.Move LrText(Index).Left + LrText(Index).Width, LrText(Index).Top
- Ydcommand1.Tag = Index
- Else
- Ydcommand1.Tag = ""
- Ydcommand1.Visible = False
- End If
- '[>>
- '可在此处定义其他处理动作
- '<<]
- End Sub
- Private Sub Wbkcsh() '录入文本框初始化
- Dim Int_TabIndex As Integer 'Tab焦点计数器
- '单据录入中文本框焦点由0开始
- LrText(0).TabIndex = 0
- '最大录入文本框索引值
- Max_Text_Index = Textvar(1)
- ReDim TextValiJudgeLock(Max_Text_Index)
- For jsqte = 0 To Max_Text_Index
- '判断此文本框录入索引号是否存在,如存在则对其进行初始化
- If Len(Trim(Textstr(jsqte, 1))) <> 0 Then
- '自动装入录入文本框和其解释标签
- If jsqte <> 0 Then
- Load LrText(jsqte)
- Load TsLabel(jsqte)
- '判断录入文本框是否显示
- If Textboolean(jsqte, 4) Then
- LrText(jsqte).Visible = True
- TsLabel(jsqte).Visible = True
- End If
- '判断文本框是否可编辑
- If Textboolean(jsqte, 5) Then
- LrText(jsqte).Enabled = True
- Else
- LrText(jsqte).Enabled = False
- End If
- End If
- '初始化其内容
- TextChangeLock = True
- LrText(jsqte).Text = ""
- LrText(jsqte).Tag = ""
- If Textint(jsqte, 5) <> 0 Then
- LrText(jsqte).MaxLength = Textint(jsqte, 5)
- End If
- TextChangeLock = False
- '设置文本框位置及大小,并设置相应标签内容及其位置
- LrText(jsqte).Move Textint(jsqte, 13), Textint(jsqte, 12), Textint(jsqte, 11), Textint(jsqte, 10)
- TsLabel(jsqte).Caption = Textstr(jsqte, 7) & ":"
- TsLabel(jsqte).Move Textint(jsqte, 13) - TsLabel(jsqte).Width - 20, Textint(jsqte, 12) + (Textint(jsqte, 10) - TsLabel(jsqte).Height) / 2 - 30
- End If
- '将文本框有效性判断进行加锁,在文本框内容发生变化时将锁打开
- TextValiJudgeLock(jsqte) = True
- Next jsqte
- '设置文本框焦点转移顺序(前提文本焦点从0至Max_Text_Index)
- For Int_TabIndex = 0 To Max_Text_Index
- For jsqte = 0 To Max_Text_Index
- If Textint(jsqte, 14) = Int_TabIndex Then
- LrText(jsqte).TabIndex = Int_TabIndex
- End If
- Next jsqte
- Next Int_TabIndex
- End Sub
- Private Function TextYxxpd(Index As Integer) As Boolean '文本框有效性判断
- Dim Sqlstr As String
- Dim Findrec As New ADODB.Recordset
- '按帮助不进行有效性判断
- If TextValiLock Then
- TextValiLock = False
- TextYxxpd = True
- Exit Function
- End If
- '文本框内容未曾改变不进行有效性判断
- If TextValiJudgeLock(Index) Then
- Ydcommand1.Visible = False
- TextYxxpd = True
- Exit Function
- End If
- '文本框内容为空认为有效,并清空其Tag值
- If Trim(LrText(Index)) = "" Then
- LrText(Index).Tag = ""
- Call Wbklrwbcl(Index)
- Ydcommand1.Visible = False
- TextValiJudgeLock(Index) = True
- TextYxxpd = True
- Exit Function
- End If
- '[>>
- '可在此加入不做有效性判断的理由(参照上面程序)
- '<<]
- Select Case Textint(Index, 4)
- Case 1 '编码型
- Sqlstr = Trim(Textstr(Index, 5))
- If Index = 0 Then
- Sqlstr = Replace(Sqlstr, "@", "'" + Trim(LrText(Index).Text) + "'")
- Sqlstr = Replace(Sqlstr, "$", "'" + Trim(LrText(1).Tag) + "'")
- Else
- Sqlstr = Replace(Sqlstr, "@", "'" + Trim(LrText(Index).Text) + "'")
- End If
- Set Findrec = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If Findrec.EOF Then
- Call Xtxxts(Trim(Textstr(Index, 6)), 0, 1)
- LrText(Index).SetFocus
- Exit Function
- Else
- Select Case Textint(Index, 3)
- Case 0
- If Len(Trim(Textstr(Index, 2))) <> 0 Then
- LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
- End If
- If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
- LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
- End If
- Case 1
- If Len(Trim(Textstr(Index, 3) & "")) <> 0 Then
- LrText(Index).Text = Trim(Findrec.Fields(Trim(Textstr(Index, 3))))
- End If
- If Len(Trim(Textstr(Index, 2))) <> 0 Then
- LrText(Index).Tag = Trim(Findrec.Fields(Trim(Textstr(Index, 2))))
- End If
- End Select
- End If
- Case 2 '日期型
- If IsDate(LrText(Index).Text) Then
- LrText(Index).Text = Format(LrText(Index).Text, "yyyy-mm-dd")
- If Val(Mid(LrText(Index), 1, 4)) < 1900 Then
- LrText(Index).Text = "1900" + Mid(LrText(Index), 5, 6)
- End If
- Else
- Tsxx = "非法公历日期!(格式:" + Format(Date, "yyyy-mm-dd") + ")"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(Index).SetFocus
- Exit Function
- End If
- Case 3 '其他类型
- End Select
- '隐藏帮助按钮
- Ydcommand1.Visible = False
- '如果有效则加锁,用户不改变内容则不再进行有效性判断
- TextValiJudgeLock(Index) = True
- '调用文本框事后处理程序
- Call Wbklrwbcl(Index)
- '有效性判断通过则返回True
- TextYxxpd = True
- End Function
- Private Function Sub_Run() As Boolean '生成凭证
- Dim jsq As Integer '临时计数器
- Dim lng_OperationNum As Long '临时凭证ID
- Dim TranVouchClassCode As String '转帐凭证类别
- Dim Str_VouchModel As String '转帐凭证模式
- Dim RecTemp As New ADODB.Recordset
- '【写临时凭证
- Sub_Run = False
- On Error GoTo ERR1
- Cw_DataEnvi.DataConnect.BeginTrans
- '取转帐凭证类型
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute("Select * from RP_TranVouch where BillItemCode='61'")
- If RecTemp.EOF = False Then
- TranVouchClassCode = RecTemp.Fields("VouchClassCode")
- Str_VouchModel = Trim(RecTemp.Fields("VouchModel"))
- Else
- TranVouchClassCode = ""
- Str_VouchModel = ""
- End If
- '将转帐过程的凭证类别放到数组TranVouchClass中
- OperationNum = CreatBillID("0102") '本次制作凭证的操作批号
- lng_OperationNum = CreatBillID("0102") '临时凭证ID号
- '写临时凭证主表
- VouchRow = 0
- Call Save_TempPz_Main(TranVouchClassCode, OperationNum, lng_OperationNum) '参数是凭证类别,批号,凭证ID
- '根据应收明细帐记录,写临时凭证子表
- Call Save_TempPz_Ass_Pre(lng_OperationNum, Str_VouchModel)
- Cw_DataEnvi.DataConnect.CommitTrans
- '记录此次转帐的批号,做为凭证窗体调用的参数
- '】以上是写临时凭证记录
- AutoTran_PzFrm.OperationNumPz = OperationNum '传递此次转帐批号
- AutoTran_PzFrm.Show 1 '临时转帐凭证窗体
- If CheckVouch = True Then '检查是否生成了正式凭证
- Sub_Run = True
- End If
- Call Clean '清理临时凭证表
- Exit Function
- ERR1:
- Cw_DataEnvi.DataConnect.RollbackTrans
- Tsxx = Err.Description
- Tsxx = "转帐过程中出现未知错误,程序自动恢复保存前状态!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End Function
- Private Sub Save_TempPz_Ass_Pre(VouchTemp_Id As Long, VouchModel As String)
- 'VouchTemp_Id 表示临时凭证的ID号,VouchModel 表示凭证的模板
- Dim RecTemp As New ADODB.Recordset '临时记录集
- Dim RecInvoice As New ADODB.Recordset '发票记录集
- Dim RecAccList As New ADODB.Recordset '应收款明细帐
- Dim Digest As String '摘要
- Dim AccCode As String '单据科目编码
- Dim AccCodeArAp As String '应收科目编码
- Dim DeptCode As String '部门编码
- Dim PersonCode As String '经办人编码
- Dim CusCode As String '客户编码
- Dim SupplierCode As String '供应商编码
- Dim ItemCode As String '项目编码
- Dim ParaXt As String '临时参数变量
- Dim YbYsje As Double '原币应收
- Dim BbYsje As Double '本币应收
- Dim BadDebtType As String '坏帐类型
- CusCode = Trim(LrText(1).Tag) '客户编码
- CustName = Trim(LrText(1).Text)
- SupplierCode = "" '供应商
- SupplierName = "" '供应商
- ItemCode = "" '项目
- SsCode = "" '结算方式
- BankBillNo = "" '票号
- Digest = Trim(LrText(2).Text)
- '取坏帐损失还是坏帐准备科目
- ParaXt = "AR_baddebtsMothed"
- Sqlstr = "Select ItemValue from Gy_AccInformation Where ItemCode='" & ParaXt & "'"
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If RecTemp.EOF = False Then
- If Trim(RecTemp.Fields("itemvalue")) = "1" Then '
- BadDebtType = 1 '第1种方式,备抵法
- Else
- BadDebtType = 0 '第2种方法,不计提坏帐准备
- End If
- End If
- If BadDebtType = 1 Then
- AccCode = Fun_GetInputCode("AR_BadDebtPrepAccCode") '坏帐准备科目
- Else
- AccCode = Fun_GetInputCode("AR_BadDebtAccCode") '坏帐损失科目(非备抵法)
- End If
- '其它数据,从网格中取
- Ybhj = 0
- Bbhj = 0
- With WglrGrid
- For Rowjsq = 1 To .Rows - 1
- If WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)) = True Then
- AccCodeArAp = Trim(.TextMatrix(Rowjsq, Sydz("010", GridStr(), Szzls))) '应收科目编码
- DeptCode = Trim(LrText(3).Tag) '部门
- PersonCode = Trim(LrText(4).Tag) '经办人
- BillDate = CDate(Trim(LrText(6)))
- YbYsje = Val(.TextMatrix(Rowjsq, Sydz("008", GridStr(), Szzls))) '原币坏帐金额
- BbYsje = Val(.TextMatrix(Rowjsq, Sydz("009", GridStr(), Szzls))) '本币坏帐金额
- PersonName = Trim(LrText(4).Tag) '经办人姓名
- ForeignCurrCode = Trim(LrText(2).Tag) '外币编码
- If YbYsje <> 0 Or YbYsje <> 0 Then
- Select Case VouchModel
- Case "5" '
- '写借应收帐款分录
- VouchRow = VouchRow + 1
- YbJe = YbYsje '每笔坏帐回收金额
- BbJe = BbYsje '每笔坏帐回收金额
- Ybhj = Ybhj + YbJe
- Bbhj = Bbhj + BbJe
- '贷应收
- Call Save_TempPz_Ass(VouchTemp_Id, VouchRow, Digest, AccCodeArAp, DeptCode, PersonCode, CusCode, SupplierCode, ItemCode, "借")
- Case Else '另一种凭证模式
- '写借应收帐款分录
- VouchRow = VouchRow + 1
- YbJe = YbYsje '每笔坏帐金额
- BbJe = BbYsje '每笔坏帐金额
- Ybhj = Ybhj + YbJe
- Bbhj = Bbhj + BbJe
- '借应收
- Call Save_TempPz_Ass(VouchTemp_Id, VouchRow, Digest, AccCodeArAp, DeptCode, PersonCode, CusCode, SupplierCode, ItemCode, "借")
- End Select
- End If
- End If
- Next Rowjsq
- End With
- If Ybhj <> 0 Or Bbhj <> 0 Then
- VouchRow = VouchRow + 1
- YbJe = Ybhj
- BbJe = Bbhj
- Call Save_TempPz_Ass(VouchTemp_Id, VouchRow, Digest, AccCode, DeptCode, PersonCode, CusCode, SupplierCode, ItemCode, "贷")
- End If
- End Sub
- Private Sub Save_TempPz_Main(TranVouchClass1 As String, OperationNum1 As Long, VouchIdTemp_Id As Long) '将有效数据写入临时凭证主表
- Dim Rec_VouchMainTemp As New ADODB.Recordset '临时凭证主表记录集
- '打开临时凭证主表,存放有效凭证的凭证号等主信息
- If Rec_VouchMainTemp.State = 1 Then Rec_VouchMainTemp.Close
- Rec_VouchMainTemp.Open "select * from Cwzz_AccVouchMainTemp Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- With Rec_VouchMainTemp
- .AddNew
- .Fields("VouchSource") = "应收系统" '凭证来源
- .Fields("OperationNo") = OperationNum1 '存放批号
- .Fields("VouchId") = VouchIdTemp_Id '临时凭证ID
- .Fields("Year") = Int_Kjyear '取选中的年份
- .Fields("period") = Int_Period '取选中的会计期间
- .Fields("Ddate") = Xtrq '取系统日期
- .Fields("VouchClassCode") = TranVouchClass1 '单据的凭证类别
- .Fields("Doc") = 0
- .Fields("Bill") = Xtczy
- .Fields("OperationClass") = "" '业务类型
- .Fields("BillType") = ""
- .Fields("BillNo") = 1 '凭证个数
- .Fields("DeleteFlag") = IIf(Bln_DeleteFlag, 1, 0)
- .Update
- End With
- End Sub
- Private Sub Save_TempPz_Ass(VouchIdTemp_Id As Long, serialnum As Long, Str_Digest As String, Str_Kmh As String, str_Dept As String, Str_Per As String, Str_Cus As String, Str_Sup As String, Str_Item As String, str_TranOri As String) '写临时凭证辅表
- 'VouchIdTemp_Id临时凭证主表、辅表对应关系Id号
- Dim Rec_VouchTemp As New ADODB.Recordset '临时凭证辅表记录集
- Dim RecTemp As New ADODB.Recordset
- '打开临时凭证辅表,用于存放转帐凭证内容
- Rec_VouchTemp.Open "select * from Cwzz_AccVouchsubTemp where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute("Select * from Cwzz_AccCode where Ccode='" & Str_Kmh & "'")
- With Rec_VouchTemp
- .AddNew
- '[公共信息
- If str_TranOri = "贷" Then '
- .Fields("WbDfje") = YbJe '贷方金额
- .Fields("Dfje") = BbJe
- Else
- .Fields("WbJfje") = YbJe '借方金额
- .Fields("Jfje") = BbJe
- End If
- .Fields("Digest") = Str_Digest '摘要
- If RecTemp.EOF = True Then
- .Fields("Ccode") = Null
- Else
- .Fields("Ccode") = Str_Kmh '转帐科目号
- End If
- .Fields("VouchId") = VouchIdTemp_Id '与主表的对应ID
- .Fields("serialID") = serialnum '序号ID
- '[辅助信息
- If RecTemp.EOF = False Then
- If RecTemp.Fields("QuantityFlag") = True Then
- If str_TranOri = "贷" Then '数量
- .Fields("Jfsl") = Sl
- Else
- .Fields("Dfsl") = Sl
- End If
- End If
- If RecTemp.Fields("PersonFlag") = True Then
- .Fields("PersonCode") = Str_Per '个人
- End If
- If RecTemp.Fields("DeptFlag") = True Then
- .Fields("DeptCode") = str_Dept '部门
- End If
- If RecTemp.Fields("CusFlag") = True Then
- .Fields("CusCode") = Str_Cus '客户
- End If
- If RecTemp.Fields("SupplierFlag") = True Then
- .Fields("Suppliercode") = Str_Sup '供应商
- End If
- End If
- '[币别信息
- .Fields("ForeignCurrCode") = ForeignCurrCode
- .Fields("AccRate") = AccRate
- '[银行结算信息
- If RecTemp.EOF = False Then
- If Trim(RecTemp.Fields("Cproperty")) = "银行" Then
- .Fields("SScode") = SsCode
- .Fields("BillNo") = BankBillNo
- .Fields("Digest") = Str_Digest & CustName & SuppName '摘要
- End If
- End If
- ']银行结算信息
- .Fields("BillDate") = BillDate
- .Fields("TranPerson") = PersonName
- .Update
- End With
- End Sub
- Private Function CheckVouch() As Boolean '检验凭证是否保存
- Dim Rec_VouchMain As New ADODB.Recordset '临时主凭证记录
- CheckVouch = False
- Sqlstr = "SELECT * FROM Cwzz_AccVouchMainTemp WHERE SureVouchId>0 and OperationNo='" & OperationNum & "' order by BillNo"
- Set Rec_VouchMain = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- If Rec_VouchMain.EOF = False Then
- CheckVouch = True
- EffectVouchId = Rec_VouchMain.Fields("SureVouchId") '已生成的正式凭证的ID
- End If
- End Function
- Private Sub Clean() '删除临时数据表数据
- '删除临时凭证主从表
- Cw_DataEnvi.DataConnect.Execute "Delete From Cwzz_AccVouchSubTemp Where VouchId in (select VouchId from Cwzz_AccVouchMainTemp where OperationNo='" & OperationNum & "')"
- Cw_DataEnvi.DataConnect.Execute "Delete From Cwzz_AccVouchMainTemp Where OperationNo='" & OperationNum & "'"
- End Sub