Friday, December 4, 2009

Parayı/Rakamı yazıya çeviren SQL Function

-- Name: Parayı/Rakamı yazıya çeviren SQL function
-- Description:
--sayısal değeri yazıya çevirir
--virgülden sonra 2 haneyi alır
--Eğer @isMoney = true ise dönüş değerine TL ve kuruş eklenir
create function dbo.fnc_ParayiYaziyaCevir (@num AS numeric(18,2), @isMoney as bit)
returns varchar(255)
AS
BEGIN

--declare @num numeric(18,2)
--declare @isMoney bit
--set @num = 1001111.99
--set @isMoney = 1
DECLARE @Split tinyint
DECLARE @iSplit tinyint
DECLARE @sNum varchar(20)
DECLARE @NumSet varchar(3)
DECLARE @Char char(1)
DECLARE @NumText varchar(255)
DECLARE @SetText varchar(100)
DECLARE @HunText varchar(100)
DECLARE @CharText varchar(50)
DECLARE @Match bit
DECLARE @Point tinyint
DECLARE @Cents varchar(2)
DECLARE @CentText varchar(100)
DECLARE @NumStrings TABLE (Num int, NumStr varchar(20))
INSERT INTO @NumStrings
SELECT 1, 'Bir'
UNION SELECT 2, 'İki'
UNION SELECT 3, 'Üç'
UNION SELECT 4, 'Dört'
UNION SELECT 5, 'Beş'
UNION SELECT 6, 'Altı'
UNION SELECT 7, 'Yedi'
UNION SELECT 8, 'Sekiz'
UNION SELECT 9, 'Dokuz'
UNION SELECT 10, 'On'
UNION SELECT 11, 'Onbir'
UNION SELECT 12, 'Oniki'
UNION SELECT 13, 'Onüç'
UNION SELECT 14, 'Ondört'
UNION SELECT 15, 'Onbeş'
UNION SELECT 16, 'Onaltı'
UNION SELECT 17, 'Onyedi'
UNION SELECT 18, 'Onsekiz'
UNION SELECT 19, 'Ondokuz'
UNION SELECT 20, 'Yirmi'
UNION SELECT 30, 'Otuz'
UNION SELECT 40, 'Kırk'
UNION SELECT 50, 'Elli'
UNION SELECT 60, 'Altmış'
UNION SELECT 70, 'Yetmiş'
UNION SELECT 80, 'Seksen'
UNION SELECT 90, 'Doksan'
SET @sNum = cast(@num as varchar(20))
--convert any cent text first, then the
-- whole number
SET @Point = charindex('.', @sNum)
IF @Point > 0
BEGIN
SET @Cents = substring(@sNum, @Point + 1, 2)
SET @sNum = left(@sNum, @Point-1)
--if isMoney THEN combine the two digits (eg 11 = eleven)
IF @isMoney = 1
BEGIN --look FOR matches WITH the RIGHT İki characters
SET @Match = (select count(*) FROM @NumStrings WHERE Num = @Cents)
IF @Match <> 0
BEGIN
SET @CentText = (select NumStr FROM @NumStrings WHERE Num = @Cents)
END
ELSE
BEGIN
SET @CentText = isnull((select NumStr FROM @NumStrings WHERE Num = left(@Cents, 1) + '0'),'') + (select NumStr from @NumStrings where Num = right(@Cents, 1))
END
END
ELSE --if NOT isMBiry THEN treat each digit seperately (eg 11 = Bir Bir)
BEGIN
SET @CentText = isnull((select NumStr FROM @NumStrings WHERE Num = left(@Cents, 1)),'') + isnull((select NumStr from @NumStrings where Num = right(@Cents, 1)),'')
END
END
IF @CentText IS NULL
SET @CentText = ''
--break the number into blocks of 3 characters
SET @Split = ((len(@sNum)-1) / 3) + 1
SET @iSplit = 0
SET @NumText = ''
WHILE @iSplit < @Split
BEGIN
SET @CharText = ''
SET @HunText = ''
SET @SetText = ''
SET @NumSet = right(left(@sNum, len(@sNum) - @iSplit * 3), 3)
IF len(@Numset) = 3 --Calculate ANY hundreds
BEGIN
SET @Char = left(@NumSet, 1)
if @Char='1'
SET @HunText = 'Yüz'
ELSE
SET @HunText = isnull((select NumStr FROM @NumStrings WHERE Num = @Char) + 'Yüz', '')
SET @SetText = @HunText
END
--look FOR matches WITH the RIGHT two characters
SET @Match = (select count(*) FROM @NumStrings WHERE Num = right(@NumSet, 2))
IF @Match <> 0
BEGIN
SET @CharText = (select NumStr FROM @NumStrings WHERE Num = right(@NumSet, 2))
END
ELSE
BEGIN
SET @CharText = isnull((select NumStr FROM @NumStrings WHERE Num = left(right(@NumSet, 2), 1) + '0'),'') + (select NumStr from @NumStrings where Num = right(@NumSet, 1))
END
--make sure there IS something in @CharText AND @SetText (ie IF @NumSet = x00, x000)
IF @CharText IS NULL SET @CharText = ''
IF @SetText IS NULL set @SetText = ''
--seperate ANY hundreds FROM Ons/units WITH an 'and'
IF @HunText <> '' AND @CharText <> ''
SET @SetText = @SetText + ''
--if there are no hundreds, it's the smallest SET AND there are other sets, ADD an 'and' before
IF @HunText = '' AND @CharText <> '' and @iSplit = 0 and @Split > 1 and @CentText = ''
SET @SetText = '' + @SetText
SET @SetText = @SetText + @CharText
--append the SET suffix text. ADD a ',' AS long as there IS something in the lowest set
if @iSplit = 1 AND @SetText='Bir' BEGIN
SET @SetText=''
SET @SetText = @SetText + CASE @iSplit
WHEN 0 THEN ''
WHEN 1 THEN 'Bin'
WHEN 2 THEN 'Milyon'
WHEN 3 THEN 'Milyar'
WHEN 4 THEN 'Trilyon'
WHEN 5 THEN 'Katrilyon'
END + CASE WHEN len(@NumText) > 0 THEN '' ELSE '' end
END
ELSE
BEGIN
IF @SetText <> ''
SET @SetText = @SetText + CASE @iSplit
WHEN 0 THEN ''
WHEN 1 THEN 'Bin'
WHEN 2 THEN 'Milyon'
WHEN 3 THEN 'Milyar'
WHEN 4 THEN 'Trilyon'
WHEN 5 THEN 'Katrilyon'
END + CASE WHEN len(@NumText) > 0 THEN '' ELSE '' end
END
SET @NumText = @SetText + @NumText
SET @iSplit = @iSplit + 1
END
--add any dollars and cent text
IF @isMoney = 1 AND @NumText <> '' and rtrim(ltrim(@NumText)) <> 'Bir'
SET @NumText = @NumText + ' TL'
IF @isMoney = 1 AND rtrim(ltrim(@NumText)) = 'Bir'
SET @NumText = @NumText + ' TL'
IF @isMoney = 1 AND @CentText <> '' and rtrim(ltrim(@CentText)) <> 'Bir'
SET @CentText = @CentText + ' kuruş'
IF @isMoney = 1 AND rtrim(ltrim(@CentText)) = 'Bir'
SET @CentText = @CentText + ' kuruş'
IF @isMoney = 0 AND @CentText <> ''
SET @CentText = ' Point' + @CentText
IF @isMoney = 1 AND @NumText <> '' and @CentText <> ''
SET @CentText = ' ' + @CentText
--combine dollars and cents
SET @NumText = @NumText + @CentText
--add 'Minus' for negative numbers
IF left(@sNum, 1) = '-'
SET @NumText = 'virgül' + @NumText
RETURN @NumText
END

