Professional Documents
Culture Documents
******************************************************************************/
--[uspUpdWorkScheduleStatus] 5,36,2,8,13
alter procedure [dbo].[uspUpdWorkScheduleStatus]
(
@DailyWorkCompletionID int,
@SOItemID int,
@StatusID int,
@TaskID int,
@ActionedBy int
)
as
begin
begin try
begin transaction updWorkscheduleStatus
begin
print @TotScheduleQty
print @TotCompletionQty
print @IsComplete
print @IsHitInventory
if(@IsComplete = 1 and (@TotCompletionQty = @TotScheduleQty) and @IsHitInventory =
1)
begin
Update WorkScheduleDetails
set
StatusID = 1667, --Complete
LastModifiedBy = @ActionedBy,
LastModifiedDate = GETDATE()
where WorkScheduleID = @WorkScheduleID and EmployeeID = @EmployeeID and SOItemID
= @SOItemID
end
else if(@IsComplete = 1 and (@TotCompletionQty != @TotScheduleQty) and
@IsHitInventory = 1)
begin
Update WorkScheduleDetails
set
StatusID = 1666, --Assign
LastModifiedBy = @ActionedBy,
LastModifiedDate = GETDATE()
where WorkScheduleID = @WorkScheduleID and EmployeeID = @EmployeeID and SOItemID
= @SOItemID
end
while(@Row<@RowCount)
begin
set @Row = @Row+1;
select @Status = StatusID from tempWorkScheduleDet where WorkScheduleID =
@WorkScheduleID and SRNo = @Row
if(@Status = 1667)--complete
begin
set @CompleteStatus = @CompleteStatus + 1;
end
end
if(@RowCount = @CompleteStatus)
begin
Update WorkSchedule set Status = 1662 ---Complete
where ID = @WorkScheduleID
end
else
begin
Update WorkSchedule set Status = 1661 --InProcess
where ID =@WorkScheduleID
end
end
select
@ErrorNumber = ERROR_NUMBER(),
@ErrorMessage = ERROR_MESSAGE(),
@ErrorSeverity = ERROR_SEVERITY()
raiserror
(
@ErrorMessage, -- Message text.
@ErrorSeverity, -- Severity.
1 -- State.
)
end catch
end