SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Q_ListKala_Sandoogh_Barcode_1](@AID INT ,@BarCode NVARCHAR(255))
AS
BEGIN	
		DECLARE @checkwithKalaID BIT=0
		

		IF(ISNUMERIC(@BarCode)=1)
				IF(CONVERT(DECIMAL(21,0) ,@BarCode)<0)
					SET @checkwithKalaID=1
			
			
		IF(@checkwithKalaID=1)
		BEGIN
		   				SELECT 
	
					ID      AS NameKalaID
					  ,BarCode
					  ,NameKala1
					  ,AID
					  ,GOKID
					  ,UnitPrice1
					  ,Currency1
					  ,NameGoKala1
					  ,NameAnbar
					  ,Zarib
					  ,NameVahed1
					  ,NameVahed2
				FROM   dbo.FunInfoKalaAll(0)  AS FunInfoKalaAll_1
				WHERE  (AID=@AID)
					   AND ([ID]=ABS(CONVERt(INT, @BarCode)))
				ORDER BY
					   BarCode

		END
	ELSE
		BEGIN
	
				SELECT 
	
					ID      AS NameKalaID
					  ,BarCode
					  ,NameKala1
					  ,AID
					  ,GOKID
					  ,UnitPrice1
					  ,Currency1
					  ,NameGoKala1
					  ,NameAnbar
					  ,Zarib
					  ,NameVahed1
					  ,NameVahed2
				FROM   dbo.FunInfoKalaAll(0)  AS FunInfoKalaAll_1
				WHERE  (AID=@AID)
					   AND (BarCode=@BarCode)
				ORDER BY
					   BarCode
	END
END
GO
