zoukankan      html  css  js  c++  java
  • 采购入库

    --exec cgrk_all 6
    --采购入库全功能
    alter proc cgrk_all(@hid int)
    as
    set nocount on
    begin
    --入库量
    declare @rksl table(ph varchar(100),pm varchar(100),cgdh varchar(100),rksl float,itemid int,hid int,ck varchar(100),location varchar(100),fid int)
    --未存在库存的物料
    declare @ph table(ph varchar(100))

    insert into @rksl(ph,pm,cgdh,rksl,itemid,hid,ck,location,fid)
    select ph,pm,cgdddh,rksl,itemid,hid,ck,location,fid from dwc_279 where hid=@hid
    --采购入库回填
    update dwc_232 set ckdigit=isnull(ckdigit,0)+isnull(rksl,0)
    from dwd_232 a inner join dwc_232 b on a.hid=b.hid inner join @rksl c on a.dh=c.cgdh and b.hpbm=c.ph

    --更新到库存
    update ditw set onHand=isnull(onHand,0)+isnull(rksl,0)
    from @rksl a inner join ditw b on a.ph=b.fathercode

    --库存未存在,插入
    insert into @ph(ph)
    select ph from @rksl where ph not in (select fathercode from ditw)
    insert into ditw(whscode,fathercode,onhand)
    select ck,a.ph,rksl from @rksl a inner join @ph b on a.ph=b.ph
    --插入明细
    insert into dwsd(insertTime,whouseID,location,doccode,doctype,docdate,itemcode,periodid,innum,fid,hid)
    select getdate(),ck,location,cgdh,'采购入库',getdate(),ph,convert(varchar(7),getdate(),120),rksl,fid,hid from @rksl
    end

    每天一进步、一积累,创造自我价值,体现人生逼格,你是自己的赢家!
  • 相关阅读:
    HDUOJ----3342Legal or Not
    HDUOJ----2647Reward
    hduoj------确定比赛名次
    HDUOJ----1165Eddy's research II
    HDUOJ-----1556Color the ball
    HDUOJ-----2175取(m堆)石子游戏
    HDUOJ---------2255奔小康赚大钱
    HDUOJ------1711Number Sequence
    HDUOJ---1712 ACboy needs your help
    HDUOJ---1867 A + B for you again
  • 原文地址:https://www.cnblogs.com/chlf/p/4152056.html
Copyright © 2011-2022 走看看