1。为什么选定多行后,渠道商返利单价 的值是相同的单价
2。单独选定一行,渠道商返利单价 的值是正确单价
Dim tb1 As WinForm.Table = e.Form.Controls("Table1")
Dim r1 As Row
Dim Names As New List(Of String)
For i As Integer = vars("trow") To vars("brow")
r1 = tb1.Table.Rows(i)
If Names.Contains(r1("行编码")) = False Then '判断集合是否包括"电视机"
Names.Add(r1("行编码"))
End If
Next
For Each djbh As String In names
Dim dr As DataRow = DataTables("出入库明细表").Find("行编码='" & djbh & "'")
If dr IsNot Nothing Then
Dim sr As DataRow
sr = DataTables("政策备案明细表").sqlFind("[供应商内码] = '" & r1("供应商内码") & "' And [渠道商内码] = '" & r1("渠道商内码") & "' And [品种内码] = '" & r1("品种内码") & "'And [销售单位内码] = '" & r1("销售单位内码") & "'", "制单日期 Desc") '在后台查找符合条件的行
If sr IsNot Nothing Then '如果找到了符合条件的行
dr("渠道商返利单价") = sr("渠道商返利单价")
dr.save
End If
End If
Next
代码放在什么事件里?vars("trow")和 vars("brow")值是怎么来的?
1、代码放在什么事件里?
按钮键-Click事件
2、vars("trow")和 vars("brow")值是怎么来的?
Table表-选择-AfterSelRangEcheng
With e.NewRange
vars("trow") = .TopRow
vars("brow") = .BottomRow
End With
Dim t As Table = e.Form.Controls("Table1").Table
Dim r1 As Row
Dim Names As New List(Of String)
For i As Integer = t.TopPosition To t.BottomPosition
r1 = t.Rows(i)
If Names.Contains(r1("行编码")) = False Then
Names.Add(r1("行编码"))
Dim dr As DataRow = DataTables("出入库明细表").Find("行编码='" & r1("行编码") & "'")
MsgBox("i=" & i & ",find=" & (dr IsNot Nothing))
If dr IsNot Nothing Then
Dim sr As DataRow
sr = DataTables("政策备案明细表").sqlFind("[供应商内码] = '" & r1("供应商内码") & "' And [渠道商内码] = '" & r1("渠道商内码") & "' And [品种内码] = '" & r1("品种内码") & "'And [销售单位内码] = '" & r1("销售单位内码") & "'", "制单日期 Desc") '在后台查找符合条件的行
MsgBox("sr=" & (sr IsNot Nothing))
If sr IsNot Nothing Then '如果找到了符合条件的行
dr("渠道商返利单价") = sr("渠道商返利单价")
dr.save
End If
End If
End If
Next
加代码调试看看
If sr IsNot Nothing Then '如果找到了符合条件的行
msgbox(dr("渠道商返利单价") )
dr("渠道商返利单价") = sr("渠道商返利单价")
msgbox(dr("渠道商返利单价") )
dr.save
End If