USE [book]
GO
/****** Object:  View [dbo].[v_booklist]    Script Date: 03/31/2012 12:08:48 ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[v_booklist]'))
DROP VIEW [dbo].[v_booklist]
GO
/****** Object:  Table [dbo].[book_booklist]    Script Date: 03/31/2012 12:08:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_book_booklist_createdate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[book_booklist] DROP CONSTRAINT [DF_book_booklist_createdate]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[book_booklist]') AND type in (N'U'))
DROP TABLE [dbo].[book_booklist]
GO
/****** Object:  Table [dbo].[book_cache]    Script Date: 03/31/2012 12:08:48 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[book_cache]') AND type in (N'U'))
DROP TABLE [dbo].[book_cache]
GO
/****** Object:  Table [dbo].[book_categories]    Script Date: 03/31/2012 12:08:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__book_cate__isdel__03317E3D]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[book_categories] DROP CONSTRAINT [DF__book_cate__isdel__03317E3D]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[book_categories]') AND type in (N'U'))
DROP TABLE [dbo].[book_categories]
GO
/****** Object:  Table [dbo].[book_log]    Script Date: 03/31/2012 12:08:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_book_log_datetime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[book_log] DROP CONSTRAINT [DF_book_log_datetime]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[book_log]') AND type in (N'U'))
DROP TABLE [dbo].[book_log]
GO
/****** Object:  Table [dbo].[book_schedular]    Script Date: 03/31/2012 12:08:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_book_schedular_ispop]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[book_schedular] DROP CONSTRAINT [DF_book_schedular_ispop]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[book_schedular]') AND type in (N'U'))
DROP TABLE [dbo].[book_schedular]
GO
/****** Object:  Table [dbo].[logos]    Script Date: 03/31/2012 12:08:47 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[logos]') AND type in (N'U'))
DROP TABLE [dbo].[logos]
GO
/****** Object:  Table [dbo].[users_dept]    Script Date: 03/31/2012 12:08:47 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_portal_category_parentid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_dept] DROP CONSTRAINT [DF_portal_category_parentid]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_portal_category_orderid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_dept] DROP CONSTRAINT [DF_portal_category_orderid]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_portal_category_depth]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_dept] DROP CONSTRAINT [DF_portal_category_depth]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_hr_csscategory_path]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_dept] DROP CONSTRAINT [DF_hr_csscategory_path]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_dept]') AND type in (N'U'))
DROP TABLE [dbo].[users_dept]
GO
/****** Object:  Table [dbo].[users_getpwd]    Script Date: 03/31/2012 12:08:47 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_getpwd_createdate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_getpwd] DROP CONSTRAINT [DF_users_getpwd_createdate]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_getpwd]') AND type in (N'U'))
DROP TABLE [dbo].[users_getpwd]
GO
/****** Object:  Table [dbo].[users_releation]    Script Date: 03/31/2012 12:08:47 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_releation]') AND type in (N'U'))
DROP TABLE [dbo].[users_releation]
GO
/****** Object:  Table [dbo].[users_roles]    Script Date: 03/31/2012 12:08:47 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_roles_issystem]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_roles] DROP CONSTRAINT [DF_users_roles_issystem]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_roles]') AND type in (N'U'))
DROP TABLE [dbo].[users_roles]
GO
/****** Object:  Table [dbo].[users_users]    Script Date: 03/31/2012 12:08:47 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_portal_users_createdate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_portal_users_createdate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_portal_users_lastlogin]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_portal_users_lastlogin]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_avtor]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_avtor]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_logintime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_logintime]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_logintime_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_logintime_1]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_ismgr]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_ismgr]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_issec]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_issec]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_isstaff]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_isstaff]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_users]') AND type in (N'U'))
DROP TABLE [dbo].[users_users]
GO
/****** Object:  Table [dbo].[users_usersinroles]    Script Date: 03/31/2012 12:08:47 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_usersinroles]') AND type in (N'U'))
DROP TABLE [dbo].[users_usersinroles]
GO
/****** Object:  User [book]    Script Date: 03/31/2012 12:08:47 ******/
IF  EXISTS (SELECT * FROM sys.database_principals WHERE name = N'book')
DROP USER [book]
GO
/****** Object:  User [book]    Script Date: 03/31/2012 12:08:47 ******/
IF NOT EXISTS (SELECT * FROM sys.database_principals WHERE name = N'book')
CREATE USER [book] WITHOUT LOGIN WITH DEFAULT_SCHEMA=[dbo]
GO
/****** Object:  Table [dbo].[users_usersinroles]    Script Date: 03/31/2012 12:08:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_usersinroles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_usersinroles](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NULL,
	[rolename] [nvarchar](50) NULL,
 CONSTRAINT [PK_portal_usersinroles] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[users_usersinroles] ON
INSERT [dbo].[users_usersinroles] ([id], [uid], [rolename]) VALUES (1, 1, N'Administrators')
INSERT [dbo].[users_usersinroles] ([id], [uid], [rolename]) VALUES (2, 4, N'Administrators')
SET IDENTITY_INSERT [dbo].[users_usersinroles] OFF
/****** Object:  Table [dbo].[users_users]    Script Date: 03/31/2012 12:08:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_users]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_users](
	[uid] [int] IDENTITY(1,1) NOT NULL,
	[username] [nvarchar](256) NOT NULL,
	[adpath] [nvarchar](1024) NULL,
	[firstname] [nvarchar](50) NULL,
	[lastname] [nvarchar](50) NULL,
	[city] [nvarchar](256) NULL,
	[Office] [nvarchar](256) NULL,
	[Description] [nvarchar](1024) NULL,
	[Tel] [nvarchar](128) NULL,
	[fax] [nvarchar](128) NULL,
	[email] [nvarchar](256) NULL,
	[MailType] [nvarchar](128) NULL,
	[Title] [nvarchar](128) NULL,
	[Department] [nvarchar](128) NULL,
	[Company] [nvarchar](128) NULL,
	[Password] [nvarchar](128) NULL,
	[displayname] [nvarchar](128) NULL,
	[StaffCode] [nvarchar](128) NULL,
	[IsAccountActive] [int] NULL,
	[createdate] [datetime] NULL CONSTRAINT [DF_portal_users_createdate]  DEFAULT (getdate()),
	[lastlogin] [datetime] NULL CONSTRAINT [DF_portal_users_lastlogin]  DEFAULT (getdate()),
	[sex] [nvarchar](50) NULL,
	[avtor] [nvarchar](300) NULL CONSTRAINT [DF_users_users_avtor]  DEFAULT ('avtor.jpg'),
	[logintimes] [int] NULL CONSTRAINT [DF_users_users_logintime]  DEFAULT ((0)),
	[ip] [nvarchar](50) NULL,
	[logintime] [int] NULL CONSTRAINT [DF_users_users_logintime_1]  DEFAULT ((0)),
	[intro] [nvarchar](500) NULL,
	[ismgr] [int] NULL CONSTRAINT [DF_users_users_ismgr]  DEFAULT ((0)),
	[issec] [int] NULL CONSTRAINT [DF_users_users_issec]  DEFAULT ((0)),
	[isstaff] [int] NULL CONSTRAINT [DF_users_users_isstaff]  DEFAULT ((1)),
 CONSTRAINT [PK_portal_users_1] PRIMARY KEY CLUSTERED 
(
	[uid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[users_users] ON
INSERT [dbo].[users_users] ([uid], [username], [adpath], [firstname], [lastname], [city], [Office], [Description], [Tel], [fax], [email], [MailType], [Title], [Department], [Company], [Password], [displayname], [StaffCode], [IsAccountActive], [createdate], [lastlogin], [sex], [avtor], [logintimes], [ip], [logintime], [intro], [ismgr], [issec], [isstaff]) VALUES (1, N'admin', NULL, NULL, NULL, NULL, N'北京', NULL, N'15001712100', N'123456', N'983506039@qq.com', NULL, N'', N'HR', NULL, N'CE-0B-FD-15-05-9B-68-D6-76-88-88-4D-7A-3D-3E-8C', N'管理员', N'', NULL, CAST(0x00009E4C013FE373 AS DateTime), CAST(0x0000A025009A4F2A AS DateTime), N'', N'images/avtor.jpg', 56, N'127.0.0.1', 0, N'我是管理员，负责网络', 0, 0, 1)
INSERT [dbo].[users_users] ([uid], [username], [adpath], [firstname], [lastname], [city], [Office], [Description], [Tel], [fax], [email], [MailType], [Title], [Department], [Company], [Password], [displayname], [StaffCode], [IsAccountActive], [createdate], [lastlogin], [sex], [avtor], [logintimes], [ip], [logintime], [intro], [ismgr], [issec], [isstaff]) VALUES (2, N'里小姐', NULL, NULL, NULL, NULL, N'', NULL, N'', N'', N'11@11.11', NULL, N'', N'', NULL, N'70-66-A4-0F-42-77-69-CC-43-34-7A-A9-6B-72-93-1A', N'里小姐', N'', NULL, CAST(0x00009FBD01306020 AS DateTime), CAST(0x00009FBD01306020 AS DateTime), N'', N'images/avtor.jpg', 0, N'::1', 0, N'', 0, 0, 1)
INSERT [dbo].[users_users] ([uid], [username], [adpath], [firstname], [lastname], [city], [Office], [Description], [Tel], [fax], [email], [MailType], [Title], [Department], [Company], [Password], [displayname], [StaffCode], [IsAccountActive], [createdate], [lastlogin], [sex], [avtor], [logintimes], [ip], [logintime], [intro], [ismgr], [issec], [isstaff]) VALUES (3, N'manages', NULL, NULL, NULL, NULL, N'', NULL, N'', N'', N'dd@qqq.ddd', NULL, N'', N'', NULL, N'FE-AD-05-2E-EE-DC-FB-31-C4-9B-19-F9-1E-DD-ED-24', N'manages', N'', NULL, CAST(0x00009FBF00A310B2 AS DateTime), CAST(0x00009FBF00A310B2 AS DateTime), N'', N'images/avtor.jpg', 0, N'192.168.1.101', 0, N'', 0, 0, 1)
SET IDENTITY_INSERT [dbo].[users_users] OFF
/****** Object:  Table [dbo].[users_roles]    Script Date: 03/31/2012 12:08:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_roles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_roles](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[rolename] [nvarchar](50) NULL,
	[issystem] [int] NULL CONSTRAINT [DF_users_roles_issystem]  DEFAULT ((0)),
	[roletype] [nvarchar](50) NULL,
 CONSTRAINT [PK_users_roles] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[users_roles] ON
INSERT [dbo].[users_roles] ([id], [rolename], [issystem], [roletype]) VALUES (1, N'Administrators', 1, N'')
INSERT [dbo].[users_roles] ([id], [rolename], [issystem], [roletype]) VALUES (4, N'audit', 1, NULL)
INSERT [dbo].[users_roles] ([id], [rolename], [issystem], [roletype]) VALUES (5, N'users', 0, N'')
INSERT [dbo].[users_roles] ([id], [rolename], [issystem], [roletype]) VALUES (6, N'前台', 0, N'')
INSERT [dbo].[users_roles] ([id], [rolename], [issystem], [roletype]) VALUES (7, N'vip', 0, N'')
SET IDENTITY_INSERT [dbo].[users_roles] OFF
/****** Object:  Table [dbo].[users_releation]    Script Date: 03/31/2012 12:08:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_releation]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_releation](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[mgrid] [int] NULL,
	[secid] [int] NULL,
 CONSTRAINT [PK_users_releation] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[users_releation] ON
INSERT [dbo].[users_releation] ([id], [mgrid], [secid]) VALUES (5, 7, 8)
SET IDENTITY_INSERT [dbo].[users_releation] OFF
/****** Object:  Table [dbo].[users_getpwd]    Script Date: 03/31/2012 12:08:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_getpwd]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_getpwd](
	[id] [int] NOT NULL,
	[uid] [int] IDENTITY(1,1) NOT NULL,
	[display] [nvarchar](50) NULL,
	[createdate] [datetime] NULL CONSTRAINT [DF_users_getpwd_createdate]  DEFAULT (getdate()),
 CONSTRAINT [PK_users_getpwd] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[users_dept]    Script Date: 03/31/2012 12:08:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_dept]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_dept](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[catname] [nvarchar](50) NULL,
	[parentid] [int] NULL CONSTRAINT [DF_portal_category_parentid]  DEFAULT ((0)),
	[orderid] [int] NULL CONSTRAINT [DF_portal_category_orderid]  DEFAULT ((0)),
	[depth] [int] NULL CONSTRAINT [DF_portal_category_depth]  DEFAULT ((1)),
	[note] [nvarchar](200) NULL,
	[path] [nvarchar](1000) NULL CONSTRAINT [DF_hr_csscategory_path]  DEFAULT (''),
	[types] [nvarchar](50) NULL,
 CONSTRAINT [PK_users_dept] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[users_dept] ON
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (1, N'公司部门', 0, 0, 1, N'', N'', N'dept')
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (2, N'管理部', 1, 0, 1, N'', N'A', N'dept')
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (3, N'制造部', 1, 0, 1, N'', N'B', N'dept')
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (4, N'人事部', 2, 0, 1, N'', N'AA', N'dept')
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (5, N'行政部', 2, 0, 1, N'', N'AB', N'dept')
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (6, N'IT部门', 2, 0, 1, N'', N'AC', N'dept')
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (7, N'环境部', 3, 0, 1, N'', N'BA', N'dept')
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (8, N'生产部', 3, 0, 1, N'', N'BB', N'dept')
SET IDENTITY_INSERT [dbo].[users_dept] OFF
/****** Object:  Table [dbo].[logos]    Script Date: 03/31/2012 12:08:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[logos]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[logos](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[logopath] [nvarchar](50) NULL,
 CONSTRAINT [PK_logos] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[logos] ON
INSERT [dbo].[logos] ([id], [logopath]) VALUES (1, N'~/uploads/20110705173035.JPG')
INSERT [dbo].[logos] ([id], [logopath]) VALUES (2, N'~/uploads/20110706133910.JPG')
SET IDENTITY_INSERT [dbo].[logos] OFF
/****** Object:  Table [dbo].[book_schedular]    Script Date: 03/31/2012 12:08:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[book_schedular]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[book_schedular](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[begintime] [datetime] NULL,
	[endtime] [datetime] NULL,
	[uid] [int] NULL,
	[meetingid] [int] NULL,
	[title] [nvarchar](500) NULL,
	[ispop] [int] NULL CONSTRAINT [DF_book_schedular_ispop]  DEFAULT ((1)),
 CONSTRAINT [PK__book_schedular__07F6335A] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[book_schedular] ON
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (1, CAST(0x00009F17011826C0 AS DateTime), CAST(0x00009F170128A180 AS DateTime), 1, 1, N'6(15001712100) 6 预定了会议室邀请您参加:', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (2, CAST(0x00009F18009450C0 AS DateTime), CAST(0x00009F1800A4CB80 AS DateTime), 1, 2, N'6(15001712100) 6 预定了会议室邀请您参加:test', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (3, CAST(0x00009F1800CDFE60 AS DateTime), CAST(0x00009F1800DE7920 AS DateTime), 1, 3, N'6(15001712100) 6 预定了会议室邀请您参加:tests2', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (4, CAST(0x00009F1800F73140 AS DateTime), CAST(0x00009F180107AC00 AS DateTime), 1, 4, N'HR(15001712100) HR 预定了会议室邀请您参加:test', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (5, CAST(0x00009F1800DE7920 AS DateTime), CAST(0x00009F1800EEF3E0 AS DateTime), 1, 5, N'HR(15001712100) HR 预定了会议室邀请您参加:test', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (6, CAST(0x00009F180128A180 AS DateTime), CAST(0x00009F1801391C40 AS DateTime), 1, 6, N'HR(15001712100) HR 预定了会议室邀请您参加:test', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (7, CAST(0x00009F1900C5C100 AS DateTime), CAST(0x00009F1900DE7920 AS DateTime), 1, 7, N'HR(15001712100) HR 预定了会议室邀请您参加:', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (8, CAST(0x00009F1A0107AC00 AS DateTime), CAST(0x00009F1A011826C0 AS DateTime), 1, 8, N'人力资源部(15001712100) 人力资源部 预定了会议室邀请您参加:内部培训用', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (9, CAST(0x00009F1A011826C0 AS DateTime), CAST(0x00009F1A0128A180 AS DateTime), 1, 9, N'HR(15001712100) HR 预定了会议室邀请您参加:test', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (10, CAST(0x00009F1F00B54640 AS DateTime), CAST(0x00009F1F00C5C100 AS DateTime), 1, 10, N'HR(15001712100) HR 预定了会议室邀请您参加:test', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (11, CAST(0x00009FBC0083D600 AS DateTime), CAST(0x00009FBC009450C0 AS DateTime), 1, 11, N'HR(15001712100) HR 预定了会议室邀请您参加:test', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (12, CAST(0x00009FBC00B54640 AS DateTime), CAST(0x00009FBC00C5C100 AS DateTime), 1, 12, N'人事部(15001712100) 人事部 预定了会议室邀请您参加:新员工入职培训', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (13, CAST(0x00009FBC00A4CB80 AS DateTime), CAST(0x00009FBC00B54640 AS DateTime), 1, 13, N'人事部(15001712100) 人事部 预定了会议室邀请您参加:内部培训使用', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (14, CAST(0x00009FBC00C5C100 AS DateTime), CAST(0x00009FBC00D63BC0 AS DateTime), 1, 14, N'管理部(15001712100) 管理部 预定了会议室邀请您参加:计算机等级内部培训', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (15, CAST(0x00009FBC00D63BC0 AS DateTime), CAST(0x00009FBC00E6B680 AS DateTime), 1, 15, N'人事部(15001712100) 人事部 预定了会议室邀请您参加:员工内部培训', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (16, CAST(0x00009FBC0128A180 AS DateTime), CAST(0x00009FBC01391C40 AS DateTime), 1, 16, N'HR(15001712100) HR 预定了会议室邀请您参加:员工培训惊声尖用', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (17, CAST(0x00009FBD00DE7920 AS DateTime), CAST(0x00009FBD00EEF3E0 AS DateTime), 1, 17, N'HR(15001712100) HR 预定了会议室邀请您参加:eee', 0)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (18, CAST(0x00009FBE00F73140 AS DateTime), CAST(0x00009FBE0107AC00 AS DateTime), 1, NULL, N'快快快', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (19, CAST(0x00009FBD00BD83A0 AS DateTime), CAST(0x00009FBD00DE7920 AS DateTime), 1, NULL, N'新事件', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (24, CAST(0x00009FBF00B54640 AS DateTime), CAST(0x00009FBF00C5C100 AS DateTime), 1, 19, N'人事部(15001712100) 人事部 预定了会议室邀请您参加:新员工入职会议', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (25, CAST(0x00009FBF009450C0 AS DateTime), CAST(0x00009FBF00A4CB80 AS DateTime), 1, 20, N'人事部(15001712100) 人事部 预定了会议室邀请您参加:新员工入职', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (26, CAST(0x00009FBF009450C0 AS DateTime), CAST(0x00009FBF00A4CB80 AS DateTime), 2, 20, N'人事部(15001712100) 人事部 预定了会议室邀请您参加:新员工入职', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (27, CAST(0x00009FBF009450C0 AS DateTime), CAST(0x00009FBF00A4CB80 AS DateTime), 1, 20, N'人事部(15001712100) 人事部 预定了会议室邀请您参加:新员工入职', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (28, CAST(0x00009FC701391C40 AS DateTime), CAST(0x00009FC701499700 AS DateTime), 1, 21, N'人事部(15001712100) 人事部 预定了会议室邀请您参加:内部培训', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (29, CAST(0x00009FC701499700 AS DateTime), CAST(0x00009FC7015A11C0 AS DateTime), 1, 22, N'HR(15001712100) HR 预定了会议室邀请您参加:内部培训', 1)
INSERT [dbo].[book_schedular] ([id], [begintime], [endtime], [uid], [meetingid], [title], [ispop]) VALUES (31, CAST(0x00009FDF00DE7920 AS DateTime), CAST(0x00009FDF00F73140 AS DateTime), 1, 23, N'HR(15001712100) HR 预定了会议室邀请您参加:test', 1)
SET IDENTITY_INSERT [dbo].[book_schedular] OFF
/****** Object:  Table [dbo].[book_log]    Script Date: 03/31/2012 12:08:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[book_log]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[book_log](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[username] [nvarchar](50) NULL,
	[ip] [nvarchar](50) NULL,
	[datetime] [datetime] NULL CONSTRAINT [DF_book_log_datetime]  DEFAULT (getdate()),
	[contents] [nvarchar](2000) NULL,
 CONSTRAINT [PK__book_log__1367E606] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[book_categories]    Script Date: 03/31/2012 12:08:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[book_categories]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[book_categories](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[catname] [nvarchar](50) NULL,
	[orderid] [int] NULL,
	[cattype] [nvarchar](50) NULL,
	[allowroles] [nvarchar](500) NULL,
	[isdelete] [int] NULL CONSTRAINT [DF__book_cate__isdel__03317E3D]  DEFAULT ((0)),
	[url] [nvarchar](500) NULL,
	[username] [nvarchar](50) NULL,
	[password] [nvarchar](50) NULL,
	[domain] [nvarchar](50) NULL,
	[hasprojector] [nvarchar](50) NULL,
	[haspc] [nvarchar](50) NULL,
	[hastc] [nvarchar](50) NULL,
	[hasvtc] [nvarchar](50) NULL,
	[num] [int] NULL,
	[numtext] [nvarchar](50) NULL,
	[flash] [nvarchar](100) NULL,
	[prev1] [nvarchar](50) NULL,
	[prev2] [nvarchar](50) NULL,
	[ip] [nvarchar](50) NULL,
 CONSTRAINT [PK__book_categories__023D5A04] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[book_categories] ON
INSERT [dbo].[book_categories] ([id], [catname], [orderid], [cattype], [allowroles], [isdelete], [url], [username], [password], [domain], [hasprojector], [haspc], [hastc], [hasvtc], [num], [numtext], [flash], [prev1], [prev2], [ip]) VALUES (1, N'xxxxx', 0, N'room', N'All Roles;Administrators;audit;users;前台;vip;', 0, N'/', NULL, NULL, NULL, N'1', N'0', N'0', N'0', 3, NULL, NULL, N'0', N'0', NULL)
SET IDENTITY_INSERT [dbo].[book_categories] OFF
/****** Object:  Table [dbo].[book_cache]    Script Date: 03/31/2012 12:08:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[book_cache]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[book_cache](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[subject] [nvarchar](1000) NULL,
	[location] [nvarchar](1000) NULL,
	[begintime] [datetime] NULL,
	[endtime] [datetime] NULL,
	[busystatus] [nvarchar](50) NULL,
	[href] [nvarchar](1000) NULL,
	[displayname] [nvarchar](500) NULL,
	[htmldescription] [nvarchar](max) NULL,
	[instancetype] [nvarchar](50) NULL,
	[roomid] [int] NULL,
	[guid] [nvarchar](50) NULL,
 CONSTRAINT [PK_book_cache] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[book_cache] ON
INSERT [dbo].[book_cache] ([id], [subject], [location], [begintime], [endtime], [busystatus], [href], [displayname], [htmldescription], [instancetype], [roomid], [guid]) VALUES (1, N'明天开会', N'', CAST(0x00009FDF00C5C100 AS DateTime), CAST(0x00009FDF00CDFE60 AS DateTime), N'BUSY', N'http://sopmail20.sol.shuion.com.cn/exchange/dream.li/Calendar/{6AA70906-B045-4875-9A5C-73E5DBAE4D3B}.EML', N'{6AA70906-B045-4875-9A5C-73E5DBAE4D3B}.EML', N'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.1">
<TITLE>明天开会</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>可以吗</FONT>
</P>

</BODY>
</HTML>', NULL, 25, N'dd2be4c7-d66b-48f9-a75d-edece3c0099f')
INSERT [dbo].[book_cache] ([id], [subject], [location], [begintime], [endtime], [busystatus], [href], [displayname], [htmldescription], [instancetype], [roomid], [guid]) VALUES (2, N'test', N'', CAST(0x00009FDE00B54640 AS DateTime), CAST(0x00009FDE00BD83A0 AS DateTime), N'BUSY', N'http://sopmail20.sol.shuion.com.cn/exchange/dream.li/Calendar/{64955884-77B3-47C1-962B-BE3C82307990}.EML', N'{64955884-77B3-47C1-962B-BE3C82307990}.EML', N'<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=utf-8">
<META NAME="Generator" CONTENT="MS Exchange Server version 6.5.7653.1">
<TITLE>test</TITLE>
</HEAD>
<BODY>
<!-- Converted from text/plain format -->

<P><FONT SIZE=2>这里是一个测试</FONT>
</P>

</BODY>
</HTML>', NULL, 25, N'dd2be4c7-d66b-48f9-a75d-edece3c0099f')
SET IDENTITY_INSERT [dbo].[book_cache] OFF
/****** Object:  Table [dbo].[book_booklist]    Script Date: 03/31/2012 12:08:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[book_booklist]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[book_booklist](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[username] [nvarchar](50) NULL,
	[createdate] [datetime] NULL CONSTRAINT [DF_book_booklist_createdate]  DEFAULT (getdate()),
	[bookdate] [datetime] NULL,
	[begintime] [datetime] NULL,
	[endtime] [datetime] NULL,
	[contactname] [nvarchar](50) NULL,
	[contactdept] [nvarchar](50) NULL,
	[contacttel] [nvarchar](50) NULL,
	[contactemail] [nvarchar](50) NULL,
	[numbers] [nvarchar](50) NULL,
	[intro] [nvarchar](500) NULL,
	[roomname] [nvarchar](500) NULL,
	[roomid] [nvarchar](50) NULL,
	[pcname] [nvarchar](50) NULL,
	[pcid] [nvarchar](50) NULL,
	[projectorname] [nvarchar](50) NULL,
	[projectorid] [nvarchar](50) NULL,
	[others1] [nvarchar](500) NULL,
	[others2] [nvarchar](500) NULL,
	[cc] [nvarchar](1000) NULL,
	[specialrequire] [nvarchar](500) NULL,
	[process] [nvarchar](50) NULL,
	[status] [nvarchar](50) NULL,
	[userid] [nvarchar](50) NULL,
	[welcomemessage] [nvarchar](300) NULL,
	[fontsize] [nvarchar](50) NULL,
	[fontcolor] [nvarchar](50) NULL,
	[logo] [nvarchar](200) NULL,
	[fontfamily] [nvarchar](50) NULL,
	[roomguid] [nvarchar](500) NULL,
	[pcguid] [nvarchar](500) NULL,
	[projectorguid] [nvarchar](500) NULL,
 CONSTRAINT [PK__book_booklist__7C8480AE] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  View [dbo].[v_booklist]    Script Date: 03/31/2012 12:08:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[v_booklist]'))
EXEC dbo.sp_executesql @statement = N'





CREATE VIEW [dbo].[v_booklist]
AS
SELECT     dbo.book_cache.id, dbo.book_cache.begintime, dbo.book_cache.endtime, dbo.book_cache.subject, dbo.book_categories.catname AS roomname, 
                      dbo.book_cache.roomid
FROM         dbo.book_cache LEFT OUTER JOIN
                      dbo.book_categories ON dbo.book_cache.roomid = dbo.book_categories.id
WHERE     (ISNULL(dbo.book_cache.begintime, N'''') <> '''') AND (dbo.book_cache.guid =
                          (SELECT     TOP (1) guid
                            FROM          dbo.book_cache AS book_cache_1
                            WHERE      (ISNULL(begintime, '''') <> '''')
                            ORDER BY id DESC))

'
GO
