Click here to Skip to main content
16,018,496 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
@Code nvarchar(100)='',
@FromDate datetime,
@ToDate datetime,
@FormName varchar(max)
AS
BEGIN
	if(@FormName='Supplier')
	
	SELECT ROW_NUMBER () over(order by sup_id )as SINO,sup_id, sup_code,sup_name,sup_phone,convert(varchar,sup_date,103)AS Date From tbl_SupplierMaster 
	where (sup_date between @FromDate and @ToDate) 	
	AND sup_active='True'
	
	AND Case when  sup_code='' then sup_code  else sup_code = @Code
	
END
Posted
Updated 28-Aug-13 22:36pm
v2

1 solution

You told that you have to filter by either date or supplier id
So use the following in procedure
Pass the Supplier code or two dates(must) from UI.
@Code nvarchar(100)=null,//Using null makes the default value as null for that variable and allows null during passing 
@FromDate datetime=null,
@ToDate datetime=null,
@FormName varchar(max)
AS
BEGIN
	if(@FormName='Supplier')
	Begin
        if(@Code <> null and @Code !='')
	SELECT ROW_NUMBER () over(order by sup_id )as SINO,sup_id, sup_code,sup_name,sup_phone,convert(varchar,sup_date,103)AS Date From tbl_SupplierMaster 
	where (sup_date between @FromDate and @ToDate) 	
	AND sup_active='True' AND sup_code = @Code
	else
	SELECT ROW_NUMBER () over(order by sup_id )as SINO,sup_id, sup_code,sup_name,sup_phone,convert(varchar,sup_date,103)AS Date From tbl_SupplierMaster 
	where (sup_date between @FromDate and @ToDate) 	
	AND sup_active='True'
	
	End
END


Hope it helps
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900