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


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

主题:时段统计问题

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


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


图片点击可在新窗口打开查看此主题相关图片如下:qq图片20210518140659.png
图片点击可在新窗口打开查看
没加第二段红色代码前,不选时段直接查询会报错,选了时段,统计正常,于是我加了第一、二段红色代码,要求起止日期或起止时间控件不能为空,否则取消查询,可加后报错,是要求把时间显示转为字符型吧?请教应如何处理?
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 = "" OrElse e.Form.Controls("EndDate").Value = "" 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 & "# And 缴费_月租_止计日期 >= #" & .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 & "# and 缴费_月租_止计日期 >= #" & .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)
                Dim t As DataTable = e.Form.Controls("Table1").Table.DataTable
                If t.DataCols.Contains("查询_月租_起计日期") = False And t.DataCols.Contains("查询_月租_止计日期") = False And t.DataCols.Contains("查询_月租_缴费月数") = False And t.DataCols.Contains("查询_月租_缴费金额") = False Then
                    t.DataCols.add("查询_月租_起计日期", Gettype(Date))
                    t.DataCols.add("查询_月租_止计日期", Gettype(Date))
                    t.DataCols.add("查询_月租_缴费月数", Gettype(Double))
                    t.DataCols.add("查询_月租_缴费金额", Gettype(Double))
                End If
                .SetColVisibleWidth("分类|60|住址_巷|60|住址_号|40|住址_房|40|姓名|50|固定电话|80|手机号码|80|车牌号码|80|缴费_月租_月租单价|60|查询_月租_起计日期|70|查询_月租_止计日期|70|查询_月租_缴费月数|70|查询_月租_缴费金额|70")
                For Each dr As DataRow In DataTables("月租所属期缴费统计表_Table1").DataRows
                    dr("查询_月租_起计日期") = e.Form.Controls("StartDate").Value
                    dr("查询_月租_止计日期") = e.Form.Controls("EndDate").Value
                    dr("查询_月租_缴费月数") = DateDiff("m",e.Form.Controls("StartDate").Value,e.Form.Controls("EndDate").Value) + 1
                    dr("查询_月租_缴费金额") = (DateDiff("m",e.Form.Controls("StartDate").Value,e.Form.Controls("EndDate").Value) + 1) * dr("缴费_月租_月租单价")
                Next
                If .Rows.Count < 15 Then
                    .AddNew(15 - .Rows.Count)
                End If
                .ResumeRedraw()
                UnLockBaseMainForm() '解锁主界面
                .Cols("查询_月租_缴费金额").GrandTotal = True
                .GrandTotal = True
            End With
        End If
    End If
    DataTables("月租所属期缴费统计表_Table1").DataCols("查询_月租_缴费金额").SetFormat("#,###.##")

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