--- gestioen della proprietà di setting magazzino logico x tipo cella
set xact_abort on
go

begin transaction
go

alter table TipoCella add
  SetMag bit constraint DF_TipoCella_SetMag default (1)
go

exec sp_addextendedproperty 'MS_Description', 'determina se deve o meno impostare il magazzino logico (contabile)', 'SCHEMA', 'dbo', 'TABLE', 'TipoCella', 'COLUMN', 'SetMag'
go

update TipoCella set SetMag=1
go

set ANSI_NULLS on
go

/***************************************
* STORED stp_TipoCella_deleteQuery
*
* elimina tipo cella
*
* Steamware, S.E.L.
* mod: 2010.07.16
*
****************************************/
alter PROCEDURE stp_TipoCella_deleteQuery
(
	@Original_IdxTipoCella INT
)

AS

DELETE		FROM TipoCella
WHERE       (IdxTipoCella = @Original_IdxTipoCella)

RETURN
go

commit
go


---setto di default a true il cambio mag logico
update TipoCella
set SetMag = 1
go

-- imposto a false x i magazzini "ovas"
update TipoCella
set SetMag = 0
where CodMag ='OVAS'
go

-- imposto a false x i magazzini "ovas"
update TipoCella
set SetMag = 0
where CodMag ='VMLP'
go


set xact_abort on
go

begin transaction
go

set ANSI_NULLS on
go

/***************************************
* STORED stp_TipoCella_updateQuery
*
* aggiorna tipo cella
*
* Steamware, S.E.L.
* mod: 2010.07.16
*
****************************************/
alter PROCEDURE stp_TipoCella_updateQuery
(
	@Original_IdxTipoCella INT,	
	@CodMag VARCHAR(50),
	@CodCS VARCHAR(2),	
	@Quantita INT,
	@Capienza INT,
	@Max_X FLOAT,
	@Max_Y FLOAT,
	@Max_Z FLOAT,
	@Max_Kg FLOAT,
	@CheckPiena BIT,
	@SetMag BIT
)

AS

UPDATE       TipoCella
SET          CodMag = @CodMag, CodCS = @CodCS, Quantita = @Quantita, Capienza = @Capienza, Max_X = @Max_X, Max_Y = @Max_Y, Max_Z = @Max_Z, 
             Max_Kg = @Max_Kg, CheckPiena = @CheckPiena, SetMag = @SetMag
WHERE        (IdxTipoCella = @Original_IdxTipoCella)

RETURN
go

commit
go






-- registro versione...
INSERT INTO [dbo].[LogUpdateDb] ([Versione],[Data]) VALUES(240, GETDATE())
GO