Foxtable(狐表)用户栏目专家坐堂 → 如何将一个表列名上的日期转成另一个表的日期型数据


  共有7074人关注过本帖树形打印复制链接

主题:如何将一个表列名上的日期转成另一个表的日期型数据

帅哥哟,离线,有人找我吗?
有点甜
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2013/6/16 10:03:00 [显示全部帖子]

做个按钮,按钮代码:

 

Dim dt1 As Date = new Date(Date.Today.Year,1,1)
dt1 = dt1.AddDays(-dt1.DayOfWeek + 1)
DataTables("ShippingTable").DataRows.Clear
DataTables("ShippingTable").StopRedraw
For Each dr1 As DataRow In DataTables("ForecastTable").Datarows
    For Each dc As DataCol In DataTables("ForecastTable").DataCols
        If dc.name Like "W#*"
            Dim dr2 As DataRow  = DataTables("ShippingTable").Addnew
            dr2("Customer") = dr1("Customer")
            dr2("StokvisPN") = dr1("StokvisPN")
            dr2("ShippingQuantity")  = dr1(dc.name)
            Dim wk As Integer = dc.name.SubString(1)
            dr2("DemandDate") = dt1.AddDays(wk * 7)
        End If
    Next
Next
DataTables("ShippingTable").ResumeRedraw

 

 


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2013/6/16 20:48:00 [显示全部帖子]

Dim dt1 As Date = new Date(Date.Today.Year,1,1)
dt1 = dt1.AddDays(-dt1.DayOfWeek + 1)
DataTables("ShippingTable").DataRows.Clear
DataTables("ShippingTable").StopRedraw
For Each dr1 As DataRow In DataTables("ForecastTable").Select("日期列名称 >= #" Date.Today.Adddays(-14) & "#")
    For Each dc As DataCol In DataTables("ForecastTable").DataCols
        If dc.name Like "W#*"
            Dim dr2 As DataRow  = DataTables("ShippingTable").Addnew
            dr2("Customer") = dr1("Customer")
            dr2("StokvisPN") = dr1("StokvisPN")
            dr2("ShippingQuantity")  = dr1(dc.name)
            Dim wk As Integer = dc.name.SubString(1)
            dr2("DemandDate") = dt1.AddDays(wk * 7)
        End If
    Next
Next
DataTables("ShippingTable").ResumeRedraw


 回到顶部
帅哥哟,离线,有人找我吗?
有点甜
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2013/7/16 21:14:00 [显示全部帖子]

原来的问题,后三周可以这样处理:

Dim dt1 As Date = new Date(Date.Today.Year,1,1)
dt1 = dt1.AddDays(-dt1.DayOfWeek + 1)
DataTables("ShippingTable").DataRows.Clear
DataTables("ShippingTable").StopRedraw
For Each dr1 As DataRow In DataTables("ForecastTable").Datarows
    For Each dc As DataCol In DataTables("ForecastTable").DataCols
        If dc.name Like "W#*"
            Dim wk As Integer = dc.name.SubString(1)
            Dim dv As Date = dt1.AddDays(wk * 7)
            If dv >= Date.Today AndAlso dv <=  Date.today.Adddays(20)
                Dim dr2 As DataRow  = DataTables("ShippingTable").Addnew
                dr2("Customer") = dr1("Customer")
                dr2("StokvisPN") = dr1("StokvisPN")
                dr2("ShippingQuantity")  = dr1(dc.name)
                dr2("DemandDate") = dv
            End If
        End If
    Next
Next
DataTables("ShippingTable").ResumeRedraw

新的问题,看不懂。



 回到顶部