ALTER PROCEDURE [dbo].[sp_deletecustcash]
-- Add the parameters for the stored procedure here
(@cid int,
@cashid int
)AS
BEGIN
SET NOCOUNT ON;
declare @mulcashid table(mulCASHid int)
insert into @mulcashid select Cash_ID from Cash_Details where Cust_ID= @cid
if exists(select mulCASHid from @mulcashid where mulCASHid <> @cashid)
begin
delete from Cash_Details where Cash_ID=@cashid
delete from SUB_DETAILS where Cash_ID=@cashid and Cust_ID=@cid
end
else
begin
delete from Customer_Master where Cust_ID=@cid
delete from Cash_Details where Cash_ID=@cashid
delete from SUB_DETAILS where Cash_ID=@cashid and Cust_ID=@cid
end
END
ALTER PROCEDURE [dbo].[sp_GetAmountDetail]
-- Add the parameters for the stored procedure here
(
@uderid int
)
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @tdcode3 varchar(100)
set @tdcode3 = (SELECT case when CONVERT(varchar(20), (SUM(AeCAmount)-SUM(AeDAmount)))>=0 then '$'+ convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount)))+'.00' else
'($'+REPLACE( convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount))),'-','')+'.00)'
end from AmountEnter where Aetraderid=1 and TdCode=3 group by Aetraderid
)
declare @tdcode2 varchar(100)
set @tdcode2=( SELECT case when CONVERT(varchar(20), (SUM(AeCAmount)-SUM(AeDAmount)))>=0 then '$'+ convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount)))+'.00' else
'($'+ REPLACE(convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount))),'-','')+'.00)'
end from AmountEnter where Aetraderid=1 and TdCode=2 group by Aetraderid)
declare @tdcode5 varchar(100)
set @tdcode5=(
SELECT case when CONVERT(varchar(20), (SUM(AeCAmount)-SUM(AeDAmount)))>=0 then '$'+ convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount)))+'.00' else
'($'+ REPLACE( convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount))),'-','')+'.00)'
end from AmountEnter where Aetraderid=1 and TdCode=5 group by Aetraderid
)
declare @maintd decimal(18,2);
if((select PATINDEX('%$%','($100.00)'))=2)
set @maintd=(select REPLACE( REPLACE('($100.00)' ,'($','-'),')',''))
else if((select PATINDEX('%$%','($100.00)'))=1)
set @maintd=(select REPLACE( REPLACE('$100.00' ,'$','+'),')',''))
else
set @maintd=0.00
print @maintd
create table #temp(
tdcode3 varchar(100),
tdcode2 varchar(100),
tdcode5 varchar(100)
)
insert into #temp values(@tdcode3,@tdcode2,@tdcode5)
select * from #temp
drop table #temp
END
main data by PATIINDEX
declare @maintd decimal(18,2);
declare @tdcode3forreplace varchar(100)
declare @tdcode31 varchar(100)
set @tdcode31 = (SELECT case when CONVERT(varchar(20), ISNULL((SUM(AeCAmount)-SUM(AeDAmount)),0))>=0 then '$'+ convert(varchar(10),ISNULL((SUM(AeCAmount)-SUM(AeDAmount)),0))+'.00' else
'($'+REPLACE( convert(varchar(10),ISNULL((SUM(AeCAmount)-SUM(AeDAmount)),0)),'-','')+'.00)'
end from AmountEnter where Aetraderid=1 and TdCode=3 group by Aetraderid
)
if((select PATINDEX('%$%',@tdcode31))=2)
set @maintd=(select REPLACE( REPLACE(@tdcode31 ,'($','-'),')',''))
else if((select PATINDEX('%$%',@tdcode31))=1)
set @maintd=(select REPLACE( REPLACE(@tdcode31 ,'$','+'),')',''))
else
set @maintd=0.00
print @maintd
Crazy developer.com
-- Add the parameters for the stored procedure here
(@cid int,
@cashid int
)AS
BEGIN
SET NOCOUNT ON;
declare @mulcashid table(mulCASHid int)
insert into @mulcashid select Cash_ID from Cash_Details where Cust_ID= @cid
if exists(select mulCASHid from @mulcashid where mulCASHid <> @cashid)
begin
delete from Cash_Details where Cash_ID=@cashid
delete from SUB_DETAILS where Cash_ID=@cashid and Cust_ID=@cid
end
else
begin
delete from Customer_Master where Cust_ID=@cid
delete from Cash_Details where Cash_ID=@cashid
delete from SUB_DETAILS where Cash_ID=@cashid and Cust_ID=@cid
end
END
ALTER PROCEDURE [dbo].[sp_GetAmountDetail]
-- Add the parameters for the stored procedure here
(
@uderid int
)
AS
BEGIN
SET NOCOUNT ON;
-- Insert statements for procedure here
declare @tdcode3 varchar(100)
set @tdcode3 = (SELECT case when CONVERT(varchar(20), (SUM(AeCAmount)-SUM(AeDAmount)))>=0 then '$'+ convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount)))+'.00' else
'($'+REPLACE( convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount))),'-','')+'.00)'
end from AmountEnter where Aetraderid=1 and TdCode=3 group by Aetraderid
)
declare @tdcode2 varchar(100)
set @tdcode2=( SELECT case when CONVERT(varchar(20), (SUM(AeCAmount)-SUM(AeDAmount)))>=0 then '$'+ convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount)))+'.00' else
'($'+ REPLACE(convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount))),'-','')+'.00)'
end from AmountEnter where Aetraderid=1 and TdCode=2 group by Aetraderid)
declare @tdcode5 varchar(100)
set @tdcode5=(
SELECT case when CONVERT(varchar(20), (SUM(AeCAmount)-SUM(AeDAmount)))>=0 then '$'+ convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount)))+'.00' else
'($'+ REPLACE( convert(varchar(10),(SUM(AeCAmount)-SUM(AeDAmount))),'-','')+'.00)'
end from AmountEnter where Aetraderid=1 and TdCode=5 group by Aetraderid
)
declare @maintd decimal(18,2);
if((select PATINDEX('%$%','($100.00)'))=2)
set @maintd=(select REPLACE( REPLACE('($100.00)' ,'($','-'),')',''))
else if((select PATINDEX('%$%','($100.00)'))=1)
set @maintd=(select REPLACE( REPLACE('$100.00' ,'$','+'),')',''))
else
set @maintd=0.00
print @maintd
create table #temp(
tdcode3 varchar(100),
tdcode2 varchar(100),
tdcode5 varchar(100)
)
insert into #temp values(@tdcode3,@tdcode2,@tdcode5)
select * from #temp
drop table #temp
END
main data by PATIINDEX
declare @maintd decimal(18,2);
declare @tdcode3forreplace varchar(100)
declare @tdcode31 varchar(100)
set @tdcode31 = (SELECT case when CONVERT(varchar(20), ISNULL((SUM(AeCAmount)-SUM(AeDAmount)),0))>=0 then '$'+ convert(varchar(10),ISNULL((SUM(AeCAmount)-SUM(AeDAmount)),0))+'.00' else
'($'+REPLACE( convert(varchar(10),ISNULL((SUM(AeCAmount)-SUM(AeDAmount)),0)),'-','')+'.00)'
end from AmountEnter where Aetraderid=1 and TdCode=3 group by Aetraderid
)
if((select PATINDEX('%$%',@tdcode31))=2)
set @maintd=(select REPLACE( REPLACE(@tdcode31 ,'($','-'),')',''))
else if((select PATINDEX('%$%',@tdcode31))=1)
set @maintd=(select REPLACE( REPLACE(@tdcode31 ,'$','+'),')',''))
else
set @maintd=0.00
print @maintd
Crazy developer.com
No comments:
Post a Comment