/* 在这里是向八张出入库老单据头中插入"销售合约:",这个字段FCode,该销售合约是一个核算项目,
类别内码为3003 (t_itemclass),在插入模板表时对应FLookUpCls字段。A01,AO2是单据类型可在 ICTransactionType表中查询*/
--外购入库
Insert Into ICTemplate(FID,FCtlIndex,FTabIndex,FCaption,FCaption_CHT,FCaption_EN,FCtlType,FLookUpCls,FNeedSave,FValueType,FSaveValue,FFieldName,FLeft,FTop,FWidth,FHeight,FEnable,FRelateOutTbl,FPrint,FFontName,FFontSize,FSelBill,FMustInput,FFilter,FRelationID,FAction,FLockA,FROB,FDefaultCtl,FVisForBillType,FVBACtlType, FFormat,FInEntryForSPrint,FDefaultValue,FMaxValue,FMinValue)
Values('A01',34,35,'销售合约:','自定義項37','Self-defined Item37',2,3003,-1,1,1,'FCode',230,455,2550,560,48,0,-1,'宋体',9,0,0,'','','',0,3,0,31,'kdtext','',0,'','','')
--产品入库
Insert Into ICTemplate(FID,FCtlIndex,FTabIndex,FCaption,FCaption_CHT,FCaption_EN,FCtlType,FLookUpCls,FNeedSave,FValueType,FSaveValue,FFieldName,FLeft,FTop,FWidth,FHeight,FEnable,FRelateOutTbl,FPrint,FFontName,FFontSize,FSelBill,FMustInput,FFilter,FRelationID,FAction,FLockA,FROB,FDefaultCtl,FVisForBillType,FVBACtlType, FFormat,FInEntryForSPrint,FDefaultValue,FMaxValue,FMinValue)
Values('A02',34,35,'销售合约:','自定義項37','Self-defined Item37',2,3003,-1,1,1,'FCode',230,455,2550,560,48,0,-1,'宋体',9,0,0,'','','',0,3,0,31,'kdtext','',0,'','','')
Insert Into ICTemplate(FID,FCtlIndex,FTabIndex,FCaption,FCaption_CHT,FCaption_EN,FCtlType,FLookUpCls,FNeedSave,FValueType,FSaveValue,FFieldName,FLeft,FTop,FWidth,FHeight,FEnable,FRelateOutTbl,FPrint,FFontName,FFontSize,FSelBill,FMustInput,FFilter,FRelationID,FAction,FLockA,FROB,FDefaultCtl,FVisForBillType,FVBACtlType, FFormat,FInEntryForSPrint,FDefaultValue,FMaxValue,FMinValue)
Values('A05',34,35,'销售合约:','自定義項37','Self-defined Item37',2,3003,-1,1,1,'FCode',230,455,2550,560,48,0,-1,'宋体',9,0,0,'','','',0,3,0,31,'kdtext','',0,'','','')
Insert Into ICTemplate(FID,FCtlIndex,FTabIndex,FCaption,FCaption_CHT,FCaption_EN,FCtlType,FLookUpCls,FNeedSave,FValueType,FSaveValue,FFieldName,FLeft,FTop,FWidth,FHeight,FEnable,FRelateOutTbl,FPrint,FFontName,FFontSize,FSelBill,FMustInput,FFilter,FRelationID,FAction,FLockA,FROB,FDefaultCtl,FVisForBillType,FVBACtlType, FFormat,FInEntryForSPrint,FDefaultValue,FMaxValue,FMinValue)
Values('A97',34,35,'销售合约:','自定義項37','Self-defined Item37',2,3003,-1,1,1,'FCode',230,455,2550,560,48,0,-1,'宋体',9,0,0,'','','',0,3,0,31,'kdtext','',0,'','','')
--销售出库
Insert Into ICTemplate(FID,FCtlIndex,FTabIndex,FCaption,FCaption_CHT,FCaption_EN,FCtlType,FLookUpCls,FNeedSave,FValueType,FSaveValue,FFieldName,FLeft,FTop,FWidth,FHeight,FEnable,FRelateOutTbl,FPrint,FFontName,FFontSize,FSelBill,FMustInput,FFilter,FRelationID,FAction,FLockA,FROB,FDefaultCtl,FVisForBillType,FVBACtlType, FFormat,FInEntryForSPrint,FDefaultValue,FMaxValue,FMinValue)
Values('B01',34,35,'销售合约:','自定義項37','Self-defined Item37',2,3003,-1,1,1,'FCode',230,455,2550,560,48,0,-1,'宋体',9,0,0,'','','',0,3,0,31,'kdtext','',0,'','','')
Insert Into ICTemplate(FID,FCtlIndex,FTabIndex,FCaption,FCaption_CHT,FCaption_EN,FCtlType,FLookUpCls,FNeedSave,FValueType,FSaveValue,FFieldName,FLeft,FTop,FWidth,FHeight,FEnable,FRelateOutTbl,FPrint,FFontName,FFontSize,FSelBill,FMustInput,FFilter,FRelationID,FAction,FLockA,FROB,FDefaultCtl,FVisForBillType,FVBACtlType, FFormat,FInEntryForSPrint,FDefaultValue,FMaxValue,FMinValue)
Values('B04',34,35,'销售合约:','自定義項37','Self-defined Item37',2,3003,-1,1,1,'FCode',230,455,2550,560,48,0,-1,'宋体',9,0,0,'','','',0,3,0,31,'kdtext','',0,'','','')
Insert Into ICTemplate(FID,FCtlIndex,FTabIndex,FCaption,FCaption_CHT,FCaption_EN,FCtlType,FLookUpCls,FNeedSave,FValueType,FSaveValue,FFieldName,FLeft,FTop,FWidth,FHeight,FEnable,FRelateOutTbl,FPrint,FFontName,FFontSize,FSelBill,FMustInput,FFilter,FRelationID,FAction,FLockA,FROB,FDefaultCtl,FVisForBillType,FVBACtlType, FFormat,FInEntryForSPrint,FDefaultValue,FMaxValue,FMinValue)
Values('B08',34,35,'销售合约:','自定義項37','Self-defined Item37',2,3003,-1,1,1,'FCode',230,455,2550,560,48,0,-1,'宋体',9,0,0,'','','',0,3,0,31,'kdtext','',0,'','','')
Insert Into ICTemplate(FID,FCtlIndex,FTabIndex,FCaption,FCaption_CHT,FCaption_EN,FCtlType,FLookUpCls,FNeedSave,FValueType,FSaveValue,FFieldName,FLeft,FTop,FWidth,FHeight,FEnable,FRelateOutTbl,FPrint,FFontName,FFontSize,FSelBill,FMustInput,FFilter,FRelationID,FAction,FLockA,FROB,FDefaultCtl,FVisForBillType,FVBACtlType, FFormat,FInEntryForSPrint,FDefaultValue,FMaxValue,FMinValue)
Values('B09',34,35,'销售合约:','自定義項37','Self-defined Item37',2,3003,-1,1,1,'FCode',230,455,2550,560,48,0,-1,'宋体',9,0,0,'','','',0,3,0,31,'kdtext','',0,'','','')
if not exists (SELECT * FROM sysobjects t1 ,syscolumns t2 where t1.id=t2.id and t1.name='ICStockBill' and t2.Name='FCode')
Alter Table ICStockBill Add FCode Int NULL
DELETE FROM GLNoteCitation WHERE FCode='FCode' AND FTemplateID='A01' AND FRelationID IN (1,2,3,20)
DELETE FROM GLNoteCitation WHERE FCode='FCode' AND FTemplateID='A02' AND FRelationID IN (1,2,3,20)
DELETE FROM GLNoteCitation WHERE FCode='FCode' AND FTemplateID='A05' AND FRelationID IN (1,2,3,20)
DELETE FROM GLNoteCitation WHERE FCode='FCode' AND FTemplateID='A97' AND FRelationID IN (1,2,3,20)
DELETE FROM GLNoteCitation WHERE FCode='FCode' AND FTemplateID='B01' AND FRelationID IN (1,2,3,20)
DELETE FROM GLNoteCitation WHERE FCode='FCode' AND FTemplateID='B04' AND FRelationID IN (1,2,3,20)
DELETE FROM GLNoteCitation WHERE FCode='FCode' AND FTemplateID='B08' AND FRelationID IN (1,2,3,20)
DELETE FROM GLNoteCitation WHERE FCode='FCode' AND FTemplateID='B09' AND FRelationID IN (1,2,3,20)
Insert Into GLNoteCitation(FTemplateID,FID,FNoteTypeID,FCitationName,FInEntry,FIsMoney,FCode,FCtlIndex,FIsSum,FKeyFieldName,FExtFieldName,FTableName,FRelationID,FCitationName_CHT,FCitationName_EN)
values ('A01',143 ,19,'销售合约:$',0,0 ,'FCode',34,0,'FCode','', '', 1,'自定義項37$','Self-defined Item37$')
Insert Into GLNoteCitation(FTemplateID,FID,FNoteTypeID,FCitationName,FInEntry,FIsMoney,FCode,FCtlIndex,FIsSum,FKeyFieldName,FExtFieldName,FTableName,FRelationID,FCitationName_CHT,FCitationName_EN)
values ('A02',143 ,19,'销售合约:$',0,0 ,'FCode',34,0,'FCode','', '', 1,'自定義項37$','Self-defined Item37$')
Insert Into GLNoteCitation(FTemplateID,FID,FNoteTypeID,FCitationName,FInEntry,FIsMoney,FCode,FCtlIndex,FIsSum,FKeyFieldName,FExtFieldName,FTableName,FRelationID,FCitationName_CHT,FCitationName_EN)
values ('A05',143 ,19,'销售合约:$',0,0 ,'FCode',34,0,'FCode','', '', 1,'自定義項37$','Self-defined Item37$')
Insert Into GLNoteCitation(FTemplateID,FID,FNoteTypeID,FCitationName,FInEntry,FIsMoney,FCode,FCtlIndex,FIsSum,FKeyFieldName,FExtFieldName,FTableName,FRelationID,FCitationName_CHT,FCitationName_EN)
values ('A97',143 ,19,'销售合约:$',0,0 ,'FCode',34,0,'FCode','', '', 1,'自定義項37$','Self-defined Item37$')
Insert Into GLNoteCitation(FTemplateID,FID,FNoteTypeID,FCitationName,FInEntry,FIsMoney,FCode,FCtlIndex,FIsSum,FKeyFieldName,FExtFieldName,FTableName,FRelationID,FCitationName_CHT,FCitationName_EN)
values ('B01',143 ,19,'销售合约:$',0,0 ,'FCode',34,0,'FCode','', '', 1,'自定義項37$','Self-defined Item37$')
Insert Into GLNoteCitation(FTemplateID,FID,FNoteTypeID,FCitationName,FInEntry,FIsMoney,FCode,FCtlIndex,FIsSum,FKeyFieldName,FExtFieldName,FTableName,FRelationID,FCitationName_CHT,FCitationName_EN)
values ('B04',143 ,19,'销售合约:$',0,0 ,'FCode',34,0,'FCode','', '', 1,'自定義項37$','Self-defined Item37$')
Insert Into GLNoteCitation(FTemplateID,FID,FNoteTypeID,FCitationName,FInEntry,FIsMoney,FCode,FCtlIndex,FIsSum,FKeyFieldName,FExtFieldName,FTableName,FRelationID,FCitationName_CHT,FCitationName_EN)
values ('B08',143 ,19,'销售合约:$',0,0 ,'FCode',34,0,'FCode','', '', 1,'自定義項37$','Self-defined Item37$')
Insert Into GLNoteCitation(FTemplateID,FID,FNoteTypeID,FCitationName,FInEntry,FIsMoney,FCode,FCtlIndex,FIsSum,FKeyFieldName,FExtFieldName,FTableName,FRelationID,FCitationName_CHT,FCitationName_EN)
values ('B09',143 ,19,'销售合约:$',0,0 ,'FCode',34,0,'FCode','', '', 1,'自定義項37$','Self-defined Item37$')
Insert Into ICChatBillTitle(FInterID,FTypeID,FColCaption,FColCaption_CHT,FColCaption_EN,FMergeable,FColName,FName,FTableName,FTableAlias,FColType,FItemClassID,FReturnDataType,FCtlIndex,FStatistical,FNeedCount,FCountPriceType,FVisForQuest,FVisForOrder,FFormat)
Values(1031,58,'销售合约:$','自定義項37$','Self-defined Item37$',1,'FCode','FName','t_Item','t1031',1,3003,2,34,1,0,0,1,1,'')
UPDATE ICChatBillTitle SET FVisForOrder=1 WHERE FTypeID=58 AND FColName ='FCode'
insert into ICTableRelation(FTypeID,FinterID,FTableName,FTableNameAlias,FFieldName,FTableName11,FTableNameAlias11,fFieldName11,FLogic)
values(58,1031,'ICStockBill','v1','FCode','t_Item','t1031','FItemID','*=')
delete From ICVoucherTBill Where FBillType = 1 AND FAuditField='FCode' And FItemClassID = 3003 And (FAuditName = '销售合约:' OR FAuditName_CHT='自定義項37' OR FAuditName_EN='Self-defined Item37')
Insert into ICVoucherTBill(FBillType,FItemClassID,FAuditName,FAuditName_CHT,FAuditName_EN,FAuditField,FIsEntry)
values(1,3003,'销售合约:','自定義項37','Self-defined Item37','FCode',0)
IF Exists(Select t2.* From t_TableDescription t1, t_FieldDescription t2 Where t1.FTableID=t2.FTableID And t1.FTableName ='ICStockBill' And t2.FFieldName ='FCode')
Begin
UPDATE t2 SET FFieldType ='INTEGER' ,
FDescription ='销售合约:',FDescription_CHT ='自定義項37',FDescription_EN ='Self-defined Item37',
FFieldNote = '销售合约:',FFieldNote_CHT = '自定義項37',FFieldNote_EN = 'Self-defined Item37'
From t_TableDescription t1, t_FieldDescription t2
Where t1.FTableID=t2.FTableID And t1.FTableName ='ICStockBill' And t2.FFieldName ='FCode'
End
Else
Begin
INSERT INTO t_FieldDescription(FTableID,FFieldName,FFieldType,
FDescription,FDescription_CHT,FDescription_EN,FFieldNote,FFieldNote_CHT,FFieldNote_EN)
Select t1.FTableID,'FCode','INTEGER',
'销售合约:','自定義項37','Self-defined Item37',
'销售合约:','自定義項37','Self-defined Item37'
From t_TableDescription t1
Where t1.FTableName ='ICStockBill'
End
go
Delete ICSelBills Where FID ='A01' and FFieldName='1007101' and FDstCtlField='FCode' and FSelType=2
go
Delete ICSelBills Where FID ='A01' and FFieldName='FBSCBillInterID' and FDstCtlField='FCode' and FSelType=2
go
Delete ICSelBills Where FID ='A01' and FFieldName='FChangeBillNo' and FDstCtlField='FCode' and FSelType=2
go
Delete ICSelBills Where FID ='A01' and FFieldName='FFYBillInterID' and FDstCtlField='FCode' and FSelType=2
go
Delete ICSelBills Where FID ='A01' and FFieldName='FImpInvoiceInterID' and FDstCtlField='FCode' and FSelType=2
go
Delete ICSelBills Where FID ='A01' and FFieldName='FInvoiceInterID' and FDstCtlField='FCode' and FSelType=2
go
Delete ICSelBills Where FID ='A01' and FFieldName='FOrderInterID' and FDstCtlField='FCode' and FSelType=2
go
Delete ICSelBills Where FID ='A01' and FFieldName='FQCRBillInterID' and FDstCtlField='FCode' and FSelType=2
go
Delete ICSelBills Where FID ='A01' and FFieldName='FRSCBillInterID' and FDstCtlField='FCode' and FSelType=2
go
Delete ICSelBills Where FID ='A01' and FFieldName='FSCBillInterID' and FDstCtlField='FCode' and FSelType=2
go