if exists (select * from dbo.sysobjects where id = object_id(N'[SY_User]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [SY_User]
GO

CREATE TABLE [SY_User] (
	[UserID] [char] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[UserName] [char] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[PassWord] [varchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	[IdNo] [char] (18) COLLATE Chinese_PRC_CI_AS NULL ,
	[Address] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[Phone] [char] (40) COLLATE Chinese_PRC_CI_AS NULL ,
	[IsYwy] [bit] NOT NULL CONSTRAINT [DF__SY_User__IsYwy__18EBB532] DEFAULT (1),
	[EMail] [char] (50) COLLATE Chinese_PRC_CI_AS NULL ,
	[note] [nvarchar] (250) COLLATE Chinese_PRC_CI_AS NULL ,
	[Valid] [char] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	 PRIMARY KEY  CLUSTERED 
	(
		[UserID]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO


if exists (select * from dbo.sysobjects where id = object_id(N'[SY_Purview]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [SY_Purview]
GO

CREATE TABLE [SY_Purview] (
	[UserID] [char] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ModuleID] [char] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ModuleSubID] [char] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	 PRIMARY KEY  CLUSTERED 
	(
		[UserID],
		[ModuleID],
		[ModuleSubID]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO


if exists (select * from dbo.sysobjects where id = object_id(N'[SY_ModuleSub]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [SY_ModuleSub]
GO

CREATE TABLE [SY_ModuleSub] (
	[ModuleID] [char] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ModuleSubID] [char] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[FormName] [char] (30) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[FormFile] [char] (30) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[FormID] [int] NOT NULL CONSTRAINT [PK__SY_ModuleSub__FormI__6DB809C1] DEFAULT (0),
	[FormType] [int] NOT NULL CONSTRAINT [DF_XS_Modules_FormType_sdswe] DEFAULT (0),
	[Idx] [int] NOT NULL CONSTRAINT [PK__SY_ModuleSub__Idx__0B335E0F] DEFAULT (0),
	[FormPara] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara1] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara2] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara3] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara4] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara5] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara6] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara7] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara8] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara9] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara10] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[FormPara11] [varchar] (500) COLLATE Chinese_PRC_CI_AS NULL ,
	[Note] [varchar] (1000) COLLATE Chinese_PRC_CI_AS NULL ,
	CONSTRAINT [PK__SY_ModuleSub] PRIMARY KEY  CLUSTERED 
	(
		[ModuleID],
		[ModuleSubID]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO


if exists (select * from dbo.sysobjects where id = object_id(N'[SY_ModuleMain]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [SY_ModuleMain]
GO

CREATE TABLE [SY_ModuleMain] (
	[ModuleID] [char] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ModuleName] [varchar] (60) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Idx] [int] NOT NULL CONSTRAINT [DF_SY_ModuleMain_Idx__0A3F39D6] DEFAULT (0),
	 PRIMARY KEY  CLUSTERED 
	(
		[ModuleID]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO


if exists (select * from dbo.sysobjects where id = object_id(N'[SY_MaxBH]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [SY_MaxBH]
GO

CREATE TABLE [SY_MaxBH] (
	[BHStr] [char] (2) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[BHType] [varchar] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[BHDate] [char] (6) COLLATE Chinese_PRC_CI_AS NULL ,
	[BHNo] [int] NULL CONSTRAINT [DF__SY_MaxBH__BHNo__173876EA] DEFAULT (0),
	[Type] [int] NOT NULL CONSTRAINT [DF__SY_MaxBH__Type__182C9B23] DEFAULT (0),
	 PRIMARY KEY  CLUSTERED 
	(
		[BHStr],
		[BHType],
		[Type]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO


if exists (select * from dbo.sysobjects where id = object_id(N'[KH_ZDY]') and OBJECTPROPERTY(id, N'IsUserTable') = 1)
drop table [KH_ZDY]
GO

CREATE TABLE [KH_ZDY] (
	[ZDYNo] [char] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[ZDYName] [varchar] (100) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[Type] [char] (20) COLLATE Chinese_PRC_CI_AS NOT NULL ,
	[MainType] [char] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[HelpType] [char] (20) COLLATE Chinese_PRC_CI_AS NULL ,
	[Note] [varchar] (100) COLLATE Chinese_PRC_CI_AS NULL ,
	[OrderNo] [int] NOT NULL CONSTRAINT [DF__KH_ZDY__OrderNo__0519C6AF] DEFAULT (0),
	[Valid] [char] (1) COLLATE Chinese_PRC_CI_AS NOT NULL CONSTRAINT [DF__KH_ZDY__Valid__060DEAE8] DEFAULT ('Y'),
	CONSTRAINT [PK_KH_ZDY] PRIMARY KEY  CLUSTERED 
	(
		[ZDYNo],
		[Type]
	)  ON [PRIMARY] 
) ON [PRIMARY]
GO


