以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]判断问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=80634)

--  作者:blsu33
--  发布时间:2016/1/27 20:19:00
--  [求助]判断问题
红袍老师,
   弄了好久,还是弄不好,能否给看下。一个判断末级的例子。
[此贴子已经被作者于2016/1/28 9:59:36编辑过]

--  作者:大红袍
--  发布时间:2016/1/27 20:36:00
--  

以前给你写过啊

 

查询 某列 like \'0101%\' 的记录,如果没有了,肯定就是最末级了啊。


--  作者:blsu33
--  发布时间:2016/1/27 20:39:00
--  
好似复杂了 有点乱。麻烦您给看下,年前想弄完。


--  作者:blsu33
--  发布时间:2016/1/27 20:40:00
--  

[此贴子已经被作者于2016/1/27 22:57:06编辑过]

--  作者:blsu33
--  发布时间:2016/1/27 20:43:00
--  


当第二行 编码规则 0101 改为 0201 时 出现错误 第一行 不能判定为末级 ,这个怎么改啊

现在的状况是只有保存一下 才能变成末级 可是添加e.datarow.save 加不好 麻烦您给看看
[此贴子已经被作者于2016/1/27 22:57:22编辑过]

--  作者:大红袍
--  发布时间:2016/1/27 21:23:00
--  
Dim e As object=args(0)
cmd99.CommandText = "Se lect * From {Z001分类编码方案} where [规则列]=\'"& e.DataCol.Name &"\' and  [基础档案名称]=\'"& e.DataTable.name &"\'"
Dim dt1 As DataTable= cmd99.ExecuteReader()
If dt1.DataRows.Count>0 Then
    Dim dr As DataRow=dt1.DataRows(0)
    Dim reg As new System.Text.RegularExpressions.Regex(dr("正则"))
    If reg.Ismatch(e.NewValue) = False Then
        e.Cancel = True
        Return Nothing
    Else
        Dim count As Integer = 0
        Dim prev As String = ""
        For i As Integer = 0 To dr("规则长度").length - 1
            count += val(dr("规则长度").chars(i))
            Dim str As String = e.NewValue.Substring(0, count)
            If count < e.NewValue.length Then
                If e.DataTable.find(dr("规则列") & "=\'" & str & "\'") Is Nothing Then
                    PopMessage("缺少上级编码:" & str,"错误", PopIconEnum.Error, 5)
                    e.Cancel = True
                    Return Nothing
                    Exit For
                Else If e.OldValue = str Then
                    PopMessage("缺少上级编码:" & str,"错误", PopIconEnum.Error, 5)
                    e.Cancel = True
                    Return Nothing
                    Exit For
                End If
            Else If count = e.NewValue.length  Then
                If i = dr("规则长度").length - 1 Then
                    e.DataRow("是否末级") = True
                    e.DataTable.ReplaceFor("是否末级", False, dr("规则列") & "=" & prev)
                Else
                    Dim filter As String = dr("规则列") & "<> \'" & str & "\' And " & dr("规则列") & " Like \'" & str & "*\'"
                    If  e.DataTable.find(filter) Is Nothing Then
                        e.DataRow("是否末级") = True
                        filter = dr("规则列") & "= \'" & prev & "\'"
                        e.DataTable.ReplaceFor("是否末级", False, filter)
                    Else
                        e.DataRow("是否末级") = False
                    End If
                    Exit For
                End If
            End If
            prev = str
        Next
        count = 0
        If e.DataRow("是否末级") = True Then
            For i As Integer = 0 To dr("规则长度").length - 1
                count += val(dr("规则长度").chars(i))
                If count <= e.oldvalue.length Then
                    Dim str As String = e.oldvalue.Substring(0,count)
                    Dim fdr As DataRow = e.DataTable.find("编码规则 like \'" & str & "%\' and 编码规则 <> \'" & str & "\' and _Identify <> " & e.DataRow("_Identify"))
                    If fdr Is Nothing
                        e.DataTable.ReplaceFor("是否末级", True, "编码规则 = \'" & str & "\'")
                    Else
                        e.DataTable.ReplaceFor("是否末级", False, "编码规则 = \'" & str & "\'")
                    End If
                End If
            Next
        End If
    End If
End If

--  作者:blsu33
--  发布时间:2016/1/27 21:36:00
--  
哦 可以 但是再新增一行0201 有提示问题 我在看下
--  作者:大红袍
--  发布时间:2016/1/27 21:37:00
--  

判断就是这样判断

 

Dim fdr As DataRow = e.DataTable.find("编码规则 like \'" & str & "%\' and 编码规则 <> \'" & str & "\' and _Identify <> " & e.DataRow("_Identify"))


--  作者:blsu33
--  发布时间:2016/1/27 21:43:00
--  
老师,
为什么 这就里过不去呢

  If e.DataRow("是否末级") = True Then
            For i As Integer = 0 To dr("规则长度").length - 1
                count += val(dr("规则长度").chars(i))
MessageBox.Show("count" & count)‘提示2次2
                If  e.oldvalue IsNot Nothing AndAlso count <= e.oldvalue.length Then’这里您在给看看可以过了 但是对吗 
                    Dim str As String = e.oldvalue.Substring(0,count)
MessageBox.Show("str" & str)

[此贴子已经被作者于2016/1/27 21:43:28编辑过]

--  作者:大红袍
--  发布时间:2016/1/27 21:44:00
--  

加上

 

systemready = False

 

systemready = true