Wednesday, December 2, 2009

Logo Objects Web Kullanımı için Yapılacak Ayarlar

UnityObjects(Web) calismasi icin yapilmasi gereken bazi parametre ayarlari vardir. Aşağıda bu ayarlar ile ilgili ayrıntıları bulacaksınız;

• Logo Unity 1.20.00.00 ve 4.20.00.00, Logo HR 3.04.03.00 versiyonlarından sonra Normal ve Web olmak üzere iki ayrı DLL dosyası hazırlanmadı. Bu DLL dosyaları birleştirilerek aynı DLL dosyasının hem Normal hemde web uyarlamarında çalışması sağlandı. Hangi amaçla kullanılacağını belirtir ForWebUse özelliği ekendi. Objects’i webte kullanabilmek için CreateObjects işleminden sonra ve Login veya Connect gibi bağlantı kurucu fonksyonlardan önce ForWebUse özelliği mutlaka TRUE olarak set edilmelidir.

Option Explicit
'LogoObjects.DLL dosyasını VB editöründe; Project\Reference bölümünden referans ederek kullanım;
Global UnityApp As New UnityObjects.UnityApplication
'UnityObject Dll'ini "Runtime" referans ederek kullanım;
'Global UnityApp As Variant
'Nesne runtime oluşturuarak çalışılacaksa initialize bölümünde aağıdaki kod işletilmelidir;
'Set UnityApp = CreateObjects("UnityObjects.UnityApplication")
Function ConnectToUnity() As Boolean
ConnectToUnity = False
If IsEmpty(UnityApp) Then
mdiFrmMain.statMain.SimpleText = " Unity Objects Objects Can not Create !!!"
Else
UnityApp.ForWebUse = True
If UnityApp.Connect Then
ConnectToUnity = True
mdiFrmMain.statMain.SimpleText = "Connected ..."
Else
mdiFrmMain.statMain.SimpleText = " Error code : " & str(UnityApp.GetLastError) & " " & UnityApp.GetLastErrorString
End If
End If
End Function
Not : HrObjects.DLL dosyasının Web kulanımı için sadece create satırı değimekte diğer kısımlar aynı kamaktadır.
'Set HrApp = CreateObjects("HRObjects.HRApplication")

