Initial commit

This commit is contained in:
user
2026-07-12 13:56:05 +04:00
commit 04bf3a4b58
850 changed files with 9057 additions and 0 deletions
@@ -0,0 +1,17 @@
USE [Database]
IF OBJECT_ID('[Procedures].[insert_product]', 'P') IS NOT NULL
DROP PROCEDURE [Procedures].[insert_product];
GO
CREATE PROCEDURE [Procedures].[insert_product]
@name AS NVARCHAR(128),
@product_type_id AS INT,
@barcode AS BIGINT,
@inserted_product_id AS INT = NULL OUTPUT
AS
BEGIN TRANSACTION;
INSERT INTO [Tables].[products]([barcode], [name], [product_type_id])
VALUES(@barcode, @name, @product_type_id);
SET @inserted_product_id = SCOPE_IDENTITY();
COMMIT TRANSACTION;
GO
@@ -0,0 +1,14 @@
USE [Database]
IF OBJECT_ID('[Procedures].[insert_product_attribute]', 'P') IS NOT NULL
DROP PROCEDURE [Procedures].[insert_product_attribute];
GO
CREATE PROCEDURE [Procedures].[insert_product_attribute]
@product_id AS INT,
@attribute_id AS INT
AS
BEGIN TRANSACTION;
INSERT INTO [Tables].[product_attributes]([product_id], [attribute_id])
VALUES (@product_id, @attribute_id);
COMMIT TRANSACTION;
GO
@@ -0,0 +1,26 @@
USE [Database]
IF OBJECT_ID('[Procedures].[insert_product_type]', 'P') IS NOT NULL
DROP PROCEDURE [Procedures].[insert_product_type];
GO
CREATE PROCEDURE [Procedures].[insert_product_type]
@parent_id AS INT = NULL,
@name AS NVARCHAR(128),
@inserted_product_type_id AS INT = NULL OUTPUT
AS
BEGIN TRY
INSERT INTO [Tables].[product_types]([parent_id], [name])
VALUES(@parent_id, @name);
SET @inserted_product_type_id = SCOPE_IDENTITY();
END TRY
BEGIN CATCH
DECLARE @message NVARCHAR(128);
SET @message =
'Cannot create [a] subgroup. Cause: the group '
+ '(name: "'+ (SELECT [name] FROM [Tables].[product_types] WHERE [id] = @parent_id) +'"; [id]:'+ LTRIM(STR(@parent_id)) +')'
+ ' is referenced by [a] product object.';
PRINT 'Actual error number: ' + CAST(ERROR_NUMBER() AS NVARCHAR(10));
PRINT 'Actual line number: ' + CAST(ERROR_LINE() AS NVARCHAR(10));
THROW 51000, @message, 1;
END CATCH
GO
@@ -0,0 +1,15 @@
USE [Database]
IF OBJECT_ID('[Procedures].[insert_product_value]', 'P') IS NOT NULL
DROP PROCEDURE [Procedures].[insert_product_value];
GO
CREATE PROCEDURE [Procedures].[insert_product_value]
@product_id AS INT,
@attribute_id AS INT,
@value AS NVARCHAR(128)
AS
BEGIN TRANSACTION;
INSERT INTO [Tables].[product_values]([product_id], [attribute_id], [value])
VALUES (@product_id, @attribute_id, @value);
COMMIT TRANSACTION;
GO
@@ -0,0 +1,20 @@
USE [Database]
IF OBJECT_ID('[Procedures].[insert_product]', 'P') IS NOT NULL
DROP PROCEDURE [Procedures].[insert_product];
GO
CREATE PROCEDURE [Procedures].[insert_product]
@name AS NVARCHAR(128),
@product_type_id AS INT,
@barcode_attribute_id AS INT,
@inserted_product_id AS INT = NULL OUTPUT
AS
BEGIN TRANSACTION;
INSERT INTO [Tables].[products]([barcode], [name], [product_type_id])
VALUES(@name, @product_type_id);
SET @inserted_product_id = SCOPE_IDENTITY();
INSERT INTO [Tables].[product_attributes]([product_id], [attribute_id])
VALUES (@inserted_product_id, @barcode_attribute_id);
COMMIT TRANSACTION;
GO