Foxtable(狐表)用户栏目专家坐堂 → 用程序从关联表按年月自动统计数据


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

主题:用程序从关联表按年月自动统计数据

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


加好友 发短信
等级:婴狐 帖子:16 积分:189 威望:0 精华:0 注册:2015/12/1 16:39:00
用程序从关联表按年月自动统计数据  发帖心情 Post By:2018/8/6 18:08:00 [显示全部帖子]

论坛工程师:您好!

对上表有两个想法:前面您给的指导,还不能自动更新,必须通过“重置”后才可以更新数据。请按如下给予修改。

<!--[if !supportLists]-->一、     <!--[endif]-->简单的做法:当“日报记录表”里数据的连铸_6M】或连铸_9M】列发生变化时,“日报表”和“月报表”的统计数据“出坯量”等数据,按年、月的选择自动更新变化。请给予帮助。

<!--[if !supportLists]-->二、     <!--[endif]-->复杂一点的程序:当“日报记录”表里的数据发生变化时,能自动生成日报表、月报表、年报表。请给予帮助指导。

                        溧阳光明:陈志刚

                               2018-08-06

 

如下面的程序:

<!--[if !supportLists]-->1. <!--[endif]-->月报表的项目事件中DataColChanged

Select Case e.DataCol.Name

    Case "","","单位"

        If e.DataRow.IsNull("") OrElse e.DataRow.IsNull("") OrElse e.DataRow.IsNull("单位") Then

            e.DataRow("连铸_6M") = Nothing

            e.DataRow("出坯量") = Nothing

        Else

            Dim d As Date = new Date(e.DataRow(""),e.DataRow(""),1)

            Dim Filter As String = "日期 >= #" & d & "# and 日期 < #" & d.AddMonths(1) & "# and 单位='" & e.DataRow("单位") & "'"

            e.DataRow("连铸_6M") = Tables("日报表").Compute("sum(连铸_6M)",Filter )

            e.DataRow("出坯量") = Tables("日报表").Compute("sum(出坯量)",Filter )

           

           

            e.DataRow("电炉_耗电") = Tables("日报表").Compute("sum(电炉_耗电)",Filter )

            e.DataRow("出库物资") = Tables("日报表").Compute("sum(出库物资)",Filter )

           

        End If

End Select

2. 日报表的项目事件中DataColChanged

Select Case e.DataCol.Name

    Case "连铸_6M","连铸_9M","连铸_每米重量","液氩"

        If e.DataRow.IsNull("日期") = False AndAlso e.DataRow.IsNull("单位") = False

            Dim pr As DataRow

            Dim d As Date = e.DataRow("日期")

            pr = DataTables("月报表").Find(" = " & d.Month & " and = " & d.Year & " and 单位='" & e.DataRow("单位") & "'")

            If pr IsNot Nothing Then

                DataTables("月报表").DataCols("").RaiseDataColChanged(pr)

            End If

        End If

    Case "日期"

        If e.OldValue <> Nothing Then

            Dim pr As DataRow

            Dim d As Date = e.OldValue

            pr = DataTables("月报表").Find(" = " & d.Month & " and = " & d.Year & " and 单位='" & e.DataRow("单位") & "'")

            If pr IsNot Nothing Then

                DataTables("月报表").DataCols("").RaiseDataColChanged(pr)

            End If

        End If

        If e.NewValue <> Nothing Then

            Dim pr As DataRow

            Dim d As Date = e.NewValue

            pr = DataTables("月报表").Find(" = " & d.Month & " and = " & d.Year & " and 单位='" & e.DataRow("单位") & "'")

            If pr IsNot Nothing Then

                DataTables("月报表").DataCols("").RaiseDataColChanged(pr)

            End If

        End If

    Case "单位"

        If e.OldValue <> Nothing Then

            Dim pr As DataRow

            Dim d As Date = e.DataRow("日期")

            pr = DataTables("月报表").Find(" = " & d.Month & " and = " & d.Year & " and 单位='" & e.OldValue  & "'")

            If pr IsNot Nothing Then

                DataTables("月报表").DataCols("").RaiseDataColChanged(pr)

            End If

        End If

        If e.NewValue <> Nothing Then

            Dim pr As DataRow

            Dim d As Date = e.DataRow("日期")

            pr = DataTables("月报表").Find(" = " & d.Month & " and = " & d.Year & " and 单位='" & e.NewValue  & "'")

            If pr IsNot Nothing Then

                DataTables("月报表").DataCols("月").RaiseDataColChanged(pr)

            End If

        End If

End Select

3. “日记表”的项目事件中DataColChanged

Select Case e.DataCol.Name

    Case "日期","单位","连铸_6M","连铸_9M","连铸_每米重量"

        If e.DataRow.IsNull("日期") = False AndAlso e.DataRow.IsNull("单位") = False

            Dim pr As DataRow

            Dim d As Date = e.DataRow("日期")

            pr = DataTables("月报表").Find("月 = " & d.Month & " and 年 = " & d.Year & " and 单位='" & e.DataRow("单位") & "'")

            If pr IsNot Nothing Then

                DataTables("月报表").DataCols("月").RaiseDataColChanged(pr)

            End If

        End If

End Select

 

 

 

 

 

 

     


[此贴子已经被作者于2018/8/6 19:12:43编辑过]

 回到顶部