IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_GID]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_GID]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ch_fee_FEETYPE]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_ch_fee_FEETYPE]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_UNITPRICE]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_UNITPRICE]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_QUANTITY]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_QUANTITY]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_AMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_AMOUNT]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_EXCHANGERATE]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_EXCHANGERATE]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_COMMISSIONRATE]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_COMMISSIONRATE]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_SETTLEMENT]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_SETTLEMENT]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_ORDERAMOUNT]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_ORDERAMOUNT]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_ORDERINVOICE]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_ORDERINVOICE]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_ENTERDATE]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_ENTERDATE]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_ISDEBIT]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_ISDEBIT]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_ISOPEN]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_ISOPEN]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_ISADVANCEDPAY]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_ISADVANCEDPAY]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_web_sys_fee_ISINVOICE]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_web_sys_fee_ISINVOICE]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ch_fee_FEESTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_ch_fee_FEESTATUS]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ch_fee_ISCRMORDERFEE]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_ch_fee_ISCRMORDERFEE]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF_ch_fee_AUDITSTATUS]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF_ch_fee_AUDITSTATUS]
END

GO

IF  EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[DF__ch_fee__LINENUM__7EB87891]') AND type = 'D')
BEGIN
ALTER TABLE [dbo].[ch_fee] DROP CONSTRAINT [DF__ch_fee__LINENUM__7EB87891]
END

GO

USE [ShippingWeb]
GO

/****** Object:  Table [dbo].[ch_fee]    Script Date: 10/22/2013 12:15:55 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[ch_fee]') AND type in (N'U'))
DROP TABLE [dbo].[ch_fee]
GO

/****** Object:  Table [dbo].[ch_fee]    Script Date: 10/22/2013 12:15:55 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

SET ANSI_PADDING ON
GO

CREATE TABLE [dbo].[ch_fee](
	[GID] [varchar](36) NOT NULL,
	[BSNO] [varchar](100) NULL,
	[FEETYPE] [int] NULL,
	[FEENAME] [varchar](100) NULL,
	[FEEDESCRIPTION] [varchar](100) NULL,
	[CUSTOMERTYPE] [varchar](50) NULL,
	[CUSTOMERNAME] [varchar](50) NULL,
	[UNIT] [varchar](20) NULL,
	[UNITPRICE] [numeric](18, 2) NULL,
	[QUANTITY] [numeric](18, 4) NULL,
	[AMOUNT] [numeric](18, 2) NULL,
	[CURRENCY] [varchar](20) NULL,
	[EXCHANGERATE] [numeric](18, 5) NULL,
	[REASON] [varchar](20) NULL,
	[REMARK] [varchar](1024) NULL,
	[COMMISSIONRATE] [numeric](18, 3) NULL,
	[SETTLEMENT] [numeric](18, 2) NULL,
	[INVOICE] [numeric](18, 2) NULL,
	[ORDERAMOUNT] [numeric](18, 2) NULL,
	[ORDERINVOICE] [numeric](18, 2) NULL,
	[SUBMITDATE] [smalldatetime] NULL,
	[AUDITOPERATOR] [varchar](50) NULL,
	[AUDITDATE] [smalldatetime] NULL,
	[ENTEROPERATOR] [varchar](50) NULL,
	[ENTERDATE] [smalldatetime] NULL,
	[DEBITNO] [varchar](36) NULL,
	[ISDEBIT] [bit] NULL,
	[ISOPEN] [bit] NULL,
	[ISADVANCEDPAY] [bit] NULL,
	[SORT] [int] NULL,
	[ISINVOICE] [bit] NULL,
	[FEESTATUS] [int] NULL,
	[FEEFRT] [varchar](20) NULL,
	[ISCRMORDERFEE] [bit] NULL,
	[AUDITSTATUS] [int] NULL,
	[INVOICENUM] [varchar](200) NULL,
	[CHEQUENUM] [varchar](200) NULL,
	[WMSOUTBSNO] [varchar](100) NULL,
	[LINENUM] [int] NULL,
	[payed] tinyint null,
 CONSTRAINT [PK_web_sys_fee] PRIMARY KEY CLUSTERED 
(
	[GID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]

GO

SET ANSI_PADDING OFF
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_GID]  DEFAULT (newid()) FOR [GID]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_ch_fee_FEETYPE]  DEFAULT ((0)) FOR [FEETYPE]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_UNITPRICE]  DEFAULT ((0)) FOR [UNITPRICE]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_QUANTITY]  DEFAULT ((0)) FOR [QUANTITY]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_AMOUNT]  DEFAULT ((0)) FOR [AMOUNT]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_EXCHANGERATE]  DEFAULT ((0)) FOR [EXCHANGERATE]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_COMMISSIONRATE]  DEFAULT ((0)) FOR [COMMISSIONRATE]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_SETTLEMENT]  DEFAULT ((0)) FOR [SETTLEMENT]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_ORDERAMOUNT]  DEFAULT ((0)) FOR [ORDERAMOUNT]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_ORDERINVOICE]  DEFAULT ((0)) FOR [ORDERINVOICE]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_ENTERDATE]  DEFAULT (getdate()) FOR [ENTERDATE]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_ISDEBIT]  DEFAULT ((0)) FOR [ISDEBIT]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_ISOPEN]  DEFAULT ((0)) FOR [ISOPEN]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_ISADVANCEDPAY]  DEFAULT ((0)) FOR [ISADVANCEDPAY]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_web_sys_fee_ISINVOICE]  DEFAULT ((0)) FOR [ISINVOICE]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_ch_fee_FEESTATUS]  DEFAULT ((1)) FOR [FEESTATUS]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_ch_fee_ISCRMORDERFEE]  DEFAULT ((0)) FOR [ISCRMORDERFEE]
GO

ALTER TABLE [dbo].[ch_fee] ADD  CONSTRAINT [DF_ch_fee_AUDITSTATUS]  DEFAULT ((0)) FOR [AUDITSTATUS]
GO

ALTER TABLE [dbo].[ch_fee] ADD  DEFAULT ((0)) FOR [LINENUM]
GO


