Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共2 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:数据引用

1楼
zhangxl1964 发表于:2011/10/29 7:35:00

请问:如何实现从后台直接跨表引用数据,或是说从数据库直接引用数据?如有考勤表和工资表,打开项目时都没有加载数据,打开工资表时没能取到考勤表的出勤数据,等打开考勤表相对应的月份数据后才引用到,这是那里出错了?

If IsNumeric(e.NewValue) And Val(e.NewValue)=0 Then
    e.DataRow(e.DataCol.Name) =Nothing
End If

If e.DataCol.Name="日期"
    Dim SendTime As DateTime=e.DataRow("日期")
    e.DataRow("发放日期")=DateAdd("m",1,SendTime)
End If

If e.DataRow("审核") = False And  e.DataCol.Name = "编号" Then
If e.DataRow("编号")<>Nothing And e.DataRow("日期")<>Nothing
If e.DataCol.Name="日期" Or e.DataCol.Name="编号"
    Dim ChangeTime(0 To 100) As DateTime
    Dim a As Integer
    Dim b As Integer
    Dim c As DateTime
    Dim n As Integer=0
    Dim tag As Integer=0
    Dim tempTime1 As DateTime
    Dim tempTime2 As DateTime
    For Each dr As DataRow In DataTables("合同记录").Select("编号 = '" & e.DataRow("编号") & "'" )
        If dr.IsNull("辞退日期") Or dr("辞退日期")>e.DataRow("日期")
            ChangeTime(n)=dr("登记月份")
            n=n+1
        Else If dr("辞退日期")<e.DataRow("日期")
            tempTime1=CDate(dr("辞退日期"))
            tempTime2=CDate(e.DataRow("日期"))
            If(tempTime1.Year=tempTime2.Year And tempTime1.Month=tempTime2.Month)
                ChangeTime(n)=dr("登记月份")
                n=n+1
            Else
                tag=-1
            End If
            Exit For
        End If
    Next
    If tag=-1    '如果有一条记录的辞退日期小于考勤日期,那么这条考勤记录为空
        e.DataRow("姓名")=Nothing
        e.DataRow("部门")=Nothing
        e.DataRow("班组")=Nothing
        e.DataRow("基本工资")=Nothing       
        e.DataRow("月度考核")=Nothing
        e.DataRow("公积金")=Nothing
        e.DataRow("社会保险")=Nothing
        e.DataRow("加班是否")=Nothing
        e.DataRow("银行卡号")=Nothing
        e.DataRow("起征额")=Nothing
        e.DataRow("所得税号")=Nothing

    Else   
    Dim AttendanceTime As DateTime
    AttendanceTime = e.DataRow("日期")
    For a=0 To n-1
        For b=a+1 To n-1
        If ChangeTime(a) > ChangeTime(b) Then
           c = ChangeTime(a)
           ChangeTime(a) = ChangeTime(b)
           ChangeTime(a) = c
        End If
        Next
    Next

    'For a=0 To n-1
        'MessageBox.Show(ChangeTime(a))
    'Next

    Dim flag As Integer=0
    For a=0 To n-1
        If(e.DataRow("日期")>=ChangeTime(a))
            flag=a
        End If
    Next
    Dim MaxChangeTime As DateTime=ChangeTime(flag)
    For Each dr As DataRow In DataTables("合同记录").Select("编号 = '" & e.DataRow("编号")& "' And 登记月份='" & MaxChangeTime & "'" )
        e.DataRow("姓名")=dr("姓名")
        e.DataRow("部门")=dr("部门")
        e.DataRow("班组")=dr("班组")
        e.DataRow("基本工资")=dr("基本工资")
        e.DataRow("月度考核")=dr("月度考核")
        e.DataRow("公积金")=dr("公积金")
        e.DataRow("社会保险")=dr("社会保险")
        e.DataRow("加班是否")=dr("加班是否")
        e.DataRow("银行卡号")=dr("银行卡号")
        e.DataRow("起征额")=dr("起征额")
        e.DataRow("所得税号")=dr("所得税号")
    Next
    End If

End If

    End If

Dim dr2 As DataRow =e.DataRow
Dim chuqin As Decimal
    chuqin=DataTables("考勤表").Compute("Sum(出勤)", "考勤日期='" & dr2("日期") & "' And 编号=" & dr2("编号") )
    Dim fadingchuqin As Decimal
    fadingchuqin=DataTables("法定出勤").Compute("Sum(出勤天数)", "日期='" & dr2("日期") & "'")

'计算出勤
If  not dr2.IsNull("姓名") Then
    If fadingchuqin=chuqin Then
        dr2("出勤")="全勤"
    Else
         dr2("出勤")=chuqin
    End If
End If

End If

2楼
狐狸爸爸 发表于:2011/10/29 8:26:00

都没有看到加载数据的代码啊。

用个简单的例子说话吧。

共2 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02734 s, 2 queries.