﻿USE [FabApprovalSystem]
GO
	/****** Object:  StoredProcedure [dbo].[ECNUpdate]    Script Date: 11/21/2024 11:29:04 AM ******/
SET
	ANSI_NULLS ON
GO
SET
	QUOTED_IDENTIFIER ON
GO
	CREATE PROCEDURE [dbo].[ECNUpdate] -- Add the parameters for the stored procedure here
	@ECNNumber INT,
	@Title VARCHAR(200),
	@IsECN BIT,
	@IsTECN BIT,
	@IsEmergencyTECN BIT,
	@ExpirationDate DATETIME,
	@ExtensionDate DATETIME,
	@CancellationDate DATETIME,
	@AcknowledgementRequired BIT,
	@TrainingRequired BIT,
	@AreaID INT,
	@TechnologyID INT,
	@PCRBRequired BIT,
	@PCRBNumber VARCHAR(50),
	@TestProgramChangeRequired BIT,
	@MetrologyChangeRequired BIT,
	@SPCChangeRequired BIT,
	@NewPartFlowRequired BIT,
	@SPNChangeRequired BIT,
	@ImplementationDetails VARCHAR(5000),
	@ImpactOnEnvironment TINYINT,
	@ImpactOnEnvironmentDescription VARCHAR(1000),
	@ImpactOnCapacity TINYINT,
	@ImpactOnCapacityDescription VARCHAR(1000),
	@IsMA BIT,
	@IsRH BIT,
	@IsAU BIT,
	@IsIndustrial BIT,
	@MaterialConsumptionChangeRequired TINYINT,
	@MaterialConsumptionChangeDescription VARCHAR(1000),
	@ReasonForChange VARCHAR(5000),
	@DescriptionOfChange VARCHAR(5000),
	@NotAFlowChange BIT,
	@AttachECN_TECNToLots BIT,
	@SPNFlowChangeAtSingleStep BIT,
	@SPNFlowChangeAtMultipleSteps BIT,
	@CategoryID int = NULL,
	@FIChangeRequired BIT = 0,
	@NumberOfLotsAffected varchar(10) = NULL,
	@RecipeChange BIT = NULL,
	@IsDocEC BIT = 0 AS BEGIN
	/*
	 2019-02-15 add NumberOfLotsAffected and RecipeChange
	 2019-01-14 add FIChangeRequired
	 2020-13-05 added the IsDocEC column
	 */
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
SET
	NOCOUNT ON;

-- Insert statements for procedure here
UPDATE
	ECN
SET
	Title = @Title,
	IsECN = @IsECN,
	IsTECN = @IsTECN,
	IsEmergencyTECN = @IsEmergencyTECN,
	ExpirationDate = @ExpirationDate,
	ExtensionDate = @ExtensionDate,
	CancellationDate = @CancellationDate,
	AcknowledgementRequired = @AcknowledgementRequired,
	TrainingRequired = @TrainingRequired,
	AreaID = @AreaID,
	TechnologyID = @TechnologyID,
	PCRBRequired = @PCRBRequired,
	PCRBNumber = @PCRBNumber,
	TestProgramChangeRequired = @TestProgramChangeRequired,
	MetrologyChangeRequired = @MetrologyChangeRequired,
	SPCChangeRequired = @SPCChangeRequired,
	NewPartFlowRequired = @NewPartFlowRequired,
	SPNChangeRequired = @SPNChangeRequired,
	ImplementationDetails = @ImplementationDetails,
	ImpactOnEnvironment = @ImpactOnEnvironment,
	ImpactOnEnvironmentDescription = @ImpactOnEnvironmentDescription,
	ImpactOnCapacity = @ImpactOnCapacity,
	ImpactOnCapacityDescription = @ImpactOnCapacityDescription,
	IsMA = @IsMA,
	IsRH = @IsRH,
	IsAU = @IsAU,
	IsIndustrial = @IsIndustrial,
	MaterialConsumptionChangeRequired = @MaterialConsumptionChangeRequired,
	MaterialConsumptionChangeDescription = @MaterialConsumptionChangeDescription,
	ReasonForChange = @ReasonForChange,
	DescriptionOfChange = @DescriptionOfChange,
	NotAFlowChange = @NotAFlowChange,
	AttachECN_TECNToLots = @AttachECN_TECNToLots,
	SPNFlowChangeAtSingleStep = @SPNFlowChangeAtSingleStep,
	SPNFlowChangeAtMultipleSteps = @SPNFlowChangeAtMultipleSteps,
	LastUpdateTimeStamp = GETDATE(),
	LastUpdateDate = GETDATE(),
	CategoryID = @CategoryID,
	FIChangeRequired = @FIChangeRequired,
	NumberOfLotsAffected = @NumberOfLotsAffected,
	RecipeChange = @RecipeChange,
	IsDocEC = @IsDocEC
WHERE
	ECNNumber = @ECNNumber
END
GO