日期:2014-05-17 浏览次数:20707 次
IF OBJECT_ID('t_IC_Item')is not null
drop table t_IC_Item
IF OBJECT_ID('t_Unit')is not null
drop table t_Unit
IF OBJECT_ID('t_BOM')is not null
drop table t_BOM
IF OBJECT_ID('t_BOMChild')is not null
drop table t_BOMChild
CREATE TABLE t_IC_Item(FItemID int,FNumber varchar(200),FName varchar(200),FModel varchar(200),FUnitID int,FErpClsID int)
INSERT t_IC_Item
SELECT 1,'CP.001','产品1' ,'产品规格1' ,1,2 UNION
SELECT 2,'BC.001','半成品1' ,'半成品规格1' ,1,2 UNION
SELECT 3,'BC.002','半成品2' ,'半成品规格2' ,1,2 UNION
SELECT 4,'BC.003','半成品3' ,'半成品规格3' ,1,3 UNION
SELECT 5,'BC.004','半成品4' ,'半成品规格4' ,1,2 UNION
SELECT 6,'ZC.001','主材料1' ,'主材料规格1' ,1,1 UNION
SELECT 7,'ZC.002','主材料2' ,'主材料规格2' ,1,1 UNION
SELECT 8,'ZC.003','主材料3' ,'主材料规格3' ,1,1 UNION
SELECT 9,'ZC.004','主材料4' ,'主材料规格4' ,1,1 UNION
SELECT 10,'ZC.005','主材料5' ,'主材料规格5' ,1,1 UNION
SELECT 11,'ZC.006','主材料6' ,'主材料规格6' ,1,1 UNION
SELECT 12,'ZC.007','主材料7' ,'主材料规格7' ,1,1 UNION
SELECT 13,'ZC.008','主材料8' ,'主材料规格8' ,1,1 UNION
SELECT 14,'ZC.009','主材料9' ,'主材料规格9' ,1,1 UNION
SELECT 15,'ZC.010','主材料10','主材料规格10',1,1 UNION
SELECT 16,'ZC.011','主材料11','主材料规格11',1,1 UNION
SELECT 17,'ZC.012','主材料12','主材料规格12',1,1
CREATE TABLE t_Unit(FID int,FName varchar(20))
INSERT t_Unit SELECT 1,'个'
CREATE TABLE t_BOM(FID int,FBomNo varchar(200),FItemID int,FQty decimal(28,10),FUnitID int)
INSERT t_BOM
SELECT 1,'BOM01',1,1,1 UNION
SELECT 2,'BOM02',2,1,1 UNION
SELECT 3,'BOM03',3,1,1 UNION
SELECT 4,'BOM04',4,1,1 UNION
SELECT 5,'BOM05',5,1,1
CREATE TABLE t_BOMChild(FID int,FEntryID int,FItemID int,FQty decimal(28,10),FUnitID int)
INSERT t_BOMChild
SELECT 1,1, 2,1,1 UNION
SELECT 1,2, 3,1,1 UNION
SELECT 1,3,15,1,1 UNION
SELECT 1,4,17,1,1 UNION
SELECT 2,1, 6,1,1 UNION
SELECT 2,2, 7,1,1 UNION
SELECT 3,1, 8,1,1 UNION
SELECT 3,2, 9,1,1 U