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.

89 lines
2.7 KiB

1 year ago
if exists(select * from sysobjects where name='p_rz_prepare_ys' and xtype='p')
drop procedure p_rz_prepare_ys
go
create procedure p_rz_prepare_ys
(
@psorgcode varchar(10),
@psbillno varchar(20),
@psparams varchar(200),
@psmsg varchar(2000) out
)
as
begin
declare @scustcode varchar(15)
declare @billprepay numeric(19,2)
declare @prepay numeric(19,2)
select @scustcode=custcode,@billprepay=paytotal from t_whprepay_head where billno=@psbillno
select @prepay=prepay from t_customer where custcode=@scustcode
if @prepay+@billprepay<0
begin
set @psmsg='<EFBFBD>ͻ<EFBFBD>'+@scustcode+'<EFBFBD><EFBFBD><EFBFBD>˿<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'+cast(@billprepay as varchar)+'<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ԥ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>'+cast(@prepay as varchar)
return(-1)
end
set @psmsg=''
return(1)
end
go
if exists(select * from sysobjects where name='p_rz_ys' and xtype='p')
drop procedure p_rz_ys
go
create procedure p_rz_ys
(
@psorgcode varchar(10),
@psbillno varchar(20),
@psparams varchar(200),
@psmsg varchar(2000) out
)
as
begin
declare @sorgcode varchar(10)
declare @scustcode varchar(15)
declare @scurdate varchar(10)
declare @scurtime varchar(8)
declare @pfprepaydate varchar(10)
declare @username varchar(10)
declare @zdrname varchar(10)
declare @custbook_name varchar(20)
declare @billprepay numeric(19,2)
declare @ssql varchar(8000)
declare @sinfo varchar(8000)
declare @irtn int
select @scurdate=convert(varchar(10),getdate(),120),@scurtime=convert(varchar(8),getdate(),108)
select @scustcode=custcode,@billprepay=paytotal,@pfprepaydate=bizdate,@username=username,@zdrname=zdrname,@sorgcode=orgcode from t_whprepay_head where billno=@psbillno
set @custbook_name='t_whcbk_yyyymm'
set @ssql='update t_customer set prepay=prepay+'+cast(@billprepay as varchar)+' where custcode='''+@scustcode+''''
exec (@ssql)
if @@error <> 0
begin
set @psmsg='<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>Ԥ<EFBFBD>տ<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>'
return(-1)
end
set @ssql='insert into '+@custbook_name+'(bookdate,booktime,bizdate,custcode,billtype,billno,
username,ywname,ctotal,ysjytotal,prepayjytotal,orgcode,tag,accdate)
select '''+@scurdate+''' as bookdate,'''+@scurtime+''' as booktime,'''+@pfprepaydate+''' as bizdate,
custcode,''2'' as billtype,'''+@psbillno+''' as billno,'''+@username+''' as username,
'''+@zdrname+''' as ywname,'+cast(@billprepay as varchar)+' as ctotal,
pftotal-thtotal-fktotal as ysjytotal,prepay as prepayjytotal,'''+@sorgcode+''' as orgcode,''0'' as tag,'''' as accdate
from t_customer where custcode='''+@scustcode+''''
exec (@ssql)
if @@error <> 0
begin
set @psmsg='<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͻ<EFBFBD>̨<EFBFBD><EFBFBD>ʧ<EFBFBD><EFBFBD>'
return(-1)
end
set @psmsg=''
return(1)
end
go