Foxtable(狐表)用户栏目专家坐堂 → 在哪里加入判断条件才严谨


  共有2828人关注过本帖树形打印复制链接

主题:在哪里加入判断条件才严谨

帅哥哟,离线,有人找我吗?
sf020cf
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:412 积分:2665 威望:0 精华:0 注册:2015/10/2 23:48:00
在哪里加入判断条件才严谨  发帖心情 Post By:2015/12/7 11:13:00 [只看该作者]

有这么一个提交按钮 代码如下 现在要先判断表"客服跟单"所选"订单状态"列是"配送妥投"才能加载到"回单异常"表 如果不是 msgbox(订单未处理完成") e.cancel=true

 

 

Dim Cols1() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","司机","车牌","车型","车数","出车日期","异常描述","处理结果","责任方"}
    Dim Cols2() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","司机","车牌","车型","车数","出车日期","异常描述","处理结果","责任方"}
    Dim count As Integer = 0
    Dim ls As new List(of Row)
    Dim dic As new Dictionary (Of DataRow, Row)
    systemready = False
    For Each r As Row In Tables("客服跟单").GetCheckedRows
        Dim filter As String = "1=1"
        For Each dc As String In Cols1
            If r.IsNull(dc) Then
                filter &= " and " & dc & " is null"
            Else
                Dim c As Col = Tables("回单异常").Cols(dc)
                If c.IsNumeric Then
                    filter &= " and " & dc & " = " & r(dc)
                ElseIf c.IsBoolean Then
                    If r(dc) = True Then
                        filter &= " and " & dc & " = true"
                    Else
                        filter &= " and " & dc & " = false"
                    End If
                ElseIf c.IsDate Then
                    filter &= " and " & dc & " = #" & r(dc) & "#"
                Else
                    filter &= " and " & dc & " = '" & r(dc) & "'"
                End If
            End If
        Next
        Dim dr As DataRow = DataTables("回单异常").find(filter)
        If dr Is Nothing Then
            ls.Add(r)
            count += 1
        Else
            dic.add(dr, r)
        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
   
    DataTables("回单异常").ResumeRedraw
    p.Visible = False
   
    systemready = True
    msgbox("共有 "& count &" 条数据提交至回单" )
    Tables("客服跟单").save
    Tables("客服跟单").ClearCheckedRows


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/12/7 11:17:00 [只看该作者]

   For Each r As Row In Tables("客服跟单").GetCheckedRows

        If r("订单状态") = "回单异常" Then
            Dim filter As String = "1=1"

 

 

 

        End If


 回到顶部
帅哥哟,离线,有人找我吗?
sf020cf
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:412 积分:2665 威望:0 精华:0 注册:2015/10/2 23:48:00
  发帖心情 Post By:2015/12/7 13:28:00 [只看该作者]

按照您的指导 我加了判断 选中三行 其中两行订单状态是:配送妥投 一行是:配送在途

msgbox有提示 代码依然往下执行 最终由两行数据提交到回单异常 但都是空值 代码:

Dim Cols1() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","司机","车牌","车型","车数","出车日期","异常描述","处理结果","责任方"}
Dim Cols2() As String = {"项目","下单日期","MK号","DO号","城市","客户","送货地址","物料代码","数量","体积","重量","司机","车牌","车型","车数","出车日期","异常描述","处理结果","责任方"}
Dim count As Integer = 0
Dim ls As new List(of Row)
Dim dic As new Dictionary (Of DataRow, Row)
systemready = False
For Each r As Row In Tables("客服跟单").GetCheckedRows
    If r("订单状态") = "配送妥投" Then
        Dim filter As String = "1=1"
        For Each dc As String In Cols1
            If r.IsNull(dc) Then
                filter &= " and " & dc & " is null"
            Else
                Dim c As Col = Tables("回单异常").Cols(dc)
                If c.IsNumeric Then
                    filter &= " and " & dc & " = " & r(dc)
                ElseIf c.IsBoolean Then
                    If r(dc) = True Then
                        filter &= " and " & dc & " = true"
                    Else
                        filter &= " and " & dc & " = false"
                    End If
                ElseIf c.IsDate Then
                    filter &= " and " & dc & " = #" & r(dc) & "#"
                Else
                    filter &= " and " & dc & " = '" & r(dc) & "'"
                End If
            End If
        Next
       
        Dim dr As DataRow = DataTables("回单异常").find(filter)
        If dr Is Nothing Then
            ls.Add(r)
            count += 1
        Else
            dic.add(dr, r)
        End If
    Else
        msgbox("订单未处理完成")
        e.cancel=True
    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

 

DataTables("回单异常").ResumeRedraw
p.Visible = False

systemready = True
msgbox("共有 "& count &" 条数据提交至回单" )
Tables("客服跟单").save
Tables("客服跟单").ClearCheckedRows


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/12/7 14:19:00 [只看该作者]

那你就看看 filter 的条件是否正常

 

参考这里的写法。不会做,就上传具体例子测试。

 

http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=78112&authorid=0&page=0&star=2

 


 回到顶部
帅哥哟,离线,有人找我吗?
sf020cf
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:412 积分:2665 威望:0 精华:0 注册:2015/10/2 23:48:00
  发帖心情 Post By:2015/12/7 16:31:00 [只看该作者]

还是上传实例吧 我改了没有效果 另外我还发现一个问题  在调度配载窗口 如果不小心点中了列字段,(有时候会,然后所有行会选中 ,然后计算 )有时候又不会 怎样才能点中列头时不等同于选中所有行

 

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目4_201512071536.zip


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/12/7 17:00:00 [只看该作者]

汗,没问题啊。勾选的,满足条件的都拷贝过去了啊。


 回到顶部
帅哥哟,离线,有人找我吗?
sf020cf
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:412 积分:2665 威望:0 精华:0 注册:2015/10/2 23:48:00
  发帖心情 Post By:2015/12/7 17:18:00 [只看该作者]

呃 我也才发现 可以了 另外那个问题要怎样解决?

空行怎样不给默认值 或者在提交的时候 不加载空行?

 


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/12/7 17:47:00 [只看该作者]

全局代码

 

Public ridx As Integer = -1

Public Sub MouseLeaveCell(sender As object, e As C1.Win.C1FlexGrid.RowColEventArgs)
    ridx = e.Row
End Sub

Public Sub MouseEnterCell(sender As object, e As C1.Win.C1FlexGrid.RowColEventArgs)
    ridx = e.Row
End Sub

 

afterOpenProject

 

Dim t As Table= Tables("配载订单")
addhandler t.grid.MouseEnterCell, addressof MouseLeaveCell

addhandler t.grid.MouseLeaveCell, addressof MouseEnterCell

 

AfterSelRangeChanged

 

If ridx > 0 Then
    If  math.abs(e.OldRange.TopRow - e.OldRange.BottomRow) >= 1 Then
        If e.OldRange.BottomRow >= e.Table.Rows.count Then Return
        For i As Integer = e.OldRange.TopRow To e.OldRange.BottomRow
            e.Table.Rows(i).Checked = False
        Next
       
        For i As Integer = e.Table.TopPosition To e.Table.BottomPosition
            e.Table.Rows(i).Checked = True
        Next
    End If
End If


 回到顶部
帅哥哟,离线,有人找我吗?
大红袍
  9楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:贵宾 帖子:39310 积分:196782 威望:0 精华:1 注册:2015/4/25 9:23:00
  发帖心情 Post By:2015/12/7 17:50:00 [只看该作者]

你可以删除空行

 

DataTables("配载订单").deletefor("项目 is null")


 回到顶部
帅哥哟,离线,有人找我吗?
sf020cf
  10楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:412 积分:2665 威望:0 精华:0 注册:2015/10/2 23:48:00
  发帖心情 Post By:2015/12/8 9:44:00 [只看该作者]

请问那个全局代码我要写在哪里

 回到顶部
总数 24 1 2 3 下一页