以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=87773)

--  作者:g1j2h3
--  发布时间:2016/7/19 11:33:00
--  [求助]

我想在考勤表中自动加载员工信息表,一天只加载一次,下边的这个代码如何修改

For Each dr As DataRow In DataTables("员工信息表").DataRows   
    Dim dr2 As DataRow
    dr2 = DataTables("考勤表").AddNew()
    dr2("岗位代码") =  dr("岗位代码")   
    dr2("岗位") =  dr("岗位")   
    dr2("姓名") =  dr("姓名")   
   Next


--  作者:大红袍
--  发布时间:2016/7/19 11:38:00
--  

 考勤表,不是应该有日期列的么?判断一下有没有今天的日期就行了

 

Dim fdr As DataRow = DataTables("考勤表").Find("日期 = #" & Date.Today & "#")

If fdr Is Nothing Then
   
    For Each dr As DataRow In DataTables("员工信息表").DataRows
        Dim dr2 As DataRow
        dr2 = DataTables("考勤表").AddNew()
        dr2("岗位代码") =  dr("岗位代码")
        dr2("岗位") =  dr("岗位")
        dr2("姓名") =  dr("姓名")
        dr2("日期")= Date.today
    Next
   
End If


--  作者:g1j2h3
--  发布时间:2016/7/19 11:52:00
--  

多谢老师指点