SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[adsum_goods_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[adsum_goods_approve](
	[ID] [bigint] NOT NULL,
	[AGID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ApproveID] [bigint] NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_adsum_goods_approve] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[regie_ploy]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[regie_ploy](
	[ID] [bigint] NOT NULL,
	[RID] [bigint] NULL,
	[PloyType] [int] NULL,
	[PloyContent] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[PloyDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_regie_ploy] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[calendar_awake]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[calendar_awake](
	[ID] [bigint] NOT NULL,
	[AwakeContent] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[AwakeDateTime] [datetime] NULL,
	[AwakeModel] [int] NULL,
	[IsAwake] [int] NULL,
	[IsDel] [int] NULL,
	[UserID] [bigint] NOT NULL,
 CONSTRAINT [PK_calendar_awake] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[outlay]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[outlay](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PayDate] [datetime] NULL,
	[CustomerID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CastDept] [bigint] NULL,
	[Caster] [bigint] NULL,
	[TotalOutlay] [decimal](16, 2) NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsAuditTwo] [int] NULL,
	[AuditTwoID] [bigint] NULL,
	[AuditTwoDate] [datetime] NULL,
	[IsAuditEnd] [int] NULL,
	[AuditEndID] [bigint] NULL,
	[AuditEndDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsCreate] [int] NULL,
 CONSTRAINT [PK_outlay] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[produce_use]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[produce_use](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PTID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UseDept] [bigint] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsEndcase] [int] NULL,
 CONSTRAINT [PK_produce_use] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[country_area]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[country_area](
	[ID] [bigint] NOT NULL,
	[AreaName] [varchar](128) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ParentID] [bigint] NULL,
	[Rank] [int] NOT NULL,
 CONSTRAINT [PK_country_area] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sample_bill_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sample_bill_approve](
	[ID] [bigint] NOT NULL,
	[SBID] [bigint] NULL,
	[ApproveID] [bigint] NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_sample_bill_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[role]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[role](
	[ID] [bigint] NOT NULL,
	[RoleName] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Describes] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_role] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[provide]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[provide](
	[PID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PName] [varchar](256) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Vocation] [int] NULL,
	[TaxCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Corporation] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[BankAccount] [varchar](24) COLLATE Chinese_PRC_CI_AS NULL,
	[BankName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Genre] [int] NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Fax] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Mobile] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[PostCode] [varchar](6) COLLATE Chinese_PRC_CI_AS NULL,
	[Addr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[AbcSort] [int] NULL,
	[PayCondition] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[HomePage] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Province] [int] NOT NULL,
	[City] [int] NOT NULL,
	[Areas] [int] NOT NULL,
	[RecordID] [bigint] NULL,
	[RegistDate] [datetime] NULL,
	[UseFlag] [int] NULL,
	[HaltDate] [datetime] NULL,
	[UpdateID] [bigint] NULL,
	[ModifyDate] [datetime] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsDel] [int] NULL,
 CONSTRAINT [PK_provide] PRIMARY KEY CLUSTERED 
