CREATE PROCEDURE DBO.TransactionsRelationInsert @ATransactionNumber INT, @ACashDesk INT, @AUserIdNumber INT AS
/*
  Created by Kent Johansen December 2009
  Used to create Transaction relation record - for CashDesk info

  Changes: 

*/
SET NOCOUNT ON

DECLARE @UserTypeNumber TINYINT
SELECT @UserTypeNumber = UserTypeNumber FROM Personel WITH (NOLOCK) WHERE UserIDNumber = @AUserIdNumber

IF (@UserTypeNumber IN (0,1,2)) -- utNotDefined, utOrdinary, utSystem, utAutoDay, utAutoNight, utPicassoOnline, utPierre, utHotel
  AND (NOT EXISTS(SELECT * FROM TransactionsRelation WITH (NOLOCK) WHERE FK_TransactionNumber = @ATransactionNumber))
BEGIN
  INSERT INTO TransactionsRelation VALUES (@ATransactionNumber, @ACashDesk)
END
