Foxtable(狐表)用户栏目专家坐堂 → 关于库存量的有趣问题,请教各位高手。(附示例)


  共有19911人关注过本帖树形打印复制链接

主题:关于库存量的有趣问题,请教各位高手。(附示例)

帅哥哟,离线,有人找我吗?
mr725
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:MVP荣誉狐 帖子:5154 积分:31434 威望:0 精华:8 注册:2008/9/8 12:27:00
  发帖心情 Post By:2009/7/4 12:07:00 [显示全部帖子]

下面是按楼主的意思写的代码,不知道行不?我在命令窗口中测试过ok。(注意焦点要在出库表上 如:最后一行)
Dim drs As List(Of DataRow)
drs = DataTables("库存").Select("[药品名称] = '" & currenttable.current("药品名称") & "'","批号")
dim sl as string
dim n as integer
For Each dr As Datarow In drs
    sl = sl & dr("库存量") & "|"
    dim k as integer = sl.split("|")(n)
    dim s as integer
    if k <= currenttable.current("数量")  and currenttable.current("数量")  -k>0 then
        s = dr("库存量")
        dr("库存量") = 0
        n=n+1
    elseif k> currenttable.current("数量") and currenttable.current("数量") -s>0 then
        dr("库存量") = k - (currenttable.current("数量") - s)
        exit for
    end if
next

其实‘库存’表有必要按批号来反映库存量吗? 如果因价格问题进行成本核算,应该选择‘入库’表中先入库的价格即可。
[此贴子已经被作者于2009-7-4 12:07:46编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
mr725
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:MVP荣誉狐 帖子:5154 积分:31434 威望:0 精华:8 注册:2008/9/8 12:27:00
  发帖心情 Post By:2009/7/4 12:59:00 [显示全部帖子]

8楼代码精简些:
Dim drs As List(Of DataRow)
drs = DataTables("库存").Select("[药品名称] = '" & currenttable.current("药品名称") & "'","批号")
dim sl as string
dim n as integer
For Each dr As Datarow In drs
    dim k as integer = dr("库存量")
    dim s as integer
    if k <= currenttable.current("数量")  and currenttable.current("数量")  -k>=0 then
        s = dr("库存量")
        dr("库存量") = 0
    elseif k> currenttable.current("数量") and currenttable.current("数量") -s>0 then
        dr("库存量") = k - (currenttable.current("数量") - s)
        exit for
    end if
next

 回到顶部
帅哥哟,离线,有人找我吗?
mr725
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:MVP荣誉狐 帖子:5154 积分:31434 威望:0 精华:8 注册:2008/9/8 12:27:00
  发帖心情 Post By:2009/7/4 13:06:00 [显示全部帖子]

以下是引用菜鸟foxtable在2009-7-4 12:51:00的发言:
由于药品库存有一定特殊性,比如同一批号的青霉素,如果三天内曾注射过则不需要皮试,假如换了批号,即使昨天注射过,今天也要进行皮试。所以库存管理必须要有批号。

我上面的代码可以用吗?
不了解行业特点啊~ 那么某批号的库存量为零时,要删除掉该条库存记录吗?  否则,n年后,库存中有一大批库存量为零的记录了。
若放在出库表的datacolchanged中 
if e.datacol.name = "数量"
     这里用10楼代码
end if

[此贴子已经被作者于2009-7-4 13:11:28编辑过]

 回到顶部
帅哥哟,离线,有人找我吗?
mr725
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信 一级勋章
等级:MVP荣誉狐 帖子:5154 积分:31434 威望:0 精华:8 注册:2008/9/8 12:27:00
  发帖心情 Post By:2009/7/4 13:49:00 [显示全部帖子]

看来不能跨批号出库了!~ 否则,可能将不同批号的药品发给同一个患者使用,恐出现‘青霉素’批号混用的现象,  那么条件设为这样:
    if k>= currenttable.current("数量") and currenttable.current("数量") >0 then
        dr("库存量") = k - currenttable.current("数量") 
        exit for
    end if

 回到顶部