DECLARE @Id INT;
SELECT @Id = id
FROM sysobjects
WHERE name = 'KalaId';
IF NOT EXISTS
(
    SELECT *
    FROM syscolumns
    WHERE id = @Id
          AND name = 'MadeType'
)
    ALTER TABLE dbo.KalaId ADD MadeType SMALLINT NULL;


SELECT @Id = id
FROM sysobjects
WHERE name = 'tblGuy_Info';
IF NOT EXISTS
(
    SELECT *
    FROM syscolumns
    WHERE id = @Id
          AND name = 'HIXCode'
)
    ALTER TABLE dbo.tblGuy_Info ADD HIXCode VARCHAR(20);


IF EXISTS
(
    SELECT *
    FROM dbo.sysobjects
    WHERE id = OBJECT_ID(N'[dbo].[SupplyChainHIX_GetInvoiceByID]')
          AND OBJECTPROPERTY(id, N'IsProcedure') = 1
)
    DROP PROCEDURE [dbo].[SupplyChainHIX_GetInvoiceByID];


IF EXISTS
(
    SELECT *
    FROM dbo.sysobjects
    WHERE id = OBJECT_ID(N'[dbo].[SupplyChainHIX_InsertUnsuccessfulInvoice]')
          AND OBJECTPROPERTY(id, N'IsProcedure') = 1
)
    DROP PROCEDURE [dbo].[SupplyChainHIX_InsertUnsuccessfulInvoice];

IF EXISTS
(
    SELECT *
    FROM dbo.sysobjects
    WHERE id = OBJECT_ID(N'[dbo].[SupplyChainHIX_Invoice]')
          AND OBJECTPROPERTY(id, N'IsProcedure') = 1
)
    DROP PROCEDURE [dbo].[SupplyChainHIX_Invoice];

IF EXISTS
(
    SELECT *
    FROM dbo.sysobjects
    WHERE id = OBJECT_ID(N'[dbo].[SupplyChainHIX_UnsendInvoice]')
          AND OBJECTPROPERTY(id, N'IsProcedure') = 1
)
    DROP PROCEDURE [dbo].[SupplyChainHIX_UnsendInvoice];


DELETE FROM dbo.GeneralSetting
WHERE Parameter LIKE 'SupplyChainHIX_%';
INSERT INTO dbo.GeneralSetting
VALUES
('SupplyChainHIX_ReceiverId', '14554455'),
('SupplyChainHIX_RKaraWSUrl', 'http://hix.rkara.com:1818/service.asmx'),
('SupplyChainHIX_WSUrl', 'http://hix.behdasht.gov.ir/dispatch');


IF NOT EXISTS(SELECT * FROM dbo.GeneralSetting WHERE Parameter = 'PricingMethod')
INSERT INTO dbo.GeneralSetting(Parameter,Value)VALUES('PricingMethod',  N'1' )

