以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]用的网络编号,增加行的判定  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=132702)

--  作者:manyifuwu
--  发布时间:2019/3/27 18:43:00
--  [求助]用的网络编号,增加行的判定

在表的DataColChanged事件里:代码为:

Select e.DataCol.Name
    Case "录入日期","录入人"
        If e.DataRow.IsNull("录入日期") OrElse e.DataRow.IsNull("录入人") Then
            e.DataRow("派单id") = Nothing
            \'msgbox(18)
        Else
            If QQClient.Ready = False Then
                PopMessage("QQClient未启动,无法生成编号!","提示",PopIconEnum.Infomation,5)
            Else
                Dim bh As String = e.DataRow("录入人") & "-" &  Format(e.DataRow("录入日期"),"yyyyMMddHHmmss")
                Dim rt As String =  QQClient.SendWait(":g" & bh & "g:")
                Dim id As Integer
                If rt > "" Then
                    If  Integer.TryParse(rt,id)  Then
                        e.DataRow("派单id") = bh & "-" & Format(id,"0000")
                        \'msgbox("新增了派工")
                    Else
                        PopMessage("服务器返回错误信息:" & rt,"提示",PopIconEnum.Infomation,5)
                    End If
                Else
                    PopMessage("服务器无响应,无法生成编号!","提示",PopIconEnum.Infomation,5)
                End If
            End If
        End If
End Select

 

希望:服务器无响应,或QQClient未启动,无法生成编号,就不能增加行。以上代码怎么改呢?

[此贴子已经被作者于2019/3/27 18:44:09编辑过]

--  作者:有点甜
--  发布时间:2019/3/27 22:35:00
--  

在你beforeAddDataRow事件,写代码处理,如

 

If qqclient.Ready = False Then

    e.cancel = true

    msgbox("不能新增")

End If