以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  提交条件与提交后隐藏成功提交的相关行  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=79347)

--  作者:sf020cf
--  发布时间:2015/12/29 14:40:00
--  提交条件与提交后隐藏成功提交的相关行

For Each r As Row In Tables("订单").GetCheckedRows
    If r.IsNull("订单编号") = False
        Dim Filter = "[订单编号] = \'" & r("订单编号") & "\'"
        Dim dr As DataRow = DataTables("配载订单").sqlFind(filter)

我想在这加另外一条提交前的条件,类似于

Dim Filter = "[项目] = \'" & r("项目") & "\'"
        Dim dr As DataRow = DataTables("项目信息").sqlFind(filter)

 

意思是"订单"的项目必须是表"项目信息"里有的并且"配载订单"的订单编号没有重复的才能提交到"配载订单"

然后满足这些条件的订单提交后隐藏(但可以刷新重新显示) 是为了可以快速分清不满足条件的行 好做其他操作


        If dr Is Nothing Then
            ls.Add(r)
            count += 1
        Else
            dic.add(dr, r)
        End If
    End If
Next

Dim p As WinForm.ProgressBar
p = e.Form.Controls("ProgressBar1")
If ls.count > 0 Then
    p.Visible = True
    p.Maximum =  ls.Count - 1 \'设置最大值
    p.Minimum = 0 \'设置最小值
    p.Value = 0 \'设置当前值
End If
Dim idx As Integer = 0
DataTables("订单").StopRedraw
For Each r As Row In ls
    Dim dr As DataRow = DataTables("配载订单").AddNew
    For i As Integer = 0 To Cols1.Length -1
        If r.IsNull(Cols1(i)) Then
            dr(Cols2(i)) = Nothing
        Else
            dr(Cols2(i)) = r(Cols1(i))
           
        End If
       
    Next
    idx += 1
    p.Value = idx
Next
For Each key As DataRow In dic.Keys
    Dim r As Row = dic(key)
    Dim dr As DataRow = key
    For i As Integer = 0 To Cols1.Length -1
        If r.IsNull(Cols1(i)) Then
            dr(Cols2(i)) = Nothing
        Else
            dr(Cols2(i)) = r(Cols1(i))
        End If
    Next
Next
 烦请版主帮忙看看 想达到的功能参杂在代码中  望见谅


--  作者:大红袍
--  发布时间:2015/12/29 15:28:00
--  

Dim Filter1 = "[订单编号] = \'" & r("订单编号") & "\'"
Dim dr1 As DataRow = DataTables("配载订单").sqlFind(filter1)

Dim Filter2 = "[项目] = \'" & r("项目") & "\'"
Dim dr2 As DataRow = DataTables("项目信息").sqlFind(filter2)

If dr1 Is Nothing AndAlso dr2 IsNot Nothing Then
    ls.Add(r)
    count += 1
End If


--  作者:sf020cf
--  发布时间:2015/12/29 15:43:00
--  

隐藏要怎样解决 r(Cols1(i)).visible=false 然后刷新的时候要整张表的visible=true后回来吗?

 


--  作者:大红袍
--  发布时间:2015/12/29 16:07:00
--  

remove掉

 

r.Remove()

 

http://www.foxtable.com/help/topics/2736.htm

 

 


--  作者:sf020cf
--  发布时间:2015/12/29 16:27:00
--  

然 r.remove() 不是把所选行都移出了吗 我想成功提交的移出 未成功的保留

 


--  作者:大红袍
--  发布时间:2015/12/29 16:33:00
--  

写在这里,这里就是所有要新增的行啊。

 

For Each r As Row In ls


--  作者:sf020cf
--  发布时间:2015/12/29 17:11:00
--  

 If r.IsNull("订单编号") = False
        Dim Filter1 = "[订单编号] = \'" & r("订单编号") & "\'"
        Dim dr1 As DataRow = DataTables("配载订单").sqlFind(filter1)
       
        Dim Filter2 = "[项目] = \'" & r("项目") & "\'"
        Dim dr2 As DataRow = DataTables("项目信息").sqlFind(filter2)
       
        If dr1 Is Nothing AndAlso dr2 IsNot Nothing Then
            ls.Add(r)
            count += 1
       \' End If
       
    Else
        dic.add(dr1, r)
    End If
End If
Next

Dim p As WinForm.ProgressBar
p = e.Form.Controls("ProgressBar1")
If ls.count > 0 Then
    p.Visible = True
    p.Maximum =  ls.Count - 1 \'设置最大值
    p.Minimum = 0 \'设置最小值
    p.Value = 0 \'设置当前值
End If
Dim idx As Integer = 0
DataTables("订单").StopRedraw
For Each r As Row In ls
    Dim dr As DataRow = DataTables("配载订单").AddNew
    For i As Integer = 0 To Cols1.Length -1
        If r.IsNull(Cols1(i)) Then
            dr(Cols2(i)) = Nothing
        Else
            dr(Cols2(i)) = r(Cols1(i))
           
        End If
       
    Next
    r.Remove()
    idx += 1
    p.Value = idx
Next
For Each key As DataRow In dic.Keys
    Dim r As Row = dic(key)
    Dim dr As DataRow = key
    For i As Integer = 0 To Cols1.Length -1
        If r.IsNull(Cols1(i)) Then
            dr(Cols2(i)) = Nothing
        Else
            dr(Cols2(i)) = r(Cols1(i))
        End If
    Next

Next

DataTables("订单").ResumeRedraw

 

这样提交的时候说 key值不能为空


p.Visible = False


--  作者:大红袍
--  发布时间:2015/12/29 17:12:00
--  

这段,不用写,删除

 

For Each key As DataRow In dic.Keys
    Dim r As Row = dic(key)
    Dim dr As DataRow = key
    For i As Integer = 0 To Cols1.Length -1
        If r.IsNull(Cols1(i)) Then
            dr(Cols2(i)) = Nothing
        Else
            dr(Cols2(i)) = r(Cols1(i))
        End If
    Next

Next


--  作者:sf020cf
--  发布时间:2015/12/29 17:20:00
--  

删了还是一样的

 

报这个错

 


--  作者:大红袍
--  发布时间:2015/12/29 17:24:00
--  
上传具体例子