锦江投资股票千股千评:ERP二次开发之触发器应用

来源:百度文库 编辑:偶看新闻 时间:2024/04/19 19:32:07
ERP二次开发之触发器应用 <上一篇 | 下一篇> ERP二次开发对于ERP实施顾问二次开发是最熟悉不过了,对实施国内ERP软件的顾问能做自己做一点二次开发那就更好不过了,如果你不会懂数据库,不会做简单的二次开发,你会发现实施一个项目很困难,解决问题那就更加困难了!ERP软件的源代码都是软件公司控制,我们不可能得到或修改。那么我们常说的二次开发都有那些呢?
1、数据库的开发,就是利用sql server里的触发器对数据增加,修改,删除的时候做一些开发。
2、ERP软件自带的单据自定义功能,报表功能。这个我相信大家都用的很熟,这里就不写了!
3、利用ERP软件开放的接口进行二次开发。如金蝶开放的:凭证,基础数据,物流单据。
4、我觉得是最没有办法的选择。就是外挂,对数据库直接进行读写操作。注:以下sql需要大家自己测试!
在这里我要和大家重点讨论数据据触发器的开发:
问题:我们需要在物料基础资料里加一个自定义项“即时库存”,那么我们怎么样才能把即时库存查询里的数据写到这里呢?很简单,我们只需要在表即时库存表里如:ICInventory加一个触发器就可以解决。以用友为例:
CREATE TRIGGER  stockqty  ON [dbo].[CurrentStock]
FOR insert ,UPDATE
AS
DECLARE
@str1 varchar(40),
@fqty numeric(15,6),
@fqty1 numeric(15,6)
select @str1=cinvcode  from Insertedselect @fqty1=sum(t20.iQuantity) from Currentstock t20 where t20.cInvCode=@str1
 and t20.cWhCode<='60' group by t20.cinvcode
select @fqty=isnull(cInvDefine14,0) from Inventory where cinvcode =@str1
if @fqty<>@fqty1
update Inventory
 set cInvDefine14=@fqty1
where cinvcode =@str1
金蝶也一样表改一下,都一样!
问题:
问题描述:
在销售发票自动传递到应收款系统时,对应的应收款日期为,销售发票日期。而客户的需求确是销售出库的日期
问题觖决:
在收款计划表t_RP_RPDetail数据新增的时候,加入一触发器:
CREATE TRIGGER t_rp_rpdetail_insert1 ON t_rp_rpdetail --###
FOR INSERT
NOT FOR REPLICATION
AS
DECLARE @Next int,
@insert int,
@fbillno varchar(30),
@fdate datetime
if @@Rowcount = 0
return
--set @TableName = 't_rp_rpdetail' --###
SELECT @Next =forgid
FROM Insertedselect @fbillno=FNumber
from t_RP_Contact
where FID=@nextselect @insert=FOutStockInterID
from ICSale
where FBillNo=@fbillnoselect @fdate =FDate
from ICStockBill
where finterid=@insert
if @fdate is not null
begin
update t_rp_contact set FRPDate=@fdate from t_rp_contact where fid=@next
update t_RP_RPDetail set fdate=@fdate from t_RP_RPDetail where forgid=@next
end  问题:出库单自动带出单价。
CREATE TRIGGER   icstockinsert  ON [dbo].[ICStockBill]
FOR INSERT, UPDATE
ASDECLARE @kinterid int,@kentryid int,@kitemid int,@kqty decimal(28,10),@kBatchNo varchar(200),
@kprice as decimal(28,10),@ktrantype as int  select @ktrantype=ftrantype, @kinterid=finterid
 from Inserted
if @ktrantype in (21,24,28,29,41)  
beginupdate icstockbillentry set
Fauxprice=isnull(( select top 1 fprice from
icstockbill t10  inner join  icstockbillentry t20 on t10.finterid=t20.finterid
where t10.ftrantype in (1,2) and t20.fitemid=t1.fitemid and t20.fbatchno=t1.fbatchno
order by t10.fdate),0)
from icstockbillentry t1
where t1.finterid=@kinterid and  fauxprice=0update icstockbillentry set
famount=Fauxprice*fqty
from icstockbillentry t1
where t1.finterid=@kinterid and famount=0end