资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:60k
源码类别:
企业管理
开发平台:
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 CL_MonthAveragePrice
- BackColor = &H00E9F4FA&
- BorderStyle = 1 'Fixed Single
- Caption = "全月平均单价"
- ClientHeight = 7260
- ClientLeft = 45
- ClientTop = 330
- ClientWidth = 11100
- HelpContextID = 130403
- Icon = "处理_全月平均单价.frx":0000
- LinkTopic = "Form1"
- MaxButton = 0 'False
- MinButton = 0 'False
- ScaleHeight = 7260
- ScaleWidth = 11100
- StartUpPosition = 2 '屏幕中心
- Begin VB.OptionButton Opt_Price
- BackColor = &H00E9F4FA&
- Caption = "全部"
- Height = 285
- Index = 1
- Left = 10260
- TabIndex = 11
- Top = 1020
- Width = 735
- End
- Begin VB.OptionButton Opt_Price
- BackColor = &H00E9F4FA&
- Caption = "平均单价小于等于零"
- Height = 285
- Index = 0
- Left = 8190
- TabIndex = 10
- Top = 1020
- Value = -1 'True
- Width = 1995
- End
- Begin VB.Timer Timer1
- Interval = 1
- Left = 2100
- Top = 630
- End
- Begin VB.ComboBox YdCombo
- Height = 315
- Left = 2610
- Style = 2 'Dropdown List
- TabIndex = 3
- Top = 600
- Visible = 0 'False
- Width = 1155
- End
- Begin VB.TextBox Ydtext
- BackColor = &H80000018&
- BorderStyle = 0 'None
- Height = 330
- Left = 2610
- MultiLine = -1 'True
- TabIndex = 2
- Top = 960
- Visible = 0 'False
- Width = 1185
- End
- Begin VSFlex8Ctl.VSFlexGrid WglrGrid
- Height = 5760
- Left = 90
- TabIndex = 0
- Top = 1365
- Width = 10905
- _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 = -2147483643
- ForeColor = -2147483640
- BackColorFixed = 12640511
- ForeColorFixed = -2147483630
- BackColorSel = -2147483634
- ForeColorSel = -2147483640
- BackColorBkg = -2147483636
- BackColorAlternate= -2147483643
- 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
- Begin MSComctlLib.ImageList ImageList1
- Left = 1470
- Top = 660
- _ExtentX = 1005
- _ExtentY = 1005
- BackColor = -2147483643
- ImageWidth = 16
- ImageHeight = 16
- MaskColor = 12632256
- _Version = 393216
- BeginProperty Images {2C247F25-8591-11D1-B16A-00C0F0283628}
- NumListImages = 24
- BeginProperty ListImage1 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":1042
- Key = "sz"
- EndProperty
- BeginProperty ListImage2 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":13DC
- Key = "bc"
- EndProperty
- BeginProperty ListImage3 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":1776
- Key = "mx"
- EndProperty
- BeginProperty ListImage4 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":1B10
- Key = "lj"
- EndProperty
- BeginProperty ListImage5 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":1EAA
- Key = "hf"
- EndProperty
- BeginProperty ListImage6 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":2244
- Key = "jz"
- EndProperty
- BeginProperty ListImage7 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":25DE
- Key = "dy"
- EndProperty
- BeginProperty ListImage8 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":2978
- Key = "yl"
- EndProperty
- BeginProperty ListImage9 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":2D12
- Key = "cx"
- EndProperty
- BeginProperty ListImage10 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":30AC
- Key = "dj"
- EndProperty
- BeginProperty ListImage11 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":3446
- Key = "sx"
- EndProperty
- BeginProperty ListImage12 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":37E0
- Key = "first"
- EndProperty
- BeginProperty ListImage13 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":3B7A
- Key = "prev"
- EndProperty
- BeginProperty ListImage14 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":3F14
- Key = "next"
- EndProperty
- BeginProperty ListImage15 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":42AE
- Key = "last"
- EndProperty
- BeginProperty ListImage16 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":4648
- Key = "bz"
- EndProperty
- BeginProperty ListImage17 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":49E2
- Key = "tc"
- EndProperty
- BeginProperty ListImage18 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":4D7C
- Key = "bcgs"
- EndProperty
- BeginProperty ListImage19 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":5116
- Key = "mrlk"
- EndProperty
- BeginProperty ListImage20 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":54B0
- Key = "xsxm"
- EndProperty
- BeginProperty ListImage21 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":584A
- Key = "check"
- EndProperty
- BeginProperty ListImage22 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":5BE4
- Key = "xz"
- EndProperty
- BeginProperty ListImage23 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":5F7E
- Key = "xg"
- EndProperty
- BeginProperty ListImage24 {2C247F27-8591-11D1-B16A-00C0F0283628}
- Picture = "处理_全月平均单价.frx":6318
- Key = "sc"
- EndProperty
- EndProperty
- End
- Begin MSComctlLib.Toolbar Tlb_Action
- Height = 555
- Left = 0
- TabIndex = 6
- Top = 0
- Width = 12060
- _ExtentX = 21273
- _ExtentY = 979
- ButtonWidth = 820
- ButtonHeight = 926
- Appearance = 1
- Style = 1
- ImageList = "ImageList1"
- _Version = 393216
- BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
- NumButtons = 8
- BeginProperty Button1 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "设置"
- Key = "ymsz"
- Object.ToolTipText = "打印页面设置"
- ImageKey = "sz"
- EndProperty
- BeginProperty Button2 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "打印"
- Key = "dy"
- ImageKey = "dy"
- EndProperty
- BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "预览"
- Key = "yl"
- ImageKey = "yl"
- EndProperty
- BeginProperty Button4 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "a"
- Style = 3
- EndProperty
- BeginProperty Button5 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "保存"
- Key = "bc"
- Object.ToolTipText = "保存单据"
- ImageKey = "bc"
- EndProperty
- BeginProperty Button6 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Key = "d"
- Style = 3
- EndProperty
- BeginProperty Button7 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Object.Visible = 0 'False
- Caption = "帮助"
- Key = "bz"
- ImageKey = "bz"
- EndProperty
- BeginProperty Button8 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "退出"
- Key = "fh"
- ImageKey = "tc"
- EndProperty
- EndProperty
- BorderStyle = 1
- Begin MSComctlLib.Toolbar GsToolbar
- Height = 525
- Left = 8550
- TabIndex = 7
- Top = 0
- Width = 2535
- _ExtentX = 4471
- _ExtentY = 926
- ButtonWidth = 1455
- ButtonHeight = 926
- Appearance = 1
- Style = 1
- ImageList = "ImageList1"
- _Version = 393216
- BeginProperty Buttons {66833FE8-8583-11D1-B16A-00C0F0283628}
- NumButtons = 3
- 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
- BeginProperty Button3 {66833FEA-8583-11D1-B16A-00C0F0283628}
- Caption = "显示项目"
- Key = "szxsxm"
- ImageKey = "xsxm"
- EndProperty
- EndProperty
- End
- End
- Begin VB.Label lbl_TitleMess
- BackStyle = 0 'Transparent
- Caption = "月份:"
- Height = 225
- Index = 0
- Left = 180
- TabIndex = 9
- Top = 1080
- Width = 465
- End
- Begin VB.Label lbl_TitleText
- BackStyle = 0 'Transparent
- Caption = "Label2"
- Height = 225
- Index = 0
- Left = 690
- TabIndex = 8
- Top = 1080
- Width = 1305
- End
- Begin VB.Label Lab_OperStatus
- BackColor = &H000080FF&
- Caption = "1"
- Height = 345
- Left = 4080
- TabIndex = 5
- Top = 600
- Visible = 0 'False
- Width = 345
- End
- Begin VB.Label Lab_Djclzt
- BackColor = &H0000FFFF&
- Caption = "1"
- ForeColor = &H00808080&
- Height = 255
- Left = 3810
- TabIndex = 4
- Top = 570
- Visible = 0 'False
- Width = 285
- End
- Begin VB.Label Lbl_TsLabel
- AutoSize = -1 'True
- BackColor = &H80000018&
- BackStyle = 0 'Transparent
- Caption = "全月平均单价"
- BeginProperty Font
- Name = "宋体"
- Size = 14.25
- Charset = 134
- Weight = 700
- Underline = 0 'False
- Italic = 0 'False
- Strikethrough = 0 'False
- EndProperty
- ForeColor = &H00000000&
- Height = 285
- Index = 0
- Left = 4560
- TabIndex = 1
- Top = 870
- Width = 1800
- End
- End
- Attribute VB_Name = "CL_MonthAveragePrice"
- Attribute VB_GlobalNameSpace = False
- Attribute VB_Creatable = False
- Attribute VB_PredeclaredId = True
- Attribute VB_Exposed = False
- '********************************************************
- '* 隐藏列值说明 *
- '* 0-*号 1-主表ID 2-子表ID *
- '********************************************************
- '*
- '*****************************************************************************************
- '* 模 块 名 称 :全月平均单价
- '*
- '* 功 能 描 述 :此功能模块主要完成全月平均单价修改、预览、打印等。
- '*
- '* 备 注:程序中所有依实际情况自定义部分均用[>> <<]括起
- '*
- '* 1.每次调入外部功能窗体,均要加锁ChangeLock=True,窗体关闭后解锁ChangeLock=false
- '*
- '* 2.Lab_OperStatus =1 (网格不可编辑)
- '*
- '*
- '* 3.原则:只要单据能够存盘(无论修改或新增)则其必须接受完整性及有效性规则检查
- '*
- '****************************************************************************************
- '[以下为根据实际情况设置变量bfy
- Dim mQuery_cond As String
- Dim Save_Flag As Boolean '平均单价保存标记
- Dim Jsqte% '临时计数器
- '**************************bfy]
- '以下为固定使用变量(网格)
- Dim Cxnrrec As New ADODB.Recordset '显示查询内容动态集
- Dim Dyymctbl As New DY_Dyymsz '打印页面窗体变量
- Dim GridCode As String '显示网格网格代码
- Dim GridInf() As Variant '整个网格设置信息
- Dim ReportTitle As String '报表主标题
- Dim Tsxx As String '系统提示信息
- 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 '文本框内容变换控制锁
- Dim Bln_Cancel As Boolean '取消按钮信息传递
- Private Sub Form_Load() '窗 体 装 入
- Save_Flag = False
- '初始化各种锁值
- Changelock = False '网格行列改变控制锁
- Gdtlock = False '滚动条滚动控制
- Yxxpdlock = True '字段有效性判断锁
- Hyxxpdlock = True '行有效性判断锁
- Wbkbhlock = False '文本框内容改变锁
- '报表主标题及报表编码
- ReportTitle = "全月平均单价"
- XtReportCode = "Chhs_MonthAveragePrice"
- Load Dyymctbl
- '调 入 网 格
- GridCode = "Chhs_MonthAveragePrice" '网格属性编码
- Call BzWgcsh(WglrGrid, GridCode, GridInf(), GridBoolean(), GridInt(), GridStr())
- Qslz = GridInf(1)
- Sjhgd = GridInf(2)
- Pmbcsjhs = GridInf(3)
- Fzxwghs = GridInf(4)
- Sfblbzkd = GridInf(5)
- Shsfts = GridInf(6)
- Sfxshjwg = GridInf(7)
- Szzls = WglrGrid.Cols - 1
- '当前会计月
- Lbl_TitleText(0) = CStr(Xtyear) + "." + CStr(PGNowmon)
- End Sub
- Private Sub Form_Unload(Cancel As Integer) '窗体卸载
- Dim Msg As Integer
- If Not Save_Flag Then
- Call Delete_AvgPrice
- End If
- '卸载打印页面窗体
- Unload Dyymctbl
- End Sub
- Private Sub Opt_Price_Click(Index As Integer)
- Timer1.Enabled = True
- End Sub
- Private Sub Timer1_Timer() '根据不同凭证或单据状态处理不同的数据初始化
- '关闭定时器
- Timer1.Enabled = False
- Lab_OperStatus = "2"
- WglrGrid.Redraw = False
- '调入单据信息
- Call Sub_Query
- WglrGrid.Redraw = True
- End Sub
- Private Sub Tlb_Action_ButtonClick(ByVal Button As MSComctlLib.Button) '用户点击工具条
- '屏蔽文本框有效性判断
- Valilock = True
- '屏蔽网格失去焦点产生的有效性判断
- Changelock = True
- Select Case Button.Key
- Case "ymsz" '页面设置
- Dyymctbl.Show 1
- Case "yl" '预 览
- If Fun_Drfrmyxxpd Then Call bbyl(True)
- Case "dy" '打 印
- If Fun_Drfrmyxxpd Then Call bbyl(False)
- Case "bc" '保 存
- If Fun_Drfrmyxxpd Then Call Sub_SaveBill
- Case "bz" '帮 助
- Case "fh" '退 出
- Unload Me
- End Select
- '解 锁
- Valilock = False
- Changelock = False
- End Sub
- Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer) '支持热键操作
- Select Case KeyCode
- Case vbKeyF6 '保存
- If Tlb_Action.Buttons("bc").Enabled And Tlb_Action.Buttons("bc").Visible Then
- If Fun_Drfrmyxxpd Then Call Sub_SaveBill
- End If
- Case vbKeyEscape '退出
- Unload Me
- End Select
- End Sub
- Private Sub Wbkcl() '文本框录入之前处理(根据实际情况)
- Dim xswbrr As String
- With WglrGrid
- Zdlrqnr = Trim(.Text)
- xswbrr = Trim(.Text)
- If GridBoolean(.Col, 3) Then '列表框录入
- '填充列表框程序
- 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) '录入数据字段有效性判断,同时进行字段录入事后处理
- Dim Str_JudgeText As String '临时有效性判断字段内容
- Dim Coljsq As Long '临时列计数器
- 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 "007"
- If Val(.TextMatrix(Dqpdwgh, Sydz("007", GridStr(), Szzls))) <= 0 Then
- Tsxx = "单价必须大于零!"
- GoTo Lrcwcl
- End If
- If Not .TextMatrix(Dqpdwgh, Sydz("006", GridStr(), Szzls)) = "" Then
- If Not Val(.TextMatrix(Dqpdwgh, Sydz("006", GridStr(), Szzls))) = 0 And Val(Str_JudgeText) <> 0 Then
- .TextMatrix(Dqpdwgh, Sydz("008", GridStr(), Szzls)) = Format(Val(.TextMatrix(Dqpdwgh, Sydz("006", GridStr(), Szzls))) * Val(Str_JudgeText), "####." + String(Xtjexsws, "0"))
- Else
- .TextMatrix(Dqpdwgh, Sydz("008", GridStr(), Szzls)) = ""
- End If
- End If
- '以上为自定义部分]
- End Select
- '字段录入正确后为零字段清空
- Call Qkwlzd(Dqpdwgh, Dqpdwgl)
- '字段录入正确后进行数据合计
- sjzdyxxpd = True
- Yxxpdlock = True
- Exit Function
- End With
- Lrcwcl: '录入错误处理
- With WglrGrid
- Call Xtxxts(Tsxx, 0, 1)
- Changelock = True
- .Select Dqpdwgh, Dqpdwgl
- Changelock = False
- Call xswbk
- sjzdyxxpd = False
- Exit Function
- End With
- End Function
- Private Function Sjhzyxxpd(ByVal Yxxpdh As Long) As Boolean '录入数据行有效性判断,同时进行行处理
- Dim Lrywlz As Long
- Dim Rectemp As Recordset
- Dim Yxrow As Long
- 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
- Changelock = False
- Sjhzyxxpd = True
- Exit Function
- End If
- End If
- End If
- If Hyxxpdlock Then
- Sjhzyxxpd = True
- Exit Function
- End If
- '以下为自定义部分[
- '1.放置行有效性判断程序
- '首先进行为空判断(固定不变)
- For Jsqte = Qslz To .Cols - 1
- If (GridInt(Jsqte, 5) = 1 And Len(Trim(.TextMatrix(Yxxpdh, Jsqte))) = 0) Or (GridInt(Jsqte, 5) = 2 And Val(Trim(.TextMatrix(Yxxpdh, Jsqte))) = 0) Then
- Tsxx = GridStr(Jsqte, 2)
- Lrywlz = Jsqte
- GoTo Lrcwcl
- Exit For
- End If
- Next Jsqte
- '自定义判断(补丁)
- If Val(.TextMatrix(Yxxpdh, Sydz("007", GridStr(), Szzls))) <= 0 Then
- Lrywlz = Sydz("007", GridStr(), Szzls)
- Tsxx = "平均单价必须大于零!"
- GoTo Lrcwcl
- End If
- '2.放置行处理程序
- '以上为自定义部分]
- End With
- Sjhzyxxpd = True
- Hyxxpdlock = True
- Exit Function
- Lrcwcl: '录入错误处理
- With WglrGrid
- Call Xtxxts(Tsxx, 0, 1)
- Changelock = True
- .Select Yxxpdh, Lrywlz
- Changelock = False
- Call xswbk
- Sjhzyxxpd = False
- Exit Function
- End With
- End Function
- Private Function Sub_SaveBill() As Boolean '保 存 单 据
- Dim Rowjsq As Long '网格行计数器
- Dim Coljsq As Long '网格列计数器
- Dim Int_RowCount As Integer '有效数据行计数器
- Dim Lrywlz As Long '录入有误列值
- Dim FindRow As Long
- Dim SqlStr As String
- '[判断用户所选会计期间是否有效(非结帐月份)
- '下面将对所有有效数据行进行有效性判断
- Int_RowCount = 0
- With WglrGrid
- For Rowjsq = .FixedRows To .Rows - 1
- '带*号者为有效数据行
- If .TextMatrix(Rowjsq, 0) <> "*" Then
- Exit For
- Else
- Int_RowCount = Int_RowCount + 1
- End If
- '1.首先进行为空或为零判断(固定不变)
- For Coljsq = Qslz To .Cols - 1
- If (GridInt(Coljsq, 5) = 1 And Len(Trim(.TextMatrix(Rowjsq, Coljsq))) = 0) Or (GridInt(Coljsq, 5) = 2 And Val(Trim(.TextMatrix(Rowjsq, Coljsq))) = 0) Then
- Tsxx = GridStr(Coljsq, 2)
- Lrywlz = Coljsq
- GoTo Lrcwcl
- Exit For
- End If
- Next Coljsq
- '2.[自定义判断(补丁)
- If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("007", GridStr(), Szzls))) <= 0 Then
- Tsxx = "平均单价不能小于等于零!"
- Lrywlz = Sydz("007", GridStr(), Szzls)
- GoTo Lrcwcl
- Exit For
- End If
- Next Rowjsq
- End With '网格
- '如果以上有效性检查均顺利通过,则执行存盘动作
- On Error GoTo Swcwcl
- Cw_DataEnvi.DataConnect.BeginTrans
- '保存单价
- For Jsqte = WglrGrid.FixedRows To WglrGrid.Rows - 1
- SqlStr = "UPDATE Chhs_Mate SET EndPrice='" & Val(WglrGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls))) & "'" & _
- "WHERE MateId='" & Val(WglrGrid.TextMatrix(Jsqte, 1)) & "' "
- Cw_DataEnvi.DataConnect.Execute (SqlStr)
- Next Jsqte
- Cw_DataEnvi.DataConnect.CommitTrans
- Save_Flag = True
- Edit_Flag = True
- Sub_SaveBill = True
- Tsxx = "保存完毕!"
- Call Xtxxts(Tsxx, 0, 4)
- Exit Function
- Swcwcl:
- Cw_DataEnvi.DataConnect.RollbackTrans
- Tsxx = "保存失败,程序自动恢复保存前状态!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- Lrcwcl: '录入错误处理
- With WglrGrid
- Call Xtxxts("(第 " + Trim(Str(Int_RowCount)) + " 条分录)-" + Tsxx, 0, 1)
- Changelock = True
- .Select Rowjsq, Lrywlz
- WglrGrid.SetFocus
- Changelock = False
- Exit Function
- End With
- End Function
- '===================以 下 程 序 为 通 用 部 分 ,一 般 不 需 更 改======================='
- 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
- End With
- End Sub
- Private Sub Lrzdbz() '录入字段帮助
- If Not Ydcommand.Visible Then
- Exit Sub
- End If
- Valilock = True
- With WglrGrid
- 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
- Ydtext.SetFocus
- 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_EnterCell() '显示当前数据行相关信息
- With WglrGrid
- If .Row >= .FixedRows Then
- Lab_Row = Trim(Str(.Row - .FixedRows + 1))
- Lbl_Label3 = Lab_Row
- End If
- End With
- End Sub
- Private Sub WglrGrid_GotFocus() '网格得到焦点
- '网格得到焦点,如果当前选择行为非数据行
- '则调整当前焦点至有效数据行
- With WglrGrid
- If .Rows = .FixedRows Then Exit Sub
- If .Row < .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
- 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() '鼠标双击网格显示文本框
- With WglrGrid
- Call xswbk
- End With
- End Sub
- Private Sub Ycwbk() '隐藏文本框,帮助按钮,列表组合框
- Ydtext.Visible = False
- YdCombo.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
- Rowjsq = .Rows - 1
- End If
- .Select Rowjsq, Coljsq
- 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() '录入事中变化处理
- '防止程序改变但不进行处理
- With WglrGrid
- '限制字段录入长度
- Wbkbhlock = True
- Select Case GridInt(.Col, 1)
- Case 8
- Call Sjgskz(Ydtext, Xtjezws - Xtjexsws - 1, Xtjexsws)
- Case 9
- 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 Trim(Lab_OperStatus.Caption) = "1" 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
- 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
- End If
- Ydtext.Left = .CellLeft + .Left + Wbkpy
- Ydtext.Top = .CellTop + .Top + Wbkpy
- Ydtext.Width = .CellWidth - Wbkpy1
- 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 Sub Cxxswbk() 'Formresize中重新显示文本框,列表框,帮助按钮(通用)
- Dim Wbkpy As Integer, Wbkpy1 As Integer
- Wbkpy = 30
- Wbkpy1 = 15
- With WglrGrid
- 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_KeyPress(KeyAscii As Integer) '网格接受键盘录入
- Dim Str_ChangeTe As String '临时交换内容
- Dim Coljsq As Long '临时列计数器
- Dim Int_SaveKey As Integer '保存KeyAscii值
- '如果单据操作状态为浏览状态则不能显示录入载体
- If Trim(Lab_OperStatus.Caption) = "1" Then
- Exit Sub
- End If
- Int_SaveKey = KeyAscii
- 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
- Rowjsq = .Rows - 1
- End If
- Changelock = True
- .Select Rowjsq, Coljsq
- Changelock = False
- Exit Sub
- End If
- '接受用户录入
- Select Case KeyAscii
- Case 0 To 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 = ""
- SendKeys Chr(KeyAscii)
- End If
- End Select
- 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 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) = "*"
- End With
- End Sub
- 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())
- Case "szxsxm" '设置显示项目
- Call Szxsxm(WglrGrid, GridCode)
- End Select
- End Sub
- Private Sub bbyl(bbylte As Boolean) '打印预览(通用)
- Dim Bbzbt$, Bbxbt() As String, bbxbtzzxs() As Integer, Bbxbtgs As Integer
- Dim Bbbwh() As String, Bbbwhzzxs() As Integer, Bbbwhgs As Integer
- Bbxbtgs = 1 '报 表 小 标 题 行 数
- Bbbwhgs = 0 '报 表 表 尾 行 数
- ReDim Bbxbt(1 To Bbxbtgs)
- ReDim bbxbtzzxs(1 To Bbxbtgs)
- If Bbbwhgs <> 0 Then
- ReDim Bbbwh(1 To Bbbwhgs)
- ReDim Bbbwhzzxs(1 To Bbbwhgs)
- End If
- Bbzbt = ReportTitle
- Call Scyxsjb(WglrGrid) '生成报表数据
- Call Scdybb(Dyymctbl, Bbzbt, Bbxbt(), bbxbtzzxs(), Bbxbtgs, Bbbwh(), Bbbwhzzxs(), Bbbwhgs, bbylte)
- If Not bbylte Then
- Unload DY_Tybbyldy
- End If
- End Sub
- Private Sub Delete_AvgPrice() '保存平均单价
- With WglrGrid
- Cw_DataEnvi.DataConnect.BeginTrans
- For Jsqte = .FixedRows To .Rows - 1
- '保存单价
- Cw_DataEnvi.DataConnect.Execute ("UPDATE Chhs_Mate SET EndPrice=0 WHERE MateId='" & Val(.TextMatrix(Jsqte, 1)) & "' ")
- Next Jsqte
- Cw_DataEnvi.DataConnect.CommitTrans
- End With
- End Sub
- Private Sub Sub_Query() '生成查询结果
- Dim Rec_Query As New ADODB.Recordset '查询结果动态集
- Dim Rectemp As New ADODB.Recordset '查询结果动态集
- Dim SqlStr As String
- Dim FindRow As Long
- Dim Jsqfz As Long
- SqlStr = Replace(mQuery_cond, "view", "Chhs_V_Mate", , , vbTextCompare)
- If Opt_Price(0).Value Then
- SqlStr = "SELECT * FROM Chhs_V_Mate WHERE KjYear='" & PGKjYear & "' and Period='" & PGNowmon & "' AND EndPrice<=0 AND " + SqlStr
- Else
- SqlStr = "SELECT * FROM Chhs_V_Mate WHERE KjYear='" & PGKjYear & "' and Period='" & PGNowmon & "' AND " + SqlStr
- End If
- Set Rec_Query = Cw_DataEnvi.DataConnect.Execute(SqlStr)
- WglrGrid.Rows = WglrGrid.FixedRows
- With Rec_Query
- Do While Not .EOF
- If .Fields("Outquan") <> 0 Then
- WglrGrid.AddItem ""
- Jsqte = WglrGrid.Rows - 1
- WglrGrid.RowHeight(Jsqte) = Sjhgd
- WglrGrid.TextMatrix(Jsqte, 0) = "*"
- WglrGrid.TextMatrix(Jsqte, 1) = Trim(.Fields("MateId"))
- WglrGrid.TextMatrix(Jsqte, Sydz("001", GridStr(), Szzls)) = Trim(.Fields("WhName") & "")
- WglrGrid.TextMatrix(Jsqte, Sydz("009", GridStr(), Szzls)) = Trim(.Fields("MName") & "")
- WglrGrid.TextMatrix(Jsqte, Sydz("002", GridStr(), Szzls)) = Trim(.Fields("MNumber") & "")
- If Not .Fields("startquan") = 0 Then
- WglrGrid.TextMatrix(Jsqte, Sydz("010", GridStr(), Szzls)) = Val(.Fields("startquan"))
- End If
- If Not .Fields("startPrice") = 0 Then
- WglrGrid.TextMatrix(Jsqte, Sydz("011", GridStr(), Szzls)) = Val(.Fields("startPrice"))
- End If
- If Not .Fields("startMoney") = 0 Then
- WglrGrid.TextMatrix(Jsqte, Sydz("012", GridStr(), Szzls)) = Val(.Fields("startMoney"))
- End If
- If Not .Fields("InQuan") = 0 Then
- WglrGrid.TextMatrix(Jsqte, Sydz("003", GridStr(), Szzls)) = Val(.Fields("InQuan"))
- End If
- If Not .Fields("InPrice") = 0 Then
- WglrGrid.TextMatrix(Jsqte, Sydz("004", GridStr(), Szzls)) = Val(.Fields("InPrice"))
- End If
- If Not .Fields("InMoney") = 0 Then
- WglrGrid.TextMatrix(Jsqte, Sydz("005", GridStr(), Szzls)) = Val(.Fields("InMoney"))
- End If
- If Not .Fields("OutQuan") = 0 Then
- WglrGrid.TextMatrix(Jsqte, Sydz("006", GridStr(), Szzls)) = Val(.Fields("OutQuan"))
- End If
- If Not .Fields("EndPrice") = 0 Then
- WglrGrid.TextMatrix(Jsqte, Sydz("007", GridStr(), Szzls)) = Val(.Fields("EndPrice"))
- End If
- If Not .Fields("OutQuan") = 0 Then
- WglrGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Format(Val(.Fields("OutQuan")) * Val(.Fields("EndPrice")), "####.0" + String(Xtjexsws, "0"))
- End If
- SqlStr = "SELECT sum(outquan) as sumoutquan,sum(outmoney) as sumoutmoney FROM Chhs_List WHERE sfjeztflag=1 and KjYear='" & PGKjYear & "' and Period='" & PGNowmon & "'" & _
- " and whcode='" & Trim(Rec_Query.Fields("whcode")) & "' and mnumber='" & Trim(Rec_Query.Fields("mnumber")) & "'"
- Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
- If Not Rectemp.EOF Then
- If Not IsNull(Rectemp.Fields("sumoutquan")) Then
- WglrGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Val(.Fields("OutQuan") - Val(Rectemp.Fields("sumoutquan"))) * Val(.Fields("EndPrice")) + Val(Rectemp.Fields("sumoutmoney"))
- End If
- Else
- WglrGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = Format(Val(.Fields("OutQuan")) * Val(.Fields("EndPrice")), "####.0" + String(Xtjexsws, "0"))
- End If
- If Val(WglrGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls))) = 0 Then
- WglrGrid.TextMatrix(Jsqte, Sydz("008", GridStr(), Szzls)) = ""
- End If
- End If
- .MoveNext
- Loop
- If WglrGrid.Rows > WglrGrid.FixedRows Then
- WglrGrid.Select WglrGrid.FixedRows, Sydz("007", GridStr(), Szzls)
- End If
- End With
- Set Rec_Query = Nothing
- End Sub
- Public Property Let Query_Cond(ByVal vNewValue As Variant)
- mQuery_cond = vNewValue
- End Property