此处为电脑访问的代码:
Tables(e.Form.Name & "_Table1").Fill("S elect Distinct 执行状态,合同类型,简称 As 客户,合同主号,合同,日期,内定交货日,名称,牌号,规格_厚度 As 厚度,规格_宽度 As 宽度,规格_长度 As 长度,单价,硬度_状态 As Hv状态,硬度_MIN As HvMin,硬度_MAX As HvMax,单位,数量 As 合同量,0.00 As 发货量,0.00 As 退货量,0.00 As 欠交量 F rom {销售及加工合同} Where " & flt & " ORDER BY 执行状态,合同类型,简称,合同主号,合同","ShcsErpSql",True)
For Each r As Row In Tables(e.Form.Name & "_table1").Rows
r("发货量") = Val(_dt工序合并表.SQLCompute("Sum(数量)","合同 = '" & r("合同") & "'And 表名 = '销售及加工出库'"))
r("退货量") = Val(_dt工序合并表.SQLCompute("Sum(数量)","合同 = '" & r("合同") & "'And 工序 = '退货入库'"))
r("欠交量") = r("合同量") - r("发货量") + r("退货量")
Next
下面是移动访问的代码,不知如何实现发货量、退货量及欠交量的计算,请老师帮我写下代码,我好参考,谢谢!
Dim e As RequestEventArgs = args(0)
Dim page As Integer = 0 '默认page为0,显示第一页
Dim pageRows As Integer = 20 '每页20行
If e.GetValues.ContainsKey("page") Then '如果地址中有page参数
Integer.TryParse(e.GetValues("page"), page) '提取page参数
End If
Dim StartRow As Integer = page * pageRows '此页第一行
Dim EndRow As Integer = (page + 1) * pageRows - 1 '此页最后一行
Dim cmd As New SQLCommand
cmd.C '记得设置数据源名称
cmd.CommandText = "S elect Count(*) F rom {销售及加工合同}"
Dim Count As Integer = cmd.ExecuteScalar() '获取总的行数
cmd.CommandText = "S elect RowNum,* ,0.00 As 发货量,0.00 As 退货量,0.00 As 欠交量 From (Select Row_Number() Over(Order by [合同]) As RowNum, * F rom 销售及加工合同 Where 执行状态 = '执行中') As a "
cmd.CommandText = cmd.CommandText & " Where RowNum >= " & StartRow & " And RowNum <= " & EndRow
Dim dt As DataTable = cmd.ExecuteReader '获取该页数据
Dim sb As New StringBuilder
Dim nms() As String = {"客户","合同量","发货量","退货量","欠交量"}
sb.AppendLine("<Table border='1'>")
sb.AppendLine("<caption>合同浏览<caption></br>")
sb.Append("<tr>")
For Each nm As String In nms
sb.Append("<td>" & nm & "</td>")
Next
sb.AppendLine("</tr>")
For Each r As DataRow In dt.DataRows
sb.Append("<tr>")
For Each nm As String In nms
sb.Append("<td>" & r(nm) & "</td>")
Next
sb.AppendLine("</tr>")
Next
sb.AppendLine("</Table></br></br>")
If page > 0 Then
sb.Append("<a href='htcx.htm?page=" & page - 1 & "'>上一页</a> ")
End If
If EndRow < Count -1 Then
sb.Append("<a href='htcx.htm?page=" & page + 1 & "'>下一页 </a>" )
End If
sb.Append("<a href='default.htm'>返回 </a>" )
e.WriteString(sb.ToString)
[此贴子已经被作者于2018/6/11 23:11:56编辑过]