以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]录入结果Cancel (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=80617) |
-- 作者:blsu33 -- 发布时间:2016/1/27 14:40:00 -- [求助]录入结果Cancel 红袍老师, 录入结果应被Cancel,但还是录入进去了,这是为什么呢?下图 01 已经被使用,不希望在增加出下级 代码如下 Dim e As object=args(0) Dim bm As String= e.DataTable.name Dim dt1,dt2,dt3 As DataTable dt1=Functions.Execute("loading","Z006配置列",0,"表名=\'"& bm &"\'and 使用表 Is Not null")\'已使用的判断 If dt1.DataRows.count>0 Then\' 判断是否被使用开始 For Each dr4 As DataRow In dt1.DataRows If e.DataTable.DataCols.Contains(dr4("列名")) Then Dim nms() As String=dr4("使用表").Split(",") Dim lm() As String =dr4("使用表对应列名").Split(",") For i1 As Integer=0 To nms.Length-1 cmd99.CommandText ="Select Count(*) F rom {"& nms(i1) &"} Where "& lm(i1) &"=\'"& e.DataRow(dr4("列名")) &"\'" If cmd99.ExecuteScalar > 0 Then PopMessage("上级编码已在""【" & nms(i1).SubString(5,nms(i1).Length-5) & "】""表中使用,不能增加!","错误", PopIconEnum.Error, 5) MessageBox.Show(e.NewValue) MessageBox.Show(e.oldValue) e.Cancel=True Return Nothing Exit For Else Continue For End If Next End If Next End If |
-- 作者:大红袍 -- 发布时间:2016/1/27 14:50:00 -- 只有DataColChanging事件才能cancel,具体做例子测试。 |
-- 作者:blsu33 -- 发布时间:2016/1/27 15:25:00 -- 老师, 大概就是这个意思,例子我在做一会上传,下面的怎么写》 If E.DataCol.Name="编码规则" Then Dim dr As DataRow= DataTables("表B").Find("第一列=\'01\'") If dr IsNot Nothing And e.NewValue Like "& 01* &" Then’老师这块应该怎么写? PopMessage("上级编码已在表B中使用,不能增加!","错误", PopIconEnum.Error, 5) e.Cancel=True End If End If
|
-- 作者:大红袍 -- 发布时间:2016/1/27 15:32:00 -- If dr IsNot Nothing And e.NewValue Like "01*" Then’老师这块应该怎么写? |