资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:172k
源码类别:
企业管理
开发平台:
Visual Basic
- .Lab_Measure.Move .LrText(Jsqte).Left + .LrText(Jsqte).Width + 50, .LrText(Jsqte).Top + 100
- Case 4 '单价
- If Val(WglrGrid.TextMatrix(Lng_GridRow, Sydz("004", GridStr(), Szzls))) <> 0 And Val(WglrGrid.TextMatrix(Lng_GridRow, 5)) <> 0 Then
- .LrText(Jsqte).Text = Val(WglrGrid.TextMatrix(Lng_GridRow, Sydz("004", GridStr(), Szzls))) / Val(WglrGrid.TextMatrix(Lng_GridRow, 5))
- Else
- If Val(WglrGrid.TextMatrix(Lng_GridRow, Sydz("005", GridStr(), Szzls))) <> 0 And Val(WglrGrid.TextMatrix(Lng_GridRow, 5)) <> 0 Then
- .LrText(Jsqte).Text = Val(WglrGrid.TextMatrix(Lng_GridRow, Sydz("005", GridStr(), Szzls))) / Val(WglrGrid.TextMatrix(Lng_GridRow, 5))
- End If
- End If
- Case 5 '外币金额
- .LrText(Jsqte).Text = WglrGrid.TextMatrix(Lng_GridRow, 10)
- .Lab_ForeignName.Caption = "(" + Trim(WglrGrid.TextMatrix(Lng_GridRow, 9)) + ")"
- .Lab_ForeignName.Move .LrText(Jsqte).Left + .LrText(Jsqte).Width + 50, .LrText(Jsqte).Top + 100
- Case 6 '汇率
- .LrText(Jsqte).Text = WglrGrid.TextMatrix(Lng_GridRow, 11)
- Case 7 '部门
- .LrText(Jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 12))
- .LrText(Jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 13))
- Case 8 '客户
- .LrText(Jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 14))
- .LrText(Jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 15))
- Case 9 '个人
- .LrText(Jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 16))
- .LrText(Jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 17))
- Case 10 '项目
- .Lab_ItemClass.Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 18))
- .Lab_ItemClass.Caption = "(" + Trim(WglrGrid.TextMatrix(Lng_GridRow, 19)) + ")"
- .Lab_ItemClass.Move .LrText(Jsqte).Left + .LrText(Jsqte).Width + 400, .LrText(Jsqte).Top + 100
- .LrText(Jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 20))
- .LrText(Jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 21))
- SqlStr = "select * from Cwzz_item where ItemClassCode='" & .Lab_ItemClass.Tag & "' and ItemCode='" & Trim(.LrText(10).Tag) & "'"
- Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
- If Not Rectemp.EOF Then
- If Rectemp.Fields("QuantityFlag") Then
- .LrText(11).Text = WglrGrid.TextMatrix(Lng_GridRow, 22)
- .Lab_ItemMeasure = Trim(Rectemp.Fields("Measure"))
- End If
- End If
- Case 11
- .Lab_ItemMeasure.Move .LrText(11).Left + .LrText(11).Width + 50, .LrText(11).Top + 50
- Case 12 '供应商
- .LrText(Jsqte).Tag = Trim(WglrGrid.TextMatrix(Lng_GridRow, 25))
- .LrText(Jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 26))
- Case 13 '经办人
- .LrText(Jsqte).Text = Trim(WglrGrid.TextMatrix(Lng_GridRow, 24))
- End Select
- Else
- .tsLabel(Jsqte).Visible = False
- .LrText(Jsqte).Visible = False
- If Bln_AssHelp(Jsqte) Then
- .Ydcommand1(Jsqte).Visible = False
- End If
- End If
- Next Jsqte
- If Kjqstop * 3 + Kjxsgs * Kjjg > Ctzxgd Then
- .Height = Kjqstop * 3 + Kjxsgs * Kjjg
- Else
- .Height = Ctzxgd
- End If
- '加锁
- Changelock = True
- .Show 1
- Changelock = False
- End With
- End Sub
- Private Sub Sub_AbandonBill() '放弃对当前单据的操作
- '先关闭录入载体
- Changelock = True
- Valilock = True
- Call Ycwbk
- Changelock = False
- Valilock = False
- Select Case Trim(Lab_OperStatus.Caption)
- Case "2" '修改状态
- '重新显示当前单据
- Call Sub_ShowBill(currrecord)
- '设置操作状态重新置为新增状态
- Lab_OperStatus = "2"
- Call Sub_OperStatus("30")
- End Select
- End Sub
- Private Sub Sub_JsVouchNo() '自动计算新增单据编号
- Dim Rectemp As New ADODB.Recordset '临时使用动态集
- '单据为新增时才有效
- If Lab_OperStatus <> "2" Then
- Exit Sub
- End If
- SqlStr = "Select MAX(VouchNo) AS MVouchNo FROM chhs_VouchMain Where Year='" & Int_Year & "' AND Period='" & Int_Period & "'" & _
- " AND VouchClassCode='" & Trim(LrText(0).Text) & "'"
- Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
- TextChangeLock = True
- If Not IsNull(Rectemp.Fields("MVouchNo")) Then
- LrText(3).Text = Mid(Trim(Str(10000 + Rectemp.Fields("MVouchNo") + 1)), 2, 4)
- Else
- LrText(3).Text = "0001"
- End If
- TextChangeLock = False
- End Sub
- Private Sub Chk_DeleteMess_Click() '删行是否提示(点击)
- If Chk_DeleteMess.Value = 1 Then
- Shsfts = True
- Else
- Shsfts = False
- End If
- End Sub
- '选择首张,上张,下张,末张
- Private Sub Sub_First() '首 张
- Call Save_VouchTemp
- currrecord = 1
- Tlb_Action.Buttons("first").Enabled = False '首张
- Tlb_Action.Buttons("prev").Enabled = False '上张
- Tlb_Action.Buttons("next").Enabled = True '下张
- Tlb_Action.Buttons("last").Enabled = True '末张
- Call Sub_ShowBill(1)
- Call Sub_JsVouchNo
- End Sub
- Private Sub Sub_Prev() '上 张
- Call Save_VouchTemp
- currrecord = currrecord - 1
- If currrecord = 1 Then
- Tlb_Action.Buttons("first").Enabled = False '首张
- Tlb_Action.Buttons("prev").Enabled = False '上张
- Tlb_Action.Buttons("next").Enabled = True '下张
- Tlb_Action.Buttons("last").Enabled = True '末张
- Else
- Tlb_Action.Buttons("first").Enabled = True '首张
- Tlb_Action.Buttons("prev").Enabled = True '上张
- Tlb_Action.Buttons("next").Enabled = True '下张
- Tlb_Action.Buttons("last").Enabled = True '末张
- End If
- Call Sub_ShowBill(currrecord)
- Call Sub_JsVouchNo
- End Sub
- Private Sub Sub_next() '下 张
- Call Save_VouchTemp
- currrecord = currrecord + 1
- If currrecord = CL_MakeVoucherSub.vsFlex_PzMain.Rows - CL_MakeVoucherSub.vsFlex_PzMain.FixedRows Then
- Tlb_Action.Buttons("first").Enabled = True '首张
- Tlb_Action.Buttons("prev").Enabled = True '上张
- Tlb_Action.Buttons("next").Enabled = False '下张
- Tlb_Action.Buttons("last").Enabled = False '末张
- Else
- Tlb_Action.Buttons("first").Enabled = True '首张
- Tlb_Action.Buttons("prev").Enabled = True '上张
- Tlb_Action.Buttons("next").Enabled = True '下张
- Tlb_Action.Buttons("last").Enabled = True '末张
- End If
- Call Sub_ShowBill((currrecord))
- Call Sub_JsVouchNo
- End Sub
- Private Sub Sub_Last() '末 张
- Call Save_VouchTemp
- currrecord = CL_MakeVoucherSub.vsFlex_PzMain.Rows - CL_MakeVoucherSub.vsFlex_PzMain.FixedRows
- Tlb_Action.Buttons("first").Enabled = True '首张
- Tlb_Action.Buttons("prev").Enabled = True '上张
- Tlb_Action.Buttons("next").Enabled = False '下张
- Tlb_Action.Buttons("last").Enabled = False '末张
- Call Sub_ShowBill(currrecord)
- Call Sub_JsVouchNo
- End Sub
- Public Sub Sub_Scpzbb(Cxsjwg As VSFlexGrid) '生成预览凭证报表
- '过程参数:输出数据网格
- Dim Yxhzjsq%, Yxlzjsq% '有效列值计数器,有效行值计数器
- Dim Rowjsq As Long '临时行计数器
- Dim Sjhjsq As Long '数据行计数器
- Dim Int_Pzmyhs As Integer '凭证每页数据行数
- Dim Dbl_Jfhj As Double '借方合计
- Dim Dbl_Dfhj As Double '贷方合计
- '生成有效数据表
- With DY_Tybbyldy.DyylGrid
- .FontName = Cxsjwg.FontName
- .FontSize = Cxsjwg.FontSize
- .FixedRows = Cxsjwg.FixedRows
- .MergeCells = flexMergeFixedOnly
- For Jsqte = 0 To .FixedRows - 1
- .MergeRow(Jsqte) = True
- Next Jsqte
- .WordWrap = True
- '重置数据列
- Yxlzjsq = 4
- .Cols = Yxlzjsq
- .ColAlignment(2) = Cxsjwg.ColAlignment(Sydz("004", GridStr(), Szzls))
- .ColAlignment(3) = Cxsjwg.ColAlignment(Sydz("005", GridStr(), Szzls))
- .ColWidth(0) = Cxsjwg.ColWidth(Sydz("001", GridStr(), Szzls))
- .ColWidth(1) = Cxsjwg.ColWidth(Sydz("002", GridStr(), Szzls)) + Cxsjwg.ColWidth(Sydz("003", GridStr(), Szzls))
- .ColWidth(2) = Cxsjwg.ColWidth(Sydz("004", GridStr(), Szzls))
- .ColWidth(3) = Cxsjwg.ColWidth(Sydz("005", GridStr(), Szzls))
- .ColFormat(2) = Cxsjwg.ColFormat(Sydz("004", GridStr(), Szzls))
- .ColFormat(3) = Cxsjwg.ColFormat(Sydz("005", GridStr(), Szzls))
- For Yxlzjsq = 0 To 3
- .MergeCol(Yxlzjsq) = True
- Next Yxlzjsq
- '重置数据行
- Yxhzjsq = 0
- For Rowjsq = 0 To Cxsjwg.Rows - 1
- If (Not Cxsjwg.RowHidden(Rowjsq)) And (Not GridRowEmpty(Cxsjwg, Rowjsq)) Then
- Yxhzjsq = Yxhzjsq + 1
- End If
- Next Rowjsq
- .Rows = Yxhzjsq
- .TextMatrix(0, 0) = Cxsjwg.TextMatrix(0, Sydz("001", GridStr(), Szzls))
- .TextMatrix(0, 1) = "科 目 名 称"
- .TextMatrix(0, 2) = Cxsjwg.TextMatrix(0, Sydz("004", GridStr(), Szzls))
- .TextMatrix(0, 3) = Cxsjwg.TextMatrix(0, Sydz("005", GridStr(), Szzls))
- .RowHeight(0) = Cxsjwg.RowHeight(0)
- Yxhzjsq = Cxsjwg.FixedRows
- For Rowjsq = Cxsjwg.FixedRows To Cxsjwg.Rows - 1
- If (Not Cxsjwg.RowHidden(Rowjsq)) And (Not GridRowEmpty(Cxsjwg, Rowjsq)) Then
- '摘要
- .TextMatrix(Yxhzjsq, 0) = Cxsjwg.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))
- '输出科目名称
- If Chk_CodeOutput.Value = 1 Then
- .TextMatrix(Yxhzjsq, 1) = Cxsjwg.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls)) + " " + Cxsjwg.TextMatrix(Rowjsq, Sydz("003", GridStr(), Szzls))
- Else
- .TextMatrix(Yxhzjsq, 1) = Cxsjwg.TextMatrix(Rowjsq, Sydz("003", GridStr(), Szzls))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 2)) <> "" Then '结算方式
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 2))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 3)) <> "" Then '票号
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 3))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 4)) <> "" Then '发生日期
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 4))
- End If
- If Val(Cxsjwg.TextMatrix(Rowjsq, 5)) <> 0 Then '数量
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 5)) + Trim(Cxsjwg.TextMatrix(Rowjsq, 7))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 9)) <> "" Then '外币名称
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 10)) + Trim(Cxsjwg.TextMatrix(Rowjsq, 9))
- End If
- If Val(Cxsjwg.TextMatrix(Rowjsq, 11)) <> 0 Then '记帐汇率
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + "汇率:" + Trim(Cxsjwg.TextMatrix(Rowjsq, 11))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 13)) <> "" Then '部门
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 13))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 15)) <> "" Then '往来客户
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 15))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 26)) <> "" Then '往来供应商
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 26))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 17)) <> "" Then '职员
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 17))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 19)) <> "" Then '项目大类
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 19))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 21)) <> "" Then '项目名称
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 21))
- End If
- If Val(Cxsjwg.TextMatrix(Rowjsq, 22)) <> 0 Then '项目数量单位
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + Trim(Cxsjwg.TextMatrix(Rowjsq, 22)) + Trim(Cxsjwg.TextMatrix(Rowjsq, 23))
- End If
- If Trim(Cxsjwg.TextMatrix(Rowjsq, 24)) <> "" Then '经办人
- .TextMatrix(Yxhzjsq, 1) = .TextMatrix(Yxhzjsq, 1) + Space(2) + "经办人:" + Trim(Cxsjwg.TextMatrix(Rowjsq, 24))
- End If
- '借方金额
- .TextMatrix(Yxhzjsq, 2) = Cxsjwg.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))
- '贷方金额
- .TextMatrix(Yxhzjsq, 3) = Cxsjwg.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls))
- .RowHeight(Yxhzjsq) = Cxsjwg.RowHeight(Rowjsq)
- Yxhzjsq = Yxhzjsq + 1
- End If
- Next Rowjsq
- '补空行和添加分页合计
- Int_Pzmyhs = 6
- If .Rows - .FixedRows = 0 Then
- Exit Sub
- Else
- If (.Rows - .FixedRows) Mod Int_Pzmyhs <> 0 Then
- For Jsqte = 1 To Int_Pzmyhs - ((.Rows - .FixedRows) Mod Int_Pzmyhs)
- .AddItem ""
- .RowHeight(.Rows - 1) = Sjhgd
- Next Jsqte
- End If
- End If
- Dbl_Jfhj = 0
- Dbl_Dfhj = 0
- Sjhjsq = 1
- Rowjsq = .FixedRows
- Do While Rowjsq <= .Rows - 1
- Dbl_Jfhj = Dbl_Jfhj + Val(.TextMatrix(Rowjsq, 2))
- Dbl_Dfhj = Dbl_Dfhj + Val(.TextMatrix(Rowjsq, 3))
- If Sjhjsq Mod Int_Pzmyhs = 0 Then
- Rowjsq = Rowjsq + 1
- .AddItem "", Rowjsq
- .RowHeight(Rowjsq) = Sjhgd
- .TextMatrix(Rowjsq, 0) = "合 计"
- .TextMatrix(Rowjsq, 2) = Format(Dbl_Jfhj, "##." + String(Xtjexsws, "0"))
- .TextMatrix(Rowjsq, 3) = Format(Dbl_Dfhj, "##." + String(Xtjexsws, "0"))
- '最后合计输出金额大写
- If Rowjsq = .Rows - 1 Then
- .TextMatrix(Rowjsq, 1) = Fun_Jezh(Dbl_Jfhj)
- End If
- End If
- Sjhjsq = Sjhjsq + 1
- Rowjsq = Rowjsq + 1
- Loop
- End With
- 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
- Else
- '判断是否有辅助行和录入行,如没有则加行
- Do While .TextMatrix(.Rows - 1 - Fzxwghs, 0) = "*"
- .AddItem ""
- .RowHeight(.Rows - 1) = Sjhgd
- Loop
- End If
- End With
- End Sub
- Private Sub Lrzdbz() '录入字段帮助
- If Not Ydcommand.Visible Then
- Exit Sub
- End If
- Valilock = True
- With WglrGrid
- '[>>会计科目编码帮助单独处理
- If .Col = Sydz("002", GridStr(), Szzls) Then
- Xtcdcs = Trim(Ydtext.Text)
- If Len(Xtfhcs) <> 0 Then
- Ydtext.Text = Xtfhcs
- End If
- Else
- '处理通用部分
- 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
- End If
- '[>>处理完毕
- Valilock = False
- If Ydtext.Visible Then
- Ydtext.SetFocus
- End If
- End With
- End Sub
- Private Sub Cshhjwg() '初始化合计网格(*对合计网格来说,录入网格为容器)
- Dim Lrwglkd As Double
- Dim Hjwgpyl As Integer
- 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
- .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
- Lab_Row = Trim(Str(.Row - .FixedRows + 1))
- '显示备注信息
- Call Sub_ShowMemo(WglrGrid.Row)
- 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() '鼠标双击网格显示文本框
- With WglrGrid
- Call xswbk
- End With
- 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
- .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() '录入事中变化处理
- '防止程序改变但不进行处理
- If Wbkbhlock Then
- Exit Sub
- End If
- 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 .TextMatrix(Dqlrwgh, Sydz("002", GridStr(), Szzls)) = "" Then
- Exit Sub
- End If
- 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
- 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 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_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
- .Select Rowjsq, Coljsq
- Exit Sub
- End If
- '接受用户录入
- Select Case KeyAscii
- Case 0 To 32
- '[>>开始 当用户输入空格时,如果在摘要列则自动填入上条记录录入的摘要内容
- ' 如果在金额列则交换借贷内容,此段程序不要求有效性判断,否则应另行处理
- Select Case GridStr(.Col, 1)
- Case "001" '摘要
- If Len(Trim(WglrGrid.TextMatrix(.Row, .Col))) = 0 And Len(Trim(Str_Digest)) <> 0 Then
- WglrGrid.TextMatrix(.Row, .Col) = Str_Digest
- '写有效行数据标志,并打开行有效性判断锁
- Call Xyxhbz(.Row)
- Hyxxpdlock = False
- End If
- Case "004", "005" '借方金额,贷方金额
- If Val(WglrGrid.TextMatrix(.Row, .Col)) = 0 Then
- Str_ChangeTe = WglrGrid.TextMatrix(.Row, Sydz("004", GridStr(), Szzls))
- WglrGrid.TextMatrix(.Row, Sydz("004", GridStr(), Szzls)) = WglrGrid.TextMatrix(.Row, Sydz("005", GridStr(), Szzls))
- WglrGrid.TextMatrix(.Row, Sydz("005", GridStr(), Szzls)) = Str_ChangeTe
- '写有效行数据标志,并打开行有效性判断锁
- Call Xyxhbz(.Row)
- Hyxxpdlock = False
- '计算合计数据
- For Coljsq = Qslz To .Cols - 1
- Call Sjhj(Coljsq)
- Next Coljsq
- End If
- End Select
- '完毕<<]
- '显示录入载体
- 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
- '[>>开始 如果用户在借贷金额位置按"="且当前行金额为零则自动计算借贷合计差额填入录入文本框
- If Chr(KeyAscii) = "=" And (Val(.TextMatrix(.Row, Sydz("004", GridStr(), Szzls))) = 0 And Val(.TextMatrix(.Row, Sydz("005", GridStr(), Szzls))) = 0) Then
- Select Case GridStr(.Col, 1)
- Case "004" '借方金额
- Ydtext.Text = ""
- Call Xyxhbz(.Row)
- Call xswbk
- Ydtext.Text = Format(Val(HjGrid.TextMatrix(0, Sydz("005", GridStr(), Szzls))) - Val(HjGrid.TextMatrix(0, .Col)), "##." + String(Xtjexsws, "0"))
- Case "005" '贷方金额
- Ydtext.Text = ""
- Call Xyxhbz(.Row)
- Call xswbk
- Ydtext.Text = Format(Val(HjGrid.TextMatrix(0, Sydz("004", GridStr(), Szzls))) - Val(HjGrid.TextMatrix(0, .Col)), "##." + String(Xtjexsws, "0"))
- End Select
- '完毕<<]
- 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), wait
- DoEvents
- Valilock = False
- End If
- 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) And HjGrid.Visible) 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
- .TopRow = .TopRow - 1
- 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) = "*"
- If sjh >= .Rows - Fzxwghs - 1 Then
- .AddItem ""
- .RowHeight(.Rows - 1) = Sjhgd
- End If
- End With
- 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 = 1 '报 表 表 尾 行 数
- 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
- Bbxbt(1) = Space(45) + Fun_FormatOutPut("制单日期:" + Trim(LrText(1).Text), 30)
- Bbxbt(1) = Bbxbt(1) + Fun_FormatOutPut("凭证字号:" + Trim(LrText(0).Text) + "-" + Trim(LrText(3).Text), 26)
- Bbbwh(1) = Fun_FormatOutPut("会计主管:", 18) + Fun_FormatOutPut("记帐:" + Lab_Book, 18)
- Bbbwh(1) = Bbbwh(1) + Fun_FormatOutPut("出纳:", 18) + Fun_FormatOutPut("审核:" + Lab_Checker, 18)
- Bbbwh(1) = Bbbwh(1) + Fun_FormatOutPut("制单:" + Lab_Bill, 18) + Trim(Fun_FormatOutPut("附单据数:" + Trim(LrText(2).Text), 23))
- bbxbtzzxs(1) = 0 '报表行组织形式(0-居左 1-居中 2-居右)
- Bbbwhzzxs(1) = 1
- Call Sub_Scpzbb(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 Wbklrwbcl(Index As Integer) '文本框录入事后处理程序
- '以下为依据实际情况自定义部分[
- '在此填写文本框录入事后处理程序
- ']以上为依据实际情况自定义部分
- End Sub
- Private Sub LrText_Change(Index As Integer)
- '屏蔽程序改变控制
- If TextChangeLock Then
- Exit Sub
- End If
- TextValiJudgeLock(Index) = False '打开有效性判断锁
- '限制字段录入长度
- TextChangeLock = True '加锁(防止执行Lrtext_Change)
- Select Case Textint(Index, 1)
- Case 8 '金额型
- Call Sjgskz(LrText(Index), Xtjezws - Xtjexsws - 1, Xtjexsws)
- Case 9 '数量型
- 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
- '[>>随时计算最新单据号
- If Index = 0 Then
- Call Sub_JsVouchNo
- End If
- '<<]
- 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
- 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
- Call Drbmhelp(Textint(Index, 2), Textstr(Index, 4), Trim(LrText(Index).Text))
- 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
- 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() '录入文本框初始化
- '最大录入文本框索引值
- 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
- TextChangeLock = True
- LrText(Jsqte).Text = ""
- LrText(Jsqte).Tag = ""
- If Textint(Jsqte, 5) <> 0 Then
- LrText(Jsqte).MaxLength = Textint(Jsqte, 5)
- End If
- TextChangeLock = False
- End If
- TextValiJudgeLock(Jsqte) = True
- Next Jsqte
- 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
- If Trim(LrText(Index)) = "" Then
- LrText(Index).Tag = ""
- Call Wbklrwbcl(Index)
- Ydcommand1.Visible = False
- TextValiJudgeLock(Index) = True
- TextYxxpd = True
- '[>>如果凭证类别清空,则字号应清空
- If Index = 0 Then
- TextChangeLock = True
- LrText(3).Text = ""
- TextChangeLock = False
- End If
- '<<]
- Exit Function
- End If
- Select Case Textint(Index, 4)
- Case 1 '编码型
- SqlStr = Trim(Textstr(Index, 5))
- SqlStr = Replace(SqlStr, "@", "'" + Trim(LrText(Index).Text) + "'")
- 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
- '[>>凭证类别如有效,且内容已经发生改变则自动计算类别字号
- If Index = 0 Then
- Call Sub_JsVouchNo
- 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
- TextYxxpd = True
- End Function
- Private Sub Save_VouchTemp() '写临时凭证
- '写临时凭证辅表
- Dim count As Long
- CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 1) = LrText(1).Text
- CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 2) = LrText(2).Text
- For Rowjsq = WglrGrid.FixedRows To WglrGrid.Rows - WglrGrid.FixedRows
- If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
- Exit For
- End If
- With CL_MakeVoucherSub.vsFlex_PzChild
- For count = .FixedRows To .Rows - .FixedRows
- If Trim(.TextMatrix(count, 0)) = Trim(CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 0)) _
- And Trim(.TextMatrix(count, 2)) = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls))) _
- And Trim(.TextMatrix(count, 6)) = Trim(WglrGrid.TextMatrix(Rowjsq, 27)) Then
- .TextMatrix(count, 1) = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls)))
- .TextMatrix(count, 7) = Trim(WglrGrid.TextMatrix(Rowjsq, 1))
- .TextMatrix(count, 8) = Trim(WglrGrid.TextMatrix(Rowjsq, 2))
- .TextMatrix(count, 9) = Trim(WglrGrid.TextMatrix(Rowjsq, 3))
- .TextMatrix(count, 10) = Trim(WglrGrid.TextMatrix(Rowjsq, 4))
- .TextMatrix(count, 11) = Trim(WglrGrid.TextMatrix(Rowjsq, 5))
- .TextMatrix(count, 12) = Trim(WglrGrid.TextMatrix(Rowjsq, 6))
- .TextMatrix(count, 13) = Trim(WglrGrid.TextMatrix(Rowjsq, 10))
- .TextMatrix(count, 14) = Trim(WglrGrid.TextMatrix(Rowjsq, 11))
- .TextMatrix(count, 15) = Trim(WglrGrid.TextMatrix(Rowjsq, 12))
- .TextMatrix(count, 16) = Trim(WglrGrid.TextMatrix(Rowjsq, 13))
- .TextMatrix(count, 17) = Trim(WglrGrid.TextMatrix(Rowjsq, 14))
- .TextMatrix(count, 18) = Trim(WglrGrid.TextMatrix(Rowjsq, 15))
- .TextMatrix(count, 19) = Trim(WglrGrid.TextMatrix(Rowjsq, 16))
- .TextMatrix(count, 20) = Trim(WglrGrid.TextMatrix(Rowjsq, 17))
- .TextMatrix(count, 21) = Trim(WglrGrid.TextMatrix(Rowjsq, 20))
- .TextMatrix(count, 22) = Trim(WglrGrid.TextMatrix(Rowjsq, 21))
- .TextMatrix(count, 23) = Trim(WglrGrid.TextMatrix(Rowjsq, 22))
- .TextMatrix(count, 24) = Trim(WglrGrid.TextMatrix(Rowjsq, 23))
- .TextMatrix(count, 25) = Trim(WglrGrid.TextMatrix(Rowjsq, 25))
- .TextMatrix(count, 26) = Trim(WglrGrid.TextMatrix(Rowjsq, 26))
- .TextMatrix(count, 27) = Trim(WglrGrid.TextMatrix(Rowjsq, 24))
- End If
- Next count
- End With
- Next Rowjsq
- End Sub
- Private Sub Sub_ShowMemo(Lng_GridRow) '显示网格备注项
- '函数参数:网格行
- Dim Str_Memo As String
- Str_Memo = ""
- With WglrGrid
- If Len(Trim(.TextMatrix(Lng_GridRow, 2))) <> 0 Then
- Str_Memo = Str_Memo + "结算方式:" + Trim(.TextMatrix(Lng_GridRow, 2)) + Space(2)
- End If
- If Len(Trim(.TextMatrix(Lng_GridRow, 3))) <> 0 Then
- Str_Memo = Str_Memo + "票号:" + Trim(.TextMatrix(Lng_GridRow, 3)) + Space(2)
- End If
- If Len(Trim(.TextMatrix(Lng_GridRow, 4))) <> 0 Then
- Str_Memo = Str_Memo + "发生日期:" + Trim(.TextMatrix(Lng_GridRow, 4)) + Space(2)
- End If
- If Val(.TextMatrix(Lng_GridRow, 5)) <> 0 Then
- Str_Memo = Str_Memo + "数量:" + Format(Trim(.TextMatrix(Lng_GridRow, 5)), "#,##0." + String(Xtslxsws, "0")) + Trim(.TextMatrix(Lng_GridRow, 7)) + Space(2)
- End If
- '显示单价
- If Val(.TextMatrix(Lng_GridRow, Sydz("004", GridStr(), Szzls))) <> 0 And Val(.TextMatrix(Lng_GridRow, 5)) <> 0 Then
- Str_Memo = Str_Memo + "单价:" + Format(Val(.TextMatrix(Lng_GridRow, Sydz("004", GridStr(), Szzls))) / Val(.TextMatrix(Lng_GridRow, 5)), "#,##0." + String(Xtdjxsws, "0"))
- Else
- If Val(.TextMatrix(Lng_GridRow, Sydz("005", GridStr(), Szzls))) <> 0 And Val(.TextMatrix(Lng_GridRow, 5)) <> 0 Then
- Str_Memo = Str_Memo + "单价:" + Format(Val(.TextMatrix(Lng_GridRow, Sydz("005", GridStr(), Szzls))) / Val(.TextMatrix(Lng_GridRow, 5)), "#,##0." + String(Xtdjxsws, "0"))
- End If
- End If
- If Val(.TextMatrix(Lng_GridRow, 10)) <> 0 Then
- Str_Memo = Str_Memo + "外币:" + Format(Trim(.TextMatrix(Lng_GridRow, 10)), "#,##0." + String(Xtjexsws, "0")) + Trim(WglrGrid.TextMatrix(Lng_GridRow, 9)) + Space(2)
- End If
- If Val(.TextMatrix(Lng_GridRow, 11)) <> 0 Then
- Str_Memo = Str_Memo + "汇率:" + Trim(.TextMatrix(Lng_GridRow, 11)) + Space(2)
- End If
- If Len(Trim(.TextMatrix(Lng_GridRow, 13))) <> 0 Then
- Str_Memo = Str_Memo + "部门:" + Trim(.TextMatrix(Lng_GridRow, 13)) + Space(2)
- End If
- If Len(Trim(.TextMatrix(Lng_GridRow, 15))) <> 0 Then
- Str_Memo = Str_Memo + "客户:" + Trim(.TextMatrix(Lng_GridRow, 15)) + Space(2)
- End If
- If Len(Trim(.TextMatrix(Lng_GridRow, 26))) <> 0 Then
- Str_Memo = Str_Memo + "供应商:" + Trim(.TextMatrix(Lng_GridRow, 26)) + Space(2)
- End If
- If Len(Trim(.TextMatrix(Lng_GridRow, 17))) <> 0 Then
- Str_Memo = Str_Memo + "个人:" + Trim(.TextMatrix(Lng_GridRow, 17)) + Space(2)
- End If
- If Len(Trim(.TextMatrix(Lng_GridRow, 21))) <> 0 Then
- Str_Memo = Str_Memo + "项目类别:" + Trim(.TextMatrix(Lng_GridRow, 19)) + Space(2) + "核算项目:" + Trim(.TextMatrix(Lng_GridRow, 21)) + Space(2)
- End If
- If Val(.TextMatrix(Lng_GridRow, 22)) <> 0 Then
- Str_Memo = Str_Memo + "项目数量:" + Trim(.TextMatrix(Lng_GridRow, 22)) + Trim(.TextMatrix(Lng_GridRow, 23)) + Space(2)
- End If
- If Len(Trim(.TextMatrix(Lng_GridRow, 24))) <> 0 Then
- Str_Memo = Str_Memo + "经办人:" + Trim(.TextMatrix(Lng_GridRow, 24))
- End If
- Lab_Memo(0).Caption = Str_Memo
- Lab_Memo(0).Refresh
- End With
- End Sub
- Private Function Sub_SaveBill() As Boolean '保 存 单 据
- Dim count As Long
- Dim Recfind As New ADODB.Recordset '有效性判断动态集
- Dim Rec_AccVouchMain As New ADODB.Recordset '凭证主表动态集
- Dim Rec_AccVouch As New ADODB.Recordset '凭证子表动态集
- Dim Rec_Ass As New ADODB.Recordset '辅助项目记录集
- Dim Jsqte As Integer '临时计数器
- Dim Rowjsq As Long '网格行计数器
- Dim Coljsq As Long '网格列计数器
- Dim Int_RowCount As Integer '有效数据行计数器
- Dim Bln_AssVali As Boolean '辅助核算错误标识
- Dim Lrywlz As Long '录入有误列值
- Dim Dbl_Jfhj As Double '借方合计
- Dim Dbl_Dfhj As Double '贷方合计
- Dim VouchId As Long '凭证ID
- 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)
- If LrText(Jsqte).Enabled = True Then LrText(Jsqte).SetFocus
- Sub_SaveBill = False
- 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)
- If LrText(Jsqte).Enabled = True Then LrText(Jsqte).SetFocus
- Sub_SaveBill = False
- Exit Function
- End If
- End If
- End If
- Next Jsqte
- '对需要进行事后判断的文本框录入内容进行有效性判断 (固定不变)
- For Jsqte = 0 To Max_Text_Index
- If Textint(Jsqte, 9) = 0 Or Textint(Jsqte, 9) = 2 Then
- If Not TextYxxpd(Jsqte) Then
- Exit Function
- End If
- End If
- Next Jsqte
- '[判断用户所选会计期间是否有效(非结帐月份),且制单日期必须和所选会计期间一致
- SqlStr = "Select * FROM GY_Kjrlb Where KjYear=" & Mid(Combo_Kjqj.Text, 1, 4) & " AND period=" & Mid(Combo_Kjqj.Text, 6, 2)
- Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
- With Rectemp
- If Not .EOF Then
- If .Fields("chhsjzbz") Then
- Tsxx = "所选会计期间已经结帐,不能再填制凭证!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End If
- If Not (Format(CDate(LrText(1).Text), "yyyy-mm-dd") >= Format(.Fields("Qsrq"), "yyyy-mm-dd") And Format(CDate(LrText(1).Text), "yyyy-mm-dd") <= Format(.Fields("Zzrq"), "yyyy-mm-dd")) Then
- Tsxx = "制单日期应在所选会计期间范围内!"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(1).SetFocus
- Exit Function
- End If
- End If
- End With
- '下面将对所有有效数据行进行有效性判断
- Int_RowCount = 0
- Dbl_Jfhj = 0
- Dbl_Dfhj = 0
- With WglrGrid
- For Rowjsq = .FixedRows To .Rows
- '带*号者为有效数据行
- 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(Trim(.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))) = 0 And Val(Trim(.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))) = 0 Then
- Tsxx = "借方和贷方金额不能同时为零!"
- Lrywlz = Sydz("004", GridStr(), Szzls)
- GoTo Lrcwcl
- End If
- If Val(Trim(.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))) <> 0 And Val(Trim(.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))) <> 0 Then
- Tsxx = "借方和贷方金额不能同时不为零!"
- Lrywlz = Sydz("004", GridStr(), Szzls)
- GoTo Lrcwcl
- End If
- '判断转帐类别是否已停用
- SqlStr = "Select * FROM Cwzz_VouchClass where VouchClassCode='" & Trim(LrText(0).Text) & "'"
- Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
- If Rectemp.EOF = True Then
- Tsxx = "该凭证的凭证类别不存在,不能保存!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End If
- '判断辅助核算项目是否填写并是否有效
- SqlStr = "Select * FROM Cwzz_AccCode Where Ccode='" & Trim(.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls))) & "'"
- Set Rectemp = Cw_DataEnvi.DataConnect.Execute(SqlStr)
- With Rectemp
- If .EOF Then
- Tsxx = "此科目不存在!"
- GoTo Lrcwcl
- End If
- If Not .Fields("EndFlag") Then
- Tsxx = "此科目非末级科目!"
- GoTo Lrcwcl
- End If
- If .Fields("StopFlag") Then
- Tsxx = "此科目已停用!"
- GoTo Lrcwcl
- End If
- '对于银行科目,如结算方式不为空则结算方式必须有效
- If Trim(Rectemp.Fields("Cproperty")) = "银行" And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 1))) <> 0 Then
- Set Recfind = Cw_DataEnvi.DataConnect.Execute("Select SSCode FROM Gy_Settlement Where SSCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 1)) & "'")
- If Recfind.EOF Then
- Tsxx = "此结算方式不存在!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- Else
- If Recfind.Fields("StopFlag") = True Then
- Tsxx = "此结算方式已停用!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- End If
- End If
- End If
- '如有数量核算且用户选择数量不能为零则数量项不能为零
- If Rectemp.Fields("QuantityFlag") And Chk_Quantity.Value = 1 And Val(WglrGrid.TextMatrix(Rowjsq, 5)) = 0 Then
- Tsxx = "此科目需要数量核算,数量项不能为零!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- End If
- '部门核算则部门不能为空且有效
- If Rectemp.Fields("DeptFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 12))) = 0 Then
- Tsxx = "此科目需要部门核算,部门项不能为空!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- Else
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 12))) <> 0 Then
- Set Recfind = Cw_DataEnvi.DataConnect.Execute("Select DeptCode FROM Gy_Department Where DeptCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 12)) & "'")
- If Recfind.EOF Then
- Tsxx = "此部门不存在!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- End If
- End If
- End If
- '往来单位核算则往来单位不能为空
- If Rectemp.Fields("CusFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 14))) = 0 Then
- Tsxx = "此科目需要往来单位核算,往来单位项不能为空"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- Else
- If Rectemp.Fields("CusFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 14))) <> 0 Then
- Set Recfind = Cw_DataEnvi.DataConnect.Execute("Select CusCode,StopFlag FROM Gy_Customer Where CusCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 14)) & "'")
- If Recfind.EOF Then
- Tsxx = "此往来单位不存在!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- Else
- If Recfind.Fields("StopFlag") = True Then
- Tsxx = "此往来单位已停用!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- End If
- End If
- End If
- End If
- '个人往来核算则个人项不能为空
- If Rectemp.Fields("PersonFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 16))) = 0 Then
- Tsxx = "此科目需要个人往来核算,个人项不能为空!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- Else
- If Rectemp.Fields("PersonFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 16))) <> 0 Then
- Set Recfind = Cw_DataEnvi.DataConnect.Execute("Select PersonCode FROM Gy_Person Where PersonCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 16)) & "'")
- If Recfind.EOF Then
- Tsxx = "此个人不存在!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- End If
- End If
- End If
- '项目核算则项目不能为空
- If Rectemp.Fields("ItemFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 20))) = 0 Then
- Tsxx = "此科目需要项目核算,核算项目不能为空!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- Else
- If Rectemp.Fields("ItemFlag") And Len(Trim(WglrGrid.TextMatrix(Rowjsq, 20))) <> 0 Then
- Set Recfind = Cw_DataEnvi.DataConnect.Execute("Select ItemCode,QuantityFlag,EndFlag FROM Cwzz_Item Where ItemClassCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 18)) & "' And ItemCode='" & Trim(WglrGrid.TextMatrix(Rowjsq, 20)) & "'")
- If Recfind.EOF Then
- Tsxx = "此核算项目不存在!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- Else
- If Recfind.Fields("QuantityFlag") And Val(WglrGrid.TextMatrix(Rowjsq, 22)) = 0 Then
- Tsxx = "此项目需数量核算,则项目数量不能为零!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- End If
- If Recfind.Fields("EndFlag") = True Then
- Tsxx = "此非末级项目!"
- Lrywlz = Sydz("002", GridStr(), Szzls)
- Bln_AssVali = True
- GoTo Lrcwcl
- End If
- End If
- End If
- End If
- End With
- '计算借贷方合计数据
- Dbl_Jfhj = Dbl_Jfhj + Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls)))
- Dbl_Dfhj = Dbl_Dfhj + Val(WglrGrid.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls)))
- Next Rowjsq
- '会计分录行数不能为零
- If Int_RowCount = 0 Then
- Tsxx = "凭证会计分录行数为零,不能存盘!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End If
- '凭证借贷双方合计必须平衡
- If Abs(Dbl_Jfhj - Dbl_Dfhj) >= 0.01 Then
- Tsxx = "凭证借贷不平衡!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End If
- End With '网格
- '如果以上有效性检查均顺利通过,则执行存盘动作
- On Error GoTo Swcwcl
- Cw_DataEnvi.DataConnect.BeginTrans
- '写正式凭证
- '1.判断凭证号是否重复,如重复则取最大值+1为当前凭证号,否则以当前凭证号存盘
- Rec_AccVouch.Open "Select VouchNo From chhs_VouchMain Where Year=" & Int_Year & " and Period=" & Int_Period & " And VouchClassCode='" & Trim(LrText(0).Text) & "' And VouchNo=" & Val(LrText(3).Text), Cw_DataEnvi.DataConnect, adOpenDynamic, adLockPessimistic
- Set Rec_AccVouch = Cw_DataEnvi.DataConnect.Execute(SqlStr)
- If Not Rec_AccVouch.EOF Then
- If Rectemp.State = 1 Then Rectemp.Close
- Rectemp.Open "Select MAX(VouchNo) AS MVouchNo FROM chhs_VouchMain Where Year=" & Mid(Combo_Kjqj.Text, 1, 4) & " AND Period=" & Mid(Combo_Kjqj.Text, 6, 2) & _
- " AND VouchClassCode='" & Trim(LrText(0).Text) & "'", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockPessimistic
- TextChangeLock = True
- If Not IsNull(Rectemp.Fields("MVouchNo")) Then
- LrText(3).Text = Mid(Trim(Str(10000 + Rectemp.Fields("MVouchNo") + 1)), 2, 4)
- Else
- LrText(3).Text = "0001"
- End If
- TextChangeLock = False
- Else
- TextChangeLock = True
- LrText(3).Text = "0001"
- TextChangeLock = False
- End If
- Int_VouchNo = Val(LrText(3).Text) '凭证号
- '打开凭证主表动态集
- If Rec_AccVouchMain.State = 1 Then Rec_AccVouchMain.Close
- Rec_AccVouchMain.Open "Select * From chhs_VouchMain Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- With Rec_AccVouchMain
- .AddNew
- .Fields("VouchID") = CreatBillID("1330")
- .Fields("Year") = Int_Year '会计年度
- .Fields("Period") = Int_Period '会计期间
- .Fields("Ddate") = CDate(LrText(1).Text) '制单日期
- .Fields("VouchClassCode") = Trim(LrText(0).Text) '凭证类别
- .Fields("VouchNo") = Int(Int_VouchNo) '凭证号
- .Fields("Doc") = Val(LrText(2).Text) '附单据数
- .Fields("Bill") = Trim(Lab_Bill.Caption) '制单人
- .Update
- VouchId = .Fields("VouchId")
- End With
- '打开凭证子表动态集
- If Rec_AccVouch.State = 1 Then Rec_AccVouch.Close
- Rec_AccVouch.Open "Select * From chhs_VouchSub Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- For Rowjsq = WglrGrid.FixedRows To WglrGrid.Rows
- If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
- Exit For
- End If
- With Rec_AccVouch
- .AddNew
- .Fields("SerialID") = Rowjsq
- .Fields("VouchID") = VouchId '凭证ID
- .Fields("Digest") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))) '摘要
- .Fields("Ccode") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("002", GridStr(), Szzls))) '会计科目
- .Fields("Jfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) '借方金额
- .Fields("Dfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls))) '贷方金额
- If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
- .Fields("Jfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 5)) '借方数量
- Else
- .Fields("Dfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 5)) '贷方数量
- End If
- '如为外币核算则原币编码为外币编码否则填充本位币编码,同时填充原币金额
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 8))) <> 0 And Trim(WglrGrid.TextMatrix(Rowjsq, 8)) <> XtSCurrCode Then
- .Fields("ForeignCurrCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 8)) '外币编码
- .Fields("AccRate") = Val(WglrGrid.TextMatrix(Rowjsq, 11)) '记帐汇率
- If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
- .Fields("Wbjfje") = Val(WglrGrid.TextMatrix(Rowjsq, 10)) '本币借方金额
- Else
- .Fields("Wbdfje") = Val(WglrGrid.TextMatrix(Rowjsq, 10)) '本币贷方金额
- End If
- Else
- .Fields("ForeignCurrCode") = XtSCurrCode '原币编码
- .Fields("AccRate") = 1 '记帐汇率
- If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
- .Fields("Wbjfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) '原币借方金额
- Else
- .Fields("Wbdfje") = Val(WglrGrid.TextMatrix(Rowjsq, Sydz("005", GridStr(), Szzls))) '原币贷方金额
- End If
- End If
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 4))) <> 0 Then
- .Fields("BillDate") = CDate(Trim(WglrGrid.TextMatrix(Rowjsq, 4))) '发生日期(银行)
- End If
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 1))) <> 0 Then
- .Fields("SScode") = Trim(WglrGrid.TextMatrix(Rowjsq, 1)) '结算方式(银行)
- End If
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 3))) <> 0 Then
- .Fields("BillNo") = Trim(WglrGrid.TextMatrix(Rowjsq, 3)) '票号(银行)
- End If
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 16))) <> 0 Then
- .Fields("PersonCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 16)) '职员编码
- End If
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 12))) <> 0 Then
- .Fields("DeptCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 12)) '部门编码
- End If
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 14))) <> 0 Then
- .Fields("CusCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 14)) '往来客户编码
- End If
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 25))) <> 0 Then
- .Fields("Supplier_Code") = Trim(WglrGrid.TextMatrix(Rowjsq, 25)) '往来供应商编码
- End If
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 18))) <> 0 Then
- .Fields("ItemClassCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 18)) '项目大类编码
- End If
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 20))) <> 0 Then
- .Fields("ItemCode") = Trim(WglrGrid.TextMatrix(Rowjsq, 20)) '项目编码
- If Val(WglrGrid.TextMatrix(Rowjsq, Sydz("004", GridStr(), Szzls))) <> 0 Then
- .Fields("ItemJfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 22)) '项目借方数量
- Else
- .Fields("ItemDfsl") = Val(WglrGrid.TextMatrix(Rowjsq, 22)) '项目贷方数量
- End If
- End If
- If Len(Trim(WglrGrid.TextMatrix(Rowjsq, 24))) <> 0 Then
- .Fields("TranPerson") = Trim(WglrGrid.TextMatrix(Rowjsq, 24)) '经办人
- End If
- .Update
- End With
- Next Rowjsq
- '将凭证号添加到scpz_frmlist中
- If lbl_Tag.Caption = "0" Then
- For count = CL_MakeVoucher.CxbbGrid.FixedRows To CL_MakeVoucher.CxbbGrid.Rows - CL_MakeVoucher.CxbbGrid.FixedRows
- If InStr(1, "1301,1302,1303", Trim(CL_MakeVoucher.CxbbGrid.TextMatrix(count, 6))) Then
- If Trim(CL_MakeVoucher.CxbbGrid.TextMatrix(count, 9)) = Trim(CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 0)) Then
- CL_MakeVoucher.CxbbGrid.TextMatrix(count, 18) = Trim(LrText(3).Text)
- Exit For
- End If
- Else
- If Trim(CL_MakeVoucher.CxbbGrid.TextMatrix(count, 8)) = Trim(CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 0)) Then
- CL_MakeVoucher.CxbbGrid.TextMatrix(count, 18) = Trim(LrText(3).Text)
- Exit For
- End If
- End If
- Next count
- Else
- For count = CL_MakeVoucher.CxbbGrid.FixedRows To CL_MakeVoucher.CxbbGrid.Rows - CL_MakeVoucher.CxbbGrid.FixedRows
- If Trim(CL_MakeVoucher.CxbbGrid.TextMatrix(count, 11)) Then
- CL_MakeVoucher.CxbbGrid.TextMatrix(count, 18) = Trim(LrText(3).Text)
- End If
- Next count
- End If
- '在chhs_list中加上标记
- If lbl_Tag.Caption = "0" Then
- Select Case Trim(CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 6))
- Case "1301,1302,1303"
- Cw_DataEnvi.DataConnect.Execute ("UPDATE Chhs_List SET VouchId=" & VouchId & " WHERE KjYear='" & PGKjYear & "' AND Period='" & PGNowmon & "' AND InoutAdjustMainId=" & Trim(CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 0)) & " AND InoutAdjustSubId=" & Trim(CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 5)) & "")
- Case "1307"
- Cw_DataEnvi.DataConnect.Execute ("UPDATE Chhs_List SET VouchId=" & VouchId & " WHERE KjYear='" & PGKjYear & "' AND Period='" & PGNowmon & "' AND ListId=" & Trim(CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 0)) & "")
- Case Else
- Cw_DataEnvi.DataConnect.Execute ("UPDATE Chhs_List SET VouchId=" & VouchId & " WHERE startflag=0 and KjYear='" & PGKjYear & "' AND Period='" & PGNowmon & "' AND InoutMainId=" & Trim(CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 0)) & " AND InOutSubId=" & Trim(CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 5)) & "")
- End Select
- Else
- For count = CL_MakeVoucherSub.WglrGrid.FixedRows To CL_MakeVoucherSub.WglrGrid.Rows - CL_MakeVoucherSub.WglrGrid.FixedRows
- Select Case Trim(CL_MakeVoucherSub.WglrGrid.TextMatrix(count, 4))
- Case "1301,1302,1303"
- Cw_DataEnvi.DataConnect.Execute ("UPDATE Chhs_List SET VouchId=" & VouchId & " WHERE KjYear='" & PGKjYear & "' AND Period='" & PGNowmon & "' AND InoutAdjustMainId=" & Trim(CL_MakeVoucherSub.WglrGrid.TextMatrix(count, 2)) & " AND InoutAdjustSubId=" & Trim(CL_MakeVoucherSub.WglrGrid.TextMatrix(count, 3)) & "")
- Case "1307"
- Cw_DataEnvi.DataConnect.Execute ("UPDATE Chhs_List SET VouchId=" & VouchId & " WHERE KjYear='" & PGKjYear & "' AND Period='" & PGNowmon & "' AND ListId=" & Trim(CL_MakeVoucherSub.WglrGrid.TextMatrix(count, 0)) & "")
- Case Else
- Cw_DataEnvi.DataConnect.Execute ("UPDATE Chhs_List SET VouchId=" & VouchId & " WHERE startflag=0 and KjYear='" & PGKjYear & "' AND Period='" & PGNowmon & "' AND InoutMainId=" & Trim(CL_MakeVoucherSub.WglrGrid.TextMatrix(count, 0)) & " AND InOutSubId=" & Trim(CL_MakeVoucherSub.WglrGrid.TextMatrix(count, 1)) & "")
- End Select
- Next count
- End If
- '在CL_MakeVoucherSub中加入生成凭证标记
- CL_MakeVoucherSub.vsFlex_PzMain.TextMatrix(currrecord, 3) = 1
- Lab_Succeed.Visible = True
- Lab_Succeed.Caption = "已生成"
- Cw_DataEnvi.DataConnect.CommitTrans
- Sub_SaveBill = True
- Tsxx = "凭证号:" & Trim(LrText(0).Text) & "--" & Trim(LrText(3).Text) & "保存完毕! "
- Call Xtxxts(Tsxx, 0, 4)
- '标识单据发生改动
- Bln_BillChange = True
- '设置操作状态为浏览
- Lab_OperStatus = "1"
- Call Sub_OperStatus("11")
- Exit Function
- Swcwcl:
- Cw_DataEnvi.DataConnect.RollbackTrans
- Lab_Succeed.Caption = ""
- 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
- Public Property Let LoadMassage(ByVal vNewValue As Integer)
- MLoadMassage = vNewValue
- End Property