Foxtable(狐表)用户栏目专家坐堂 → 代码错误无厘头


  共有1502人关注过本帖树形打印复制链接

主题:代码错误无厘头

帅哥哟,离线,有人找我吗?
xvkewen
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:593 积分:5538 威望:0 精华:0 注册:2012/6/29 19:11:00
代码错误无厘头  发帖心情 Post By:2018/4/27 15:49:00 [只看该作者]

以下一段代码运行过一段时间没问题,今天突然出现以下错误提示,经过排查是以下在删除空行的时候现的问题,但仔细看了很多遍代码,实在发现不了到底是哪出问题了?请老师帮忙看看

图片点击可在新窗口打开查看此主题相关图片如下:123.jpg
图片点击可在新窗口打开查看

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

 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By: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
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:二尾狐 帖子:593 积分:5538 威望:0 精华:0 注册:2012/6/29 19:11:00
  发帖心情 Post By:2018/4/27 16:38:00 [只看该作者]

果然是这个问题;谢谢了;

 回到顶部