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
Dim Filter As String
Filter = "分类 = '" & e.Form.Controls("ComboBox1").Value & "'"
With e.Form.Controls("StartDate")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "缴费_月租_起计日期 <= #" & .Value & "#"
End If
End With
With e.Form.Controls("EndDate")
If .Value IsNot Nothing Then
If Filter > "" Then
Filter = Filter & " And "
End If
Filter = Filter & "缴费_月租_止计日期 >= #" & .Value & "#"
End If
End With
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],分类,住址_巷,住址_号,住址_房,姓名,固定电话,手机号码,车牌号码,缴费_月租_月租单价 fro m {缴费情况} 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
ElseIf e.Form.Controls("ComboBox1").Value = e.Form.Controls("ComboBox1").Items(2)
Dim Filter1 As String
Filter1 = "分类 = '" & e.Form.Controls("ComboBox1").Value & "'"
With e.Form.Controls("DateTimePicker1")
If .Value IsNot Nothing Then
If Filter1 > "" Then
Filter1 = Filter1 & " And "
End If
Filter1 = Filter1 & "缴费_临时停放_起计时间 >= #" & Format(.Value.adddays(-1),"G") & "#"
End If
End With
With e.Form.Controls("DateTimePicker2")
If .Value IsNot Nothing Then
If Filter1 > "" Then
Filter1 = Filter1 & " And "
End If
Filter1 = Filter1 & "缴费_临时停放_止计时间 <= #" & Format(.Value.adddays(1),"G") & "#"
End If
End With
With e.Form.Controls("DropBox1")
If .Value IsNot Nothing Then
If Filter1 > "" Then
Filter1 = Filter1 & " And "
End If
Filter1 = Filter1 & "车牌号码 = '" & .Value & "'"
End If
End With
If Filter1 > "" 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],分类,亲属临时停车,车牌号码 fro m {缴费情况} Where " & Filter1,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 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))
t.DataCols.add("查询_临时停放_缴费累计金额", Gettype(Double))
End If
.SetColVisibleWidth("分类|80|亲属临时停车|50|车牌号码|100|查询_临时停放_起计时间|120|查询_临时停放_止计时间|120|查询_临时停放_停放累计时间|120|查询_临时停放_计费累计时间|120|查询_临时停放_缴费累计金额|120")
For Each dr As DataRow In DataTables("月租所属期缴费统计表_Table1").DataRows
dr("查询_临时停放_起计时间") = e.Form.Controls("DateTimePicker1").Value
dr("查询_临时停放_止计时间") = e.Form.Controls("DateTimePicker2").Value
dr("查询_临时停放_停放累计时间") = DataTables("缴费情况").Compute("Sum(缴费_临时停放_停车时间)","[车牌号码] ='" & dr("车牌号码") & "' And [缴费_临时停放_起计时间] >= #" & Format(e.Form.Controls("DateTimePicker1").Value.adddays(-1),"G") & "# And [缴费_临时停放_止计时间] <= #" & Format(e.Form.Controls("DateTimePicker2").Value.adddays(1),"G") & "#")
dr("查询_临时停放_计费累计时间") = DataTables("缴费情况").Compute("Sum(缴费_临时停放_计费时间)","[车牌号码] ='" & dr("车牌号码") & "' And [缴费_临时停放_起计时间] >= #" & Format(e.Form.Controls("DateTimePicker1").Value.adddays(-1),"G") & "# And [缴费_临时停放_止计时间] <= #" & Format(e.Form.Controls("DateTimePicker2").Value.adddays(1),"G") & "#")
dr("查询_临时停放_缴费累计金额") = DataTables("缴费情况").Compute("Sum(缴费_临时停放_缴费金额)","[车牌号码] ='" & dr("车牌号码") & "' And [缴费_临时停放_起计时间] >= #" & Format(e.Form.Controls("DateTimePicker1").Value.adddays(-1),"G") & "# And [缴费_临时停放_止计时间] <= #" & Format(e.Form.Controls("DateTimePicker2").Value.adddays(1),"G") & "#")
Next
If .Rows.Count < 15 Then
.AddNew(15 - .Rows.Count)
End If
.ResumeRedraw()
UnLockBaseMainForm()
.Cols("查询_临时停放_停放累计时间").GrandTotal = True
.Cols("查询_临时停放_计费累计时间").GrandTotal = True
.Cols("查询_临时停放_缴费累计金额").GrandTotal = True
.GrandTotal = True
End With
End If
End If
请教应如何写这代码?