You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

83 lines
2.9 KiB

1 year ago
if exists(select * from sysobjects where name='p_rz_cnt' and xtype='p')
drop procedure p_rz_cnt
go
create procedure p_rz_cnt
(
@psorgcode varchar(10),
@psbillno varchar(20),
@psparams varchar(200),
@psmsg varchar(2000) out
)
as
begin
declare @sisgenoq varchar(1)
declare @sorgcode varchar(10)
declare @ssupcode varchar(15)
declare @sjymode varchar(1)
declare @sjscode varchar(1)
declare @sdkrate varchar(500)
declare @soqbillno varchar(20)
declare @scurdate varchar(10)
declare @scurtime varchar(8)
set @sisgenoq=isnull(@psparams,'1')
set @soqbillno=''
select @sorgcode=orgcode,@ssupcode=supcode,@sjymode=jymode,@sjscode=jscode,@sdkrate=ext3 from t_contract where contrno=@psbillno
select @scurdate=convert(varchar(100),getdate(),23),@scurtime=convert(varchar(100),getdate(),108)
if @sjscode not in ('0','1')
begin
begin
set @psmsg='<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>ʽ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȷ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
return(-1)
end
end
if @sisgenoq = '1'
begin
--<EFBFBD><EFBFBD><EFBFBD>ݺ<EFBFBD>ͬ<EFBFBD><EFBFBD>Ʒ<EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɳ<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD>
exec f_get_billno 'oq',@psorgcode,'1',@soqbillno output
--<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD>ͷ
insert into t_orderquote_head(billno,contrno,orgcode,supcode,supname,quotetype,lrdate,lrtime,rzdate,rztime,usercode,username,zdrcode,zdrname,shrcode,shrname,chkstatus,remark)
select @soqbillno,contrno,@psorgcode,supcode,isnull((select supname from t_supplier where supcode=cnt.supcode),'') as supname,'0',@scurdate,@scurtime,@scurdate,@scurtime,
usercode,username,usercode,username,'','','0','<EFBFBD><EFBFBD>ִͬ<EFBFBD>г<EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
from t_contract cnt where contrno=@psbillno
--<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD>Ʒ<EFBFBD><EFBFBD>ϸ
insert into t_orderquote_body(billno,serialno,plucode,barcode,pluname,cargono,spec,unit,jtaxrate,depcode,depname,remark)
select @soqbillno,row_number() over(order by p.plucode) as serialno,p.plucode,p.barcode,p.pluname,p.cargono,p.spec,p.unit,p.jtaxrate,
u.depcode,(select depname from t_dept where depcode=u.depcode) as depname,''
from t_contr_plu p,t_plu u where p.plucode=u.plucode and p.contrno=@psbillno
--<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϸ
insert into t_orderquote_org(BillNo,SerialNo,PluCode,OrgCode,JPrice,NetJPrice,Remark)
select @soqbillno,oqb.SerialNo,p.plucode,o.orgcode,p.jprice,p.netjprice,''
from t_contr_org o,t_contr_plu p,t_orderquote_body oqb where o.contrno=p.contrno and p.plucode=oqb.plucode
and o.contrno=@psbillno and oqb.BillNo=@soqbillno
--<EFBFBD><EFBFBD><EFBFBD>ü<EFBFBD><EFBFBD>˹<EFBFBD><EFBFBD><EFBFBD>
exec p_rz_oq @psorgcode,@soqbillno,'',@psmsg output
if @@error <> 0
begin
set @psmsg = '<EFBFBD><EFBFBD><EFBFBD>ɵĺ<EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>۵<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>:' + @psmsg
return(-1)
end
end
if @sjscode='2'
begin
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>֯<EFBFBD><EFBFBD>Ʒ<EFBFBD>ĵ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
update p
set p.dkrate = convert(numeric(19,4),@sdkrate)
from t_plu_org p
where supcode=@ssupcode
and exists(select orgcode from t_contr_org c where c.orgcode=p.orgcode and c.contrno=@psbillno)
end
update t_contract set contrstatus='0',statusdate=@scurdate where contrno=@psbillno
set @psmsg=''
return(1)
end
go