资源名称:ERPSYS.zip [点击查看]
上传用户:zhpu1995
上传日期:2013-09-06
资源大小:61151k
文件大小:164k
源码类别:
企业管理
开发平台:
Visual Basic
- '1.对于某些单据号自动生成的单据则可在此处自动生成
- LrText(0).Text = CreatBillCode(BillCode, True)
- '2.开始存盘
- '打开单据主表动态集
- If Rec_VouchMain.State = 1 Then Rec_VouchMain.Close
- Rec_VouchMain.Open "Select * From Kf_InventoryMain Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- With Rec_VouchMain
- .AddNew
- .Fields("InventoryMainId") = CreatBillID(BillCode) '盘点单ID
- .Fields("BillCode") = "1208" '单据类型
- .Fields("BillNum") = Trim(LrText(0).Text) '单据号
- .Fields("BillDate") = CDate(LrText(2).Text) '单据日期
- If Trim(LrText(3).Tag) <> "" Then
- .Fields("DeptCode") = Trim(LrText(3).Tag) '部门
- Else
- .Fields("DeptCode") = Null
- End If
- If Trim(LrText(1).Tag) <> "" Then
- .Fields("WhCode") = Trim(LrText(1).Tag) '仓库编码
- Else
- .Fields("WhCode") = Null
- End If
- If Trim(LrText(5).Tag) <> "" Then
- .Fields("Outclass") = Trim(LrText(5).Tag) '出库类别
- Else
- .Fields("Outclass") = Null
- End If
- If Trim(LrText(4).Tag) <> "" Then
- .Fields("Inclass") = Trim(LrText(4).Tag) '入库类别
- Else
- .Fields("Inclass") = Null
- End If
- If Trim(LrText(6).Tag) <> "" Then
- .Fields("PersonCode") = Trim(LrText(6).Tag) '人员编码
- Else
- .Fields("PersonCode") = Null
- End If
- .Fields("kjyear") = Int_Year '会计年度
- .Fields("period") = Int_Period '会计期间
- .Fields("Remark") = Trim(LrText(7).Text) '备注
- .Fields("Maker") = Xtczy '制单人
- .Update
- '系统读出单据ID写入Lab_BillID
- Lab_BillId.Caption = .Fields("InventoryMainId")
- End With
- Else
- '修改单据
- '1.删除原单据子表中所有内容
- Cw_DataEnvi.DataConnect.Execute ("Delete Kf_InventorySub Where InventoryMainId=" & S2N(Lab_BillId.Caption))
- '打开单据主表动态集
- If Rec_VouchMain.State = 1 Then Rec_VouchMain.Close
- Rec_VouchMain.Open "Select * From Kf_InventoryMain Where InventoryMainId=" & S2N(Lab_BillId.Caption), Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- With Rec_VouchMain
- .Fields("InventoryMainId") = CreatBillID(BillCode) '盘点单ID
- .Fields("BillCode") = "1208" '单据类型
- .Fields("BillNum") = Trim(LrText(0).Text) '单据号
- .Fields("BillDate") = CDate(LrText(2).Text) '单据日期
- If Trim(LrText(3).Tag) <> "" Then
- .Fields("DeptCode") = Trim(LrText(3).Tag) '部门编码
- Else
- .Fields("DeptCode") = Null
- End If
- If Trim(LrText(1).Tag) <> "" Then
- .Fields("WhCode") = Trim(LrText(1).Tag) '仓库编码
- Else
- .Fields("WhCode") = Null
- End If
- If Trim(LrText(5).Tag) <> "" Then
- .Fields("Outclass") = Trim(LrText(5).Tag) '出库类别
- Else
- .Fields("Outclass") = Null
- End If
- If Trim(LrText(4).Tag) <> "" Then
- .Fields("Inclass") = Trim(LrText(4).Tag) '入库类别
- Else
- .Fields("Inclass") = Null
- End If
- If Trim(LrText(6).Tag) <> "" Then
- .Fields("PersonCode") = Trim(LrText(6).Tag) '人员编码
- Else
- .Fields("PersonCode") = Null
- End If
- .Fields("kjyear") = Int_Year '会计年度
- .Fields("period") = Int_Period '会计期间
- .Fields("Remark") = Trim(LrText(7).Text) '备注
- .Fields("Maker") = Xtczy '制单人
- .Update
- Lab_BillId.Caption = .Fields("InventoryMainId")
- End With
- End If
- '2.对单据子表进行处理
- '打开单据子表动态集
- If Rec_VouchSub.State = 1 Then Rec_VouchSub.Close
- Rec_VouchSub.Open "Select * From Kf_InventorySub Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- '将网格中有效数据行写入单据子表
- For Rowjsq = WglrGrid.FixedRows To WglrGrid.Rows - 1
- If WglrGrid.TextMatrix(Rowjsq, 0) <> "*" Then
- Exit For
- End If
- With Rec_VouchSub
- .AddNew
- .Fields("InventorySubId") = Rowjsq - WglrGrid.FixedRows + 1
- .Fields("InventoryMainId") = S2N(Lab_BillId.Caption)
- .Fields("MNumber") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("001", GridStr(), Szzls))) '物料编码
- If Trim(WglrGrid.TextMatrix(Rowjsq, 1)) <> "" Then
- .Fields("MArea") = Trim(WglrGrid.TextMatrix(Rowjsq, 1)) '货区
- Else
- .Fields("MArea") = Null
- End If
- .Fields("BatchNum") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("006", GridStr(), Szzls))) '批次
- .Fields("AccQuan") = S2N(WglrGrid.TextMatrix(Rowjsq, Sydz("007", GridStr(), Szzls))) '盘点数量
- .Fields("QuanInve") = S2N(WglrGrid.TextMatrix(Rowjsq, Sydz("008", GridStr(), Szzls))) '盈亏数量
- .Fields("PlanPrice") = S2N(WglrGrid.TextMatrix(Rowjsq, Sydz("010", GridStr(), Szzls))) '计划单价
- .Fields("Price") = S2N(WglrGrid.TextMatrix(Rowjsq, Sydz("011", GridStr(), Szzls))) '单价
- .Fields("PlanMoney") = S2N(WglrGrid.TextMatrix(Rowjsq, Sydz("012", GridStr(), Szzls))) '计划金额
- .Fields("EMoney") = S2N(WglrGrid.TextMatrix(Rowjsq, Sydz("013", GridStr(), Szzls))) '金额
- .Fields("Cause") = Trim(WglrGrid.TextMatrix(Rowjsq, Sydz("014", GridStr(), Szzls))) '原因
- .Update
- End With
- Next Rowjsq
- Cw_DataEnvi.DataConnect.CommitTrans
- Sub_SaveBill = True
- Tsxx = "单据存盘完毕! 单据号:" & Trim(LrText(0).Text)
- Call Xtxxts(Tsxx, 0, 4)
- '标识单据发生改动
- Bln_BillChange = True
- '设置单据改变后的状态
- Lab_OperStatus = "1"
- If Label1.Visible Then
- Tlb_Action.Buttons("jh").Enabled = False
- Else
- Tlb_Action.Buttons("jh").Enabled = True
- End If
- Call Sub_OperStatus("10")
- Rec_Query.Requery
- Rec_Query.Find "InventoryMainId=" & S2N(Lab_BillId.Caption)
- Exit Function
- Swcwcl: '数据存盘时出现错误
- Cw_DataEnvi.DataConnect.RollbackTrans
- With WglrGrid
- If Err.Number = -2147217887 Then
- Tsxx = "单据中第 " & Trim(str(Rowjsq - .FixedRows + 1)) & " 条分录录入数据超出允许范围!"
- Call Xtxxts(Tsxx, 0, 1)
- Changelock = True
- .Select Rowjsq, Qslz
- WglrGrid.SetFocus
- Changelock = False
- Exit Function
- Else
- Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Function
- End If
- End With
- Lrcwcl: '录入错误处理(存盘前逐行有效性判断)
- With WglrGrid
- Call Xtxxts("(第 " & Trim(str(Rowjsq - .FixedRows + 1)) & " 条单据分录)-" & Tsxx, 0, 1)
- Changelock = True
- .Select Rowjsq, Lrywlz
- WglrGrid.SetFocus
- Changelock = False
- Exit Function
- End With
- End Function
- '选择首张,上张,下张,末张(此4个过程只需用您的单据ID字段名替换"InventoryMainId"即可)
- Private Sub Sub_First() '首 张
- With Rec_Query
- If .RecordCount = 0 Then
- Exit Sub
- End If
- .MoveFirst
- Lab_BillId.Caption = .Fields("InventoryMainId")
- Call Sub_ShowBill
- End With
- End Sub
- Private Sub Sub_Prev() '上 张
- With Rec_Query
- If .RecordCount = 0 Then
- Exit Sub
- End If
- If Not .BOF Then
- .MovePrevious
- End If
- If Not .BOF Then
- Lab_BillId.Caption = .Fields("InventoryMainId")
- Else
- .MoveNext
- End If
- Call Sub_ShowBill
- End With
- End Sub
- Private Sub Sub_next() '下 张
- With Rec_Query
- If .RecordCount = 0 Then
- Exit Sub
- End If
- If Not .EOF Then
- .MoveNext
- End If
- If Not .EOF Then
- Lab_BillId.Caption = .Fields("InventoryMainId")
- Else
- .MovePrevious
- End If
- Call Sub_ShowBill
- End With
- End Sub
- Private Sub Sub_Last() '末 张
- With Rec_Query
- If .RecordCount = 0 Then
- Exit Sub
- End If
- .MoveLast
- Lab_BillId.Caption = .Fields("InventoryMainId")
- Call Sub_ShowBill
- End With
- End Sub
- '[>>===================以下为根据实际业务需要自定义过程区域=============================<<]
- '审核,弃审
- Private Sub Sub_CheckBill() '审 核
- '[>>
- '此处可以写入禁止单据审核的理由
- '<<]
- '判断用户是否有此功能执行权限,如有则写上机日志(进入)
- If Not Security_Log(Str_RightCheck, Xtczybm, 1, True) Then
- Exit Sub
- End If
- '将单据写入审核标识
- Cw_DataEnvi.DataConnect.Execute ("Update Kf_InventoryMain Set Checker='" & Xtczy & "' Where InventoryMainId=" & S2N(Lab_BillId.Caption))
- '写入系统操作员
- LrText(11).Text = Xtczy
- '设置审核弃审按钮状态
- ' Call Sub_CheckStatus
- '标识单据发生变化
- Bln_BillChange = True
- End Sub
- Private Sub Sub_AbandonCheck() '弃 审
- '[>>
- '此处可以写入禁止单据弃审的理由
- '<<]
- '判断用户是否有此功能执行权限,如有则写上机日志(进入)
- If Not Security_Log(Str_RightCheck, Xtczybm, 1, True) Then
- Exit Sub
- End If
- '将单据清除审核标识
- Cw_DataEnvi.DataConnect.Execute ("Update Kf_InventoryMain Set Checker='' Where InventoryMainId=" & S2N(Lab_BillId.Caption))
- '清空单据审核人
- LrText(11).Text = ""
- '标识单据发生变化
- Bln_BillChange = True
- End Sub
- Private Function Fun_AllowEdit() As Boolean '判断当前单据是否允许编辑或删除
- Dim RecTemp As New ADODB.Recordset '临时使用动态集
- Fun_AllowEdit = False
- Sqlstr = "Select ChalkitupMan From Kf_InventoryMain Where InventoryMainId=" & S2N(Lab_BillId.Caption)
- Set RecTemp = Cw_DataEnvi.DataConnect.Execute(Sqlstr)
- With RecTemp
- If Not .EOF Then
- If Trim(.Fields("ChalkitupMan") & "") <> "" Then
- Tsxx = "该单据已记帐,不能修改或删除!"
- Call Xtxxts(Tsxx, 0, 4)
- Exit Function
- End If
- End If
- End With
- Fun_AllowEdit = True
- 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
- 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
- With WglrGrid
- Valilock = True
- '处理通用部分
- Changelock = True '调入另外窗体必须加锁
- If GridInt(.Col, 6) <> 1 Then
- If GridStr(.Col, 3) = "KF_BatchHelp" Then
- strHlpR = FunHlpR(Trim(GridStr(.Col, 3)), "whcode", Trim(LrText(1).Tag))
- Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(.TextMatrix(.Row, Sydz("001", GridStr(), Szzls))))
- Else
- strHlpR = FunHlpR(Trim(GridStr(.Col, 3)), "whcode", Trim(LrText(1).Tag))
- Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(Ydtext.Text))
- End If
- Else
- Call Drbmhelp(GridInt(.Col, 6), GridStr(.Col, 3), Trim(Ydtext.Text))
- End If
- Changelock = False
- If Len(Xtfhcs) <> 0 Then
- If GridInt(.Col, 7) = 0 Then
- Ydtext.Text = Xtfhcs
- Else
- Ydtext.Text = Xtfhcsfz
- End If
- End If
- Valilock = False
- If Ydtext.Visible Then
- Ydtext.SetFocus
- End If
- End With
- End Sub
- Private Sub Cshhjwg() '初始化合计网格(*对合计网格来说,录入网格为容器)
- With HjGrid
- '是否显示合计网格
- If Not Sfxshjwg Then
- .Visible = False
- Exit Sub
- Else
- .Visible = True
- End If
- '设置网格相关属性
- .Enabled = False
- .Appearance = flexFlat
- .BorderStyle = flexBorderNone
- .ScrollBars = flexScrollBarNone
- .Width = WglrGrid.Width
- .FixedRows = 0
- .Rows = 1
- .Cols = WglrGrid.Cols
- .LeftCol = WglrGrid.LeftCol
- .TextMatrix(0, Qslz) = "合 计"
- For jsqte = 0 To WglrGrid.Cols - 1
- .ColHidden(jsqte) = WglrGrid.ColHidden(jsqte)
- .ColWidth(jsqte) = WglrGrid.ColWidth(jsqte)
- .ColAlignment(jsqte) = WglrGrid.ColAlignment(jsqte)
- .ColFormat(jsqte) = WglrGrid.ColFormat(jsqte)
- Next jsqte
- .ColAlignment(Qslz) = flexAlignCenterTop
- For jsqte = .FixedRows To .Rows - 1
- .RowHeight(jsqte) = .Height / .Rows
- Next jsqte
- '程序自动调整网格高度(自动设置为网格剩余高度+辅助项网格行数(默认为1)*数据行高度)、并设置其位置信息
- .Height = Fzxwghs * Sjhgd + ((WglrGrid.Height - WglrGrid.FixedRows * WglrGrid.RowHeight(0)) Mod Sjhgd)
- .RowHeight(0) = .Height
- .Move 0, WglrGrid.Height - .Height, WglrGrid.Width, .Height
- End With
- End Sub
- Private Sub Form_Resize() '窗体大小发生变化时,重新显示文本框
- Call Cxxswbk
- End Sub
- Private Function Fun_Drfrmyxxpd() As Boolean '调入其它窗体或功能产生的有效性判断(包括数据回写)
- Fun_Drfrmyxxpd = True
- With WglrGrid
- '如果当前网格处于编辑状态,则先进行数据回写再进行有效性判断
- If Ydtext.Visible Or YdCombo.Visible Then
- Call Lrsjhx
- If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
- Fun_Drfrmyxxpd = False
- Exit Function
- End If
- End If
- '进行行有效性判断
- If Not Sjhzyxxpd(.Row) Then
- Fun_Drfrmyxxpd = False
- Exit Function
- End If
- End With
- End Function
- Private Sub WglrGrid_AfterUserResize(ByVal Row As Long, ByVal Col As Long) '调整列宽
- If HjGrid.Visible Then
- With HjGrid
- .ColWidth(Col) = WglrGrid.ColWidth(Col)
- End With
- End If
- End Sub
- Private Sub WglrGrid_EnterCell() '显示当前数据行相关信息
- With WglrGrid
- If .Row >= .FixedRows Then
- '[>>
- '此处可以填写显示与此网格行相关信息
- '<<]
- End If
- End With
- End Sub
- Private Sub WglrGrid_GotFocus() '网格得到焦点
- '网格得到焦点,如果当前选择行为非数据行
- '则调整当前焦点至有效数据行
- With WglrGrid
- If .Row < .FixedRows And .Rows > .FixedRows Then
- Changelock = True
- .Select .FixedRows, .Col
- Changelock = False
- End If
- If .Col < Qslz Then
- Changelock = True
- .Select .Row, Qslz
- Changelock = False
- End If
- End With
- End Sub
- Private Sub WglrGrid_LostFocus() '录入网格失去焦点
- '用以屏蔽调用其它窗体时发生网格失去焦点事件
- If Changelock Then
- Exit Sub
- End If
- '引发网格RowcolChange事件
- With WglrGrid
- If Not (Ydtext.Visible Or YdCombo.Visible) Then
- .Select 0, 0
- End If
- End With
- End Sub
- Private Sub WglrGrid_AfterScroll(ByVal OldTopRow As Long, ByVal OldLeftCol As Long, ByVal NewTopRow As Long, ByVal NewLeftCol As Long) '限制用户在录入过程中滚动鼠标
- If Gdtlock Then
- Exit Sub
- End If
- With WglrGrid
- If Ydtext.Visible Or YdCombo.Visible Then
- Gdtlock = True
- .TopRow = Dqtoprow
- .LeftCol = Dqleftcol
- Gdtlock = False
- Exit Sub
- End If
- HjGrid.LeftCol = .LeftCol
- End With
- End Sub
- Private Sub WglrGrid_LeaveCell() '离开单元格
- If Changelock Then
- Exit Sub
- End If
- '记录刚刚离开网格单元的行列值
- Dqlkwgh = WglrGrid.Row
- Dqlkwgl = WglrGrid.Col
- '判断是否需要录入数据回写
- If Not (Ydtext.Visible Or YdCombo.Visible) Then
- Exit Sub
- End If
- Call Lrsjhx
- End Sub
- Private Sub WglrGrid_RowColChange() '网格录入行列发生变化时,进行有效性判断
- Valilock = True '屏蔽文本框失去焦点进行有效性判断
- With WglrGrid
- If Changelock Then
- Exit Sub
- End If
- If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
- Exit Sub
- End If
- If .Row <> Dqlkwgh Then
- If Not Sjhzyxxpd(Dqlkwgh) Then
- Exit Sub
- End If
- End If
- End With
- Call fhyxh
- Call Xldql
- End Sub
- Private Sub WglrGrid_DblClick() '鼠标双击网格显示文本框
- 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
- If Rowjsq <= .Rows - 1 Then
- .Select Rowjsq, Coljsq
- End If
- Case vbKeyUp '上 箭 头 =38
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- If .Row > .FixedRows Then
- .Row = .Row - 1
- End If
- Case vbKeyDown '下 箭 头 =40
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- If .Row < .Rows - 1 Then
- .Row = .Row + 1
- End If
- Case vbKeyLeft '左 箭 头 =37
- If .Col - 1 = Qslz Then
- If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
- GoTo jzzx
- End If
- End If
- If Ydtext.SelStart = 0 And .Col > Qslz Then
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- Coljsq = .Col - 1
- Do While Coljsq > Qslz
- If Coljsq - 1 = Qslz Then
- If .ColHidden(Qslz) Or (Not GridBoolean(Qslz, 1)) Then
- GoTo jzzx
- End If
- End If
- If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
- Coljsq = Coljsq - 1
- Else
- Exit Do
- End If
- Loop
- .Select .Row, Coljsq
- End If
- jzzx:
- Case vbKeyRight '右 箭 头 =39
- wblong = Len(Ydtext.Text)
- If (Ydtext.SelStart = wblong Or Ydtext.SelLength = wblong) Then
- KeyCode = 0
- .SetFocus
- Call Lrsjhx
- Rowjsq = .Row
- Coljsq = .Col + 1
- If Coljsq > .Cols - 1 Then
- If Rowjsq < .Rows - 1 Then
- Rowjsq = Rowjsq + 1
- End If
- Coljsq = Qslz
- End If
- Do While Rowjsq <= .Rows - 1
- If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
- Coljsq = Coljsq + 1
- If Coljsq > .Cols - 1 Then
- Rowjsq = Rowjsq + 1
- Coljsq = Qslz
- End If
- Else
- Exit Do
- End If
- Loop
- .Select Rowjsq, Coljsq
- End If
- Case Else
- End Select
- End With
- End Sub
- Private Sub ydtext_KeyPress(KeyAscii As Integer) '录入字符事中控制
- Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
- If KeyAscii <> 0 Then
- Call Xyxhbz(Dqlrwgh)
- End If
- End Sub
- Private Sub ydtext_Change() '录入事中变化处理
- '防止程序改变但不进行处理
- If Wbkbhlock Then
- Exit Sub
- End If
- With WglrGrid
- '限制字段录入长度
- Wbkbhlock = True
- Call TextChangeLimit(Ydtext, GridInt(.Col, 1)) '去掉无效字符
- Select Case GridInt(.Col, 1)
- Case 8, 11 '金额型
- Call Sjgskz(Ydtext, Xtjezws - Xtjexsws - 1, Xtjexsws)
- Case 9, 12 '数量型
- Call Sjgskz(Ydtext, Xtslzws - Xtslxsws - 1, Xtslxsws)
- Case 10 '单价型
- Call Sjgskz(Ydtext, Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
- Case Else '其他类型
- If GridInt(.Col, 3) <> 0 Or GridInt(.Col, 4) <> 0 Then
- Call Sjgskz(Ydtext, GridInt(.Col, 3), GridInt(.Col, 4))
- End If
- End Select
- Wbkbhlock = False
- End With
- End Sub
- Private Sub ydtext_LostFocus() '如果由于选中网格之外的控件而发生有效性判断(选中网格会先发生Rowcolchange事件置Valiock为TRUE)
- With WglrGrid
- If Not Valilock Then
- Call Lrsjhx
- If Not sjzdyxxpd(Dqlrwgh, Dqlrwgl) Then
- Exit Sub
- End If
- If Not Sjhzyxxpd(Dqlrwgh) Then
- Exit Sub
- End If
- End If
- End With
- End Sub
- Private Sub xswbk() '在当前选中单元显示文本框,列表框,帮助按钮(通用)
- Dim Wbkpy As Integer, Wbkpy1 As Integer '文本框偏移量
- '当某种条件成立时禁止文本框激活使单据处于录入状态
- If Not Fun_AllowInput Then
- Exit Sub
- End If
- '显示文本框前返回有效行列(解决滚动条问题)
- Call Xldqh
- Call Xldql
- '隐藏文本框,帮助按钮,列表组合框
- Call Ycwbk
- With WglrGrid
- Dqlrwgh = .Row
- Dqlrwgl = .Col
- If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
- Exit Sub
- End If
- Wbkpy = 30
- Wbkpy1 = 15
- If GridBoolean(.Col, 3) Then
- YdCombo.Left = .CellLeft + .Left + Wbkpy
- YdCombo.Top = .CellTop + .Top + Wbkpy
- YdCombo.Width = .CellWidth - Wbkpy1
- Call Wbkcl
- YdCombo.Visible = True
- YdCombo.SetFocus
- Ydcommand.Visible = False
- Ydtext.Visible = False
- Else
- If GridBoolean(.Col, 2) Then
- Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
- Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
- Ydcommand.Visible = True
- Else
- Ydcommand.Visible = False
- End If
- Ydtext.Left = .CellLeft + .Left + Wbkpy
- Ydtext.Top = .CellTop + .Top + Wbkpy
- If Ydcommand.Visible Then
- If Sfblbzkd Then
- Ydtext.Width = .CellWidth - Ydcommand.Width
- Else
- Ydtext.Width = .CellWidth - Wbkpy1
- End If
- Else
- Ydtext.Width = .CellWidth - Wbkpy1
- End If
- Ydtext.Height = .CellHeight - Wbkpy1
- If GridInt(.Col, 2) <> 0 Then
- Ydtext.MaxLength = GridInt(.Col, 2)
- Else
- Ydtext.MaxLength = 3000
- End If
- Call Wbkcl
- Ydtext.Visible = True
- Ydtext.SetFocus
- End If
- Dqtoprow = .TopRow
- Dqleftcol = .LeftCol
- '重置锁值
- Valilock = False
- Wbkbhlock = False
- End With
- End Sub
- Private Function Fun_AllowInput() As Boolean '当某种条件成立时禁止文本框激活使单据处于录入状态
- '如果单据操作状态为浏览状态则不能显示录入载体(通用)
- If Trim(Lab_OperStatus.Caption) = "1" Then
- Exit Function
- End If
- '[>>
- '此处可以填写禁止文本框激活使单据处于录入状态的理由
- '<<]
- Fun_AllowInput = True
- End Function
- Private Sub Cxxswbk() 'Formresize中重新显示文本框,列表框,帮助按钮(通用)
- Dim Wbkpy As Integer, Wbkpy1 As Integer
- Wbkpy = 30
- Wbkpy1 = 15
- With WglrGrid
- If YdCombo.Visible Then
- YdCombo.Left = .CellLeft + .Left + Wbkpy
- YdCombo.Top = .CellTop + .Top + Wbkpy
- YdCombo.Width = .CellWidth - Wbkpy1
- End If
- If Ydcommand.Visible Then
- Ydcommand.Left = .Left + .CellLeft + .CellWidth - Ydcommand.Width + Wbkpy
- Ydcommand.Top = .Top + .CellTop + .CellHeight - Ydcommand.Height + Wbkpy
- End If
- If Ydtext.Visible Then
- If Ydcommand.Visible Then
- If Sfblbzkd Then
- Ydtext.Width = .CellWidth - Ydcommand.Width
- Else
- Ydtext.Width = .CellWidth - Wbkpy1
- End If
- Else
- Ydtext.Width = .CellWidth - Wbkpy1
- End If
- Ydtext.Left = .CellLeft + .Left + Wbkpy
- Ydtext.Top = .CellTop + .Top + Wbkpy
- Ydtext.Height = .CellHeight - Wbkpy1
- End If
- End With
- End Sub
- Private Sub Lrsjhx() '文本框录入数据回写
- With WglrGrid
- If YdCombo.Visible Then
- .Text = Trim(YdCombo.Text)
- End If
- If Ydtext.Visible Then
- .Text = Trim(Ydtext.Text)
- End If
- '(如果字段录入内容发生变化,则打开有效性判断锁)
- If Zdlrqnr <> Trim(.Text) Then
- Yxxpdlock = False
- Hyxxpdlock = False
- End If
- '如果字段录入内容不为空则写数据行有效性标志
- If Len(Trim(.Text)) <> 0 Then
- Call Xyxhbz(.Row)
- End If
- '隐藏文本框,帮助按钮,列表组合框
- Call Ycwbk
- End With
- End Sub
- Private Sub WglrGrid_KeyDown(KeyCode As Integer, Shift As Integer) '网格录入增行,删行快捷键
- '如果单据操作状态为浏览状态则不能显示录入载体
- If Trim(Lab_OperStatus.Caption) = "1" Then
- Exit Sub
- End If
- Select Case KeyCode
- Case vbKeyF2 '按F2键参照
- Call xswbk
- Call Lrzdbz
- Case vbKeyDelete '删行
- Call Scdqfl
- Case vbKeyInsert '增行
- Call zjlrfl
- End Select
- End Sub
- Private Sub WglrGrid_KeyPress(KeyAscii As Integer) '网格接受键盘录入
- '当某种条件成立时禁止文本框激活使单据处于录入状态
- If Not Fun_AllowInput Then
- Exit Sub
- End If
- With WglrGrid
- '屏 蔽 回 车 键
- If KeyAscii = vbKeyReturn Then
- KeyAscii = 0
- Rowjsq = .Row
- Coljsq = .Col + 1
- If Coljsq > .Cols - 1 Then
- If Rowjsq < .Rows - 1 Then
- Rowjsq = Rowjsq + 1
- End If
- Coljsq = Qslz
- End If
- Do While Rowjsq <= .Rows - 1
- If .ColHidden(Coljsq) Or (Not GridBoolean(Coljsq, 1)) Then
- Coljsq = Coljsq + 1
- If Coljsq > .Cols - 1 Then
- Rowjsq = Rowjsq + 1
- Coljsq = Qslz
- End If
- Else
- Exit Do
- End If
- Loop
- If Rowjsq <= .Rows - 1 Then
- .Select Rowjsq, Coljsq
- End If
- Exit Sub
- End If
- '接受用户录入
- Select Case KeyAscii
- Case 0 To 32 '用户输入KeyAscii为0-32的键 如空格
- '显示录入载体
- Call xswbk
- Case Else
- '防止非编辑字段SendKeys()出现死循环
- If Not GridBoolean(.Col, 1) Or .Row < .FixedRows Then
- Exit Sub
- End If
- '如果此字段为列表框录入则调入相应列表框
- If GridBoolean(.Col, 3) Then
- '列表框录入
- Call xswbk
- Else
- Ydtext.Text = ""
- '录入限制
- Call InputFieldLimit(Ydtext, GridInt(WglrGrid.Col, 1), KeyAscii)
- If KeyAscii = 0 Then
- Exit Sub
- End If
- '如果录入字符有效则写有效行数据标志
- Call Xyxhbz(.Row)
- Call xswbk
- Ydtext.Text = ""
- Valilock = True
- SendKeys Chr(KeyAscii), True
- DoEvents
- Valilock = False
- End If
- End Select
- End With
- End Sub
- Private Sub zjlrfl() '增加录入分录
- With WglrGrid
- If Not (Ydtext.Visible Or YdCombo.Visible) Then
- If Not Fun_Drfrmyxxpd Then
- Exit Sub
- End If
- Else
- Exit Sub
- End If
- If .Row < .FixedRows Then
- Exit Sub
- End If
- .AddItem "", .Row
- .RowHeight(.Row) = Sjhgd
- If .Row <> .Rows - 1 Then
- If .TextMatrix(.Row + 1, 0) = "*" Then
- .TextMatrix(.Row, 0) = "*"
- Else
- .RemoveItem .Rows - 1
- End If
- End If
- Call Xldqh
- Call Xldql
- Hyxxpdlock = False
- End With
- End Sub
- Private Sub Scdqfl() '删除当前分录
- Dim Answer As Integer, Scqwghz As Long, Scqwglz As Long, Hjlzte As Long, Sflrzt As Boolean
- With WglrGrid
- Scqwghz = .Row
- Scqwglz = .Col
- If .TextMatrix(.Row, 0) = "*" Then
- '判断是否为录入状态
- If Ydtext.Visible Or YdCombo.Visible Then
- Sflrzt = True
- Validate = True
- Call Lrsjhx
- Validate = False
- End If
- Call Xldqh
- Changelock = True
- .Select .Row, 0
- Changelock = False
- If Shsfts Then
- .Cell(flexcpBackColor, .Row, Qslz, .Row, .Cols - 1) = QBColor(12)
- Tsxx = "请确认是否删除当前记录?"
- Yhanswer = Xtxxts(Tsxx, 2, 2)
- If Yhanswer = 2 Then
- .Cell(flexcpBackColor, .Row, Qslz, .Row, .Cols - 1) = &H80000005
- Changelock = True
- .Select Scqwghz, Scqwglz
- Changelock = False
- '如为录入状态,则恢复录入
- If Sflrzt Then
- Call xswbk
- End If
- Exit Sub
- End If
- End If
- .RemoveItem .Row
- If .Rows < Pmbcsjhs + .FixedRows + Fzxwghs + 1 Then
- .AddItem ""
- .RowHeight(.Rows - 1) = Sjhgd
- End If
- Changelock = True
- .Select .Row, Scqwglz
- Changelock = False
- '重新计算合计数据
- For Hjlzte = Qslz To .Cols - 1
- Call Sjhj(Hjlzte)
- Next Hjlzte
- End If
- End With
- End Sub
- Private Sub Sjhj(Hjwgl As Long) '网格列数据合计
- Dim Hjjg As Double
- If Not GridBoolean(Hjwgl, 4) Then
- Exit Sub
- End If
- With WglrGrid
- Hjjg = 0
- For jsqte = .FixedRows To .Rows - 1
- If .TextMatrix(jsqte, 0) = "*" Then
- Hjjg = Hjjg + S2N(.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 S2N(Trim(.TextMatrix(sjh, Sjl))) = 0 Then
- .TextMatrix(sjh, Sjl) = ""
- End If
- End With
- End Sub
- Private Sub fhyxh() '返回录入数据有效行,同时让得到焦点网格可见
- With WglrGrid
- If .Row >= .FixedRows Then
- If .TextMatrix(.Row, 0) <> "*" Then
- For Rowjsq = .FixedRows To .Rows - 1
- If .TextMatrix(Rowjsq, 0) <> "*" Then
- Exit For
- End If
- Next Rowjsq
- If Rowjsq <= .Rows - 1 Then
- Changelock = True
- .Select Rowjsq, .Col
- Changelock = False
- Else
- Changelock = True
- .Select .Rows - 1, .Col
- Changelock = False
- End If
- End If
- Call Xldqh
- End If
- End With
- End Sub
- Private Sub Xldqh() '显露当前行
- Dim Toprowte As Long
- With WglrGrid
- Toprowte = 0
- Do While .CellTop + .RowHeight(.Row) + Fzxwghs * Sjhgd > .Height And .TopRow <> Toprowte
- Toprowte = .TopRow
- .TopRow = .TopRow + 1
- Loop
- Toprowte = 0
- Do While .CellTop < .FixedRows * .RowHeight(0) And .TopRow <> Toprowte
- Toprowte = .TopRow
- If .TopRow > 1 Then
- .TopRow = .TopRow - 1
- End If
- Loop
- End With
- End Sub
- Private Sub Xldql() '显露当前列
- Dim Leftcolte As Long
- With WglrGrid
- If .Col >= Qslz And .Col >= .FixedCols Then
- If .LeftCol > .Col Then
- .LeftCol = .Col
- End If
- Leftcolte = 0
- Do While .CellLeft + .CellWidth > .Width And .LeftCol <> Leftcolte
- Leftcolte = .LeftCol
- .LeftCol = .LeftCol + 1
- Loop
- End If
- End With
- End Sub
- Private Function pdhwk(sjh As Long) '判断网格行是否为空行(所有录入字段均为空*非录入字段除外)
- With WglrGrid
- For Coljsq = Qslz To .Cols - 1
- If Len(Trim(.TextMatrix(sjh, Coljsq))) <> 0 And GridBoolean(Coljsq, 1) Then
- pdhwk = False
- Exit Function
- End If
- Next Coljsq
- pdhwk = True
- End With
- End Function
- Private Sub Xyxhbz(sjh As Long) '写行有效性标志,并判断是否增行
- With WglrGrid
- If .TextMatrix(sjh, 0) = "*" Then
- Exit Sub
- End If
- .TextMatrix(sjh, 0) = "*"
- If sjh >= .Rows - Fzxwghs - 1 Then
- .AddItem ""
- .RowHeight(.Rows - 1) = Sjhgd
- End If
- End With
- End Sub
- '*****************************以下为文本框录入处理程序(固定不变部分)*******************************'
- Private Sub Wbklrwbcl(Index As Integer) '文本框录入事后处理程序
- '以下为依据实际情况自定义部分[
- Dim adoMode As New ADODB.Recordset
- '在此填写文本框录入事后处理程序
- Select Case Index
- Case 1
- Set adoMode = Cw_DataEnvi.DataConnect.Execute("select whname,pricemode,ishqgl from gy_warehouse where whcode='" & Trim(LrText(Index).Text) & "' or whname='" & Trim(LrText(Index).Text) & "'")
- If Not adoMode.EOF Then
- If CBool(adoMode.Fields("ishqgl")) Then
- WglrGrid.ColHidden(Sydz("005", GridStr(), Szzls)) = False
- Else
- WglrGrid.ColHidden(Sydz("005", GridStr(), Szzls)) = True
- End If
- If Trim(adoMode.Fields("PriceMode")) = "计划价法" Then
- WglrGrid.ColHidden(Sydz("010", GridStr(), Szzls)) = False
- WglrGrid.ColHidden(Sydz("012", GridStr(), Szzls)) = False
- PriceMode = Trim(adoMode.Fields("PriceMode"))
- Else
- WglrGrid.ColHidden(Sydz("010", GridStr(), Szzls)) = True
- WglrGrid.ColHidden(Sydz("012", GridStr(), Szzls)) = True
- End If
- End If
- For rjsq = WglrGrid.FixedRows To WglrGrid.Rows - 1
- WglrGrid.TextMatrix(rjsq, Sydz("005", GridStr(), Szzls)) = ""
- Next rjsq
- Call Cshhjwg
- End Select
- ']以上为依据实际情况自定义部分
- End Sub
- Private Sub LrText_Change(Index As Integer)
- '屏蔽程序改变控制
- If TextChangeLock Then
- Exit Sub
- End If
- TextValiJudgeLock(Index) = False '打开有效性判断锁
- '限制字段录入长度
- TextChangeLock = True '加锁(防止执行Lrtext_Change)
- Call TextChangeLimit(LrText(Index), Textint(Index, 1)) '去掉无效字符
- Select Case Textint(Index, 1)
- Case 8, 11 '金额型
- Call Sjgskz(LrText(Index), Xtjezws - Xtjexsws - 1, Xtjexsws)
- Case 9, 12 '数量型
- Call Sjgskz(LrText(Index), Xtslzws - Xtslxsws - 1, Xtslxsws)
- Case 10 '单价型
- Call Sjgskz(LrText(Index), Xtdjzws - Xtdjxsws - 1, Xtdjxsws)
- Case Else '其他小数类型控制
- If Textint(Index, 6) <> 0 Or Textint(Index, 7) <> 0 Then
- Call Sjgskz(LrText(Index), Textint(Index, 6), Textint(Index, 7))
- End If
- End Select
- TextChangeLock = False '解锁
- If Index = 1 Then
- LrText(1).Tag = ""
- WglrGrid.Clear 1
- WglrGrid.Rows = Pmbcsjhs + WglrGrid.FixedRows + Fzxwghs
- End If
- 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
- If Textint(Index, 2) <> 1 Then
- strHlpR = FunHlpR(Trim(Textstr(Index, 4)), "czybm", Xtczybm)
- End If
- 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() '录入文本框初始化
- Dim Int_TabIndex As Integer 'Tab焦点计数器
- '单据录入中文本框焦点由0开始
- LrText(0).TabIndex = 0
- '最大录入文本框索引值
- Max_Text_Index = Textvar(1)
- ReDim TextValiJudgeLock(Max_Text_Index)
- For jsqte = 0 To Max_Text_Index
- '判断此文本框录入索引号是否存在,如存在则对其进行初始化
- If Len(Trim(Textstr(jsqte, 1))) <> 0 Then
- '自动装入录入文本框和其解释标签
- If jsqte <> 0 Then
- Load LrText(jsqte)
- Load TsLabel(jsqte)
- '判断录入文本框是否显示
- If Textboolean(jsqte, 4) Then
- LrText(jsqte).Visible = True
- TsLabel(jsqte).Visible = True
- End If
- '判断文本框是否可编辑
- If Textboolean(jsqte, 5) Then
- LrText(jsqte).Enabled = True
- Else
- LrText(jsqte).Enabled = False
- End If
- End If
- '初始化其内容
- TextChangeLock = True
- LrText(jsqte).Text = ""
- LrText(jsqte).Tag = ""
- If Textint(jsqte, 5) <> 0 Then
- LrText(jsqte).MaxLength = Textint(jsqte, 5)
- End If
- TextChangeLock = False
- '设置文本框位置及大小,并设置相应标签内容及其位置
- LrText(jsqte).Move Textint(jsqte, 13), Textint(jsqte, 12), Textint(jsqte, 11), Textint(jsqte, 10)
- TsLabel(jsqte).Caption = Textstr(jsqte, 7) & ":"
- TsLabel(jsqte).Move Textint(jsqte, 13) - TsLabel(jsqte).Width - 20, Textint(jsqte, 12) + (Textint(jsqte, 10) - TsLabel(jsqte).Height) / 2 - 30
- End If
- '将文本框有效性判断进行加锁,在文本框内容发生变化时将锁打开
- TextValiJudgeLock(jsqte) = True
- Next jsqte
- '设置文本框焦点转移顺序(前提文本焦点从0至Max_Text_Index)
- For Int_TabIndex = 0 To Max_Text_Index
- For jsqte = 0 To Max_Text_Index
- If Textint(jsqte, 14) = Int_TabIndex Then
- LrText(jsqte).TabIndex = Int_TabIndex
- End If
- Next jsqte
- Next Int_TabIndex
- End Sub
- Private Function TextYxxpd(Index As Integer) As Boolean '文本框有效性判断
- Dim Sqlstr As String
- Dim Findrec As New ADODB.Recordset
- '按帮助不进行有效性判断
- If TextValiLock Then
- TextValiLock = False
- TextYxxpd = True
- Exit Function
- End If
- '文本框内容未曾改变不进行有效性判断
- If TextValiJudgeLock(Index) Then
- Ydcommand1.Visible = False
- TextYxxpd = True
- Exit Function
- End If
- '文本框内容为空认为有效,并清空其Tag值
- If Trim(LrText(Index)) = "" Then
- LrText(Index).Tag = ""
- Call Wbklrwbcl(Index)
- Ydcommand1.Visible = False
- TextValiJudgeLock(Index) = True
- TextYxxpd = True
- Exit Function
- End If
- '[>>
- '可在此加入不做有效性判断的理由(参照上面程序)
- '<<]
- Select Case Textint(Index, 4)
- Case 1 '编码型
- Sqlstr = Trim(Textstr(Index, 5))
- 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
- Case 2 '日期型
- If IsDate(LrText(Index).Text) Then
- LrText(Index).Text = Format(LrText(Index).Text, "yyyy-mm-dd")
- If S2N(Mid(LrText(Index), 1, 4)) < 1900 Then
- LrText(Index).Text = "1900" + Mid(LrText(Index), 5, 6)
- End If
- Else
- Tsxx = "非法公历日期!(格式:" + Format(Date, "yyyy-mm-dd") + ")"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(Index).SetFocus
- Exit Function
- End If
- Case 3 '其他类型
- End Select
- '隐藏帮助按钮
- Ydcommand1.Visible = False
- '如果有效则加锁,用户不改变内容则不再进行有效性判断
- TextValiJudgeLock(Index) = True
- '调用文本框事后处理程序
- Call Wbklrwbcl(Index)
- '有效性判断通过则返回True
- TextYxxpd = True
- End Function
- Public Sub VisulGrid()
- With WglrGrid
- If S2N(conArea) = 0 Then
- .ColHidden(Sydz("005", GridStr(), Szzls)) = True
- Else
- .ColHidden(Sydz("005", GridStr(), Szzls)) = False
- End If
- If conBatch = 1 Then
- .ColHidden(Sydz("006", GridStr(), Szzls)) = False
- Else
- .ColHidden(Sydz("006", GridStr(), Szzls)) = True
- End If
- End With
- Call Cshhjwg
- End Sub
- Private Sub Sub_PK() '盘库
- Dim int_answer As Integer
- Dim adoWare As New ADODB.Recordset
- Dim jsq As Long
- Dim jsqte As Long
- If LrText(1).Tag = "" Then
- Tsxx = "请选择仓库!"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(1).SetFocus
- Exit Sub
- End If
- int_answer = MsgBox("是否对整个仓库进行盘点?", vbOKCancel + vbInformation, "百利/ERP-库存管理")
- If int_answer = 1 Then
- WglrGrid.Clear 1
- Set adoWare = Cw_DataEnvi.DataConnect.Execute("select whcode,marea,mareaname,mname,model,PrimaryUnitName,planprice,batchnum,mnumber,ispcgl,endquan from kf_v_nowquan where whcode='" & Trim(LrText(1).Tag) & "' or whcode='" & Trim(LrText(1).Text) & "'")
- With adoWare
- If Not .EOF Then
- jsq = WglrGrid.FixedRows
- Do While Not .EOF
- If jsq > WglrGrid.Rows - 1 Then
- WglrGrid.AddItem ""
- End If
- WglrGrid.TextMatrix(jsq, 0) = "*"
- WglrGrid.TextMatrix(jsq, Sydz("001", GridStr(), Szzls)) = Trim(.Fields("mnumber") & "") '物料编码
- WglrGrid.TextMatrix(jsq, Sydz("002", GridStr(), Szzls)) = Trim(.Fields("mname") & "") '物料名称
- WglrGrid.TextMatrix(jsq, Sydz("003", GridStr(), Szzls)) = Trim(.Fields("model") & "") '规格型号
- WglrGrid.TextMatrix(jsq, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("PrimaryUnitName") & "") '计量单位
- WglrGrid.TextMatrix(jsq, 1) = .Fields("marea") & "" '货区编码
- WglrGrid.TextMatrix(jsq, 2) = .Fields("ispcgl") & "" '是否批次管理
- If Not WglrGrid.ColHidden(Sydz("005", GridStr(), Szzls)) Then
- WglrGrid.TextMatrix(jsq, Sydz("005", GridStr(), Szzls)) = Trim(.Fields("mareaname") & "") '货区名称
- End If
- If CBool(IIf(IsNull(.Fields("ispcgl")), False, .Fields("ispcgl"))) Then
- WglrGrid.TextMatrix(jsq, Sydz("006", GridStr(), Szzls)) = Trim(.Fields("batchnum") & "") '批号
- End If
- If S2N(.Fields("endquan")) <> 0 Then
- WglrGrid.TextMatrix(jsq, Sydz("007", GridStr(), Szzls)) = S2N(.Fields("endquan") & "") '现有数量
- WglrGrid.TextMatrix(jsq, Sydz("009", GridStr(), Szzls)) = S2N(WglrGrid.TextMatrix(jsq, Sydz("008", GridStr(), Szzls)) & "") - S2N(.Fields("endquan") & "")
- End If
- If Not WglrGrid.ColHidden(Sydz("010", GridStr(), Szzls)) Then
- If S2N(.Fields("planprice")) <> 0 Then
- WglrGrid.TextMatrix(jsq, Sydz("010", GridStr(), Szzls)) = Trim(.Fields("planprice")) '计划单价
- End If
- End If
- If Not WglrGrid.ColHidden(Sydz("012", GridStr(), Szzls)) Then
- If S2N(.Fields("endquan")) * S2N(.Fields("planprice")) <> 0 Then
- WglrGrid.TextMatrix(jsq, Sydz("012", GridStr(), Szzls)) = S2N(.Fields("endquan")) * S2N(.Fields("planprice")) '计划金额
- End If
- End If
- jsq = jsq + 1
- .MoveNext
- Loop
- End If
- End With
- End If
- '调整网格(Fixed)
- Call Sub_AdjustGrid
- '计算合计数据(Fixed)
- For jsqte = Qslz To WglrGrid.Cols - 1
- Call Sjhj(jsqte)
- Next jsqte
- '将网格刷新解禁(Fixed)
- WglrGrid.Redraw = True
- End Sub
- Private Sub Sub_JH()
- '判断用户是否有此功能执行权限,如有则写上机日志(进入)
- If Not Security_Log(Str_RightEdit, Xtczybm, 1, True) Then
- Exit Sub
- End If
- If LrText(1).Tag <> "" Then
- If conForbid = 1 Then
- Cw_DataEnvi.DataConnect.Execute ("update gy_warehouse set freezeflag=1 where whcode='" & Trim(LrText(1).Tag) & "'")
- End If
- Cw_DataEnvi.DataConnect.Execute ("update kf_inventorymain set actstate=1,investate='A' where inventorymainid=" & S2N(Lab_BillId.Caption))
- Tlb_Action.Buttons("jh").Enabled = False
- Tlb_Action.Buttons("jz").Enabled = True
- Label1.Visible = True
- End If
- End Sub
- Private Sub Sub_JZ() '记帐
- Dim jzmain1 As String
- Dim jzmain2 As String
- Dim adojzmain1 As New ADODB.Recordset
- Dim adojzmain2 As New ADODB.Recordset
- Dim adojzsub1 As New ADODB.Recordset
- Dim adojzsub2 As New ADODB.Recordset
- Dim jsq As Integer
- Dim Kjyear As Integer: Dim Period As Integer
- Dim adoP As New ADODB.Recordset
- '判断用户是否有此功能执行权限,如有则写上机日志(进入)
- If Not Security_Log(Str_RightChalk, Xtczybm, 1, True) Then
- Exit Sub
- End If
- InID = CreatBillID("1203")
- OutID = CreatBillID("1206")
- Me.MousePointer = ccHourglass
- Set adoP = Cw_DataEnvi.DataConnect.Execute("select period from gy_kjrlb where '" & Xtrq & "'>=qsrq and '" & Xtrq & "'<=zzrq and kjyear='" & Mid(Xtrq, 1, 4) & "' and period in (select top 1 period from gy_kjrlb where kfjzbz=0 and kjyear=" & Xtyear & "order by period)")
- If Not adoP.EOF Then
- adoP.Sort = "period"
- Period = S2N(adoP.Fields("period"))
- Kjyear = S2N(Mid(Xtrq, 1, 4))
- Else
- Tsxx = "系统登陆日期应在当前会计期间内!"
- Call Xtxxts(Tsxx, 0, 1)
- Me.MousePointer = ccDefault
- Exit Sub
- End If
- PB.Visible = True
- On Error GoTo Swcwcl
- Cw_DataEnvi.DataConnect.BeginTrans
- jzmain1 = "insert into gy_inoutmain (opertype,InOutMainId,BillCode,BillNum,InoutFlag,maker,BillDate,kjyear,period,WhCode,OperbillNum,InoutClassCode,DeptCode,PersonCode,Remark) (select " & Trim("'盘盈入库'") & "," & InID & " ,'1203','" & CreatBillCode("1203", True) & "',1,'" & Xtczy & "' ,'" & Xtrq & "'," & Kjyear & "," & Period & ", WhCode,BillNum,InClass,DeptCode,PersonCode,Remark from Kf_InventoryMain where inventorymainid=" & S2N(Lab_BillId.Caption) & ")"
- jzmain2 = "insert into gy_inoutmain (opertype,InOutMainId,BillCode,BillNum,InoutFlag,maker,BillDate,kjyear,period,WhCode,OperbillNum,InoutClassCode,DeptCode,PersonCode,Remark) (select " & Trim("'盘亏出库'") & "," & OutID & " ,'1206','" & CreatBillCode("1206", True) & "',0,'" & Xtczy & "' ,'" & Xtrq & "'," & Kjyear & "," & Period & ", WhCode,BillNum,OutClass,DeptCode,PersonCode,Remark from Kf_InventoryMain where inventorymainid=" & S2N(Lab_BillId.Caption) & ")"
- Set adojzmain1 = Cw_DataEnvi.DataConnect.Execute("select * from kf_v_pdd where quaninve>accquan and inventorymainid=" & S2N(Lab_BillId.Caption))
- Set adojzmain2 = Cw_DataEnvi.DataConnect.Execute("select * from kf_v_pdd where quaninve<accquan and inventorymainid=" & S2N(Lab_BillId.Caption))
- If Not adojzmain1.EOF Then
- Cw_DataEnvi.DataConnect.Execute (jzmain1)
- End If
- If Not adojzmain2.EOF Then
- Cw_DataEnvi.DataConnect.Execute (jzmain2)
- End If
- '打开单据子表动态集
- If adojzsub1.State = 1 Then adojzsub1.Close
- adojzsub1.Open "Select * From Gy_InOutSub Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- If adojzsub2.State = 1 Then adojzsub2.Close
- adojzsub2.Open "Select * From Gy_InOutSub Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
- '将网格中有效数据行写入单据子表
- With adojzmain1
- If Not .EOF Then
- PB.Min = 0
- PB.Max = .RecordCount
- For jsq = 1 To .RecordCount
- With adojzsub1
- .AddNew
- .Fields("InOutSubID") = jsq
- .Fields("InOutMainID") = S2N(InID)
- .Fields("MNumber") = Trim(adojzmain1.Fields("mnumber")) '物料编码
- .Fields("MArea") = Trim(adojzmain1.Fields("MArea")) '货区
- .Fields("BatchNum") = Trim(adojzmain1.Fields("BatchNum")) '批次
- .Fields("FactReceiptQuan") = S2N(adojzmain1.Fields("quaninve") - S2N(adojzmain1.Fields("accquan"))) '数量
- .Fields("PlanPrice") = S2N(adojzmain1.Fields("PlanPrice")) '计划单价
- .Fields("Price") = S2N(adojzmain1.Fields("Price")) '单价
- .Fields("PlanMoney") = S2N(adojzmain1.Fields("PlanMoney")) '计划金额
- .Fields("EMoney") = S2N(adojzmain1.Fields("EMoney")) '金额
- .Update
- End With
- '修改现存量和物料表
- Cw_DataEnvi.DataConnect.Execute (" KF_SP_ChangeQuan '" & Trim(adojzmain1.Fields("whcode")) & "','" & IIf(IsNull(adojzmain1.Fields("MArea")), "", Trim(adojzmain1.Fields("MArea"))) & "','" & Trim(adojzmain1.Fields("mnumber")) & "','" & Trim(adojzmain1.Fields("BatchNum")) & "'," & S2N(adojzmain1.Fields("accquan") - S2N(adojzmain1.Fields("quaninve"))) & ",0")
- Cw_DataEnvi.DataConnect.Execute ("Update gy_material set NowStorage=NowStorage+(" & S2N(adojzmain1.Fields("accquan") - S2N(adojzmain1.Fields("quaninve"))) & ") where mNumber='" & Trim(adojzmain1.Fields("mnumber")) & "'")
- '批次管理时,增加批次
- If strBatch <> "" Then
- Cw_DataEnvi.DataConnect.Execute ("insert into KF_Batch(FatherTableNum,SubTableNum,WhCode,MNumber,BatchNum) values (" & S2N(InID) & "," & jsq & ",'" & Trim(adojzmain1.Fields("whcode")) & "','" & Trim(adojzmain1.Fields("mnumber")) & "','" & Trim(adojzmain1.Fields("BatchNum")) & "')")
- End If
- .MoveNext
- PB.Value = jsq
- Next jsq
- End If
- End With
- With adojzmain2
- If Not .EOF Then
- PB.Min = 0
- PB.Max = .RecordCount
- For jsq = 1 To .RecordCount
- With adojzsub2
- .AddNew
- .Fields("InOutSubID") = jsq
- .Fields("InOutMainID") = S2N(OutID)
- .Fields("MNumber") = Trim(adojzmain2.Fields("mnumber")) '物料编码
- .Fields("MArea") = Trim(adojzmain2.Fields("MArea")) '货区
- .Fields("BatchNum") = Trim(adojzmain2.Fields("BatchNum")) '批次
- .Fields("FactIssueQuan") = S2N(adojzmain2.Fields("accquan") - S2N(adojzmain2.Fields("quaninve"))) '数量
- .Fields("PlanPrice") = S2N(adojzmain2.Fields("PlanPrice")) '计划单价
- .Fields("Price") = S2N(adojzmain2.Fields("Price")) '单价
- .Fields("PlanMoney") = S2N(adojzmain2.Fields("PlanMoney")) '计划金额
- .Fields("IssueMoney") = S2N(adojzmain2.Fields("EMoney")) '金额
- .Update
- End With
- '修改现存量和物料表
- Cw_DataEnvi.DataConnect.Execute (" KF_SP_ChangeQuan '" & Trim(adojzmain2.Fields("whcode")) & "','" & IIf(IsNull(adojzmain2.Fields("MArea")), "", Trim(adojzmain2.Fields("MArea"))) & "','" & Trim(adojzmain2.Fields("mnumber")) & "','" & Trim(adojzmain2.Fields("BatchNum")) & "'," & S2N(adojzmain2.Fields("quaninve") - S2N(adojzmain2.Fields("accquan"))) & ",1")
- Cw_DataEnvi.DataConnect.Execute ("Update gy_material set NowStorage=NowStorage-(" & S2N(adojzmain2.Fields("accquan") - S2N(adojzmain2.Fields("quaninve"))) & ") where mNumber='" & Trim(adojzmain2.Fields("mnumber")) & "'")
- '回填批次所对应的出库数量
- If Trim(adojzmain2.Fields("BatchNum")) <> "" Then
- If BatchJudge(Trim(LrText(1).Tag), Trim(adojzmain2.Fields("mnumber")), Trim(adojzmain2.Fields("BatchNum")), intCount, intFatherID(), intChildID(), IsQc(), False) = 0 Then
- Call RestoreQuan(intCount, intFatherID(), intChildID(), IsQc(), S2N(adojzmain2.Fields("accquan") - S2N(adojzmain2.Fields("quaninve"))), False)
- End If
- End If
- .MoveNext
- PB.Value = jsq
- Next jsq
- End If
- End With
- Cw_DataEnvi.DataConnect.Execute ("update kf_inventorymain set InMainId=" & S2N(InID) & ",OutMainId=" & S2N(OutID) & ", ChalkitupMan='" & Trim(Xtczy) & "' where inventorymainid=" & S2N(Lab_BillId.Caption))
- Cw_DataEnvi.DataConnect.Execute ("update gy_warehouse set freezeflag=0 where whcode='" & Trim(LrText(1).Tag) & "'")
- Cw_DataEnvi.DataConnect.CommitTrans
- Tlb_Action.Buttons("jz").Enabled = False
- Tlb_Action.Buttons("re").Enabled = True
- Tsxx = "记帐成功!"
- Call Xtxxts(Tsxx, 0, 4)
- LrText(8).Text = Xtczy
- PB.Visible = False
- Label1.Visible = False
- Me.MousePointer = ccDefault
- Exit Sub
- Swcwcl: '数据存盘时出现错误
- Cw_DataEnvi.DataConnect.RollbackTrans
- Tsxx = "记帐中出现{" & Trim(Err.Description) & "}错误,程序自动恢复记帐前状态!"
- Call Xtxxts(Tsxx, 0, 1)
- PB.Visible = False
- Me.MousePointer = ccDefault
- Exit Sub
- End Sub
- Private Sub REJZ() '恢复记帐
- Dim adoCheck As ADODB.Recordset
- Dim adoSub1 As New ADODB.Recordset
- Dim adoSub2 As New ADODB.Recordset
- '判断用户是否有此功能执行权限,如有则写上机日志(进入)
- If Not Security_Log(Str_RightChalk, Xtczybm, 1, True) Then
- Exit Sub
- End If
- Set adoCheck = Cw_DataEnvi.DataConnect.Execute("select checkflag from gy_inoutmain where inoutmainid=(select InMainId from kf_inventorymain where InventoryMainId=" & S2N(Lab_BillId.Caption) & ")")
- If Not adoCheck.EOF Then
- If CBool(adoCheck.Fields("checkflag")) Then
- Tsxx = "盈亏单据已经结帐,不能再恢复盘点记帐!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Sub
- End If
- End If
- On Error GoTo Swcwcl
- Cw_DataEnvi.DataConnect.BeginTrans
- If adoSub1.State = 1 Then Rec_Sub.Close
- Set adoSub1 = Cw_DataEnvi.DataConnect.Execute("select whcode,mnumber,marea,batchnum,factreceiptquan from KF_V_OtherIn where InoutMainId=" & S2N(InID))
- With adoSub1
- If Not .EOF Then
- .MoveFirst
- Cw_DataEnvi.DataConnect.Execute ("delete KF_Batch where fathertablenum='" & S2N(InID) & "'")
- For LsJs = 1 To .RecordCount
- '1修改现存量
- Cw_DataEnvi.DataConnect.Execute (" KF_SP_ChangeQuan '" & Trim(.Fields("whcode")) & "','" & IIf(IsNull(.Fields("marea")), "", Trim(.Fields("marea"))) & "','" & Trim(.Fields("mnumber")) & "','" & Trim(.Fields("batchnum")) & "'," & S2N(.Fields("factreceiptquan")) & ",1")
- Cw_DataEnvi.DataConnect.Execute ("Update gy_material set NowStorage=NowStorage+(" & (0 - S2N(.Fields("factreceiptquan"))) & ") where mNumber='" & Trim(.Fields("mnumber")) & "'")
- .MoveNext
- Next LsJs
- End If
- End With
- If adoSub2.State = 1 Then Rec_Sub.Close
- Set adoSub2 = Cw_DataEnvi.DataConnect.Execute("select whcode,mnumber,marea,batchnum,factissuequan from KF_V_OtherOut where InoutMainId=" & S2N(OutID))
- With adoSub2
- If Not .EOF Then
- .MoveFirst
- For LsJs = 1 To .RecordCount
- '1修改现存量
- Cw_DataEnvi.DataConnect.Execute (" KF_SP_ChangeQuan '" & Trim(.Fields("whcode")) & "','" & IIf(IsNull(.Fields("marea")), "", Trim(.Fields("marea"))) & "','" & Trim(.Fields("mnumber")) & "','" & Trim(.Fields("batchnum")) & "'," & S2N(.Fields("factissuequan")) & ",0")
- Cw_DataEnvi.DataConnect.Execute ("Update gy_material set NowStorage=NowStorage+(" & S2N(.Fields("factissuequan")) & ") where mNumber='" & Trim(.Fields("mnumber")) & "'")
- '4修改实际出库数量
- If Trim(.Fields("batchnum") & "") <> "" Then
- If BatchJudge(Trim(.Fields("whcode")), Trim(.Fields("mnumber")), Trim(.Fields("batchnum")), intCount, intFatherID(), intChildID(), IsQc(), True) = 0 Then
- Call RestoreQuan(intCount, intFatherID(), intChildID(), IsQc(), .Fields("factissuequan"), True)
- End If
- End If
- .MoveNext
- Next LsJs
- End If
- End With
- Cw_DataEnvi.DataConnect.Execute ("delete gy_inoutmain where inoutmainid=( select inoutmainid from gy_inoutmain where inoutmainid=(select InMainId from kf_inventorymain where InventoryMainId=" & S2N(Lab_BillId.Caption) & "))")
- Cw_DataEnvi.DataConnect.Execute ("delete gy_inoutsub where inoutmainid=( select inoutmainid from gy_inoutmain where inoutmainid=(select InMainId from kf_inventorymain where InventoryMainId=" & S2N(Lab_BillId.Caption) & "))")
- Cw_DataEnvi.DataConnect.Execute ("delete gy_inoutmain where inoutmainid=( select inoutmainid from gy_inoutmain where inoutmainid=(select OutMainId from kf_inventorymain where InventoryMainId=" & S2N(Lab_BillId.Caption) & "))")
- Cw_DataEnvi.DataConnect.Execute ("delete gy_inoutsub where inoutmainid=( select inoutmainid from gy_inoutmain where inoutmainid=(select OutMainId from kf_inventorymain where InventoryMainId=" & S2N(Lab_BillId.Caption) & "))")
- Cw_DataEnvi.DataConnect.Execute ("update kf_inventorymain set InMainId=" & S2N(0) & ",OutMainId=" & S2N(0) & ", ChalkitupMan=null where inventorymainid=" & S2N(Lab_BillId.Caption))
- Cw_DataEnvi.DataConnect.Execute ("update gy_warehouse set freezeflag=0 where whcode='" & Trim(LrText(1).Tag) & "'")
- Cw_DataEnvi.DataConnect.Execute ("update kf_inventorymain set actstate=0,investate='N' where inventorymainid=" & S2N(Lab_BillId.Caption))
- Cw_DataEnvi.DataConnect.CommitTrans
- Tsxx = "恢复记帐成功!"
- Call Xtxxts(Tsxx, 0, 4)
- Tlb_Action.Buttons("jz").Enabled = False
- Tlb_Action.Buttons("jh").Enabled = True
- Tlb_Action.Buttons("re").Enabled = False
- LrText(8).Text = ""
- Label1.Visible = False
- Exit Sub
- Swcwcl: '数据存盘时出现错误
- Cw_DataEnvi.DataConnect.RollbackTrans
- Tsxx = "恢复记帐过程中出现{" & Trim(Err.Description) & "}错误,程序自动恢复到以前状态!"
- Call Xtxxts(Tsxx, 0, 1)
- Exit Sub
- End Sub
- Private Sub Sub_Sx()
- Dim adoNow As New ADODB.Recordset
- Dim jsqr As Long
- If LrText(1).Text = "" Then
- Tsxx = "请选择仓库!"
- Call Xtxxts(Tsxx, 0, 1)
- LrText(1).SetFocus
- Exit Sub
- End If
- jsqr = WglrGrid.FixedRows
- Do While WglrGrid.TextMatrix(jsqr, 0) = "*"
- If WglrGrid.TextMatrix(jsqr, 1) <> "" Then
- Set adoNow = Cw_DataEnvi.DataConnect.Execute("select whcode,marea,mareaname,mname,model,PrimaryUnitName,planprice,batchnum,mnumber,ispcgl,endquan from kf_v_nowquan where whcode='" & Trim(LrText(1).Tag) & "' and mnumber='" & Trim(WglrGrid.TextMatrix(jsqr, Sydz("001", GridStr(), Szzls))) & "' and marea='" & Trim(WglrGrid.TextMatrix(jsqr, 1)) & "' and batchnum='" & Trim(WglrGrid.TextMatrix(jsqr, Sydz("006", GridStr(), Szzls))) & "'")
- Else
- Set adoNow = Cw_DataEnvi.DataConnect.Execute("select whcode,marea,mareaname,mname,model,PrimaryUnitName,planprice,batchnum,mnumber,ispcgl,endquan from kf_v_nowquan where whcode='" & Trim(LrText(1).Tag) & "' and mnumber='" & Trim(WglrGrid.TextMatrix(jsqr, Sydz("001", GridStr(), Szzls))) & "' and marea is null and batchnum='" & Trim(WglrGrid.TextMatrix(jsqr, Sydz("006", GridStr(), Szzls))) & "'")
- End If
- With adoNow
- If Not .EOF Then
- If S2N(.Fields("endquan")) <> 0 Then
- WglrGrid.TextMatrix(jsqr, Sydz("007", GridStr(), Szzls)) = S2N(.Fields("endquan"))
- WglrGrid.TextMatrix(jsqr, Sydz("009", GridStr(), Szzls)) = S2N(WglrGrid.TextMatrix(jsqr, Sydz("008", GridStr(), Szzls)) & "") - S2N(.Fields("endquan") & "")
- End If
- End If
- End With
- jsqr = jsqr + 1
- Loop
- End Sub
- Private Sub fillmate()
- Dim jsq As Long
- Dim adoMate As New ADODB.Recordset
- If strM <> "" Then
- WglrGrid.Clear 1
- strM = Mid(strM, 1, (Len(strM) - 1))
- Set adoMate = Cw_DataEnvi.DataConnect.Execute("select whcode,marea,mareaname,mname,model,PrimaryUnitName,planprice,batchnum,mnumber,ispcgl,endquan from kf_v_nowquan where whcode='" & Trim(LrText(1).Tag) & "' and mnumber in(" & Trim(strM) & ")")
- With adoMate
- If Not .EOF Then
- jsq = WglrGrid.FixedRows
- Do While Not .EOF
- If jsq >= WglrGrid.Rows - 1 Then
- WglrGrid.AddItem ""
- End If
- WglrGrid.TextMatrix(jsq, 0) = "*"
- WglrGrid.TextMatrix(jsq, Sydz("001", GridStr(), Szzls)) = Trim(.Fields("mnumber") & "")
- WglrGrid.TextMatrix(jsq, Sydz("002", GridStr(), Szzls)) = Trim(.Fields("mname") & "")
- WglrGrid.TextMatrix(jsq, Sydz("003", GridStr(), Szzls)) = Trim(.Fields("model") & "")
- WglrGrid.TextMatrix(jsq, Sydz("004", GridStr(), Szzls)) = Trim(.Fields("PrimaryUnitName") & "")
- WglrGrid.TextMatrix(jsq, 1) = .Fields("marea") & ""
- WglrGrid.TextMatrix(jsq, 2) = .Fields("ispcgl") & ""
- If Not WglrGrid.ColHidden(Sydz("005", GridStr(), Szzls)) Then
- WglrGrid.TextMatrix(jsq, Sydz("005", GridStr(), Szzls)) = Trim(.Fields("mareaname") & "")
- End If
- If CBool(.Fields("ispcgl")) Then
- WglrGrid.TextMatrix(jsq, Sydz("006", GridStr(), Szzls)) = Trim(.Fields("batchnum") & "")
- End If
- If S2N(.Fields("endquan")) <> 0 Then
- WglrGrid.TextMatrix(jsq, Sydz("007", GridStr(), Szzls)) = S2N(.Fields("endquan") & "")
- WglrGrid.TextMatrix(jsq, Sydz("009", GridStr(), Szzls)) = S2N(WglrGrid.TextMatrix(jsq, Sydz("008", GridStr(), Szzls)) & "") - S2N(.Fields("endquan") & "")
- End If
- If Not WglrGrid.ColHidden(Sydz("010", GridStr(), Szzls)) Then
- If S2N(.Fields("planprice")) <> 0 Then
- WglrGrid.TextMatrix(jsq, Sydz("010", GridStr(), Szzls)) = Trim(.Fields("planprice"))
- End If
- End If
- If Not WglrGrid.ColHidden(Sydz("012", GridStr(), Szzls)) Then
- If S2N(.Fields("endquan")) * S2N(.Fields("planprice")) <> 0 Then
- WglrGrid.TextMatrix(jsq, Sydz("012", GridStr(), Szzls)) = S2N(.Fields("endquan")) * S2N(.Fields("planprice"))
- End If
- End If
- .MoveNext
- jsq = jsq + 1
- Loop
- End If
- End With
- End If
- End Sub
- Private Function NowQuan(strWhCode As String, strMArea As String, strBatch As String, strMnumber As String) As Double
- Dim adoQuan As New ADODB.Recordset
- If WglrGrid.TextMatrix(jsqr, 1) <> "" Then
- Set adoQuan = Cw_DataEnvi.DataConnect.Execute("select whcode,marea,mareaname,mname,model,PrimaryUnitName,planprice,batchnum,mnumber,ispcgl,endquan from kf_v_nowquan where whcode='" & Trim(strWhCode) & "' and mnumber='" & Trim(strMnumber) & "' and marea='" & Trim(strMArea) & "' and batchnum='" & Trim(strBatch) & "'")
- Else
- Set adoQuan = Cw_DataEnvi.DataConnect.Execute("select whcode,marea,mareaname,mname,model,PrimaryUnitName,planprice,batchnum,mnumber,ispcgl,endquan from kf_v_nowquan where whcode='" & Trim(strWhCode) & "' and mnumber='" & Trim(strMnumber) & "' and marea is null and batchnum='" & Trim(strBatch) & "'")
- End If
- With adoQuan
- If Not .EOF Then
- NowQuan = S2N(.Fields("endquan") & "")
- End If
- End With
- End Function
- Private Sub Sub_PDZB(Blf As Boolean)
- '判断用户是否有此功能执行权限,如有则写上机日志(进入)
- If Not Security_Log(Str_RightEdit, Xtczybm, 1, True) Then
- Exit Sub
- End If
- With WglrGrid
- If Blf Then
- .ColHidden(Sydz("007", GridStr(), Szzls)) = True
- .ColHidden(Sydz("009", GridStr(), Szzls)) = True
- .ColHidden(Sydz("014", GridStr(), Szzls)) = True
- .ColHidden(Sydz("011", GridStr(), Szzls)) = True
- .ColHidden(Sydz("013", GridStr(), Szzls)) = True
- Else
- .ColHidden(Sydz("007", GridStr(), Szzls)) = False
- .ColHidden(Sydz("009", GridStr(), Szzls)) = False
- .ColHidden(Sydz("014", GridStr(), Szzls)) = False
- .ColHidden(Sydz("011", GridStr(), Szzls)) = False
- .ColHidden(Sydz("013", GridStr(), Szzls)) = False
- 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 = 4 '报 表 小 标 题 行 数
- 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
- ReportTitle = "盘点单制表"
- Bbzbt = ReportTitle
- Bbxbt(1) = Space(5) + Fun_FormatOutPut("盘点单号:" & Trim(LrText(0)), 30)
- Bbxbt(1) = Bbxbt(1) + Fun_FormatOutPut(" 仓库:" & Trim(LrText(1)), 30)
- Bbxbt(1) = Bbxbt(1) + Fun_FormatOutPut("盘点日期:" & Trim(LrText(2)), 30)
- Bbxbt(2) = Space(5) + Fun_FormatOutPut(" 部门:" & Trim(LrText(3)), 30)
- Bbxbt(2) = Bbxbt(2) + Fun_FormatOutPut("入库类别:" & Trim(LrText(4)), 30)
- Bbxbt(2) = Bbxbt(2) + Fun_FormatOutPut("出库类别:" & Trim(LrText(5)), 30)
- Bbxbt(3) = Space(5) + Fun_FormatOutPut(" 经手人:" & Trim(LrText(6)), 30)
- Bbxbt(3) = Bbxbt(3) + Fun_FormatOutPut(" 备注:" & Trim(LrText(7)), 60)
- bbxbtzzxs(1) = 0 '报表行组织形式(0-居左 1-居中 2-居右)
- 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