以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 代码错误无厘头 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=118248) |
-- 作者:xvkewen -- 发布时间:2018/4/27 15:49:00 -- 代码错误无厘头 以下一段代码运行过一段时间没问题,今天突然出现以下错误提示,经过排查是以下在删除空行的时候现的问题,但仔细看了很多遍代码,实在发现不了到底是哪出问题了?请老师帮忙看看 Dim dr As DataRow = DataTables("SPB_ProcessSpecLibrary").Find("ProcessCode = \'" & e.DataRow("ProcessCode") & "\'") If e.DataRow("ProcessDescription") <> dr("ProcessDescription") Then Dim Index As Integer Index = Tables("MainSchedule.SPB_ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值 If Index > -1 Then \'如果找到此行 Tables("MainSchedule.SPB_ProcessSchdule").Position = Index \'将焦点定位到此行 End If msgbox("当前表的第 " & index+1 & "行工艺描述与工艺库不符,可能有手误更改,请重新选择~") e.Cancel = True \'取消存盘 End If With e.DataRow If .IsNull("ProcessNo") And .IsNull("SamplePart") And .IsNull("ProcessTeam") And .IsNull("ProcessMachine") And .IsNull("Partname") And .IsNull("Method") And .IsNull("ProcessDescription") Then \'如果办单号,客户,款号,尺码,颜色都为空,则自动认为是无办单,系统自动删除; e.DataRow.Delete Return Else msgbox(4) If .IsNull("ProcessNo") Then Dim Index As Integer Index = Tables("MainSchedule.SPB_ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值 If Index > -1 Then \'如果找到此行 Tables("MainSchedule.SPB_ProcessSchdule").Position = Index \'将焦点定位到此行 End If msgbox("【工艺序号】不能为空,保存失败") e.Cancel = True \'取消存盘 ElseIf .IsNull("SamplePart") Then Dim Index As Integer Index = Tables("MainSchedule.SPB_ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值 If Index > -1 Then \'如果找到此行 Tables("MainSchedule.SPB_ProcessSchdule").Position = Index \'将焦点定位到此行 End If msgbox("【办房部位】不能为空,保存失败") e.Cancel = True \'取消存盘 ElseIf .IsNull("ProcessTeam") Then Dim Index As Integer Index = Tables("MainSchedule.SPB_ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值 If Index > -1 Then \'如果找到此行 Tables("MainSchedule.SPB_ProcessSchdule").Position = Index \'将焦点定位到此行 End If msgbox("【工艺分配(办房/大货)】不能为空,保存失败") e.Cancel = True \'取消存盘 ElseIf .IsNull("ProcessMachine") Then Dim Index As Integer Index = Tables("MainSchedule.SPB_ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值 If Index > -1 Then \'如果找到此行 Tables("MainSchedule.SPB_ProcessSchdule").Position = Index \'将焦点定位到此行 End If msgbox("【工艺操作设备】不能为空,保存失败") e.Cancel = True \'取消存盘 ElseIf .IsNull("ProcessName") Then Dim Index As Integer Index = Tables("MainSchedule.SPB_ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值 If Index > -1 Then \'如果找到此行 Tables("MainSchedule.SPB_ProcessSchdule").Position = Index \'将焦点定位到此行 End If msgbox("【工艺名称】不能为空,保存失败") e.Cancel = True \'取消存盘 ElseIf .IsNull("processDescription") Then Dim Index As Integer Index = Tables("MainSchedule.SPB_ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值 If Index > -1 Then \'如果找到此行 Tables("MainSchedule.SPB_ProcessSchdule").Position = Index \'将焦点定位到此行 End If msgbox("【操作要求】不能为空,保存失败") e.Cancel = True \'取消存盘 ElseIf .IsNull("ProcessCode") Then Dim Index As Integer Index = Tables("MainSchedule.SPB_ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值 If Index > -1 Then \'如果找到此行 Tables("MainSchedule.SPB_ProcessSchdule").Position = Index \'将焦点定位到此行 End If msgbox("当前表的第 " & index+1 & "行工艺不是在工艺库里选择的工艺,请重新选择~") e.Cancel = True \'取消存盘 Else Return End If End If End With
|
-- 作者:有点甜 -- 发布时间:2018/4/27 15:53:00 -- 如果dr没有找到的情况你要处理
Dim dr As DataRow = DataTables("SPB_ProcessSpecLibrary").Find("ProcessCode = \'" & e.DataRow("ProcessCode") & "\'")
If dr isNot Nothing Andalso e.DataRow("ProcessDescription") <> dr("ProcessDescription") Then
|
-- 作者:xvkewen -- 发布时间:2018/4/27 16:38:00 -- 果然是这个问题;谢谢了; |