以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]经过一系列代码之后代码把打印指向了datatable的行,如何让其指向当前table的当前行?  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=47579)

--  作者:jimmyhwang
--  发布时间:2014/3/12 20:09:00
--  [求助]经过一系列代码之后代码把打印指向了datatable的行,如何让其指向当前table的当前行?

如题。。打印出来是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编辑过]

--  作者:lsy
--  发布时间:2014/3/12 21:02:00
--  
代码多,又没例子,没法测试。
--  作者:jimmyhwang
--  发布时间:2014/3/12 22:32:00
--  
代码虽多,层次分明啊。应该是最初的寻找dr的时候把打印指向datatable。因为print进程是在条件里面,我只是不知道如何指定要打印的行。
--  作者:jimmyhwang
--  发布时间:2014/3/12 23:49:00
--  

原来原因不在于有没有绑定table,而是用position定位之后没有生效,要点击table里的当前行才能打印当前行的内容。。请问如何选中position所在的行啊?

[此贴子已经被作者于2014-3-13 0:52:49编辑过]

--  作者:Bin
--  发布时间:2014/3/13 8:43:00
--  
代码多,又没例子,没法测试分析.

--  作者:狐狸爸爸
--  发布时间:2014/3/13 17:56:00
--  

楼主,DataTable怎么会存在当前行呢? 只有Table才有当前行之说。

也许你定义细节区的时候,并非是根据“查询_Table1"定义的。

修改模版的定义,或者看看:

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

 


--  作者:jimmyhwang
--  发布时间:2014/3/13 18:31:00
--  

狐爸,谢谢你~ 结症就在这里了。解决了~