-- 作者:sf020cf
-- 发布时间: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
|
-- 作者:sf020cf
-- 发布时间: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
|
-- 作者:大红袍
-- 发布时间: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
|