如题。。打印出来是datatable的当前行。不是table的当前行。困惑中~ 各位大侠帮帮忙,小弟拜谢~ 通常是什么原因导致这样? 难道因为用datatable的find之行之后的结果?但是后来又把table的position修正过来呢。
完整代码,各位老师帮忙看看。。到底为什么打印到了datatable去了。。困惑呢。
Dim txt As String = e.Form.controls("cxtextbox").text '查询
Dim dr As DataRow
dr = DataTables("小包发货单").Find(" [订单子编号] = '" & txt & "'" )
If e.Form.controls("cxtextbox").text = "" OrElse dr Is Nothing Then '没结果,窗口所有空间都锁定
Tables("查询_Table1").Filter = " 1 = 2 "
e.Form.controls("cxtextbox").Select()
Else If dr IsNot Nothing Then '如果找到该行
Tables("查询_Table1").Filter = ""
Dim wz As Integer = Tables("查询_Table1").FindRow(dr) '查找该行在table中的行号
If wz >= 0 Then
Tables("查询_Table1").Position = wz
Tables("查询_Table1").Filter = " 订单编号 = '" & e.Form.Controls("ddbhTextBox").Text & "'"
Dim r As Integer
r = Tables("查询_Table1").FindRow("[订单子编号] ='" & txt & "'" ) '从第一行开始查找
If r >= 0 Then '如果找到的话
Tables("查询_Table1").Position = r '定位到找到的行
Dim sl As String = e.Form.controls("sltextbox").text '子单商品数量.
If e.Form.controls("cjdsltextbox").text = "" Then
If sl = "1" Then
Tables("查询_Table1").Current("采集到数量") = sl
Dim cjdsl As String = e.Form.controls("cjdsltextbox").text
Tables("查询_Table1").Current("缺货数量") = val(sl) - val(cjdsl)
Tables("查询_Table1").Current("退货数量") = "0"
Tables("查询_Table1").Current("入库数量") = sl
Tables("查询_Table1").Current("拣货状态") = "已入库"
Dim Sum As Integer
Dim sum1 As Integer
Sum = Tables("查询_Table1").Compute("Sum(数量)")
Sum1 = Tables("查询_Table1").Compute("Sum(入库数量)", " 拣货状态 = '已入库' or 拣货状态 = '数量不够'")
If sum1 = sum Then
Dim Result As DialogResult
Result = messagebox.show("货已经全齐,请打印地址标签/快递单并发货?","发货信息提示", MessageBoxButtons.OK, MessageBoxIcon.Question)
If Result = DialogResult.OK Then
Dim Book As New XLS.Book(ProjectPath & "Attachments\小包发货单.xls")
Dim fl As String = ProjectPath & "Reports\小包发货单.xls"
Book.Build()
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
'Proc.Verb = "Print" '指定动作
Proc.Start()
For Each r1 As Row In Tables("查询_Table1").Rows
r1("地址标签") = True
r1("拣货状态") = "待发货"
r1("仓位信息") = "已出库"
Next
End If
Else If sum1 <> sum Then
Dim ddbh As String = e.Form.controls("ddbhtextbox").text '订单编号
Dim dr2 As DataRow
dr2 = DataTables("小包发货单").Find(" [订单编号] = '" & ddbh & "' And [拣货状态] = '采集中'" )
If dr2 Is Nothing Then
Dim n As Integer = sum - sum1
messagebox.show("该订单采集完毕!缺" & n & "件! 请更在网站更改订单状态通知客户!")
Else If dr2 IsNot Nothing Then
Return
End If
End If
Else If sl > "1" Then
Dim Result1 As DialogResult
Result1 = messagebox.show("是否" & "'" & sl & "'" & "件都齐了?", "入库提示",MessageBoxButtons.YesNo, MessageBoxIcon.Question)
If Result1 = DialogResult.Yes Then
Tables("查询_Table1").Current("采集到数量") = sl
Dim cjdsl As String = e.Form.controls("cjdsltextbox").text
Tables("查询_Table1").Current("缺货数量") = val(sl) - val(cjdsl)
Tables("查询_Table1").Current("退货数量") = "0"
Tables("查询_Table1").Current("入库数量") = sl
Tables("查询_Table1").Current("拣货状态") = "已入库"
Dim Sum As Integer
Dim sum1 As Integer
Sum = Tables("查询_Table1").Compute("Sum(数量)")
Sum1 = Tables("查询_Table1").Compute("Sum(入库数量)", " 拣货状态 = '已入库' or 拣货状态 = '数量不够'")
If sum1 = sum Then
Dim Result As DialogResult
Result = messagebox.show("货已经全齐,请打印地址标签/快递单并发货?","发货信息提示", MessageBoxButtons.OK, MessageBoxIcon.Question)
If Result = DialogResult.OK Then
Dim Book As New XLS.Book(ProjectPath & "Attachments\小包发货单.xls")
Dim fl As String = ProjectPath & "Reports\小包发货单.xls"
Book.Build()
Book.Save(fl)
Dim Proc As New Process
Proc.File = fl
'Proc.Verb = "Print" '指定动作
Proc.Start()
For Each r1 As Row In Tables("查询_Table1").Rows
r1("地址标签") = True
r1("拣货状态") = "待发货"
r1("仓位信息") = "已出库"
Next
End If
Else If sum1 <> sum Then
Dim ddbh As String = e.Form.controls("ddbhtextbox").text '订单编号
Dim dr2 As DataRow
dr2 = DataTables("小包发货单").Find(" [订单编号] = '" & ddbh & "' And [拣货状态] = '采集中'" )
If dr2 Is Nothing Then
Dim n As Integer = sum - sum1
messagebox.show("该订单采集完毕!缺" & n & "件! 请更在网站更改订单状态通知客户!")
Else If dr2 IsNot Nothing Then
Return
End If
End If
Else If Result1 = DialogResult.No Then
e.Form.controls("cjdsltextbox").Select()
Messagebox.show("请输入采集到实际数量!")
End If
End If
Else If e.Form.controls("cjdsltextbox").text <> "" Then
Return
End If
End If
End If
End If
[此贴子已经被作者于2014-3-12 20:23:12编辑过]