SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[快递单参数]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[快递单参数](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[快递单名称] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[top1] [int] NULL,
	[left1] [int] NULL,
	[top2] [int] NULL,
	[left2] [int] NULL,
	[top3] [int] NULL,
	[left3] [int] NULL,
	[top4] [int] NULL,
	[left4] [int] NULL,
	[top5] [int] NULL,
	[left5] [int] NULL,
	[top6] [int] NULL,
	[left6] [int] NULL,
	[图片] [nchar](50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[赠卡]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[赠卡](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[卡号] [int] NOT NULL,
	[密码] [int] NOT NULL,
	[面值] [int] NULL,
	[已兑] [bit] NULL,
	[开卡时间] [datetime] NOT NULL CONSTRAINT [DF_赠卡_开卡时间]  DEFAULT (getdate()),
	[兑换时间] [datetime] NULL,
	[有效期] [datetime] NULL,
	[会员] [nchar](20) COLLATE Chinese_PRC_CI_AS NULL,
	[已打] [bit] NULL,
	[用户] [nchar](20) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_赠卡] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY],
 CONSTRAINT [IX_赠卡] UNIQUE NONCLUSTERED 
(
	[卡号] 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].[商品分类]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[商品分类](
	[分类序号] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[资料号] [nchar](14) COLLATE Chinese_PRC_CI_AS NULL,
	[时间] [datetime] NULL
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[分类表]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[分类表](
	[序号] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[类别] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[时间] [datetime] NULL
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[在线状态]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[在线状态](
	[用户编号] [char](6) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[在线状态] [char](4) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
END
go
ALTER TABLE 在线状态 DROP COLUMN [版本号]
alter table [在线状态] add [版本号] [char](4) COLLATE Chinese_PRC_CI_AS NULL
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[通知表]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[通知表](
	[序号] [int] IDENTITY(1,1) NOT NULL,
	[通知] [text] COLLATE Chinese_PRC_CI_AS NOT NULL,
	[日期] [datetime] NOT NULL CONSTRAINT [DF_通知表_日期]  DEFAULT (getdate()),
	[用户编号] [char](10) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK_通知表] PRIMARY KEY CLUSTERED 
(
	[序号] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
END
go
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[客户跟踪表]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[客户跟踪表](
	[编号] [char](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[客户编号] [char](50) COLLATE Chinese_PRC_CI_AS NULL,
	[日期] [datetime] NULL,
	[业务员] [char](10) COLLATE Chinese_PRC_CI_AS NULL,
	[制单人] [char](10) COLLATE Chinese_PRC_CI_AS NULL,
	[地址] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[事项] [char](4) COLLATE Chinese_PRC_CI_AS NULL,
	[备注] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL
) ON [PRIMARY]
END
go
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[预售单]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[预售单](
	[编号] [char](20) COLLATE Chinese_PRC_CI_AS NOT NULL,
	[客户编号] [char](50) COLLATE Chinese_PRC_CI_AS NULL,
	[预售日期] [datetime] NULL,
	[业务员] [char](10) COLLATE Chinese_PRC_CI_AS NULL,
	[制单人] [char](10) COLLATE Chinese_PRC_CI_AS NULL,
	[保管员] [char](10) COLLATE Chinese_PRC_CI_AS NULL,
	[总金额] [decimal](28, 6) NULL,
	[实收金额] [decimal](28, 6) NULL,
	[订单号] [char](20) COLLATE Chinese_PRC_CI_AS NULL,
	[审核] [char](4) COLLATE Chinese_PRC_CI_AS NULL,
	[销退货] [char](4) COLLATE Chinese_PRC_CI_AS NULL,
	[选中] [char](4) COLLATE Chinese_PRC_CI_AS NULL,
	[备注] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[仓库] [nchar](10) COLLATE Chinese_PRC_CI_AS NULL,
	[总利润] [decimal](28, 6) NULL,
	[总重量] [decimal](28, 6) NULL,
	[金额核对] [char](4) COLLATE Chinese_PRC_CI_AS NULL,
	[核对人] [char](10) COLLATE Chinese_PRC_CI_AS NULL,
 CONSTRAINT [PK__预售单__5C8CB268] PRIMARY KEY CLUSTERED 
(
	[编号] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[预售单明细]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[预售单明细](
	[预售单号] [char](20) COLLATE Chinese_PRC_CI_AS NULL,
	[货号] [char](14) COLLATE Chinese_PRC_CI_AS NULL,
	[预售数量] [decimal](28, 6) NULL,
	[预售价] [decimal](28, 6) NULL,
	[仓库] [char](20) COLLATE Chinese_PRC_CI_AS NULL,
	[合计金额] [decimal](28, 6) NULL,
	[审核] [char](4) COLLATE Chinese_PRC_CI_AS NULL,
	[销退货] [char](4) COLLATE Chinese_PRC_CI_AS NULL,
	[选中] [char](4) COLLATE Chinese_PRC_CI_AS NULL,
	[备注] [nvarchar](50) COLLATE Chinese_PRC_CI_AS NULL,
	[利润] [decimal](28, 6) NULL,
	[重量] [decimal](28, 6) NULL,
	[成本价] [decimal](28, 6) NULL,
	[编号] [int] IDENTITY(1,1) NOT NULL,
 CONSTRAINT [PK__预售单明细__5E74FADA] PRIMARY KEY CLUSTERED 
(
	[编号] ASC
)WITH (IGNORE_DUP_KEY = OFF) ON [PRIMARY]
) ON [PRIMARY]
END
GO
IF NOT EXISTS (SELECT * FROM sys.foreign_keys WHERE object_id = OBJECT_ID(N'[dbo].[预售单明细_货号_fk]') AND parent_object_id = OBJECT_ID(N'[dbo].[预售单明细]'))
ALTER TABLE [dbo].[预售单明细]  WITH NOCHECK ADD  CONSTRAINT [预售单明细_货号_fk] FOREIGN KEY([货号])
REFERENCES [dbo].[商品清单] ([货号])
GO
ALTER TABLE [dbo].[预售单明细] CHECK CONSTRAINT [预售单明细_货号_fk]
GO
alter table  [dbo].[用户清单]  ALTER  COLUMN [经营权] [char](61) COLLATE Chinese_PRC_CI_AS NULL 
alter table  [dbo].[用户清单]  ALTER  COLUMN [管理权] [char](61) COLLATE Chinese_PRC_CI_AS NULL 
alter table  [dbo].[用户清单]  ALTER  COLUMN [价格权] [char](61) COLLATE Chinese_PRC_CI_AS NULL 
alter table  [dbo].[用户清单]  ALTER  COLUMN [用户编号] [char](20) COLLATE Chinese_PRC_CI_AS NOT NULL
alter table  [dbo].[用户清单]  ALTER  COLUMN [密码] [char](40) COLLATE Chinese_PRC_CI_AS NULL
alter table [用户清单] drop constraint [PK_用户清单]
alter table [dbo].[用户清单] ADD CONSTRAINT [PK_用户清单] PRIMARY KEY (用户编号)
alter table [商品基本资料] drop constraint [PK_商品基本资料]
alter table [dbo].[商品基本资料] ADD CONSTRAINT [PK_商品基本资料] PRIMARY KEY (资料号)
GO
alter table [通知表] drop constraint [PK_通知表]
ALTER TABLE [通知表] DROP COLUMN [序号]
alter table [通知表] add [序号] int identity(1,1)
alter table [dbo].[通知表] ADD CONSTRAINT [PK_通知表] PRIMARY KEY (序号) 
ALTER TABLE [dbo].[通知表]  DROP CONSTRAINT [DF_通知表_日期]
alter table [dbo].[通知表] alter column [日期] [datetime] NOT NULL 
ALTER TABLE dbo.[通知表] add CONSTRAINT  [DF_通知表_日期] DEFAULT (getdate()) FOR [日期]
   
GO
alter table [调拨单明细] drop constraint [PK__调拨单明细__69E6AD86]
ALTER TABLE [调拨单明细] DROP COLUMN [编号]
 alter table [调拨单明细] add [编号] int identity(1,1)
 alter table [dbo].[调拨单明细] ADD CONSTRAINT [PK__调拨单明细__69E6AD86] PRIMARY KEY (编号)
go
alter table [盘点单明细] drop constraint [PK__盘点单明细__0B47A151]
ALTER TABLE [盘点单明细] DROP COLUMN [编号]
 alter table [盘点单明细] add [编号] int identity(1,1)
 alter table [dbo].[盘点单明细] ADD CONSTRAINT [PK__盘点单明细__0B47A151] PRIMARY KEY (编号) 
go
alter table 销售单明细 drop constraint [PK__销售单明细__5E74FADA]
ALTER TABLE [销售单明细] DROP COLUMN [编号]
 alter table [销售单明细] add [编号] int identity(1,1)
 alter table [dbo].[销售单明细] ADD CONSTRAINT [PK__销售单明细__5E74FADA] PRIMARY KEY (编号) 
alter table [进货单明细] drop constraint [PK__进货单明细__4D4A6ED8]
ALTER TABLE [进货单明细] DROP COLUMN [编号]
 alter table [进货单明细] add [编号] int identity(1,1)
 alter table [dbo].[进货单明细] ADD CONSTRAINT [PK__进货单明细__4D4A6ED8] PRIMARY KEY (编号) 
alter table 预售单明细 drop constraint [PK__预售单明细__5E74FADA]
ALTER TABLE [预售单明细] DROP COLUMN [编号]
 alter table [预售单明细] add [编号] int identity(1,1)
 alter table [dbo].[预售单明细] ADD CONSTRAINT [PK__预售单明细__5E74FADA] PRIMARY KEY (编号) 