
USE [bps]
GO
/****** Object:  View [dbo].[v_proTable]    Script Date: 08/13/2019 09:29:49 ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[v_proTable]'))
DROP VIEW [dbo].[v_proTable]
GO
/****** Object:  View [dbo].[v_cat]    Script Date: 08/13/2019 09:29:49 ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[v_cat]'))
DROP VIEW [dbo].[v_cat]
GO
/****** Object:  View [dbo].[v_price]    Script Date: 08/13/2019 09:29:49 ******/
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[v_price]'))
DROP VIEW [dbo].[v_price]
GO
/****** Object:  Table [dbo].[purchase_supply_product]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_supply_product]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_supply_product]
GO
/****** Object:  Table [dbo].[purchase_categories]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_categories_price]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_categories] DROP CONSTRAINT [DF_purchase_categories_price]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_categories_minnum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_categories] DROP CONSTRAINT [DF_purchase_categories_minnum]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_categories_currentInStore]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_categories] DROP CONSTRAINT [DF_purchase_categories_currentInStore]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_categories_iscat]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_categories] DROP CONSTRAINT [DF_purchase_categories_iscat]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_categories_orderid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_categories] DROP CONSTRAINT [DF_purchase_categories_orderid]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_categories_createdate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_categories] DROP CONSTRAINT [DF_purchase_categories_createdate]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_categories]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_categories]
GO
/****** Object:  Table [dbo].[purchase_customer]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_customer_adddate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_customer] DROP CONSTRAINT [DF_purchase_customer_adddate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_customer_orderid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_customer] DROP CONSTRAINT [DF_purchase_customer_orderid]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_customer_opdate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_customer] DROP CONSTRAINT [DF_purchase_customer_opdate]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_customer]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_customer]
GO
/****** Object:  Table [dbo].[purchase_maker]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_maker]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_maker]
GO
/****** Object:  Table [dbo].[purchase_param]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_para_orderid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_param] DROP CONSTRAINT [DF_purchase_para_orderid]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_param]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_param]
GO
/****** Object:  Table [dbo].[purchase_quote]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_quote_isdraft]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_quote] DROP CONSTRAINT [DF_purchase_quote_isdraft]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_quote_audit1status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_quote] DROP CONSTRAINT [DF_purchase_quote_audit1status]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_quote_audit2status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_quote] DROP CONSTRAINT [DF_purchase_quote_audit2status]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_quote_auditstatus]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_quote] DROP CONSTRAINT [DF_purchase_quote_auditstatus]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_quote]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_quote]
GO
/****** Object:  Table [dbo].[purchase_quote_items]    Script Date: 08/13/2019 09:29:47 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_quote_items]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_quote_items]
GO
/****** Object:  Table [dbo].[purchase_supply]    Script Date: 08/13/2019 09:29:47 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_supply_adddate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_supply] DROP CONSTRAINT [DF_purchase_supply_adddate]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_supply]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_supply]
GO
/****** Object:  Table [dbo].[purchase_supply_group]    Script Date: 08/13/2019 09:29:47 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_supply_group]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_supply_group]
GO
/****** Object:  Table [dbo].[bps_historyprice]    Script Date: 08/13/2019 09:29:47 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_historyprice_adddate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[bps_historyprice] DROP CONSTRAINT [DF_purchase_historyprice_adddate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_bps_historyprice_minnum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[bps_historyprice] DROP CONSTRAINT [DF_bps_historyprice_minnum]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_bps_historyprice_maxnum]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[bps_historyprice] DROP CONSTRAINT [DF_bps_historyprice_maxnum]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[bps_historyprice]') AND type in (N'U'))
DROP TABLE [dbo].[bps_historyprice]
GO
/****** Object:  Table [dbo].[sh_logs]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_sh_logs_createdate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[sh_logs] DROP CONSTRAINT [DF_sh_logs_createdate]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sh_logs]') AND type in (N'U'))
DROP TABLE [dbo].[sh_logs]
GO
/****** Object:  Table [dbo].[temp_purchase_bom_items]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[temp_purchase_bom_items]') AND type in (N'U'))
DROP TABLE [dbo].[temp_purchase_bom_items]
GO
/****** Object:  Table [dbo].[purchase_bom]    Script Date: 08/13/2019 09:29:47 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_bom_status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_bom] DROP CONSTRAINT [DF_purchase_bom_status]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_bom_audit1status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_bom] DROP CONSTRAINT [DF_purchase_bom_audit1status]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_bom_audit2status]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_bom] DROP CONSTRAINT [DF_purchase_bom_audit2status]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_bom_isdraft]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_bom] DROP CONSTRAINT [DF_purchase_bom_isdraft]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_purchase_bom_auditstatus]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[purchase_bom] DROP CONSTRAINT [DF_purchase_bom_auditstatus]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_bom]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_bom]
GO
/****** Object:  Table [dbo].[purchase_bom_items]    Script Date: 08/13/2019 09:29:47 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_bom_items]') AND type in (N'U'))
DROP TABLE [dbo].[purchase_bom_items]
GO
/****** Object:  Table [dbo].[users_dept]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_portal_category_parentid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_dept] DROP CONSTRAINT [DF_portal_category_parentid]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_portal_category_orderid]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_dept] DROP CONSTRAINT [DF_portal_category_orderid]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_portal_category_depth]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_dept] DROP CONSTRAINT [DF_portal_category_depth]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_hr_csscategory_path]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_dept] DROP CONSTRAINT [DF_hr_csscategory_path]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_dept]') AND type in (N'U'))
DROP TABLE [dbo].[users_dept]
GO
/****** Object:  Table [dbo].[users_getpwd]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_getpwd_createdate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_getpwd] DROP CONSTRAINT [DF_users_getpwd_createdate]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_getpwd]') AND type in (N'U'))
DROP TABLE [dbo].[users_getpwd]
GO
/****** Object:  Table [dbo].[users_releation]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_releation]') AND type in (N'U'))
DROP TABLE [dbo].[users_releation]
GO
/****** Object:  Table [dbo].[users_roles]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_roles_issystem]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_roles] DROP CONSTRAINT [DF_users_roles_issystem]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_roles]') AND type in (N'U'))
DROP TABLE [dbo].[users_roles]
GO
/****** Object:  Table [dbo].[users_users]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_portal_users_createdate]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_portal_users_createdate]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_portal_users_lastlogin]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_portal_users_lastlogin]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_avtor]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_avtor]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_logintime]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_logintime]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_logintime_1]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_logintime_1]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_ismgr]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_ismgr]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_issec]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_issec]
END
GO
IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_users_users_isstaff]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[users_users] DROP CONSTRAINT [DF_users_users_isstaff]
END
GO
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_users]') AND type in (N'U'))
DROP TABLE [dbo].[users_users]
GO
/****** Object:  Table [dbo].[users_usersinroles]    Script Date: 08/13/2019 09:29:48 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_usersinroles]') AND type in (N'U'))
DROP TABLE [dbo].[users_usersinroles]
GO
/****** Object:  Table [dbo].[users_usersinroles]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_usersinroles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_usersinroles](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NULL,
	[rolename] [nvarchar](50) NULL,
 CONSTRAINT [PK_portal_usersinroles] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[users_usersinroles] ON
INSERT [dbo].[users_usersinroles] ([id], [uid], [rolename]) VALUES (1, 1, N'administrators')
INSERT [dbo].[users_usersinroles] ([id], [uid], [rolename]) VALUES (2, 1, N'admin operator')
INSERT [dbo].[users_usersinroles] ([id], [uid], [rolename]) VALUES (3, 4, N'bom1')
INSERT [dbo].[users_usersinroles] ([id], [uid], [rolename]) VALUES (4, 4, N'quote1')
INSERT [dbo].[users_usersinroles] ([id], [uid], [rolename]) VALUES (5, 2, N'bom2')
INSERT [dbo].[users_usersinroles] ([id], [uid], [rolename]) VALUES (6, 2, N'quote2')
SET IDENTITY_INSERT [dbo].[users_usersinroles] OFF
/****** Object:  Table [dbo].[users_users]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_users]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_users](
	[uid] [int] IDENTITY(1,1) NOT NULL,
	[username] [nvarchar](256) NOT NULL,
	[adpath] [nvarchar](1024) NULL,
	[firstname] [nvarchar](50) NULL,
	[lastname] [nvarchar](50) NULL,
	[city] [nvarchar](256) NULL,
	[Office] [nvarchar](256) NULL,
	[Description] [nvarchar](1024) NULL,
	[Tel] [nvarchar](128) NULL,
	[fax] [nvarchar](128) NULL,
	[email] [nvarchar](256) NULL,
	[MailType] [nvarchar](128) NULL,
	[Title] [nvarchar](128) NULL,
	[Department] [nvarchar](128) NULL,
	[Company] [nvarchar](128) NULL,
	[Password] [nvarchar](128) NULL,
	[displayname] [nvarchar](128) NULL,
	[StaffCode] [nvarchar](128) NULL,
	[IsAccountActive] [int] NULL,
	[createdate] [datetime] NULL CONSTRAINT [DF_portal_users_createdate]  DEFAULT (getdate()),
	[lastlogin] [datetime] NULL CONSTRAINT [DF_portal_users_lastlogin]  DEFAULT (getdate()),
	[sex] [nvarchar](50) NULL,
	[avtor] [nvarchar](300) NULL CONSTRAINT [DF_users_users_avtor]  DEFAULT ('avtor.jpg'),
	[logintimes] [int] NULL CONSTRAINT [DF_users_users_logintime]  DEFAULT ((0)),
	[ip] [nvarchar](50) NULL,
	[logintime] [int] NULL CONSTRAINT [DF_users_users_logintime_1]  DEFAULT ((0)),
	[intro] [nvarchar](500) NULL,
	[ismgr] [int] NULL CONSTRAINT [DF_users_users_ismgr]  DEFAULT ((0)),
	[issec] [int] NULL CONSTRAINT [DF_users_users_issec]  DEFAULT ((0)),
	[isstaff] [int] NULL CONSTRAINT [DF_users_users_isstaff]  DEFAULT ((1)),
	[aid] [int] NULL,
	[mobile] [nvarchar](50) NULL,
	[pinyin] [nvarchar](50) NULL,
 CONSTRAINT [PK_portal_users_1] PRIMARY KEY CLUSTERED 
(
	[uid] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[users_users] ON
INSERT [dbo].[users_users] ([uid], [username], [adpath], [firstname], [lastname], [city], [Office], [Description], [Tel], [fax], [email], [MailType], [Title], [Department], [Company], [Password], [displayname], [StaffCode], [IsAccountActive], [createdate], [lastlogin], [sex], [avtor], [logintimes], [ip], [logintime], [intro], [ismgr], [issec], [isstaff], [aid], [mobile], [pinyin]) VALUES (1, N'admin', NULL, NULL, NULL, NULL, N'', NULL, N'', N'', N'', NULL, N'', N'PROJ', N'', N'CE-0B-FD-15-05-9B-68-D6-76-88-88-4D-7A-3D-3E-8C', N'李万宝', N'', NULL, CAST(0x0000AA0300E9A8E5 AS DateTime), CAST(0x0000AA0300E9A8E5 AS DateTime), N'', N'avtor.jpg', 0, NULL, 0, N'', 0, 0, 1, NULL, N'', N'LWB')
INSERT [dbo].[users_users] ([uid], [username], [adpath], [firstname], [lastname], [city], [Office], [Description], [Tel], [fax], [email], [MailType], [Title], [Department], [Company], [Password], [displayname], [StaffCode], [IsAccountActive], [createdate], [lastlogin], [sex], [avtor], [logintimes], [ip], [logintime], [intro], [ismgr], [issec], [isstaff], [aid], [mobile], [pinyin]) VALUES (2, N'luo', NULL, NULL, NULL, NULL, N'', NULL, N'', N'', N'', NULL, N'', N'PROJ', N'', N'CE-0B-FD-15-05-9B-68-D6-76-88-88-4D-7A-3D-3E-8C', N'罗总', N'', NULL, CAST(0x0000AA1B0090C44D AS DateTime), CAST(0x0000AA1B0090C44D AS DateTime), N'', N'avtor.jpg', 0, NULL, 0, N'', 0, 0, 1, NULL, N'', N'LZ')
INSERT [dbo].[users_users] ([uid], [username], [adpath], [firstname], [lastname], [city], [Office], [Description], [Tel], [fax], [email], [MailType], [Title], [Department], [Company], [Password], [displayname], [StaffCode], [IsAccountActive], [createdate], [lastlogin], [sex], [avtor], [logintimes], [ip], [logintime], [intro], [ismgr], [issec], [isstaff], [aid], [mobile], [pinyin]) VALUES (4, N'kevin', NULL, NULL, NULL, NULL, N'', NULL, N'', N'', N'983506039@qq.com', NULL, N'', N'IT', N'', N'CE-0B-FD-15-05-9B-68-D6-76-88-88-4D-7A-3D-3E-8C', N'黄科长', N'', NULL, CAST(0x0000AA1B00911353 AS DateTime), CAST(0x0000AA1B00911353 AS DateTime), N'', N'avtor.jpg', 0, NULL, 0, N'', 0, 0, 1, NULL, N'', N'HKC')
SET IDENTITY_INSERT [dbo].[users_users] OFF
/****** Object:  Table [dbo].[users_roles]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_roles]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_roles](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[rolename] [nvarchar](50) NULL,
	[issystem] [int] NULL CONSTRAINT [DF_users_roles_issystem]  DEFAULT ((0)),
	[roletype] [nvarchar](50) NULL,
 CONSTRAINT [PK_users_roles] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[users_roles] ON
INSERT [dbo].[users_roles] ([id], [rolename], [issystem], [roletype]) VALUES (1, N'administrators', 1, N'系统管理员')
INSERT [dbo].[users_roles] ([id], [rolename], [issystem], [roletype]) VALUES (2, N'bom1', 1, N'BOM审批人')
INSERT [dbo].[users_roles] ([id], [rolename], [issystem], [roletype]) VALUES (3, N'bom2', 1, N'BOM承认人')
INSERT [dbo].[users_roles] ([id], [rolename], [issystem], [roletype]) VALUES (4, N'quote1', 1, N'Quote审批人')
INSERT [dbo].[users_roles] ([id], [rolename], [issystem], [roletype]) VALUES (5, N'quote2', 1, N'Quote承认人')
SET IDENTITY_INSERT [dbo].[users_roles] OFF
/****** Object:  Table [dbo].[users_releation]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_releation]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_releation](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[mgrid] [int] NULL,
	[secid] [int] NULL,
 CONSTRAINT [PK_users_releation] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[users_getpwd]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_getpwd]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_getpwd](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[uid] [int] NOT NULL,
	[display] [nvarchar](50) NULL,
	[createdate] [datetime] NULL CONSTRAINT [DF_users_getpwd_createdate]  DEFAULT (getdate()),
 CONSTRAINT [PK_users_getpwd] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[users_dept]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[users_dept]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[users_dept](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[catname] [nvarchar](50) NULL,
	[parentid] [int] NULL CONSTRAINT [DF_portal_category_parentid]  DEFAULT ((0)),
	[orderid] [int] NULL CONSTRAINT [DF_portal_category_orderid]  DEFAULT ((0)),
	[depth] [int] NULL CONSTRAINT [DF_portal_category_depth]  DEFAULT ((1)),
	[note] [nvarchar](200) NULL,
	[path] [nvarchar](1000) NULL CONSTRAINT [DF_hr_csscategory_path]  DEFAULT (''),
	[types] [nvarchar](50) NULL,
 CONSTRAINT [PK_users_dept] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[users_dept] ON
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (1, N'IT', 0, 0, 1, NULL, N'', NULL)
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (2, N'FIN', 0, 0, 1, NULL, N'', NULL)
INSERT [dbo].[users_dept] ([id], [catname], [parentid], [orderid], [depth], [note], [path], [types]) VALUES (3, N'PROJ', 0, 0, 1, NULL, N'', NULL)
SET IDENTITY_INSERT [dbo].[users_dept] OFF
/****** Object:  Table [dbo].[purchase_bom_items]    Script Date: 08/13/2019 09:29:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_bom_items]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_bom_items](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[ItemCode] [nvarchar](50) NULL,
	[ItemName] [nvarchar](200) NULL,
	[Spec] [nvarchar](500) NULL,
	[Levels] [nvarchar](50) NULL,
	[FindNumber] [nvarchar](50) NULL,
	[Quantity] [decimal](18, 1) NULL,
	[ReferenceDesignator] [nvarchar](200) NULL,
	[Revision] [decimal](18, 1) NULL,
	[UOM] [nvarchar](50) NULL,
	[MPN] [nvarchar](50) NULL,
	[Manufacturer] [nvarchar](200) NULL,
	[LostRate] [decimal](18, 0) NULL,
	[Attrition] [decimal](18, 0) NULL,
	[Envprotect] [nvarchar](50) NULL,
	[Note] [nvarchar](500) NULL,
	[bid] [int] NULL,
	[Drawing2] [nvarchar](200) NULL,
 CONSTRAINT [PK_purchase_goods_items] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[purchase_bom_items] ON
INSERT [dbo].[purchase_bom_items] ([id], [ItemCode], [ItemName], [Spec], [Levels], [FindNumber], [Quantity], [ReferenceDesignator], [Revision], [UOM], [MPN], [Manufacturer], [LostRate], [Attrition], [Envprotect], [Note], [bid], [Drawing2]) VALUES (1, N'M003', N'Flat Washer', NULL, NULL, NULL, CAST(1.0 AS Decimal(18, 1)), NULL, CAST(1.0 AS Decimal(18, 1)), N'', N'24186', N'LPS BOSSARD PVT', CAST(0 AS Decimal(18, 0)), NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[purchase_bom_items] ([id], [ItemCode], [ItemName], [Spec], [Levels], [FindNumber], [Quantity], [ReferenceDesignator], [Revision], [UOM], [MPN], [Manufacturer], [LostRate], [Attrition], [Envprotect], [Note], [bid], [Drawing2]) VALUES (2, N'1585', N'Cross Recessed Pan Head Screw', NULL, NULL, NULL, CAST(1.0 AS Decimal(18, 1)), NULL, CAST(1.0 AS Decimal(18, 1)), N'', N'11060', N'ANIXTER', CAST(0 AS Decimal(18, 0)), NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[purchase_bom_items] ([id], [ItemCode], [ItemName], [Spec], [Levels], [FindNumber], [Quantity], [ReferenceDesignator], [Revision], [UOM], [MPN], [Manufacturer], [LostRate], [Attrition], [Envprotect], [Note], [bid], [Drawing2]) VALUES (3, N'Hexagon', N'Hexagon Socket Head Cap Screw', NULL, NULL, NULL, CAST(1.0 AS Decimal(18, 1)), NULL, CAST(1.0 AS Decimal(18, 1)), N'', N'10487', N'OHTA', CAST(0 AS Decimal(18, 0)), NULL, NULL, NULL, 1, NULL)
INSERT [dbo].[purchase_bom_items] ([id], [ItemCode], [ItemName], [Spec], [Levels], [FindNumber], [Quantity], [ReferenceDesignator], [Revision], [UOM], [MPN], [Manufacturer], [LostRate], [Attrition], [Envprotect], [Note], [bid], [Drawing2]) VALUES (4, N'1000-M8C016-31', N'HEXAGON SOCKET HEAD CAP SCREW', NULL, NULL, NULL, CAST(1.0 AS Decimal(18, 1)), NULL, CAST(1.0 AS Decimal(18, 1)), N'', N'A0996', N'BOSSARD', CAST(0 AS Decimal(18, 0)), NULL, NULL, NULL, 1, NULL)
SET IDENTITY_INSERT [dbo].[purchase_bom_items] OFF
/****** Object:  Table [dbo].[purchase_bom]    Script Date: 08/13/2019 09:29:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_bom]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_bom](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[productname] [nvarchar](100) NULL,
	[productcode] [nvarchar](50) NULL,
	[revision] [decimal](18, 1) NULL,
	[designname] [nvarchar](100) NULL,
	[designdate] [datetime] NULL,
	[Envprotect] [nvarchar](50) NULL,
	[customername] [nvarchar](200) NULL,
	[customercode] [nvarchar](50) NULL,
	[producttype] [nvarchar](100) NULL,
	[attach1] [nvarchar](500) NULL,
	[attach2] [nvarchar](500) NULL,
	[note] [nvarchar](500) NULL,
	[status] [int] NULL CONSTRAINT [DF_purchase_bom_status]  DEFAULT ((0)),
	[audit1uid] [int] NULL  DEFAULT(0),
	[audit1name] [nvarchar](50) NULL,
	[audit1date] [datetime] NULL,
	[audit1note] [nvarchar](50) NULL,
	[audit1status] [int] NULL CONSTRAINT [DF_purchase_bom_audit1status]  DEFAULT ((0)),
	[audit2uid] [int] NULL DEFAULT(0),
	[audit2name] [nvarchar](50) NULL,
	[audit2date] [datetime] NULL,
	[audit2note] [nvarchar](500) NULL,
	[audit2status] [int] NULL CONSTRAINT [DF_purchase_bom_audit2status]  DEFAULT ((0)),
	[createdate] [datetime] NULL,
	[opname] [nvarchar](50) NULL,
	[opdate] [datetime] NULL,
	[opuid] [int] NULL,
	[isdraft] [int] NULL CONSTRAINT [DF_purchase_bom_isdraft]  DEFAULT ((1)),
	[auditstatus] [int] NULL CONSTRAINT [DF_purchase_bom_auditstatus]  DEFAULT ((0)),
	[waituid] [int] NULL,
	[waitname] [nvarchar](50) NULL,
	[appname] [nvarchar](100) NULL,
	[appuid] [int] NULL,
 CONSTRAINT [PK_purchase_goods] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[purchase_bom] ON
INSERT [dbo].[purchase_bom] ([id], [productname], [productcode], [revision], [designname], [designdate], [Envprotect], [customername], [customercode], [producttype], [attach1], [attach2], [note], [status], [audit1uid], [audit1name], [audit1date], [audit1note], [audit1status], [audit2uid], [audit2name], [audit2date], [audit2note], [audit2status], [createdate], [opname], [opdate], [opuid], [isdraft], [auditstatus], [waituid], [waitname], [appname], [appuid]) VALUES (1, N'次轮', N'G0001', CAST(1.0 AS Decimal(18, 1)), N'李万宝', CAST(0x0000AAA800000000 AS DateTime), NULL, N'戴尔', N'DELL', N'组装件', N'', N'', N'', 0, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, 0, CAST(0x0000AAA8007CE6A2 AS DateTime), N'李万宝', CAST(0x0000AAA8007CE6A2 AS DateTime), 1, 0, 1, 0, N'', N'李万宝', 1)
SET IDENTITY_INSERT [dbo].[purchase_bom] OFF
/****** Object:  Table [dbo].[temp_purchase_bom_items]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[temp_purchase_bom_items]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[temp_purchase_bom_items](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[ItemCode] [nvarchar](50) NULL,
	[ItemName] [nvarchar](200) NULL,
	[Spec] [nvarchar](500) NULL,
	[Levels] [nvarchar](50) NULL,
	[FindNumber] [nvarchar](50) NULL,
	[Quantity] [decimal](18, 1) NULL,
	[ReferenceDesignator] [nvarchar](200) NULL,
	[Revision] [decimal](18, 1) NULL,
	[UOM] [nvarchar](50) NULL,
	[MPN] [nvarchar](50) NULL,
	[Manufacturer] [nvarchar](200) NULL,
	[LostRate] [decimal](18, 0) NULL,
	[Attrition] [decimal](18, 0) NULL,
	[Envprotect] [nvarchar](50) NULL,
	[Note] [nvarchar](500) NULL,
	[bid] [int] NULL,
	[guid] [uniqueidentifier] NULL,
 CONSTRAINT [PK_purchase_goods_items2] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[sh_logs]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sh_logs]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[sh_logs](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[shid] [int] NULL,
	[createdate] [datetime] NULL CONSTRAINT [DF_sh_logs_createdate]  DEFAULT (getdate()),
	[uid] [int] NULL,
	[myauditstatus] [int] NULL,
	[myauditnote] [nvarchar](500) NULL,
	[types] [nvarchar](50) NULL,
 CONSTRAINT [PK_sh_logs] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[bps_historyprice]    Script Date: 08/13/2019 09:29:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[bps_historyprice]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[bps_historyprice](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[pid] [int] NULL,
	[price] [nvarchar](50) NULL,
	[adddate] [date] NULL CONSTRAINT [DF_purchase_historyprice_adddate]  DEFAULT (getdate()),
	[pricedate] [datetime] NULL,
	[supplyname] [nvarchar](200) NULL,
	[minnum] [int] NULL CONSTRAINT [DF_bps_historyprice_minnum]  DEFAULT ((0)),
	[maxnum] [int] NULL CONSTRAINT [DF_bps_historyprice_maxnum]  DEFAULT ((0)),
	[pricedateto] [datetime] NULL,
 CONSTRAINT [PK_purchase_historyprice] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Table [dbo].[purchase_supply_group]    Script Date: 08/13/2019 09:29:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_supply_group]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_supply_group](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[groupname] [nvarchar](500) NULL,
	[issystem] [int] NULL,
 CONSTRAINT [PK_purchase_supply_group] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[purchase_supply_group] ON
INSERT [dbo].[purchase_supply_group] ([id], [groupname], [issystem]) VALUES (1, N'核心部件供应商', NULL)
INSERT [dbo].[purchase_supply_group] ([id], [groupname], [issystem]) VALUES (2, N'普通部件供应商', NULL)
INSERT [dbo].[purchase_supply_group] ([id], [groupname], [issystem]) VALUES (3, N'合作伙伴供应商', NULL)
INSERT [dbo].[purchase_supply_group] ([id], [groupname], [issystem]) VALUES (4, N'集团内部供应商', NULL)
INSERT [dbo].[purchase_supply_group] ([id], [groupname], [issystem]) VALUES (5, N'潜在供应商', NULL)
SET IDENTITY_INSERT [dbo].[purchase_supply_group] OFF
/****** Object:  Table [dbo].[purchase_supply]    Script Date: 08/13/2019 09:29:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_supply]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_supply](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[supplyname] [nvarchar](500) NULL,
	[supplycode] [nvarchar](200) NULL,
	[contactname] [nvarchar](200) NULL,
	[purchaseuser] [nvarchar](200) NULL,
	[mobile] [nvarchar](500) NULL,
	[email] [nvarchar](500) NULL,
	[tel] [nvarchar](200) NULL,
	[fax] [nvarchar](50) NULL,
	[website] [nvarchar](500) NULL,
	[groupname] [nvarchar](50) NULL,
	[paycircle] [nvarchar](500) NULL,
	[bankusername] [nvarchar](200) NULL,
	[banknum] [nvarchar](200) NULL,
	[payment] [nvarchar](200) NULL,
	[invoicetype] [nvarchar](200) NULL,
	[taxrate] [nvarchar](100) NULL,
	[incoterm] [nvarchar](100) NULL,
	[address] [nvarchar](1000) NULL,
	[note] [nvarchar](1000) NULL,
	[createdate] [datetime] NULL CONSTRAINT [DF_purchase_supply_adddate]  DEFAULT (getdate()),
	[updateusername] [nvarchar](50) NULL,
	[opname] [nvarchar](50) NULL,
	[opuid] [int] NULL,
	[opdate] [datetime] NULL,
 CONSTRAINT [PK_purchase_supply] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[purchase_supply] ON
INSERT [dbo].[purchase_supply] ([id], [supplyname], [supplycode], [contactname], [purchaseuser], [mobile], [email], [tel], [fax], [website], [groupname], [paycircle], [bankusername], [banknum], [payment], [invoicetype], [taxrate], [incoterm], [address], [note], [createdate], [updateusername], [opname], [opuid], [opdate]) VALUES (1, N'荣顺电子', N'FF', N'', N'admin', N'', N'', N'', N'', N'', N'默认分组', N'45天', N'', N'', N'电汇', N'增值税专用发票', N'', N'EXW', N'', N'', CAST(0x0000AA22009B8AF7 AS DateTime), NULL, N'李万宝', 1, CAST(0x0000AA2200AAD642 AS DateTime))
INSERT [dbo].[purchase_supply] ([id], [supplyname], [supplycode], [contactname], [purchaseuser], [mobile], [email], [tel], [fax], [website], [groupname], [paycircle], [bankusername], [banknum], [payment], [invoicetype], [taxrate], [incoterm], [address], [note], [createdate], [updateusername], [opname], [opuid], [opdate]) VALUES (2, N'苏州营营有限公司', N'SZYY', N'李军', N'admin', N'0581-2584786', N'', N'', N'', N'', N'合作伙伴供应商', N'60天', N'', N'', N'电汇', N'增值税专用发票', N'', N'EXW', N'', N'', CAST(0x0000AA2200A5D339 AS DateTime), NULL, N'李万宝', 1, CAST(0x0000AA2200A5D339 AS DateTime))
INSERT [dbo].[purchase_supply] ([id], [supplyname], [supplycode], [contactname], [purchaseuser], [mobile], [email], [tel], [fax], [website], [groupname], [paycircle], [bankusername], [banknum], [payment], [invoicetype], [taxrate], [incoterm], [address], [note], [createdate], [updateusername], [opname], [opuid], [opdate]) VALUES (3, N'佐途五金旗舰店', N'ZT', N'张军', N'admin', N'', N'', N'14852698745', N'', N'', N'默认分组', N'45天', N'', N'', N'电汇', N'增值税专用发票', N'4', N'EXW', N'', N'紧固件供应商', CAST(0x0000AA2200A61FA3 AS DateTime), NULL, N'李万宝', 1, CAST(0x0000AA2200A61FA3 AS DateTime))
INSERT [dbo].[purchase_supply] ([id], [supplyname], [supplycode], [contactname], [purchaseuser], [mobile], [email], [tel], [fax], [website], [groupname], [paycircle], [bankusername], [banknum], [payment], [invoicetype], [taxrate], [incoterm], [address], [note], [createdate], [updateusername], [opname], [opuid], [opdate]) VALUES (4, N'启明星', N'QMX', N'李万宝', N'admin', N'18155261033', N'', N'', N'', N'', N'默认分组', N'45天', N'', N'', N'电汇', N'增值税专用发票', N'6', N'EXW', N'', N'软件供应商', CAST(0x0000AA2200A64154 AS DateTime), NULL, N'李万宝', 1, CAST(0x0000AA2200A64154 AS DateTime))
INSERT [dbo].[purchase_supply] ([id], [supplyname], [supplycode], [contactname], [purchaseuser], [mobile], [email], [tel], [fax], [website], [groupname], [paycircle], [bankusername], [banknum], [payment], [invoicetype], [taxrate], [incoterm], [address], [note], [createdate], [updateusername], [opname], [opuid], [opdate]) VALUES (5, N'大润发', N'DRF', N'', N'admin', N'', N'', N'', N'', N'', N'默认分组', N'预付', N'', N'', N'电汇', N'增值税专用发票', N'', N'EXW', N'', N'', CAST(0x0000AA2200A660C7 AS DateTime), NULL, N'李万宝', 1, CAST(0x0000AA2200A660C7 AS DateTime))
INSERT [dbo].[purchase_supply] ([id], [supplyname], [supplycode], [contactname], [purchaseuser], [mobile], [email], [tel], [fax], [website], [groupname], [paycircle], [bankusername], [banknum], [payment], [invoicetype], [taxrate], [incoterm], [address], [note], [createdate], [updateusername], [opname], [opuid], [opdate]) VALUES (6, N'BOSSARD JAPAN', N'BOSSARD JAPAN', N'', N'admin', N'', N'', N'', N'', N'', N'默认分组', N'45天', N'', N'', N'电汇', N'增值税专用发票', N'3', N'EXW', N'', N'', CAST(0x0000AA2200AE5320 AS DateTime), NULL, N'李万宝', 1, CAST(0x0000AA2200AE5320 AS DateTime))
SET IDENTITY_INSERT [dbo].[purchase_supply] OFF
/****** Object:  Table [dbo].[purchase_quote_items]    Script Date: 08/13/2019 09:29:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_quote_items]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_quote_items](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[ItemCode] [nvarchar](100) NULL,
	[ItemName] [nvarchar](300) NULL,
	[Spec] [nvarchar](500) NULL,
	[MPN] [nvarchar](50) NULL,
	[Manufacturer] [nvarchar](100) NULL,
	[uom] [nvarchar](50) NULL,
	[EnvProject] [nvarchar](50) NULL,
	[supplycode] [nvarchar](50) NULL,
	[supplyname] [nvarchar](50) NULL,
	[LeadTime] [nvarchar](50) NULL,
	[quantity] [decimal](18, 2) NULL,
	[Price] [decimal](18, 2) NULL,
	[Currency] [nvarchar](50) NULL,
	[Remarks] [nvarchar](50) NULL,
	[quoteid] [int] NULL,
	[Drawing2] [nvarchar](300) NULL,
 CONSTRAINT [PK_purchase_price_items] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[purchase_quote_items] ON
INSERT [dbo].[purchase_quote_items] ([id], [ItemCode], [ItemName], [Spec], [MPN], [Manufacturer], [uom], [EnvProject], [supplycode], [supplyname], [LeadTime], [quantity], [Price], [Currency], [Remarks], [quoteid], [Drawing2]) VALUES (1, N'M003', N'Flat Washer', N'', N'24186', N'LPS BOSSARD PVT', N'', NULL, N'SZYY', N'苏州营营有限公司', N'', CAST(1.00 AS Decimal(18, 2)), CAST(2.00 AS Decimal(18, 2)), N'RMB', NULL, 2, N'')
INSERT [dbo].[purchase_quote_items] ([id], [ItemCode], [ItemName], [Spec], [MPN], [Manufacturer], [uom], [EnvProject], [supplycode], [supplyname], [LeadTime], [quantity], [Price], [Currency], [Remarks], [quoteid], [Drawing2]) VALUES (2, N'1585', N'Cross Recessed Pan Head Screw', N'', N'11060', N'ANIXTER', N'', NULL, N'ZT', N'佐途五金旗舰店', N'', CAST(1.00 AS Decimal(18, 2)), CAST(3.00 AS Decimal(18, 2)), N'RMB', NULL, 2, N'')
INSERT [dbo].[purchase_quote_items] ([id], [ItemCode], [ItemName], [Spec], [MPN], [Manufacturer], [uom], [EnvProject], [supplycode], [supplyname], [LeadTime], [quantity], [Price], [Currency], [Remarks], [quoteid], [Drawing2]) VALUES (3, N'Hexagon', N'Hexagon Socket Head Cap Screw', N'', N'10487', N'OHTA', N'', NULL, N'SZYY', N'苏州营营有限公司', N'', CAST(1.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), N'USD', NULL, 2, N'')
INSERT [dbo].[purchase_quote_items] ([id], [ItemCode], [ItemName], [Spec], [MPN], [Manufacturer], [uom], [EnvProject], [supplycode], [supplyname], [LeadTime], [quantity], [Price], [Currency], [Remarks], [quoteid], [Drawing2]) VALUES (4, N'1000-M8C016-31', N'HEXAGON SOCKET HEAD CAP SCREW', N'', N'A0996', N'BOSSARD', N'', NULL, N'BOSSARD JAPAN', N'BOSSARD JAPAN', N'', CAST(1.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), N'USD', NULL, 2, N'')
SET IDENTITY_INSERT [dbo].[purchase_quote_items] OFF
/****** Object:  Table [dbo].[purchase_quote]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_quote]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_quote](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[quotecode] [nvarchar](50) NULL,
	[productcode] [nvarchar](50) NULL,
	[productname] [nvarchar](50) NULL,
	[bomrevision] [decimal](18, 1) NULL,
	[customercode] [nvarchar](50) NULL,
	[customername] [nvarchar](50) NULL,
	[sellname] [nvarchar](50) NULL,
	[quotedate] [datetime] NULL,
	[revision] [decimal](18, 1) NULL,
	[quantity] [decimal](18, 0) NULL,
	[piece] [nvarchar](50) NULL,
	[leadtime] [nvarchar](50) NULL,
	[note] [nvarchar](500) NULL,
	[createdate] [datetime] NULL,
	[opname] [nvarchar](50) NULL,
	[opuid] [int] NULL,
	[opdate] [datetime] NULL,
	[bomid] [int] NULL,
	[isdraft] [int] NULL CONSTRAINT [DF_purchase_quote_isdraft]  DEFAULT ((1)),
	[audit1uid] [int] NULL DEFAULT(0),
	[audit1name] [nvarchar](50) NULL,
	[audit1date] [datetime] NULL,
	[audit1note] [nvarchar](50) NULL,
	[audit1status] [int] NULL CONSTRAINT [DF_purchase_quote_audit1status]  DEFAULT ((0)),
	[audit2uid] [int] NULL  DEFAULT(0),
	[audit2name] [nvarchar](50) NULL,
	[audit2date] [datetime] NULL,
	[audit2note] [nvarchar](500) NULL,
	[audit2status] [int] NULL CONSTRAINT [DF_purchase_quote_audit2status]  DEFAULT ((0)),
	[auditstatus] [int] NULL CONSTRAINT [DF_purchase_quote_auditstatus]  DEFAULT ((0)),
	[waituid] [int] NULL,
	[waitname] [nvarchar](50) NULL,
	[appname] [nvarchar](50) NULL,
	[appuid] [int] NULL,
	[materialfee] [decimal](18, 2) NULL,
	[materialrate] [decimal](18, 2) NULL,
	[mgrrate] [decimal](18, 2) NULL,
	[mgrfee] [decimal](18, 2) NULL,
	[profitfee] [decimal](18, 2) NULL,
	[profitrate] [decimal](18, 2) NULL,
	[price] [decimal](18, 2) NULL,
	[workprice] [decimal](18, 2) NULL,
	[workfee] [decimal](18, 2) NULL,
	[workhour] [decimal](18, 2) NULL,
	[toolingcost] [decimal](18, 2) NULL,
	[adjustrate] [decimal](18, 2) NULL,
	[adjustfee] [decimal](18, 2) NULL,
 CONSTRAINT [PK_purchase_price] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[purchase_quote] ON
INSERT [dbo].[purchase_quote] ([id], [quotecode], [productcode], [productname], [bomrevision], [customercode], [customername], [sellname], [quotedate], [revision], [quantity], [piece], [leadtime], [note], [createdate], [opname], [opuid], [opdate], [bomid], [isdraft], [audit1uid], [audit1name], [audit1date], [audit1note], [audit1status], [audit2uid], [audit2name], [audit2date], [audit2note], [audit2status], [auditstatus], [waituid], [waitname], [appname], [appuid], [materialfee], [materialrate], [mgrrate], [mgrfee], [profitfee], [profitrate], [price], [workprice], [workfee], [workhour], [toolingcost], [adjustrate], [adjustfee]) VALUES (1, N'Q001', N'G0001', N'次轮', CAST(1.0 AS Decimal(18, 1)), N'DELL', N'戴尔', N'李万宝', CAST(0x0000AAA800000000 AS DateTime), CAST(1.0 AS Decimal(18, 1)), CAST(0 AS Decimal(18, 0)), N'PCS', NULL, N'', CAST(0x0000AAA8007E1441 AS DateTime), N'李万宝', 1, CAST(0x0000AAA8007E1441 AS DateTime), 1, 1, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, N'李万宝', 1, NULL, NULL, CAST(10.00 AS Decimal(18, 2)), NULL, NULL, CAST(6.00 AS Decimal(18, 2)), NULL, CAST(0.00 AS Decimal(18, 2)), NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), NULL)
INSERT [dbo].[purchase_quote] ([id], [quotecode], [productcode], [productname], [bomrevision], [customercode], [customername], [sellname], [quotedate], [revision], [quantity], [piece], [leadtime], [note], [createdate], [opname], [opuid], [opdate], [bomid], [isdraft], [audit1uid], [audit1name], [audit1date], [audit1note], [audit1status], [audit2uid], [audit2name], [audit2date], [audit2note], [audit2status], [auditstatus], [waituid], [waitname], [appname], [appuid], [materialfee], [materialrate], [mgrrate], [mgrfee], [profitfee], [profitrate], [price], [workprice], [workfee], [workhour], [toolingcost], [adjustrate], [adjustfee]) VALUES (2, N'0285', N'G0001', N'次轮', CAST(1.0 AS Decimal(18, 1)), N'DELL', N'戴尔', N'李万宝', CAST(0x0000AAA800000000 AS DateTime), CAST(1.0 AS Decimal(18, 1)), CAST(0 AS Decimal(18, 0)), N'PCS', NULL, N'', CAST(0x0000AAA8007F148E AS DateTime), N'李万宝', 1, CAST(0x0000AAA8007F148E AS DateTime), 1, 1, NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, NULL, 0, 0, NULL, NULL, N'李万宝', 1, CAST(0.00 AS Decimal(18, 2)), NULL, CAST(10.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), CAST(6.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)))
SET IDENTITY_INSERT [dbo].[purchase_quote] OFF
/****** Object:  Table [dbo].[purchase_param]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_param]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_param](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[paramname] [nvarchar](200) NULL,
	[types] [nvarchar](50) NULL,
	[orderid] [int] NULL CONSTRAINT [DF_purchase_para_orderid]  DEFAULT ((0)),
	[rate] [nvarchar](100) NULL,
 CONSTRAINT [PK_purchase_para] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[purchase_param] ON
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (2, N'PCS', N'unit', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (3, N'仓库1', N'store', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (4, N'空运', N'shipmethod', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (5, N'水运', N'shipmethod', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (6, N'CNY', N'Incoterm', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (8, N'银行转账', N'payment', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (9, N'30天', N'paycircle', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (10, N'CNY', N'currency', 0, N'1')
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (11, N'组装件', N'producttype', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (12, N'结构件', N'producttype', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (13, N'易损件', N'producttype', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (14, N'是', N'envprotect', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (15, N'否', N'envprotect', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (16, N'未知', N'envprotect', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (17, N'调查中', N'envprotect', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (18, N'Each', N'unit', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (19, N'台', N'unit', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (20, N'个', N'unit', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (21, N'箱', N'unit', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (29, N'陆运', N'shipmethod', -1, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (31, N'45天', N'paycircle', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (32, N'60天', N'paycircle', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (33, N'90天', N'paycircle', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (34, N'0天', N'paycircle', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (35, N'电汇', N'payment', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (36, N'承兑', N'payment', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (37, N'其它', N'payment', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (38, N'增值税专用发票', N'invoicetype', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (39, N'增值税(电子)普通发票', N'invoicetype', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (40, N'机打发票A版三联', N'invoicetype', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (41, N'机打发票一联', N'invoicetype', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (42, N'普通发票', N'invoicetype', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (43, N'USD', N'Incoterm', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (44, N'JPY', N'Incoterm', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (45, N'DAP', N'Incoterm', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (46, N'Others', N'Incoterm', 0, NULL)
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (47, N'USD', N'currency', 0, N'6')
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (48, N'JPY', N'currency', 0, N'0.07')
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (49, N'HKD', N'currency', 0, N'1.5')
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (50, N'TWD', N'currency', 0, N'0.25')
INSERT [dbo].[purchase_param] ([id], [paramname], [types], [orderid], [rate]) VALUES (51, N'75天', N'paycircle', 0, NULL)
SET IDENTITY_INSERT [dbo].[purchase_param] OFF
/****** Object:  Table [dbo].[purchase_maker]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_maker]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_maker](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[code] [nvarchar](50) NULL,
	[name] [nvarchar](200) NULL,
	[fullname] [nvarchar](50) NULL,
	[note] [nvarchar](300) NULL,
	[adddate] [datetime] NULL,
 CONSTRAINT [PK_purchase_maker] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[purchase_maker] ON
INSERT [dbo].[purchase_maker] ([id], [code], [name], [fullname], [note], [adddate]) VALUES (1, N'A0996', N'BOSSARD', N'柏中', N'螺丝钉制造商', CAST(0x0000AA220097188C AS DateTime))
INSERT [dbo].[purchase_maker] ([id], [code], [name], [fullname], [note], [adddate]) VALUES (2, N'10487', N'OHTA', N'大田', N'齿轮制造商', CAST(0x0000AA22009C8D39 AS DateTime))
INSERT [dbo].[purchase_maker] ([id], [code], [name], [fullname], [note], [adddate]) VALUES (3, N'11060', N'ANIXTER', N'儒苏', N'瑞士电缆制造商', CAST(0x0000AA2200A01A68 AS DateTime))
INSERT [dbo].[purchase_maker] ([id], [code], [name], [fullname], [note], [adddate]) VALUES (4, N'20589', N'FASTENAL ', N'', N'紧固件', CAST(0x0000AA2200A09709 AS DateTime))
INSERT [dbo].[purchase_maker] ([id], [code], [name], [fullname], [note], [adddate]) VALUES (5, N'20029', N'FF ', N'荣顺', NULL, CAST(0x0000AA2200A0B84B AS DateTime))
INSERT [dbo].[purchase_maker] ([id], [code], [name], [fullname], [note], [adddate]) VALUES (6, N'28175', N'OPTIMAS OE SOLUTIONS', N'', N'', CAST(0x0000AA2200AE8E06 AS DateTime))
INSERT [dbo].[purchase_maker] ([id], [code], [name], [fullname], [note], [adddate]) VALUES (7, N'24140', N'TR FORMAC DIV OF TR FASTENINGS', NULL, NULL, CAST(0x0000AA2200AEAD30 AS DateTime))
INSERT [dbo].[purchase_maker] ([id], [code], [name], [fullname], [note], [adddate]) VALUES (8, N'23967', N'SHIBAKEISOZAI', NULL, NULL, CAST(0x0000AA2200AEE2E1 AS DateTime))
INSERT [dbo].[purchase_maker] ([id], [code], [name], [fullname], [note], [adddate]) VALUES (9, N'24186', N'LPS BOSSARD PVT', NULL, NULL, CAST(0x0000AA2200AF096A AS DateTime))
SET IDENTITY_INSERT [dbo].[purchase_maker] OFF
/****** Object:  Table [dbo].[purchase_customer]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_customer]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_customer](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[customercode] [nvarchar](50) NULL,
	[name] [nvarchar](500) NULL,
	[address] [nvarchar](500) NULL,
	[city] [nvarchar](50) NULL,
	[country] [nvarchar](50) NULL,
	[bankaccount] [nchar](10) NULL,
	[contactname] [nvarchar](50) NULL,
	[contactmobile] [nvarchar](300) NULL,
	[contactemail] [nvarchar](200) NULL,
	[currency] [nvarchar](50) NULL,
	[paytype] [nvarchar](50) NULL,
	[note] [nvarchar](500) NULL,
	[adddate] [datetime] NULL CONSTRAINT [DF_purchase_customer_adddate]  DEFAULT (getdate()),
	[orderid] [int] NULL CONSTRAINT [DF_purchase_customer_orderid]  DEFAULT ((0)),
	[opuid] [int] NULL,
	[opname] [nvarchar](100) NULL,
	[opdate] [datetime] NULL CONSTRAINT [DF_purchase_customer_opdate]  DEFAULT (getdate()),
	[createdate] [datetime] NULL,
 CONSTRAINT [PK_purchase_custom] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[purchase_customer] ON
INSERT [dbo].[purchase_customer] ([id], [customercode], [name], [address], [city], [country], [bankaccount], [contactname], [contactmobile], [contactemail], [currency], [paytype], [note], [adddate], [orderid], [opuid], [opname], [opdate], [createdate]) VALUES (4, N'GE', N'GE公司', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(0x0000AAA8007C1E69 AS DateTime), 0, NULL, NULL, CAST(0x0000AAA8007C1E69 AS DateTime), NULL)
INSERT [dbo].[purchase_customer] ([id], [customercode], [name], [address], [city], [country], [bankaccount], [contactname], [contactmobile], [contactemail], [currency], [paytype], [note], [adddate], [orderid], [opuid], [opname], [opdate], [createdate]) VALUES (5, N'HP', N'HP', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(0x0000AAA8007C2271 AS DateTime), 0, NULL, NULL, CAST(0x0000AAA8007C2271 AS DateTime), NULL)
INSERT [dbo].[purchase_customer] ([id], [customercode], [name], [address], [city], [country], [bankaccount], [contactname], [contactmobile], [contactemail], [currency], [paytype], [note], [adddate], [orderid], [opuid], [opname], [opdate], [createdate]) VALUES (6, N'DELL', N'戴尔', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(0x0000AAA8007C253E AS DateTime), 0, NULL, NULL, CAST(0x0000AAA8007C253E AS DateTime), NULL)
SET IDENTITY_INSERT [dbo].[purchase_customer] OFF
/****** Object:  Table [dbo].[purchase_categories]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_categories]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_categories](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[catname] [nvarchar](300) NULL,
	[code] [nvarchar](50) NULL,
	[piece] [nvarchar](50) NULL,
	[spec] [nvarchar](50) NULL,
	[price] [decimal](18, 2) NULL CONSTRAINT [DF_purchase_categories_price]  DEFAULT ((0)),
	[currency] [nvarchar](50) NULL,
	[leadtime] [nvarchar](50) NULL,
	[parentid] [int] NULL,
	[moq] [decimal](18, 2) NULL,
	[shipmethod] [nvarchar](200) NULL,
	[supplyname] [nvarchar](500) NULL,
	[supplycode] [nvarchar](50) NULL,
	[supplyprocode] [nvarchar](200) NULL,
	[manufacturer] [nvarchar](50) NULL,
	[mpn] [nvarchar](50) NULL,
	[envprotect] [nvarchar](50) NULL,
	[attach1] [nvarchar](500) NULL,
	[attach2] [nvarchar](500) NULL,
	[note] [nvarchar](500) NULL,
	[depth] [int] NULL,
	[store] [nvarchar](50) NULL,
	[minstorenum] [decimal](18, 2) NULL CONSTRAINT [DF_purchase_categories_minnum]  DEFAULT ((0)),
	[currentInStore] [decimal](18, 2) NULL CONSTRAINT [DF_purchase_categories_currentInStore]  DEFAULT ((0)),
	[iscat] [int] NULL CONSTRAINT [DF_purchase_categories_iscat]  DEFAULT ((0)),
	[orderid] [int] NULL CONSTRAINT [DF_purchase_categories_orderid]  DEFAULT ((0)),
	[updatedate] [datetime] NULL,
	[updateuser] [nvarchar](50) NULL,
	[storeIn] [int] NULL,
	[pinyin] [nvarchar](200) NULL,
	[defaultuser] [nvarchar](50) NULL,
	[createdate] [datetime] NULL CONSTRAINT [DF_purchase_categories_createdate]  DEFAULT (getdate()),
	[opname] [nvarchar](50) NULL,
	[opuid] [int] NULL,
	[opdate] [datetime] NULL,
	[IsInprice] [int] NULL,
	[pricenote] [nvarchar](500) NULL,
	[enname] [nvarchar](400) NULL,
	[drawing] [nvarchar](200) NULL,
 CONSTRAINT [PK__supplying_catego__0425A276] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET IDENTITY_INSERT [dbo].[purchase_categories] ON
INSERT [dbo].[purchase_categories] ([id], [catname], [code], [piece], [spec], [price], [currency], [leadtime], [parentid], [moq], [shipmethod], [supplyname], [supplycode], [supplyprocode], [manufacturer], [mpn], [envprotect], [attach1], [attach2], [note], [depth], [store], [minstorenum], [currentInStore], [iscat], [orderid], [updatedate], [updateuser], [storeIn], [pinyin], [defaultuser], [createdate], [opname], [opuid], [opdate], [IsInprice], [pricenote], [enname], [drawing]) VALUES (1, N'普通件', NULL, NULL, NULL, CAST(0.00 AS Decimal(18, 2)), NULL, NULL, 0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 1, 0, NULL, NULL, NULL, N'PTJ', NULL, CAST(0x0000AA22008B048A AS DateTime), NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[purchase_categories] ([id], [catname], [code], [piece], [spec], [price], [currency], [leadtime], [parentid], [moq], [shipmethod], [supplyname], [supplycode], [supplyprocode], [manufacturer], [mpn], [envprotect], [attach1], [attach2], [note], [depth], [store], [minstorenum], [currentInStore], [iscat], [orderid], [updatedate], [updateuser], [storeIn], [pinyin], [defaultuser], [createdate], [opname], [opuid], [opdate], [IsInprice], [pricenote], [enname], [drawing]) VALUES (2, N'常用物品', NULL, NULL, NULL, CAST(0.00 AS Decimal(18, 2)), NULL, NULL, 1, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 1, 0, NULL, NULL, NULL, N'CYWP', NULL, CAST(0x0000AA22008B5ADD AS DateTime), NULL, NULL, NULL, NULL, NULL, NULL, NULL)
INSERT [dbo].[purchase_categories] ([id], [catname], [code], [piece], [spec], [price], [currency], [leadtime], [parentid], [moq], [shipmethod], [supplyname], [supplycode], [supplyprocode], [manufacturer], [mpn], [envprotect], [attach1], [attach2], [note], [depth], [store], [minstorenum], [currentInStore], [iscat], [orderid], [updatedate], [updateuser], [storeIn], [pinyin], [defaultuser], [createdate], [opname], [opuid], [opdate], [IsInprice], [pricenote], [enname], [drawing]) VALUES (3, N'Label G Filter', N'6544005', N'Each', N'', CAST(5.00 AS Decimal(18, 2)), N'RMB', N'', 2, CAST(0.00 AS Decimal(18, 2)), N'陆运', N'荣顺电子', N'FF', N'', N'FF', N'20029', N'是', N'', N'', N'', NULL, NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 0, 0, NULL, NULL, NULL, N'', NULL, CAST(0x0000AA2200ACC27D AS DateTime), N'李万宝', 1, CAST(0x0000AA2200ACC27D AS DateTime), 1, N'', NULL, NULL)
INSERT [dbo].[purchase_categories] ([id], [catname], [code], [piece], [spec], [price], [currency], [leadtime], [parentid], [moq], [shipmethod], [supplyname], [supplycode], [supplyprocode], [manufacturer], [mpn], [envprotect], [attach1], [attach2], [note], [depth], [store], [minstorenum], [currentInStore], [iscat], [orderid], [updatedate], [updateuser], [storeIn], [pinyin], [defaultuser], [createdate], [opname], [opuid], [opdate], [IsInprice], [pricenote], [enname], [drawing]) VALUES (4, N'STARTER G FILTER BRASS STUD M', N'5675569-2', N'Each', N'', CAST(1.00 AS Decimal(18, 2)), N'RMB', N'', 2, CAST(0.00 AS Decimal(18, 2)), N'陆运', N'荣顺电子', N'FF', N'', N'FF', N'20029', N'是', N'', N'', N'', NULL, NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 0, 0, NULL, NULL, NULL, N'', NULL, CAST(0x0000AA2200AD1835 AS DateTime), N'李万宝', 1, CAST(0x0000AA2200AD1835 AS DateTime), 1, N'', NULL, NULL)
INSERT [dbo].[purchase_categories] ([id], [catname], [code], [piece], [spec], [price], [currency], [leadtime], [parentid], [moq], [shipmethod], [supplyname], [supplycode], [supplyprocode], [manufacturer], [mpn], [envprotect], [attach1], [attach2], [note], [depth], [store], [minstorenum], [currentInStore], [iscat], [orderid], [updatedate], [updateuser], [storeIn], [pinyin], [defaultuser], [createdate], [opname], [opuid], [opdate], [IsInprice], [pricenote], [enname], [drawing]) VALUES (5, N'STARTER FILTER SPACER A', N'5675566-2', N'Each', N'', CAST(2.00 AS Decimal(18, 2)), N'RMB', N'', 2, CAST(0.00 AS Decimal(18, 2)), N'陆运', N'荣顺电子', N'FF', N'', N'FF', N'20029', N'是', N'', N'', N'', NULL, NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 0, 0, NULL, NULL, NULL, N'', NULL, CAST(0x0000AA2200AD4183 AS DateTime), N'李万宝', 1, CAST(0x0000AA2200AD4183 AS DateTime), 1, N'', NULL, NULL)
INSERT [dbo].[purchase_categories] ([id], [catname], [code], [piece], [spec], [price], [currency], [leadtime], [parentid], [moq], [shipmethod], [supplyname], [supplycode], [supplyprocode], [manufacturer], [mpn], [envprotect], [attach1], [attach2], [note], [depth], [store], [minstorenum], [currentInStore], [iscat], [orderid], [updatedate], [updateuser], [storeIn], [pinyin], [defaultuser], [createdate], [opname], [opuid], [opdate], [IsInprice], [pricenote], [enname], [drawing]) VALUES (6, N'Hexagon Nut', N'3100-M8C-40', N'Each', N'M8-1.25, Grade CU2 Brass', CAST(3.00 AS Decimal(18, 2)), N'RMB', N'', 2, CAST(0.00 AS Decimal(18, 2)), N'陆运', N'苏州营营有限公司', N'SZYY', N'', N'BOSSARD', N'A0996', N'是', N'', N'', N'', NULL, NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 0, 0, NULL, NULL, NULL, N'', NULL, CAST(0x0000AA2200ADA3D9 AS DateTime), N'李万宝', 1, CAST(0x0000AA2200ADA3D9 AS DateTime), 1, N'', NULL, NULL)
INSERT [dbo].[purchase_categories] ([id], [catname], [code], [piece], [spec], [price], [currency], [leadtime], [parentid], [moq], [shipmethod], [supplyname], [supplycode], [supplyprocode], [manufacturer], [mpn], [envprotect], [attach1], [attach2], [note], [depth], [store], [minstorenum], [currentInStore], [iscat], [orderid], [updatedate], [updateuser], [storeIn], [pinyin], [defaultuser], [createdate], [opname], [opuid], [opdate], [IsInprice], [pricenote], [enname], [drawing]) VALUES (7, N'HEXAGON SOCKET HEAD CAP SCREW', N'1000-M8C016-31', N'', N'', CAST(0.00 AS Decimal(18, 2)), N'USD', N'', 2, CAST(0.00 AS Decimal(18, 2)), N'陆运', N'BOSSARD JAPAN', N'BOSSARD JAPAN', N'', N'BOSSARD', N'A0996', N'是', N'', N'', N'', NULL, NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 0, 0, NULL, NULL, NULL, N'', NULL, CAST(0x0000AA2200AE333F AS DateTime), N'李万宝', 1, CAST(0x0000AA2200AE6E14 AS DateTime), 1, N'', NULL, NULL)
INSERT [dbo].[purchase_categories] ([id], [catname], [code], [piece], [spec], [price], [currency], [leadtime], [parentid], [moq], [shipmethod], [supplyname], [supplycode], [supplyprocode], [manufacturer], [mpn], [envprotect], [attach1], [attach2], [note], [depth], [store], [minstorenum], [currentInStore], [iscat], [orderid], [updatedate], [updateuser], [storeIn], [pinyin], [defaultuser], [createdate], [opname], [opuid], [opdate], [IsInprice], [pricenote], [enname], [drawing]) VALUES (8, N'Hexagon Socket Head Cap Screw', N'Hexagon', N'', N'A2-70 Stainless Steel, Passivate, RoHS Fastener', CAST(0.00 AS Decimal(18, 2)), N'USD', N'', 2, CAST(0.00 AS Decimal(18, 2)), N'陆运', N'苏州营营有限公司', N'SZYY', N'', N'OHTA', N'10487', N'是', N'', N'', N'', NULL, NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 0, 0, NULL, NULL, NULL, N'', NULL, CAST(0x0000AA2200B74167 AS DateTime), N'李万宝', 1, CAST(0x0000AA2200B74167 AS DateTime), 1, N'', NULL, NULL)
INSERT [dbo].[purchase_categories] ([id], [catname], [code], [piece], [spec], [price], [currency], [leadtime], [parentid], [moq], [shipmethod], [supplyname], [supplycode], [supplyprocode], [manufacturer], [mpn], [envprotect], [attach1], [attach2], [note], [depth], [store], [minstorenum], [currentInStore], [iscat], [orderid], [updatedate], [updateuser], [storeIn], [pinyin], [defaultuser], [createdate], [opname], [opuid], [opdate], [IsInprice], [pricenote], [enname], [drawing]) VALUES (9, N'Cross Recessed Pan Head Screw', N'1585', N'', N' Grade A4-50 Stainless Steel, RoHS Fastener', CAST(3.00 AS Decimal(18, 2)), N'RMB', N'', 2, CAST(0.00 AS Decimal(18, 2)), N'陆运', N'佐途五金旗舰店', N'ZT', N'', N'ANIXTER', N'11060', N'是', N'', N'', N'', NULL, NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 0, 0, NULL, NULL, NULL, N'', NULL, CAST(0x0000AA2200B77202 AS DateTime), N'李万宝', 1, CAST(0x0000AA2200B77202 AS DateTime), 1, N'', NULL, NULL)
INSERT [dbo].[purchase_categories] ([id], [catname], [code], [piece], [spec], [price], [currency], [leadtime], [parentid], [moq], [shipmethod], [supplyname], [supplycode], [supplyprocode], [manufacturer], [mpn], [envprotect], [attach1], [attach2], [note], [depth], [store], [minstorenum], [currentInStore], [iscat], [orderid], [updatedate], [updateuser], [storeIn], [pinyin], [defaultuser], [createdate], [opname], [opuid], [opdate], [IsInprice], [pricenote], [enname], [drawing]) VALUES (10, N'Flat Washer', N'M003', N'', N'', CAST(2.00 AS Decimal(18, 2)), N'RMB', N'', 2, CAST(0.00 AS Decimal(18, 2)), N'陆运', N'苏州营营有限公司', N'SZYY', N'', N'LPS BOSSARD PVT', N'24186', N'是', N'', N'', N'', NULL, NULL, CAST(0.00 AS Decimal(18, 2)), CAST(0.00 AS Decimal(18, 2)), 0, 0, NULL, NULL, NULL, N'', NULL, CAST(0x0000AA2200B7A98C AS DateTime), N'李万宝', 1, CAST(0x0000AA2200B7A98C AS DateTime), 1, N'', NULL, NULL)
SET IDENTITY_INSERT [dbo].[purchase_categories] OFF
/****** Object:  Table [dbo].[purchase_supply_product]    Script Date: 08/13/2019 09:29:48 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[purchase_supply_product]') AND type in (N'U'))
BEGIN
CREATE TABLE [dbo].[purchase_supply_product](
	[id] [int] IDENTITY(1,1) NOT NULL,
	[proid] [int] NULL,
	[mcode] [nvarchar](50) NULL,
	[scode] [nvarchar](50) NULL,
	[sname] [nvarchar](300) NULL,
	[price] [decimal](18, 4) NULL,
	[currency] [nvarchar](50) NULL,
	[note] [nvarchar](500) NULL,
	[opname] [nvarchar](50) NULL,
	[opuid] [int] NULL,
	[opdate] [datetime] NULL,
	[createdate] [datetime] NULL,
	[minnum] [decimal](18, 0) NULL,
	[maxnum] [decimal](18, 0) NULL,
	[leadtime] [nvarchar](50) NULL,
	[shipmethod] [nvarchar](50) NULL,
	[supplyprocode] [nvarchar](50) NULL,
	[supplyproname] [nvarchar](200) NULL,
	[pricedatefrom] [datetime] NULL,
	[pricedateto] [datetime] NULL,
 CONSTRAINT [PK_purchase_supply_product] PRIMARY KEY CLUSTERED 
(
	[id] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
END
GO
/****** Object:  Trigger [update_price2]    Script Date: 08/13/2019 09:29:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[update_price2]'))
EXEC dbo.sp_executesql @statement = N'





CREATE trigger [dbo].[update_price2] on [dbo].[purchase_categories] for update
as 
  
 
begin
declare @newprice decimal(18,4)
declare @oldprice decimal(18,4)
select @newprice=price from inserted
select @oldprice=price from deleted
if(@newprice!=@oldprice)
begin
 insert into bps_historyprice (pid,price,adddate,pricedate,supplyname)
 select id,price,GETDATE(), GETDATE(),supplyname from inserted  where iscat=0
 end
 end



'
GO
/****** Object:  Trigger [update_price1]    Script Date: 08/13/2019 09:29:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[update_price1]'))
EXEC dbo.sp_executesql @statement = N'





CREATE trigger [dbo].[update_price1] on [dbo].[purchase_supply_product] for update
as 
   
begin
declare @newprice decimal(18,4)
declare @oldprice decimal(18,4)
select @newprice=price from inserted
select @oldprice=price from deleted
if(@newprice!=@oldprice)
begin
 
 
 insert into bps_historyprice (pid,price,adddate,pricedate,supplyname,minnum,maxnum,pricedateto)
 select proid,price,GETDATE(), pricedatefrom,sname,minnum,maxnum,pricedateto from inserted 
 
 end
 end







'
GO
/****** Object:  Trigger [insert_price2]    Script Date: 08/13/2019 09:29:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[insert_price2]'))
EXEC dbo.sp_executesql @statement = N'





CREATE trigger [dbo].[insert_price2] on [dbo].[purchase_categories] for insert
as 
  
 
begin
 insert into bps_historyprice (pid,price,adddate,pricedate,supplyname)
 select id,price,GETDATE(),  GETDATE() ,supplyname from inserted where iscat=0
 end



'
GO
/****** Object:  Trigger [insert_price1]    Script Date: 08/13/2019 09:29:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[insert_price1]'))
EXEC dbo.sp_executesql @statement = N'


 













CREATE trigger [dbo].[insert_price1] on [dbo].[purchase_supply_product] for insert
as 
   

  insert into bps_historyprice (pid,price,adddate,pricedate,supplyname,minnum,maxnum,pricedateto)
 select proid,price,GETDATE(), pricedatefrom,sname,minnum,maxnum,pricedateto from inserted 
  
















'
GO
/****** Object:  Trigger [delete_price1]    Script Date: 08/13/2019 09:29:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.triggers WHERE object_id = OBJECT_ID(N'[dbo].[delete_price1]'))
EXEC dbo.sp_executesql @statement = N'
 













CREATE trigger [dbo].[delete_price1] on [dbo].[purchase_supply_product] for delete
as 
   
 insert into bps_historyprice (pid,price,adddate,pricedate,supplyname,minnum,maxnum,pricedateto)
 select proid,price,GETDATE(), pricedatefrom,sname,minnum,maxnum,pricedateto from deleted 
  














'
GO
/****** Object:  View [dbo].[v_price]    Script Date: 08/13/2019 09:29:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[v_price]'))
EXEC dbo.sp_executesql @statement = N'CREATE view [dbo].[v_price] as 

 
 select  
 id, code,catname,spec,price,currency,supplyname,supplycode, pricenote as note ,1 as defaults,opdate  from purchase_categories where iscat=0
   union 
   
 select purchase_supply_product.id, 
 code,
 catname,
 spec,
 purchase_supply_product.price,
 purchase_supply_product.currency,
 sname  as supplyname,
 scode as supplycode,
 purchase_supply_product.note ,0 as defaults,
 purchase_supply_product.opdate 
 from purchase_categories 
 inner join purchase_supply_product on purchase_categories.code=purchase_supply_product.mcode
'
GO
/****** Object:  View [dbo].[v_cat]    Script Date: 08/13/2019 09:29:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[v_cat]'))
EXEC dbo.sp_executesql @statement = N'create view [dbo].[v_cat]
as

 select A.id as Cat1Id, a.catname AS Cat1Name, B.id as Cat2ID, B.catname as Cat2Name
 
 
 from (
select id,catname,parentid from purchase_categories where parentid=0 and iscat=1
) A

left join
(
select purchase_categories.id, purchase_categories.catname , purchase_categories.parentid from purchase_categories inner join
(
select id,catname,parentid from purchase_categories where parentid=0 and iscat=1
) Level1 on purchase_categories.parentid=Level1.id where iscat=1
) B
on A.id=b.parentid
'
GO
/****** Object:  View [dbo].[v_proTable]    Script Date: 08/13/2019 09:29:49 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[v_proTable]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[v_proTable] AS SELECT Cat1Id, Cat1Name, Cat2ID, Cat2Name, P.pinyin, P.id AS ProId, P.catname AS ProName, P.code AS Code, P.piece AS Piece, P.spec AS Spec, P.price AS Price, P.currency AS Currency, P.leadtime AS LeadTime, P.shipmethod AS ShipMethod, P.supplycode AS SupplyCode, P.moq AS Moq, P.supplyprocode AS SupplyProCode, P.note AS Note, CurrentInStore,manufacturer,mpn,IsInprice FROM [v_cat] INNER JOIN ( SELECT * FROM purchase_categories WHERE iscat=0 ) P ON v_cat.Cat2ID=P.parentid
'
GO
