以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  Filter  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=60800)

--  作者:石四
--  发布时间:2014/12/1 15:30:00
--  Filter

Dim Filter As String
Dim kehu As String = e.Form.Controls("guke1").Value
Filter = Filter &  " 客户名称 = \'" & kehu & "\'"
Dim f As New Filler
f.SourceTable = DataTables("产品目录") \'指定数据来源
f.SourceCols = "客户名称,零件图号,零件名称,单价" \'指定数据来源列
f.DataTable = DataTables("发票记录") \'指定数据接收表
f.Filter = Filter
f.Fill() \'填充数

 

"发票记录"表有日期列,Filter"产品目录"表相应数据后,怎么用代码将窗口日期控件的值写入"发票记录"表日期列?

 


--  作者:Bin
--  发布时间:2014/12/1 15:33:00
--  
这种情况,我建议你直接遍历填充吧, 然后直接为这个列赋值你 日期控件的值
--  作者:有点甜
--  发布时间:2014/12/1 15:35:00
--  


Dim sCols() As String = {"客户名称","零件图号","零件名称","单价"}
Dim dCols() As String = {"客户名称","零件图号","零件名称","单价"}
Dim dt1 As DataTable = DataTables("产品目录") \'指定数据来源
Dim dt2 As DataTable = DataTables("发票记录") \'指定数据接收表
Dim kehu As String = e.Form.Controls("guke1").Value
Dim riqi As String = e.Form.Controls("日期").Value
Dim Filter As String = " 客户名称 = \'" & kehu & "\'"
For Each dr As DataRow In dt1.Select(filter)
    Dim nr As DataRow = dt2.AddNew()
    For i As Integer =0 To sCols.Length -1
        nr(dCols(i)) = dr(sCols(i))
    Next
    nr("日期") = riqi
Next

 


--  作者:石四
--  发布时间:2014/12/1 15:44:00
--  

不太会用遍历:

 

Dim lbl As WinForm.DateTimePicker

lbl = e.Form.Controls("日期")

Dim b As Table = Tables("发票记录")

For r As Integer = 0 To b.Rows.Count - 1

   b.Current("日期") = lb1

  Next

For r As Integer = b.rows.Count - 1 To 0 Step -1

Next

 

这样对不?不会把发票记录表原有数据行日期覆盖吧?


--  作者:有点甜
--  发布时间:2014/12/1 15:45:00
--  
 看3楼。
--  作者:石四
--  发布时间:2014/12/1 16:12:00
--  
 

Dim Filter As String

Dim kehu As String = e.Form.Controls("guke1").Value

Filter = Filter &  " 客户名称 = \'" & kehu & "\'"

Dim f As New Filler

f.SourceTable = DataTables("产品目录") \'指定数据来源

f.SourceCols = "客户名称,零件图号,零件名称,单价" \'指定数据来源列

f.DataTable = DataTables("发票记录") \'指定数据接收表

f.Filter = Filter

f.Fill() \'填充数

 

Dim b As Table = Tables("发票记录")

For r As Integer = 0 To b.Rows.Count - 1

    b.Current("日期") = new Date(e.Form.Controls("日期"))

Next

For r As Integer = b.rows.Count - 1 To 0 Step -1

Next

 

试了上面代码,倒没有覆盖问题,就是数据数据类型转换又迷糊了:

 

从类型“DateTimePicker”到类型“Long”的转换无效。


--  作者:Bin
--  发布时间:2014/12/1 16:15:00
--  
日期类型要对应日期类型
--  作者:Bin
--  发布时间:2014/12/1 16:15:00
--  
b.Current("日期") =e.Form.Controls("日期").Value
--  作者:石四
--  发布时间:2014/12/1 16:16:00
--  
以下是引用有点甜在2014-12-1 15:35:00的发言:


Dim sCols() As String = {"客户名称","零件图号","零件名称","单价"}
Dim dCols() As String = {"客户名称","零件图号","零件名称","单价"}
Dim dt1 As DataTable = DataTables("产品目录") \'指定数据来源
Dim dt2 As DataTable = DataTables("发票记录") \'指定数据接收表
Dim kehu As String = e.Form.Controls("guke1").Value
Dim riqi As String = e.Form.Controls("日期").Value
Dim Filter As String = " 客户名称 = \'" & kehu & "\'"
For Each dr As DataRow In dt1.Select(filter)
    Dim nr As DataRow = dt2.AddNew()
    For i As Integer =0 To sCols.Length -1
        nr(dCols(i)) = dr(sCols(i))
    Next
    nr("日期") = riqi
Next

 

似乎这是唯一正确办法.

 

[此贴子已经被作者于2014-12-1 16:17:05编辑过]

--  作者:有点甜
--  发布时间:2014/12/1 16:16:00
--  

 看3楼。

 

 6楼代码

 

Dim Filter As String

Dim kehu As String = e.Form.Controls("guke1").Value

Filter = Filter &  " 客户名称 = \'" & kehu & "\'"

Dim f As New Filler

f.SourceTable = DataTables("产品目录") \'指定数据来源

f.SourceCols = "客户名称,零件图号,零件名称,单价" \'指定数据来源列

f.DataTable = DataTables("发票记录") \'指定数据接收表

f.Filter = Filter

f.Fill() \'填充数

 

Dim b As Table = Tables("发票记录")

For r As Integer = 0 To b.Rows.Count - 1
   
    b.Rows(r)("日期") = e.Form.Controls("日期").Text
   
Next

For r As Integer = b.rows.Count - 1 To 0 Step -1
   
Next