以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  提示窗口无法关闭  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=161359)

--  作者:nuoyan89
--  发布时间:2021/3/15 9:07:00
--  提示窗口无法关闭

 老师,我在表事件中写了以下代码,明明写的是提示后该单元格内容清空就行了,但是目前提示后提示框无法关闭,非得强行关闭然后重新登录系统,重头再来,请帮忙看看,谢谢

Select Case e.DataCol.name
    Case "毛坯编码","成品流水号","成品编码"
        Dim dr As DataRow = e.DataRow
        If dr.IsNull("毛坯编码") = False AndAlso dr.IsNull("成品流水号") = False AndAlso dr.IsNull("成品编码") = False   Then
            If DataTables("产成品入库_录入").Compute("Count([_Identify])","毛坯编码 = \'" & dr("毛坯编码") & "\' And 成品流水号 = \'" & dr("成品流水号")  & "\' And 成品编码 = \'" & dr("成品编码")  & "\'") > 1 Then
                MessageBox.Show("成品流水号重复,重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.DataRow(e.DataCol.Name) = e.OldValue \'取消输入
            ElseIf DataTables("出入库明细").sqlCompute("Count([_Identify])","毛坯编码 = \'" & dr("毛坯编码") & "\' And 成品流水号 = \'" & dr("成品流水号") & "\' And 成品编码 = \'" & dr("成品编码")   & "\'") > 0 Then
                MessageBox.Show("成品流水号重复,重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.DataRow(e.DataCol.Name) = e.OldValue \'取消输入
            End If
        End If
End Select


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

--  作者:有点蓝
--  发布时间:2021/3/15 9:31:00
--  
我测试没有问题,应该datacolchanged事件好有其它代码,互相影响了
--  作者:nuoyan89
--  发布时间:2021/3/15 9:39:00
--  

老师,以下是我整个完整的代码

Select Case e.DataCol.Name
    Case "毛坯编码"
        Dim dr As DataRow = e.DataRow
        Dim pr As DataRow
        If dr.IsNull("毛坯编码")   Then
            dr("生产批次") = Nothing
            dr("批次序号") = Nothing
            dr("成品编码") = Nothing
        Else
            Dim filter As String
            filter = "毛坯编码= \'" & dr("毛坯编码")  & "\' and 加工内容=\'喷油入库\'"
            pr = DataTables("工序跟踪表").SQLFind(filter)
            If pr IsNot Nothing Then
                dr("生产批次") = pr("生产批次")
                dr("批次序号") = pr("批次序号")
                dr("成品编码") = pr("成品编码")
            End If
        End If
End Select
If e.DataRow("成品编码") = "0103001" OrElse e.DataRow("成品编码") = "0103020" Then
    e.DataRow("成品流水号") = e.DataRow("毛坯编码")
Else
    Select Case e.DataCol.Name
        Case "成品流水号"
            Dim dr As DataRow = e.DataRow
            Dim pr As DataRow
            If dr.IsNull("毛坯编码")  Then
                dr("成品流水号") = Nothing
            Else
                Dim filter As String
                filter = "Barcode= \'" & dr("毛坯编码") & "\'"
                pr = DataTables("T_Produce_No").SQLFind(filter)
                If pr IsNot Nothing Then
                    dr("成品流水号") = pr("Produce_No")
                End If
            End If
    End Select
End If
If e.DataCol.Name = "毛坯编码" Then
    Dim nms() As String = {"产地编码","规格型号"}
    If e.NewValue = Nothing Then
        For Each nm As String In nms
            e.DataRow(nm) = Nothing
        Next
    Else
        Dim dr As DataRow
        dr = DataTables("条码基础数据").sqlFind("[毛坯编码] = \'" & e.NewValue & "\'")
        If dr IsNot Nothing
            For Each nm As String In nms
                e.DataRow(nm) = dr(nm)
            Next
        End If
    End If
End If
Select Case e.DataCol.Name
    Case "成品编码"
        Dim dr As DataRow = e.DataRow
        Dim pr As DataRow
        If dr.IsNull("成品编码")   Then
            dr("成品描述") = Nothing
            dr("毛坯产地") = Nothing
            dr("规格型号") = Nothing
        Else
            Dim filter As String
            filter = "成品编码= \'" & dr("成品编码")  & "\'"
            pr = DataTables("产品基础数据").SQLFind(filter)
            If pr IsNot Nothing Then
                dr("成品描述") = pr("成品描述")
                dr("毛坯产地") = pr("毛坯产地")
                dr("规格型号") = pr("规格型号")
            End If
        End If
End Select
If e.DataCol.Name = "单据日期" Then
    If e.DataRow.IsNull("单据日期") Then
        e.DataRow("年") = Nothing
    Else
        e.DataRow("年") = Format(e.DataRow("单据日期"),"yyyy")
    End If
End If
If e.DataCol.Name = "单据日期" Then
    If e.DataRow.IsNull("单据日期") Then
        e.DataRow("月") = Nothing
    Else
        e.DataRow("月") = Format(e.DataRow("单据日期"),"yyyyMM")
    End If
End If
If e.DataCol.Name = "单据日期" Then
    If e.DataRow.IsNull("单据日期") Then
        e.DataRow("日") = Nothing
    Else
        e.DataRow("日") = Format(e.DataRow("单据日期"),"yyyyMMdd")
    End If
End If
Select Case e.DataCol.name
    Case "毛坯编码","成品流水号","成品编码"
        Dim dr As DataRow = e.DataRow
        If dr.IsNull("毛坯编码") = False AndAlso dr.IsNull("成品流水号") = False AndAlso dr.IsNull("成品编码") = False   Then
            If DataTables("产成品入库_录入").Compute("Count([_Identify])","毛坯编码 = \'" & dr("毛坯编码") & "\' And 成品流水号 = \'" & dr("成品流水号")  & "\' And 成品编码 = \'" & dr("成品编码")  & "\'") > 1 Then
                MessageBox.Show("成品流水号重复,重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.DataRow(e.DataCol.Name) = e.OldValue \'取消输入
            ElseIf DataTables("出入库明细").sqlCompute("Count([_Identify])","毛坯编码 = \'" & dr("毛坯编码") & "\' And 成品流水号 = \'" & dr("成品流水号") & "\' And 成品编码 = \'" & dr("成品编码")   & "\'") > 0 Then
                MessageBox.Show("成品流水号重复,重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.DataRow(e.DataCol.Name) = e.OldValue \'取消输入
            End If
        End If
End Select

 

 

 


--  作者:有点蓝
--  发布时间:2021/3/15 9:47:00
--  
互相影响了,但是怎么样影响的要自己调试了,简单的就屏蔽事件

Select Case e.DataCol.name

    Case "毛坯编码","成品流水号","成品编码"
        Dim dr As DataRow = e.DataRow
        If dr.IsNull("毛坯编码") = False AndAlso dr.IsNull("成品流水号") = False AndAlso dr.IsNull("成品编码") = False   Then
SystemReady = False
            If DataTables("产成品入库_录入").Compute("Count([_Identify])","毛坯编码 = \'" & dr("毛坯编码") & "\' And 成品流水号 = \'" & dr("成品流水号")  & "\' And 成品编码 = \'" & dr("成品编码")  & "\'") > 1 Then
                MessageBox.Show("成品流水号重复,重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.DataRow(e.DataCol.Name) = e.OldValue \'取消输入
            ElseIf DataTables("出入库明细").sqlCompute("Count([_Identify])","毛坯编码 = \'" & dr("毛坯编码") & "\' And 成品流水号 = \'" & dr("成品流水号") & "\' And 成品编码 = \'" & dr("成品编码")   & "\'") > 0 Then
                MessageBox.Show("成品流水号重复,重新输入!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
                e.DataRow(e.DataCol.Name) = e.OldValue \'取消输入
            End If
SystemReady = true
        End If
End Select