Dim dr As DataRow = Tables("工程款管理").current.DataRow
If dr("审批状态") = "已审批完成" Then
MessageBox.Show("已审批完成的项目不能再进行计算!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
e.Cancel = True
Return
End If
Output.Show(Format(Date.Now,"HH:mm:ss.ffff"))
Dim filter As String = "合同编码='" & dr("合同编码") & "'and 计量期数='" & dr("计量期数") & "'"
Output.Show(dr("新老项目"))
If dr("新老项目") = "新项目" Then '为空
Dim Filter1 As String= "合同编码='" & dr("合同编码") & "'"
With e.Form.Controls("开piao日期")
If .Value IsNot Nothing Then
Dim d As Date = .value
Dim d2 As Date = new Date(d.year, d.Month, 15)
d2 = d2.AddMonths(1)
Filter1 &= " and 寄达日期 <= '" & d2 & "'"
End If
End With
Output.Show(Format(Date.Now,"HH:mm:ss.ffff"))
Dim sum1 As Double = DataTables("进项piao审核").sqlCompute("sum(税额)", filter1 & " and 审核状态='已审核' and 类别='专piao'")
Output.Show(Format(Date.Now,"HH:mm:ss.ffff"))
Dim sum2 As Double = 0
For i As Integer = 1 To dr("计量期数")-1
sum2 += val(dr.DataTable.datarows(i-1)("本期统计增值税"))
Next
Output.Show(Format(Date.Now,"HH:mm:ss.ffff"))
'dr("本期统计增值税")= sum1-sum2
dr("本期统计增值税") = DataTables("进项piao审核").sqlCompute("sum(税额)", filter & " And 审核状态='已审核' and 类别='专piao'")
dr("本期统计成本fa piao") = DataTables("进项piao审核").sqlCompute("sum(税后金额)", filter & " And 审核状态='已审核' and 工料机类别 in ('材料','机械','管理')") + DataTables("进项piao审核").sqlCompute("sum(税额)", filter & " And 审核状态='已审核' and 类别='普piao' and 工料机类别 in ('材料','机械','管理')")
dr("本期统计人工工资") = DataTables("进项piao审核").sqlCompute("sum(税后金额)", filter & " And 审核状态='已审核' and 工料机类别='人工'") + DataTables("进项piao审核").sqlCompute("sum(税额)", filter & " And 审核状态='已审核' and 类别='普piao' and 工料机类别='人工'")
Else
Output.Show(Format(Date.Now,"HH:mm:ss.ffff"))
dr("本期统计增值税") = DataTables("进项piao审核").sqlCompute("sum(税额)", filter & " And 审核状态='已审核' and 类别='专piao'") '不分时段计算
dr("本期统计成本fa piao") = DataTables("进项piao审核").sqlCompute("sum(税后金额)", filter & " And 审核状态='已审核' and 工料机类别 in ('材料','机械','管理')") + DataTables("进项piao审核").sqlCompute("sum(税额)", filter & " And 审核状态='已审核' and 类别='普piao' and 工料机类别 in ('材料','机械','管理')")
dr("本期统计人工工资") = DataTables("进项piao审核").sqlCompute("sum(税后金额)", filter & " And 审核状态='已审核' and 工料机类别='人工'")
End If
Output.Show(Format(Date.Now,"HH:mm:ss.ffff"))
'成本fa piao及人工工资
If dr("应缴增值税基数") =Nothing Then '为空
dr("成本基数") = Nothing
ElseIf dr("应缴增值税基数") ="合同金额" Then
dr("成本基数") = dr("合同金额")
Else If dr("应缴增值税基数") ="fa piao金额" Then
dr("成本基数") = dr("fa piao金额")
Else If dr("应缴增值税基数") ="计量金额" Then
dr("成本基数") = dr("计量金额")
Else If dr("应缴增值税基数") ="申请金额" Then
dr("成本基数") = dr("申请金额")
End If
Output.Show(Format(Date.Now,"HH:mm:ss.ffff"))
……