• Eğer DLL dosyasını yukarıdaki gibi WEB olarak kullanırsanız veri tabanıya bağantı kurmak için gerekli olan bilgilerin bulunduğu LogoDB.CFG dosyasının buunduğu konumu (Set ile aynı konumdadır) local Registery atındaki ilgili anahtarlardan değil kullandığınız işletim sistemi klasörü (Windows 2000 için C:\winnt) altında oluşturacağınız INI dosyalardan okuyacaktır.Oluşturacağınız INI file ve içerikleri aşağıdadır.
- Logo Unity ürün ailesi için; LGold.INI dosyası olmalıdır, içeriği aşağıdadır.
[Program]
GoldPath=D:\GOLD\Unity110
[Gold Data Source]
DataPath=D:\GOLD\Unity110

One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes.

In Microsoft Visual Studio 2005, you rebuild a solution and try to view a Microsoft Windows Form in Design view. When you do this, Design view may not show the Windows Form. Additionally, you may receive the following error message and call stack:

PROBLEM:
One or more errors encountered while loading the designer. The errors are listed below. Some errors can be fixed by rebuilding your project, while others may require code changes. TypeLoad failure. Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.

at System.Reflection.Module.GetTypesInternal(StackCrawlMark& stackMark)
at System.Reflection.Assembly.GetTypes()
at Microsoft.VisualStudio.Shell.Design.AssemblyObsoleteEventArgs..ctor(Assembly assembly)
at Microsoft.VisualStudio.Design.VSDynamicTypeService.ReloadAssemblyIfChanged(String codeBase)
at Microsoft.VisualStudio.Design.VSDynamicTypeService.CreateDynamicAssembly(String codeBase)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.get_Assembly()
at Microsoft.VisualStudio.Design.VSTypeResolutionService.AssemblyEntry.Search(String fullName, String typeName, Boolean ignoreTypeCase, Assembly& assembly, String description)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.SearchProjectEntries(AssemblyName assemblyName, String typeName, Boolean ignoreTypeCase, Assembly& assembly)
at Microsoft.VisualStudio.Design.VSTypeResolutionService.GetType(String typeName, Boolean throwOnError, Boolean ignoreCase, ReferenceType refType)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError, Boolean ignoreCase)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.AggregateTypeResolutionService.GetType(String name, Boolean throwOnError)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.GetType(ITypeResolutionService trs, String name, Dictionary`2 names)
at System.ComponentModel.Design.Serialization.CodeDomSerializerBase.FillStatementTable(IDesignerSerializationManager manager, IDictionary table, Dictionary`2 names, CodeStatementCollection statements, String className)
at System.ComponentModel.Design.Serialization.TypeCodeDomSerializer.Deserialize(IDesignerSerializationManager manager, CodeTypeDeclaration declaration)
at System.ComponentModel.Design.Serialization.CodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager manager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.PerformLoad(IDesignerSerializationManager serializationManager)
at Microsoft.VisualStudio.Design.Serialization.CodeDom.VSCodeDomDesignerLoader.DeferredLoadHandler.Microsoft.VisualStudio.TextManager.Interop.IVsTextBufferDataEvents.OnLoadCompleted(Int32 fReload)

RESOLUTION:

For more information about the MSDN Code Gallery, visit the following Microsoft Web site:
http://code.msdn.microsoft.com/KB912019

To apply this hotfix, you must have Visual Studio 2005 installed on the computer.