以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]保存之前判断空值 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=140384) |
-- 作者:JN_LC -- 发布时间:2019/9/4 17:08:00 -- [求助]保存之前判断空值 我的代码放到了全局项目事件beforesavedatarow里,意思是保存之前先检查是否有空值,但不起作用。代码如下: With CurrentTable
For i As Integer = .TopPosition To .BottomPosition Dim r As Row = .Rows(i) Dim cls() As String Select Case .DataTable.name Case "Dwxx" cls = New String(){"单位全称","单位简称"} Case "Xcgl_jjd" cls = New String(){"发放时间"} Case "Xcgl_jjpf" cls = New String(){"奖金名称","奖金类别","批复时间","批复金额"} Case "Xcgl_kqtjb" cls = New String(){"本月应出勤"} Case "Xcgl_工资单" cls = New String(){"身份证号"} Case "员工信息表" cls = New String(){"姓名","身份证号","员工类别"} End Select For Each c As String In cls If r.isnull(c) Then MessageBox.Show("[" & c & "]列不能为空!","提示",MessageBoxButtons.ok,MessageBoxIcon.warning) \'msgbox("[" & c & "]列不能为空!") Return End If Next Next End With [此贴子已经被作者于2019/9/4 17:08:09编辑过]
|
-- 作者:有点蓝 -- 发布时间:2019/9/4 17:50:00 -- 这种代码适合放到按钮中判断,而不是表事件,应该这样 Dim r As datarow= e.datarow Dim cls() As String Select Case e.DataTable.name Case "Dwxx" cls = New String(){"单位全称","单位简称"} Case "Xcgl_jjd" cls = New String(){"发放时间"} Case "Xcgl_jjpf" cls = New String(){"奖金名称","奖金类别","批复时间","批复金额"} Case "Xcgl_kqtjb" cls = New String(){"本月应出勤"} Case "Xcgl_工资单" cls = New String(){"身份证号"} Case "员工信息表" cls = New String(){"姓名","身份证号","员工类别"} End Select For Each c As String In cls If r.isnull(c) Then MessageBox.Show("[" & c & "]列不能为空!","提示",MessageBoxButtons.ok,MessageBoxIcon.warning) \'msgbox("[" & c & "]列不能为空!")
e.cancel = true
Return End If Next |
-- 作者:JN_LC -- 发布时间:2019/9/4 18:30:00 -- 可以加在按钮里,但系统自带的最右上角有个叉号,可以关闭,提示保存时会漏掉空值,直接保存。 |
-- 作者:有点蓝 -- 发布时间:2019/9/5 8:35:00 -- 参考:http://www.foxtable.com/webhelp/topics/0668.htm |