Title: AddToPunch dawami                                 If you need copy same format use firefox or chrome or safari but iexplorer not work


Preview of Code
USE [actatek_access2]
GO
/****** Object:  Trigger [dbo].[AddToIPunch]    Script Date: Sunday 05 02 2017 06:16:11 م ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
 
-- =============================================
-- Author:        Ahmed EL Araby
-- Create date: 09/05/2012
-- Description:    Add Logs to iPunch Database
-- =============================================
ALTER TRIGGER [dbo].[AddToIPunch] 
   ON  [dbo].[access_event_logs]
   AFTER INSERT
AS 
BEGIN
 
SET NOCOUNT ON;
declare @userid nvarchar(50);
declare @date nvarchar(10);
declare @time nvarchar(10);
declare @terminal nvarchar(50);
declare @inout nvarchar(50);
declare @inoutInt int;
--
select @userid = USERID  from inserted ;
select @terminal = TERMINALSN from inserted ;
select  @date = convert(nvarchar,LOCAL_TIMESTAMP,105) from inserted ;
select  @time = convert(nvarchar,LOCAL_TIMESTAMP,108) from inserted ;
select @inout = EVENTID  from inserted;
 
set @inoutInt = 255;
 
if @inout = `IN`
begin
set @inoutInt = 0;
end
if @inout = `OUT`
begin
set @inoutInt = 1;
end
if @inout = `F1`
begin
set @inoutInt = 11;
end
if @inout = `F2`
begin
set @inoutInt = 12;
end
if @inout = `F3`
begin
set @inoutInt = 13;
end
if @inout = `F4`
begin
set @inoutInt = 14;
end
insert into dawami.dbo.AccessLog (EmployeeID,LogDate,LogTime,TerminalID,InOut) values(@userid,@date,@time,@terminal,@inoutInt);
 
END