以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 分箱功能虽然实现,请专家帮助优化一下,我实现的太繁琐 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=109959) |
||||
-- 作者:whtb999 -- 发布时间:2017/11/23 16:01:00 -- 分箱功能虽然实现,请专家帮助优化一下,我实现的太繁琐
|
||||
-- 作者:whtb999 -- 发布时间:2017/11/23 16:05:00 -- 我是使用窗口1,开始每实现一步用了一个按钮,最后把所有的代码进行了整合,集中到了一键分箱的事件里了,请专家老师帮我优化,而且我还中间用了两个表作为中介。感觉写的太麻烦,但又没有能力修改,是不是可以省去中间的两个表直接实现我的功能。 |
||||
-- 作者:有点蓝 -- 发布时间:2017/11/23 16:14:00 -- 如何进行分箱,拆分的逻辑是什么?原来是怎么做的,具体代码在哪里? |
||||
-- 作者:whtb999 -- 发布时间:2017/11/23 16:15:00 -- \'第一步将记录拆成一条一条的 Dim Cols1() As String = {"长度","宽度","厚度","编号","单个重量","编号"} Dim Cols2() As String = {"长度","宽度","厚度","编号","单个重量","编号"} For Each dr1 As DataRow In DataTables("产品数据").Select("[数量] > 0") For j As Integer = 1 To dr1("数量") Dim dr2 As DataRow = DataTables("产品数据拆分").AddNew() For i As Integer = 0 To Cols1.Length -1 dr2(Cols2(i)) = dr1(Cols1(i)) dr2("数量")=1 Next Next Next \'一条条的累加重量不超过500 Dim Sumzl As Integer Dim k As Integer=1 Dim Cols11() As String = {"长度","宽度","厚度","编号","单个重量","编号","数量"} Dim Cols22() As String = {"长度","宽度","厚度","编号","单个重量","编号","数量"} For Each dr11 As DataRow In DataTables("产品数据拆分").Select("[数量] > 0") sumzl= sumzl + dr11("单个重量") If sumzl>500 Then sumzl=0 k=k+1 End If Dim dr22 As DataRow = DataTables("分箱明细").AddNew() For i As Integer = 0 To Cols11.Length -1 dr22(Cols22(i)) = dr11(Cols11(i)) dr22("箱号")=k Next Next \'建立分组查看代码进行复制生成分箱结果 Dim g As New GroupTableBuilder("分箱结果", DataTables("分箱明细")) g.Groups.AddDef("长度") g.Groups.AddDef("宽度") g.Groups.AddDef("厚度") g.Groups.AddDef("单个重量") g.Groups.AddDef("编号") g.Groups.AddDef("箱号") g.Totals.AddDef("数量") g.Build() MainTable = Tables("分箱结果")
|
||||
-- 作者:whtb999 -- 发布时间:2017/11/23 16:15:00 -- 老师整个项目压缩上传了 |
||||
-- 作者:whtb999 -- 发布时间:2017/11/23 16:30:00 -- 此主题相关图片如下:窗口图片.png |
||||
-- 作者:whtb999 -- 发布时间:2017/11/23 16:45:00 -- 老师我是根据数量的循环进行先拆分存储到产品拆分的表里,然后在根据条件,一条条的累加,如果总重量超过500就算一箱完毕,箱号进行加一操作,并且存储到分箱明细表里,然后对分箱明细进行分组查询,生成分箱结果。 |
||||
-- 作者:有点蓝 -- 发布时间:2017/11/23 17:29:00 -- 看看是不是这种效果 DataTables("分箱明细").DataRows.Clear Dim Cols1() As String = {"长度","宽度","厚度","编号","单个重量","编号"} Dim Cols2() As String = {"长度","宽度","厚度","编号","单个重量","编号"} Dim dr2 As DataRow Dim zl As Integer = 0 For Each dr1 As DataRow In DataTables("产品数据").Select("[数量] > 0 and 单个重量 > 0") Dim gs As Integer = Math.Floor(500 / dr1("单个重量")) Dim cnt As Integer = 1 Dim sl As Integer = dr1("数量") For j As Integer = 1 To sl Step gs dr2 = DataTables("分箱明细").AddNew() For i As Integer = 0 To Cols1.Length -1 dr2(Cols2(i)) = dr1(Cols1(i)) Next dr2("数量")= iif(j+gs > sl,sl - j+1,gs) dr2("箱号")=cnt cnt += 1 Next Next |
||||
-- 作者:有点甜 -- 发布时间:2017/11/23 17:47:00 -- Dim Cols1() As String = {"长度","宽度","厚度","编号","单个重量","编号"}
|
||||
-- 作者:whtb999 -- 发布时间:2017/11/24 6:06:00 -- 谢谢老师就是这种效果 [此贴子已经被作者于2017/11/24 6:12:45编辑过]
|