(
	[PID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[affiche]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[affiche](
	[ID] [bigint] NOT NULL,
	[AfficheTitle] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[AfficheContent] [text] COLLATE Chinese_PRC_CI_AS NULL,
	[AfficheType] [int] NULL,
	[Ponderance] [int] NULL,
	[AfficheDept] [int] NULL,
	[PublishDate] [datetime] NULL,
	[PublishMan] [bigint] NOT NULL,
 CONSTRAINT [PK_affiche] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_withdraw_invoice]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_withdraw_invoice](
	[ID] [bigint] NOT NULL,
	[InvoiceCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[InvoiceType] [int] NULL,
	[Refundment] [int] NULL,
	[MakeInvoiceDate] [datetime] NULL,
	[InvocieDate] [datetime] NULL,
	[InvoiceSum] [decimal](18, 2) NULL,
	[CID] [bigint] NULL,
	[PurchaseDept] [bigint] NULL,
	[PurchaseID] [bigint] NULL,
	[Memo] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[UpdateID] [bigint] NULL,
	[LastDate] [datetime] NULL,
 CONSTRAINT [PK_purchase_withdraw_invoice] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[adsum_goods]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[adsum_goods](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PBID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PurchaseSort] [int] NULL,
	[PID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PLinkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[ObtainCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PurchaseDept] [bigint] NULL,
	[PurchaseID] [bigint] NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[ReceiveDate] [datetime] NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[Remark] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[IsTransferIncome] [int] NULL,
 CONSTRAINT [PK_adsum_goods] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product_property]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[product_property](
	[ID] [bigint] NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PropertyCode] [int] NULL,
 CONSTRAINT [PK_product_property] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[role_menu]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[role_menu](
	[ID] [bigint] NOT NULL,
	[RoleID] [bigint] NULL,
	[MenuID] [bigint] NULL,
	[MenuUrl] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[IsPopedom] [int] NULL,
 CONSTRAINT [PK_role_menu] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[role_menu]') AND name = N'IX_role_menu')
CREATE NONCLUSTERED INDEX [IX_role_menu] ON [dbo].[role_menu] 
(
	[RoleID] ASC,
	[IsPopedom] ASC,
	[MenuUrl] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[dept]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[dept](
	[ID] [bigint] NOT NULL,
	[DeptName] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_dept] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[affiche_browse]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[affiche_browse](
	[ID] [bigint] NOT NULL,
	[AfficheID] [bigint] NOT NULL,
	[UserID] [bigint] NULL,
	[IsBrowse] [int] NULL,
 CONSTRAINT [PK_affiche_browse] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_withdraw_invoice_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_withdraw_invoice_detail](
	[ID] [bigint] NOT NULL,
	[PWIID] [bigint] NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpceMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_purchase_withdraw_invoice_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[provide_linkman]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[provide_linkman](
	[ID] [bigint] NOT NULL,
	[PID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Name] [varchar](64) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Sex] [int] NOT NULL,
	[Wedlock] [int] NULL,
	[Birthday] [datetime] NULL,
	[Department] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Duty] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[OfficeTel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Fax] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Mobile] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[HomeTel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Qq] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Msn] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Addr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsMain] [int] NULL,
	[Memo] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_provide_linkman] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[quality_pass]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[quality_pass](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[AGID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PurchaseSort] [int] NULL,
	[PID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PLinkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[PurchaseDept] [bigint] NULL,
	[PurchaseID] [bigint] NULL,
	[QualityDept] [bigint] NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[Remark] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[IsTransferIncome] [int] NULL,
 CONSTRAINT [PK_quality_pass] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[adsum_goods_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[adsum_goods_detail](
	[ID] [bigint] NOT NULL,
	[AGID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](10, 2) NULL,
	[ChangeQuantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_adsum_goods_detail] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sale_order_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sale_order_approve](
	[ID] [bigint] NOT NULL,
	[SOID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_sale_order_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[income_log_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[income_log_approve](
	[ID] [bigint] NOT NULL,
	[ILID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_income_log_approve] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ditch]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[ditch](
	[ID] [bigint] NOT NULL,
	[DName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[TelOne] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[TelTwo] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Fax] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Province] [int] NULL,
	[City] [int] NULL,
	[Areas] [int] NULL,
	[DetailAddr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[PostCode] [varchar](12) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[HomePage] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[DitchRank] [int] NULL,
	[Prestige] [int] NULL,
	[Scale] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Vocation] [int] NULL,
	[TaxCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[BankName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[DoorName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[BankAccount] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Memo] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[UserID] [bigint] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_ditch] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[ditch]') AND name = N'IX_ditch')
CREATE NONCLUSTERED INDEX [IX_ditch] ON [dbo].[ditch] 
(
	[UserID] ASC,
	[MakeDate] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[user_log]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[user_log](
	[ID] [bigint] IDENTITY(1,1) NOT NULL,
	[UserID] [bigint] NOT NULL,
	[LogTime] [datetime] NOT NULL,
	[Detail] [varchar](1024) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_user_log] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[base_resource]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[base_resource](
	[ID] [bigint] NOT NULL,
	[TagName] [varchar](24) COLLATE Chinese_PRC_CI_AS NULL,
	[TagSubKey] [int] NULL,
	[TagSubValue] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_base_resource] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[produce_receive]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[produce_receive](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PTID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ReceiveDept] [bigint] NULL,
	[WarehouseID] [bigint] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsEndcase] [int] NULL,
 CONSTRAINT [PK_produce_receive] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[consign_machining_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[consign_machining_detail](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CMID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Quantity] [decimal](18, 2) NULL,
 CONSTRAINT [PK_consign_machining_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[hap]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[hap](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[HapContent] [int] NULL,
	[HapKind] [int] NULL,
	[HapStatus] [int] NULL,
	[Intend] [decimal](18, 2) NULL,
	[HapBegin] [datetime] NULL,
	[HapEnd] [datetime] NULL,
	[Memo] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_hap] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[hap]') AND name = N'IX_hap')
CREATE NONCLUSTERED INDEX [IX_hap] ON [dbo].[hap] 
(
	[MakeDate] DESC,
	[CID] ASC,
	[MakeID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[quality_pass_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[quality_pass_detail](
	[ID] [bigint] NOT NULL,
	[QPID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_quality_pass_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_inquire_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_inquire_detail](
	[ID] [bigint] NOT NULL,
	[PIID] [bigint] NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NOT NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [int] NULL,
	[SubSum] [decimal](16, 2) NULL,
 CONSTRAINT [PK_purchase_inquire_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[settlement_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[settlement_approve](
	[ID] [bigint] NOT NULL,
	[SID] [bigint] NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_settlement_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[make_conf]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[make_conf](
	[ID] [bigint] NOT NULL,
	[TableName] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[CurrentValue] [bigint] NULL,
 CONSTRAINT [PK_make_conf] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[menu]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[menu](
	[ID] [bigint] NOT NULL,
	[MenuName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[OperateID] [bigint] NOT NULL,
	[Url] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_menu] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[shipment_bill_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[shipment_bill_approve](
	[ID] [bigint] NOT NULL,
	[SBID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_shipment_bill_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[task]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[task](
	[ID] [bigint] NOT NULL,
	[TPTitle] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[BeginDate] [datetime] NULL,
	[EndDate] [datetime] NULL,
	[Status] [int] NULL,
	[TPContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[UserID] [bigint] NOT NULL,
	[IsAllot] [int] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_task] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[project]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[project](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PContent] [int] NULL,
	[PStatus] [int] NULL,
	[Amount] [decimal](18, 2) NULL,
	[PBegin] [datetime] NULL,
	[PEnd] [datetime] NULL,
	[Memo] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_project] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[project]') AND name = N'IX_project')
CREATE NONCLUSTERED INDEX [IX_project] ON [dbo].[project] 
(
	[CID] ASC,
	[MakeDate] DESC,
	[MakeID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[consign_machining]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[consign_machining](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProvideID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PPID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[MachiningPact] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[StartWorkDate] [datetime] NULL,
	[CompleteDate] [datetime] NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IdEndcase] [int] NULL,
 CONSTRAINT [PK_consign_machining] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[consign_receive_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[consign_receive_detail](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CRID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Quantity] [decimal](18, 2) NULL,
	[OughtQuantity] [decimal](18, 2) NULL,
	[Cost] [decimal](18, 2) NULL,
 CONSTRAINT [PK_consign_receive_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sale_invoice]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sale_invoice](
	[ID] [bigint] NOT NULL,
	[InvoiceCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[InvoiceType] [int] NULL,
	[MakeInvoiceDate] [datetime] NULL,
	[InvoiceDate] [datetime] NULL,
	[InvoiceSum] [decimal](18, 2) NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[SaleDept] [bigint] NULL,
	[SaleID] [bigint] NULL,
	[Memo] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsSettlement] [int] NULL CONSTRAINT [DF_sale_invoice_IsSettlement]  DEFAULT ((0)),
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[UpdateID] [bigint] NULL,
	[LastDate] [datetime] NULL,
 CONSTRAINT [PK_sale_invoice] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[mobile_area]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[mobile_area](
	[ID] [bigint] NOT NULL,
	[MobileNum] [varchar](12) COLLATE Chinese_PRC_CI_AS NULL,
	[Areas] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[CardType] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[operate]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[operate](
	[ID] [bigint] NOT NULL,
	[OperateName] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[ModuleID] [int] NULL,
 CONSTRAINT [PK_operate] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stock_adjust]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stock_adjust](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[AdjustDate] [datetime] NULL,
	[WarehouseID] [bigint] NULL,
	[AdjustCause] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsTally] [int] NULL,
	[TallyID] [bigint] NULL,
	[TallyDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsComplete] [int] NULL,
	[CompleteID] [bigint] NULL,
	[CompleteDate] [datetime] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_stock_adjust] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[consign_use_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[consign_use_detail](
	[ID] [bigint] NOT NULL,
	[CUID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[SpecMode] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[WarehouseID] [bigint] NULL,
	[Quantity] [decimal](18, 2) NULL,
	[Cost] [decimal](18, 2) NULL,
 CONSTRAINT [PK_consign_use_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[largess]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[largess](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[LargessDescribe] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[LFee] [decimal](18, 2) NULL,
	[LDate] [datetime] NULL,
	[Memo] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_largess] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[largess]') AND name = N'IX_largess')
CREATE NONCLUSTERED INDEX [IX_largess] ON [dbo].[largess] 
(
	[CID] ASC,
	[MakeDate] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stock_adjust_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stock_adjust_approve](
	[ID] [bigint] NOT NULL,
	[SAID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_stock_adjust_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[other_income]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[other_income](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[WarehouseID] [bigint] NOT NULL,
	[IncomeSort] [int] NULL,
	[IncomeDept] [bigint] NULL,
	[IncomeDate] [datetime] NULL,
	[Remark] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsRatify] [int] NULL,
	[RatifyID] [bigint] NULL,
	[RatifyDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_other_income] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[suit]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[suit](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[SuitContent] [int] NULL,
	[SuitWay] [int] NULL,
	[SuitTools] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SuitStatus] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[SuitDate] [datetime] NULL,
	[Memo] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[IsDeal] [int] NULL,
	[DealWay] [int] NULL,
	[DealUser] [bigint] NULL,
	[DealDate] [datetime] NULL,
	[DealContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[DealFinal] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_suit] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[suit]') AND name = N'IX_suit')
CREATE NONCLUSTERED INDEX [IX_suit] ON [dbo].[suit] 
(
	[CID] ASC,
	[MakeDate] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stock_adjust_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stock_adjust_detail](
	[ID] [bigint] NOT NULL,
	[SAID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [bigint] NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NOT NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [decimal](18, 0) NULL,
	[OperateSign] [varchar](2) COLLATE Chinese_PRC_CI_AS NULL,
	[SubSum] [decimal](18, 0) NULL,
 CONSTRAINT [PK_stock_adjust_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[other_income_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[other_income_approve](
	[ID] [bigint] NOT NULL,
	[OIID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_other_income_approve] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[customer]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[customer](
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CName] [varchar](256) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Vocation] [int] NULL,
	[Cphoto] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[SignDate] [datetime] NULL,
	[CustomerType] [int] NULL,
	[CustomerStatus] [int] NULL,
	[Yauld] [int] NULL,
	[Source] [int] NULL,
	[DitchID] [bigint] NULL,
	[Province] [int] NULL,
	[City] [int] NULL,
	[Areas] [int] NULL,
	[DetailAddr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[PostCode] [varchar](6) COLLATE Chinese_PRC_CI_AS NULL,
	[HomePage] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[OfficeTel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Mobile] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Fax] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[BankName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[DoorName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[BankAccount] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[TaxCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[RegistDate] [datetime] NULL,
	[SpecializeID] [bigint] NULL,
	[RecordID] [bigint] NULL,
	[LastContact] [datetime] NULL,
	[NextContact] [datetime] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsDel] [int] NULL,
 CONSTRAINT [PK_customer] PRIMARY KEY CLUSTERED 
(
	[CID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[customer]') AND name = N'IX_customer')
CREATE NONCLUSTERED INDEX [IX_customer] ON [dbo].[customer] 
(
	[SpecializeID] ASC,
	[RegistDate] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sale_invoice_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sale_invoice_detail](
	[ID] [bigint] NOT NULL,
	[SIID] [bigint] NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NOT NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [decimal](16, 2) NULL,
	[SubSum] [decimal](16, 2) NULL,
 CONSTRAINT [PK_sale_invoice_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[income_log]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[income_log](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ROID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Drawee] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[FundSrc] [int] NULL,
	[FundAttach] [int] NULL,
	[IncomeSum] [decimal](18, 2) NULL,
	[BillNum] [varchar](24) COLLATE Chinese_PRC_CI_AS NULL,
	[IncomeDate] [datetime] NULL,
	[OweBalance] [decimal](16, 2) NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_income_log] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[income_log]') AND name = N'IX_income_log')
CREATE NONCLUSTERED INDEX [IX_income_log] ON [dbo].[income_log] 
(
	[ROID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[contact_log]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[contact_log](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[ContactDate] [datetime] NULL,
	[ContactMode] [int] NULL,
	[ContactProperty] [int] NULL,
	[ContactContent] [varchar](1024) COLLATE Chinese_PRC_CI_AS NULL,
	[FeedBack] [varchar](1024) COLLATE Chinese_PRC_CI_AS NULL,
	[Linkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[NextContact] [datetime] NULL,
	[NextGoal] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[UserID] [bigint] NULL,
 CONSTRAINT [PK_contact_log_1] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[contact_log]') AND name = N'IX_contact_log')
CREATE NONCLUSTERED INDEX [IX_contact_log] ON [dbo].[contact_log] 
(
	[CID] ASC,
	[UserID] ASC,
	[ContactDate] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stock_check]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stock_check](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[WarehouseID] [bigint] NULL,
	[CheckDate] [datetime] NULL,
	[ReckonDate] [datetime] NULL,
	[CheckDept] [bigint] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[UpdateID] [bigint] NULL,
	[LastDate] [datetime] NULL,
	[Memo] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsRatify] [int] NULL,
	[RatifyID] [bigint] NULL,
	[RatifyDate] [datetime] NULL,
	[IsTally] [int] NULL,
	[TallyID] [bigint] NULL,
	[TallyDate] [datetime] NULL,
	[IsCreate] [int] NULL,
 CONSTRAINT [PK_stock_check] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[other_shipment_bill_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[other_shipment_bill_approve](
	[ID] [bigint] NOT NULL,
	[OSID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_other_shipment_bill_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[service_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[service_detail](
	[ID] [bigint] NOT NULL,
	[SAID] [bigint] NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_service_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[service_detail]') AND name = N'IX_service_detail')
CREATE NONCLUSTERED INDEX [IX_service_detail] ON [dbo].[service_detail] 
(
	[SAID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stock_check_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stock_check_approve](
	[ID] [bigint] NOT NULL,
	[SCID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_stock_check_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[material_bill]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[material_bill](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[StructCode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[PartNum] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PartName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[PartProperty] [int] NULL,
	[Quantity] [decimal](18, 2) NULL,
	[UnitID] [int] NULL,
	[SpecMode] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Cost] [decimal](18, 2) NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_material_bill] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[service_execute]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[service_execute](
	[ID] [bigint] NOT NULL,
	[SAID] [bigint] NULL,
	[UserID] [bigint] NULL,
	[IsAffirm] [int] NULL,
 CONSTRAINT [PK_service_execute] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[service_execute]') AND name = N'IX_service_execute')
CREATE NONCLUSTERED INDEX [IX_service_execute] ON [dbo].[service_execute] 
(
	[SAID] ASC,
	[UserID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[consign_use]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[consign_use](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CMID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UseDept] [bigint] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsEndcase] [int] NULL,
 CONSTRAINT [PK_consign_use] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_income_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_income_detail](
	[ID] [bigint] NOT NULL,
	[PIID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NOT NULL,
	[Batch] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [int] NULL,
	[SubSum] [decimal](16, 2) NULL,
	[IsSettlement] [int] NULL,
	[SettlementID] [bigint] NULL,
 CONSTRAINT [PK_purchase_income_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sale_order_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sale_order_detail](
	[ID] [bigint] NOT NULL,
	[SOID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NOT NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[ControlQuantity] [decimal](18, 2) NULL,
	[Cost] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
	[StatSign] [int] NULL,
	[UserID] [bigint] NULL,
 CONSTRAINT [PK_sale_order_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_invoice]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_invoice](
	[ID] [bigint] NOT NULL,
	[InvoiceCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[InvoiceType] [int] NULL,
	[MakeInvoiceDate] [datetime] NULL,
	[InvoiceDate] [datetime] NULL,
	[ProvideID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PurchaseSort] [bigint] NULL,
	[PurchaseDept] [bigint] NULL,
	[PurchaseID] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Memo] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[UpdateID] [bigint] NULL,
	[LastDate] [datetime] NULL,
	[IsSettlement] [int] NULL,
 CONSTRAINT [PK_purchase_invoice] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[service_agreement]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[service_agreement](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Linkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[SContent] [int] NULL,
	[SFee] [decimal](18, 2) NULL,
	[SStatus] [int] NULL,
	[Rank] [int] NULL,
	[SDate] [datetime] NULL,
	[Question] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[Memo] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[IsAllot] [int] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_service_agreement] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[service_agreement]') AND name = N'IX_service_agreement')
CREATE NONCLUSTERED INDEX [IX_service_agreement] ON [dbo].[service_agreement] 
(
	[CID] ASC,
	[MakeDate] DESC,
	[MakeID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stock_move_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stock_move_approve](
	[ID] [bigint] NOT NULL,
	[SMID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ApproveID] [bigint] NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_stock_move_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[outlay_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[outlay_approve](
	[ID] [bigint] NOT NULL,
	[OID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_outlay_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[contact_ditch]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[contact_ditch](
	[ID] [bigint] NOT NULL,
	[DID] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[ContactDate] [datetime] NULL,
	[ContactMode] [int] NULL,
	[ContactProperty] [int] NULL,
	[ContactContent] [varchar](1024) COLLATE Chinese_PRC_CI_AS NULL,
	[FeedBack] [varchar](1024) COLLATE Chinese_PRC_CI_AS NULL,
	[Linkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[NextContact] [datetime] NULL,
	[NextGoal] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[UserID] [bigint] NULL,
 CONSTRAINT [PK_contact_ditch] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[contact_ditch]') AND name = N'IX_contact_ditch')
CREATE NONCLUSTERED INDEX [IX_contact_ditch] ON [dbo].[contact_ditch] 
(
	[DID] ASC,
	[ContactDate] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[settlement]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[settlement](
	[ID] [bigint] NOT NULL,
	[SettlementDate] [datetime] NULL,
	[SettlementID] [bigint] NULL,
	[ProvideID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProvideName] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[SettlementSum] [decimal](18, 2) NULL,
	[Remark] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsRatify] [int] NULL,
	[RatifyID] [bigint] NULL,
	[RatifyDate] [datetime] NULL,
	[IsCreate] [int] NULL,
 CONSTRAINT [PK_settlement] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[material_require_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[material_require_detail](
	[ID] [bigint] NOT NULL,
	[MRID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[Quantity] [decimal](18, 2) NULL,
 CONSTRAINT [PK_material_require_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sample_bill]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sample_bill](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Linkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[PostCode] [varchar](12) COLLATE Chinese_PRC_CI_AS NULL,
	[ReceiveAddr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[ShipmentDate] [datetime] NULL,
	[EstimateRecycle] [datetime] NULL,
	[MakeUser] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsRecycle] [int] NULL,
	[RecycleID] [bigint] NULL,
	[ActualRecycle] [datetime] NULL,
 CONSTRAINT [PK_sample_bill] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[settlement_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[settlement_detail](
	[ID] [bigint] NOT NULL,
	[SID] [bigint] NULL,
	[ShipmentID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[InvoiceID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[SettlementQuantity] [decimal](18, 2) NULL,
	[SettlementPrice] [decimal](18, 2) NULL,
	[SettlementSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_settlement_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[other_income_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[other_income_detail](
	[ID] [bigint] NOT NULL,
	[OIID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NOT NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_other_income_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[consign_receive]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[consign_receive](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CMID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ReceiveDept] [bigint] NULL,
	[WarehouseID] [bigint] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsEndcase] [int] NULL,
 CONSTRAINT [PK_consign_receive] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product_income]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[product_income](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[HandwordCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[WarehouseID] [bigint] NOT NULL,
	[ProduceBatch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[IncomeDept] [bigint] NULL,
	[IncomeDate] [datetime] NULL,
	[IncomeSort] [int] NULL,
	[Remark] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_product_income] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[warehouse_visit]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[warehouse_visit](
	[ID] [bigint] NOT NULL,
	[WID] [bigint] NULL,
	[UserID] [bigint] NULL,
 CONSTRAINT [PK_warehouse_visit] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [IX_warehouse_visit] UNIQUE NONCLUSTERED 
(
	[UserID] ASC,
	[WID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stuff_shipment_bill_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stuff_shipment_bill_approve](
	[ID] [bigint] NOT NULL,
	[SSID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_stuff_shipment_bill_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[payable_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[payable_approve](
	[ID] [bigint] NOT NULL,
	[PID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_payable_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[shipment_bill_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[shipment_bill_detail](
	[ID] [bigint] NOT NULL,
	[SBID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NOT NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [decimal](16, 2) NULL,
	[SubSum] [decimal](16, 2) NULL,
 CONSTRAINT [PK_shipment_bill_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[other_shipment_bill]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[other_shipment_bill](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[WarehouseID] [bigint] NULL,
	[ShipmentSort] [int] NULL,
	[ShipmentDept] [bigint] NULL,
	[RequireDate] [datetime] NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsRatify] [int] NULL,
	[RatifyID] [bigint] NULL,
	[RatifyDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_other_shipment_bill] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_income]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_income](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[WarehouseID] [bigint] NOT NULL,
	[AGID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProvideID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProvideName] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[ObtainCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PurchaseSort] [int] NULL,
	[PurchaseDept] [bigint] NULL,
	[PurchaseID] [bigint] NULL,
	[IncomeDate] [datetime] NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[Remark] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsCreate] [int] NULL,
 CONSTRAINT [PK_purchase_income] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[task_execute]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[task_execute](
	[ID] [bigint] NOT NULL,
	[TPID] [bigint] NOT NULL,
	[UserID] [bigint] NOT NULL,
	[IsAffirm] [int] NULL,
 CONSTRAINT [PK_task_execute] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[other_shipment_bill_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[other_shipment_bill_detail](
	[ID] [bigint] NOT NULL,
	[OSID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NOT NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](16, 2) NULL,
 CONSTRAINT [PK_other_shipment_bill_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[company_msg]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[company_msg](
	[ID] [bigint] NOT NULL,
	[Tel] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Fax] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[PostCode] [varchar](12) COLLATE Chinese_PRC_CI_AS NULL,
	[Addr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[WebSite] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_company_msg] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stock_check_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stock_check_detail](
	[ID] [bigint] NOT NULL,
	[SCID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NOT NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[ReckonQuantity] [decimal](18, 2) NULL,
	[CheckQuantity] [decimal](18, 2) NULL,
 CONSTRAINT [PK_stock_check_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[payment_log_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[payment_log_approve](
	[ID] [bigint] NOT NULL,
	[PLID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ApproveID] [bigint] NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_payment_log_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[trial_apply]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[trial_apply](
	[ID] [bigint] NOT NULL,
	[CompanyName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[CompanyAddr] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Linkman] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Qq] [varchar](24) COLLATE Chinese_PRC_CI_AS NULL,
	[Msn] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[CompanyTel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[CompanySite] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Intent] [int] NULL,
	[TrialMode] [int] NULL,
	[Route] [int] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeDate] [datetime] NULL,
	[IsDispose] [int] NULL,
 CONSTRAINT [PK_trial_apply] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[paysrc]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[paysrc](
	[ID] [bigint] NOT NULL,
	[SrcName] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[SrcMemo] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[ParentID] [bigint] NULL,
	[Rank] [int] NULL,
 CONSTRAINT [PK_paysrc] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[user_area]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[user_area](
	[ID] [bigint] NOT NULL,
	[UserID] [bigint] NOT NULL,
	[AreaID] [bigint] NOT NULL,
 CONSTRAINT [PK_user_area] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[outlay_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[outlay_detail](
	[ID] [bigint] NOT NULL,
	[OID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[OutlayProjectID] [int] NULL,
	[OutlaySum] [decimal](18, 2) NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_outlay_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stock_move]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stock_move](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[MoveDate] [datetime] NULL,
	[OutWarehouseID] [bigint] NULL,
	[InWarehouseID] [bigint] NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[MoveCause] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsShipment] [int] NULL,
	[ShipmentID] [bigint] NULL,
	[ShipmentDate] [datetime] NULL,
	[IsComplete] [int] NULL,
	[ReceiveID] [bigint] NULL,
	[ReceiveDate] [datetime] NULL,
 CONSTRAINT [PK_stock_move] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[phone_book]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[phone_book](
	[ID] [bigint] NOT NULL,
	[Name] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Sex] [int] NOT NULL,
	[Phone] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Mobile] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Qq] [varchar](24) COLLATE Chinese_PRC_CI_AS NULL,
	[Msn] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Birthday] [datetime] NULL,
	[Addr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[SortID] [int] NULL,
	[UserID] [bigint] NULL,
 CONSTRAINT [PK_phone_book] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_inquire]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_inquire](
	[ID] [bigint] NOT NULL,
	[PPID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[InquireTitle] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[PID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PLinkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[ValidDate] [int] NULL,
	[Remark] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[IsCaseend] [int] NULL CONSTRAINT [DF_purchase_inquire_IsCaseend]  DEFAULT ((0)),
 CONSTRAINT [PK_purchase_inquire] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[phone_book_sort]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[phone_book_sort](
	[ID] [bigint] NOT NULL,
	[SortName] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UserID] [bigint] NULL,
 CONSTRAINT [PK_phone_book_sort] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[user_role]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[user_role](
	[ID] [bigint] NOT NULL,
	[UserID] [bigint] NOT NULL,
	[RoleID] [bigint] NOT NULL,
	[IsPopedom] [int] NULL,
 CONSTRAINT [PK_user_role] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[user_role]') AND name = N'IX_user_role')
CREATE NONCLUSTERED INDEX [IX_user_role] ON [dbo].[user_role] 
(
	[RoleID] ASC,
	[IsPopedom] ASC,
	[UserID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sale_trades_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sale_trades_detail](
	[ID] [bigint] NOT NULL,
	[STID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [int] NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_sale_trades_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[sale_trades_detail]') AND name = N'IX_sale_trades_detail')
CREATE NONCLUSTERED INDEX [IX_sale_trades_detail] ON [dbo].[sale_trades_detail] 
(
	[STID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stock_move_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stock_move_detail](
	[ID] [bigint] NOT NULL,
	[SMID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NOT NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_stock_move_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_withdraw]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_withdraw](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PLinkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[WarehouseID] [bigint] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[WithdrawCause] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
 CONSTRAINT [PK_purchase_withdraw] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
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]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users](
	[UserID] [bigint] NOT NULL,
	[LoginName] [varchar](64) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Password] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[ApprovePwd] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[RealName] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[NameEN] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Sex] [int] NULL,
	[Birthday] [datetime] NULL,
	[IdCard] [varchar](24) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Mobile] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[OfficeTel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[HomeTel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Qq] [varchar](24) COLLATE Chinese_PRC_CI_AS NULL,
	[Msn] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Addr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[CreateDate] [datetime] NULL,
	[LastLogin] [datetime] NULL,
	[LoginTimes] [int] NULL,
	[Dept] [int] NULL,
	[ParentID] [bigint] NULL,
	[Status] [int] NULL,
	[IsOnline] [int] NULL,
 CONSTRAINT [PK_users] PRIMARY KEY CLUSTERED 
(
	[UserID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[users]') AND name = N'IX_users')
CREATE NONCLUSTERED INDEX [IX_users] ON [dbo].[users] 
(
	[LoginName] ASC,
	[Password] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[users]') AND name = N'IX_users_1')
CREATE UNIQUE NONCLUSTERED INDEX [IX_users_1] ON [dbo].[users] 
(
	[LoginName] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product_income_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[product_income_approve](
	[ID] [bigint] NOT NULL,
	[PIID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_product_income_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[warehouse]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[warehouse](
	[ID] [bigint] NOT NULL,
	[WarehouseName] [varchar](128) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Dept] [bigint] NULL,
	[UserID] [bigint] NULL,
	[WarehouseTel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[WarehouseProperty] [int] NULL,
	[WarehouseAddr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[UseFlag] [int] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_warehouse] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[payment_log]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[payment_log](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[POID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Payee] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[PayPurpose] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[PayMode] [int] NULL,
	[PaySum] [decimal](18, 2) NULL,
	[BillDate] [datetime] NULL,
	[OweBalance] [decimal](18, 2) NULL,
	[BillNum] [varchar](24) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_payment_log] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[payment_log]') AND name = N'IX_payment_log')
CREATE NONCLUSTERED INDEX [IX_payment_log] ON [dbo].[payment_log] 
(
	[POID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stock_waste_book]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stock_waste_book](
	[ID] [bigint] NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[WarehouseID] [bigint] NULL,
	[BillCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Memo] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[CycleFirstQuantity] [decimal](18, 2) NULL,
	[CycleInQuantity] [decimal](18, 2) NULL,
	[CycleOutQuantity] [decimal](18, 2) NULL,
	[CycleBalanceQuantity] [decimal](18, 2) NULL,
	[RecordDate] [datetime] NULL,
 CONSTRAINT [PK_stock_waste_book] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[material_require]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[material_require](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PPID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
 CONSTRAINT [PK_material_require] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[warehouse_annunciator]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[warehouse_annunciator](
	[ID] [bigint] NOT NULL,
	[WarehouseID] [bigint] NULL,
	[UserID] [bigint] NULL,
	[IsAwake] [int] NULL,
 CONSTRAINT [PK_warehouse_annunciator] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[produce_plan_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[produce_plan_detail](
	[ID] [bigint] NOT NULL,
	[PPID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[Quantity] [decimal](18, 2) NULL,
	[TaskQuantity] [decimal](18, 2) NULL,
 CONSTRAINT [PK_produce_plan_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_withdraw_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_withdraw_detail](
	[ID] [bigint] NOT NULL,
	[PWID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_purchase_withdraw_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product_struct]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[product_struct](
	[ID] [bigint] NOT NULL,
	[StructCode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[SortName] [varchar](64) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Remark] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_product_struct] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[retail_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[retail_detail](
	[ID] [bigint] NOT NULL,
	[RID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[Cost] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
	[UserID] [bigint] NULL,
 CONSTRAINT [PK_retail_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[retail_detail]') AND name = N'IX_retail_detail')
CREATE NONCLUSTERED INDEX [IX_retail_detail] ON [dbo].[retail_detail] 
(
	[RID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stuff_shipment_bill]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stuff_shipment_bill](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[WarehouseID] [bigint] NULL,
	[ShipmentSort] [int] NULL,
	[ShipmentDept] [bigint] NULL,
	[RequireDate] [datetime] NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_stuff_shipment_bill] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[produce_receive_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[produce_receive_detail](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PRID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpceMode] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Quantity] [decimal](18, 2) NULL,
	[OuthtQuantity] [decimal](18, 2) NULL,
	[Cost] [decimal](18, 2) NULL,
 CONSTRAINT [PK_produce_receive_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[produce_task]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[produce_task](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProduceDept] [bigint] NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[StartWorkDate] [datetime] NULL,
	[CompleteDate] [datetime] NULL,
	[Batch] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[Quantity] [decimal](18, 2) NULL,
	[CheckQuantity] [decimal](18, 2) NULL,
	[SpecMode] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsEndcase] [int] NULL,
 CONSTRAINT [PK_produce_task] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_trades_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_trades_detail](
	[ID] [bigint] NOT NULL,
	[PTID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_purchase_trades_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[purchase_trades_detail]') AND name = N'IX_purchase_trades_detail')
CREATE NONCLUSTERED INDEX [IX_purchase_trades_detail] ON [dbo].[purchase_trades_detail] 
(
	[PTID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[stuff_shipment_bill_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[stuff_shipment_bill_detail](
	[ID] [bigint] NOT NULL,
	[SSID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NOT NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [decimal](16, 2) NULL,
	[SubSum] [decimal](16, 2) NULL,
 CONSTRAINT [PK_stuff_shipment_bill_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[produce_plan]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[produce_plan](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PlanDept] [bigint] NULL,
	[PlanID] [bigint] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[StartWorkDate] [datetime] NULL,
	[CompleteDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsEnd] [int] NULL,
 CONSTRAINT [PK_produce_plan] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[receivable_object]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[receivable_object](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ObjectSort] [int] NULL,
	[Payer] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[TotalReceivableSum] [decimal](18, 2) NULL,
	[AlreadyReceivableSum] [decimal](18, 2) NULL,
	[WaitReceivableSum] [decimal](18, 2) NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[PromiseDate] [datetime] NULL,
 CONSTRAINT [PK_receivable_object] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[receivable_object]') AND name = N'IX_receivable_object')
CREATE NONCLUSTERED INDEX [IX_receivable_object] ON [dbo].[receivable_object] 
(
	[MakeID] ASC,
	[MakeDate] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[withdraw_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[withdraw_approve](
	[ID] [bigint] NOT NULL,
	[WID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_withdraw_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_bill_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_bill_approve](
	[ID] [bigint] NOT NULL,
	[PBID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_purchase_bill_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[receivable]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[receivable](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ROID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ReceivableSum] [decimal](18, 2) NULL,
	[BillNo] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ReceivableDescribe] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_receivable] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[warehouse_annunciator_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[warehouse_annunciator_detail](
	[ID] [bigint] NOT NULL,
	[WAID] [bigint] NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Quantity] [decimal](18, 2) NULL,
 CONSTRAINT [PK_warehouse_annunciator_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[produce_task_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[produce_task_detail](
	[ID] [bigint] NOT NULL,
	[PTID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[Quantity] [decimal](18, 2) NULL,
 CONSTRAINT [PK_produce_task_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[payable_object]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[payable_object](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ObjectSort] [int] NULL,
	[Payee] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[TotalPayableSum] [decimal](18, 2) NULL,
	[AlreadyPayableSum] [decimal](18, 2) NULL,
	[WaitPayableSum] [decimal](18, 2) NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_payable_object] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[payable_object]') AND name = N'IX_payable_object')
CREATE NONCLUSTERED INDEX [IX_payable_object] ON [dbo].[payable_object] 
(
	[MakeID] ASC,
	[MakeDate] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[work_report]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[work_report](
	[ID] [bigint] NOT NULL,
	[CreateID] [bigint] NOT NULL,
	[ReportContent] [varchar](1024) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ReportSort] [int] NOT NULL,
	[ReferDate] [datetime] NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[Affix] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_work_report] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[produce_use_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[produce_use_detail](
	[ID] [bigint] NOT NULL,
	[PUID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[SpecMode] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[WarehouseID] [bigint] NULL,
	[Quantity] [decimal](18, 2) NULL,
	[Cost] [decimal](18, 2) NULL,
 CONSTRAINT [PK_produce_use_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[payable]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[payable](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[POID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PayableSum] [decimal](18, 2) NULL,
	[BillNo] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PayableDescribe] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_payable] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[payable]') AND name = N'IX_payable')
CREATE NONCLUSTERED INDEX [IX_payable] ON [dbo].[payable] 
(
	[POID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[work_report_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[work_report_approve](
	[ID] [bigint] NOT NULL,
	[ReportID] [bigint] NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](1024) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_work_report_approve] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_income_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_income_approve](
	[ID] [bigint] NOT NULL,
	[PIID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_purchase_income_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[retail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[retail](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[WarehouseID] [bigint] NULL,
	[PostCode] [varchar](12) COLLATE Chinese_PRC_CI_AS NULL,
	[Addr] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsSettlement] [int] NULL,
	[SettlementID] [bigint] NULL,
	[SettlementDate] [datetime] NULL,
 CONSTRAINT [PK_retail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[warehouse_safety_intercalate]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[warehouse_safety_intercalate](
	[ID] [bigint] NOT NULL,
	[WarehouseID] [bigint] NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[SafetyH] [decimal](18, 2) NULL,
	[SafetyL] [decimal](18, 2) NULL,
 CONSTRAINT [PK_warehouse_safety_intercalate] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[product](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PSID] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[CountUnit] [int] NOT NULL,
	[ProductCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[BarCode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductPicture] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[StandardPurchase] [decimal](16, 2) NULL,
	[StandardSale] [decimal](16, 2) NULL,
	[LeastSale] [decimal](16, 2) NULL,
	[Cost] [decimal](18, 2) NULL,
	[LeastStock] [decimal](10, 2) NULL,
	[StandardStock] [decimal](10, 2) NULL,
	[TiptopStock] [decimal](10, 2) NULL,
	[AbcSort] [int] NULL,
	[Memo] [varchar](1024) COLLATE Chinese_PRC_CI_AS NULL,
	[UseFlag] [int] NULL,
	[MakeID] [bigint] NULL,
 CONSTRAINT [PK_product] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sale_order]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sale_order](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CustomerBillID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CName] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[SaleType] [int] NULL,
	[SaleDept] [bigint] NULL,
	[WarehouseID] [bigint] NULL,
	[ConsignmentDate] [datetime] NULL,
	[FundSrc] [int] NULL,
	[FundAttach] [int] NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[TransportMode] [int] NULL,
	[TransportAddr] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[ReceiveMan] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[UpdateID] [bigint] NULL,
	[LastUpdate] [datetime] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsAuditTwo] [int] NULL,
	[AuditTwoID] [bigint] NULL,
	[AuditTwoDate] [datetime] NULL,
	[IsCompleteControl] [int] NULL,
	[IsShipment] [int] NULL,
	[IsTransferShipment] [int] NULL,
	[OrderStatus] [int] NULL,
 CONSTRAINT [PK_sale_order] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product_cost]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[product_cost](
	[ID] [bigint] NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Cost] [decimal](18, 2) NULL,
	[CostDate] [datetime] NULL,
 CONSTRAINT [PK_product_cost] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_trades]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_trades](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[WarehouseInID] [bigint] NULL,
	[WarehouseOutID] [bigint] NULL,
	[ProvideID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProvideName] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[PLinkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[TradesMode] [int] NULL,
	[TradesDate] [datetime] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsReceive] [int] NULL,
	[ReceiveID] [bigint] NULL,
	[ReceiveDate] [datetime] NULL,
 CONSTRAINT [PK_purchase_trades] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[purchase_trades]') AND name = N'IX_purchase_trades')
CREATE NONCLUSTERED INDEX [IX_purchase_trades] ON [dbo].[purchase_trades] 
(
	[ProvideID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[customer_users]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[customer_users](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[UID] [bigint] NOT NULL,
	[IsCreate] [int] NULL,
 CONSTRAINT [PK_customer_users] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product_history]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[product_history](
	[ID] [bigint] NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[StandardPurchase] [decimal](18, 2) NULL,
	[StandardSale] [decimal](18, 2) NULL,
	[StandardStock] [decimal](18, 2) NULL,
	[UseFlag] [int] NULL,
	[UpdateID] [bigint] NULL,
	[LastDate] [datetime] NULL,
 CONSTRAINT [PK_product_history] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sale_trades]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sale_trades](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[WarehouseInID] [bigint] NULL,
	[WarehouseOutID] [bigint] NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[CName] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[CLinkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[TradesMode] [int] NULL,
	[TradesDate] [datetime] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[Auditdate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsBacktrack] [int] NULL,
	[BacktrackID] [bigint] NULL,
	[BacktrackDate] [datetime] NULL,
 CONSTRAINT [PK_sale_trades] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO

IF NOT EXISTS (SELECT * FROM sys.indexes WHERE object_id = OBJECT_ID(N'[dbo].[sale_trades]') AND name = N'IX_sale_trades')
CREATE NONCLUSTERED INDEX [IX_sale_trades] ON [dbo].[sale_trades] 
(
	[CID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[withdraw_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[withdraw_detail](
	[ID] [bigint] NOT NULL,
	[WID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NOT NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [decimal](16, 2) NULL,
	[SubSum] [decimal](16, 2) NULL,
 CONSTRAINT [PK_withdraw_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_plan]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_plan](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PurchaseSort] [int] NULL,
	[PlanDate] [datetime] NULL,
	[PlanDept] [bigint] NULL,
	[PlanID] [bigint] NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsRatify] [int] NULL,
	[RatifyID] [bigint] NULL,
	[RatifyDate] [datetime] NULL,
	[IsComplete] [int] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_purchase_plan] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_bill]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_bill](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PPID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PurchaseSort] [int] NULL,
	[PID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[PLinkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[PurchaseDept] [bigint] NULL,
	[PurchaseID] [bigint] NULL,
	[PayCondition] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[TotalSum] [decimal](16, 2) NULL,
	[ReceiveDate] [datetime] NULL,
	[ReceiveAddr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsRatify] [int] NULL,
	[RatifyID] [bigint] NULL,
	[RatifyDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[Remark] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[IsTransferAdsum] [int] NULL,
	[PurchaseBillStatus] [int] NULL,
 CONSTRAINT [PK_purchase_bill] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[linkman]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[linkman](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Name] [varchar](64) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Sex] [int] NOT NULL,
	[IdCard] [varchar](24) COLLATE Chinese_PRC_CI_AS NULL,
	[Birthday] [datetime] NULL,
	[Department] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Duty] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[OfficeTel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Mobile] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[HomeTel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[Email] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Qq] [varchar](24) COLLATE Chinese_PRC_CI_AS NULL,
	[Msn] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Addr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsMain] [int] NULL,
	[RelationCustomer] [int] NULL,
	[UserID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_linkman] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_plan_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_plan_approve](
	[ID] [bigint] NOT NULL,
	[PPID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ApproveID] [bigint] NOT NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_purchase_plan_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product_income_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[product_income_detail](
	[ID] [bigint] NOT NULL,
	[PIID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NOT NULL,
	[Quantity] [decimal](18, 2) NULL,
	[CostPrice] [decimal](18, 2) NULL,
	[CostSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_product_income_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[withdraw_invoice]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[withdraw_invoice](
	[ID] [bigint] NOT NULL,
	[InvoiceCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[InvoiceType] [int] NULL,
	[Refundment] [int] NULL,
	[MakeInvoiceDate] [datetime] NULL,
	[InvoiceDate] [datetime] NULL,
	[InvoiceSum] [decimal](18, 2) NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[SaleDept] [bigint] NULL,
	[SaleID] [bigint] NULL,
	[Memo] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[UpdateID] [bigint] NULL,
	[LastDate] [datetime] NULL,
 CONSTRAINT [PK_withdraw_invoice] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[product_stockpile]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[product_stockpile](
	[ID] [bigint] NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[CountUnit] [int] NOT NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[BarCode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[WarehouseID] [bigint] NOT NULL,
	[Stockpile] [decimal](18, 2) NULL,
	[PrepareOut] [decimal](18, 2) NULL,
	[IsLock] [int] NULL,
 CONSTRAINT [PK_product_stockpile] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[withdraw_invoice_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[withdraw_invoice_detail](
	[ID] [bigint] NOT NULL,
	[WIID] [bigint] NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_withdraw_invoice_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_withdraw_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_withdraw_approve](
	[ID] [bigint] NOT NULL,
	[PWID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ApproveID] [bigint] NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_purchase_withdraw_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[correlation_document]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[correlation_document](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ClientType] [int] NULL,
	[DocumentName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[RealPathName] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[UpdateDate] [datetime] NULL,
	[UserID] [bigint] NOT NULL,
 CONSTRAINT [PK_correlation_document] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[provider_product]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[provider_product](
	[ID] [bigint] NOT NULL,
	[ProviderID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[CountUnit] [int] NULL,
	[BarCode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Price] [decimal](18, 2) NULL,
	[PriceDate] [datetime] NULL,
 CONSTRAINT [PK_provider_product] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[pact]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[pact](
	[ID] [bigint] NOT NULL,
	[PactCode] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[PactType] [int] NULL,
	[UserID] [bigint] NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CDeputy] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[SignDate] [datetime] NULL,
	[Provide] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[PDeputy] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[SignAddr] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[PactScopy] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Affix] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_pact] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_bill_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_bill_detail](
	[ID] [bigint] NOT NULL,
	[PBID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NOT NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [decimal](16, 2) NULL,
	[SubSum] [decimal](16, 2) NULL,
 CONSTRAINT [PK_purchase_bill_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[shipment_bill]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[shipment_bill](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[WarehouseID] [bigint] NULL,
	[SOID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[SaleType] [int] NULL,
	[SaleDept] [bigint] NULL,
	[FundSrc] [int] NULL,
	[FundAttach] [int] NULL,
	[ReceiveID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[Linkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[ReceiveAddr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[RequireDate] [datetime] NULL,
	[TransportMode] [int] NULL,
	[TransportNum] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[TotalSum] [decimal](16, 2) NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_shipment_bill] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[receivable_approve]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[receivable_approve](
	[ID] [bigint] NOT NULL,
	[RID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ApproveID] [bigint] NULL,
	[ActID] [int] NULL,
	[ApproveContent] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[Approve] [int] NULL,
	[ApproveDate] [datetime] NULL,
 CONSTRAINT [PK_receivable_approve] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[withdraw]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[withdraw](
	[ID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[WarehouseID] [bigint] NOT NULL,
	[MakeID] [bigint] NOT NULL,
	[MakeDate] [datetime] NULL,
	[WithdrawCause] [varchar](512) COLLATE Chinese_PRC_CI_AS NULL,
	[TotalSum] [decimal](16, 2) NULL,
	[IsRefer] [int] NULL,
	[ApproveStatus] [int] NULL,
	[ApproveDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[IsAuditTwo] [int] NULL,
	[AuditTwoID] [bigint] NULL,
	[AuditTwoDate] [datetime] NULL,
 CONSTRAINT [PK_withdraw] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_invoice_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_invoice_detail](
	[ID] [bigint] NOT NULL,
	[PIID] [bigint] NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NULL,
	[Batch] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
	[IsSettlement] [int] NULL,
	[SettlementID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
 CONSTRAINT [PK_purchase_invoice_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[approve_flow]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[approve_flow](
	[ID] [bigint] NOT NULL,
	[FlowName] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Memo] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_approve_flow] PRIMARY KEY CLUSTERED 
(
	[ID] DESC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[demand_price_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[demand_price_detail](
	[ID] [bigint] NOT NULL,
	[DPID] [bigint] NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_demand_price_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[regie]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[regie](
	[ID] [bigint] NOT NULL,
	[RegieName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[RegieType] [int] NULL,
	[Acreage] [decimal](18, 0) NULL,
	[Actuality] [int] NULL,
	[RegieAddr] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
	[ManCount] [int] NULL,
	[RegieNob] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Province] [int] NULL,
	[City] [int] NULL,
	[ShopDate] [datetime] NULL,
	[UserID] [bigint] NULL,
	[IsUse] [int] NULL,
	[Remark] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_regie] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[approve_flow_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[approve_flow_detail](
	[ID] [bigint] NOT NULL,
	[AFID] [bigint] NULL,
	[ApproveID] [bigint] NULL,
	[ActID] [int] NULL,
 CONSTRAINT [PK_approve_flow_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sample_bill_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sample_bill_detail](
	[ID] [bigint] NOT NULL,
	[SBID] [bigint] NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [bigint] NULL,
	[UnitPrice] [decimal](18, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[SubSum] [decimal](18, 2) NULL,
 CONSTRAINT [PK_sample_bill_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_plan_detail]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_plan_detail](
	[ID] [bigint] NOT NULL,
	[PPID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[ProductID] [varchar](32) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[ProductName] [varchar](128) COLLATE Chinese_PRC_CI_AS NULL,
	[SpecMode] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[UnitID] [int] NOT NULL,
	[UnitPrice] [decimal](16, 2) NULL,
	[Quantity] [decimal](18, 2) NULL,
	[ChangeQuantity] [decimal](18, 2) NULL,
	[RequireDate] [datetime] NULL,
	[AdviceDate] [datetime] NULL,
	[RequireExplain] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_purchase_plan_detail] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[demand_price]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[demand_price](
	[ID] [bigint] NOT NULL,
	[CID] [varchar](32) COLLATE Chinese_PRC_CI_AS NULL,
	[Linkman] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[Tel] [varchar](26) COLLATE Chinese_PRC_CI_AS NULL,
	[DemandName] [varchar](64) COLLATE Chinese_PRC_CI_AS NULL,
	[MakeID] [bigint] NULL,
	[MakeDate] [datetime] NULL,
	[IsAudit] [int] NULL,
	[AuditID] [bigint] NULL,
	[AuditDate] [datetime] NULL,
	[TotalSum] [decimal](18, 2) NULL,
	[IsOver] [int] NULL,
	[Remark] [varchar](256) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_demand_price] PRIMARY KEY CLUSTERED 
(
	[ID] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
