Foxtable(狐表)用户栏目专家坐堂 → 时段统计问题


  共有13850人关注过本帖平板打印复制链接

主题:时段统计问题

美女呀,离线,留言给我吧!
采菊东篱下
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:八尾狐 帖子:1881 积分:10374 威望:0 精华:0 注册:2019/4/6 8:45:00
  发帖心情 Post By:2021/12/2 16:09:00 [只看该作者]


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20211202160341.png
图片点击可在新窗口打开查看
这代码得出很多重复的数据,我要得出2020-12-01到2021-06-30所有不重复累计数,这些数据有些很可能不是连续交费的,所以只能在此基础上再统计一次。
If e.Form.Controls("ComboBox1").Value = "" Then'当日期为空取消保存操作
    messagebox.show("请选择分类")
    Return
End If
If e.Form.Controls("ComboBox1").Value = e.Form.Controls("ComboBox1").Items(1) Then
    If e.Form.Controls("StartDate").Value = Nothing OrElse e.Form.Controls("EndDate").Value = Nothing Then '当日期为空取消保存操作
        messagebox.show("请选择起止日期")
        Return
    Else
        Dim Filter As String
        Dim f2 As String
        Filter = "分类 = '" & e.Form.Controls("ComboBox1").Value & "'"
        With e.Form.Controls("StartDate")
            If .Value IsNot Nothing Then
                f2 = "[缴费_月租_起计日期] >= #" & .Value & "#"
            End If
        End With
        With e.Form.Controls("EndDate")
            If .Value IsNot Nothing Then
                If f2 > "" Then
                    f2 = Filter & " And "
                End If
                f2  = f2  & "[缴费_月租_起计日期] <= #" & .Value & "#"
            End If
        End With
        If F2 > "" Then
            If Filter > "" Then
                Filter = Filter & " And "
            End If
            Filter = Filter & " (" & F2 & ") "
        End If
        With e.Form.Controls("DropBox1")
            If .Value IsNot Nothing Then
                If Filter > "" Then
                    Filter = Filter & " And "
                End If
                Filter = Filter & "车牌号码 = '" & .Value & "'"
            End If
        End With
        If Filter > "" Then
            With Tables("安费用所属期查询统计_Table1")
                For i As Integer = .Rows.count - 1 To 0 Step -1
                    .Rows(i).Delete
                Next
                LockBaseMainForm() '锁定主界面
                .StopRedraw()
                For i As Integer = DataTables("缴费情况").DataRows.count - 1 To 0 Step -1
                    Dim tr As DataRow = DataTables("缴费情况").DataRows(i)
                    If tr.Isnull("车牌号码") Then
                        tr.delete
                    End If
                Next
                .Fill("Select [_Identify],分类,住址_巷,住址_号,住址_房,姓名,手机号码,车牌号码,缴费_月租_起计日期,缴费_月租_止计日期,缴费_月租_月租单价 fr om {缴费情况} Where " & Filter,False)
                If .Rows.Count < 15 Then
                    .AddNew(15 - .Rows.Count)
                End If
                .ResumeRedraw()
                UnLockBaseMainForm() '解锁主界面
            End With
        End If
        Dim t As DataTable = e.Form.Controls("Table1").Table.DataTable
        If t.DataCols.Contains("查询_月租_有效起计日期") = False Then
            t.DataCols.add("查询_月租_有效起计日期", Gettype(Date))
        End If
        If t.DataCols.Contains("查询_月租_有效止计日期") = False Then
            t.DataCols.add("查询_月租_有效止计日期", Gettype(Date))
        End If
        If t.DataCols.Contains("查询_月租_缴费月数") = False Then
            t.DataCols.add("查询_月租_缴费月数", Gettype(Double))
        End If
        If t.DataCols.Contains("查询_月租_缴费金额") = False Then
            t.DataCols.add("查询_月租_缴费金额", Gettype(Double))
        End If
        Tables("安费用所属期查询统计_Table1").SetColVisibleWidth("分类|60|住址_巷|60|住址_号|30|住址_房|30|姓名|50|手机号码|80|车牌号码|70|查询_月租_有效起计日期|70|查询_月租_有效止计日期|70|缴费_月租_月租单价|60|查询_月租_缴费月数|70|查询_月租_缴费金额|70")
        Tables("安费用所属期查询统计_Table1").SetHeaderRowHeight(0,0,25)
        If t.DataRows.Count > 0 Then
            Dim rq1 As Date
            Dim rq2 As Date
            For Each dr As DataRow In t.DataRows
                If dr("缴费_月租_起计日期") <= "#" & e.Form.Controls("StartDate").Value & "#" Then
                    rq1 = "#" & e.Form.Controls("StartDate").Value & "#"
                ElseIf dr("缴费_月租_起计日期") > "#" & e.Form.Controls("StartDate").Value & "#" Then
                    rq1 = "#" & dr("缴费_月租_起计日期") & "#"
                End If
                If dr("缴费_月租_止计日期") >= "#" & e.Form.Controls("EndDate").Value & "#" Then
                    rq2 = "#" & e.Form.Controls("EndDate").Value & "#"
                ElseIf dr("缴费_月租_止计日期") < "#" & e.Form.Controls("EndDate").Value & "#" Then
                    rq2 = "#" & dr("缴费_月租_止计日期") & "#"
                End If                
                If dr.IsNull("车牌号码") Then
                    dr("查询_月租_有效起计日期") = Nothing
                    dr("查询_月租_有效止计日期") = Nothing
                    dr("查询_月租_缴费月数") = Nothing
                Else
                    dr("查询_月租_有效起计日期") = rq1
                    dr("查询_月租_有效止计日期") = rq2
                    dr("查询_月租_缴费月数") = DateDiff("m",dr("查询_月租_有效起计日期"),dr("查询_月租_有效止计日期")) + 1
                    dr("查询_月租_缴费金额") = (DateDiff("m",dr("查询_月租_有效起计日期"),dr("查询_月租_有效止计日期")) + 1) * dr("缴费_月租_月租单价")
                End If
            Next
        End If
        Tables("安费用所属期查询统计_Table1").Cols("查询_月租_缴费金额").GrandTotal = True
        Tables("安费用所属期查询统计_Table1").GrandTotal = True
        DataTables("安费用所属期查询统计_Table1").DataCols("查询_月租_缴费金额").SetFormat("#,###.##")
    End If
End If
[此贴子已经被作者于2021/12/2 17:29:18编辑过]

 回到顶部
总数 123 1 2 3 4 5 6 7 8 9 10 下一页 ..13