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.

107 lines
5.7 KiB

--<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
1 year ago
if exists(select * from sysobjects where name='p_rz_oq' and xtype='p')
drop procedure p_rz_oq
go
create procedure p_rz_oq
(
@psorgcode varchar(10),
@psbillno varchar(20),
@psparams varchar(200),
@psmsg varchar(2000) out
)
as
begin
declare @sorgcode varchar(10)
declare @squotetype varchar(1)
declare @scontrno varchar(40)
declare @ssupcode varchar(15)
declare @scurver varchar(1)
declare @scurdate varchar(10)
declare @scurtime varchar(8)
declare @susercode varchar(6)
declare @susername varchar(10)
declare @sstationid varchar(15)
declare @soptcontent varchar(100)
declare @ilen int
declare @iindex int
declare @stmp varchar(100)
select @susername=substring(@stmp,1,@iindex-1),@sstationid=substring(@stmp,@iindex+1,@ilen)
select @sorgcode=orgcode,@squotetype=quotetype,@scontrno=isnull(contrno,''),@ssupcode=supcode from t_orderquote_head where billno=@psbillno
select @scurdate=convert(varchar(100),getdate(),23),@scurtime=convert(varchar(100),getdate(),108)
if @squotetype='0'
begin
update a set a.jtaxrate=src.jtaxrate,
a.jprice=src.jprice,
a.netjprice=src.netjprice,
a.billno=src.billno,
a.usercode=src.usercode,
a.username=src.username,
a.rzdate=src.rzdate,
a.rztime=src.rztime,
a.dsccode=src.dsccode,
a.remark=src.remark
from t_order_quote a,
(select f.billno,s.orgcode,f.quotetype,f.supcode,f.supname,f.contrno,isnull(f.bgndate,'') bgndate,isnull(f.enddate,'') enddate,
d.plucode,d.pluname,d.barcode,d.spec,d.cargono,d.unit,d.jtaxrate,s.jprice,s.netjprice,f.usercode,f.username,f.rzdate,f.rztime,f.dsccode,d.remark
from t_orderquote_head f,t_orderquote_body d,t_orderquote_org s
where f.billno=d.billno and d.plucode=s.plucode and d.billno=s.billno and f.billno=@psbillno)src
where a.orgcode=src.orgcode and a.quotetype=src.quotetype and a.supcode=src.supcode and a.contrno=src.contrno and a.plucode=src.plucode
if @@error <> 0
begin
set @psmsg='<EFBFBD><EFBFBD><EFBFBD>¼۸<EFBFBD>ʧ<EFBFBD><EFBFBD>'
1 year ago
return(-1)
end
insert into t_order_quote(billno,orgcode,quotetype,supcode,supname,contrno,bgndate,enddate,plucode,pluname,barcode,spec,cargono,unit,jtaxrate,jprice,netjprice,usercode,username,rzdate,rztime,dsccode,remark)
select f.billno,s.orgcode,f.quotetype,f.supcode,f.supname,f.contrno,isnull(f.bgndate,''),isnull(f.enddate,'') ,
d.plucode,d.pluname,d.barcode,d.spec,d.cargono,d.unit,d.jtaxrate,s.jprice,s.netjprice,f.usercode,f.username,f.rzdate,f.rztime,f.dsccode,d.remark
from t_orderquote_head f,t_orderquote_body d,t_orderquote_org s
where f.billno=d.billno and d.plucode=s.plucode and d.billno=s.billno and f.billno=@psbillno
and not exists(select 1 from t_order_quote where orgcode=s.orgcode and quotetype=f.quotetype and supcode=f.supcode and contrno=f.contrno and plucode=d.plucode)
if @@error <> 0
begin
set @psmsg='<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD>ʧ<EFBFBD><EFBFBD>'
1 year ago
return(-1)
end
end
else if @squotetype='1'
begin
update a set billno=b.billno,jprice=b.jprice,netjprice=b.netjprice,usercode=b.usercode,username=b.username,rzdate=b.rzdate,rztime=b.rztime,dsccode=b.dsccode,remark=b.remark
from t_order_quote a,
(select f.billno,s.orgcode,f.quotetype,f.supcode,f.supname,f.contrno,isnull(f.bgndate,'') bgndate,isnull(f.enddate,'') enddate,
d.plucode,d.pluname,d.barcode,d.spec,d.cargono,d.unit,d.jtaxrate,s.jprice,s.netjprice,f.usercode,f.username,f.rzdate,f.rztime,f.dsccode,d.remark
from t_orderquote_head f,t_orderquote_body d,t_orderquote_org s
where f.billno=d.billno and d.plucode=s.plucode and d.billno=s.billno and f.billno=@psbillno) b
where a.orgcode=b.orgcode and a.quotetype=b.quotetype and a.supcode=b.supcode and a.contrno=b.contrno and a.plucode=b.plucode and a.bgndate=b.bgndate and a.enddate=b.enddate
insert into t_order_quote(billno,orgcode,quotetype,supcode,supname,contrno,bgndate,enddate,plucode,pluname,barcode,spec,cargono,unit,jtaxrate,jprice,netjprice,usercode,username,rzdate,rztime,dsccode,remark)
select f.billno,s.orgcode,f.quotetype,f.supcode,f.supname,f.contrno,isnull(f.bgndate,''),isnull(f.enddate,''),
d.plucode,d.pluname,d.barcode,d.spec,d.cargono,d.unit,d.jtaxrate,s.jprice,s.netjprice,f.usercode,f.username,f.rzdate,f.rztime,f.dsccode,d.remark
from t_orderquote_head f,t_orderquote_body d,t_orderquote_org s
where f.billno=d.billno and d.plucode=s.plucode and d.billno=s.billno and f.billno=@psbillno
and not exists(select 1 from t_order_quote where orgcode=s.orgcode and quotetype=f.quotetype
and supcode=f.supcode and contrno=f.contrno and plucode=d.plucode and bgndate=f.bgndate and enddate=f.enddate)
if @@error<>0
begin
set @psmsg='<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>۸<EFBFBD>ʧ<EFBFBD><EFBFBD>'
1 year ago
return(-1)
end
end
--<EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>Ϊ*<EFBFBD>Ҳ<EFBFBD>Ϊ<EFBFBD>գ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ӧ<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD>Ʒ<EFBFBD>е<EFBFBD><EFBFBD><EFBFBD>ϸ
1 year ago
if (@scontrno <> '*') and (@scontrno <> '')
begin
INSERT INTO t_contr_plu(contrno,serialno,plucode,barcode,pluname,cargono,spec,unit,jtaxrate,jprice,netjprice,remark)
SELECT @scontrno,row_number() over(order by a.plucode) AS serialno,a.plucode,barcode,pluname,cargono,spec,unit,jtaxrate,a.jprice,netjprice,'<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>' AS remark FROM
1 year ago
(SELECT oq.plucode,MIN(oq.JPrice) AS JPrice FROM t_order_quote oq WHERE oq.billno=@psbillno AND oq.contrno=@scontrno AND oq.supcode=@ssupcode
GROUP BY plucode) a, t_plu b WHERE a.PluCode=b.PluCode
and not exists(select 1 from t_contr_plu where contrno=@scontrno and plucode=a.plucode)
end
update t_orderquote_head set rzdate=@scurdate,rztime=@scurtime where billno=@psbillno
set @soptcontent='<EFBFBD><EFBFBD>ͬ<EFBFBD><EFBFBD><EFBFBD>ۣ<EFBFBD>'+@psbillno+'<EFBFBD><EFBFBD><EFBFBD><EFBFBD>'
1 year ago
set @psmsg=''
return(1)
end
go