以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  保存成功的提示  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=100592)

--  作者:xvkewen
--  发布时间:2017/5/14 18:15:00
--  保存成功的提示

以下代码是写在beforesavedatarow事件里的,在保存的时候判断必填项是否都已填写完整,如果不完整给出提示,并定位到这一行;除此以外,我还想当数据已经全部保存以后,给出“保存成功”的提示,如何做才能不是保存一行提示一行呢?

 

With e.DataRow
    If .IsNull("ProcessNo") And .IsNull("SamplePart") And .IsNull("ProcessTeam") And .IsNull("ProcessMachine") And .IsNull("ProcessName") And .IsNull("processDescription") Then    \'如果办单号,客户,款号,尺码,颜色都为空,则自动认为是无办单,系统自动删除;
        e.DataRow.Delete
    Else
        If .IsNull("ProcessNo") Then
            Dim Index As Integer
            Index = Tables("MainSchedule.ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值
            If Index > -1 Then \'如果找到此行
                Tables("MainSchedule.ProcessSchdule").Position = Index \'将焦点定位到此行
            End If
            msgbox("【序号】不能为空,保存失败")
            e.Cancel = True \'取消存盘
        ElseIf .IsNull("SamplePart") Then
            Dim Index As Integer
            Index = Tables("MainSchedule.ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值
            If Index > -1 Then \'如果找到此行
                Tables("MainSchedule.ProcessSchdule").Position = Index \'将焦点定位到此行
            End If
            msgbox("【办房部位】不能为空,保存失败")
            e.Cancel = True \'取消存盘
        ElseIf .IsNull("ProcessTeam") Then
            Dim Index As Integer
            Index = Tables("MainSchedule.ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值
            If Index > -1 Then \'如果找到此行
                Tables("MainSchedule.ProcessSchdule").Position = Index \'将焦点定位到此行
            End If
            msgbox("【办房工艺分配】不能为空,保存失败")
            e.Cancel = True \'取消存盘
        ElseIf .IsNull("ProcessMachine") Then
            Dim Index As Integer
            Index = Tables("MainSchedule.ProcessSchdule").FindRow(e.DataRow) \'找出此行的基础信息是有为空的值
            If Index > -1 Then \'如果找到此行
                Tables("MainSchedule.ProcessSchdule").Position = Index \'将焦点定位到此行
            End If
            msgbox("【操作设备】不能为空,保存失败")
            e.Cancel = True \'取消存盘
        Else
            Return
        End If
    End If
End With


--  作者:有点色
--  发布时间:2017/5/15 8:29:00
--  

1、e.Cancel = True 代码后面,应该跟一句 return,这样才不会重复提示;

 

2、保存提示可以这样写,单独做个保存按钮。

 

Dim dt As DataTable = DataTables("表A")
dt.save
If dt.HasChanges = False Then
    msgbox("保存成功")
Else
    msgbox("保存失败")
End If