阳光网驿-企业信息化交流平台【DTC零售连锁全渠道解决方案】

 找回密码
 注册

QQ登录

只需一步,快速开始

扫描二维码登录本站

手机号码,快捷登录

老司机
查看: 5462|回复: 17

[原创] 发些金蝶K3二次开发的成品,喜欢的朋友可以研究。

  [复制链接]
  • TA的每日心情
    开心
    2015-9-11 11:24
  • 签到天数: 63 天

    [LV.6]常住居民II

    发表于 2012-3-15 09:33:53 | 显示全部楼层 |阅读模式
    看这版有点冷,扔把火烧烧,动静动静。二次开发这类的,我不知道发到哪里,就先发补丁这版区了。

    采购入库分解触发器:
    作用:自动分解入库结果
    代码:
    ALTER trigger [dbo].[t_cgrkdentry_zby_insert] on [dbo].[t_cgrkdentry]
    for insert
    AS
    --select * from t_cgrkd
    --select * from t_cgrkdentry
    --select * from t_cgrkdmxcl
    declare @Fid int,@Findex int,@Fqty decimal(20,2),@i int,@maxi int,@Foperid int
    declare @Fitemid int,@Funitid int,@p int,@maxp int,@Fsupid int
    select @Fid=Fid,@Findex=Findex from inserted
    select @Fsupid=Fsupply from t_cgrkd where Fid=@Fid
    create table #bomdata(Fitemid int,Funitid int,Fqty decimal(20,2),Fbatchno varchar(50),Fauxpropid int,
    Fcustid int,Fpp int,Fother int,Fprice decimal(20,6),Famount decimal(20,2),Ftaxprice decimal(20,6),Ftaxamount decimal(20,2),
    Ftaxrate decimal(20,2),Fstockid int,Fspid int,Fnote varchar(250),Fqinhao varchar(50),
    Fid_src int,Fentryid_src int,Fbillno_src varchar(50),Fclassid_src int)
    create table #bomdata2(Findex int not null identity,Fitemid int,Funitid int,Fqty decimal(20,2),Fbatchno varchar(50),Fauxpropid int,
    Fcustid int,Fpp int,Fother int,Fprice decimal(20,6),Famount decimal(20,2),Ftaxprice decimal(20,6),Ftaxamount decimal(20,2),
    Ftaxrate decimal(20,2),Fstockid int,Fspid int,Fnote varchar(250),Fqinhao varchar(50),
    Fid_src int,Fentryid_src int,Fbillno_src varchar(50),Fclassid_src int)
    --select @maxi=max(Fentryid) from t_routingoper where Finterid=@Froutingid
    select @i=1,@p=1
    delete from t_cgrkdmxcl where Fid=@Fid and Fitemid=0
    --插入临时表1
    select @maxp=max(Findex) from t_cgrkdentry where Fid=@Fid
    select @p=1
    delete from t_cgrkdmxcl where Fid=@Fid
    while @p<=@maxp
    begin
    select @Fitemid=Fitemid from t_cgrkdentry where Fid=@Fid and Findex=@p
    if exists(select 1 from icbom where Fitemid=@Fitemid)
    insert into #bomdata
    select t3.Fitemid,t3.Funitid,t1.Fqty*t3.Fauxqty as Fqty,t1.Fbatchno,t1.Fauxpropid,
    t1.Fcustid,t1.Fpp,t1.Fother,0,0,0,0,
    17,t1.Fstockid,t1.Fspid,t1.Fnote,t1.Fqinhao,
    t1.Fid_src,t1.Fentryid_src,t1.Fbillno_src,t1.Fclassid_src
    from t_cgrkdentry t1,icbom t2,icbomchild t3,t_icitem t4
    where t1.Fid=@Fid and t1.Findex=@p and t1.Fitemid=t2.Fitemid and t2.Finterid=t3.Finterid
    and t3.Fitemid=t4.Fitemid
    else
    insert into #bomdata
    select Fitemid,Funitid,Fqty,Fbatchno,Fauxpropid,
    Fcustid,Fpp,Fother,Fprice,Famount,Ftaxprice,Ftaxamount,
    Ftaxrate,Fstockid,Fspid,Fnote,Fqinhao,
    Fid_src,Fentryid_src,Fbillno_src,Fclassid_src
    From t_cgrkdentry where Fid=@Fid and Findex=@p
    --select * from icbom
    --select * from t_cgrkdentry
    select @p=@p+1
    if @p>@maxp
      break
    else
      continue
    end
    --更新辅助属性
    update t1 set t1.Fauxpropid=13234
    from #bomdata t1,t_icitem t2 where t1.Fitemid=t2.Fitemid and t2.FAuxClassID=3009 and t1.Fauxpropid=0
    --更新忘记写的批次
    update t1 set t1.Fbatchno='-'
    from #bomdata t1,t_icitem t2 where t1.Fitemid=t2.Fitemid and t2.Fbatchmanager=1 and isnull(t1.Fbatchno,'')=''
    --更新价格为0部分物料的价格和金额?
    update t1 set t1.Ftaxprice=t2.Fprice,t1.Fprice=t2.Fprice/(1+t3.Fvalueaddrate/100),
    t1.Ftaxamount=round(t2.Fprice*t1.Fqty,2),t1.Famount=round(t2.Fprice/(1+t3.Fvalueaddrate/100)*t1.Fqty,2)
    from #bomdata t1,t_supplyentry t2,t_supplier t3 where t1.Fitemid=t2.Fitemid and t2.Fsupid=@Fsupid and t2.Fsupid=t3.Fitemid
    and t2.Fused=1
    --select * from t_supplyentry
    --select Fvalueaddrate,* from t_supplier
    --插入临时表2
    insert into #bomdata2
    select Fitemid,Funitid,Fqty,Fbatchno,Fauxpropid,
    Fcustid,Fpp,Fother,Fprice,Famount,Ftaxprice,Ftaxamount,
    Ftaxrate,Fstockid,Fspid,Fnote,Fqinhao,
    Fid_src,Fentryid_src,Fbillno_src,Fclassid_src
    From #bomdata --order by Fnumber
    --group by Fitemid,Funitid,FoperID,Fdefaultloc,Fitemid2,FSCbillno
    --插入投料信息分录表
    INSERT INTO t_cgrkdmxcl
    (FID,Findex,Fitemid,Funitid,Fqty,Fbatchno,Fauxpropid,
    Fcustid,Fpp,Fother,Fprice,Famount,Ftaxprice,Ftaxamount,
    Ftaxrate,Fstockid,Fspid,Fnote,Fqinhao,
    Fid_src,Fentryid_src,Fbillno_src,Fclassid_src)
    select @FID,Findex,Fitemid,Funitid,Fqty,Fbatchno,Fauxpropid,
    Fcustid,Fpp,Fother,Fprice,Famount,Ftaxprice,Ftaxamount,
    Ftaxrate,Fstockid,Fspid,Fnote,Fqinhao,
    Fid_src,Fentryid_src,Fbillno_src,Fclassid_src From #bomdata2
    drop table #bomdata2,#bomdata

    楼主热帖
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    无聊
    2017-9-21 21:25
  • 签到天数: 21 天

    [LV.4]偶尔看看III

    发表于 2017-6-14 12:33:52 | 显示全部楼层
    看这版有点冷,扔把火烧烧,动静动静。二次开发这类的,我不知道发到哪里,就先发补丁这版区了。
    启用邀请码注册,提高发帖质量,建设交流社区
    头像被屏蔽
  • TA的每日心情
    开心
    2020-5-20 20:01
  • 签到天数: 373 天

    [LV.9]以坛为家II

    发表于 2019-3-15 13:36:36 | 显示全部楼层
    提示: 作者被禁止或删除 内容自动屏蔽
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    开心
    2024-3-25 15:30
  • 签到天数: 354 天

    [LV.8]以坛为家I

    发表于 2019-1-19 20:47:47 | 显示全部楼层
    必须顶一下,辛苦的劳动成果,先收下,看以后能不能用上
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    开心
    2015-9-11 11:24
  • 签到天数: 63 天

    [LV.6]常住居民II

     楼主| 发表于 2012-3-15 09:39:19 | 显示全部楼层
    update icbom set Fusestatus=1072,Fstatus=1,Fcheckerid=16394,Fcheckdate='2011-03-20'
    where Fstatus=0
    update icbom set Fusestatus=1072 where Fusestatus=1073
    在icbom中Fusestatus字段值为1073的是未审核的,批量更新为1072就是已审核的了。
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    开心
    2015-9-11 11:24
  • 签到天数: 63 天

    [LV.6]常住居民II

     楼主| 发表于 2012-3-15 09:41:00 | 显示全部楼层
    修改“仓位”为非必录项
    update ictemplateentry set Fmustinput=0,Fsysmustinputitem=0 where Fid='B04' and FHeadcaption='仓位'
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    开心
    2016-2-6 00:09
  • 签到天数: 268 天

    [LV.8]以坛为家I

    发表于 2012-3-15 09:46:33 | 显示全部楼层
    马克........感谢分享.....................
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    奋斗
    2018-7-31 10:49
  • 签到天数: 105 天

    [LV.6]常住居民II

    发表于 2012-3-15 09:58:08 | 显示全部楼层
    收藏下来了。虽然暂时用的是用友。以后工作中还是能有很多机会使用金蝶的。
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    无聊
    2017-9-11 15:40
  • 签到天数: 961 天

    [LV.10]以坛为家III

    发表于 2012-3-15 10:22:50 | 显示全部楼层
    这个必须得顶一下,顺便再收藏一下,感谢分享。
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    开心
    2020-3-14 14:31
  • 签到天数: 270 天

    [LV.8]以坛为家I

    发表于 2012-3-15 10:54:22 | 显示全部楼层
    这个不错,支持一下,再多点就好了
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    慵懒
    2021-1-28 19:34
  • 签到天数: 1144 天

    [LV.10]以坛为家III

    发表于 2012-3-15 22:44:29 | 显示全部楼层
    这些东西不错,都是劳动成果和经验。。
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    开心
    2023-3-25 13:48
  • 签到天数: 316 天

    [LV.8]以坛为家I

    发表于 2012-3-16 00:27:01 | 显示全部楼层
    这个技术贴太专业了,都搞不懂了,得顶
    启用邀请码注册,提高发帖质量,建设交流社区
  • TA的每日心情
    慵懒
    2024-4-2 09:40
  • 签到天数: 817 天

    [LV.10]以坛为家III

    发表于 2012-3-16 09:14:03 | 显示全部楼层
    技术贴,对于我们这些刚入门的,有解释就好了
    启用邀请码注册,提高发帖质量,建设交流社区
    您需要登录后才可以回帖 登录 | 注册

    本版积分规则

    快速回复 返回顶部 返回列表