以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  求助  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=96982)

--  作者:sf020cf
--  发布时间:2017/3/3 15:14:00
--  求助
现有一个出库窗口,在窗口中有一个控件是出库数量,在TextChanged 中想实现如果出库数量小于该商品号所在的其中一个库位中的数量,直接遍历赋值,再扣减库存,假如出库数量大于任何一个其中的库位,则按入库日期秉承先进先出原则,若干个库位中的库存相加满足出库量则止,并把这些库位列出到窗口库位控件中,以便接下来打印出库单。我写了些代码,接下来的要怎样完成,望指导。
 代码如下:
Dim pbx As WinForm.PictureBox
pbx = e.form.Controls("提示")
Dim sl As Double = val(e.Sender.text)
Dim kykc As Double = val(e.form.Controls("可用库存").text)
Dim dj As Double = val(e.form.Controls("单价").value)
If sl = Nothing Then
    e.Form.Controls("出库数量").text = "0 " 
    pbx.Image = GetImage("Images\\exclamation.gif")
    e.Form.Controls("提示信息").text = "请输入出库数量,不能为空!"
    e.Form.Controls("提示信息").ForeColor = Color.Red
    e.Form.Controls("增加").Enabled = False
    Return
End If
If sl = 0 Then
    e.Form.Controls("出库数量").text = "0 " 
    pbx.Image = GetImage("Images\\exclamation.gif")
    e.Form.Controls("提示信息").text = "出库数量必须大于 0"
    e.Form.Controls("提示信息").ForeColor = Color.Red
    e.Form.Controls("增加").Enabled = False
    Return
ElseIf sl > kykc Then
    e.Form.Controls("出库数量").text = "0 " 
    pbx.Image = GetImage("Images\\exclamation.gif")
    e.Form.Controls("提示信息").text = "库存可用数量不足本次出库!"
    e.Form.Controls("提示信息").ForeColor = Color.Red
    e.Form.Controls("增加").Enabled = False
    Return
else
e.Form.Controls("出库数量").text = sl 

Dim dr As DataRow = DataTables("商品库存明细").Find("Item = \'" & e.Form.Controls("商品编号").text & "\'")

 

If dr IsNot Nothing Then

Dim wz As Integer = Tables("商品库存明细").FindRow(dr)

        If wz >= 0 Then

            Tables("商品库存明细").Position = wz

        End If

If dr("可用库存") sl Then

        

        e.Form.Controls("单价").text = dr("单价") & " 元"

        e.Form.Controls("总价").text = Format(dr(“单价”) * sl,"n")  & " 元

        If dr("生产日期") = Nothing Then

            e.Form.Controls("生产日期").text = "未知"

        Else

            e.Form.Controls("生产日期").text = dr("生产日期")

        End If

        If dr("有效期至") = Nothing Then

            e.Form.Controls("有效期至").text = "未知"

        Else

           e.Form.Controls("有效期至").text = dr("有效期至")

        End If

        e.Form.Controls("规格").text = dr("Pack Size")

        e.Form.Controls("商品状态").text = dr("商品状态")

        e.Form.Controls("库位").text = dr("库位")

       

    End If

End If

End if

If dj = Nothing Then
    pbx.Image = GetImage("Images\\exclamation.gif")
    e.Form.Controls("提示信息").text = "商品单价为空,请尽量完善!"
    e.Form.Controls("提示信息").ForeColor = Color.Red
    e.Form.Controls("增加").Enabled = True
    Return
End If
If dj = 0 Then
    pbx.Image = GetImage("Images\\exclamation.gif")
    e.Form.Controls("提示信息").text = "商品单价为 0 ,请尽量完善!"
    e.Form.Controls("提示信息").ForeColor = Color.Red
    e.Form.Controls("增加").Enabled = True
    Return
End If
e.Form.Controls("增加").Enabled = True
pbx.Image = GetImage("Images\\payment_card.png")
e.Form.Controls("提示信息").text = "金额小计: " & Format(dj * sl,"n")  & " 元"
e.Form.Controls("提示信息").ForeColor = Color.black

--  作者:狐狸爸爸
--  发布时间:2017/3/3 15:19:00
--  
涉及到具体业务逻辑,别人很难帮得上忙,因为理解不了你的设计逻辑,最好化为具体的技术问题。
--  作者:sf020cf
--  发布时间:2017/3/3 15:32:00
--  
我得好好理一理,是这样,比如出库数量是80个商品编号为A10001的商品,在库存明细表中,A10001有3个库位存储,库位1:A-1  库位2:B-1 库位3:C-1 对应的有库存:20, 70, 75 ,对应的入库日期:2016-1-10     2016-12-10    2016-05-05 
逻辑是 假如是其中一个库位直接满足出库量,直接在该库位出,如果不满足,如上:三个库位都不满足出库量,则需要按入库日期的顺序把库存相加直到满足出库量,上面的最终的出库单上库位提示是在 A-1 和 C-1 提货出库 代码需要怎样实现


--  作者:有点蓝
--  发布时间:2017/3/3 15:58:00
--  
上传实例测试
--  作者:有点色
--  发布时间:2017/3/3 16:43:00
--  

 一个库是否满足的,直接查询有没有大于的即可。

 

 先进先出,参考这个例子 http://www.foxtable.com/bbs/dispbbs.asp?BoardID=2&ID=82143&skin=0