diff --git a/Projects/GimDB/dbo/Stored Procedures/stp_AnLoc_deleteQuery.sql b/Projects/GimDB/dbo/Stored Procedures/stp_AnLoc_deleteQuery.sql new file mode 100644 index 0000000..fab6d1a --- /dev/null +++ b/Projects/GimDB/dbo/Stored Procedures/stp_AnLoc_deleteQuery.sql @@ -0,0 +1,7 @@ +CREATE PROCEDURE [dbo].stp_AnLoc_deleteQuery +( + @Original_CodLocazione nvarchar(50) +) +AS + SET NOCOUNT OFF; +DELETE FROM [dbo].[AnagLocazioni] WHERE (([CodLocazione] = @Original_CodLocazione)) \ No newline at end of file diff --git a/Projects/GimDB/dbo/Stored Procedures/stp_AnLoc_insertQuery.sql b/Projects/GimDB/dbo/Stored Procedures/stp_AnLoc_insertQuery.sql new file mode 100644 index 0000000..7d081a1 --- /dev/null +++ b/Projects/GimDB/dbo/Stored Procedures/stp_AnLoc_insertQuery.sql @@ -0,0 +1,8 @@ +CREATE PROCEDURE [dbo].stp_AnLoc_insertQuery +( + @CodLocazione nvarchar(50), + @Descrizione nvarchar(50) +) +AS + SET NOCOUNT OFF; +INSERT INTO [dbo].[AnagLocazioni] ([CodLocazione], [Descrizione]) VALUES (@CodLocazione, @Descrizione) \ No newline at end of file diff --git a/Projects/GimDB/dbo/Stored Procedures/stp_AnLoc_updateQuery.sql b/Projects/GimDB/dbo/Stored Procedures/stp_AnLoc_updateQuery.sql new file mode 100644 index 0000000..47b5ae4 --- /dev/null +++ b/Projects/GimDB/dbo/Stored Procedures/stp_AnLoc_updateQuery.sql @@ -0,0 +1,9 @@ +CREATE PROCEDURE [dbo].stp_AnLoc_updateQuery +( + @CodLocazione nvarchar(50), + @Descrizione nvarchar(50), + @Original_CodLocazione nvarchar(50) +) +AS + SET NOCOUNT OFF; +UPDATE [dbo].[AnagLocazioni] SET [CodLocazione] = @CodLocazione, [Descrizione] = @Descrizione WHERE (([CodLocazione] = @Original_CodLocazione)) \ No newline at end of file diff --git a/Projects/GimDB/dbo/Stored Procedures/stp_StatoMag_delete.sql b/Projects/GimDB/dbo/Stored Procedures/stp_StatoMag_delete.sql new file mode 100644 index 0000000..30e8113 --- /dev/null +++ b/Projects/GimDB/dbo/Stored Procedures/stp_StatoMag_delete.sql @@ -0,0 +1,26 @@ +/************************************* +* STORED PROCEDURE stp_StatoMag_delete +* +* elimina record magazzino (item + giacenza...) +* +* mod : 19/11/2015 +* aut : S.E. Locatelli +**************************************/ +CREATE PROCEDURE stp_StatoMag_delete +( + @Original_idxItem INT = 0 +) +AS + + +BEGIN tran + + DELETE FROM MagRic + WHERE idxItem = @Original_idxItem + + DELETE FROM AnagItems + WHERE idxItem = @Original_idxItem + +COMMIT tran + +RETURN \ No newline at end of file diff --git a/Projects/GimDB/dbo/Stored Procedures/stp_StatoMag_insert.sql b/Projects/GimDB/dbo/Stored Procedures/stp_StatoMag_insert.sql new file mode 100644 index 0000000..dda539b --- /dev/null +++ b/Projects/GimDB/dbo/Stored Procedures/stp_StatoMag_insert.sql @@ -0,0 +1,41 @@ +/************************************* +* STORED PROCEDURE stp_StatoMag_insert +* +* insert record magazzino (inserisce item + giacenza in mag...) +* +* mod : 19/11/2015 +* aut : S.E. Locatelli +**************************************/ +CREATE PROCEDURE [dbo].[stp_StatoMag_insert] +( + @Descrizione NVARCHAR(250) + , @NomeCostruttore NVARCHAR(250) + , @CodCostruttore NVARCHAR(250) + , @CodSomaschini NVARCHAR(50) + , @QtaMin INT + , @QtaLotto INT + , @Valore DECIMAL(18, 6) + , @Giacenza INT + , @CodLocazione NVARCHAR(50) + , @Note NVARCHAR(MAX) +) +AS + + +BEGIN tran + + DECLARE @idxItem INT = 0 + -- creo nuovo ITEM + INSERT INTO dbo.AnagItems (Descrizione, NomeCostruttore, CodCostruttore, CodSomaschini, QtaMin, QtaLotto, Valore) + VALUES (@Descrizione, @NomeCostruttore, @CodCostruttore, @CodSomaschini, @QtaMin, @QtaLotto, @Valore) + + -- recupero IDX + SELECT @idxItem = SCOPE_IDENTITY() + + -- creo record giacenza + INSERT INTO MagRic (idxItem,CodLocazione,Giacenza,Note,dtLastUpd) + VALUES (@idxItem, @CodLocazione, @Giacenza, @Note, GETDATE()) + +COMMIT tran + +RETURN \ No newline at end of file diff --git a/Projects/GimDB/dbo/Stored Procedures/stp_StatoMag_update.sql b/Projects/GimDB/dbo/Stored Procedures/stp_StatoMag_update.sql new file mode 100644 index 0000000..51e202e --- /dev/null +++ b/Projects/GimDB/dbo/Stored Procedures/stp_StatoMag_update.sql @@ -0,0 +1,50 @@ +/************************************* +* STORED PROCEDURE stp_StatoMag_update +* +* update record magazzino (item + giacenza...) +* +* mod : 19/11/2015 +* aut : S.E. Locatelli +**************************************/ +CREATE PROCEDURE stp_StatoMag_update +( + @Original_idxItem INT = 0 + , @Descrizione NVARCHAR(250) + , @NomeCostruttore NVARCHAR(250) + , @CodCostruttore NVARCHAR(250) + , @CodSomaschini NVARCHAR(50) + , @QtaMin INT + , @QtaLotto INT + , @Valore DECIMAL(18, 6) + , @CodLocazione NVARCHAR(50) + , @Note NVARCHAR(MAX) +) +AS + + +BEGIN tran + + -- update ITEM + UPDATE AnagItems + SET Descrizione = @Descrizione + ,NomeCostruttore = @NomeCostruttore + ,CodCostruttore = @CodCostruttore + ,CodSomaschini = @CodSomaschini + ,QtaMin = @QtaMin + ,QtaLotto = @QtaLotto + ,Valore = @Valore + WHERE idxItem = @Original_idxItem + + INSERT INTO dbo.AnagItems (Descrizione, NomeCostruttore, CodCostruttore, CodSomaschini, QtaMin, QtaLotto, Valore) + VALUES (@Descrizione, @NomeCostruttore, @CodCostruttore, @CodSomaschini, @QtaMin, @QtaLotto, @Valore) + + -- update record giacenza + UPDATE dbo.MagRic + SET CodLocazione = @CodLocazione + ,Note = @Note + ,dtLastUpd = GETDATE() + WHERE idxItem = @Original_idxItem + +COMMIT tran + +RETURN \ No newline at end of file diff --git a/Projects/GimDB/dbo/Tables/AnagItems.sql b/Projects/GimDB/dbo/Tables/AnagItems.sql index 6ab318a..bc5e899 100644 --- a/Projects/GimDB/dbo/Tables/AnagItems.sql +++ b/Projects/GimDB/dbo/Tables/AnagItems.sql @@ -1,13 +1,20 @@ CREATE TABLE [dbo].[AnagItems] ( - [idxItem] INT NOT NULL, - [Descrizione] NVARCHAR (250) CONSTRAINT [DF_AnagItems_Descrizione] DEFAULT ('') NOT NULL, - [NomeCostruttore] NVARCHAR (250) CONSTRAINT [DF_AnagItems_NomeCostruttore] DEFAULT ('') NOT NULL, - [CodCostruttore] NVARCHAR (250) CONSTRAINT [DF_AnagItems_CodCostruttore] DEFAULT ('') NOT NULL, - [CodSomaschini] NVARCHAR (50) CONSTRAINT [DF_AnagItems_CodSomaschini] DEFAULT ('') NOT NULL, - [QtaMin] INT CONSTRAINT [DF_AnagItems_QtaMin] DEFAULT ((0)) NOT NULL, - [QtaLotto] INT CONSTRAINT [DF_AnagItems_QtaLotto] DEFAULT ((0)) NOT NULL, + [idxItem] INT NOT NULL, + [Descrizione] NVARCHAR (250) CONSTRAINT [DF_AnagItems_Descrizione] DEFAULT ('') NOT NULL, + [NomeCostruttore] NVARCHAR (250) CONSTRAINT [DF_AnagItems_NomeCostruttore] DEFAULT ('') NOT NULL, + [CodCostruttore] NVARCHAR (250) CONSTRAINT [DF_AnagItems_CodCostruttore] DEFAULT ('') NOT NULL, + [CodSomaschini] NVARCHAR (50) CONSTRAINT [DF_AnagItems_CodSomaschini] DEFAULT ('') NOT NULL, + [QtaMin] INT CONSTRAINT [DF_AnagItems_QtaMin] DEFAULT ((0)) NOT NULL, + [QtaLotto] INT CONSTRAINT [DF_AnagItems_QtaLotto] DEFAULT ((1)) NOT NULL, + [Valore] DECIMAL (18, 6) CONSTRAINT [DF_AnagItems_Valore] DEFAULT ((0)) NOT NULL, CONSTRAINT [PK_AnagItems] PRIMARY KEY CLUSTERED ([idxItem] ASC) ); + + + +GO +EXECUTE sp_addextendedproperty @name = N'MS_Description', @value = N'valore unitario item', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'TABLE', @level1name = N'AnagItems', @level2type = N'COLUMN', @level2name = N'Valore'; + diff --git a/Projects/GimDB/dbo/Views/v_StatoMag.sql b/Projects/GimDB/dbo/Views/v_StatoMag.sql new file mode 100644 index 0000000..8ec89fd --- /dev/null +++ b/Projects/GimDB/dbo/Views/v_StatoMag.sql @@ -0,0 +1,172 @@ +CREATE VIEW dbo.v_StatoMag +AS +SELECT dbo.AnagItems.idxItem, dbo.AnagItems.Descrizione, dbo.AnagItems.NomeCostruttore, dbo.AnagItems.CodCostruttore, dbo.AnagItems.CodSomaschini, dbo.AnagItems.QtaMin, dbo.AnagItems.QtaLotto, + dbo.AnagItems.Valore, dbo.MagRic.Giacenza + dbo.v_movMagPend.TotQtaMov AS Giacenza, dbo.AnagLocazioni.CodLocazione, dbo.AnagLocazioni.Descrizione AS DescrLocazione, dbo.MagRic.Note, + dbo.MagRic.dtLastUpd +FROM dbo.AnagItems INNER JOIN + dbo.MagRic ON dbo.AnagItems.idxItem = dbo.MagRic.idxItem LEFT OUTER JOIN + dbo.v_movMagPend ON dbo.MagRic.idxItem = dbo.v_movMagPend.idxItem LEFT OUTER JOIN + dbo.AnagLocazioni ON dbo.MagRic.CodLocazione = dbo.AnagLocazioni.CodLocazione +GO +EXECUTE sp_addextendedproperty @name = N'MS_DiagramPaneCount', @value = 2, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_StatoMag'; + + +GO +EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane2', @value = N'y = 1350 + Filter = 1350 + Or = 1350 + Or = 1350 + Or = 1350 + End + End +End +', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_StatoMag'; + + +GO +EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane1', @value = N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00] +Begin DesignProperties = + Begin PaneConfigurations = + Begin PaneConfiguration = 0 + NumPanes = 4 + Configuration = "(H (1[40] 4[20] 2[20] 3) )" + End + Begin PaneConfiguration = 1 + NumPanes = 3 + Configuration = "(H (1 [50] 4 [25] 3))" + End + Begin PaneConfiguration = 2 + NumPanes = 3 + Configuration = "(H (1 [50] 2 [25] 3))" + End + Begin PaneConfiguration = 3 + NumPanes = 3 + Configuration = "(H (4 [30] 2 [40] 3))" + End + Begin PaneConfiguration = 4 + NumPanes = 2 + Configuration = "(H (1 [56] 3))" + End + Begin PaneConfiguration = 5 + NumPanes = 2 + Configuration = "(H (2 [66] 3))" + End + Begin PaneConfiguration = 6 + NumPanes = 2 + Configuration = "(H (4 [50] 3))" + End + Begin PaneConfiguration = 7 + NumPanes = 1 + Configuration = "(V (3))" + End + Begin PaneConfiguration = 8 + NumPanes = 3 + Configuration = "(H (1[56] 4[18] 2) )" + End + Begin PaneConfiguration = 9 + NumPanes = 2 + Configuration = "(H (1 [75] 4))" + End + Begin PaneConfiguration = 10 + NumPanes = 2 + Configuration = "(H (1[66] 2) )" + End + Begin PaneConfiguration = 11 + NumPanes = 2 + Configuration = "(H (4 [60] 2))" + End + Begin PaneConfiguration = 12 + NumPanes = 1 + Configuration = "(H (1) )" + End + Begin PaneConfiguration = 13 + NumPanes = 1 + Configuration = "(V (4))" + End + Begin PaneConfiguration = 14 + NumPanes = 1 + Configuration = "(V (2))" + End + ActivePaneConfig = 0 + End + Begin DiagramPane = + Begin Origin = + Top = 0 + Left = 0 + End + Begin Tables = + Begin Table = "AnagLocazioni" + Begin Extent = + Top = 230 + Left = 662 + Bottom = 326 + Right = 832 + End + DisplayFlags = 280 + TopColumn = 0 + End + Begin Table = "MagRic" + Begin Extent = + Top = 82 + Left = 384 + Bottom = 245 + Right = 554 + End + DisplayFlags = 280 + TopColumn = 0 + End + Begin Table = "v_movMagPend" + Begin Extent = + Top = 43 + Left = 769 + Bottom = 142 + Right = 939 + End + DisplayFlags = 280 + TopColumn = 0 + End + Begin Table = "AnagItems" + Begin Extent = + Top = 35 + Left = 95 + Bottom = 260 + Right = 277 + End + DisplayFlags = 280 + TopColumn = 0 + End + End + End + Begin SQLPane = + End + Begin DataPane = + Begin ParameterDefaults = "" + End + Begin ColumnWidths = 13 + Width = 284 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + End + End + Begin CriteriaPane = + Begin ColumnWidths = 11 + Column = 1440 + Alias = 900 + Table = 1170 + Output = 720 + Append = 1400 + NewValue = 1170 + SortType = 1350 + SortOrder = 1410 + GroupB', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_StatoMag'; + diff --git a/Projects/GimDB/dbo/Views/v_movMagPend.sql b/Projects/GimDB/dbo/Views/v_movMagPend.sql new file mode 100644 index 0000000..96b37ab --- /dev/null +++ b/Projects/GimDB/dbo/Views/v_movMagPend.sql @@ -0,0 +1,131 @@ +CREATE VIEW dbo.v_movMagPend +AS +SELECT idxItem, SUM(Qta) AS TotQtaMov +FROM dbo.MovMagRic +WHERE (dtExport IS NULL) +GROUP BY idxItem +GO +EXECUTE sp_addextendedproperty @name = N'MS_DiagramPaneCount', @value = 1, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_movMagPend'; + + +GO +EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane1', @value = N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00] +Begin DesignProperties = + Begin PaneConfigurations = + Begin PaneConfiguration = 0 + NumPanes = 4 + Configuration = "(H (1[40] 4[20] 2[20] 3) )" + End + Begin PaneConfiguration = 1 + NumPanes = 3 + Configuration = "(H (1 [50] 4 [25] 3))" + End + Begin PaneConfiguration = 2 + NumPanes = 3 + Configuration = "(H (1 [50] 2 [25] 3))" + End + Begin PaneConfiguration = 3 + NumPanes = 3 + Configuration = "(H (4 [30] 2 [40] 3))" + End + Begin PaneConfiguration = 4 + NumPanes = 2 + Configuration = "(H (1 [56] 3))" + End + Begin PaneConfiguration = 5 + NumPanes = 2 + Configuration = "(H (2 [66] 3))" + End + Begin PaneConfiguration = 6 + NumPanes = 2 + Configuration = "(H (4 [50] 3))" + End + Begin PaneConfiguration = 7 + NumPanes = 1 + Configuration = "(V (3))" + End + Begin PaneConfiguration = 8 + NumPanes = 3 + Configuration = "(H (1[56] 4[18] 2) )" + End + Begin PaneConfiguration = 9 + NumPanes = 2 + Configuration = "(H (1 [75] 4))" + End + Begin PaneConfiguration = 10 + NumPanes = 2 + Configuration = "(H (1[66] 2) )" + End + Begin PaneConfiguration = 11 + NumPanes = 2 + Configuration = "(H (4 [60] 2))" + End + Begin PaneConfiguration = 12 + NumPanes = 1 + Configuration = "(H (1) )" + End + Begin PaneConfiguration = 13 + NumPanes = 1 + Configuration = "(V (4))" + End + Begin PaneConfiguration = 14 + NumPanes = 1 + Configuration = "(V (2))" + End + ActivePaneConfig = 0 + End + Begin DiagramPane = + Begin Origin = + Top = 0 + Left = 0 + End + Begin Tables = + Begin Table = "MovMagRic" + Begin Extent = + Top = 6 + Left = 38 + Bottom = 220 + Right = 208 + End + DisplayFlags = 280 + TopColumn = 0 + End + End + End + Begin SQLPane = + End + Begin DataPane = + Begin ParameterDefaults = "" + End + Begin ColumnWidths = 9 + Width = 284 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + Width = 1500 + End + End + Begin CriteriaPane = + Begin ColumnWidths = 12 + Column = 1440 + Alias = 900 + Table = 1170 + Output = 720 + Append = 1400 + NewValue = 1170 + SortType = 1350 + SortOrder = 1410 + GroupBy = 1350 + Filter = 1350 + Or = 1350 + Or = 1350 + Or = 1350 + End + End +End +', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_movMagPend'; +