| /****** Object: StoredProcedure [dbo].[img_CreateImage] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Max Akbar -- Create date: -- Description: Create a Product Image\File record -- ============================================= CREATE PROCEDURE [dbo].[img_CreateImage] -- Add the parameters for the stored procedure here @FeatureID int, @Sequence int, @ProductID nvarchar(255) = null, @VariantID nvarchar(255) = null, @CategoryName nvarchar(255) = null, @CatalogName nvarchar(85), @DisplayName nvarchar(255), @ImageName nvarchar(255), @Height nvarchar(4) = null, @Width nvarchar(4) = null, @language nvarchar(255) = 'en-US' AS DECLARE @ImageID as nvarchar(255) BEGIN -- SET NOCOUNT ON added to prevent extra result sets from SET NOCOUNT ON; BEGIN TRANSACTION -- insert the record into the image table INSERT INTO Images(FeatureID, CreateDate) VALUES (@FeatureID, GetDate()) SELECT @ImageID = @@IDENTITY -- insert a record into the ImageHierarchy INSERT INTO ImageHierarchy (ImageFileID, Sequence, ProductID, VariantID, CategoryName, CatalogName) VALUES (@ImageID, @Sequence, @ProductID, @VariantID, @CategoryName, @CatalogName) -- insert a record into the language table IF @language = 'en-US' BEGIN -- this should be stored procedure INSERT INTO [Images_en-US] (DisplayName, ImageName, Height, Width, ImageFileID) VALUES (@DisplayName, @ImageName, @Height, @Width, @ImageID) END IF(@@Error=0) BEGIN COMMIT TRANSACTION END ELSE BEGIN ROLLBACK TRANSACTION END END GO /****** Object: StoredProcedure [dbo].[img_DeleteCategory] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Max Akbar -- Create date: -- Description: Create a Product Image\File record -- ============================================= CREATE PROCEDURE [dbo].[img_DeleteCategory] -- Add the parameters for the stored procedure here @ImageFileID int, @CategoryName nvarchar(255), @language nvarchar(255) = 'en-US' AS DECLARE @ImageName nvarchar(255) DECLARE @Path nvarchar(255) BEGIN -- SET NOCOUNT ON added to prevent extra result sets from SET NOCOUNT ON; -- check to make sure it's ok to delete the product. SELECT * FROM GetImage WHERE (ImageFileID = @ImageFileID) IF @@ROWCOUNT <> 0 BEGIN RETURN END SELECT @ImageName = ImageName, @Path = Path FROM GetImage WHERE (ImageFileID = @ImageFileID) and (CategoryName = @CategoryName) IF @@ROWCOUNT = 0 BEGIN RETURN END BEGIN TRANSACTION -- delete a record into the ImageHierarchy DELETE FROM ImageHierarchy WHERE (ImageFileID = @ImageFileID) and (CategoryName = @CategoryName) -- delete a record into the language table IF @language = 'en-US' BEGIN -- this should be stored procedure DELETE FROM [Images_en-US] WHERE (ImageFileID = @ImageFileID) END -- delete the record into the image table DELETE FROM Images WHERE (ImageFileID = @ImageFileID) INSERT INTO Images_Deleted (ImageFileID, ImageName, ImagePath) VALUES (@ImageFileID, @ImageName, @Path) IF(@@Error<>0) BEGIN COMMIT TRANSACTION END ELSE BEGIN ROLLBACK TRANSACTION END END GO /****** Object: StoredProcedure [dbo].[img_DeleteProduct] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Max Akbar -- Create date: -- Description: Create a Product Image\File record -- ============================================= CREATE PROCEDURE [dbo].[img_DeleteProduct] -- Add the parameters for the stored procedure here @ImageFileID int, @ProductID nvarchar(255), @language nvarchar(255) = 'en-US' AS DECLARE @ImageName nvarchar(255) DECLARE @Path nvarchar(255) BEGIN -- SET NOCOUNT ON added to prevent extra result sets from -- interfering with SELECT statements. SET NOCOUNT ON; -- check to make sure it's ok to delete the product. SELECT * FROM GetImage WHERE (ImageFileID = @ImageFileID) IF @@ROWCOUNT <> 0 BEGIN RETURN END SELECT @ImageName = ImageName, @Path = Path FROM GetImage WHERE (ImageFileID = @ImageFileID) and (ProductID = @ProductID) IF @@ROWCOUNT = 0 BEGIN RETURN END BEGIN TRANSACTION -- delete a record into the ImageHierarchy DELETE FROM ImageHierarchy WHERE (ImageFileID = @ImageFileID) and (ProductID = @ProductID) -- delete a record into the language table IF @language = 'en-US' BEGIN -- this should be stored procedure DELETE FROM [Images_en-US] WHERE (ImageFileID = @ImageFileID) END -- delete the record into the image table DELETE FROM Images WHERE (ImageFileID = @ImageFileID) INSERT INTO Images_Deleted (ImageFileID, ImageName, ImagePath) VALUES (@ImageFileID, @ImageName, @Path) IF(@@Error=0) BEGIN COMMIT TRANSACTION END ELSE BEGIN ROLLBACK TRANSACTION END END GO /****** Object: StoredProcedure [dbo].[img_DeleteVariant] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Max Akbar -- Create date: -- Description: Create a Product Image\File record -- ============================================= CREATE PROCEDURE [dbo].[img_DeleteVariant] -- Add the parameters for the stored procedure here @ImageFileID int, @ProductID nvarchar(255), @VariantID nvarchar(255), @language nvarchar(255) = 'en-US' AS DECLARE @ImageName nvarchar(255) DECLARE @Path nvarchar(255) BEGIN -- SET NOCOUNT ON added to prevent extra result sets from SET NOCOUNT ON; -- check to make sure it's ok to delete the product. SELECT * FROM GetImage WHERE (ImageFileID = @ImageFileID) IF @@ROWCOUNT <> 0 BEGIN RETURN END SELECT @ImageName = ImageName, @Path = Path FROM GetImage WHERE (ImageFileID = @ImageFileID) and (VariantID = @VariantID) and (ProductID = @ProductID) IF @@ROWCOUNT = 0 BEGIN RETURN END BEGIN TRANSACTION -- delete a record into the ImageHierarchy DELETE FROM ImageHierarchy WHERE (ImageFileID = @ImageFileID) and (VariantID = @VariantID) and (ProductID = @ProductID) -- delete a record into the language table IF @language = 'en-US' BEGIN -- this should be stored procedure DELETE FROM [Images_en-US] WHERE (ImageFileID = @ImageFileID) END -- delete the record into the image table DELETE FROM Images WHERE (ImageFileID = @ImageFileID) INSERT INTO Images_Deleted (ImageFileID, ImageName, ImagePath) VALUES (@ImageFileID, @ImageName, @Path) IF(@@Error<>0) BEGIN COMMIT TRANSACTION END ELSE BEGIN ROLLBACK TRANSACTION END END GO /****** Object: StoredProcedure [dbo].[img_GetImagecategory] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Max Akbar -- Create date: -- Description: Get Image based on CategoryName -- ============================================= CREATE PROCEDURE [dbo].[img_GetImagecategory] -- Add the parameters for the stored procedure here @CategoryName nvarchar(255) = null AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from SET NOCOUNT ON; SELECT Sequence, DisplayName, ImageName, Height, Width, ImageType, Path, ProductID, VariantID, CategoryName FROM GetImage WHERE (CategoryName = @CategoryName) END GO /****** Object: StoredProcedure [dbo].[img_GetImageProduct] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Max Akbar -- Create date: -- Description: Get Image based on ProductID -- ============================================= CREATE PROCEDURE [dbo].[img_GetImageProduct] -- Add the parameters for the stored procedure here @ProductID nvarchar(255) = null AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from SET NOCOUNT ON; SELECT Sequence, DisplayName, ImageName, Height, Width, ImageType, Path, ProductID, VariantID FROM GetImage WHERE (ProductID = @ProductID) END GO /****** Object: StoredProcedure [dbo].[img_GetImageProductVariant] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Max Akbar -- Create date: -- Description: Get Image based on VariantID -- ============================================= CREATE PROCEDURE [dbo].[img_GetImageProductVariant] -- Add the parameters for the stored procedure here @ProductID nvarchar(255) = null, @VariantID nvarchar(255) = null AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from SET NOCOUNT ON; SELECT Sequence, DisplayName, ImageName, Height, Width, ImageType, Path, ProductID, VariantID FROM GetImage WHERE (ProductID = @ProductID) and (VariantID = @VariantID) END GO /****** Object: StoredProcedure [dbo].[img_Resequence] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Max Akbar -- Create date: -- Description: Create a Product Image\File record -- ============================================= CREATE PROCEDURE [dbo].[img_updateImageHierarchytbl] -- Add the parameters for the stored procedure here @ImageFileID int, @Sequence int, @ProductID nvarchar (255), @VariantID nvarchar(255), @CategoryName nvarchar(255), @CatalogName nvarchar(85), @ImageHierarchyID int AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from SET NOCOUNT ON; BEGIN TRANSACTION -- insert a record into the ImageHierarchy UPDATE ImageHierarchy SET ImageFileID = @ImageFileID, Sequence = @Sequence, ProductID = @ProductID, VariantID = @VariantID, CategoryName = @CategoryName, CatalogName = @CatalogName WHERE (ImageHierarchyID = @ImageHierarchyID) IF(@@Error=0) BEGIN COMMIT TRANSACTION END ELSE BEGIN ROLLBACK TRANSACTION END END GO /****** Object: StoredProcedure [dbo].[img_UpdateImagetbl] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Max Akbar -- Create date: -- Description: Create a Product Image\File record -- ============================================= CREATE PROCEDURE [dbo].[img_UpdateImagetbl] -- Add the parameters for the stored procedure here @FeatureID int, @ImageFileID int AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from SET NOCOUNT ON; BEGIN TRANSACTION -- insert the record into the image table UPDATE Images SET FeatureID = @FeatureID WHERE (ImageFileID = @ImageFileID) IF(@@Error=0) BEGIN COMMIT TRANSACTION END ELSE BEGIN ROLLBACK TRANSACTION END END GO /****** Object: StoredProcedure [dbo].[img_UpdateLanguagetbl] ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO -- ============================================= -- Author: Max Akbar -- Create date: -- Description: Create a Product Image\File record -- ============================================= CREATE PROCEDURE [dbo].[img_UpdateLanguagetbl] -- Add the parameters for the stored procedure here @ImageFileID nvarchar(255), @DisplayName nvarchar(255), @ImageName nvarchar(255), @Height int, @Width int, @language nvarchar(255) = 'en-US' AS BEGIN -- SET NOCOUNT ON added to prevent extra result sets from SET NOCOUNT ON; BEGIN TRANSACTION -- insert the record into the image table IF @language = 'en-US' BEGIN -- this should be stored procedure UPDATE [Images_en-US] SET DisplayName = @DisplayName, ImageName = @ImageName, Height = @Height, Width = @Width WHERE (ImageFileID = @ImageFileID) END IF(@@Error=0) BEGIN COMMIT TRANSACTION END ELSE BEGIN ROLLBACK TRANSACTION END END |