Aşağıdakilerde fonksiyonlar;
USE [GO3]
GO
/****** Object: UserDefinedFunction [dbo].[fn_DegerFarki_mi] Script Date: 12/14/2018 13:51:10 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[fn_DegerFarki_mi] (@TypeNo as tinyint)
RETURNS tinyint AS
BEGIN
Declare @Sonuc as tinyint
IF (@TypeNo =8 )or(@TypeNo =15)
set @Sonuc = 1
ELSE
set @Sonuc = 0
RETURN @Sonuc
END
USE [GO3]
GO
/****** Object: UserDefinedFunction [dbo].[fn_GetByteParam] Script Date: 12/14/2018 13:51:53 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[fn_GetByteParam](@VarOffset as integer)
RETURNS integer
AS
BEGIN
Declare @value integer
SELECT @value = SUBSTRING(Param_buf, @VarOffset,1)
FROM VERI_TABANI_PARAMETRELERI WITH (NOLOCK)
WHERE Param_id=200 AND Param_item=0
RETURN (@value)
END
USE [GO3]
GO
/****** Object: UserDefinedFunction [dbo].[fn_GetResource] Script Date: 12/14/2018 13:52:17 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[fn_GetResource](@ResType AS char, @ResNo as integer, @LangChar char(1) = '')
RETURNS nvarchar(50)
AS
BEGIN
RETURN MikroDB_V14.dbo.fn_GetResource(@ResType, @ResNo, @LangChar)
END
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[fn_StokHareketNetDeger] ( @HTutar as Float,
@Hisk1 as Float,
@Hisk2 as Float,
@Hisk3 as Float,
@Hisk4 as Float,
@Hisk5 as Float,
@Hisk6 as Float,
@Mas1 as Float,
@Mas2 as Float,
@Mas3 as Float,
@Mas4 as Float,
@OtvTutar as Float,
@OivTutar as Float,
@Sthtip as tinyint,
@Doviztip as tinyint,
@HarKur as Float,
@HarAltKur as Float,
@HarStkKur As Float
)
RETURNS Float AS
BEGIN
Declare @NetTutar As Float
Declare @OTV_Eklenecek_Fl as bit
Declare @OIV_Eklenecek_Fl as bit
If (@Sthtip=0) And (@OtvTutar <> 0)
SET @OTV_Eklenecek_Fl = dbo.fn_GetByteParam(1048)
Else
SET @OTV_Eklenecek_Fl = 0
If (@Sthtip=0) And (@OivTutar <> 0)
SET @OIV_Eklenecek_Fl = dbo.fn_GetByteParam(3906)
Else
SET @OIV_Eklenecek_Fl = 0
SET @NetTutar = @HTutar - @Hisk1 - @Hisk2 - @Hisk3 - @Hisk4 - @Hisk5 - @Hisk6 + @Mas1 + @Mas2 + @Mas3 + @Mas4
IF (@OTV_Eklenecek_Fl = 1)
SET @NetTutar = @NetTutar + @OtvTutar
IF (@OIV_Eklenecek_Fl = 1)
SET @NetTutar = @NetTutar + @OivTutar
if @HarAltKur=0 SET @HarAltKur=1
if @HarStkKur=0 SET @HarStkKur=1
SET @NetTutar = CASE
WHEN @Doviztip=0 THEN @NetTutar * @HarKur
WHEN (@Doviztip=1) AND (@HarAltKur>0) THEN (@NetTutar * @HarKur) / @HarAltKur
WHEN (@Doviztip=2) AND (@HarStkKur>0) THEN (@NetTutar * @HarKur) / @HarStkKur
WHEN (@Doviztip=3) THEN @NetTutar
ELSE 0
END
RETURN @NetTutar
END
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[fn_StokHareketNetBirimFiyat] ( @HTutar as Float,
@Hisk1 as Float,
@Hisk2 as Float,
@Hisk3 as Float,
@Hisk4 as Float,
@Hisk5 as Float,
@Hisk6 as Float,
@Mas1 as Float,
@Mas2 as Float,
@Mas3 as Float,
@Mas4 as Float,
@OtvTutar as Float,
@OivTutar as Float,
@Sthtip as tinyint,
@Doviztip as tinyint,
@HarKur as Float,
@HarAltKur as Float,
@HarStkKur As Float,
@sth_miktar As Float
)
RETURNS Float AS
BEGIN
RETURN Round((dbo.fn_StokHareketNetDeger (@HTutar,@Hisk1,@Hisk2,@Hisk3,@Hisk4,@Hisk5,@Hisk6,@Mas1,@Mas2,@Mas3,@Mas4,@OtvTutar,@OivTutar,@Sthtip,
@Doviztip,@HarKur,@HarAltKur,@HarStkKur) / @sth_miktar),8)
END
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
ALTER FUNCTION [dbo].[fn_StokIsmi](@SKod as nvarchar(25))
RETURNS nvarchar(50) AS
BEGIN
Declare @Isim as nvarchar(50)
Select @Isim=sto_isim from dbo.STOKLAR WITH (NOLOCK) WHERE sto_kod=@SKod
IF @Isim is NULL SET @Isim = dbo.fn_GetResource('M',430,DEFAULT)
Return @Isim
END