END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[p_show]') AND OBJECTPROPERTY(id,N'IsProcedure') = 1)
BEGIN
EXEC dbo.sp_executesql @statement = N'
CREATE Proc [dbo].[p_show]
@QueryStr nvarchar(300),--表名、视图名、查询语句
@PageSize int,--每页的大小(行数)
@PageCurrent int,--要显示的页
@FdShow nvarchar (300)='''',--要显示的字段列表,如果查询结果不需要标识字段,需要指定此值,且不包含标识字段
@FdOrder nvarchar (300)=''''--排序字段列表
as
set nocount on
declare @FdName nvarchar(250)--表中的主键或表、临时表中的标识列名
,@Id1 varchar(20),@Id2 varchar(20)--开始和结束的记录号
,@Obj_ID int--对象ID
--表中有复合主键的处理
declare @strfd nvarchar(2000)--复合主键列表
,@strjoin nvarchar(4000)--连接字段
,@strwhere nvarchar(2000)--查询条件
select @Obj_ID=object_id(@QueryStr)
,@FdShow=case isnull(@FdShow,'''') when '''' then '' *'' else '' ''+@FdShow end
,@FdOrder=case isnull(@FdOrder,'''') when '''' then '''' else '' order by ''+@FdOrder end
,@QueryStr=case when @Obj_ID is not null then '' ''+@QueryStr else '' (''+@QueryStr+'') a'' end
--如果显示第一页,可以直接用top来完成
if @PageCurrent=1
begin
select @Id1=cast(@PageSize as varchar(20))
exec(''select top ''+@Id1+@FdShow+'' from ''+@QueryStr+@FdOrder)
return
end
--如果是表,则检查表中是否有标识更或主键
if @Obj_ID is not null and objectproperty(@Obj_ID,''IsTable'')=1
begin
select @Id1=cast(@PageSize as varchar(20))
,@Id2=cast((@PageCurrent-1)*@PageSize as varchar(20))
select @FdName=name from syscolumns where id=@Obj_ID and status=0x80
if @@rowcount=0--如果表中无标识列,则检查表中是否有主键
begin
if not exists(select 1 from sysobjects where parent_obj=@Obj_ID and xtype=''PK'')
goto lbusetemp--如果表中无主键,则用临时表处理
select @FdName=name from syscolumns where id=@Obj_ID and colid in(
select colid from sysindexkeys where @Obj_ID=id and indid in(
select indid from sysindexes where @Obj_ID=id and name in(
select name from sysobjects where xtype=''PK'' and parent_obj=@Obj_ID
)))
if @@rowcount>1--检查表中的主键是否为复合主键
begin
select @strfd='''',@strjoin='''',@strwhere=''''
select @strfd=@strfd+'',[''+name+'']''
,@strjoin=@strjoin+'' and a.[''+name+'']=b.[''+name+'']''
,@strwhere=@strwhere+'' and b.[''+name+''] is null''
from syscolumns where id=@Obj_ID and colid in(
select colid from sysindexkeys where @Obj_ID=id and indid in(
select indid from sysindexes where @Obj_ID=id and name in(
select name from sysobjects where xtype=''PK'' and parent_obj=@Obj_ID
)))
select @strfd=substring(@strfd,2,2000)
,@strjoin=substring(@strjoin,5,4000)
,@strwhere=substring(@strwhere,5,4000)
goto lbusepk
end
end
end
else
goto lbusetemp
/*--使用标识列或主键为单一字段的处理方法--*/
lbuseidentity:
exec(''select top ''+@Id1+@FdShow+'' from ''+@QueryStr
+'' where ''+@FdName+'' not in(select top ''
+@Id2+'' ''+@FdName+'' from ''+@QueryStr+@FdOrder
+'')''+@FdOrder
)
return
/*--表中有复合主键的处理方法--*/
lbusepk:
exec(''select ''+@FdShow+'' from(select top ''+@Id1+'' a.* from
(select top 100 percent * from ''+@QueryStr+@FdOrder+'') a
left join (select top ''+@Id2+'' ''+@strfd+''
from ''+@QueryStr+@FdOrder+'') b on ''+@strjoin+''
where ''+@strwhere+'') a''
)
return
/*--用临时表处理的方法--*/
lbusetemp:
select @FdName=''[ID_''+cast(newid() as varchar(40))+'']''
,@Id1=cast(@PageSize*(@PageCurrent-1) as varchar(20))
,@Id2=cast(@PageSize*@PageCurrent-1 as varchar(20))
exec(''select ''+@FdName+''=identity(int,0,1),''+@FdShow+''
into #tb from''+@QueryStr+@FdOrder+''
select ''+@FdShow+'' from #tb where ''+@FdName+'' between ''
+@Id1+'' and ''+@Id2
)
'
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_CorpInfo]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_CorpInfo](
[CorpID] [varchar](20) NOT NULL,
[AccID] [varchar](20) NOT NULL,
[CorpName] [varchar](200) NULL,
[CorpEnName] [varchar](200) NULL,
[Super] [varchar](50) NULL,
[Tel] [varchar](20) NULL,
[Fax] [varchar](20) NULL,
[Addr] [varchar](500) NULL,
[Email] [varchar](50) NULL,
[http] [varchar](50) NULL,
[CorpKey] [varchar](4) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_CuDnComparison]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_CuDnComparison](
[AutoID] [int] IDENTITY(1,1) NOT NULL,
[CorpID] [varchar](20) NULL,
[CustID] [varchar](50) NULL,
[DesignID] [varchar](50) NULL,
[Note] [nchar](100) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_DefGoldConvert]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_DefGoldConvert](
[CorpID] [varchar](50) NULL,
[Silver] [varchar](50) NULL,
[Gold] [varchar](50) NULL,
[ValOne] [decimal](18, 2) NULL,
[ValTwo] [decimal](18, 2) NULL,
[AutoID] [int] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_DepartCraft]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_DepartCraft](
[AutoID] [int] IDENTITY(1,1) NOT NULL,
[CorpID] [varchar](50) NOT NULL,
[DepartCraftID] [varchar](20) NULL,
[DepartCraft] [varchar](20) NULL,
[Craft1] [varchar](20) NULL,
[Craft2] [varchar](20) NULL,
[Craft3] [varchar](50) NULL,
[Craft4] [varchar](20) NULL,
[Craft5] [varchar](20) NULL,
[Craft6] [varchar](20) NULL,
[Craft7] [varchar](20) NULL,
[Craft8] [varchar](20) NULL,
[Craft9] [varchar](20) NULL,
[Craft10] [varchar](20) NULL,
[Craft11] [varchar](20) NULL,
[Craft12] [varchar](20) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_GemList]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_GemList](
[CorpID] [varchar](50) NOT NULL,
[BillID] [varchar](50) NOT NULL,
[BillDate] [datetime] NOT NULL,
[ItemState] [varchar](50) NULL,
[FlowID] [varchar](50) NULL,
[WareID] [varchar](50) NULL,
[DirID] [varchar](50) NULL,
[ItemID] [varchar](50) NOT NULL,
[ItemName] [varchar](50) NOT NULL,
[BarCode] [varchar](50) NULL,
[Shape] [varchar](50) NULL,
[Spec] [varchar](50) NULL,
[CalcType] [varchar](50) NULL,
[iQty] [decimal](18, 0) NOT NULL CONSTRAINT [DF_jfac_GemList_iQty] DEFAULT (0),
[iWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_GemList_Weg] DEFAULT (0),
[iPrice] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_GemList_iPrice] DEFAULT (0),
[iSumPrice] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_GemList_SumPrice] DEFAULT (0),
[iSumWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_GemList_iSumWeg] DEFAULT (0),
[Beset] [varchar](50) NULL,
[Inlay] [varchar](50) NULL,
[Cut] [varchar](50) NULL,
[Color] [varchar](50) NULL,
[Clean] [varchar](50) NULL,
[VendID] [varchar](50) NULL,
[oSumPrice] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_GemList_oSumPrice] DEFAULT (0),
[oSumWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_GemList_oSumWeg] DEFAULT (0),
[oWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_GemList_oWeg] DEFAULT (0),
[oPrice] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_GemList_oPrice] DEFAULT (0),
[oQty] [decimal](18, 0) NOT NULL CONSTRAINT [DF_jfac_GemList_oQty] DEFAULT (0),
[LBillID] [varchar](50) NULL,
[LDate] [datetime] NULL,
[Line] [int] NOT NULL,
[IO] [int] NOT NULL,
[Note] [varchar](255) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL,
[Jcred] [varchar](50) NULL,
[Unit] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_DepartmentSend]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_DepartmentSend](
[CorpID] [varchar](12) NOT NULL,
[BillID] [varchar](50) NOT NULL,
[WorkBillID] [varchar](50) NOT NULL,
[OrderID] [varchar](50) NOT NULL,
[SDepartID] [varchar](20) NULL,
[ADepartID] [varchar](20) NULL,
[FlowID] [varchar](50) NOT NULL,
[FlowName] [varchar](50) NOT NULL,
[Qty] [int] NOT NULL CONSTRAINT [DF_jfac_DepartmenSend_Qty] DEFAULT (0),
[Weg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_DepartmenSend_Weg] DEFAULT (0),
[NextFlowID] [varchar](50) NULL,
[NextFlowName] [varchar](50) NULL,
[Note] [varchar](50) NULL,
[AutoID] [int] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_Dictionary]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_Dictionary](
[AutoID] [int] IDENTITY(1,1) NOT NULL,
[CorpID] [nvarchar](50) NOT NULL,
[DectItem] [nvarchar](50) NOT NULL,
[DectID] [nvarchar](50) NOT NULL,
[DectName] [nvarchar](200) NULL,
[DirID] [nvarchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_DiscerSet]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_DiscerSet](
[CorpID] [varchar](50) NULL,
[type] [varchar](50) NULL,
[value1] [varchar](50) NULL,
[value2] [varchar](50) NULL,
[Note] [varchar](50) NULL,
[AutoID] [int] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_Employee]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_Employee](
[CorpID] [varchar](20) NOT NULL,
[EmployeeID] [varchar](20) NOT NULL,
[EmpName] [varchar](50) NOT NULL,
[DepartMent] [varchar](30) NULL,
[Logout] [bit] NOT NULL CONSTRAINT [DF_jfac_Employee_Logout] DEFAULT (1),
[Address] [varchar](200) NULL,
[Email] [varchar](50) NULL,
[Mobile] [varchar](50) NULL,
[Note] [varchar](500) NULL,
[Photo] [varchar](200) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL,
[ClDegree] [varchar](16) NULL,
[Age] [int] NOT NULL CONSTRAINT [DF_jfac_Employee_Age] DEFAULT (18),
[Sex] [char](2) NOT NULL CONSTRAINT [DF_jfac_Employee_Sex] DEFAULT ('男'),
[Vocation] [varchar](20) NULL,
[IDCard] [varchar](30) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_FlowsDefine]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_FlowsDefine](
[OrderID] [varchar](50) NOT NULL,
[ModeID] [varchar](20) NOT NULL,
[ItemID] [varchar](50) NOT NULL,
[ItemName] [varchar](30) NOT NULL,
[WorkTime] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_FlowsDefine_WorkTime] DEFAULT (0),
[Line] [int] NOT NULL CONSTRAINT [DF_jfac_FlowsDefine_Line] DEFAULT (0),
[AutoID] [int] IDENTITY(1,1) NOT NULL,
[CorpID] [varchar](20) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_PartsList]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_PartsList](
[CorpID] [varchar](50) NOT NULL,
[BillID] [varchar](50) NOT NULL,
[BillDate] [datetime] NOT NULL,
[ItemState] [varchar](50) NULL,
[FlowID] [varchar](50) NULL,
[WareID] [varchar](50) NULL,
[ItemID] [varchar](50) NOT NULL,
[ItemName] [varchar](50) NOT NULL,
[Texture] [varchar](50) NULL,
[CalcType] [varchar](50) NULL,
[Shape] [varchar](50) NULL,
[Spec] [varchar](50) NULL,
[Design] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[Color] [varchar](50) NULL,
[iPrice] [decimal](18, 2) NOT NULL,
[iWeg] [decimal](18, 3) NOT NULL,
[iQty] [decimal](18, 0) NOT NULL,
[iSumWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_PartsList_iSumWeg] DEFAULT (0),
[iSumPrice] [decimal](18, 2) NOT NULL,
[oSumWeg] [decimal](18, 0) NOT NULL CONSTRAINT [DF_jfac_PartsList_oSumWeg] DEFAULT (0),
[oSumPrice] [decimal](18, 2) NOT NULL,
[oWeg] [decimal](18, 3) NOT NULL,
[oPrice] [decimal](18, 2) NOT NULL,
[oQty] [decimal](18, 0) NOT NULL,
[LBillID] [varchar](50) NULL,
[LDate] [datetime] NULL,
[Line] [int] NOT NULL,
[IO] [int] NOT NULL,
[Note] [varchar](255) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_GemChangeRecord]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_GemChangeRecord](
[AutoID] [int] IDENTITY(1,1) NOT NULL,
[CorpID] [varchar](50) NOT NULL,
[BillID] [varchar](50) NOT NULL,
[WorkBillID] [varchar](50) NULL,
[BillDate] [datetime] NULL,
[ItemID] [varchar](50) NOT NULL,
[ItemName] [varchar](50) NOT NULL,
[Shape] [varchar](50) NULL,
[Spec] [varchar](50) NULL,
[Qty] [decimal](18, 0) NOT NULL CONSTRAINT [DF_jfac_GemChangeRecord_Qty] DEFAULT (0),
[Weg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_GemChangeRecord_Weg] DEFAULT (0),
[Cut] [varchar](50) NULL,
[Color] [varchar](50) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_JewelIO]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_JewelIO](
[CorpID] [varchar](50) NOT NULL,
[IBillID] [varchar](50) NOT NULL,
[IDX] [int] NOT NULL,
[BarCode] [varchar](50) NULL,
[gzmCode] [varchar](50) NULL,
[InDate] [datetime] NULL,
[Design] [varchar](50) NULL,
[MakeID] [varchar](50) NULL,
[JewelName] [varchar](50) NULL,
[Spec] [varchar](50) NULL,
[Adorn] [varchar](50) NULL,
[TWeg] [decimal](18, 2) NOT NULL,
[Gold] [varchar](50) NULL,
[GoldWeg] [decimal](18, 3) NOT NULL,
[xGoldWeg] [decimal](18, 3) NOT NULL,
[Gem] [varchar](50) NULL,
[mGemWeg] [decimal](18, 3) NOT NULL,
[mGemQty] [decimal](18, 0) NOT NULL,
[fGem] [varchar](50) NULL,
[fGemWeg] [decimal](18, 3) NOT NULL,
[fGemQty] [decimal](18, 0) NOT NULL,
[JewelCred] [varchar](50) NULL,
[JewelType] [varchar](50) NULL,
[Cost] [decimal](18, 2) NOT NULL,
[GoldValue] [decimal](18, 2) NOT NULL,
[GemValue] [decimal](18, 2) NOT NULL,
[WorkValue] [decimal](18, 2) NOT NULL,
[LossRate] [decimal](18, 1) NOT NULL,
[LossValue] [decimal](18, 2) NOT NULL,
[OtherValue] [decimal](18, 2) NOT NULL,
[Price] [decimal](18, 0) NOT NULL,
[SellPrice] [decimal](18, 2) NOT NULL,
[SellLoss] [decimal](18, 2) NOT NULL,
[Rate] [decimal](18, 1) NOT NULL,
[BackPrice] [decimal](18, 2) NOT NULL,
[isPrint] [bit] NOT NULL,
[isFloat] [bit] NOT NULL,
[isFS] [bit] NOT NULL,
[isFD] [bit] NOT NULL,
[isLS] [bit] NOT NULL,
[isPS] [bit] NOT NULL,
[WareID] [varchar](50) NULL,
[VendID] [varchar](50) NULL,
[CustID] [varchar](50) NULL,
[OBillID] [varchar](50) NULL,
[ODX] [int] NOT NULL,
[OtDate] [datetime] NULL,
[ProductType] [varchar](50) NULL,
[Photo] [varchar](500) NULL,
[Note] [varchar](500) NULL,
[BillType] [varchar](50) NULL,
[MakeFrom] [nvarchar](50) NULL,
[WorkPrice] [decimal](18, 0) NOT NULL,
[WorkRate] [decimal](18, 0) NOT NULL,
[newCost] [decimal](18, 2) NOT NULL,
[oldPrice] [decimal](18, 2) NOT NULL,
[def1] [varchar](100) NULL,
[def2] [varchar](100) NULL,
[def3] [varchar](100) NULL,
[def4] [varchar](100) NULL,
[def5] [varchar](100) NULL,
[def6] [varchar](100) NULL,
[def8] [varchar](50) NULL,
[def7] [varchar](50) NULL,
[def9] [varchar](50) NULL,
[def10] [varchar](50) NULL,
[origCode] [varchar](50) NULL,
[IO] [int] NOT NULL,
[Line] [int] NOT NULL,
[AutoID] [bigint] NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeBill_Main]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeBill_Main](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL,
[OrderBill] [varchar](50) NULL,
[OldWorkBill] [varchar](50) NULL,
[Design] [varchar](50) NULL,
[BarCode] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[MakeID] [varchar](50) NULL,
[Adorn] [varchar](50) NULL,
[JewelName] [varchar](50) NULL,
[BeginDate] [datetime] NULL,
[EndDate] [datetime] NULL,
[Spec] [varchar](50) NULL,
[TQty] [decimal](18, 0) NOT NULL,
[TWeg] [decimal](18, 2) NOT NULL,
[Gold] [varchar](50) NULL,
[GoldWeg] [decimal](18, 2) NOT NULL,
[xGoldWeg] [decimal](18, 3) NOT NULL,
[Gem] [varchar](50) NULL,
[mGemWeg] [decimal](18, 3) NOT NULL,
[mGemQty] [decimal](18, 0) NOT NULL,
[fGem] [varchar](50) NULL,
[fGemWeg] [decimal](18, 3) NOT NULL,
[fGemQty] [decimal](18, 0) NOT NULL,
[JewelType] [varchar](50) NULL,
[CustID] [varchar](50) NULL,
[ProductType] [varchar](50) NULL,
[origCode] [varchar](50) NULL,
[ModeClass] [varchar](50) NULL,
[Note] [varchar](500) NULL,
[MakeNote] [varchar](500) NULL,
[Imprint] [varchar](50) NULL,
[Flag] [int] NOT NULL CONSTRAINT [DF_jfac_MakeBill_Main_Flag] DEFAULT (1),
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeBill_Arts]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeBill_Arts](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL,
[OrderBill] [varchar](50) NULL,
[Design] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[ItemName] [varchar](100) NULL,
[Note] [varchar](200) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeBill_Flows]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeBill_Flows](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL,
[OrderBill] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[Design] [varchar](50) NULL,
[Line] [int] NOT NULL,
[ItemID] [varchar](50) NULL,
[ItemName] [varchar](50) NULL,
[WorkTime] [decimal](18, 1) NOT NULL,
[WorkValue] [decimal](18, 0) NOT NULL,
[Note] [varchar](200) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeBill_Gems]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeBill_Gems](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL,
[OrderBill] [varchar](50) NULL,
[Design] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[iStyle] [varchar](50) NULL,
[ItemName] [varchar](50) NULL,
[Spec] [varchar](50) NULL,
[Shape] [varchar](50) NULL,
[Qty] [decimal](18, 0) NOT NULL,
[Weg] [decimal](18, 3) NOT NULL,
[Flag] [int] NOT NULL CONSTRAINT [DF_jfac_MakeBill_Gems_Flag] DEFAULT (0),
[Beset] [varchar](50) NULL,
[Inlay] [varchar](50) NULL,
[Cut] [varchar](50) NULL,
[Color] [varchar](50) NULL,
[Clean] [varchar](50) NULL,
[Note] [varchar](50) NULL,
[AutoID] [int] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeBill_Golds]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeBill_Golds](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL,
[OrderBill] [varchar](50) NULL,
[Design] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[iStyle] [varchar](50) NULL,
[ItemName] [varchar](50) NULL,
[Weg] [decimal](18, 3) NOT NULL,
[Note] [varchar](200) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_WorkFlowBack]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_WorkFlowBack](
[AutoID] [int] IDENTITY(1,1) NOT NULL,
[CorpID] [varchar](20) NOT NULL,
[Line] [int] NOT NULL CONSTRAINT [DF_jfac_WorkFlowSend_Line] DEFAULT (0),
[BillID] [varchar](25) NOT NULL,
[WorkBillID] [varchar](25) NOT NULL,
[ItemID] [varchar](20) NULL,
[ItemName] [varchar](20) NULL,
[FlowID] [varchar](20) NOT NULL,
[Flag] [int] NOT NULL CONSTRAINT [DF_jfac_WorkFlowSend_Flag] DEFAULT (1),
[InceptWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_WorkFlowSend_Weg] DEFAULT (0),
[BeWastage] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_WorkFlowSend_BeWastage] DEFAULT (0),
[Wastage] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_WorkFlowSend_Wastage] DEFAULT (0),
[SendWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_WorkFlowSend_SendIncept] DEFAULT (0),
[Qty] [int] NOT NULL CONSTRAINT [DF_jfac_WorkFlowSend_Qty] DEFAULT (0),
[SumQty] [int] NOT NULL CONSTRAINT [DF_jfac_WorkFlowBack_SumQty] DEFAULT (0),
[SumWeg] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_WorkFlowBack_SumWeg] DEFAULT (0),
[WorkExpense] [decimal](18, 1) NOT NULL CONSTRAINT [DF_jfac_WorkFlowSend_WorkExpense] DEFAULT (0),
[Spec] [varchar](70) NULL,
[Note] [varchar](200) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeBill_Parts]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeBill_Parts](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL,
[OrderBill] [varchar](50) NULL,
[Design] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[ItemID] [varchar](50) NULL,
[ItemName] [varchar](50) NULL,
[ItemType] [varchar](50) NULL,
[Spec] [varchar](50) NULL,
[Qty] [decimal](18, 0) NOT NULL,
[Weg] [decimal](18, 3) NOT NULL,
[Note] [varchar](200) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeOrder_Arts]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeOrder_Arts](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Arts_IDX] DEFAULT (0),
[Design] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[ItemName] [varchar](100) NULL,
[Note] [varchar](200) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeOrder_Gems]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeOrder_Gems](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Gems_IDX] DEFAULT (0),
[Design] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[iStyle] [varchar](50) NULL,
[ItemName] [varchar](50) NULL,
[Spec] [varchar](50) NULL,
[Shape] [varchar](50) NULL,
[Qty] [decimal](18, 0) NOT NULL,
[Weg] [decimal](18, 3) NOT NULL,
[Beset] [varchar](50) NULL,
[Inlay] [varchar](50) NULL,
[Cut] [varchar](50) NULL,
[Color] [varchar](50) NULL,
[Clean] [varchar](50) NULL,
[Note] [varchar](50) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeOrder_Golds]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeOrder_Golds](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Golds_IDX] DEFAULT (0),
[Design] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[iStyle] [varchar](50) NULL,
[ItemName] [varchar](50) NULL,
[Weg] [decimal](18, 3) NOT NULL,
[Note] [varchar](200) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_GoldList]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_GoldList](
[CorpID] [varchar](50) NOT NULL,
[BillID] [varchar](50) NOT NULL,
[BillDate] [datetime] NOT NULL,
[FlowID] [varchar](50) NULL,
[ItemState] [varchar](50) NULL,
[WareID] [varchar](50) NULL,
[ItemID] [varchar](50) NOT NULL,
[ItemName] [varchar](50) NOT NULL,
[iWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_GoldList_iWeg] DEFAULT (0),
[iPrice] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_GoldList_iPrice] DEFAULT (0),
[iSumPrice] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_GoldList_SumPrice] DEFAULT (0),
[iSumWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_GoldList_iSumWeg] DEFAULT (0),
[Color] [varchar](50) NULL,
[oSumPrice] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_GoldList_oSumPrice] DEFAULT (0),
[oSumWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_GoldList_oSumWeg] DEFAULT (0),
[oWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_GoldList_oWeg] DEFAULT (0),
[oPrice] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_GoldList_oPrice] DEFAULT (0),
[LBillID] [varchar](50) NULL,
[LDate] [datetime] NULL,
[Line] [int] NOT NULL,
[IO] [int] NOT NULL,
[Note] [varchar](300) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeOrder_Main]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeOrder_Main](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL,
[Design] [varchar](50) NULL,
[BarCode] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[MakeID] [varchar](50) NULL,
[Adorn] [varchar](50) NULL,
[JewelName] [varchar](50) NULL,
[BeginDate] [datetime] NULL,
[EndDate] [datetime] NULL,
[Spec] [varchar](50) NULL,
[TQty] [decimal](18, 0) NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Main_TQty] DEFAULT (1),
[TWeg] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Main_TWeg] DEFAULT (0),
[Gold] [varchar](50) NULL,
[GoldWeg] [decimal](18, 2) NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Main_GoldWeg] DEFAULT (0),
[xGoldWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Main_xGoldWeg] DEFAULT (0),
[Gem] [varchar](50) NULL,
[mGemWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Main_mGemWeg] DEFAULT (0),
[mGemQty] [decimal](18, 0) NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Main_mGemQty] DEFAULT (0),
[fGem] [varchar](50) NULL,
[fGemWeg] [decimal](18, 3) NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Main_fGemWeg] DEFAULT (0),
[fGemQty] [decimal](18, 0) NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Main_fGemQty] DEFAULT (0),
[JewelType] [varchar](50) NULL,
[CustID] [varchar](50) NULL,
[ProductType] [varchar](50) NULL,
[origCode] [varchar](50) NULL,
[ModeClass] [varchar](50) NULL,
[Note] [varchar](500) NULL,
[LBillID] [varchar](50) NULL,
[isFinish] [bit] NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Main_isFinish] DEFAULT (0),
[isDiscer] [bit] NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Main_isDiscer] DEFAULT (0),
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_WorkFlowIncept]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_WorkFlowIncept](
[AutoID] [int] IDENTITY(1,1) NOT NULL,
[CorpID] [varchar](20) NOT NULL,
[BillID] [varchar](25) NOT NULL,
[WorkBillID] [nchar](25) NOT NULL,
[FlowID] [varchar](20) NOT NULL,
[DatumType] [varchar](20) NULL,
[ItemID] [varchar](20) NULL,
[ItemName] [varchar](20) NULL,
[Line] [int] NOT NULL,
[Weg] [float] NOT NULL,
[Qty] [int] NOT NULL,
[Shape] [varchar](70) NULL,
[Spec] [varchar](70) NULL,
[Price] [decimal](18, 2) NOT NULL,
[Note] [varchar](200) NULL,
CONSTRAINT [PK_jfac_WorkFlowIncept] PRIMARY KEY CLUSTERED
(
[AutoID] ASC
) ON [PRIMARY]
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_MakeOrder_Parts]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_MakeOrder_Parts](
[CorpID] [varchar](50) NULL,
[BillID] [varchar](50) NULL,
[IDX] [int] NOT NULL CONSTRAINT [DF_jfac_MakeOrder_Parts_IDX] DEFAULT (0),
[Design] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[ItemID] [varchar](50) NULL,
[ItemName] [varchar](50) NULL,
[ItemType] [varchar](50) NULL,
[Spec] [varchar](50) NULL,
[Qty] [decimal](18, 0) NOT NULL,
[Weg] [decimal](18, 3) NOT NULL,
[Note] [varchar](200) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_Material_Check]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_Material_Check](
[CorpID] [varchar](50) NOT NULL,
[BillID] [varchar](50) NOT NULL,
[BillDate] [datetime] NOT NULL,
[ItemID] [varchar](50) NOT NULL,
[ItemName] [varchar](50) NOT NULL,
[WareName] [varchar](50) NOT NULL,
[Shape] [varchar](50) NULL,
[Spec] [varchar](50) NULL,
[Clean] [varchar](50) NULL,
[lWeg] [decimal](18, 3) NULL,
[lQty] [numeric](18, 0) NULL,
[iSWeg] [numeric](18, 3) NULL,
[iSQty] [numeric](18, 0) NULL,
[SumPrice] [numeric](18, 2) NULL,
[avgPrice] [numeric](18, 2) NULL,
[Texture] [varchar](50) NULL,
[ProductType] [varchar](50) NULL,
[Unit] [varchar](50) NULL,
[pWeg] [numeric](18, 3) NULL,
[pQty] [numeric](18, 0) NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_ModeDesignNumber]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_ModeDesignNumber](
[CorpID] [varchar](50) NULL,
[Design] [varchar](50) NULL,
[MakeID] [varchar](50) NULL,
[ModeClass] [varchar](50) NULL,
[BuildDate] [datetime] NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_ModeInfo_Arts]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_ModeInfo_Arts](
[CorpID] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[Design] [varchar](50) NULL,
[ItemName] [varchar](100) NULL,
[Note] [varchar](200) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM dbo.sysobjects WHERE id = OBJECT_ID(N'[dbo].[jfac_ModeInfo_Flows]') AND OBJECTPROPERTY(id, N'IsUserTable') = 1)
BEGIN
CREATE TABLE [dbo].[jfac_ModeInfo_Flows](
[CorpID] [varchar](50) NULL,
[ModeID] [varchar](50) NULL,
[Design] [varchar](50) NULL,
[Line] [int] NOT NULL CONSTRAINT [DF_jfac_ModeInfo_Flows_Line] DEFAULT (0),
[ItemID] [varchar](50) NULL,
[ItemName] [varchar](50) NULL,
[WorkTime] [decimal](18, 1) NOT NULL CONSTRAINT [DF_jfac_ModeInfo_Flows_WorkTime] DEFAULT (0),
[WorkValue] [decimal](18, 0) NOT NULL CONSTRAINT [DF_jfac_ModeInfo_Flows_WorkValue] DEFAULT (0),
[Note] [varchar](200) NULL,
[AutoID] [bigint] IDENTITY(1,1) NOT NULL
) ON [PRIMARY]
END
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO |