
------------------------------------------------------------------------------
-- ADVANTAGE 2004.3.9
-- OPTIONS and APPLICATION SINCE ADVANTAGE 2004.3.8
-- 22 JUN 2008
------------------------------------------------------------------------------


--************************************************
--******     NB. NB. NB. RUN ONLY ONCE     *******
--************************************************


-- USE ADV2004
-- GO



----------------------------------------------------------------
-- New System Options
----------------------------------------------------------------


IF NOT EXISTS
    (
        SELECT Sys_AW_Options_ID
        FROM Sys_AW_Options
        WHERE Control_Type = 'TextBox' AND
              Control_Name = 'txtSalesOrdersPath' AND
              Control_Index = 0
    )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'TextBox',
                'txtSalesOrdersPath',
                0,
                ''
            )
    END

----------------------------------------------------------------

    IF NOT EXISTS
        (
            SELECT Sys_AW_Options_ID
            FROM Sys_AW_Options
            WHERE Control_Type = 'OptionButton' AND
                  Control_Name = 'optSOShippingCharge' AND
                  Control_Index = 0
        )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'OptionButton',
                'optSOShippingCharge',
                0,
                'True'
            )
    END

--------------------------------

    IF NOT EXISTS
        (
            SELECT Sys_AW_Options_ID
            FROM Sys_AW_Options
            WHERE Control_Type = 'OptionButton' AND
                  Control_Name = 'optSOShippingCharge' AND
                  Control_Index = 1
        )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'OptionButton',
                'optSOShippingCharge',
                1,
                'False'
            )
    END

--------------------------------

    IF NOT EXISTS
        (
            SELECT Sys_AW_Options_ID
            FROM Sys_AW_Options
            WHERE Control_Type = 'OptionButton' AND
                  Control_Name = 'optSOShippingCharge' AND
                  Control_Index = 2
        )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'OptionButton',
                'optSOShippingCharge',
                2,
                'False'
            )
    END

--------------------------------

IF NOT EXISTS
    (
        SELECT Sys_AW_Options_ID
        FROM Sys_AW_Options
        WHERE Control_Type = 'TextBox' AND
              Control_Name = 'txtSOShippingProductID' AND
              Control_Index = 0
    )
    BEGIN
        INSERT Sys_AW_Options
            (
                Control_Type,
                Control_Name,
                Control_Index,
                Control_Value
            )
        VALUES
            (
                'TextBox',
                'txtSOShippingProductID',
                0,
                ''
            )
    END

----------------------------------------------------------------



----------------------------------------------------------------
-- Retired System Options
----------------------------------------------------------------



----------------------------------------------------------------
-- New Applications
----------------------------------------------------------------

DECLARE @AppID int 


IF NOT EXISTS
    (
        SELECT Sys_AW_Applications_ID
        FROM Sys_AW_Applications
        WHERE Description = 'Sales Orders' AND
              Form_Name = 'frmSalesOrders'
    )
    BEGIN
        INSERT Sys_AW_Applications
            (
                Description,
                Sys_AW_Modules_ID,
                Application_Seq,
                Form_Name,
                Date_Captured,
                User_ID,
                Slu_AW_Active_ID
            )
        VALUES
            (
                'Sales Orders',
                1,
                15,
                'frmSalesOrders',
                getdate(),
                1,
                1
            )

        SELECT @AppID = Scope_Identity()
        
        EXEC sp_AW_Insert_Apps_Per_Role 2, @AppID, 1, 1

    END


------------------------------------



--------------------------------------------------


----------------------------------------------------------------------------
-- Retired Applications
----------------------------------------------------------------------------


------------------------------------

----------------------------------------------------------------------------
-- Lookup Editor
----------------------------------------------------------------------------

IF NOT EXISTS
    (
        SELECT Sys_AW_Lookup_Editor_ID
        FROM Sys_AW_Lookup_Editor
        WHERE TableName = 'Slu_AW_Shipping_Rates' AND
              Caption = 'Shipping Rates'
    )
    BEGIN
        INSERT Sys_AW_Lookup_Editor
            (
                Sys_AW_Lookup_Editor_ID,
                TableName,
                Caption,
                ColumnWidths
            )
        VALUES
            (
                74,
                'Slu_AW_Shipping_Rates',
                'Shipping Rates',
                '0,1500,7275,1500,1500,1005'
            )
    END

------------------------------------

------------------------------------

