📄 设备检修_检修记录编辑.frm
字号:
End If
End With
End If
End Sub
Private Sub Sub_EditBill() '修改一张单据
Dim RecTemp As New ADODB.Recordset '临时使用动态集
If Not Security_Log("Dev_MonthRepairFile", Xtczybm, 1, True) Then
Exit Sub
End If
'非有效单据不予进行修改动作
If Val(Lab_BillId.Caption) = 0 Then
Exit Sub
End If
'判断当前单据是否允许修改
If Not Fun_AllowEdit Then
Exit Sub
End If
'设置操作状态为修改
Lab_OperStatus.Caption = "3"
'设置工具条状态
Call Sub_OperStatus("30")
'显示制单人
LrText(0).Enabled = False
LrText(1).Enabled = False
LrText(2).Enabled = False
LrText(3).Enabled = False
LrText(4).Enabled = False
LrText(14).Enabled = False
LrText(15).Enabled = False
LrText(16).Enabled = False
LrText(14).Text = Xtczy
End Sub
Private Sub Sub_DeleteBill() '删除当前单据
Dim YAnswer As Integer '确认是否删除当前单据
Dim jsqte As Long '临时使用计数器
'非有效单据不予进行删除动作
If Val(Lab_BillId.Caption) = 0 Then
Exit Sub
End If
If Not Security_Log("Dev_MonthRepairFile", Xtczybm, 1, True) Then
Exit Sub
End If
Tsxx = "请确认是否删除当前单据?"
YAnswer = Xtxxts(Tsxx, 2, 2)
If YAnswer = 1 Then
'判断当前单据是否允许删除
If Not Fun_AllowEdit Then
Exit Sub
End If
'进行事务处理
On Error GoTo Swcwcl
Cw_DataEnvi.DataConnect.BeginTrans
'1.删除单据所有内容
Cw_DataEnvi.DataConnect.Execute ("Delete Dev_DevCheckFile Where DevCheckFileID=" & Val(Lab_BillId.Caption))
Set TempRec = Cw_DataEnvi.DataConnect.Execute("Select RepairMainID from Dev_RepairMain where RepairMainCode='" & Trim(Lab_Code.Caption) & "'")
Cw_DataEnvi.DataConnect.Execute ("update Dev_RepairSub set FileFlag=0,RealBeginDate=Null,RealEndDate=NULL,RealMoney=0 where RepairMainID=" & Val(TempRec.Fields("RepairMainID")) & " and RepairSubID=" & Val(Lab_ID.Caption))
If Trim(Lab_File.Caption) <> "" Then
Cw_DataEnvi.DataConnect.Execute ("update Dev_CheckScenario Set NoteFlag=0 where ScenarioCode='" & Trim(Lab_File.Caption) & "'")
End If
Cw_DataEnvi.DataConnect.CommitTrans
'标识单据发生改动
Bln_BillChange = True
'单据ID置0
Lab_BillId.Caption = 0
Else
Exit Sub
End If
'删除单据后重置状态
'1.显示下一张单据
Call Sub_Next
'2.如果无下一张单据则搜索上一张单据
If Val(Lab_BillId.Caption) = 0 Then
Call Sub_Prev
End If
'3.如无单据则置单据为空状态
If Val(Lab_BillId.Caption) = 0 Then
'清除录入文本框
For jsqte = Max_Text_Index To 0 Step -1
LrText(jsqte).Tag = ""
LrText(jsqte).Text = ""
Next jsqte
'设置操作状态为浏览
Lab_OperStatus = "1"
Call Sub_OperStatus("10")
End If
Rec_Query.Requery
Rec_Query.Find "DevCheckFileID=" & Val(Lab_BillId.Caption)
Exit Sub
Swcwcl: '单据删除时出现错误
Cw_DataEnvi.DataConnect.RollbackTrans
Tsxx = "单据删除过程中出现未知错误,程序自动恢复保存前状态!"
Call Xtxxts(Tsxx, 0, 1)
Exit Sub
End Sub
Private Sub Sub_AbandonBill() '放弃对当前单据的操作
Dim jsqte As Long '临时使用计数器
'如果单据有效则重新显示当前单据,置单据为空状态
If Not Rec_Query.EOF Then
Lab_BillId.Caption = Rec_Query.Fields("DevCheckFileID")
Call Sub_ShowBill
Else
'单据ID置为0
Lab_BillId.Caption = 0
'清除录入文本框
For jsqte = Max_Text_Index To 0 Step -1
LrText(jsqte).Tag = ""
LrText(jsqte).Text = ""
Next jsqte
End If
'设置操作状态为浏览
Lab_OperStatus = "1"
Call Sub_OperStatus("10")
End Sub
Private Function Sub_SaveBill() As Boolean '保 存 单 据
Dim RecTemp As New ADODB.Recordset '临时使用动态集
Dim Rec_Bill As New ADODB.Recordset '单据表动态集
Dim jsqte As Integer '临时计数器
Dim TempRec As New ADODB.Recordset
Sub_SaveBill = False
'一.============先对单据内容进行有效性判断==============='
'先进行字段不能为空或不能为零有效性判断(Fixed)
For jsqte = 0 To Max_Text_Index
If Textint(jsqte, 8) = 1 Then '字段不能为空
If Len(Trim(LrText(jsqte).Text)) = 0 Then
Tsxx = Textstr(jsqte, 7) & "不能为空!"
Call Xtxxts(Tsxx, 0, 1)
LrText(jsqte).SetFocus
Exit Function
End If
Else
If Textint(jsqte, 8) = 2 Then '字段不能为零
If Val(Trim(LrText(jsqte).Text)) = 0 Then
Tsxx = Textstr(jsqte, 7) & "不能为零!"
Call Xtxxts(Tsxx, 0, 1)
LrText(jsqte).SetFocus
Exit Function
End If
End If
End If
Next jsqte
'对需要进行事后判断的文本框录入内容进行有效性判断 (Fixed)
For jsqte = 0 To Max_Text_Index
If Textint(jsqte, 9) = 0 Or Textint(jsqte, 9) = 2 Then
If Not TextYxxpd(jsqte) Then
Exit Function
End If
End If
Next jsqte
'[>>
'可在此区域写入其他对单据表头内容的有效性判断,具体格式参照如下
'<<]
'二.=============如果以上有效性检查均顺利通过,则执行存盘动作============'
'对存盘进行事务处理(Fixed)
On Error GoTo Swcwcl
Cw_DataEnvi.DataConnect.BeginTrans
'判断单据状态以进行不同处理
'1.先对单据主表进行处理
If Trim(Lab_OperStatus) = "2" Then
'新增单据
'1.对于某些单据号自动生成的单据则可在此处自动生成
LrText(0).Text = CreatBillCode(BillCode, True)
'2.开始存盘
'打开单据表动态集
If Rec_Bill.State = 1 Then Rec_Bill.Close
Rec_Bill.Open "Select * From Dev_DevCheckFile Where 1=2", Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
With Rec_Bill
.AddNew
.Fields("DevCheckFileID") = CreatBillID(BillCode) '记录ID
.Fields("CheckCode") = Trim(LrText(0).Text) '记录单号
.Fields("RepairType") = Trim(LrText(1).Text) '计划类型
.Fields("DEVID") = Trim(LrText(2).Text) '设备编号
.Fields("UseDept") = Trim(LrText(5).Tag) '使用部门
.Fields("RprPerson") = Trim(LrText(6).Tag) '维修人员
.Fields("BeginDate") = CDate(LrText(7).Text) '开始日期
.Fields("EndDate") = CDate(LrText(8).Text) '结束日期
.Fields("RepairHour") = Val(LrText(9).Text) '修理工时
.Fields("StopHour") = Val(LrText(10).Text) '停机台时
.Fields("RepairExes") = Val(LrText(11).Text) '修理费用
.Fields("Repair") = Trim(LrText(12).Text) '修理内容
.Fields("DealResult") = Trim(LrText(13).Text) '处理结果
.Fields("StateCode") = Trim(LrText(17).Tag) '维修后状态
.Fields("Maker") = Xtczy '制表人
.Fields("Authorizer") = "" '批准人
.Fields("Checker") = "" '审核人
.Fields("RepairMainCode") = Trim(Lab_Code.Caption) & "" '计划单号
.Fields("RepairSubID") = Val(Lab_ID.Caption) '子表ID
.Fields("ScenarioCode") = Trim(Lab_File.Caption) & "" '方案编号
.Update
Set TempRec = Cw_DataEnvi.DataConnect.Execute("Select RepairMainID from Dev_RepairMain where RepairMainCode='" & Trim(Lab_Code.Caption) & "'")
Cw_DataEnvi.DataConnect.Execute ("update Dev_RepairSub set FileFlag=1,RealBeginDate=convert(datetime,nullif('" & LrText(7).Text & "','')),RealEndDate=convert(datetime,nullif('" & LrText(8).Text & "','')),RealMoney=" & Val(LrText(11).Text) & ",StateCode='" & Trim(LrText(17).Tag) & "' where RepairMainID=" & Val(TempRec.Fields("RepairMainID")) & " and RepairSubID=" & Val(Lab_ID.Caption))
If Trim(Lab_File.Caption) <> "" Then
Cw_DataEnvi.DataConnect.Execute ("update Dev_CheckScenario set NoteFlag=1 where ScenarioCode='" & Trim(Lab_File.Caption) & "'")
End If
'系统读出单据ID写入Lab_BillID
Lab_BillId.Caption = .Fields("DevCheckFileID")
End With
Else
'修改单据
'打开单据表动态集
If Rec_Bill.State = 1 Then Rec_Bill.Close
Rec_Bill.Open "Select * From Dev_DevCheckFile Where DevCheckFileID=" & Val(Lab_BillId.Caption), Cw_DataEnvi.DataConnect, adOpenDynamic, adLockOptimistic
With Rec_Bill
.Fields("CheckCode") = Trim(LrText(0).Text) '记录单号
.Fields("RepairType") = Trim(LrText(1).Text) '计划类型
.Fields("DEVID") = Trim(LrText(2).Text) '设备编号
.Fields("UseDept") = Trim(LrText(5).Tag) '使用部门
.Fields("RprPerson") = Trim(LrText(6).Tag) '维修人员
.Fields("BeginDate") = CDate(LrText(7).Text) '开始日期
.Fields("EndDate") = CDate(LrText(8).Text) '结束日期
.Fields("RepairHour") = Val(LrText(9).Text) '修理工时
.Fields("StopHour") = Val(LrText(10).Text) '停机台时
.Fields("RepairExes") = Val(LrText(11).Text) '修理费用
.Fields("Repair") = Trim(LrText(12).Text) '修理内容
.Fields("DealResult") = Trim(LrText(13).Text) '处理结果
.Fields("StateCode") = Trim(LrText(17).Tag) '维修后状态
.Fields("Maker") = Xtczy '制表人
.Fields("Authorizer") = "" '批准人
.Fields("Checker") = "" '审核人
.Fields("RepairMainCode") = Trim(Lab_Code.Caption) & "" '计划单号
.Fields("RepairSubID") = Val(Lab_ID.Caption) '子表ID
.Fields("ScenarioCode") = Trim(Lab_File.Caption) & "" '方案编号
.Update
Set TempRec = Cw_DataEnvi.DataConnect.Execute("Select RepairMainID from Dev_RepairMain where RepairMainCode='" & Trim(Lab_Code.Caption) & "'")
Cw_DataEnvi.DataConnect.Execute ("update Dev_RepairSub set FileFlag=1,RealBeginDate=convert(datetime,nullif('" & LrText(7).Text & "','')),RealEndDate=convert(datetime,nullif('" & LrText(8).Text & "','')),RealMoney=" & Val(LrText(11).Text) & ",StateCode='" & Trim(LrText(17).Tag) & "' where RepairMainID=" & Val(TempRec.Fields("RepairMainID")) & " and RepairSubID=" & Val(Lab_ID.Caption))
If Trim(Lab_File.Caption) <> "" Then
Cw_DataEnvi.DataConnect.Execute ("update Dev_CheckScenario set NoteFlag=1 where ScenarioCode='" & Trim(Lab_File.Caption) & "'")
End If
End With
End If
Cw_DataEnvi.DataConnect.CommitTrans
Sub_SaveBill = True
Tsxx = "单据存盘完毕! 单据号:" & Trim(LrText(0).Text)
Call Xtxxts(Tsxx, 0, 4)
'标识单据发生改动
Bln_BillChange = True
'设置单据改变后的状态
Lab_OperStatus = "1"
Call Sub_OperStatus("10")
Rec_Query.Requery
Rec_Query.Find "DevCheckFileID=" & Val(Lab_BillId.Caption)
Exit Function
Swcwcl: '数据存盘时出现错误
Cw_DataEnvi.DataConnect.RollbackTrans
Tsxx = "存盘过程中出现未知错误,程序自动恢复保存前状态!"
Call Xtxxts(Tsxx, 0, 1)
Exit Function
End Function
'选择首张,上张,下张,末张(此4个过程只需用您的单据ID字段名替换"DevCheckFileID"即可)
Private Sub Sub_First() '首 张
With Rec_Query
If .RecordCount = 0 Then
Exit Sub
End If
.MoveFirst
Lab_BillId.Caption = .Fields("DevCheckFileID")
Call Sub_ShowBill
End With
End Sub
Private Sub Sub_Prev() '上 张
With Rec_Query
If .RecordCount = 0 Then
Exit Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -