/****** Object:  Database iCCard    Script Date: 2006-4-29 12:23:39 ******/
/*由程序定位删除和指定文件位置. 如果是通过查询工具, 则取消以下注释就可 ****/
/**
2006-10-19 13:9:33 Thursday 修改Bug 
将fun_wg_GetQueryGroupUser函数中的
WHERE (@groupName='000' or ([f_GroupName]=@groupName) Or ([f_GroupName] Like (@groupName + '\%')))
改为
WHERE (@groupName='000' or ([f_GroupName]=@groupName) Or ([f_GroupName] Like (RTRIM(@groupName) + '\%')))

*/
/*
IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'iCCard')
	DROP DATABASE [iCCard]
GO

CREATE DATABASE [iCCard]  ON (NAME = N'iCCard_Data', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL\data\iCCard_Data.MDF' , SIZE = 6, FILEGROWTH = 10%) LOG ON (NAME = N'iCCard_Log', FILENAME = N'C:\Program Files\Microsoft SQL Server\MSSQL\data\iCCard_Log.LDF' , SIZE = 4, FILEGROWTH = 10%)
 COLLATE Chinese_PRC_CI_AS
GO
*/

exec sp_dboption N'iCCard', N'autoclose', N'true'
GO

exec sp_dboption N'iCCard', N'bulkcopy', N'false'
GO

exec sp_dboption N'iCCard', N'trunc. log', N'true'
GO

exec sp_dboption N'iCCard', N'torn page detection', N'true'
GO

exec sp_dboption N'iCCard', N'read only', N'false'
GO

exec sp_dboption N'iCCard', N'dbo use', N'false'
GO

exec sp_dboption N'iCCard', N'single', N'false'
GO

exec sp_dboption N'iCCard', N'autoshrink', N'true'
GO

exec sp_dboption N'iCCard', N'ANSI null default', N'false'
GO

exec sp_dboption N'iCCard', N'recursive triggers', N'false'
GO

exec sp_dboption N'iCCard', N'ANSI nulls', N'false'
GO

exec sp_dboption N'iCCard', N'concat null yields null', N'false'
GO

exec sp_dboption N'iCCard', N'cursor close on commit', N'false'
GO

exec sp_dboption N'iCCard', N'default to local cursor', N'false'
GO

exec sp_dboption N'iCCard', N'quoted identifier', N'false'
GO

exec sp_dboption N'iCCard', N'ANSI warnings', N'false'
GO

exec sp_dboption N'iCCard', N'auto create statistics', N'true'
GO

exec sp_dboption N'iCCard', N'auto update statistics', N'true'
GO

/*
set language 'Simplified Chinese'
GO
*/

use [iCCard]
GO


/****** 对象:  用户定义的函数 dbo.fun_wg_GetQueryGroupUser    脚本日期: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fun_wg_GetQueryGroupUser]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fun_wg_GetQueryGroupUser]
GO

/****** 对象:  用户定义的函数 dbo.fun_wg_GetCardRecordByTime    脚本日期: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fun_wg_GetCardRecordByTime]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fun_wg_GetCardRecordByTime]
GO

/****** 对象:  用户定义的函数 dbo.fun_wg_GetCardRecordByTimeRecID    脚本日期: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fun_wg_GetCardRecordByTimeRecID]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fun_wg_GetCardRecordByTimeRecID]
GO

/****** 对象:  用户定义的函数 dbo.fun_CompareTime    脚本日期: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[fun_CompareTime]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[fun_CompareTime]
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetQueryGroupUser    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_wg_GetQueryGroupUser]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_wg_GetQueryGroupUser]
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByTime    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_wg_GetCardRecordByTime]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_wg_GetCardRecordByTime]
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByTimeRecID    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_wg_GetCardRecordByTimeRecID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_wg_GetCardRecordByTimeRecID]
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecord4Attendence    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_wg_GetCardRecord4Attendence]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_wg_GetCardRecord4Attendence]
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByGroupUser    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_wg_GetCardRecordByGroupUser]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_wg_GetCardRecordByGroupUser]
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByGroupUserRecID    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_wg_GetCardRecordByGroupUserRecID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_wg_GetCardRecordByGroupUserRecID]
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordWithGroupUser    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_wg_GetCardRecordWithGroupUser]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_wg_GetCardRecordWithGroupUser]
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordWithGroupUserRecID    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[sp_wg_GetCardRecordWithGroupUserRecID]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[sp_wg_GetCardRecordWithGroupUserRecID]
GO

/****** Object:  View dbo.v_d_Patrol_Data4Statistic    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_Patrol_Data4Statistic]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_Patrol_Data4Statistic]
GO

/****** Object:  View dbo.v_d_Patrol_Data    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_Patrol_Data]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_Patrol_Data]
GO

/****** Object:  View dbo.v_b_Patrol_RouteList    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_b_Patrol_RouteList]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_b_Patrol_RouteList]
GO

/****** Object:  View dbo.v_d_CardRecord    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_CardRecord]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_CardRecord]
GO

/****** Object:  View dbo.v_d_CardRecord4Attendence    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_CardRecord4Attendence]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_CardRecord4Attendence]
GO

/****** Object:  View dbo.v_d_CardRecord4Patrol    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_CardRecord4Patrol]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_CardRecord4Patrol]
GO

/****** Object:  View dbo.v_d_Leave    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_Leave]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_Leave]
GO

/****** Object:  View dbo.v_d_ManualCardRecord4Attendence    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_ManualCardRecord4Attendence]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_ManualCardRecord4Attendence]
GO

/****** Object:  View dbo.v_d_ManualCardRecord4Display    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_ManualCardRecord4Display]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_ManualCardRecord4Display]
GO

/****** Object:  View dbo.v_d_Patrol_Statistic    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_Patrol_Statistic]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_Patrol_Statistic]
GO

/****** Object:  View dbo.v_d_Patrol_TaskList    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_Patrol_TaskList]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_Patrol_TaskList]
GO

/****** Object:  View dbo.v_d_Privilege    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_Privilege]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_Privilege]
GO

/****** Object:  View dbo.v_d_Shift_AttReport    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_Shift_AttReport]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_Shift_AttReport]
GO

/****** Object:  View dbo.v_d_Shift_AttStatistic    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_Shift_AttStatistic]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_Shift_AttStatistic]
GO

/****** Object:  View dbo.v_d_shiftdata    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_shiftdata]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_shiftdata]
GO

/****** Object:  View dbo.v_b_ConsumerIDCard    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_b_ConsumerIDCard]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_b_ConsumerIDCard]
GO

/****** Object:  View dbo.v_b_Patrol_RouteDetail    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_b_Patrol_RouteDetail]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_b_Patrol_RouteDetail]
GO

/****** Object:  View dbo.v_a_Holiday    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_a_Holiday]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_a_Holiday]
GO

/****** Object:  View dbo.v_b_Door    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_b_Door]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_b_Door]
GO

/****** Object:  View dbo.v_b_IDCardLost    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_b_IDCardLost]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_b_IDCardLost]
GO

/****** Object:  View dbo.v_b_IDCard_valid    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_b_IDCard_valid]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_b_IDCard_valid]
GO

/****** Object:  View dbo.v_b_Reader    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_b_Reader]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_b_Reader]
GO

/****** Object:  View dbo.v_b_Reader4Patrol    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_b_Reader4Patrol]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_b_Reader4Patrol]
GO

/****** Object:  View dbo.v_d_CardRecordBuf    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_d_CardRecordBuf]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_d_CardRecordBuf]
GO

/****** Object:  Table [dbo].[t_a_Attendence]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_a_Attendence]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_a_Attendence]
GO


/****** Object:  Table [dbo].[t_a_Holiday]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_a_Holiday]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_a_Holiday]
GO

/****** Object:  Table [dbo].[t_a_HolidayType]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_a_HolidayType]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_a_HolidayType]
GO

/****** Object:  Table [dbo].[t_a_Shift_Attendence]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_a_Shift_Attendence]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_a_Shift_Attendence]
GO

/****** Object:  Table [dbo].[t_a_SystemParam]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_a_SystemParam]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_a_SystemParam]
GO

/****** Object:  Table [dbo].[t_b_Consumer]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_Consumer]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_Consumer]
GO

/****** Object:  Table [dbo].[t_b_ControlSeg]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_ControlSeg]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_ControlSeg]
GO

/****** Object:  Table [dbo].[t_b_Controller]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_Controller]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_Controller]
GO

/****** Object:  Table [dbo].[t_b_ControllerExtensionBoard]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_ControllerExtensionBoard]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_ControllerExtensionBoard]
GO

/****** Object:  Table [dbo].[t_b_ControllerPassword]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_ControllerPassword]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_ControllerPassword]
GO

/****** Object:  Table [dbo].[t_b_Door]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_Door]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_Door]
GO

/****** Object:  Table [dbo].[t_b_GetRecord_TaskList]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_GetRecord_TaskList]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_GetRecord_TaskList]
GO

/****** Object:  Table [dbo].[t_b_Group]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_Group]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_Group]
GO

/****** Object:  Table [dbo].[t_b_IDCard]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_IDCard]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_IDCard]
GO

/****** Object:  Table [dbo].[t_b_Patrol_RouteDetail]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_Patrol_RouteDetail]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_Patrol_RouteDetail]
GO

/****** Object:  Table [dbo].[t_b_Patrol_RouteList]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_Patrol_RouteList]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_Patrol_RouteList]
GO

/****** Object:  Table [dbo].[t_b_Reader]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_Reader]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_Reader]
GO

/****** Object:  Table [dbo].[t_b_ShiftSet]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_ShiftSet]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_ShiftSet]
GO

/****** Object:  Table [dbo].[t_b_TaskList]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_TaskList]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_TaskList]
GO

/****** Object:  Table [dbo].[t_b_UploadPrivilege_TaskList]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_UploadPrivilege_TaskList]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_UploadPrivilege_TaskList]
GO

/****** Object:  Table [dbo].[t_d_AttStatistic]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_AttStatistic]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_AttStatistic]
GO

/****** Object:  Table [dbo].[t_d_AttendenceData]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_AttendenceData]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_AttendenceData]
GO

/****** Object:  Table [dbo].[t_d_CardRecord]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_CardRecord]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_CardRecord]
GO

/****** Object:  Table [dbo].[t_d_CardRecordBuf]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_CardRecordBuf]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_CardRecordBuf]
GO

/****** Object:  Table [dbo].[t_d_Leave]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_Leave]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_Leave]
GO

/****** Object:  Table [dbo].[t_d_ManualCardRecord]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_ManualCardRecord]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_ManualCardRecord]
GO

/****** Object:  Table [dbo].[t_d_Patrol_Data]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_Patrol_Data]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_Patrol_Data]
GO

/****** Object:  Table [dbo].[t_d_Patrol_Statistic]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_Patrol_Statistic]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_Patrol_Statistic]
GO

/****** Object:  Table [dbo].[t_d_Patrol_TaskList]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_Patrol_TaskList]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_Patrol_TaskList]
GO

/****** Object:  Table [dbo].[t_d_Privilege]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_Privilege]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_Privilege]
GO

/****** Object:  Table [dbo].[t_d_ShiftData]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_ShiftData]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_ShiftData]
GO

/****** Object:  Table [dbo].[t_d_Shift_Work_Schedule]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_Shift_Work_Schedule]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_Shift_Work_Schedule]
GO

/****** Object:  Table [dbo].[t_d_doorFirstCardUsers]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_doorFirstCardUsers]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_doorFirstCardUsers]
GO

/****** Object:  Table [dbo].[t_d_doorMoreCardsUsers]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_doorMoreCardsUsers]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_doorMoreCardsUsers]
GO

/****** Object:  Table [dbo].[t_d_mapdoors]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_mapdoors]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_mapdoors]
GO

/****** Object:  Table [dbo].[t_d_maps]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_maps]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_maps]
GO

/****** Object:  Table [dbo].[t_d_shift_AttReport]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_shift_AttReport]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_shift_AttReport]
GO

/****** Object:  Table [dbo].[t_d_shift_AttStatistic]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_d_shift_AttStatistic]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_d_shift_AttStatistic]
GO

/****** Object:  Table [dbo].[t_s_FunctionOption]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_s_FunctionOption]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_s_FunctionOption]
GO

/****** Object:  Table [dbo].[t_s_Operator]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_s_Operator]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_s_Operator]
GO

/****** Object:  Table [dbo].[t_s_OperatorMode]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_s_OperatorMode]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_s_OperatorMode]
GO

/****** Object:  Table [dbo].[t_s_wglog]    Script Date: 2006-4-29 12:23:41 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_s_wglog]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_s_wglog]
GO

/****** Object:  Table [dbo].[t_b_ReaderPassword]    Script Date: 2006-5-11 ******/
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[t_b_ReaderPassword]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [dbo].[t_b_ReaderPassword]
GO

/****** Object:  Table [dbo].[t_a_Attendence]    Script Date: 2006-4-29 12:23:43 ******/
CREATE TABLE [dbo].[t_a_Attendence] (
	[f_No] [int] NOT NULL ,
	[f_Name] [nvarchar] (50)  NULL ,
	[f_EName] [nvarchar] (50)  NULL ,
	[f_Value] [nvarchar] (50)  NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO


/****** Object:  Table [dbo].[t_a_Holiday]    Script Date: 2006-4-29 12:23:43 ******/
CREATE TABLE [dbo].[t_a_Holiday] (
	[f_NO] [int] IDENTITY (1, 1) NOT NULL ,
	[f_Name] [nvarchar] (50)  NULL ,
	[f_EName] [nvarchar] (50)  NULL ,
	[f_Value] [nvarchar] (50)  NULL ,
	[f_Value1] [nvarchar] (50)  NULL ,
	[f_Value2] [nvarchar] (50)  NULL ,
	[f_Value3] [nvarchar] (50)  NULL ,
	[f_Type] [nvarchar] (50)  NULL ,
	[f_Note] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_a_HolidayType]    Script Date: 2006-4-29 12:23:43 ******/
CREATE TABLE [dbo].[t_a_HolidayType] (
	[f_No] [int] IDENTITY (1, 1) NOT NULL ,
	[f_HolidayType] [nvarchar] (50)  NOT NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_a_Shift_Attendence]    Script Date: 2006-4-29 12:23:43 ******/
CREATE TABLE [dbo].[t_a_Shift_Attendence] (
	[f_NO] [int] NOT NULL ,
	[f_EName] [nvarchar] (50)  NULL ,
	[f_Value] [nvarchar] (50)  NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_a_SystemParam]    Script Date: 2006-4-29 12:23:43 ******/
CREATE TABLE [dbo].[t_a_SystemParam] (
	[f_No] [int] NOT NULL ,
	[f_Name] [nvarchar] (50)  NULL ,
	[f_EName] [nvarchar] (50)  NULL ,
	[f_Value] [nvarchar] (50)  NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_Consumer]    Script Date: 2006-4-29 12:23:44 ******/
CREATE TABLE [dbo].[t_b_Consumer] (
	[f_ConsumerID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ConsumerNO] [int] NULL ,
	[f_ConsumerName] [nvarchar] (100)  NULL ,
	[f_ConsumerGrade] [nvarchar] (100)  NULL ,
	[f_GroupID] [int] NULL ,
	[f_AttendEnabled] [int] NULL ,
	[f_DoorEnabled] [int] NULL ,
	[f_BeginYMD] [datetime] NULL ,
	[f_EndYMD] [datetime] NULL ,
	[f_Password] [nvarchar] (100)  NULL ,
	[f_PhotoPath] [nvarchar] (100)  NULL ,
	[f_Note] [ntext]  NULL ,
	[f_PatrolEnabled] [int] NOT NULL ,
	[f_WorkNo] [nvarchar] (100)  NULL ,
	[f_Title] [nvarchar] (100)  NULL ,
	[f_Culture] [nvarchar] (100)  NULL ,
	[f_Hometown] [nvarchar] (100)  NULL ,
	[f_Birthday] [nvarchar] (100)  NULL ,
	[f_Marriage] [nvarchar] (100)  NULL ,
	[f_JoinDate] [nvarchar] (100)  NULL ,
	[f_LeaveDate] [nvarchar] (100)  NULL ,
	[f_CertificateType] [nvarchar] (100)  NULL ,
	[f_CertificateID] [nvarchar] (100)  NULL ,
	[f_SocialInsuranceNo] [nvarchar] (100)  NULL ,
	[f_Addr] [nvarchar] (100)  NULL ,
	[f_Postcode] [nvarchar] (100)  NULL ,
	[f_Sex] [nvarchar] (100)  NULL ,
	[f_Nationality] [nvarchar] (100)  NULL ,
	[f_Religion] [nvarchar] (100)  NULL ,
	[f_EnglishName] [nvarchar] (100)  NULL ,
	[f_Mobile] [nvarchar] (100)  NULL ,
	[f_HomePhone] [nvarchar] (100)  NULL ,
	[f_Telephone] [nvarchar] (100)  NULL ,
	[f_Email] [nvarchar] (100)  NULL ,
	[f_Political] [nvarchar] (100)  NULL ,
	[f_CorporationName] [nvarchar] (100)  NULL ,
	[f_TechGrade] [nvarchar] (100)  NULL ,
	[f_bShift] [int] NOT NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_ControlSeg]    Script Date: 2006-4-29 12:23:44 ******/
CREATE TABLE [dbo].[t_b_ControlSeg] (
	[f_ControlSegID] [int] NOT NULL ,
	[f_ControlSegName] [nvarchar] (50)  NULL ,
	[f_DateControl] [nvarchar] (50)  NULL ,
	[f_Monday] [nvarchar] (50)  NULL ,
	[f_Tuesday] [nvarchar] (50)  NULL ,
	[f_Wednesday] [nvarchar] (50)  NULL ,
	[f_Thursday] [nvarchar] (50)  NULL ,
	[f_Friday] [nvarchar] (50)  NULL ,
	[f_Saturday] [nvarchar] (50)  NULL ,
	[f_Sunday] [nvarchar] (50)  NULL ,
	[f_BeginHMS1] [datetime] NULL ,
	[f_EndHMS1] [datetime] NULL ,
	[f_BeginHMS2] [datetime] NULL ,
	[f_EndHMS2] [datetime] NULL ,
	[f_BeginHMS3] [datetime] NULL ,
	[f_EndHMS3] [datetime] NULL ,
	[f_BeginYMD] [datetime] NULL ,
	[f_EndYMD] [datetime] NULL ,
	[f_ControlSegIDLinked] [int] NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_Controller]    Script Date: 2006-4-29 12:23:44 ******/
CREATE TABLE [dbo].[t_b_Controller] (
	[f_ControllerID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ControllerNO] [nvarchar] (100)  NULL ,
	[f_ControllerSN] [nvarchar] (12)  NULL ,
	[f_ControllerType] [nvarchar] (100)  NULL ,
	[f_ControllerName] [nvarchar] (100)  NULL ,
	[f_Enabled] [int] NOT NULL ,
	[f_ComPort] [nvarchar] (100)  NULL ,
	[f_AntiBack] [int] NOT NULL ,
	[f_InterLock12] [int] NOT NULL ,
	[f_InterLock34] [int] NOT NULL ,
	[f_DoorInvalidOpen] [int] NOT NULL ,
	[f_DoorOpenTooLong] [int] NOT NULL ,
	[f_ForceWarn] [int] NOT NULL ,
	[f_MoreCards] [int] NOT NULL ,
	[f_Note] [ntext]  NULL ,
	[f_IP] [nvarchar] (50)  NULL ,
	[f_PORT] [nvarchar] (50)  NULL ,
	[f_MoreDoorsInterlock] [int] NOT NULL ,
	[f_InvalidCardWarn] [int] NOT NULL ,
	[f_DayNoPassword] [int] NOT NULL ,
	[f_AntiBackOption4Reader] [int] NOT NULL ,
	[f_MoreCards_GoInOut] [int] NOT NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_ControllerExtensionBoard]    Script Date: 2006-4-29 12:23:44 ******/
CREATE TABLE [dbo].[t_b_ControllerExtensionBoard] (
	[f_Id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ControllerID] [int] NULL ,
	[f_ExtensionBoardNo] [int] NULL ,
	[f_Port] [int] NULL ,
	[f_TriggerSource] [int] NULL ,
	[f_TriggerEvents] [int] NULL ,
	[f_Timeout] [numeric](10, 1) NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_ControllerPassword]    Script Date: 2006-4-29 12:23:44 ******/
CREATE TABLE [dbo].[t_b_ControllerPassword] (
	[f_Id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_Password] [int] NULL ,
	[f_BAll] [int] NULL ,
	[f_ControllerID] [int] NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_Door]    Script Date: 2006-4-29 12:23:44 ******/
CREATE TABLE [dbo].[t_b_Door] (
	[f_DoorID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ControllerID] [int] NULL ,
	[f_DoorNO] [nvarchar] (100)  NULL ,
	[f_DoorName] [nvarchar] (100)  NOT NULL ,
	[f_DoorControl] [nvarchar] (100)  NULL ,
	[f_DoorDelay] [int] NULL ,
	[f_DoorAntiback] [int] NULL ,
	[f_DoorLockEach] [int] NULL ,
	[f_DoorWarn1] [int] NULL ,
	[f_DoorWarn2] [int] NULL ,
	[f_DoorWarn3] [int] NULL ,
	[f_DoorWarn4] [int] NULL ,
	[f_DoorWarn2Timeout] [int] NULL ,
	[f_DoorWarn4Timeout] [int] NULL ,
	[f_DoorWarnAutoReset] [int] NULL ,
	[f_DoorEnabled] [int] NULL ,
	[f_MoreCards_Total] [int] NOT NULL ,
	[f_MoreCards_Grp1] [int] NOT NULL ,
	[f_MoreCards_Grp2] [int] NOT NULL ,
	[f_MoreCards_Grp3] [int] NOT NULL ,
	[f_MoreCards_Grp4] [int] NOT NULL ,
	[f_MoreCards_Grp5] [int] NOT NULL ,
	[f_MoreCards_Grp6] [int] NOT NULL ,
	[f_MoreCards_Grp7] [int] NOT NULL ,
	[f_MoreCards_Grp8] [int] NOT NULL ,
	[f_FirstCard_Enabled] [int] NOT NULL ,
	[f_FirstCard_Weekday] [int] NULL ,
	[f_FirstCard_BeginHMS] [nvarchar] (100)  NULL ,
	[f_FirstCard_BeginControl] [int] NULL ,
	[f_FirstCard_EndHMS] [nvarchar] (100)  NULL ,
	[f_FirstCard_EndControl] [int] NULL , 
	[f_MoreCards_Option] [int] NOT NULL
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_GetRecord_TaskList]    Script Date: 2006-4-29 12:23:44 ******/
CREATE TABLE [dbo].[t_b_GetRecord_TaskList] (
	[f_Id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_DoorID] [int] NULL ,
	[f_BAll] [int] NULL ,
	[f_DoorControl] [nvarchar] (100)  NULL ,
	[f_DateControl] [nvarchar] (100)  NULL ,
	[f_Notes] [ntext]  NULL ,
	[f_Monday] [nvarchar] (100)  NULL ,
	[f_Tuesday] [nvarchar] (100)  NULL ,
	[f_Wednesday] [nvarchar] (100)  NULL ,
	[f_Thursday] [nvarchar] (100)  NULL ,
	[f_Friday] [nvarchar] (100)  NULL ,
	[f_Saturday] [nvarchar] (100)  NULL ,
	[f_Sunday] [nvarchar] (100)  NULL ,
	[f_BeginHMS1] [datetime] NULL ,
	[f_CustomOperation] [nvarchar] (136)  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_Group]    Script Date: 2006-4-29 12:23:44 ******/
CREATE TABLE [dbo].[t_b_Group] (
	[f_GroupID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_GroupName] [nvarchar] (100)  NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_IDCard]    Script Date: 2006-4-29 12:23:45 ******/
CREATE TABLE [dbo].[t_b_IDCard] (
	[f_CardID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_CardNO] [int] NULL ,
	[f_CardStatusDesc] [nvarchar] (50)  NOT NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_IssueDate] [datetime] NULL ,
	[f_Deadline] [datetime] NULL ,
	[f_LostDate] [datetime] NULL ,
	[f_DeletedDate] [datetime] NULL ,
	[f_StatusChangeDate] [datetime] NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_Patrol_RouteDetail]    Script Date: 2006-4-29 12:23:45 ******/
CREATE TABLE [dbo].[t_b_Patrol_RouteDetail] (
	[f_RecId] [int] IDENTITY (1, 1) NOT NULL ,
	[f_RouteID] [int] NOT NULL ,
	[f_Sn] [int] NOT NULL ,
	[f_ReaderID] [int] NULL ,
	[f_Interval] [int] NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_Patrol_RouteList]    Script Date: 2006-4-29 12:23:45 ******/
CREATE TABLE [dbo].[t_b_Patrol_RouteList] (
	[f_RouteId] [int] IDENTITY (1, 1) NOT NULL ,
	[f_RouteName] [nvarchar] (50)  NOT NULL ,
	[f_Description] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_Reader]    Script Date: 2006-4-29 12:23:45 ******/
CREATE TABLE [dbo].[t_b_Reader] (
	[f_ReaderID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ControllerID] [int] NULL ,
	[f_ReaderNO] [nvarchar] (50)  NULL ,
	[f_ReaderName] [nvarchar] (50)  NULL ,
	[f_PasswordEnabled] [int] NULL ,
	[f_Attend] [int] NULL ,
	[f_Patrol] [int] NOT NULL ,
	[f_DutyOnOff] [int] NOT NULL ,
	[f_InputCardno_Enabled] [int] NOT NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_ShiftSet]    Script Date: 2006-4-29 12:23:45 ******/
CREATE TABLE [dbo].[t_b_ShiftSet] (
	[f_ShiftID] [int] NOT NULL ,
	[f_ShiftName] [nvarchar] (50)  NULL ,
	[f_ReadTimes] [int] NULL ,
	[f_OnDuty1] [datetime] NULL ,
	[f_OffDuty1] [datetime] NULL ,
	[f_OnDuty2] [datetime] NULL ,
	[f_OffDuty2] [datetime] NULL ,
	[f_OnDuty3] [datetime] NULL ,
	[f_OffDuty3] [datetime] NULL ,
	[f_OnDuty4] [datetime] NULL ,
	[f_OffDuty4] [datetime] NULL ,
	[f_bOvertimeShift] [int] NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_TaskList]    Script Date: 2006-4-29 12:23:45 ******/
CREATE TABLE [dbo].[t_b_TaskList] (
	[f_Id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_DoorID] [int] NULL ,
	[f_BAll] [int] NULL ,
	[f_DoorControl] [nvarchar] (50)  NULL ,
	[f_DateControl] [nvarchar] (50)  NULL ,
	[f_Notes] [ntext]  NULL ,
	[f_Monday] [nvarchar] (50)  NULL ,
	[f_Tuesday] [nvarchar] (50)  NULL ,
	[f_Wednesday] [nvarchar] (50)  NULL ,
	[f_Thursday] [nvarchar] (50)  NULL ,
	[f_Friday] [nvarchar] (50)  NULL ,
	[f_Saturday] [nvarchar] (50)  NULL ,
	[f_Sunday] [nvarchar] (50)  NULL ,
	[f_BeginHMS1] [datetime] NULL ,
	[f_CustomOperation] [nvarchar] (68)  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_UploadPrivilege_TaskList]    Script Date: 2006-4-29 12:23:45 ******/
CREATE TABLE [dbo].[t_b_UploadPrivilege_TaskList] (
	[f_Id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_DoorID] [int] NULL ,
	[f_BAll] [int] NULL ,
	[f_DoorControl] [nvarchar] (50)  NULL ,
	[f_DateControl] [nvarchar] (50)  NULL ,
	[f_Notes] [ntext]  NULL ,
	[f_Monday] [nvarchar] (50)  NULL ,
	[f_Tuesday] [nvarchar] (50)  NULL ,
	[f_Wednesday] [nvarchar] (50)  NULL ,
	[f_Thursday] [nvarchar] (50)  NULL ,
	[f_Friday] [nvarchar] (50)  NULL ,
	[f_Saturday] [nvarchar] (50)  NULL ,
	[f_Sunday] [nvarchar] (50)  NULL ,
	[f_BeginHMS1] [datetime] NULL ,
	[f_CustomOperation] [nvarchar] (68)  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_AttStatistic]    Script Date: 2006-4-29 12:23:45 ******/
CREATE TABLE [dbo].[t_d_AttStatistic] (
	[f_RecID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_AttDateStart] [datetime] NULL ,
	[f_AttDateEnd] [datetime] NULL ,
	[f_DayShouldWork] [int] NOT NULL ,
	[f_DayRealWork] [int] NULL ,
	[f_TotalLate] [int] NOT NULL ,
	[f_TotalLeaveEarly] [int] NOT NULL ,
	[f_TotalOvertime] [numeric](18, 1) NOT NULL ,
	[f_TotalAbsenceDay] [numeric](8, 1) NOT NULL ,
	[f_TotalNotReadCard] [int] NULL ,
	[f_SpecialType1] [nvarchar] (50)  NULL ,
	[f_SpecialType2] [nvarchar] (50)  NULL ,
	[f_SpecialType3] [nvarchar] (50)  NULL ,
	[f_SpecialType4] [nvarchar] (50)  NULL ,
	[f_SpecialType5] [nvarchar] (50)  NULL ,
	[f_SpecialType6] [nvarchar] (50)  NULL ,
	[f_SpecialType7] [nvarchar] (50)  NULL ,
	[f_SpecialType8] [nvarchar] (50)  NULL ,
	[f_SpecialType9] [nvarchar] (50)  NULL ,
	[f_SpecialType10] [nvarchar] (50)  NULL ,
	[f_SpecialType11] [nvarchar] (50)  NULL ,
	[f_SpecialType12] [nvarchar] (50)  NULL ,
	[f_SpecialType13] [nvarchar] (50)  NULL ,
	[f_SpecialType14] [nvarchar] (50)  NULL ,
	[f_SpecialType15] [nvarchar] (50)  NULL ,
	[f_SpecialType16] [nvarchar] (50)  NULL ,
	[f_SpecialType17] [nvarchar] (50)  NULL ,
	[f_SpecialType18] [nvarchar] (50)  NULL ,
	[f_SpecialType19] [nvarchar] (50)  NULL ,
	[f_SpecialType20] [nvarchar] (50)  NULL ,
	[f_SpecialType21] [nvarchar] (50)  NULL ,
	[f_SpecialType22] [nvarchar] (50)  NULL ,
	[f_SpecialType23] [nvarchar] (50)  NULL ,
	[f_SpecialType24] [nvarchar] (50)  NULL ,
	[f_SpecialType25] [nvarchar] (50)  NULL ,
	[f_SpecialType26] [nvarchar] (50)  NULL ,
	[f_SpecialType27] [nvarchar] (50)  NULL ,
	[f_SpecialType28] [nvarchar] (50)  NULL ,
	[f_SpecialType29] [nvarchar] (50)  NULL ,
	[f_SpecialType30] [nvarchar] (50)  NULL ,
	[f_SpecialType31] [nvarchar] (50)  NULL ,
	[f_SpecialType32] [nvarchar] (50)  NULL ,
	[f_LateMinutes] [numeric](10, 0) NOT NULL ,
	[f_LeaveEarlyMinutes] [numeric](10, 0) NOT NULL ,
	[f_ManualReadTimesCount] [int] NOT NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_AttendenceData]    Script Date: 2006-4-29 12:23:45 ******/
CREATE TABLE [dbo].[t_d_AttendenceData] (
	[f_RecID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_AttDate] [datetime] NULL ,
	[f_Onduty1] [datetime] NULL ,
	[f_Onduty1Desc] [nvarchar] (50)  NULL ,
	[f_Offduty1] [datetime] NULL ,
	[f_Offduty1Desc] [nvarchar] (50)  NULL ,
	[f_Onduty2] [datetime] NULL ,
	[f_Onduty2Desc] [nvarchar] (50)  NULL ,
	[f_Offduty2] [datetime] NULL ,
	[f_Offduty2Desc] [nvarchar] (50)  NULL ,
	[f_LateTime] [int] NOT NULL ,
	[f_LeaveEarlyTime] [int] NOT NULL ,
	[f_OvertimeTime] [numeric](18, 1) NOT NULL ,
	[f_AbsenceDay] [numeric](8, 1) NOT NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_CardRecord]    Script Date: 2006-4-29 12:23:46 ******/
CREATE TABLE [dbo].[t_d_CardRecord] (
	[f_CardRecordID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_CardNO] [int] NULL ,
	[f_ReadDate] [datetime] NULL ,
	[f_Character] [smallint] NULL ,
	[f_ControllerSN] [nvarchar] (8)  NULL ,
	[f_ReaderID] [int] NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_Note] [nvarchar] (68)  NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_CardRecordBuf]    Script Date: 2006-4-29 12:23:46 ******/
CREATE TABLE [dbo].[t_d_CardRecordBuf] (
	[f_RecID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_CardNO] [int] NULL ,
	[f_ReadDate] [datetime] NULL ,
	[f_Character] [smallint] NULL ,
	[f_ControllerSN] [nvarchar] (8)  NULL ,
	[f_ReaderID] [int] NULL ,
	[f_Note] [nvarchar] (68)  NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_Leave]    Script Date: 2006-4-29 12:23:46 ******/
CREATE TABLE [dbo].[t_d_Leave] (
	[f_NO] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_Value] [nvarchar] (50)  NULL ,
	[f_Value1] [nvarchar] (50)  NULL ,
	[f_Value2] [nvarchar] (50)  NULL ,
	[f_Value3] [nvarchar] (50)  NULL ,
	[f_HolidayType] [nvarchar] (50)  NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_ManualCardRecord]    Script Date: 2006-4-29 12:23:46 ******/
CREATE TABLE [dbo].[t_d_ManualCardRecord] (
	[f_ManualCardRecordID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_CardNO] [int] NULL ,
	[f_ReadDate] [datetime] NULL ,
	[f_Character] [smallint] NULL ,
	[f_ControllerSN] [nvarchar] (8)  NULL ,
	[f_ReaderID] [int] NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_Note] [nvarchar] (68)  NULL ,
	[f_DutyOnOff] [int] NOT NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_Patrol_Data]    Script Date: 2006-4-29 12:23:46 ******/
CREATE TABLE [dbo].[t_d_Patrol_Data] (
	[f_RecId] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_PatrolDate] [datetime] NULL ,
	[f_TaskID] [int] NULL ,
	[f_ReaderID] [int] NULL ,
	[f_PlanPatrolTime] [datetime] NULL ,
	[f_RealPatrolTime] [datetime] NULL ,
	[f_EventDesc] [nvarchar] (50)  NOT NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_Patrol_Statistic]    Script Date: 2006-4-29 12:23:46 ******/
CREATE TABLE [dbo].[t_d_Patrol_Statistic] (
	[f_RecId] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_PatrolDateStart] [datetime] NULL ,
	[f_PatrolDateEnd] [datetime] NULL ,
	[f_TotalLate] [int] NULL ,
	[f_TotalEarly] [int] NULL ,
	[f_TotalAbsence] [int] NULL ,
	[f_TotalNormal] [int] NULL ,
	[f_TotalRest] [int] NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_Patrol_TaskList]    Script Date: 2006-4-29 12:23:46 ******/
CREATE TABLE [dbo].[t_d_Patrol_TaskList] (
	[f_TaskID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_TaskNO] [nvarchar] (50)  NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_RouteID] [int] NULL ,
	[f_StartDate] [datetime] NULL ,
	[f_StartTime] [datetime] NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_Privilege]    Script Date: 2006-4-29 12:23:46 ******/
CREATE TABLE [dbo].[t_d_Privilege] (
	[f_RecID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_DoorID] [int] NULL ,
	[f_ControlSegID] [int] NULL ,
	[f_ConsumerID] [int] NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_ShiftData]    Script Date: 2006-4-29 12:23:47 ******/
CREATE TABLE [dbo].[t_d_ShiftData] (
	[f_RecID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_DateYM] [nvarchar] (10)  NULL ,
	[f_ShiftID_01] [int] NULL ,
	[f_ShiftID_02] [int] NULL ,
	[f_ShiftID_03] [int] NULL ,
	[f_ShiftID_04] [int] NULL ,
	[f_ShiftID_05] [int] NULL ,
	[f_ShiftID_06] [int] NULL ,
	[f_ShiftID_07] [int] NULL ,
	[f_ShiftID_08] [int] NULL ,
	[f_ShiftID_09] [int] NULL ,
	[f_ShiftID_10] [int] NULL ,
	[f_ShiftID_11] [int] NULL ,
	[f_ShiftID_12] [int] NULL ,
	[f_ShiftID_13] [int] NULL ,
	[f_ShiftID_14] [int] NULL ,
	[f_ShiftID_15] [int] NULL ,
	[f_ShiftID_16] [int] NULL ,
	[f_ShiftID_17] [int] NULL ,
	[f_ShiftID_18] [int] NULL ,
	[f_ShiftID_19] [int] NULL ,
	[f_ShiftID_20] [int] NULL ,
	[f_ShiftID_21] [int] NULL ,
	[f_ShiftID_22] [int] NULL ,
	[f_ShiftID_23] [int] NULL ,
	[f_ShiftID_24] [int] NULL ,
	[f_ShiftID_25] [int] NULL ,
	[f_ShiftID_26] [int] NULL ,
	[f_ShiftID_27] [int] NULL ,
	[f_ShiftID_28] [int] NULL ,
	[f_ShiftID_29] [int] NULL ,
	[f_ShiftID_30] [int] NULL ,
	[f_ShiftID_31] [int] NULL ,
	[f_LogDate] [datetime] NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_Shift_Work_Schedule]    Script Date: 2006-4-29 12:23:47 ******/
CREATE TABLE [dbo].[t_d_Shift_Work_Schedule] (
	[f_RecID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_ShiftDate] [datetime] NULL ,
	[f_ShiftID] [int] NULL ,
	[f_ReadTimes] [int] NULL ,
	[f_PlanTime] [datetime] NULL ,
	[f_TimeSeg] [int] NULL ,
	[f_WorkTime] [datetime] NULL ,
	[f_AttDesc] [nvarchar] (20)  NULL ,
	[f_CardRecordDesc] [nvarchar] (20)  NULL ,
	[f_Duration] [int] NULL ,
	[f_bOvertimeShift] [int] NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_doorFirstCardUsers]    Script Date: 2006-4-29 12:23:47 ******/
CREATE TABLE [dbo].[t_d_doorFirstCardUsers] (
	[f_doorFirstCardUsersId] [int] IDENTITY (1, 1) NOT NULL ,
	[f_DoorID] [int] NOT NULL ,
	[f_ConsumerID] [int] NOT NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_doorMoreCardsUsers]    Script Date: 2006-4-29 12:23:47 ******/
CREATE TABLE [dbo].[t_d_doorMoreCardsUsers] (
	[f_doorMoreCardsUsersId] [int] IDENTITY (1, 1) NOT NULL ,
	[f_DoorID] [int] NOT NULL ,
	[f_MoreCards_GrpID] [int] NOT NULL ,
	[f_ConsumerID] [int] NOT NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_mapdoors]    Script Date: 2006-4-29 12:23:47 ******/
CREATE TABLE [dbo].[t_d_mapdoors] (
	[f_MapDoorId] [int] IDENTITY (1, 1) NOT NULL ,
	[f_DoorID] [int] NOT NULL ,
	[f_MapId] [int] NOT NULL ,
	[f_DoorLocationX] [int] NOT NULL ,
	[f_DoorLocationY] [int] NOT NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_maps]    Script Date: 2006-4-29 12:23:47 ******/
CREATE TABLE [dbo].[t_d_maps] (
	[f_MapId] [int] IDENTITY (1, 1) NOT NULL ,
	[f_MapName] [nvarchar] (255)  NOT NULL ,
	[f_MapPageIndex] [int] NOT NULL ,
	[f_MapFile] [nvarchar] (255)  NOT NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_shift_AttReport]    Script Date: 2006-4-29 12:23:47 ******/
CREATE TABLE [dbo].[t_d_shift_AttReport] (
	[f_RecID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_ShiftDate] [datetime] NULL ,
	[f_ShiftID] [int] NULL ,
	[f_ReadTimes] [int] NULL ,
	[f_OnDuty1] [datetime] NULL ,
	[f_OnDuty1AttDesc] [nvarchar] (50)  NULL ,
	[f_OnDuty1CardRecordDesc] [nvarchar] (50)  NULL ,
	[f_OffDuty1] [datetime] NULL ,
	[f_OffDuty1AttDesc] [nvarchar] (50)  NULL ,
	[f_OffDuty1CardRecordDesc] [nvarchar] (50)  NULL ,
	[f_OnDuty2] [datetime] NULL ,
	[f_OnDuty2AttDesc] [nvarchar] (50)  NULL ,
	[f_OnDuty2CardRecordDesc] [nvarchar] (50)  NULL ,
	[f_OffDuty2] [datetime] NULL ,
	[f_OffDuty2AttDesc] [nvarchar] (50)  NULL ,
	[f_OffDuty2CardRecordDesc] [nvarchar] (50)  NULL ,
	[f_OnDuty3] [datetime] NULL ,
	[f_OnDuty3AttDesc] [nvarchar] (50)  NULL ,
	[f_OnDuty3CardRecordDesc] [nvarchar] (50)  NULL ,
	[f_OffDuty3] [datetime] NULL ,
	[f_OffDuty3AttDesc] [nvarchar] (50)  NULL ,
	[f_OffDuty3CardRecordDesc] [nvarchar] (50)  NULL ,
	[f_OnDuty4] [datetime] NULL ,
	[f_OnDuty4AttDesc] [nvarchar] (50)  NULL ,
	[f_OnDuty4CardRecordDesc] [nvarchar] (50)  NULL ,
	[f_OffDuty4] [datetime] NULL ,
	[f_OffDuty4AttDesc] [nvarchar] (50)  NULL ,
	[f_OffDuty4CardRecordDesc] [nvarchar] (50)  NULL ,
	[f_LateMinutes] [numeric](10, 0) NULL ,
	[f_LeaveEarlyMinutes] [numeric](10, 0) NULL ,
	[f_OvertimeHours] [numeric](10, 1) NULL ,
	[f_AbsenceDays] [numeric](10, 1) NULL ,
	[f_NotReadCardCount] [int] NULL ,
	[f_bOvertimeShift] [int] NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_d_shift_AttStatistic]    Script Date: 2006-4-29 12:23:47 ******/
CREATE TABLE [dbo].[t_d_shift_AttStatistic] (
	[f_RecID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_ConsumerID] [int] NULL ,
	[f_AttDateStart] [datetime] NULL ,
	[f_AttDateEnd] [datetime] NULL ,
	[f_DayShouldWork] [int] NULL ,
	[f_LateMinutes] [numeric](10, 0) NULL ,
	[f_LateCount] [int] NULL ,
	[f_LeaveEarlyMinutes] [numeric](10, 0) NULL ,
	[f_LeaveEarlyCount] [int] NULL ,
	[f_OvertimeHours] [numeric](10, 1) NULL ,
	[f_AbsenceDays] [numeric](10, 1) NULL ,
	[f_NotReadCardCount] [int] NULL ,
	[f_ManualReadTimesCount] [int] NULL ,
	[f_SpecialType1] [nvarchar] (50)  NULL ,
	[f_SpecialType2] [nvarchar] (50)  NULL ,
	[f_SpecialType3] [nvarchar] (50)  NULL ,
	[f_SpecialType4] [nvarchar] (50)  NULL ,
	[f_SpecialType5] [nvarchar] (50)  NULL ,
	[f_SpecialType6] [nvarchar] (50)  NULL ,
	[f_SpecialType7] [nvarchar] (50)  NULL ,
	[f_SpecialType8] [nvarchar] (50)  NULL ,
	[f_SpecialType9] [nvarchar] (50)  NULL ,
	[f_SpecialType10] [nvarchar] (50)  NULL ,
	[f_SpecialType11] [nvarchar] (50)  NULL ,
	[f_SpecialType12] [nvarchar] (50)  NULL ,
	[f_SpecialType13] [nvarchar] (50)  NULL ,
	[f_SpecialType14] [nvarchar] (50)  NULL ,
	[f_SpecialType15] [nvarchar] (50)  NULL ,
	[f_SpecialType16] [nvarchar] (50)  NULL ,
	[f_SpecialType17] [nvarchar] (50)  NULL ,
	[f_SpecialType18] [nvarchar] (50)  NULL ,
	[f_SpecialType19] [nvarchar] (50)  NULL ,
	[f_SpecialType20] [nvarchar] (50)  NULL ,
	[f_SpecialType21] [nvarchar] (50)  NULL ,
	[f_SpecialType22] [nvarchar] (50)  NULL ,
	[f_SpecialType23] [nvarchar] (50)  NULL ,
	[f_SpecialType24] [nvarchar] (50)  NULL ,
	[f_SpecialType25] [nvarchar] (50)  NULL ,
	[f_SpecialType26] [nvarchar] (50)  NULL ,
	[f_SpecialType27] [nvarchar] (50)  NULL ,
	[f_SpecialType28] [nvarchar] (50)  NULL ,
	[f_SpecialType29] [nvarchar] (50)  NULL ,
	[f_SpecialType30] [nvarchar] (50)  NULL ,
	[f_SpecialType31] [nvarchar] (50)  NULL ,
	[f_SpecialType32] [nvarchar] (50)  NULL 
) ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_s_FunctionOption]    Script Date: 2006-4-29 12:23:48 ******/
CREATE TABLE [dbo].[t_s_FunctionOption] (
	[f_No] [int] NOT NULL ,
	[f_Name] [nvarchar] (50)  NULL ,
	[f_Value] [int] NOT NULL ,
	[f_StrValue] [nvarchar] (50)  NULL ,
	[f_Note] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_s_Operator]    Script Date: 2006-4-29 12:23:48 ******/
CREATE TABLE [dbo].[t_s_Operator] (
	[f_OperatorID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_OperatorName] [nvarchar] (50)  NOT NULL ,
	[f_Password] [nvarchar] (50)  NULL ,
	[f_Privilege] [nvarchar] (50)  NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_s_OperatorMode]    Script Date: 2006-4-29 12:23:48 ******/
CREATE TABLE [dbo].[t_s_OperatorMode] (
	[f_RecID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_OperatorID] [int] NULL ,
	[f_FunctionEName] [nvarchar] (50)  NULL ,
	[f_FunctionName] [nvarchar] (50)  NULL ,
	[f_Read] [int] NULL ,
	[f_Write] [int] NULL ,
	[f_FullControl] [int] NULL ,
	[f_Type] [int] NOT NULL ,
	[f_SerialNo] [int] NULL ,
	[f_Note] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_s_wglog]    Script Date: 2006-4-29 12:23:48 ******/
CREATE TABLE [dbo].[t_s_wglog] (
	[f_RecID] [int] IDENTITY (1, 1) NOT NULL ,
	[f_EventType] [nvarchar] (50)  NULL ,
	[f_EventDesc] [ntext]  NULL ,
	[f_UserID] [int] NULL ,
	[f_UserName] [nvarchar] (50)  NULL ,
	[f_LogDateTime] [datetime] NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO

/****** Object:  Table [dbo].[t_b_ReaderPassword]    Script Date: 2006-5-12  ******/
CREATE TABLE [dbo].[t_b_ReaderPassword] (
	[f_Id] [int] IDENTITY (1, 1) NOT NULL ,
	[f_Password] [int] NULL ,
	[f_BAll] [int] NULL ,
	[f_ReaderID] [int] NULL ,
	[f_Notes] [ntext]  NULL 
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[t_b_ReaderPassword] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_ReaderPassword] PRIMARY KEY  CLUSTERED 
	(
		[f_Id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_ReaderPassword] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_ReaderPassword_f_Password] DEFAULT (0) FOR [f_Password],
	CONSTRAINT [DF_t_b_ReaderPassword_f_BAll] DEFAULT (1) FOR [f_BAll],
	CONSTRAINT [DF_t_b_ReaderPassword_f_ReaderID] DEFAULT (0) FOR [f_ReaderID]
GO

ALTER TABLE [dbo].[t_a_Attendence] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_a_Attendence] PRIMARY KEY  CLUSTERED 
	(
		[f_No]
	)  ON [PRIMARY] 
GO


ALTER TABLE [dbo].[t_a_Holiday] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_a_Holiday] PRIMARY KEY  CLUSTERED 
	(
		[f_NO]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_a_HolidayType] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_a_HolidayType] PRIMARY KEY  CLUSTERED 
	(
		[f_No]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_a_SystemParam] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_a_SystemParam] PRIMARY KEY  CLUSTERED 
	(
		[f_No]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_Consumer] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_Consumer] PRIMARY KEY  CLUSTERED 
	(
		[f_ConsumerID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_ControlSeg] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_ControlSeg] PRIMARY KEY  CLUSTERED 
	(
		[f_ControlSegID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_Controller] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_Controller] PRIMARY KEY  CLUSTERED 
	(
		[f_ControllerID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_ControllerExtensionBoard] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_ControllerExtensionBoard] PRIMARY KEY  CLUSTERED 
	(
		[f_Id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_ControllerPassword] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_ControllerPassword] PRIMARY KEY  CLUSTERED 
	(
		[f_Id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_Door] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_Door] PRIMARY KEY  CLUSTERED 
	(
		[f_DoorID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_GetRecord_TaskList] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_GetRecord_TaskList] PRIMARY KEY  CLUSTERED 
	(
		[f_Id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_Group] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_Group] PRIMARY KEY  CLUSTERED 
	(
		[f_GroupID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_IDCard] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_IDCard] PRIMARY KEY  CLUSTERED 
	(
		[f_CardID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_Patrol_RouteDetail] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_Patrol_RouteDetail] PRIMARY KEY  CLUSTERED 
	(
		[f_RouteID],
		[f_Sn]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_Patrol_RouteList] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_Patrol_RouteList] PRIMARY KEY  CLUSTERED 
	(
		[f_RouteId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_Reader] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_Reader] PRIMARY KEY  CLUSTERED 
	(
		[f_ReaderID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_TaskList] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_TaskList] PRIMARY KEY  CLUSTERED 
	(
		[f_Id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_b_UploadPrivilege_TaskList] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_b_UploadPrivilege_TaskList] PRIMARY KEY  CLUSTERED 
	(
		[f_Id]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_AttStatistic] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_AttStatistic] PRIMARY KEY  CLUSTERED 
	(
		[f_RecID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_AttendenceData] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_AttendenceData] PRIMARY KEY  CLUSTERED 
	(
		[f_RecID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_CardRecord] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_CardRecord] PRIMARY KEY  CLUSTERED 
	(
		[f_CardRecordID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_CardRecordBuf] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_CardRecordBuf] PRIMARY KEY  CLUSTERED 
	(
		[f_RecID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_Leave] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_Leave] PRIMARY KEY  CLUSTERED 
	(
		[f_NO]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_ManualCardRecord] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_ManualCardRecord] PRIMARY KEY  CLUSTERED 
	(
		[f_ManualCardRecordID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_Patrol_Data] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_Patrol_Data] PRIMARY KEY  CLUSTERED 
	(
		[f_RecId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_Patrol_Statistic] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_Patrol_Statistic] PRIMARY KEY  CLUSTERED 
	(
		[f_RecId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_Patrol_TaskList] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_Patrol_TaskList] PRIMARY KEY  CLUSTERED 
	(
		[f_TaskID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_Privilege] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_Privilege] PRIMARY KEY  CLUSTERED 
	(
		[f_RecID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_ShiftData] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_ShiftData] PRIMARY KEY  CLUSTERED 
	(
		[f_RecID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_Shift_Work_Schedule] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_Shift_Work_Schedule] PRIMARY KEY  CLUSTERED 
	(
		[f_RecID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_doorFirstCardUsers] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_doorFirstCardUsers] PRIMARY KEY  CLUSTERED 
	(
		[f_doorFirstCardUsersId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_doorMoreCardsUsers] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_doorMoreCardsUsers] PRIMARY KEY  CLUSTERED 
	(
		[f_doorMoreCardsUsersId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_mapdoors] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_mapdoors] PRIMARY KEY  CLUSTERED 
	(
		[f_MapDoorId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_maps] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_maps] PRIMARY KEY  CLUSTERED 
	(
		[f_MapId]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_shift_AttReport] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_shift_AttReport] PRIMARY KEY  CLUSTERED 
	(
		[f_RecID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_d_shift_AttStatistic] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_d_shift_AttStatistic] PRIMARY KEY  CLUSTERED 
	(
		[f_RecID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_s_FunctionOption] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_s_FunctionOption] PRIMARY KEY  CLUSTERED 
	(
		[f_No]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_s_Operator] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_s_Operator] PRIMARY KEY  CLUSTERED 
	(
		[f_OperatorID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_s_OperatorMode] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_s_OperatorMode] PRIMARY KEY  CLUSTERED 
	(
		[f_RecID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_s_wglog] WITH NOCHECK ADD 
	CONSTRAINT [PK_t_s_wglog] PRIMARY KEY  CLUSTERED 
	(
		[f_RecID]
	)  ON [PRIMARY] 
GO

ALTER TABLE [dbo].[t_a_Attendence] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_a_Attendence_f_No] DEFAULT (0) FOR [f_No]
GO


ALTER TABLE [dbo].[t_a_SystemParam] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_a_SystemParam_f_No] DEFAULT (0) FOR [f_No]
GO

ALTER TABLE [dbo].[t_b_Consumer] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_Consumer_f_ConsumerNO] DEFAULT (0) FOR [f_ConsumerNO],
	CONSTRAINT [DF_t_b_Consumer_f_GroupID] DEFAULT (0) FOR [f_GroupID],
	CONSTRAINT [DF_t_b_Consumer_f_AttendEnabled] DEFAULT (1) FOR [f_AttendEnabled],
	CONSTRAINT [DF_t_b_Consumer_f_DoorEnabled] DEFAULT (1) FOR [f_DoorEnabled],
	CONSTRAINT [DF_t_b_Consumer_f_BeginYMD] DEFAULT (convert(datetime,'2004 - 1 - 1')) FOR [f_BeginYMD],
	CONSTRAINT [DF_t_b_Consumer_f_EndYMD] DEFAULT (convert(datetime,'2020-12-31')) FOR [f_EndYMD],
	CONSTRAINT [DF_t_b_Consumer_f_Password] DEFAULT (123456) FOR [f_Password],
	CONSTRAINT [DF_t_b_Consumer_f_PatrolEnabled] DEFAULT (0) FOR [f_PatrolEnabled],
	CONSTRAINT [DF_t_b_Consumer_f_bShift] DEFAULT (0) FOR [f_bShift]
GO

ALTER TABLE [dbo].[t_b_ControlSeg] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_ControlSeg_f_Monday] DEFAULT (1) FOR [f_Monday],
	CONSTRAINT [DF_t_b_ControlSeg_f_Tuesday] DEFAULT (1) FOR [f_Tuesday],
	CONSTRAINT [DF_t_b_ControlSeg_f_Wednesday] DEFAULT (1) FOR [f_Wednesday],
	CONSTRAINT [DF_t_b_ControlSeg_f_Thursday] DEFAULT (1) FOR [f_Thursday],
	CONSTRAINT [DF_t_b_ControlSeg_f_Friday] DEFAULT (1) FOR [f_Friday],
	CONSTRAINT [DF_t_b_ControlSeg_f_Saturday] DEFAULT (1) FOR [f_Saturday],
	CONSTRAINT [DF_t_b_ControlSeg_f_Sunday] DEFAULT (1) FOR [f_Sunday],
	CONSTRAINT [DF_t_b_ControlSeg_f_BeginYMD] DEFAULT (convert(datetime,'2004-1-1')) FOR [f_BeginYMD],
	CONSTRAINT [DF_t_b_ControlSeg_f_EndYMD] DEFAULT (convert(datetime,'2020-12-31')) FOR [f_EndYMD],
	CONSTRAINT [DF_t_b_ControlSeg_f_ControlSegIDLinked] DEFAULT (0) FOR [f_ControlSegIDLinked]
GO

ALTER TABLE [dbo].[t_b_Controller] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_Controller_f_Enabled] DEFAULT (1) FOR [f_Enabled],
	CONSTRAINT [DF_t_b_Controller_f_ComPort] DEFAULT (N'COM1') FOR [f_ComPort],
	CONSTRAINT [DF_t_b_Controller_f_AntiBack] DEFAULT (0) FOR [f_AntiBack],
	CONSTRAINT [DF_t_b_Controller_f_InterLock12] DEFAULT (0) FOR [f_InterLock12],
	CONSTRAINT [DF_t_b_Controller_f_InterLock34] DEFAULT (0) FOR [f_InterLock34],
	CONSTRAINT [DF_t_b_Controller_f_DoorInvalidOpen] DEFAULT (0) FOR [f_DoorInvalidOpen],
	CONSTRAINT [DF_t_b_Controller_f_DoorOpenTooLong] DEFAULT (0) FOR [f_DoorOpenTooLong],
	CONSTRAINT [DF_t_b_Controller_f_ForceWarn] DEFAULT (0) FOR [f_ForceWarn],
	CONSTRAINT [DF_t_b_Controller_f_MoreCards] DEFAULT (0) FOR [f_MoreCards],
	CONSTRAINT [DF_t_b_Controller_f_MoreDoorsInterlock] DEFAULT (0) FOR [f_MoreDoorsInterlock],
	CONSTRAINT [DF_t_b_Controller_f_InvalidCardWarn] DEFAULT (0) FOR [f_InvalidCardWarn],
	CONSTRAINT [DF_t_b_Controller_f_DayNoPassword] DEFAULT (0) FOR [f_DayNoPassword],
	CONSTRAINT [DF_t_b_Controller_f_AntiBackOption4Reader] DEFAULT (0) FOR [f_AntiBackOption4Reader],
	CONSTRAINT [DF_t_b_Controller_f_MoreCards_GoInOut] DEFAULT (85) FOR [f_MoreCards_GoInOut]
GO

ALTER TABLE [dbo].[t_b_ControllerExtensionBoard] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_ControllerExtensionBoard_f_ExtensionBoardNo] DEFAULT (1) FOR [f_ExtensionBoardNo],
	CONSTRAINT [DF_t_b_ControllerExtensionBoard_f_Port] DEFAULT (1) FOR [f_Port],
	CONSTRAINT [DF_t_b_ControllerExtensionBoard_f_TriggerSource] DEFAULT (0) FOR [f_TriggerSource],
	CONSTRAINT [DF_t_b_ControllerExtensionBoard_f_TriggerEvents] DEFAULT (0) FOR [f_TriggerEvents],
	CONSTRAINT [DF_t_b_ControllerExtensionBoard_f_Timeout] DEFAULT (10) FOR [f_Timeout]
GO

ALTER TABLE [dbo].[t_b_ControllerPassword] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_ControllerPassword_f_Password] DEFAULT (0) FOR [f_Password],
	CONSTRAINT [DF_t_b_ControllerPassword_f_BAll] DEFAULT (1) FOR [f_BAll],
	CONSTRAINT [DF_t_b_ControllerPassword_f_ControllerID] DEFAULT (0) FOR [f_ControllerID]
GO

ALTER TABLE [dbo].[t_b_Door] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_Door_f_DoorDelay] DEFAULT (0) FOR [f_DoorDelay],
	CONSTRAINT [DF_t_b_Door_f_DoorAntiback] DEFAULT (0) FOR [f_DoorAntiback],
	CONSTRAINT [DF_t_b_Door_f_DoorLockEach] DEFAULT (0) FOR [f_DoorLockEach],
	CONSTRAINT [DF_t_b_Door_f_DoorWarn1] DEFAULT (0) FOR [f_DoorWarn1],
	CONSTRAINT [DF_t_b_Door_f_DoorWarn2] DEFAULT (0) FOR [f_DoorWarn2],
	CONSTRAINT [DF_t_b_Door_f_DoorWarn3] DEFAULT (0) FOR [f_DoorWarn3],
	CONSTRAINT [DF_t_b_Door_f_DoorWarn4] DEFAULT (0) FOR [f_DoorWarn4],
	CONSTRAINT [DF_t_b_Door_f_DoorWarn2Timeout] DEFAULT (0) FOR [f_DoorWarn2Timeout],
	CONSTRAINT [DF_t_b_Door_f_DoorWarn4Timeout] DEFAULT (0) FOR [f_DoorWarn4Timeout],
	CONSTRAINT [DF_t_b_Door_f_DoorWarnAutoReset] DEFAULT (0) FOR [f_DoorWarnAutoReset],
	CONSTRAINT [DF_t_b_Door_f_DoorEnabled] DEFAULT (0) FOR [f_DoorEnabled],
	CONSTRAINT [DF_t_b_Door_f_MoreCards_Total] DEFAULT (0) FOR [f_MoreCards_Total],
	CONSTRAINT [DF_t_b_Door_f_MoreCards_Grp1] DEFAULT (0) FOR [f_MoreCards_Grp1],
	CONSTRAINT [DF_t_b_Door_f_MoreCards_Grp2] DEFAULT (0) FOR [f_MoreCards_Grp2],
	CONSTRAINT [DF_t_b_Door_f_MoreCards_Grp3] DEFAULT (0) FOR [f_MoreCards_Grp3],
	CONSTRAINT [DF_t_b_Door_f_MoreCards_Grp4] DEFAULT (0) FOR [f_MoreCards_Grp4],
	CONSTRAINT [DF_t_b_Door_f_MoreCards_Grp5] DEFAULT (0) FOR [f_MoreCards_Grp5],
	CONSTRAINT [DF_t_b_Door_f_MoreCards_Grp6] DEFAULT (0) FOR [f_MoreCards_Grp6],
	CONSTRAINT [DF_t_b_Door_f_MoreCards_Grp7] DEFAULT (0) FOR [f_MoreCards_Grp7],
	CONSTRAINT [DF_t_b_Door_f_MoreCards_Grp8] DEFAULT (0) FOR [f_MoreCards_Grp8],
	CONSTRAINT [DF_t_b_Door_f_FirstCard_Enabled] DEFAULT (0) FOR [f_FirstCard_Enabled],
	CONSTRAINT [DF_t_b_Door_f_FirstCard_Weekday] DEFAULT (127) FOR [f_FirstCard_Weekday],
	CONSTRAINT [DF_t_b_Door_f_FirstCard_BeginHMS] DEFAULT (N'00:00:00') FOR [f_FirstCard_BeginHMS],
	CONSTRAINT [DF_t_b_Door_f_FirstCard_BeginControl] DEFAULT (0) FOR [f_FirstCard_BeginControl],
	CONSTRAINT [DF_t_b_Door_f_FirstCard_EndHMS] DEFAULT (N'00:00:00') FOR [f_FirstCard_EndHMS],
	CONSTRAINT [DF_t_b_Door_f_FirstCard_EndControl] DEFAULT (0) FOR [f_FirstCard_EndControl],
	CONSTRAINT [DF_t_b_Door_f_MoreCards_Option] DEFAULT (0) FOR [f_MoreCards_Option]
GO

ALTER TABLE [dbo].[t_b_GetRecord_TaskList] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_GetRecord_TaskList_f_DoorID] DEFAULT (0) FOR [f_DoorID],
	CONSTRAINT [DF_t_b_GetRecord_TaskList_f_BAll] DEFAULT (1) FOR [f_BAll],
	CONSTRAINT [DF_t_b_GetRecord_TaskList_f_Monday] DEFAULT (1) FOR [f_Monday],
	CONSTRAINT [DF_t_b_GetRecord_TaskList_f_Tuesday] DEFAULT (1) FOR [f_Tuesday],
	CONSTRAINT [DF_t_b_GetRecord_TaskList_f_Wednesday] DEFAULT (1) FOR [f_Wednesday],
	CONSTRAINT [DF_t_b_GetRecord_TaskList_f_Thursday] DEFAULT (1) FOR [f_Thursday],
	CONSTRAINT [DF_t_b_GetRecord_TaskList_f_Friday] DEFAULT (1) FOR [f_Friday],
	CONSTRAINT [DF_t_b_GetRecord_TaskList_f_Saturday] DEFAULT (1) FOR [f_Saturday],
	CONSTRAINT [DF_t_b_GetRecord_TaskList_f_Sunday] DEFAULT (1) FOR [f_Sunday]
GO

ALTER TABLE [dbo].[t_b_IDCard] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_IDCard_f_CardNO] DEFAULT (0) FOR [f_CardNO],
	CONSTRAINT [DF_t_b_IDCard_f_CardStatusDesc] DEFAULT (0) FOR [f_CardStatusDesc]
GO

ALTER TABLE [dbo].[t_b_Reader] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_Reader_f_ControllerID] DEFAULT (0) FOR [f_ControllerID],
	CONSTRAINT [DF_t_b_Reader_f_PasswordEnabled] DEFAULT (0) FOR [f_PasswordEnabled],
	CONSTRAINT [DF_t_b_Reader_f_Attend] DEFAULT (0) FOR [f_Attend],
	CONSTRAINT [DF_t_b_Reader_f_Patrol] DEFAULT (0) FOR [f_Patrol],
	CONSTRAINT [DF_t_b_Reader_f_DutyOnOff] DEFAULT (3) FOR [f_DutyOnOff],
	CONSTRAINT [DF_t_b_Reader_f_InputCardno_Enabled] DEFAULT (0) FOR [f_InputCardno_Enabled]
GO

ALTER TABLE [dbo].[t_b_ShiftSet] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_ShiftSet_f_ReadTimes] DEFAULT (2) FOR [f_ReadTimes],
	CONSTRAINT [DF_t_b_ShiftSet_f_bOvertimeShift] DEFAULT (0) FOR [f_bOvertimeShift]
GO

ALTER TABLE [dbo].[t_b_TaskList] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_TaskList_f_DoorID] DEFAULT (0) FOR [f_DoorID],
	CONSTRAINT [DF_t_b_TaskList_f_BAll] DEFAULT (1) FOR [f_BAll],
	CONSTRAINT [DF_t_b_TaskList_f_Monday] DEFAULT (1) FOR [f_Monday],
	CONSTRAINT [DF_t_b_TaskList_f_Tuesday] DEFAULT (1) FOR [f_Tuesday],
	CONSTRAINT [DF_t_b_TaskList_f_Wednesday] DEFAULT (1) FOR [f_Wednesday],
	CONSTRAINT [DF_t_b_TaskList_f_Thursday] DEFAULT (1) FOR [f_Thursday],
	CONSTRAINT [DF_t_b_TaskList_f_Friday] DEFAULT (1) FOR [f_Friday],
	CONSTRAINT [DF_t_b_TaskList_f_Saturday] DEFAULT (1) FOR [f_Saturday],
	CONSTRAINT [DF_t_b_TaskList_f_Sunday] DEFAULT (1) FOR [f_Sunday]
GO

ALTER TABLE [dbo].[t_b_UploadPrivilege_TaskList] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_b_UploadPrivilege_TaskList_f_DoorID] DEFAULT (0) FOR [f_DoorID],
	CONSTRAINT [DF_t_b_UploadPrivilege_TaskList_f_BAll] DEFAULT (1) FOR [f_BAll],
	CONSTRAINT [DF_t_b_UploadPrivilege_TaskList_f_Monday] DEFAULT (1) FOR [f_Monday],
	CONSTRAINT [DF_t_b_UploadPrivilege_TaskList_f_Tuesday] DEFAULT (1) FOR [f_Tuesday],
	CONSTRAINT [DF_t_b_UploadPrivilege_TaskList_f_Wednesday] DEFAULT (1) FOR [f_Wednesday],
	CONSTRAINT [DF_t_b_UploadPrivilege_TaskList_f_Thursday] DEFAULT (1) FOR [f_Thursday],
	CONSTRAINT [DF_t_b_UploadPrivilege_TaskList_f_Friday] DEFAULT (1) FOR [f_Friday],
	CONSTRAINT [DF_t_b_UploadPrivilege_TaskList_f_Saturday] DEFAULT (1) FOR [f_Saturday],
	CONSTRAINT [DF_t_b_UploadPrivilege_TaskList_f_Sunday] DEFAULT (1) FOR [f_Sunday]
GO

ALTER TABLE [dbo].[t_d_AttStatistic] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_AttStatistic_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID],
	CONSTRAINT [DF_t_d_AttStatistic_f_DayShouldWork] DEFAULT (0) FOR [f_DayShouldWork],
	CONSTRAINT [DF_t_d_AttStatistic_f_DayRealWork] DEFAULT (0) FOR [f_DayRealWork],
	CONSTRAINT [DF_t_d_AttStatistic_f_TotalLate] DEFAULT (0) FOR [f_TotalLate],
	CONSTRAINT [DF_t_d_AttStatistic_f_TotalLeaveEarly] DEFAULT (0) FOR [f_TotalLeaveEarly],
	CONSTRAINT [DF_t_d_AttStatistic_f_TotalOvertime] DEFAULT (0) FOR [f_TotalOvertime],
	CONSTRAINT [DF_t_d_AttStatistic_f_TotalAbsenceDay] DEFAULT (0) FOR [f_TotalAbsenceDay],
	CONSTRAINT [DF_t_d_AttStatistic_f_TotalNotReadCard] DEFAULT (0) FOR [f_TotalNotReadCard],
	CONSTRAINT [DF_t_d_AttStatistic_f_LateMinutes] DEFAULT (0) FOR [f_LateMinutes],
	CONSTRAINT [DF_t_d_AttStatistic_f_LeaveEarlyMinutes] DEFAULT (0) FOR [f_LeaveEarlyMinutes],
	CONSTRAINT [DF_t_d_AttStatistic_f_ManualReadTimesCount] DEFAULT (0) FOR [f_ManualReadTimesCount]
GO

ALTER TABLE [dbo].[t_d_AttendenceData] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_AttendenceData_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID],
	CONSTRAINT [DF_t_d_AttendenceData_f_LateTime] DEFAULT (0) FOR [f_LateTime],
	CONSTRAINT [DF_t_d_AttendenceData_f_LeaveEarlyTime] DEFAULT (0) FOR [f_LeaveEarlyTime],
	CONSTRAINT [DF_t_d_AttendenceData_f_OvertimeTime] DEFAULT (0) FOR [f_OvertimeTime],
	CONSTRAINT [DF_t_d_AttendenceData_f_AbsenceDay] DEFAULT (0) FOR [f_AbsenceDay]
GO

ALTER TABLE [dbo].[t_d_CardRecord] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_CardRecord_f_CardNO] DEFAULT (0) FOR [f_CardNO],
	CONSTRAINT [DF_t_d_CardRecord_f_Character] DEFAULT (0) FOR [f_Character],
	CONSTRAINT [DF_t_d_CardRecord_f_ReaderID] DEFAULT (0) FOR [f_ReaderID],
	CONSTRAINT [DF_t_d_CardRecord_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID]
GO

ALTER TABLE [dbo].[t_d_CardRecordBuf] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_CardRecordBuf_f_CardNO] DEFAULT (0) FOR [f_CardNO],
	CONSTRAINT [DF_t_d_CardRecordBuf_f_Character] DEFAULT (0) FOR [f_Character],
	CONSTRAINT [DF_t_d_CardRecordBuf_f_ReaderID] DEFAULT (0) FOR [f_ReaderID]
GO

ALTER TABLE [dbo].[t_d_Leave] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_Leave_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID]
GO

ALTER TABLE [dbo].[t_d_ManualCardRecord] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_ManualCardRecord_f_CardNO] DEFAULT (0) FOR [f_CardNO],
	CONSTRAINT [DF_t_d_ManualCardRecord_f_Character] DEFAULT (0) FOR [f_Character],
	CONSTRAINT [DF_t_d_ManualCardRecord_f_ReaderID] DEFAULT (0) FOR [f_ReaderID],
	CONSTRAINT [DF_t_d_ManualCardRecord_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID],
	CONSTRAINT [DF_t_d_ManualCardRecord_f_DutyOnOff] DEFAULT (3) FOR [f_DutyOnOff]
GO

ALTER TABLE [dbo].[t_d_Patrol_Data] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_Patrol_Data_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID],
	CONSTRAINT [DF_t_d_Patrol_Data_f_TaskID] DEFAULT (0) FOR [f_TaskID],
	CONSTRAINT [DF_t_d_Patrol_Data_f_ReaderID] DEFAULT (0) FOR [f_ReaderID]
GO

ALTER TABLE [dbo].[t_d_Privilege] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_Privilege_f_DoorID] DEFAULT (0) FOR [f_DoorID],
	CONSTRAINT [DF_t_d_Privilege_f_ControlSegID] DEFAULT (1) FOR [f_ControlSegID],
	CONSTRAINT [DF_t_d_Privilege_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID]
GO

ALTER TABLE [dbo].[t_d_ShiftData] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_ShiftData_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_01] DEFAULT ((-1)) FOR [f_ShiftID_01],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_02] DEFAULT ((-1)) FOR [f_ShiftID_02],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_03] DEFAULT ((-1)) FOR [f_ShiftID_03],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_04] DEFAULT ((-1)) FOR [f_ShiftID_04],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_05] DEFAULT ((-1)) FOR [f_ShiftID_05],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_06] DEFAULT ((-1)) FOR [f_ShiftID_06],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_07] DEFAULT ((-1)) FOR [f_ShiftID_07],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_08] DEFAULT ((-1)) FOR [f_ShiftID_08],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_09] DEFAULT ((-1)) FOR [f_ShiftID_09],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_10] DEFAULT ((-1)) FOR [f_ShiftID_10],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_11] DEFAULT ((-1)) FOR [f_ShiftID_11],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_12] DEFAULT ((-1)) FOR [f_ShiftID_12],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_13] DEFAULT ((-1)) FOR [f_ShiftID_13],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_14] DEFAULT ((-1)) FOR [f_ShiftID_14],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_15] DEFAULT ((-1)) FOR [f_ShiftID_15],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_16] DEFAULT ((-1)) FOR [f_ShiftID_16],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_17] DEFAULT ((-1)) FOR [f_ShiftID_17],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_18] DEFAULT ((-1)) FOR [f_ShiftID_18],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_19] DEFAULT ((-1)) FOR [f_ShiftID_19],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_20] DEFAULT ((-1)) FOR [f_ShiftID_20],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_21] DEFAULT ((-1)) FOR [f_ShiftID_21],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_22] DEFAULT ((-1)) FOR [f_ShiftID_22],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_23] DEFAULT ((-1)) FOR [f_ShiftID_23],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_24] DEFAULT ((-1)) FOR [f_ShiftID_24],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_25] DEFAULT ((-1)) FOR [f_ShiftID_25],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_26] DEFAULT ((-1)) FOR [f_ShiftID_26],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_27] DEFAULT ((-1)) FOR [f_ShiftID_27],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_28] DEFAULT ((-1)) FOR [f_ShiftID_28],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_29] DEFAULT ((-1)) FOR [f_ShiftID_29],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_30] DEFAULT ((-1)) FOR [f_ShiftID_30],
	CONSTRAINT [DF_t_d_ShiftData_f_ShiftID_31] DEFAULT ((-1)) FOR [f_ShiftID_31],
	CONSTRAINT [DF_t_d_ShiftData_f_LogDate] DEFAULT (getdate()) FOR [f_LogDate]
GO

ALTER TABLE [dbo].[t_d_Shift_Work_Schedule] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_Shift_Work_Schedule_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID],
	CONSTRAINT [DF_t_d_Shift_Work_Schedule_f_TimeSeg] DEFAULT (0) FOR [f_TimeSeg],
	CONSTRAINT [DF_t_d_Shift_Work_Schedule_f_Duration] DEFAULT (0) FOR [f_Duration],
	CONSTRAINT [DF_t_d_Shift_Work_Schedule_f_bOvertimeShift] DEFAULT (0) FOR [f_bOvertimeShift]
GO

ALTER TABLE [dbo].[t_d_doorFirstCardUsers] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_doorFirstCardUsers_f_DoorID] DEFAULT (0) FOR [f_DoorID],
	CONSTRAINT [DF_t_d_doorFirstCardUsers_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID]
GO

ALTER TABLE [dbo].[t_d_doorMoreCardsUsers] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_doorMoreCardsUsers_f_DoorID] DEFAULT (0) FOR [f_DoorID],
	CONSTRAINT [DF_t_d_doorMoreCardsUsers_f_MoreCards_GrpID] DEFAULT (0) FOR [f_MoreCards_GrpID],
	CONSTRAINT [DF_t_d_doorMoreCardsUsers_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID]
GO

ALTER TABLE [dbo].[t_d_mapdoors] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_mapdoors_f_DoorID] DEFAULT (0) FOR [f_DoorID],
	CONSTRAINT [DF_t_d_mapdoors_f_MapId] DEFAULT (0) FOR [f_MapId],
	CONSTRAINT [DF_t_d_mapdoors_f_DoorLocationX] DEFAULT (0) FOR [f_DoorLocationX],
	CONSTRAINT [DF_t_d_mapdoors_f_DoorLocationY] DEFAULT (0) FOR [f_DoorLocationY]
GO

ALTER TABLE [dbo].[t_d_maps] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_maps_f_MapName] DEFAULT (N'Map') FOR [f_MapName],
	CONSTRAINT [DF_t_d_maps_f_MapPageIndex] DEFAULT (0) FOR [f_MapPageIndex],
	CONSTRAINT [DF_t_d_maps_f_MapFile] DEFAULT (N'.\Photo') FOR [f_MapFile]
GO

ALTER TABLE [dbo].[t_d_shift_AttReport] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_shift_AttReport_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID],
	CONSTRAINT [DF_t_d_shift_AttReport_f_ShiftID] DEFAULT ((-1)) FOR [f_ShiftID],
	CONSTRAINT [DF_t_d_shift_AttReport_f_ReadTimes] DEFAULT (0) FOR [f_ReadTimes],
	CONSTRAINT [DF_t_d_shift_AttReport_f_LateMinutes] DEFAULT (0) FOR [f_LateMinutes],
	CONSTRAINT [DF_t_d_shift_AttReport_f_LeaveEarlyMinutes] DEFAULT (0) FOR [f_LeaveEarlyMinutes],
	CONSTRAINT [DF_t_d_shift_AttReport_f_OvertimeHours] DEFAULT (0) FOR [f_OvertimeHours],
	CONSTRAINT [DF_t_d_shift_AttReport_f_AbsenceDays] DEFAULT (0) FOR [f_AbsenceDays],
	CONSTRAINT [DF_t_d_shift_AttReport_f_NotReadCardCount] DEFAULT (0) FOR [f_NotReadCardCount],
	CONSTRAINT [DF_t_d_shift_AttReport_f_bOvertimeShift] DEFAULT (0) FOR [f_bOvertimeShift]
GO

ALTER TABLE [dbo].[t_d_shift_AttStatistic] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_d_shift_AttStatistic_f_ConsumerID] DEFAULT (0) FOR [f_ConsumerID],
	CONSTRAINT [DF_t_d_shift_AttStatistic_f_DayShouldWork] DEFAULT (0) FOR [f_DayShouldWork],
	CONSTRAINT [DF_t_d_shift_AttStatistic_f_LateMinutes] DEFAULT (0) FOR [f_LateMinutes],
	CONSTRAINT [DF_t_d_shift_AttStatistic_f_LateCount] DEFAULT (0) FOR [f_LateCount],
	CONSTRAINT [DF_t_d_shift_AttStatistic_f_LeaveEarlyMinutes] DEFAULT (0) FOR [f_LeaveEarlyMinutes],
	CONSTRAINT [DF_t_d_shift_AttStatistic_f_LeaveEarlyCount] DEFAULT (0) FOR [f_LeaveEarlyCount],
	CONSTRAINT [DF_t_d_shift_AttStatistic_f_OvertimeHours] DEFAULT (0) FOR [f_OvertimeHours],
	CONSTRAINT [DF_t_d_shift_AttStatistic_f_AbsenceDays] DEFAULT (0) FOR [f_AbsenceDays],
	CONSTRAINT [DF_t_d_shift_AttStatistic_f_NotReadCardCount] DEFAULT (0) FOR [f_NotReadCardCount],
	CONSTRAINT [DF_t_d_shift_AttStatistic_f_ManualReadTimesCount] DEFAULT (0) FOR [f_ManualReadTimesCount]
GO

ALTER TABLE [dbo].[t_s_FunctionOption] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_s_FunctionOption_f_Value] DEFAULT (0) FOR [f_Value]
GO

ALTER TABLE [dbo].[t_s_OperatorMode] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_s_OperatorMode_f_OperatorID] DEFAULT (0) FOR [f_OperatorID],
	CONSTRAINT [DF_t_s_OperatorMode_f_Read] DEFAULT (1) FOR [f_Read],
	CONSTRAINT [DF_t_s_OperatorMode_f_Write] DEFAULT (1) FOR [f_Write],
	CONSTRAINT [DF_t_s_OperatorMode_f_FullControl] DEFAULT (1) FOR [f_FullControl],
	CONSTRAINT [DF_t_s_OperatorMode_f_Type] DEFAULT (0) FOR [f_Type],
	CONSTRAINT [DF_t_s_OperatorMode_f_SerialNo] DEFAULT (0) FOR [f_SerialNo]
GO

ALTER TABLE [dbo].[t_s_wglog] WITH NOCHECK ADD 
	CONSTRAINT [DF_t_s_wglog_f_UserID] DEFAULT (0) FOR [f_UserID],
	CONSTRAINT [DF_t_s_wglog_f_LogDateTime] DEFAULT (getdate()) FOR [f_LogDateTime]
GO

 CREATE  UNIQUE  INDEX [IX_t_b_Controller] ON [dbo].[t_b_Controller]([f_ControllerNO]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_t_d_Privilege] ON [dbo].[t_d_Privilege]([f_DoorID]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_t_d_Privilege_1] ON [dbo].[t_d_Privilege]([f_ControlSegID]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_t_d_Privilege_2] ON [dbo].[t_d_Privilege]([f_ConsumerID]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_t_d_ShiftData] ON [dbo].[t_d_ShiftData]([f_ConsumerID]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_t_d_Shift_Work_Schedule] ON [dbo].[t_d_Shift_Work_Schedule]([f_ConsumerID]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_t_d_shift_AttReport] ON [dbo].[t_d_shift_AttReport]([f_ConsumerID]) ON [PRIMARY]
GO

 CREATE  INDEX [IX_t_d_shift_AttStatistic] ON [dbo].[t_d_shift_AttStatistic]([f_ConsumerID]) ON [PRIMARY]
GO

 CREATE  UNIQUE  INDEX [IX_t_s_Operator] ON [dbo].[t_s_Operator]([f_OperatorName]) ON [PRIMARY]
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_a_Holiday    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_a_Holiday    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_a_Holiday
AS
SELECT t_a_Holiday.*,
CASE WHEN isdate([f_Value])=1 THEN 
convert(char(4),DATEPART(yyyy,[f_Value])) + '-' +
convert(nvarchar(2),DATEPART(mm,[f_Value])) + '-' +
convert(nvarchar(2),DATEPART(dd,[f_Value])) + ' ' +
[f_Value1] 
ELSE
CONVERT(nvarchar(50),DATEPART (yyyy , getdate() ))+'-' +
[f_Value] + ' ' +
[f_Value1] 
END
AS f_from, 
CASE WHEN isdate([f_Value2])=1 THEN 
convert(char(4),DATEPART(yyyy,[f_Value2])) + '-' +
convert(nvarchar(2),DATEPART(mm,[f_Value2])) + '-' +
convert(nvarchar(2),DATEPART(dd,[f_Value2])) + ' ' +
[f_Value3] 
ELSE
CONVERT(nvarchar(50),DATEPART (yyyy , getdate() ))+'-' +
[f_Value2] + ' ' +
[f_Value3] 
END
AS f_to
FROM t_a_Holiday

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_b_Door    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_b_Door    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_b_Door
AS
SELECT dbo.t_b_Door.*, dbo.t_b_Controller.f_ControllerNO AS f_ControllerNO, 
      dbo.t_b_Controller.f_Enabled AS f_ControllerEnabled, 
      dbo.t_b_Door.f_DoorName AS f_DoorFullName
FROM dbo.t_b_Door INNER JOIN
      dbo.t_b_Controller ON dbo.t_b_Door.f_ControllerID = dbo.t_b_Controller.f_ControllerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_b_IDCardLost    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_b_IDCardLost    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_b_IDCardLost
AS
SELECT dbo.t_b_IDCard.*
FROM dbo.t_b_IDCard
WHERE (f_CardStatusDesc <> '0')


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_b_IDCard_valid    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_b_IDCard_valid    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_b_IDCard_valid
AS
SELECT dbo.t_b_IDCard.*
FROM dbo.t_b_IDCard
WHERE (f_CardStatusDesc = '0')


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_b_Reader    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_b_Reader    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_b_Reader
AS
SELECT dbo.t_b_Door.f_DoorName, dbo.t_b_Reader.f_ReaderID, 
      dbo.t_b_Reader.f_ControllerID, dbo.t_b_Reader.f_ReaderNO, 
      dbo.t_b_Reader.f_PasswordEnabled, 
      ISNULL(dbo.t_b_Door.f_DoorName + '[' + dbo.t_b_Reader.f_ReaderName + ']', 
      dbo.t_b_Door.f_DoorName) AS f_ReaderName, dbo.t_b_Reader.f_Attend
FROM dbo.t_b_Reader INNER JOIN
      dbo.t_b_Door ON dbo.t_b_Reader.f_ControllerID = dbo.t_b_Door.f_ControllerID AND 
      SUBSTRING(dbo.t_b_Reader.f_ReaderNO, 2, 1) = dbo.t_b_Door.f_DoorNO


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_b_Reader4Patrol    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_b_Reader4Patrol    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_b_Reader4Patrol
AS
SELECT dbo.t_b_Door.f_DoorName AS f_DoorName, dbo.t_b_Reader.*, 
      ISNULL(dbo.t_b_Door.f_DoorName + '-' + dbo.t_b_Reader.f_ReaderName, 
      dbo.t_b_Door.f_DoorName) AS f_ReaderFullNo
FROM dbo.t_b_Reader INNER JOIN
      dbo.t_b_Door ON dbo.t_b_Reader.f_ControllerID = dbo.t_b_Door.f_ControllerID AND 
      SUBSTRING(dbo.t_b_Reader.f_ReaderNO, 2, 1) = dbo.t_b_Door.f_DoorNO


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_CardRecordBuf    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_CardRecordBuf    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_CardRecordBuf
AS
SELECT dbo.t_b_IDCard.f_ConsumerID, dbo.t_d_CardRecordBuf.f_CardNO, 
      dbo.t_d_CardRecordBuf.f_ReadDate, dbo.t_d_CardRecordBuf.f_Character, 
      dbo.t_d_CardRecordBuf.f_ControllerSN, dbo.t_d_CardRecordBuf.f_ReaderID, 
      dbo.t_d_CardRecordBuf.f_Note
FROM dbo.t_d_CardRecordBuf LEFT OUTER JOIN
      dbo.t_b_IDCard ON dbo.t_d_CardRecordBuf.f_CardNO = dbo.t_b_IDCard.f_CardNO


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_b_ConsumerIDCard    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_b_ConsumerIDCard    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_b_ConsumerIDCard
AS
SELECT TOP 100 PERCENT dbo.t_b_Consumer.*, 
      dbo.t_b_Group.f_GroupName AS f_GroupName, 
      dbo.v_b_IDCard_valid.f_CardNO AS f_CardNO
FROM dbo.t_b_Consumer LEFT OUTER JOIN
      dbo.t_b_Group ON 
      dbo.t_b_Consumer.f_GroupID = dbo.t_b_Group.f_GroupID LEFT OUTER JOIN
      dbo.v_b_IDCard_valid ON 
      dbo.t_b_Consumer.f_ConsumerID = dbo.v_b_IDCard_valid.f_ConsumerID
ORDER BY dbo.t_b_Consumer.f_ConsumerNO


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_b_Patrol_RouteDetail    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_b_Patrol_RouteDetail    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_b_Patrol_RouteDetail
AS
SELECT dbo.t_b_Patrol_RouteDetail.f_Sn, dbo.t_b_Patrol_RouteDetail.f_ReaderID, 
      dbo.t_b_Patrol_RouteDetail.f_RouteID, dbo.t_b_Patrol_RouteDetail.f_Interval, 
      dbo.v_b_Reader4Patrol.f_ReaderFullNo AS f_ReaderName
FROM dbo.t_b_Patrol_RouteDetail INNER JOIN
      dbo.v_b_Reader4Patrol ON 
      dbo.t_b_Patrol_RouteDetail.f_ReaderID = dbo.v_b_Reader4Patrol.f_ReaderID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_b_Patrol_RouteList    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_b_Patrol_RouteList    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_b_Patrol_RouteList
AS
SELECT dbo.t_b_Patrol_RouteList.*, 
      dbo.v_b_Patrol_RouteDetail.f_ReaderName AS f_ReaderName, 
      dbo.v_b_Patrol_RouteDetail.f_Interval AS f_Interval, 
      dbo.v_b_Patrol_RouteDetail.f_ReaderID AS f_ReaderID, 
      dbo.v_b_Patrol_RouteDetail.f_Sn AS f_Sn
FROM dbo.t_b_Patrol_RouteList LEFT OUTER JOIN
      dbo.v_b_Patrol_RouteDetail ON 
      dbo.t_b_Patrol_RouteList.f_RouteId = dbo.v_b_Patrol_RouteDetail.f_RouteID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_CardRecord    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_CardRecord    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_CardRecord
AS
SELECT DISTINCT 
      dbo.t_d_CardRecord.f_Note, dbo.t_d_CardRecord.f_CardRecordID, 
      dbo.t_d_CardRecord.f_CardNO, dbo.t_d_CardRecord.f_ReadDate, 
      dbo.t_d_CardRecord.f_Character, dbo.t_d_CardRecord.f_ControllerSN, 
      dbo.t_d_CardRecord.f_ReaderID, dbo.t_d_CardRecord.f_ConsumerID, 
      dbo.v_b_Reader.f_ControllerID, dbo.v_b_Reader.f_ReaderName, 
      dbo.v_b_Reader.f_ReaderNO, dbo.v_b_Reader.f_Attend, 
      dbo.v_b_ConsumerIDCard.f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_GroupName, dbo.v_b_ConsumerIDCard.f_AttendEnabled, 
      dbo.v_b_ConsumerIDCard.f_ConsumerNO
FROM dbo.t_d_CardRecord LEFT OUTER JOIN
      dbo.v_b_Reader ON 
      dbo.t_d_CardRecord.f_ReaderID = dbo.v_b_Reader.f_ReaderID LEFT OUTER JOIN
      dbo.v_b_ConsumerIDCard ON 
      dbo.t_d_CardRecord.f_ConsumerID = dbo.v_b_ConsumerIDCard.f_ConsumerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_CardRecord4Attendence    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_CardRecord4Attendence    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_CardRecord4Attendence
AS
SELECT DISTINCT 
      dbo.t_d_CardRecord.f_ReadDate, dbo.t_d_CardRecord.f_Character, 
      dbo.t_d_CardRecord.f_ConsumerID, dbo.v_b_ConsumerIDCard.f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_GroupName, dbo.v_b_ConsumerIDCard.f_ConsumerNO, 
      '' AS f_Type
FROM dbo.t_d_CardRecord LEFT OUTER JOIN
      dbo.t_b_Reader ON 
      dbo.t_d_CardRecord.f_ReaderID = dbo.t_b_Reader.f_ReaderID LEFT OUTER JOIN
      dbo.v_b_ConsumerIDCard ON 
      dbo.t_d_CardRecord.f_ConsumerID = dbo.v_b_ConsumerIDCard.f_ConsumerID
WHERE (dbo.t_b_Reader.f_Attend = 1) AND 
      (dbo.v_b_ConsumerIDCard.f_AttendEnabled = 1)


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_CardRecord4Patrol    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_CardRecord4Patrol    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_CardRecord4Patrol
AS
SELECT DISTINCT 
      dbo.t_d_CardRecord.f_ReadDate, dbo.t_d_CardRecord.f_Character, 
      dbo.t_d_CardRecord.f_ConsumerID, dbo.v_b_ConsumerIDCard.f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_GroupName, dbo.v_b_ConsumerIDCard.f_ConsumerNO, 
      dbo.t_d_CardRecord.f_ReaderID, '' AS f_Type
FROM dbo.t_d_CardRecord LEFT OUTER JOIN
      dbo.t_b_Reader ON 
      dbo.t_d_CardRecord.f_ReaderID = dbo.t_b_Reader.f_ReaderID LEFT OUTER JOIN
      dbo.v_b_ConsumerIDCard ON 
      dbo.t_d_CardRecord.f_ConsumerID = dbo.v_b_ConsumerIDCard.f_ConsumerID
WHERE (dbo.t_b_Reader.f_Patrol = 1) AND (dbo.v_b_ConsumerIDCard.f_PatrolEnabled = 1)


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_Leave    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_Leave    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_Leave
AS
SELECT dbo.t_d_Leave.*, CONVERT(nvarchar(50), DATEPART(yyyy, 
      dbo.t_d_Leave.f_Value)) + '-' + CONVERT(nvarchar(50), DATEPART(mm, 
      dbo.t_d_Leave.f_Value)) + '-' + CONVERT(nvarchar(50), DATEPART(dd, 
      dbo.t_d_Leave.f_Value)) + ' ' + dbo.t_d_Leave.f_Value1 AS f_from, 
      CONVERT(nvarchar(50), DATEPART(yyyy, dbo.t_d_Leave.f_Value2)) 
      + '-' + CONVERT(nvarchar(50), DATEPART(mm, dbo.t_d_Leave.f_Value2)) 
      + '-' + CONVERT(nvarchar(50), DATEPART(dd, dbo.t_d_Leave.f_Value2)) 
      + ' ' + dbo.t_d_Leave.f_Value3 AS f_to, 
      dbo.v_b_ConsumerIDCard.f_ConsumerNO AS f_ConsumerNO, 
      dbo.v_b_ConsumerIDCard.f_ConsumerName AS f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_GroupName AS f_GroupName
FROM dbo.t_d_Leave INNER JOIN
      dbo.v_b_ConsumerIDCard ON 
      dbo.t_d_Leave.f_ConsumerID = dbo.v_b_ConsumerIDCard.f_ConsumerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_ManualCardRecord4Attendence    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_ManualCardRecord4Attendence    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_ManualCardRecord4Attendence
AS
SELECT DISTINCT 
      dbo.t_d_ManualCardRecord.f_ReadDate, dbo.t_d_ManualCardRecord.f_Character, 
      dbo.t_d_ManualCardRecord.f_ConsumerID, 
      dbo.v_b_ConsumerIDCard.f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_GroupName, dbo.v_b_ConsumerIDCard.f_ConsumerNO, 
      'SignIn' AS f_Type
FROM dbo.t_d_ManualCardRecord LEFT OUTER JOIN
      dbo.v_b_ConsumerIDCard ON 
      dbo.t_d_ManualCardRecord.f_ConsumerID = dbo.v_b_ConsumerIDCard.f_ConsumerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_ManualCardRecord4Display    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_ManualCardRecord4Display    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_ManualCardRecord4Display
AS
SELECT DISTINCT 
      dbo.t_d_ManualCardRecord.f_ManualCardRecordID, 
      dbo.t_d_ManualCardRecord.f_ReadDate, dbo.t_d_ManualCardRecord.f_Character, 
      dbo.t_d_ManualCardRecord.f_ConsumerID, dbo.v_b_ConsumerIDCard.f_WorkNo, 
      dbo.v_b_ConsumerIDCard.f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_GroupName, dbo.v_b_ConsumerIDCard.f_ConsumerNO, 
      'SignIn' AS f_Type, dbo.t_d_ManualCardRecord.f_Note
FROM dbo.t_d_ManualCardRecord LEFT OUTER JOIN
      dbo.v_b_ConsumerIDCard ON 
      dbo.t_d_ManualCardRecord.f_ConsumerID = dbo.v_b_ConsumerIDCard.f_ConsumerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_Patrol_Statistic    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_Patrol_Statistic    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_Patrol_Statistic
AS
SELECT dbo.t_d_Patrol_Statistic.*, 
      dbo.v_b_ConsumerIDCard.f_ConsumerNO AS f_ConsumerNO, 
      dbo.v_b_ConsumerIDCard.f_ConsumerName AS f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_GroupName AS f_GroupName
FROM dbo.t_d_Patrol_Statistic INNER JOIN
      dbo.v_b_ConsumerIDCard ON 
      dbo.t_d_Patrol_Statistic.f_ConsumerID = dbo.v_b_ConsumerIDCard.f_ConsumerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_Patrol_TaskList    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_Patrol_TaskList    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_Patrol_TaskList
AS
SELECT dbo.t_d_Patrol_TaskList.*, 
      dbo.t_b_Patrol_RouteList.f_RouteName AS f_RouteName, 
      dbo.t_b_Patrol_RouteList.f_Description AS f_Description, 
      dbo.v_b_ConsumerIDCard.f_ConsumerName AS f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_GroupName AS f_GroupName
FROM dbo.v_b_ConsumerIDCard INNER JOIN
      dbo.t_d_Patrol_TaskList LEFT OUTER JOIN
      dbo.t_b_Patrol_RouteList ON 
      dbo.t_d_Patrol_TaskList.f_RouteID = dbo.t_b_Patrol_RouteList.f_RouteId ON 
      dbo.v_b_ConsumerIDCard.f_ConsumerID = dbo.t_d_Patrol_TaskList.f_ConsumerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_Privilege    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_Privilege    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_Privilege
AS
SELECT dbo.t_d_Privilege.*, dbo.v_b_Door.f_ControllerID AS f_ControllerID, 
      dbo.v_b_ConsumerIDCard.f_CardNO AS f_CardNO, 
      dbo.v_b_Door.f_DoorNO AS f_DoorNO, 
      dbo.v_b_ConsumerIDCard.f_BeginYMD AS f_BeginYMD, 
      dbo.v_b_ConsumerIDCard.f_EndYMD AS f_EndYMD, 
      dbo.v_b_ConsumerIDCard.f_GroupName AS f_GroupName, 
      dbo.v_b_ConsumerIDCard.f_Password AS f_Password, 
      dbo.v_b_Door.f_DoorFullName AS f_DoorFullName, 
      dbo.v_b_ConsumerIDCard.f_ConsumerName AS f_ConsumerName
FROM dbo.v_b_ConsumerIDCard INNER JOIN
      dbo.t_d_Privilege INNER JOIN
      dbo.v_b_Door ON dbo.t_d_Privilege.f_DoorID = dbo.v_b_Door.f_DoorID ON 
      dbo.v_b_ConsumerIDCard.f_ConsumerID = dbo.t_d_Privilege.f_ConsumerID
WHERE (dbo.v_b_Door.f_DoorEnabled = 1)


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_Shift_AttReport    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_Shift_AttReport    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_Shift_AttReport
AS
SELECT dbo.t_d_shift_AttReport.*, 
      dbo.v_b_ConsumerIDCard.f_GroupName AS f_GroupName, 
      dbo.v_b_ConsumerIDCard.f_ConsumerName AS f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_ConsumerNO AS f_ConsumerNO, 
      dbo.v_b_ConsumerIDCard.f_WorkNo AS f_WorkNo, 
      ISNULL(dbo.t_d_shift_AttReport.f_OnDuty1AttDesc, '') 
      + ISNULL(dbo.t_d_shift_AttReport.f_OnDuty1CardRecordDesc, '') AS f_Desc1, 
      ISNULL(dbo.t_d_shift_AttReport.f_OffDuty1AttDesc, '') 
      + ISNULL(dbo.t_d_shift_AttReport.f_OffDuty1CardRecordDesc, '') AS f_Desc2, 
      ISNULL(dbo.t_d_shift_AttReport.f_OnDuty2AttDesc, '') 
      + ISNULL(dbo.t_d_shift_AttReport.f_OnDuty2CardRecordDesc, '') AS f_Desc3, 
      ISNULL(dbo.t_d_shift_AttReport.f_OffDuty2AttDesc, '') 
      + ISNULL(dbo.t_d_shift_AttReport.f_OffDuty2CardRecordDesc, '') AS f_Desc4, 
      ISNULL(dbo.t_d_shift_AttReport.f_OnDuty3AttDesc, '') 
      + ISNULL(dbo.t_d_shift_AttReport.f_OnDuty3CardRecordDesc, '') AS f_Desc5, 
      ISNULL(dbo.t_d_shift_AttReport.f_OffDuty3AttDesc, '') 
      + ISNULL(dbo.t_d_shift_AttReport.f_OffDuty3CardRecordDesc, '') AS f_Desc6, 
      ISNULL(dbo.t_d_shift_AttReport.f_OnDuty4AttDesc, '') 
      + ISNULL(dbo.t_d_shift_AttReport.f_OnDuty4CardRecordDesc, '') AS f_Desc7, 
      ISNULL(dbo.t_d_shift_AttReport.f_OffDuty4AttDesc, '') 
      + ISNULL(dbo.t_d_shift_AttReport.f_OffDuty4CardRecordDesc, '') AS f_Desc8, 
      ISNULL(CONVERT(char(4), DATEPART(yyyy, dbo.t_d_shift_AttReport.f_ShiftDate)) 
      + '-' + CONVERT(char(2), DATEPART(mm, dbo.t_d_shift_AttReport.f_ShiftDate)) 
      + '-' + CONVERT(char(2), DATEPART(dd, dbo.t_d_shift_AttReport.f_ShiftDate)), '') 
      AS f_ShiftDateShort, ISNULL(CONVERT(char(2), DATEPART(hh, 
      dbo.t_d_shift_AttReport.f_OnDuty1)) + ':' + CONVERT(char(2), DATEPART(mi, 
      dbo.t_d_shift_AttReport.f_OnDuty1)) + ':' + CONVERT(char(2), DATEPART(ss, 
      dbo.t_d_shift_AttReport.f_OnDuty1)), '') AS f_OnDuty1Short, ISNULL(CONVERT(char(2), 
      DATEPART(hh, dbo.t_d_shift_AttReport.f_OffDuty1)) + ':' + CONVERT(char(2), 
      DATEPART(mi, dbo.t_d_shift_AttReport.f_OffDuty1)) + ':' + CONVERT(char(2), 
      DATEPART(ss, dbo.t_d_shift_AttReport.f_OffDuty1)), '') AS f_OffDuty1Short, 
      ISNULL(CONVERT(char(2), DATEPART(hh, dbo.t_d_shift_AttReport.f_OnDuty2)) 
      + ':' + CONVERT(char(2), DATEPART(mi, dbo.t_d_shift_AttReport.f_OnDuty2)) 
      + ':' + CONVERT(char(2), DATEPART(ss, dbo.t_d_shift_AttReport.f_OnDuty2)), '') 
      AS f_OnDuty2Short, ISNULL(CONVERT(char(2), DATEPART(hh, 
      dbo.t_d_shift_AttReport.f_OffDuty2)) + ':' + CONVERT(char(2), DATEPART(mi, 
      dbo.t_d_shift_AttReport.f_OffDuty2)) + ':' + CONVERT(char(2), DATEPART(ss, 
      dbo.t_d_shift_AttReport.f_OffDuty2)), '') AS f_OffDuty2Short, ISNULL(CONVERT(char(2), 
      DATEPART(hh, dbo.t_d_shift_AttReport.f_OnDuty3)) + ':' + CONVERT(char(2), 
      DATEPART(mi, dbo.t_d_shift_AttReport.f_OnDuty3)) + ':' + CONVERT(char(2), 
      DATEPART(ss, dbo.t_d_shift_AttReport.f_OnDuty3)), '') AS f_OnDuty3Short, 
      ISNULL(CONVERT(char(2), DATEPART(hh, dbo.t_d_shift_AttReport.f_OffDuty3)) 
      + ':' + CONVERT(char(2), DATEPART(mi, dbo.t_d_shift_AttReport.f_OffDuty3)) 
      + ':' + CONVERT(char(2), DATEPART(ss, dbo.t_d_shift_AttReport.f_OffDuty3)), '') 
      AS f_OffDuty3Short, ISNULL(CONVERT(char(2), DATEPART(hh, 
      dbo.t_d_shift_AttReport.f_OnDuty4)) + ':' + CONVERT(char(2), DATEPART(mi, 
      dbo.t_d_shift_AttReport.f_OnDuty4)) + ':' + CONVERT(char(2), DATEPART(ss, 
      dbo.t_d_shift_AttReport.f_OnDuty4)), '') AS f_OnDuty4Short, ISNULL(CONVERT(char(2), 
      DATEPART(hh, dbo.t_d_shift_AttReport.f_OffDuty4)) + ':' + CONVERT(char(2), 
      DATEPART(mi, dbo.t_d_shift_AttReport.f_OffDuty4)) + ':' + CONVERT(char(2), 
      DATEPART(ss, dbo.t_d_shift_AttReport.f_OffDuty4)), '') AS f_OffDuty4Short
FROM dbo.v_b_ConsumerIDCard RIGHT OUTER JOIN
      dbo.t_d_shift_AttReport ON 
      dbo.v_b_ConsumerIDCard.f_ConsumerID = dbo.t_d_shift_AttReport.f_ConsumerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_Shift_AttStatistic    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_Shift_AttStatistic    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_Shift_AttStatistic
AS
SELECT dbo.t_d_shift_AttStatistic.*, 
      dbo.v_b_ConsumerIDCard.f_GroupName AS f_GroupName, 
      dbo.v_b_ConsumerIDCard.f_ConsumerName AS f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_ConsumerNO AS f_ConsumerNO, 
      dbo.v_b_ConsumerIDCard.f_WorkNo AS f_WorkNo
FROM dbo.v_b_ConsumerIDCard RIGHT OUTER JOIN
      dbo.t_d_shift_AttStatistic ON 
      dbo.v_b_ConsumerIDCard.f_ConsumerID = dbo.t_d_shift_AttStatistic.f_ConsumerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_shiftdata    Script Date: 2006-4-29 12:23:48 ******/

/****** Object:  View dbo.v_d_shiftdata    Script Date: 2006-4-29 12:19:15 ******/
CREATE VIEW dbo.v_d_shiftdata
AS
SELECT dbo.t_d_ShiftData.*, dbo.v_b_ConsumerIDCard.f_GroupName AS f_GroupName, 
      dbo.v_b_ConsumerIDCard.f_ConsumerName AS f_ConsumerName, 
      dbo.v_b_ConsumerIDCard.f_ConsumerNO AS f_ConsumerNO, 
      dbo.v_b_ConsumerIDCard.f_WorkNo AS f_WorkNo
FROM dbo.v_b_ConsumerIDCard RIGHT OUTER JOIN
      dbo.t_d_ShiftData ON 
      dbo.v_b_ConsumerIDCard.f_ConsumerID = dbo.t_d_ShiftData.f_ConsumerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_Patrol_Data    Script Date: 2006-4-29 12:23:49 ******/

/****** Object:  View dbo.v_d_Patrol_Data    Script Date: 2006-4-29 12:19:16 ******/
CREATE VIEW dbo.v_d_Patrol_Data
AS
SELECT dbo.t_d_Patrol_Data.*, 
      dbo.t_b_Consumer.f_ConsumerName AS f_ConsumerName, 
      dbo.v_d_Patrol_TaskList.f_RouteName AS f_RouteName, 
      dbo.v_b_Reader4Patrol.f_ReaderFullNo AS f_ReaderName, 
      dbo.v_d_Patrol_TaskList.f_Description AS f_Description
FROM dbo.v_d_Patrol_TaskList INNER JOIN
      dbo.v_b_Reader4Patrol INNER JOIN
      dbo.t_d_Patrol_Data ON 
      dbo.v_b_Reader4Patrol.f_ReaderID = dbo.t_d_Patrol_Data.f_ReaderID ON 
      dbo.v_d_Patrol_TaskList.f_TaskID = dbo.t_d_Patrol_Data.f_TaskID INNER JOIN
      dbo.t_b_Consumer ON 
      dbo.t_d_Patrol_Data.f_ConsumerID = dbo.t_b_Consumer.f_ConsumerID


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  View dbo.v_d_Patrol_Data4Statistic    Script Date: 2006-4-29 12:23:49 ******/

/****** Object:  View dbo.v_d_Patrol_Data4Statistic    Script Date: 2006-4-29 12:19:16 ******/
CREATE VIEW dbo.v_d_Patrol_Data4Statistic
AS
SELECT f_ConsumerID, f_EventDesc, COUNT(f_RecId) AS f_times
FROM dbo.v_d_Patrol_Data
GROUP BY f_ConsumerID, f_EventDesc


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecord4Attendence    Script Date: 2006-4-29 12:23:49 ******/

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecord4Attendence    Script Date: 2006-4-29 12:19:16 ******/
CREATE proc sp_wg_GetCardRecord4Attendence
        @startDateTime nvarchar(255),
        @endDateTime nvarchar(255),  
        @groupName nvarchar(255),
        @userId  nvarchar(255)

as
begin
declare @validStartDateTime as nvarchar(255)
declare @validEndDateTime as nvarchar(255)

if isDate(@startDateTime)>0 
set	@validstartDateTime=@startDateTime
if isDate(@endDateTime)>0
set	@validendDateTime=@endDateTime
SELECT fun_wg_GetCardRecordByTime.f_ReadDate,
fun_wg_GetCardRecordByTime.f_Character,
fun_wg_GetCardRecordByTime.f_ConsumerID,
fun_wg_GetQueryGroupUser.f_ConsumerName, 
fun_wg_GetQueryGroupUser.f_GroupName, 
fun_wg_GetQueryGroupUser.f_ConsumerNO,
 '' AS f_Type
FROM (fun_wg_GetCardRecordByTime(@validstartDateTime,@validendDateTime) 
 LEFT JOIN t_b_Reader
 ON fun_wg_GetCardRecordByTime.f_ReaderID = t_b_Reader.f_ReaderID) 
LEFT JOIN fun_wg_GetQueryGroupUser(@groupName,@userId) 
ON fun_wg_GetCardRecordByTime.f_ConsumerID = fun_wg_GetQueryGroupUser.f_ConsumerID
WHERE (((t_b_Reader.f_Attend)=1) AND ((fun_wg_GetQueryGroupUser.f_AttendEnabled)=1))
END

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByGroupUser    Script Date: 2006-4-29 12:23:49 ******/

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByGroupUser    Script Date: 2006-4-29 12:19:16 ******/
CREATE proc sp_wg_GetCardRecordByGroupUser
        @startDateTime nvarchar(255),
        @endDateTime nvarchar(255),  
        @groupName nvarchar(255),
        @userId  nvarchar(255)

as
begin
declare @validStartDateTime as nvarchar(255)
declare @validEndDateTime as nvarchar(255)

if isDate(@startDateTime)>0 
set	@validstartDateTime=@startDateTime
if isDate(@endDateTime)>0
set	@validendDateTime=@endDateTime
	
SELECT fun_wg_GetCardRecordByTime.*, v_b_Reader.f_ControllerID, v_b_Reader.f_ReaderNO, v_b_Reader.f_ReaderName, v_b_Reader.f_Attend, 
fun_wg_GetQueryGroupUser.f_ConsumerNO, fun_wg_GetQueryGroupUser.f_WorkNo, fun_wg_GetQueryGroupUser.f_ConsumerName, 
fun_wg_GetQueryGroupUser.f_AttendEnabled, fun_wg_GetQueryGroupUser.f_GroupName
FROM (v_b_Reader 
RIGHT JOIN fun_wg_GetCardRecordByTime(@validstartDateTime,@validendDateTime) 
	ON v_b_Reader.f_ReaderID = fun_wg_GetCardRecordByTime.f_ReaderID) 
	INNER JOIN fun_wg_GetQueryGroupUser(@groupName,@userId) ON fun_wg_GetCardRecordByTime.f_ConsumerID = fun_wg_GetQueryGroupUser.f_ConsumerID
ORDER BY fun_wg_GetCardRecordByTime.f_CardRecordID DESC
END

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByGroupUserRecID    Script Date: 2006-4-29 12:23:49 ******/

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByGroupUserRecID    Script Date: 2006-4-29 12:19:16 ******/
CREATE proc sp_wg_GetCardRecordByGroupUserRecID
        @readerName nvarchar(255),
	@startRecID integer,
 	@endRecID integer,
        @startDateTime nvarchar(255),
        @endDateTime nvarchar(255),  
        @groupName nvarchar(255),
        @userId  nvarchar(255)

as
begin
declare @validStartDateTime as nvarchar(255)
declare @validEndDateTime as nvarchar(255)

if isDate(@startDateTime)>0 
set	@validstartDateTime=@startDateTime
if isDate(@endDateTime)>0
set	@validendDateTime=@endDateTime
	
SELECT fun_wg_GetCardRecordByTimeRecID.*, v_b_Reader.f_ControllerID, v_b_Reader.f_ReaderNO, v_b_Reader.f_ReaderName, v_b_Reader.f_Attend, 
fun_wg_GetQueryGroupUser.f_ConsumerNO, fun_wg_GetQueryGroupUser.f_WorkNo, fun_wg_GetQueryGroupUser.f_ConsumerName, 
fun_wg_GetQueryGroupUser.f_AttendEnabled, fun_wg_GetQueryGroupUser.f_GroupName
FROM (v_b_Reader 
RIGHT JOIN fun_wg_GetCardRecordByTimeRecID(@startRecID,@endRecID,@validstartDateTime,@validendDateTime) 
	ON v_b_Reader.f_ReaderID = fun_wg_GetCardRecordByTimeRecID.f_ReaderID) 
	INNER JOIN fun_wg_GetQueryGroupUser(@groupName,@userId) ON fun_wg_GetCardRecordByTimeRecID.f_ConsumerID = fun_wg_GetQueryGroupUser.f_ConsumerID
WHERE @readerName='000' or [v_b_Reader].[f_ReaderName]=@readerName
ORDER BY fun_wg_GetCardRecordByTimeRecID.f_CardRecordID DESC
END

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordWithGroupUser    Script Date: 2006-4-29 12:23:49 ******/

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordWithGroupUser    Script Date: 2006-4-29 12:19:16 ******/
CREATE proc sp_wg_GetCardRecordWithGroupUser
        @startDateTime nvarchar(255),
        @endDateTime nvarchar(255),  
        @groupName nvarchar(255),
        @userId  nvarchar(255)

as
begin
declare @validStartDateTime as nvarchar(255)
declare @validEndDateTime as nvarchar(255)

if isDate(@startDateTime)>0 
set	@validstartDateTime=@startDateTime
if isDate(@endDateTime)>0
set	@validendDateTime=@endDateTime
	
SELECT fun_wg_GetCardRecordByTime.*, v_b_Reader.f_ControllerID, v_b_Reader.f_ReaderNO, v_b_Reader.f_ReaderName, v_b_Reader.f_Attend, 
fun_wg_GetQueryGroupUser.f_ConsumerNO, fun_wg_GetQueryGroupUser.f_WorkNo, fun_wg_GetQueryGroupUser.f_ConsumerName, 
fun_wg_GetQueryGroupUser.f_AttendEnabled, fun_wg_GetQueryGroupUser.f_GroupName
FROM (v_b_Reader 
RIGHT JOIN fun_wg_GetCardRecordByTime(@validstartDateTime,@validendDateTime) 
	ON v_b_Reader.f_ReaderID = fun_wg_GetCardRecordByTime.f_ReaderID) 
	LEFT JOIN fun_wg_GetQueryGroupUser(@groupName,@userId) ON fun_wg_GetCardRecordByTime.f_ConsumerID = fun_wg_GetQueryGroupUser.f_ConsumerID
ORDER BY fun_wg_GetCardRecordByTime.f_CardRecordID DESC
END

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordWithGroupUserRecID    Script Date: 2006-4-29 12:23:49 ******/

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordWithGroupUserRecID    Script Date: 2006-4-29 12:19:16 ******/
CREATE proc sp_wg_GetCardRecordWithGroupUserRecID
        @readerName nvarchar(255),
	@startRecID integer,
 	@endRecID integer,
        @startDateTime nvarchar(255),
        @endDateTime nvarchar(255),  
        @groupName nvarchar(255),
        @userId  nvarchar(255)

as
begin
declare @validStartDateTime as nvarchar(255)
declare @validEndDateTime as nvarchar(255)

if isDate(@startDateTime)>0 
set	@validstartDateTime=@startDateTime
if isDate(@endDateTime)>0
set	@validendDateTime=@endDateTime
	
SELECT fun_wg_GetCardRecordByTimeRecID.*, v_b_Reader.f_ControllerID, v_b_Reader.f_ReaderNO, v_b_Reader.f_ReaderName, v_b_Reader.f_Attend, 
fun_wg_GetQueryGroupUser.f_ConsumerNO, fun_wg_GetQueryGroupUser.f_WorkNo, fun_wg_GetQueryGroupUser.f_ConsumerName, 
fun_wg_GetQueryGroupUser.f_AttendEnabled, fun_wg_GetQueryGroupUser.f_GroupName
FROM (v_b_Reader 
RIGHT JOIN fun_wg_GetCardRecordByTimeRecID(@startRecID,@endRecID,@validstartDateTime,@validendDateTime) 
	ON v_b_Reader.f_ReaderID = fun_wg_GetCardRecordByTimeRecID.f_ReaderID) 
	LEFT JOIN fun_wg_GetQueryGroupUser(@groupName,@userId) ON fun_wg_GetCardRecordByTimeRecID.f_ConsumerID = fun_wg_GetQueryGroupUser.f_ConsumerID
WHERE @readerName='000' or [v_b_Reader].[f_ReaderName]=@readerName
ORDER BY fun_wg_GetCardRecordByTimeRecID.f_CardRecordID DESC
END

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByTime    Script Date: 2006-4-29 12:23:49 ******/

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByTime    Script Date: 2006-4-29 12:19:16 ******/


create proc sp_wg_GetCardRecordByTime
        @startDateTime nvarchar(255),
        @endDateTime nvarchar(255)
        
as
if isdate(@startDateTime)>0
BEGIN
if isdate(@endDateTime)>0
BEGIN
SELECT DISTINCT 
substring(t_d_CardRecord.f_note,17,2) AS f_WarnType, 
t_d_CardRecord.f_CardRecordID, t_d_CardRecord.f_CardNO, t_d_CardRecord.f_ReadDate, t_d_CardRecord.f_Character, t_d_CardRecord.f_ReaderID, t_d_CardRecord.f_ConsumerID
FROM t_d_CardRecord
WHERE ([f_ReadDate]>=Convert(datetime,@startDateTime))
END
else
BEGIN
SELECT DISTINCT 
substring(t_d_CardRecord.f_note,17,2) AS f_WarnType, 
t_d_CardRecord.f_CardRecordID, t_d_CardRecord.f_CardNO, t_d_CardRecord.f_ReadDate, t_d_CardRecord.f_Character, t_d_CardRecord.f_ReaderID, t_d_CardRecord.f_ConsumerID
FROM t_d_CardRecord
WHERE ([f_ReadDate]>=Convert(datetime,@startDateTime))
AND ([f_ReadDate]<=Convert(datetime,@endDateTime));
END
END
else
BEGIN
if isdate(@endDateTime)>0
BEGIN
SELECT DISTINCT 
substring(t_d_CardRecord.f_note,17,2) AS f_WarnType, 
t_d_CardRecord.f_CardRecordID, t_d_CardRecord.f_CardNO, t_d_CardRecord.f_ReadDate, t_d_CardRecord.f_Character, t_d_CardRecord.f_ReaderID, t_d_CardRecord.f_ConsumerID
FROM t_d_CardRecord
END
else
BEGIN
SELECT DISTINCT 
substring(t_d_CardRecord.f_note,17,2) AS f_WarnType, 
t_d_CardRecord.f_CardRecordID, t_d_CardRecord.f_CardNO, t_d_CardRecord.f_ReadDate, t_d_CardRecord.f_Character, t_d_CardRecord.f_ReaderID, t_d_CardRecord.f_ConsumerID
FROM t_d_CardRecord
WHERE  ([f_ReadDate]<=Convert(datetime,@endDateTime))
END

END




GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByTimeRecID    Script Date: 2006-4-29 12:23:49 ******/

/****** Object:  Stored Procedure dbo.sp_wg_GetCardRecordByTimeRecID    Script Date: 2006-4-29 12:19:16 ******/

create proc sp_wg_GetCardRecordByTimeRecID
	@startRecID integer,
	@endRecID integer,
        @startDateTime nvarchar(255),
        @endDateTime nvarchar(255)
        
as
if isdate(@startDateTime)>0
BEGIN
if isdate(@endDateTime)>0
BEGIN
SELECT DISTINCT 
substring(t_d_CardRecord.f_note,17,2) AS f_WarnType, 
t_d_CardRecord.f_CardRecordID, t_d_CardRecord.f_CardNO, t_d_CardRecord.f_ReadDate, t_d_CardRecord.f_Character, t_d_CardRecord.f_ReaderID, t_d_CardRecord.f_ConsumerID
FROM t_d_CardRecord
WHERE ((t_d_CardRecord.f_CardRecordID)>=(@startRecID) And (t_d_CardRecord.f_CardRecordID)<=(@endRecID)) 
AND ([f_ReadDate]>=Convert(datetime,@startDateTime))
END
else
BEGIN
SELECT DISTINCT 
substring(t_d_CardRecord.f_note,17,2) AS f_WarnType, 
t_d_CardRecord.f_CardRecordID, t_d_CardRecord.f_CardNO, t_d_CardRecord.f_ReadDate, t_d_CardRecord.f_Character, t_d_CardRecord.f_ReaderID, t_d_CardRecord.f_ConsumerID
FROM t_d_CardRecord
WHERE ((t_d_CardRecord.f_CardRecordID)>=(@startRecID) And (t_d_CardRecord.f_CardRecordID)<=(@endRecID)) 
AND ([f_ReadDate]>=Convert(datetime,@startDateTime))
AND ([f_ReadDate]<=Convert(datetime,@endDateTime));
END
END
else
BEGIN
if isdate(@endDateTime)>0
BEGIN
SELECT DISTINCT 
substring(t_d_CardRecord.f_note,17,2) AS f_WarnType, 
t_d_CardRecord.f_CardRecordID, t_d_CardRecord.f_CardNO, t_d_CardRecord.f_ReadDate, t_d_CardRecord.f_Character, t_d_CardRecord.f_ReaderID, t_d_CardRecord.f_ConsumerID
FROM t_d_CardRecord
WHERE ((t_d_CardRecord.f_CardRecordID)>=(@startRecID) And (t_d_CardRecord.f_CardRecordID)<=(@endRecID)) 
END
else
BEGIN
SELECT DISTINCT 
substring(t_d_CardRecord.f_note,17,2) AS f_WarnType, 
t_d_CardRecord.f_CardRecordID, t_d_CardRecord.f_CardNO, t_d_CardRecord.f_ReadDate, t_d_CardRecord.f_Character, t_d_CardRecord.f_ReaderID, t_d_CardRecord.f_ConsumerID
FROM t_d_CardRecord
WHERE ((t_d_CardRecord.f_CardRecordID)>=(@startRecID) And (t_d_CardRecord.f_CardRecordID)<=(@endRecID)) 
AND ([f_ReadDate]<=Convert(datetime,@endDateTime))
END

END




GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO

/****** Object:  Stored Procedure dbo.sp_wg_GetQueryGroupUser    Script Date: 2006-4-29 12:23:49 ******/

/****** Object:  Stored Procedure dbo.sp_wg_GetQueryGroupUser    Script Date: 2006-4-29 12:19:16 ******/

create proc sp_wg_GetQueryGroupUser
        @groupName nvarchar(255),
        @userId  nvarchar(255)
as

if @groupName='000' 
BEGIN
	if @userID='000' 
	BEGIN
--ALL
SELECT v_b_ConsumerIDCard.f_ConsumerID, v_b_ConsumerIDCard.f_ConsumerNO, v_b_ConsumerIDCard.f_WorkNo, v_b_ConsumerIDCard.f_ConsumerName, v_b_ConsumerIDCard.f_AttendEnabled, v_b_ConsumerIDCard.f_GroupName
FROM v_b_ConsumerIDCard
	END
	ELSE
	BEGIN
SELECT v_b_ConsumerIDCard.f_ConsumerID, v_b_ConsumerIDCard.f_ConsumerNO, v_b_ConsumerIDCard.f_WorkNo, v_b_ConsumerIDCard.f_ConsumerName, v_b_ConsumerIDCard.f_AttendEnabled, v_b_ConsumerIDCard.f_GroupName
FROM v_b_ConsumerIDCard
WHERE [v_b_ConsumerIDCard].[f_ConsumerID]=Convert(integer,@userID)
END
END
else
BEGIN
if @userID='000' 
BEGIN
--
SELECT v_b_ConsumerIDCard.f_ConsumerID, v_b_ConsumerIDCard.f_ConsumerNO, v_b_ConsumerIDCard.f_WorkNo, v_b_ConsumerIDCard.f_ConsumerName, v_b_ConsumerIDCard.f_AttendEnabled, v_b_ConsumerIDCard.f_GroupName
FROM v_b_ConsumerIDCard
WHERE ([f_GroupName]=@groupName) Or ([f_GroupName] Like (@groupName + '\%')) 
END
ELSE
BEGIN
SELECT v_b_ConsumerIDCard.f_ConsumerID, v_b_ConsumerIDCard.f_ConsumerNO, v_b_ConsumerIDCard.f_WorkNo, v_b_ConsumerIDCard.f_ConsumerName, v_b_ConsumerIDCard.f_AttendEnabled, v_b_ConsumerIDCard.f_GroupName
FROM v_b_ConsumerIDCard
WHERE [v_b_ConsumerIDCard].[f_ConsumerID]=Convert(integer,@userID)
AND ( ([f_GroupName]=@groupName) Or ([f_GroupName] Like (@groupName + '\%')) )
END

END



GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

/****** 对象:  用户定义的函数 dbo.fun_CompareTime    脚本日期: 2006-4-29 12:23:49 ******/

/****** 对象:  用户定义的函数 dbo.fun_CompareTime    脚本日期: 2006-4-29 12:19:16 ******/
CREATE FUNCTION fun_CompareTime ( @startDateTime nvarchar(255),    @endDateTime nvarchar(255))  
RETURNS INT 
AS  
begin
if (ISDATE(@startDateTime))=0 
	return 1;
if (ISDATE(@endDateTime))=0 
	return 1;
if Convert(datetime,@startDateTime)<=Convert(datetime,@endDateTime)
	return 1;
return 0
end



GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

/****** 对象:  用户定义的函数 dbo.fun_wg_GetCardRecordByTime    脚本日期: 2006-4-29 12:23:49 ******/

/****** 对象:  用户定义的函数 dbo.fun_wg_GetCardRecordByTime    脚本日期: 2006-4-29 12:19:16 ******/
CREATE FUNCTION fun_wg_GetCardRecordByTime (
        @startDateTime nvarchar(255),
        @endDateTime nvarchar(255))  
RETURNS TABLE 
AS  
RETURN( 
SELECT DISTINCT 
substring(t_d_CardRecord.f_note,17,2) AS f_WarnType, 
t_d_CardRecord.f_CardRecordID, t_d_CardRecord.f_CardNO, t_d_CardRecord.f_ReadDate, t_d_CardRecord.f_Character, t_d_CardRecord.f_ReaderID, t_d_CardRecord.f_ConsumerID
FROM t_d_CardRecord
WHERE  (ISDATE(@startDateTime)=0 or t_d_CardRecord.[f_ReadDate]>=Convert(datetime,isnull(@startDateTime,'1990-1-1')))
AND (ISDATE(@endDateTime)=0 or t_d_CardRecord.[f_ReadDate]<=Convert(datetime,isnull(@endDateTime,'2099-1-1')))

)


GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

/****** 对象:  用户定义的函数 dbo.fun_wg_GetCardRecordByTimeRecID    脚本日期: 2006-4-29 12:23:49 ******/

/****** 对象:  用户定义的函数 dbo.fun_wg_GetCardRecordByTimeRecID    脚本日期: 2006-4-29 12:19:16 ******/
CREATE FUNCTION fun_wg_GetCardRecordByTimeRecID ( @startRecID integer,
 @endRecID integer,
        @startDateTime nvarchar(255),
        @endDateTime nvarchar(255))  
RETURNS TABLE 
AS  
RETURN( 
SELECT DISTINCT 
substring(t_d_CardRecord.f_note,17,2) AS f_WarnType, 
t_d_CardRecord.f_CardRecordID, t_d_CardRecord.f_CardNO, t_d_CardRecord.f_ReadDate, t_d_CardRecord.f_Character, t_d_CardRecord.f_ReaderID, t_d_CardRecord.f_ConsumerID
FROM t_d_CardRecord
WHERE (t_d_CardRecord.f_CardRecordID>=@startRecID) And (t_d_CardRecord.f_CardRecordID<=@endRecID) 
AND (ISDATE(@startDateTime)=0 or t_d_CardRecord.[f_ReadDate]>=Convert(datetime,isnull(@startDateTime,'1990-1-1')))
AND (ISDATE(@endDateTime)=0 or t_d_CardRecord.[f_ReadDate]<=Convert(datetime,isnull(@endDateTime,'2099-1-1')))

)

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

/****** 对象:  用户定义的函数 dbo.fun_wg_GetQueryGroupUser    脚本日期: 2006-4-29 12:23:49 ******/

/****** 对象:  用户定义的函数 dbo.fun_wg_GetQueryGroupUser    脚本日期: 2006-4-29 12:19:16 ******/
CREATE FUNCTION fun_wg_GetQueryGroupUser ( 
        @groupName nvarchar(255),
        @userId  nvarchar(255)
)
RETURNS TABLE 
AS
RETURN (
SELECT v_b_ConsumerIDCard.f_ConsumerID, v_b_ConsumerIDCard.f_ConsumerNO, 
v_b_ConsumerIDCard.f_WorkNo, v_b_ConsumerIDCard.f_ConsumerName, v_b_ConsumerIDCard.f_AttendEnabled, v_b_ConsumerIDCard.f_GroupName
FROM v_b_ConsumerIDCard
WHERE (@groupName='000' or ([f_GroupName]=@groupName) Or ([f_GroupName] Like (RTRIM(@groupName) + '\%')))
AND (@userId='000' or [v_b_ConsumerIDCard].[f_ConsumerID]=Convert(integer,@userID)) 
)

GO

SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS ON 
GO


Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(1,'迟到多少分钟以内不算迟到','LateTimeout','5','单位是分钟 缺省是5分钟')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(2,'迟到多少分钟作旷工','LateAbsenceTimeout','120','单位是分钟 缺省是120分钟')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(3,'迟到作旷工的天数','LateAbsenceDay','0.5','单位是天, 缺省是半天')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(4,'提前多少分钟离开不算迟到','LeaveTimeout','5','单位是分钟 缺省是5分钟')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(5,'迟到多少分钟作旷工','LeaveAbsenceTimeout','120','单位是分钟 缺省是120分钟')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(6,'迟到作旷工的天数','LeaveAbsenceDay','0.5','单位是天, 缺省是半天[只有0,0.5,1] 0天，半天，1天')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(7,'下午下班多少分钟后打卡算加班','OvertimeTimeout','60','单位是分钟 缺省是60分钟')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(8,'两次刷卡上班时间0','OnDuty0','2004-07-18 08:30:00','上班时间0 缺省是8:30:00==只取用时间部分, 而日期只是为了整个操作方便')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(9,'两次刷卡下班时间0','OffDuty0','2004-07-18 17:30:00','下班时间0 缺省是17:30:00')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(10,'四次刷卡上班时间1','OnDuty1','2004-07-18 08:30:00','上班时间1 缺省是08:30:00')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(11,'四次刷卡下班时间1','OffDuty1','2004-07-18 12:00:00','下班时间1 缺省是12:00:00')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(12,'四次刷卡上班时间2','OnDuty2','2004-07-18 13:30:00','上班时间2 缺省是13:30:00')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(13,'四次刷卡下班时间2','OffDuty2','2004-07-18 17:30:00','下班时间2 缺省是17:30:00')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(14,'每天刷卡次数','EveryDayReadCardTimes','2','缺省是2次，采用两次刷卡上班时间,采用Duty0设置。另一个是四次，采用Duty1,Duty2设置')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(15,'考勤报表生成日志','LogCreateReport','','')
Insert Into t_a_Attendence(f_No,f_Name,f_EName,f_Value,f_Notes) Values(16,'两次刷卡最小间隔','twoReadMintime','60','缺省是60秒, V8')

Insert Into t_a_Holiday(f_Name,f_EName,f_Value,f_Value1,f_Value2,f_Value3,f_Type,f_Note) Values('Sat.','Saturday','0','','','','1','缺省休息， 0=表示休息，1=表示上午上班，2=表示下午上班，3=表示上正常班')
Insert Into t_a_Holiday(f_Name,f_EName,f_Value,f_Value1,f_Value2,f_Value3,f_Type,f_Note) Values('Sun.','Sunday','0','','','','1','缺省休息， 0=表示休息，1=表示上午上班，2=表示下午上班，3=表示上正常班')

Insert Into t_a_HolidayType(f_HolidayType) Values('Business Trip')
Insert Into t_a_HolidayType(f_HolidayType) Values('Sick Leave')
Insert Into t_a_HolidayType(f_HolidayType) Values('Private Leave')

Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(1,'LateTimeout','5','V13-OK 迟到多少分钟以内不算迟到 单位是分钟 缺省是5分钟')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(2,'LateAbsenceTimeout','120','V13-UNUSED 迟到多少分钟作旷工 单位是分钟 缺省是120分钟')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(3,'LateAbsenceDay','0.5','V13XX 迟到作旷工的天数 单位是天, 缺省是半天')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(4,'LeaveTimeout','5','V13 提前多少分钟离开不算迟到 单位是分钟 缺省是5分钟')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(5,'LeaveAbsenceTimeout','120','V13-UNUSED 迟到多少分钟作旷工 单位是分钟 缺省是120分钟')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(6,'LeaveAbsenceDay','0.5','V13XX 迟到作旷工的天数 单位是天, 缺省是半天[只有0,0.5,1] 0天，半天，1天')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(7,'OvertimeTimeout','60','V13 下午下班多少分钟后打卡算加班 单位是分钟 缺省是60分钟')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(8,'OnDuty0','2004-07-18 08:30:00','V13XX 两次刷卡上班时间0 上班时间0 缺省是8:30:00==只取用时间部分, 而日期只是为了整个操作方便')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(9,'OffDuty0','2004-07-18 17:30:00','V13XX 两次刷卡下班时间0 下班时间0 缺省是17:30:00')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(10,'OnDuty1','2004-07-18 08:30:00','V13XX 四次刷卡上班时间1 上班时间1 缺省是08:30:00')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(11,'OffDuty1','2004-07-18 12:00:00','V13XX 四次刷卡下班时间1 下班时间1 缺省是12:00:00')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(12,'OnDuty2','2004-07-18 13:30:00','V13XX 四次刷卡上班时间2 上班时间2 缺省是13:30:00')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(13,'OffDuty2','2004-07-18 17:30:00','V13XX 四次刷卡下班时间2 下班时间2 缺省是17:30:00')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(14,'EveryDayReadCardTimes','2','V13XX 每天刷卡次数 缺省是2次，采用两次刷卡上班时间,采用Duty0设置。另一个是四次，采用Duty1,Duty2设置')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(15,'LogCreateReport','','')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(16,'twoReadMintime','60','V13-OK 两次刷卡最小间隔 缺省是60秒')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(17,'AheadMinutesOnDutyFirst','60','V13-OK 17最早上班可提早的分钟, 缺省60分钟')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(18,'AheadMinutes','60','V13-OK 18普通可提早的分钟, 缺省60分钟')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(19,'DelayMinutes','60','V13-OK 19可推迟的分钟, 缺省60分钟')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(20,'OvertimeMinutes','360','V13-OK 20可加班的最大时间长度[分钟], 缺省360分钟[相当于6小时]')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(21,'tBTowNotReadAsAbsence','0','V13-UNUSED 21上下班两次都未读卡则作为旷工, 时间以计划时间差为准, 缺省是0, 否则设为1')
Insert Into t_a_Shift_Attendence(f_NO,f_EName,f_Value,f_Notes) Values(22,'minShifDiffByMinute','5','V13-UNUSED 22最小的班次点的时间间隔, 缺省是5分钟')

Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(9,'Database Version','dbVersion','18','')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(10,'Communication Cycle','commInterval','100','V3--100')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(11,'Default Port1','COMPORT','1','V3')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(12,'PD','2005-01-06','0','produce')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(13,'Comm. Timeout','CommTimeOut','1000','缺省是1秒[1000ms]')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(14,'Comm. Tries','Tries','2','一般是2次')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(15,'Comm. Try Interval','TryInterval','500','100ms')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(16,'Watch Cycle','WatchCycle','500','500ms对单台设备信息更新速度')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(17,'Custom Title.','CustomTitle','','个性化的公司标题[不能超过25个汉字]')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(18,'Default Port2','STR_COMPORT','COM1','V4 串口默认项,用于缺省时处理')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(19,'Watch Comm. Timeout','WatchTimeOut','300','V5-缺省是300ms')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(20,'Watch Comm. Tries','WatchTries','2','V5-缺省是2次')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(21,'Watch Try Interval','WatchTryInterval','100','V5--100ms')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(22,'Watch Pricture Size Enlarge','WatchPictureSizeEnlarge','0.6','V6 缺省倍数调为0.6 V5 ''监控时的显示图标--缺省是倍数为1')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(23,'Watch Door Interval','WatchDoorDelay','300','V5--缺省为不停止, 否则等待一段时间, 主要用在单客户的直接串口访问中[2004/8/28]')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(24,'Threat Password','ForcePassword','889988','V5--可以修改, 但不能为空, 缺省为889988')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(25,'Retry Cycle if Not Connected','NotConnectedRetryInterval','2','V8 表示2个循环试一次')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(26,'try times if Not Connected','NotConnectedTries','2','V8')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(27,'Timeout For Patrol-Absent','TimeoutForPatrolAbsence','30','V9 巡检用,默认值超过30分钟作漏检')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(28,'Timeout For Patrol','TimeoutForPatrol','10','V9 巡检用,超过10分钟作早到或迟到, 10分钟之内为正常')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(29,'Logging Create Patrol Report','LogCreatePatrolReport','','')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(30,'Application Version','Application Version','','V9 当前使用的应用软件版本')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(31,'Application Type','Application Type','4Office','V9 应用软件类型 4Office=办公门禁考勤,4Building=小区出入管理')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(32,'Controller Comm Delay','Controller Comm Delay','0','V9 控制器通信延时,单位是ms, 默认是0ms, 最大不能超过128ms')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(33,'Work Start Time','Work Start Time','2006-4-28 8:00:00','停用 V10 白天开始时间,默认是8:00:00')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(34,'Work End Time','Work End Time','2006-4-28 18:00:00','停用 V10 白天结束时间,默认是18:00:00')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(35,'Backup Director','Backup Director','','V10 备份目录, 主要用作备份数据到另一台机器上')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(36,'Company Name','Company Name','','')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(37,'Shared','Shared','','V12 Shared, 缺省=""没有共享, 1=表示共享')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(38,'System Information','System Information','V13','V13')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(39,'TCPIP Overtime','TCPIP Overtime','120','V15 默认是120秒, 不能少于30秒')
Insert Into t_a_SystemParam(f_No,f_Name,f_EName,f_Value,f_Notes) Values(40,'Open Door Overtime','Open Door Overtime','25','V15 默认是25秒, 不能大于6553秒')
                                                                                
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(1,'Activate Time Profile',0,'','1表示启用, 0表示不启用. 缺省全为0--扩展之一')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(2,'Batch Privilege Manager',0,'','是否显示管理界面--不放入')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(3,'Remote Open',0,'','RemoteOpen作为扩展功能--扩展之一')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(4,'Set Control State',0,'','直接对门进行在线, 常开,常闭操作--扩展之一')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(5,'Need Download',0,'','用户修改控制器配置和权限后, 出提示告之用户要上传. 用户执行上传操作后或点击按钮后, 此位复位')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(6,'Keypad',0,'','显示出密码键盘功能--扩展之一')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(7,'Activate Anti-Passback/InterLock/Alarm/More Cards',0,'','作为扩展功能--扩展之一')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(8,'Operator Mode',0,'','主要实现不同的管理员权限--扩展之一')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(9,'Activate Fire or Link Warn',0,'','1表示启用,0表示不启用--V5')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(10,'Display Alarm',0,'','--V5')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(11,'Display Error',0,'','--V5')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(12,'Log Run Time Info\',0,'','主要是实时监控中的运行信息--V5')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(13,'Log Button Event',0,'','--V5')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(14,'Log Alarm Event',0,'','--V5')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(15,'Activate Task List',0,'','V5 启用控制器定时任务')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(16,'Activate Controller Password',0,'','V5 启用开门密码[只用密码就可开门]')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(17,'Activate Log Query',0,'','V6 查询日志和运行信息')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(18,'Activate TCPIP',0,'','V8')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(19,'Activate Patrol',0,'','V9 巡检')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(20,'Activate AutoGetRecord',0,'','V9 启用定时提取记录')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(21,'Activate ZipBeforeExit',1,'','V9 退出时自动压缩和修复数据库, 默认是启用')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(22,'Access Control',1,'','V9 显示门禁功能菜单, 默认是启用')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(23,'Attendance',1,'','V9 显示考勤功能菜单, 默认是启用')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(24,'IF More Cards Enabled,Need For Going Out',0,'','V10  多卡开门的一个选项. 缺省是=0 进门多卡,出门单卡')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(25,'Activate No Password for special time',0,'','V10  启用指定时间段无须密码. 缺省是=0')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(26,'No Absent',0,'','V12  考勤不要有旷工. 缺省=0,有旷工')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(27,'Activate Shift',0,'','V13  倒班. 缺省=0 不启用')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(28,'Activate AntiBack',0,'','V14  反潜回. 缺省=0 不启用')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(29,'Activate InterLock',0,'','V14 多门互锁. 缺省=0 不启用')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(30,'Activate Warn',0,'','V14  报警.消防联动 . 缺省=0 不启用')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(31,'Activate MoreCards',0,'','V14  多卡开门. 缺省=0 不启用')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(32,'Activate Auto Upload Privilege',0,'','V15 启用定时上传权限')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(33,'Activate First Card Open',0,'','V16 启用首卡开门')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(34,'Activate Open by Inputing "Cardno+Password"',0,'','V16启用输入"ESC+卡号+ESC+密码+ENT"开门')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(35,'Activate Map',0,'','V16启用电子地图')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(36,'Log Door Status',0,'','V16启用记录门开, 门关')
Insert Into t_s_FunctionOption(f_No,f_Name,f_Value,f_StrValue,f_Note) Values(37,'Controller Comm Password',0,'','V17 启用控制器通信密码管理')

Insert Into t_s_Operator(f_OperatorName,f_Password,f_Privilege,f_Notes) Values('abc','123','Super Manager','不能删除和修改权限级别，可以改名和密码')

Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmControllers','Controllers',1,1,1,2,1,'高级管理才能全控[添加修改]')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmGroups','Department',1,1,1,0,2,'部门班组')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmConsumers','Personnel',1,1,1,0,3,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmControlSegs','TimeProfile',1,1,1,0,21,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmPrivilege','Access Privilege',1,1,1,0,22,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'dfrmWorkShedule','Normal working schedule',1,1,1,0,31,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'dfrmHolidaySet','Holiday',1,1,1,0,32,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmLeave','Leave/Business Trip',1,1,1,0,33,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmManualCardRecords','Manual Sign IN',1,1,1,0,34,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmTotalControl','Console',1,1,1,1,41,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmDoorInfo','Door Information',1,1,1,0,42,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmAdjustTime','Adjust Time',1,1,1,1,43,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmSend','Download',1,1,1,1,44,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmWatch','Realtime Monitoring',1,1,1,0,45,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmGetCardRecords','Collect Data',1,1,1,0,46,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmCardRecords','Query Records',1,1,1,0,47,'完全控制与只读一样， 无特殊')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmAttendenceData','Attendance details',1,1,1,0,51,'只读时不具有生成报表功能，完全控制时才有生成功能')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmAttStatistic','Attendance Statistics',1,1,1,0,52,'只读时不具有生成报表功能，完全控制时才有生成功能')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'dfrmCardLostRegister','Lost card register',1,1,1,0,61,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'dfrmInputPassword','Change Password',1,1,1,0,62,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'dfrmOperators','Operator Management',1,1,1,2,63,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'dfrmDbCompact','Database compact & backup',1,1,1,0,64,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'dfrmDbDelCardRecord','Delete Card Record',1,1,1,2,65,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'dfrmOption','Extended Function',1,1,1,1,66,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'dfrmDbmanage','Database operation',1,1,1,2,67,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'dfrmShiftRule','Other Shift Rules',1,1,1,0,71,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmShiftSet','Other Shift Types',1,1,1,0,72,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmShiftData','Other Shift Schedule',1,1,1,0,73,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(0,'frmRemoteOpenDoor','Remote Openning Door',1,1,1,0,74,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmControllers','Controllers',1,1,1,2,1,'高级管理才能全控[添加修改]')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmGroups','Department',1,1,1,0,2,'部门班组')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmConsumers','Personnel',1,1,1,0,3,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmControlSegs','TimeProfile',1,1,1,0,21,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmPrivilege','Access Privilege',1,1,1,0,22,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'dfrmWorkShedule','Normal working schedule',1,1,1,0,31,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'dfrmHolidaySet','Holiday',1,1,1,0,32,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmLeave','Leave/Business Trip',1,1,1,0,33,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmManualCardRecords','Manual Sign IN',1,1,1,0,34,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmTotalControl','Console',1,1,1,1,41,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmDoorInfo','Door Information',1,1,1,0,42,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmAdjustTime','Adjust Time',1,1,1,1,43,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmSend','Download',1,1,1,1,44,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmWatch','Realtime Monitoring',1,1,1,0,45,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmGetCardRecords','Collect Data',1,1,1,0,46,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmCardRecords','Query Records',1,1,1,0,47,'完全控制与只读一样， 无特殊')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmAttendenceData','Attendance details',1,1,1,0,51,'只读时不具有生成报表功能，完全控制时才有生成功能')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmAttStatistic','Attendance Statistics',1,1,1,0,52,'只读时不具有生成报表功能，完全控制时才有生成功能')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'dfrmCardLostRegister','Lost card register',1,1,1,0,61,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'dfrmInputPassword','Change Password',1,1,1,0,62,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'dfrmOperators','Operator Management',1,1,1,2,63,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'dfrmDbCompact','Database compact & backup',1,1,1,0,64,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'dfrmDbDelCardRecord','Delete Card Record',1,1,1,2,65,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'dfrmOption','Extended Function',1,1,1,1,66,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'dfrmDbmanage','Database operation',1,1,1,2,67,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'dfrmShiftRule','Other Shift Rules',1,1,1,0,71,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmShiftSet','Other Shift Type',1,1,1,0,72,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmShiftData','Other Shift Schedule',1,1,1,0,73,'')
Insert Into t_s_OperatorMode(f_OperatorID,f_FunctionEName,f_FunctionName,f_Read,f_Write,f_FullControl,f_Type,f_SerialNo,f_Note) Values(1,'frmRemoteOpenDoor','Remote Openning Door',1,1,1,0,74,'')
