USE [chuangpingdata]
GO
/****** Object:  StoredProcedure [dbo].[P_Select_Get_CP_YDang]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--Exec P_Select_CP_YDang '',0,''
CREATE procedure [dbo].[P_Select_Get_CP_YDang]
  @CKID      char(20),  -----编号
  @BegDate   varchar(40),
  @EndDate   varchar(40),
  @Pstate    Int  --  0 浏览，1新增，2修改
AS
  DECLARE @Tmsql         VARCHAR(8000)
  Set @Tmsql= 'select AA.*,A.*,B.CPName from CP_YDang_KHGet AA 
               inner join CP_YDang A  on AA.CYID=A.CYID 
               inner join CP_Type B On A.CYType=B.CPID where 1=1 ' 
  if @Pstate=0
  begin
    Set @Tmsql=@Tmsql+' and AA.CKDate>='''+RTrim(@BegDate)+''' and AA.CKDate<'''+RTrim(@EndDate)+'''' 
  end
  if @Pstate=2
  begin
    Set @Tmsql=@Tmsql+' and AA.CKID='''+RTrim(@CKID)+'''' 
  end
  if @Pstate=1
  begin
    Set @Tmsql=@Tmsql+' and AA.CKID='''' ' 
  end
exec(@Tmsql)
GO
/****** Object:  StoredProcedure [dbo].[P_HJG_View]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_HJG_View '2014-08-01','2014-10-1',1,'BKAAV14043          '
CREATE Procedure [dbo].[P_HJG_View]
  @begdate varchar(20),
  @enddate varchar(20),
  @Pstate  int,
  @ConNo   varchar(20)
AS
 DECLARE @MSQL Varchar(8000)
 Set @MSQL='
 select isnull(FactoryNoName20,FactoryNoName10) FactoryNoName,
        isnull(ConNO20,ConNO10) ConNO,
 AA.* from(
 select A.*,isnull(C.C_CodeName,D.PBName) C_CodeName,C.MainId,D.DHUnit,C.SubId,ConNo20=B.ConNo 
,isnull(C.C_Spec,D.PBSpec) C_Spec,isnull(C.MFQty,D.PBMF) MFQty,isnull(C.KZQty,D.PBKZ) KZQty
 ,ConNO10=(select ConNo from ContractSX_Main SM where SM.MainId=D.SXMainId )
 ,FactoryNoName10=(select FirstName from ContractSX_Cloth_DH SD where SD.DHID=D.SXDHID)
 ,JM.OrderNo,JS.PRTColor,FactoryNoName20=B.FactoryNoName
,Price=(select Top 1 JGPrice from Contract_Cloth_LLMX AAA where AAA.DHID=A.DHID )
,KCPS=TPPS-HCPS,KCQty=BCPQty-HCQty
,APFlag=(select Count(*) from JYOrder_Sub_AnPai JAP where JAP.LLID=A.LLID)
,khconNo=(select Top 1 khconNo from JYOrderCon_main X where X.conNo=JM.conNO)
 from Contract_Cloth_LL A 
 inner join Contract_Cloth_DH D on A.DHID=D.DHID 
 left join Contract_Main B on D.Mainid=B.Mainid
 left join Contract_Sub C on D.Subid=C.Subid
 inner join JYOrder_Sub JS on A.OrdSubId=JS.SubId 
 inner join JYOrder_Main JM on JS.Mainid=JM.MainId 
 where exists( select * from Contract_Cloth_LLMX LLM where LLM.DHID=isnull(A.DHIdHelp,A.DHID))) AA'
 if @Pstate=1
 begin
   Set @MSQL=@MSQL+' where exists(select * from Contract_Cloth_LLMX CLL where CLL.DHID=AA.DHID  
                    and CLL.TPDate>='''+@begdate+''' and CLL.TPDate<'''+@enddate+''')'
 end
 if @Pstate=2
 begin
   Set @MSQL=@MSQL+' where isnull(ConNO20,ConNO10) like '''+'%'+@ConNo+'%'+''''
 end
 print(@MSQL)
 exec(@MSQL)
GO
/****** Object:  Table [dbo].[P_Label]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[P_Label](
	[LabelID] [int] IDENTITY(1,1) NOT NULL,
	[CustomerNO] [char](20) NULL,
	[CustomerNOName] [char](20) NULL,
	[OrderId] [int] NULL,
	[LabelCaption] [varchar](60) NULL,
	[labelClass] [varchar](20) NULL,
	[LabelType] [varchar](20) NULL,
	[LabelFile] [image] NULL,
	[LabelFileName] [varchar](60) NULL,
	[Filler] [varchar](20) NULL,
	[FillTime] [datetime] NULL,
	[beizhu] [varchar](200) NULL,
	[Editer] [varchar](20) NULL,
	[EditTime] [datetime] NULL,
	[Valid] [char](1) NOT NULL,
 CONSTRAINT [PK_P_Label] PRIMARY KEY CLUSTERED 
(
	[LabelID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  StoredProcedure [dbo].[P_JYOrder_HZFX20]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[P_JYOrder_HZFX20]
  @begdate varchar(20),
  @enddate varchar(20),
  @PState  int,
  @FFWSql   varchar(200)
as
begin   
  declare @strsql varchar(8000)
  declare @strwhere varchar(8000)
  
  SET @strwhere=''
  
  IF @PState=0
  SET @strwhere=@strwhere+' where A.FillTime>='''+@begdate+''' and A.FillTime<'''+@enddate+''' and A.WCStatus=''已完成'' '
  else
  SET @strwhere=@strwhere+@FFWSql
  
  SET @strsql=' select BB.PRTKuanNO,DD.PRTColor,DD.PRTColorNo SOrddefstr1,BB.PRTHX,DD.SOrddefstr4,CC.OrderNo
               ,CC.MPRTCodeName,DD.PRTMF MPRTMF,DD.PRTKZ MPRTKZ,CC.MPRTKuanNO,CC.MaiTouNote
          ,B.factoryName,B.fromFactoryName,EE.ConPerson2,EE.conDefstr2,EE.conDefstr3,EE.ConNo,EE.KHConNO,DD.StyleNo,A.*
          ,B.RCGangNo
          ,CDName=dbo.F_Get_Order_SubStr(A.MJID,''QDHZ'')
          ,CDQty=(select SUM(CDqty) from WFB_MJJY_CD X where X.MJID=A.MJID)
          ,SumQty=(select SUM(CDBeg) from WFB_MJJY_CD X where X.MJID=A.MJID)
    from WFB_MJJY A
    inner join CK_SXPB_CR B on B.SPID=A.APID
    left join JYOrder_Sub BB on A.SubId=BB.SubId
    left join JYOrder_Main CC on A.MainId=CC.MainId 
    left join JYOrderCon_Sub DD on A.ConID=DD.Subid 
    left join JYOrderCon_Main EE on DD.Mainid=EE.Mainid'
    
  
  EXEC(@strsql+@strwhere)
    
end

--,CDQK=dbo.F_Get_Order_SubStr(A.MJID,''QDHZ'')
GO
/****** Object:  StoredProcedure [dbo].[P_View_CPKCMX]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec [P_View_CPKCMX] ''
CREATE Procedure [dbo].[P_View_CPKCMX]
  @WSQl varchar(200)
 AS
   DECLARE @MSQL varchar(6000)
   Set @MSQL='
   Select AAA.*,Case when CDFlag>0 then dbo.F_Get_Order_SubStr(AAA.MJID,''MJCDHZSL'') else '''' end as CDQK 
   from (
   select AA.KCQty,AA.KCKgQty,B.OrderNo,B.MPRTCodeName,B.MprtkuanNo,C.PRTColor,B.MPRTMF,B.MPRTKZ,D.MJXH,C.SOrddefstr1,C.PRTHX,C.PrtKuanNo
         ,AOrdDefstr1=(select AOrdDefstr1 from JYOrder_Sub_AnPai where ApId=A.ApId),B.Filler,B.OrdPerson2,B.MainId,C.SubId
         ,A.CPType,AA.MJID,CDFlag=(select Count(MJID) from WFB_MJJY_CD CD where MJID=D.MJID),A.QtyUnit,AA.CRID,A.CRTime,A.BaoNO,A.BCID,A.RKplace
   from CK_BanCP_KC AA 
   inner join  CK_BanCP_CR A on AA.CRID=A.CRID and A.CRType=''检验入库'' 
   inner join JYOrder_Main B on A.MainId=B.MainId
   inner join JYOrder_Sub C on A.SubId=C.SubId
   inner join WFB_MJJY D on AA.MJId=D.MJId
   where (AA.KCQty>0 or AA.KCKGQty>0) '+@WSQl
   Set @MSQL=@MSQL+')AAA order by OrderNo,PRTColor,MJID'
   exec(@MSQL)
GO
/****** Object:  StoredProcedure [dbo].[P_View_Cost]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from YF_Money_CR
--exec P_View_Cost '2013-01-01','2013-10-10',''
CREATE Procedure [dbo].[P_View_Cost]
  @Begdate varchar(20),
  @Enddate varchar(20),
  @WSql    varchar(200) 
AS
  DECLARE @MSql varchar(8000)
  Set @MSql='select A.*,A.OrderNo OrderNoM   
              ,OrderQty=(select isnull(Sum(PRTOrderQty),0) from JYOrder_Sub B where B.MainId=A.MainId)
              ,DPQty=(select isnull(Sum(Qty),0) from YF_Money_CR B where B.MainId=A.MainId and B.CRType=''应付款登记''
                      and YFType=''自动生成'' and YFName=''坯布费用''  )
              ,DPUnit=(select Top 1 QtyUnit from YF_Money_CR B where B.MainId=A.MainId and B.CRType=''应付款登记''
                      and YFType=''自动生成'' and YFName=''坯布费用''  ) 
              ,PriceUnit=(select Top 1 PriceUnit from JYOrder_Sub B where B.MainId=A.MainId)
              ,OrderUnit=(select Top 1 OrderUnit from JYOrder_Sub B where B.MainId=A.MainId)
              ,PRTPrice=dbo.F_Get_Order_SubStr(A.MainId,''OrdPrice'')
              ,FHQty=(select isnull(sum(Qty),0) from CK_BanCp_CR B
                      where B.MainId=A.MainId and B.CRType=''正常出库'' and CPType=''正品'' )
              ,YSK=(select isnull(sum(BBMoney),0) from YF_Money_CR B where B.MainId=A.MainId and B.CRType=''应收款登记'')
              ,YSKYB=(select isnull(sum(Money),0) from YF_Money_CR B where B.MainId=A.MainId and B.CRType=''应收款登记'')
              ,SK=(select isnull(sum(BBMoney),0) from YF_Money_CR B where B.MainId=A.MainId  and CRType=''收款登记'' )
              ,SKYB=(select isnull(sum(Money),0) from YF_Money_CR B where B.MainId=A.MainId  and CRType=''收款登记'' )
              ,FK=(select isnull(sum(BBMoney),0) from YF_Money_CR B where B.MainId=A.MainId and  CRType=''付款登记'' )
              ,YFK=(select isnull(sum(BBMoney),0) from YF_Money_CR B where B.MainId=A.MainId and  CRType=''应付款登记'' )
       from JYOrder_Main A where 1=1'
       if RTrim(@Begdate)<>''
       begin
         Set @Msql=@Msql+' and OrdDate>='''+@Begdate+''' and OrdDate<'''+@Enddate+''''
       end
       if RTrim(@Wsql)<>''
       begin
         Set @Msql=@Msql+@Wsql
       end
  Set @MSql='select YSK=isnull(YSK,0),FHQty=isnull(FHQty,0),
         AA.* ,MLR=SK-YFK,YMoneyYB=YSKYB-SKYB,YMoneyBB=YSK-SK  
         from( '+@MSql+')AA'
--Print(@MSql)  
exec(@MSql)
GO
/****** Object:  StoredProcedure [dbo].[P_View_ClothHZ]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_ClothHZ '2012-01-01','2012-12-31',' and ConNo like ''%1233%'' '
CREATE Procedure [dbo].[P_View_ClothHZ]
  @begdate varchar(20),
  @enddate varchar(20),
  @WSQL    varchar(100)
AS
  DECLARE @MSQL varchar(7000)
  Set @MSQL='SELECT * FROM(
    Select  ConNo,C_CodeName,C_Spec,MFQty,KZQty,PBC,FirstNo,FirstName,
            DHPS,DHMQty,TPPS,TPMQty,BCPPS,BCPMQty,
            BPPS=DHPS-TPPS,BPQty=DHMQty-TPMQty,
            HCPS=HCPS-HXPS,HCMQty=HCMQty-HXMQty,
            JGZPS=TPPS-(HCPS-HXPS),JGZMQty=BCPMQty-(HCMQty-HXMQty),
            KCPS=DHPS-(HCPS-HXPS),KCQty=DHMQty-TPMQty+BCPMQty-(HCMQty-HXMQty),
            case when TPMQty<>0 then (TPMQty-BCPMQty)*1.00/TPMQty*100 else null end as BCPSH 
            ,case when BCPMQty<>0 and HCMQty>0 then (BCPMQty-HCMQty+HXMQty)*1.00/BCPMQty*100 else null end as CPSH 
     from(
     select FirstNo,FirstName,DHPS,DHMQty,
            TPPS=(select isnull(Sum(TPPS),0) from Contract_Cloth_LL LL where LL.DHID=DH.DHID and isnull(DHIDHelp,'''')=''''),
            TPMQty=(select isnull(Sum(TPMQty),0) from Contract_Cloth_LL LL where LL.DHID=DH.DHID and isnull(DHIDHelp,'''')=''''),
            BCPPS=(select isnull(Sum(TPPS),0) from Contract_Cloth_LL LL where LL.DHID=DH.DHID and isnull(DHIDHelp,'''')=''''), 
            BCPMQty=(select isnull(Sum(BCPMQty),0) from Contract_Cloth_LL LL where LL.DHID=DH.DHID and isnull(DHIDHelp,'''')=''''),
            HCPS=(select isnull(Sum(HCPS),0) from Contract_Cloth_LL LL where LL.DHID=DH.DHID and isnull(DHIDHelp,'''')=''''), 
            HCMQty=(select isnull(Sum(HCMQty),0) from Contract_Cloth_LL LL where LL.DHID=DH.DHID and isnull(DHIDHelp,'''')=''''), 
            HXPS=(select isnull(Sum(HXPS),0) from Contract_Cloth_LL LL where LL.DHID=DH.DHID and isnull(DHIDHelp,'''')=''''), 
            HXMQty=(select isnull(Sum(HXMQty),0) from Contract_Cloth_LL LL where LL.DHID=DH.DHID and isnull(DHIDHelp,'''')=''''),
            CM.ConNo,PBC=CM.FactoryNoName,CS.C_CodeName,CS.C_Spec,CS.MFQty,CS.KZQty 
     from Contract_Cloth_DH DH
     inner join Contract_Main CM on DH.MainId=CM.MainId
     inner join Contract_Sub CS on DH.SubId=CS.SubId
     where CM.QDTime>='''+@begdate+''' and CM.QDTime<'''+@enddate+'''
     ) AA
  union All 
  Select  ConNo,C_CodeName,C_Spec,MFQty,KZQty,PBC,FirstNo,FirstName,
            DHPS,DHMQty,TPPS,TPMQty,BCPPS,BCPMQty,
            BPPS=0,BPQty=0,
            HCPS=HCPS-HXPS,HCMQty=HCMQty-HXMQty,
            JGZPS=TPPS-(HCPS-HXPS),JGZMQty=BCPMQty-(HCMQty-HXMQty),
            KCPS=DHPS-(HCPS-HXPS),KCQty=DHMQty-TPMQty+BCPMQty-(HCMQty-HXMQty)
            ,case when TPMQty<>0 then (TPMQty-BCPMQty)*1.00/TPMQty*100 else null end as BCPSH 
            ,case when BCPMQty<>0 and HCMQty>0 then (BCPMQty-HCMQty+HXMQty)*1.00/BCPMQty*100 else null end as CPSH 
     from(
     select DH.FirstNo,DH.FirstName,
            DHPS=(select isnull(Sum(LL.HCPS),0) from Contract_Cloth_LL LL where LL.LLID=DH.DHIDHelp),
            DHMQty=(select isnull(Sum(LL.HCMQty),0) from Contract_Cloth_LL LL where LL.LLID=DH.DHIDHelp),
            DH.TPPS,
            DH.TPMQty,
            BCPPS=DH.TPPS, 
            DH.BCPMQty,
            DH.HCPS, 
            DH.HCMQty, 
            DH.HXPS, 
            DH.HXMQty,
            CM.ConNo,PBC=CM.FactoryNoName,CS.C_CodeName,CS.C_Spec,CS.MFQty,CS.KZQty 
     from Contract_Cloth_LL DH
     inner join Contract_Cloth_DH DHB on DH.DHID=DHB.DHID
     inner join Contract_Main CM on DHB.MainId=CM.MainId
     inner join Contract_Sub CS on DHB.SubId=CS.SubId
     where CM.QDTime>='''+@begdate+''' and CM.QDTime<'''+@enddate+''' and isnull(DH.DHIDHelp,'''')<>''''
     ) AA  )AAA where 1=1 '
   Set @MSql=@MSQL+@WSQL
   --Print(@MSql)
   Exec(@MSql)
GO
/****** Object:  StoredProcedure [dbo].[P_View_BaoGuanData_XS]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- exec [P_View_BaoGuanData_XS] ''
CREATE Procedure [dbo].[P_View_BaoGuanData_XS]
  @WSql varchar(2000)
AS
  DECLARE @Msql varchar(8000) 
  Set @Msql='
select 
 A7FPDate=Convert(varchar(10),A7FPDate,120),B3KaiHangDate=Convert(varchar(10),B3KaiHangDate,120),
 A.*,B.*,Case when C5BGUnit=''MTR'' then C4BGQty else ZheSuanMiQty end as C4BGQtyJS
,Case when C5BGUnit=''KG'' then ZheSuanMiQty else E4JingZ  end as FZQty
,Case when C5BGUnit=''KG'' then ''MTR'' else ''KG''  end as FZQtyUnit
--,KHNameEng=(select Top 1 KHNameEng from ZH_KH_Info KH where KH.KHNameJC =
           --(select CustomerNoName from JYOrderCon_Main F where F.ConNo like ''%''+RTrim(A.A5ConNO) ))
 from JYOrder_BaoGuan_Main A inner join JYOrder_BaoGuan_Sub B on A.BGId=B.BGId 
 where    A.Valid=''Y'' '--
 
 Set @Msql=@Msql+@WSql+' order by A4FPNO'
 exec(@Msql)
GO
/****** Object:  StoredProcedure [dbo].[P_View_Order_FB]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_Order '2012-01-01','2014-01-01',''
CREATE Procedure [dbo].[P_View_Order_FB]
  @Begdate varchar(20),
  @enddate varchar(20),
  @WSql    varchar(2000)
AS
DECLARE @MSql varchar(8000)
  Set @MSql=
            'select AA.*
             from
                 (select 
                  OrderQty=(select Sum(PRTOrderQty) from JYOrderFB_Sub B where B.MainId=A.MainId group by B.MainId),
                  ZQty=(select Sum(PRTOrderQty) from JYOrderFB_Sub B where B.MainId=A.MainId group by B.MainId),
                  OrderUnit=(select Top 1 OrderUnit  from JYOrderFB_Sub B where B.MainId=A.MainId),
                  ZSordQty1=(select Sum(SordQty1) from JYOrderFB_Sub B where B.MainId=A.MainId group by B.MainId),
                  PrtMoney=(select Sum(PrtMoney) from JYOrderFB_Sub B where B.MainId=A.MainId),
                  MPRTType=(select E.MPRTTYPE from JYOrderCon_Main E where E.ConNo=A.conNo ),
                  A.* 
            from JYOrderFB_Main A 
            where A.OrdDate>='''+@Begdate+''' and  A.OrdDate<'''+@enddate+''''
  Set @MSql=@MSql+@WSql+')AA'
  --Print(@MSql)
  exec(@MSql)
GO
/****** Object:  StoredProcedure [dbo].[P_View_Order_CY]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_Order '2012-01-01','2014-01-01',''
CREATE Procedure [dbo].[P_View_Order_CY]
  @Begdate varchar(20),
  @enddate varchar(20),
  @WSql    varchar(2000)
AS
DECLARE @MSql varchar(8000)
  Set @MSql=
            'select AA.*
             from
                 (select 
                  OrderQty=(select Sum(PRTOrderQty) from JYOrderCY_Sub B where B.MainId=A.MainId group by B.MainId),
                  ZQty=(select Sum(PRTOrderQty) from JYOrderCY_Sub B where B.MainId=A.MainId group by B.MainId),
                  OrderUnit=(select Top 1 OrderUnit  from JYOrderCY_Sub B where B.MainId=A.MainId),
                  ZSordQty1=(select Sum(SordQty1) from JYOrderCY_Sub B where B.MainId=A.MainId group by B.MainId),
                  A.*,A.OrderNo OrderNoM 
            from JYOrderCY_Main A 
            where A.OrdDate>='''+@Begdate+''' and  A.OrdDate<'''+@enddate+''''
  Set @MSql=@MSql+@WSql+')AA'
  --Print(@MSql)
  exec(@MSql)
GO
/****** Object:  StoredProcedure [dbo].[P_View_Order]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_Order '2012-01-01','2014-01-01',''
CREATE Procedure [dbo].[P_View_Order]
  @Begdate varchar(20),
  @enddate varchar(20),
  @WSql    varchar(2000)
AS
DECLARE @MSql varchar(8000)
  Set @MSql=
            'select AA.*,GYYQ=GM+SM+SLD+SXLD+SL+ND+PH+KQQ+DSGY+DPL+ZRX+SLYD
             from
                 (select 
                  OrderQty=(select Sum(PRTOrderQty) from JYOrder_Sub B where B.MainId=A.MainId group by B.MainId),
                  ZQty=(select Sum(PRTOrderQty) from JYOrder_Sub B where B.MainId=A.MainId group by B.MainId),
                  OrderUnit=(select Top 1 OrderUnit  from JYOrder_Sub B where B.MainId=A.MainId),
                  PriceUnit=(select Top 1 PriceUnit  from JYOrder_Sub B where B.MainId=A.MainId),
                  PRTPrice=(select Top 1 PRTPrice  from JYOrder_Sub B where B.MainId=A.MainId),
                  SLBName=(select Top 1 SLBName  from JYOrder_Sub B where B.MainId=A.MainId),
                  KHConNO=(select Top 1 KHConNO  from JYOrdercon_Main X where X.conNO=A.conNO),
                  Case when isnull(MPRTColorLaoDu1,'''')='''' then '''' else ''干磨:''+RTrim(MPRTColorLaoDu1)+'' '' end as GM,
                  Case when isnull(MPRTColorLaoDu2,'''')='''' then '''' else ''湿磨:''+RTrim(MPRTColorLaoDu2)+''  '' end as SM,
                  Case when isnull(MPRTColorLaoDu3,'''')='''' then '''' else ''沾色牢度:''+RTrim(MPRTColorLaoDu3)+'' '' end as SLD,
                  Case when isnull(MPRTColorLaoDu4,'''')='''' then '''' else ''水洗牢度:''+RTrim(MPRTColorLaoDu4)+'' '' end as SXLD,
                  Case when isnull(MPRTSL,'''')='''' then '''' else ''缩率:''+RTrim(MPRTSL)+'' '' end as SL,
                  Case when isnull(MPRTNiuDu,'''')='''' then '''' else ''扭度:''+RTrim(MPRTNiuDu)+'' '' end as ND,
                  Case when isnull(MPRTPH,'''')='''' then '''' else ''PH:''+RTrim(MPRTPH)+'' '' end as PH,
                  Case when isnull(MPRTKQiQiu,'''')='''' then '''' else ''抗起球:''+RTrim(MPRTKQiQiu)+'' '' end as KQQ,
                  Case when isnull(MPRTDuiSeGY,'''')='''' then '''' else ''对色光源:''+RTrim(MPRTDuiSeGY)+'' '' end as DSGY,
                  Case when isnull(MPRTDingPoLv,'''')='''' then '''' else ''顶破率:''+RTrim(MPRTDingPoLv)+'' '' end as DPL,
                  Case when isnull(MPRTZuRanXing,'''')='''' then '''' else ''阻燃性:''+RTrim(MPRTZuRanXing)+'' '' end as ZRX,
                  Case when isnull(MPRTQtyNote,'''')='''' then '''' else ''数量溢短:''+RTrim(MPRTQtyNote)+'' '' end as SLYD,
                  A.*,A.OrderNo OrderNoM
                  ,ConNoHZ=[dbo].[F_Get_Order_SubStr](A.MainId,''ConNoHZ'') 
                  ,KHConNoHZ=[dbo].[F_Get_Order_SubStr](A.MainId,''KHConNoHZ'') 
                  ,Case when isnull((select count(*) from TP_File where WBID=A.MainID and TFType=''指示单'' ),0)>0 
                   then Cast(1 as bit) else Cast(0 as bit) end as FJFlag
            from JYOrder_Main A 
            where A.OrdDate>='''+@Begdate+''' and  A.OrdDate<'''+@enddate+''')AA where 1=1 '
  Set @MSql=@MSql+@WSql
  --Print(@MSql)
  exec(@MSql)
GO
/****** Object:  StoredProcedure [dbo].[P_View_HC]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_HC '2014-10-01','2018-10-22',''
CREATE PROCEDURE [dbo].[P_View_HC]
  @Begdate varchar(20),
  @Enddate varchar(20),
  @WSql    varchar(100)
AS   
  DECLARE @MSQL varchar(2000)
  Set @MSQL='select B.OrderNo OrderNoM,C.PRTColor,c.prtkuanNo,C.PRTHX,C.PRTOrderQty,C.OrderUnit,
               A.*,B.ConNO ConNoM,B.MPrtCodeName,B.Mprtspec,
                    KHCOnNO=(select KHCOnNo from JYOrdercon_Main X where X.conNO=B.conNO)
                    from CK_SXPB_CR A
                    inner join JYOrder_Sub C on A.OrdSubIdCK=C.SubId
                    inner join JYOrder_Main B on A.OrdMainIdCK=B.MainId
             where 1=1 '
  IF RTRIM(@Begdate)<>''
  BEGIN
    Set @MSQL=@MSQL+' and A.CRTime>='''+@Begdate+''' 
                      and A.CRTime<'''+@Enddate+'''' 
  END
  SET @MSQL=@MSQL+@WSql
  EXEC(@MSQL)
GO
/****** Object:  StoredProcedure [dbo].[P_View_PBCPKCMX]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[P_View_PBCPKCMX]
  @WSQl varchar(200)
 AS
   DECLARE @MSQL varchar(6000)
   Set @MSQL='
   Select AAA.*,Case when CDFlag>0 then dbo.F_Get_Order_SubStr_PB(AAA.MJID,''MJCDHZSLPB'') else '''' end as CDQK 
   from (
   select AA.KCQty,AA.KCKgQty,B.ConNo,C.C_CodeName,B.OrderNo,D.MJXH,A.QtyUnit,AA.CRID
         ,B.Filler,A.CPType,AA.MJID,CDFlag=(select Count(*) from WFB_MJJY_CD_PB CD where MJID=D.MJID),
         C.MFQty,C.KZQty
   from CK_PBCP_KC AA 
   inner join  CK_PBCP_CR A on AA.CRID=A.CRID and A.CRType=''检验入库'' 
   inner join Cloth_Main B on A.MainId=B.MainId
   inner join Cloth_Sub C on A.MainId=C.MainId
   inner join WFB_MJJY_PB D on AA.MJId=D.MJId
   where AA.KCQty>0 or KCKGQty>0 '+@WSQl
   Set @MSQL=@MSQL+')AAA order by ConNo,MJID'
   exec(@MSQL)
GO
/****** Object:  StoredProcedure [dbo].[P_View_OrderSub]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from JYOrder_Main 
--exec P_View_OrderSub '2012-01-01','2014-01-01',' and A.MainId=''JM130703001         '' '
CREATE Procedure [dbo].[P_View_OrderSub]
  @Begdate varchar(20),
  @enddate varchar(20),
  @WSql    varchar(2000)
AS
DECLARE @MSql varchar(8000)
  Set @MSql=
            'select AA.*,GYYQ=GM+SM+SLD+SXLD+SL+ND+PH+KQQ+DSGY+DPL+ZRX+SLYD
             from
                 (select 
                  OrderQty=(select Sum(PRTOrderQty) from JYOrder_Sub B where B.MainId=A.MainId group by B.MainId),
                  ZQty=(select Sum(PRTOrderQty) from JYOrder_Sub B where B.MainId=A.MainId group by B.MainId),
                  OrderUnit=(select Top 1 OrderUnit  from JYOrder_Sub B where B.MainId=A.MainId),
                  PriceUnit=(select Top 1 PriceUnit  from JYOrder_Sub B where B.MainId=A.MainId),
                  PRTPrice=(select Top 1 PRTPrice  from JYOrder_Sub B where B.MainId=A.MainId),
                  SLBName=(select Top 1 SLBName  from JYOrder_Sub B where B.MainId=A.MainId),
                  Case when isnull(MPRTColorLaoDu1,'''')='''' then '''' else ''干磨:''+RTrim(MPRTColorLaoDu1)+'' '' end as GM,
                  Case when isnull(MPRTColorLaoDu2,'''')='''' then '''' else ''湿磨:''+RTrim(MPRTColorLaoDu2)+''  '' end as SM,
                  Case when isnull(MPRTColorLaoDu3,'''')='''' then '''' else ''沾色牢度:''+RTrim(MPRTColorLaoDu3)+'' '' end as SLD,
                  Case when isnull(MPRTColorLaoDu4,'''')='''' then '''' else ''水洗牢度:''+RTrim(MPRTColorLaoDu4)+'' '' end as SXLD,
                  Case when isnull(MPRTSL,'''')='''' then '''' else ''缩率:''+RTrim(MPRTSL)+'' '' end as SL,
                  Case when isnull(MPRTNiuDu,'''')='''' then '''' else ''扭度:''+RTrim(MPRTNiuDu)+'' '' end as ND,
                  Case when isnull(MPRTPH,'''')='''' then '''' else ''PH:''+RTrim(MPRTPH)+'' '' end as PH,
                  Case when isnull(MPRTKQiQiu,'''')='''' then '''' else ''抗起球:''+RTrim(MPRTKQiQiu)+'' '' end as KQQ,
                  Case when isnull(MPRTDuiSeGY,'''')='''' then '''' else ''对色光源:''+RTrim(MPRTDuiSeGY)+'' '' end as DSGY,
                  Case when isnull(MPRTDingPoLv,'''')='''' then '''' else ''顶破率:''+RTrim(MPRTDingPoLv)+'' '' end as DPL,
                  Case when isnull(MPRTZuRanXing,'''')='''' then '''' else ''阻燃性:''+RTrim(MPRTZuRanXing)+'' '' end as ZRX,
                  Case when isnull(MPRTQtyNote,'''')='''' then '''' else ''数量溢短:''+RTrim(MPRTQtyNote)+'' '' end as SLYD,
                  B.XHNO,B.PRTColor,B.PRTOrderQty,B.PRTHX,B.SOrddefstr1,B.SOrddefstr4,B.SOrddefstr2,
                  Case when B.OrderUnit=''M'' then ''(''+Cast (Cast(dbo.F_Get_Order_MFKZ(A.MainId,''MF'') 
                                                   *1.00/100*B.PRTOrderQty*dbo.F_Get_Order_MFKZ(A.MainId,''KZ'')
                                                    /1000  as decimal(18,0) ) as varchar(20))+''Kg)'' 
                       when B.OrderUnit=''Y'' then ''(''+Cast ( Cast(dbo.F_Get_Order_MFKZ(A.MainId,''MF'')
                                                  *1.00/100*B.PRTOrderQty*0.9144*dbo.F_Get_Order_MFKZ(A.MainId,''KZ'')
                                                   /1000 as decimal(18,0) )as varchar(20))+''Kg)'' 
                       else '''' end as PRTOrderKgQtyStr, 
                  Case when B.OrderUnit=''M'' then Cast(dbo.F_Get_Order_MFKZ(A.MainId,''MF'') 
                                                   *1.00/100*B.PRTOrderQty*dbo.F_Get_Order_MFKZ(A.MainId,''KZ'')
                                                    /1000  as decimal(18,0) ) 
                       when B.OrderUnit=''Y'' then  Cast(dbo.F_Get_Order_MFKZ(A.MainId,''MF'')
                                                  *1.00/100*B.PRTOrderQty*0.9144*dbo.F_Get_Order_MFKZ(A.MainId,''KZ'')
                                                   /1000 as decimal(18,0) ) 
                       when B.OrderUnit=''Kg'' then B.PRTOrderQty
                       else null end as PRTOrderKgQty,
 
                  A.*,A.OrderNo OrderNoM 
            from JYOrder_Main A 
            inner join JYOrder_Sub B on A.MainId=B.MainId
            where A.OrdDate>='''+@Begdate+''' and  A.OrdDate<'''+@enddate+''''
  Set @MSql=@MSql+@WSql+')AA'
  --Print(@MSql)
  exec(@MSql)


--select * from JYOrder_Main
--alter table JYOrder_Main Add PiZhong decimal(18,2) not null default(0)
GO
/****** Object:  StoredProcedure [dbo].[P_View_OrderLabelSet]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_OrderLabelSet '2017-01-01','2018-01-01',''
CREATE Procedure [dbo].[P_View_OrderLabelSet]
  @Begdate varchar(20),
  @enddate varchar(20),
  @WSql    varchar(2000)
AS
DECLARE @MSql varchar(8000)
  Set @MSql='select AA.* from JYOrder_Main AA where 1=1 '
  if RTRIM(@Begdate)<>''
  begin
    Set @MSql=@MSql+' and OrdDate>='''+@Begdate+''' and  OrdDate<'''+@enddate+''' '
  end
            
  Set @MSql=@MSql+@WSql
  --Print(@MSql)
  exec(@MSql)
GO
/****** Object:  StoredProcedure [dbo].[P_View_OrderJD]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from Contract_Cloth_LLMX
--select * from CK_BanCp_CR
--exec P_View_OrderJD '','','',''
CREATE Procedure [dbo].[P_View_OrderJD]
  @begdate varchar(20),
  @enddate varchar(20),
  @Filler  varchar(20),
  @WSql    varchar(1000)
AS
  DECLARE @MSQL varchar(8000)
  Set @MSQL='
select A.MainId,A.OrderNo,A.CustomerNoName,A.DlyDate,A.OrdDate,A.MPRTCodeName,A.MPRTSpec,
       A.MPRTCF,A.MPRTMF,A.MPRTKZ,A.MPRTSL,A.Note,TaiTou=RTrim(A.OrdDefStr2),A.Filler
       ,OrdColor=dbo.F_Get_Order_SubStr(A.MainId,''OrdColor'')
       ,OrdQty=(select sum(PRTOrderQty) 
                     from JYOrder_Sub JS 
                     where JS.MainId=A.MainId )
       ,OrdUnit=(select Top 1 JS.OrderUnit 
                     from JYOrder_Sub JS 
                     where JS.MainId=A.MainId )
       ,ClothHTFlag=(select case when count(*)>0 then 1 else 0 end As ClothHTFlag 
                     from Contract_Main CM where CM.ConNo=A.OrderNo group by CM.ConNo)
       , ClothHTQty=(select sum(CS.C_Qty) 
                     from Contract_Main CM inner join Contract_Sub CS on CM.Mainid=CS.Mainid 
                     where CM.ConNo=A.OrderNo )
       , ClothHTUnit=(select Top 1 CS.C_Unit 
                     from Contract_Main CM inner join Contract_Sub CS on CM.Mainid=CS.Mainid 
                     where CM.ConNo=A.OrderNo )
       ,ClothDHFlag=(select case when count(*)>0 then 1 else 0 end As ClothDHFlag 
                     from Contract_Main CM inner join Contract_Sub CS on CM.Mainid=CS.Mainid 
                     inner join Contract_Sub_MX CSM on CS.Subid=CSM.Subid 
                     where CM.ConNo=A.OrderNo group by CM.ConNo)
        ,ClothDHQty=(select sum(CSM.MXQty) 
                     from Contract_Main CM inner join Contract_Sub CS on CM.Mainid=CS.Mainid 
                     inner join Contract_Sub_MX CSM on CS.Subid=CSM.Subid 
                     where CM.ConNo=A.OrderNo )
       ,ClothTPFlag=(select case when count(*)>0 then 1 else 0 end As ClothTPFlag 
                     from Contract_Cloth_LL CL inner join JYOrder_Sub JS on CL.OrdSubid=JS.Subid 
                     where JS.Mainid=A.MainId group by JS.Mainid)
       ,ClothTPQty=(select sum(CM.TPQty) 
                     from  Contract_Cloth_LLMX CM inner join JYOrder_Sub JS on CM.OrdSubid=JS.Subid 
                     where JS.MainId=A.MainId )
       ,ClothTPUnit=(select Top 1 CM.TPUnit
                     from  Contract_Cloth_LLMX CM inner join JYOrder_Sub JS on CM.OrdSubid=JS.Subid 
                     where JS.MainId=A.MainId )
       ,ClothTPColor=dbo.F_Get_Order_SubStr(A.MainId,''TPColor'')
       ,ClothHCFlag=(select case when count(*)>0 then 1 else 0 end As ClothHCFlag 
                     from JYOrder_Sub_AnPai JAP 
                     where JAP.Mainid=A.MainId group by JAP.Mainid)
       ,ClothHCQty=(select sum(AOrdQty1)
                     from JYOrder_Sub_AnPai JAP 
                     where JAP.Mainid=A.MainId group by JAP.Mainid)
       ,ClothHCUnit=(select Top 1 JAP.AOrddefstr2
                     from JYOrder_Sub_AnPai JAP 
                     where JAP.Mainid=A.MainId )
       ,HCColor=dbo.F_Get_Order_SubStr(A.MainId,''HCColor'')
       ,ClothRKFlag=(select case when count(*)>0 then 1 else 0 end As ClothRKFlag 
                     from CK_BanCp_CR CBR 
                     where CBR.Mainid=A.MainId group by CBR.Mainid)
       ,ClothRKQty=(select sum(Qty)
                     from CK_BanCp_CR CBR 
                     where CBR.Mainid=A.MainId and CRType=''检验入库'' group by CBR.Mainid)
       ,ClothRKUnit=(select Top 1 CBR.QtyUnit
                     from CK_BanCp_CR CBR 
                     where CBR.Mainid=A.MainId and CRType=''检验入库'' )
       ,RKColor=dbo.F_Get_Order_SubStr(A.MainId,''RKColor'')
       ,ClothCKFlag=(select case when count(*)>0 then 1 else 0 end As ClothCKFlag 
                     from CK_BanCp_CR CBR 
                     where CBR.Mainid=A.MainId and CRType=''正常出库'' group by CBR.Mainid)
       ,ClothCKQty=(select sum(Qty)
                     from CK_BanCp_CR CBR 
                     where CBR.Mainid=A.MainId and CRType=''正常出库'' group by CBR.Mainid)
       ,CKColor=dbo.F_Get_Order_SubStr(A.MainId,''CKColor'')
       ,KCZPQty=(select sum(KCQty) from CK_BanCP_CR CR inner join CK_BanCP_KC KC on CR.CRID=KC.CRID
                 where CR.MainId=A.MainId and KC.KCQty>0 and CRType=''检验入库'' and CPType=''正品''
                   )
       ,KCCPQty=(select sum(KCQty) from CK_BanCP_CR CR inner join CK_BanCP_KC KC on CR.CRID=KC.CRID
                 where CR.MainId=A.MainId and KC.KCQty>0 and CRType=''检验入库'' and CPType=''次品''
                   )
       ,KCLYQty=(select sum(KCQty) from CK_BanCP_CR CR inner join CK_BanCP_KC KC on CR.CRID=KC.CRID
                 where CR.MainId=A.MainId and KC.KCQty>0 and CRType=''检验入库'' and CPType=''留样''
                   )
    
from JYOrder_Main A where 1=1'
   if RTrim(@begdate)<>''
   begin
     Set @MSQL=@MSQL+' and A.OrdDate>='''+RTrim(@begdate)+''' and A.OrdDate<'''+RTrim(@enddate)+''''
   end
   if RTrim(@Filler)<>''
   begin
     Set @MSQL=@MSQL+' and A.Filler='''+RTrim(@Filler)+''''
   end
   if RTrim(@WSql)<>''
   begin
     Set @MSQL=@MSQL+@WSql
   end
  exec(@MSQL)
GO
/****** Object:  StoredProcedure [dbo].[P_YFFK_HZCX]    Script Date: 12/17/2021 15:51:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_YFFK_HZCX ' and OrderNo=''CP20180084-1'''
CREATE Procedure [dbo].[P_YFFK_HZCX] 
  @ZDY varchar(1000)
AS  
DECLARE @Tmsql VARCHAR(8000)
Set @Tmsql= 'select AA.*
            ,YGMoney=isnull(YSZMoney,0)-isnull(PBMoney,0)-isnull(JGMoney,0)-isnull(ZFMoney,0)-isnull(TSMoney,0)-isnull(FLMoney,0)-isnull(JFJGMoney,0)
            ,MLMoney=isnull(SKMoney,0)-isnull(PBMoney,0)-isnull(JGMoney,0)-isnull(ZFMoney,0)-isnull(TSMoney,0)-isnull(FLMoney,0)-isnull(JFJGMoney,0)
              from (select F.ConNo,F.SYRName,F.CustomerNo,F.CustomerNoName,P.MPRTCodeName,P.YWY,P.Mainid,F.OrdDate,P.OrderNo
            ,P.GanKou,F.ConPerson1,F.WCStatus,P.CJJGBiLV
			,PBMoney=isnull((select SUM(C.Qty*D.Price) from CK_SXPB_CR C inner join YF_Money_CR D on C.FZSPID=D.YFTypeId where C.CKName=''坯布'' and C.CRFlag=''出库'' and C.ORDMainIdCK=P.Mainid),0)
			         +isnull((select SUM(D.Qty*D.Price) from CK_SXPB_CR C inner join YF_Money_CR D on C.SPID=D.YFTypeId where C.CRType=''采购退货'' and C.CRFlag=''出库'' and C.ORDMainIdCK=P.Mainid),0)
			,JGMoney=(select SUM(C.Qty*D.Price) from CK_SXPB_CR C inner join YF_Money_CR D on C.FZSPID=D.YFTypeId where C.CKName in (''外加工'',''待检布'',''成品'') and D.CRType=''应付款登记'' and C.CRFlag=''出库'' and C.ORDMainIdCK=P.Mainid)
			,FLMoney=(select SUM(C.Qty*D.Price) from CK_SXPB_CR C inner join YF_Money_CR D on C.FZSPID=D.YFTypeId where C.CKName=''辅料'' and C.CRFlag=''出库'' and C.ORDMainIdCK=P.Mainid)
			,FHQty=(select SUM(C.Qty) from CK_SXPB_CR C where C.CKName=''成品'' and C.CRFlag=''出库'' and C.ORDMainIdCK=P.Mainid)
			,QtyUnit=(select Top 1 C.QtyUnit from CK_SXPB_CR C where C.CKName=''成品'' and C.CRFlag=''出库'' and C.ORDMainIdCK=P.Mainid)
			,ZFMoney=(select SUM(C.Money) from YF_Money_CR C  where C.Mainid=P.Mainid and C.CRType in (''应付款登记'',''付款杂费'') and isnull(C.FYType,'''')<>''加工费''
                      and isnull(C.FYType,'''')<>''坯布费'' and isnull(C.YFName,'''')<>''辅料费'' and C.status<>''0'' and isnull(C.YFName,'''')<>''退税''
                      and isnull(C.YFName,'''')<>''裁剪人工费'' and isnull(C.YFName,'''')<>''车工人工费'' and isnull(C.YFName,'''')<>''包装人工费'')
			,JFJGMoney=(select SUM(C.Money) from YF_Money_CR C where C.CRType=''付款杂费'' and C.Mainid=P.Mainid and C.YFName in (''裁剪人工费'',''车工人工费'',''包装人工费'') and isnull(C.YFName,'''')<>''退税'')*P.CJJGBiLV
			,TSMoney=(select SUM(C.Money) from YF_Money_CR C where C.CRType=''付款杂费'' and C.Mainid=P.Mainid and isnull(C.YFName,'''')=''退税'')
			,YSZMoney=(select isnull(sum(X.Money*X.Huilv),0) from YF_Money_CR X where X.Mainid=P.Mainid and X.CRType=''应收款登记'' and isnull(status,'''')<>''0'')
            ,SKMoney=(select isnull(sum(X.HxNum*X.Huilv),0) from YF_Money_CR X where X.Mainid=P.Mainid and X.CRType=''应收款登记'' and isnull(status,'''')<>''0'')
			 from JYOrder_Main P 
			 inner join JYOrderCon_Main F on F.ConNO=P.ConNO
			 where 1=1
			 group by F.ConNo,F.SYRName,F.CustomerNo,F.CustomerNoName,P.MPRTCodeName,P.YWY,P.Mainid,F.OrdDate,P.OrderNo
            ,P.GanKou,F.ConPerson1,F.WCStatus,P.CJJGBiLV) AA where 1=1'
    Set @Tmsql=@Tmsql+@ZDY
exec(@Tmsql)
GO
/****** Object:  StoredProcedure [dbo].[P_Viwe_JYInfo]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from WFB_MJJY_CD_PB
CREATE Procedure [dbo].[P_Viwe_JYInfo]
  @begdate varchar(40),
  @enddate varchar(40),
  @PState  int , --1 检验日期 2 安排日期
  @WSql varchar(1000)
AS
  DECLARE @MainSql varchar(5000)
  BEGIN
    Set @MainSql='
    select CC.ConNo,C_Color,MFQty,KZQty,CC.OrderNo,
           C_CodeName,AP.CarNo,AP.SCPerson,AP.ZhuanQty,
           C.*,CDQty=(select sum(CDQty) from WFB_MJJY_CD_PB CP where CP.MJID=C.MJID),
           CDGSHZ=(select sum(CDGS) from WFB_MJJY_CD_PB CP where CP.MJID=C.MJID),
           CDQK10=dbo.F_Get_Order_SubStr_PB(C.MJID,''MJCDHZFM''),Ap.APDate   
    from WFB_MJJY_PB C 
    inner join JYCon_Sub_AnPai AP on C.APID=AP.APID
    inner join Cloth_Sub BB on C.SubId=BB.SubId
    inner join Cloth_Main CC on C.MainId=CC.MainId where 1=1'
    if RTrim(@begdate)<>''
    begin
      if @PState=1 
      begin
        set @MainSql=@MainSql+' and C.FillTime>='''+@begdate+''' and C.FillTime<='''+@enddate+''''
      end else
      if @PState=2 
      begin
        set @MainSql=@MainSql+' and AP.APDate>='''+@begdate+''' and AP.APDate<'''+@enddate+''''
      end
    end
    exec(@MainSql+@WSql)
   
  END

--select * from WFB_MJJY_PB
GO
/****** Object:  StoredProcedure [dbo].[P_OrderNo_YSK_View]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from YF_Money_CR where CRType='应收款登记'
CREATE Procedure [dbo].[P_OrderNo_YSK_View]
  @Begdate varchar(20),
  @Enddate varchar(20),
  @WSql  varchar(200)
AS
DECLARE @MSql varchar(6000)
Set @MSql='
select A.MainId,A.OrderNo,A.MPRTCodeName,
       CRTime=(select Top 1 CRTime from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''应收款登记'' ),
       Qty=(select isnull(sum(Qty),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''应收款登记'') ,
       Price=(select Top 1 Price from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''应收款登记'') ,
       --HuiLv=(select Top 1 HuiLv from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''应收款登记'') ,
       BZType=(select Top 1 BZType from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRFlag=''应收收'') ,
       QtyUnit=(select Top 1 QtyUnit from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''应收款登记''),
       YSYBMoney=(select isnull(sum(Money),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''应收款登记'' and isnull(YC.BZType,'''')=''USD'') ,
       KPMoney=(select isnull(sum(KPMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''应收款发票登记'') ,
       YSBBMoney=(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''应收款登记'' and isnull(YC.BZType,'''')<>''USD'') ,
       SKYBMoney=(select isnull(sum(Money),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''收款登记'' 
                  and isnull(YFName,'''')<>''退税'' and isnull(YC.BZType,'''')=''USD'') ,
       HuiLv=(select sum(Money*HuiLv)*1.00/sum(Money) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''收款登记'' 
                  and isnull(YFName,'''')<>''退税'' and isnull(YC.BZType,'''')=''USD'') ,
       SKBBMoney=(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''收款登记'' 
                  and isnull(YFName,'''')<>''退税'' and isnull(YC.BZType,'''')<>''USD'') ,
       YSYBYMoney=(select isnull(sum(Money),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''应收款登记'' and isnull(YC.BZType,'''')=''USD'')
                  -(select isnull(sum(Money),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''收款登记'' 
                    and isnull(YFName,'''')<>''退税'' and isnull(YC.BZType,'''')=''USD''),
       YSBBYMoney=(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''应收款登记'' and isnull(YC.BZType,'''')<>''USD'')
                  -(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''收款登记'' 
                    and isnull(YFName,'''')<>''退税'' and isnull(YC.BZType,'''')<>''USD''),
       SKTSBBMoney=(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType=''收款登记'' and isnull(YFName,'''')=''退税'') ,
       FKFS=(select Top 1 PayMent from JYOrderCon_Main C where C.ConNo=A.OrderNo) ,
       A.Filler ,
       A.OrdDefNote3,
       A.OrdDefNote4
from JYOrder_Main A
where exists(select * from YF_Money_CR B where B.MainId=A.MainId and B.CRFlag=''应收收'' 
             and B.CRTime>='''+@begdate+''' and B.CRTime<'''+@enddate+''')
     '
Set @MSql=@MSql+@WSql
exec(@MSql)

--select * from YF_Money_CR where CRFlag='应收收'
GO
/****** Object:  Table [dbo].[KH_Zdy_Attachment_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[KH_Zdy_Attachment_Sub](
	[ATSID] [varchar](50) NOT NULL,
	[KHLXR] [varchar](60) NULL,
	[LXTel] [varchar](50) NULL,
	[LXNote] [varchar](200) NULL,
	[filler] [varchar](50) NULL,
	[filltime] [datetime] NOT NULL,
	[ATID] [varchar](50) NULL,
	[LXZWu] [varchar](50) NULL,
	[LXPhone] [varchar](50) NULL,
	[LXFax] [varchar](50) NULL,
	[LXEmail] [varchar](200) NULL,
	[WA] [varchar](200) NULL,
	[IFZLX] [varchar](5) NULL,
	[WeiXin] [varchar](60) NULL,
	[QQ] [varchar](60) NULL,
	[DD] [varchar](50) NULL,
	[MXQQ] [varchar](60) NULL,
	[MXWeiXin] [varchar](60) NULL,
	[WangWang] [varchar](60) NULL,
PRIMARY KEY CLUSTERED 
(
	[ATSID] 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
/****** Object:  Table [dbo].[KH_Zdy_Attachment]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[KH_Zdy_Attachment](
	[ATID] [char](20) NOT NULL,
	[ZdyName] [varchar](300) NULL,
	[ZdyNameZ] [varchar](300) NULL,
	[ZdyCode] [varchar](50) NULL,
	[DEFstr1] [varchar](100) NULL,
	[DEFstr2] [varchar](100) NULL,
	[DEFstr3] [varchar](400) NULL,
	[DEFstr4] [varchar](200) NULL,
	[DEFstr5] [varchar](100) NULL,
	[DEFstr6] [varchar](600) NULL,
	[DEFstr7] [varchar](100) NULL,
	[DEFstr8] [varchar](100) NULL,
	[DEFstr9] [varchar](100) NULL,
	[DEFstr10] [varchar](100) NULL,
	[DEFNote1] [varchar](2000) NULL,
	[DEFNote2] [varchar](500) NULL,
	[DEFNote3] [varchar](300) NULL,
	[DEFNote4] [varchar](300) NULL,
	[DEFNote5] [varchar](300) NULL,
	[DEFNote6] [varchar](200) NULL,
	[DEFNote7] [varchar](200) NULL,
	[DEFNote8] [varchar](200) NULL,
	[DEFNote9] [varchar](200) NULL,
	[DEFNote10] [varchar](200) NULL,
	[Note] [varchar](200) NULL,
	[Type] [varchar](20) NULL,
	[MainType] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valid] [varchar](5) NULL,
	[DefStr11] [varchar](100) NULL,
	[DefStr12] [varchar](100) NULL,
	[DefStr13] [varchar](100) NULL,
	[DefStr14] [varchar](100) NULL,
	[DefStr15] [varchar](100) NULL,
	[KHType] [varchar](20) NULL,
	[Mrate] [decimal](18, 2) NOT NULL,
	[DefFlt1] [decimal](18, 2) NOT NULL,
	[DefFlt2] [decimal](18, 2) NOT NULL,
	[DefFlt3] [decimal](18, 2) NOT NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD [ZDYNameTj] [varchar](200) NULL
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD [KeFu] [varchar](20) NULL
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD [OrderNo] [varchar](20) NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD [ZdyNameYW] [varchar](50) NULL
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD [QQ] [varchar](50) NULL
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD [WeiXin] [varchar](50) NULL
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD [Wangwang] [varchar](50) NULL
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD [Email] [varchar](50) NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD [DPZH] [varchar](50) NULL
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD  CONSTRAINT [PK_KH_Zdy_Attachment] PRIMARY KEY CLUSTERED 
(
	[ATID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[KH_DaYang_MX]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[KH_DaYang_MX](
	[DYId] [char](20) NOT NULL,
	[DMId] [char](20) NOT NULL,
	[XHNo] [char](20) NULL,
	[PRTColor] [varchar](20) NULL,
	[PRTColorNO] [varchar](20) NULL,
	[Note] [varchar](200) NULL,
	[XHInt] [int] NULL,
	[YJNote] [varchar](100) NULL,
 CONSTRAINT [PK_KH_DaYang_MX] PRIMARY KEY CLUSTERED 
(
	[DMId] 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
/****** Object:  Table [dbo].[KH_DaYang]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[KH_DaYang](
	[DYId] [char](20) NOT NULL,
	[DYNo] [varchar](20) NULL,
	[DYDate] [datetime] NULL,
	[FactoryNo] [char](60) NULL,
	[FactoryName] [char](60) NULL,
	[StyleNo] [varchar](20) NULL,
	[KHNo] [char](60) NULL,
	[KHName] [char](60) NULL,
	[CPCode] [char](60) NULL,
	[CPName] [char](60) NULL,
	[DuiSeGuangYuan] [varchar](200) NULL,
	[ChiCunNote] [varchar](200) NULL,
	[ColorHZ] [varchar](50) NULL,
	[HXHZ] [varchar](50) NULL,
	[DYPerson] [varchar](20) NULL,
	[Note] [varchar](200) NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[FillerCode] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NOT NULL,
	[KHNameJC] [varchar](20) NULL,
	[YWY] [varchar](20) NULL,
	[HYDate] [datetime] NULL,
	[GDPerson] [varchar](20) NULL,
 CONSTRAINT [PK_KH_DaYang] PRIMARY KEY CLUSTERED 
(
	[DYId] 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
/****** Object:  Table [dbo].[JYOrderYSK]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderYSK](
	[YSID] [varchar](60) NOT NULL,
	[filler] [varchar](50) NULL,
	[filltime] [datetime] NULL,
	[SKDate] [datetime] NULL,
	[RLDate] [datetime] NULL,
	[FeeName] [varchar](60) NULL,
	[Mainid] [varchar](60) NULL,
	[SKMoney] [decimal](18, 2) NULL,
	[RLMoney] [decimal](18, 2) NULL,
	[YFNote] [varchar](500) NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[JYOrderYSK] ADD [BZType] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderYSK] ADD [YFID] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderYSK] ADD PRIMARY KEY CLUSTERED 
(
	[YSID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[JYOrderWT_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderWT_Sub](
	[Subid] [varchar](20) NOT NULL,
	[Mainid] [varchar](20) NULL,
	[BJNO] [varchar](20) NULL,
	[BGType] [varchar](20) NULL,
	[PRTspec] [varchar](30) NULL,
	[GoodsNo] [varchar](30) NULL,
	[Money] [decimal](18, 2) NOT NULL,
	[SordQty1] [decimal](18, 2) NOT NULL,
	[SordQty2] [decimal](18, 2) NOT NULL,
	[SordQty3] [decimal](18, 2) NOT NULL,
	[SordQty4] [decimal](18, 2) NOT NULL,
	[XHNO] [varchar](30) NULL,
	[PRTCode] [varchar](30) NULL,
	[PRTCodeName] [varchar](30) NULL,
	[PRTColor] [varchar](30) NULL,
	[PriceUnit] [varchar](30) NULL,
	[OrderUnit] [varchar](30) NULL,
	[SOrdDefNote1] [varchar](1000) NULL,
	[SOrdDefNote2] [varchar](100) NULL,
	[SOrdDefNote3] [varchar](100) NULL,
	[PrtPrice] [decimal](18, 2) NOT NULL,
	[SOrdDefNote4] [varchar](100) NULL,
PRIMARY KEY CLUSTERED 
(
	[Subid] 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
/****** Object:  Table [dbo].[JYOrderWT_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderWT_Main](
	[Mainid] [varchar](30) NOT NULL,
	[Subid] [varchar](30) NULL,
	[WTNo] [varchar](40) NULL,
	[OrderNo] [varchar](40) NULL,
	[CustomerNoName] [varchar](50) NULL,
	[orddefstr1] [varchar](50) NULL,
	[conDefstr1] [varchar](200) NULL,
	[ConPerson1] [varchar](50) NULL,
	[ConPerson2] [varchar](50) NULL,
	[conNo] [varchar](30) NULL,
	[KHConNo] [varchar](30) NULL,
	[XYNO] [varchar](30) NULL,
	[TDNum] [int] NULL,
	[original] [int] NULL,
	[Attached] [int] NULL,
	[Payaddress] [varchar](200) NULL,
	[Export] [varchar](100) NULL,
	[POD] [varchar](100) NULL,
	[shiptime] [datetime] NULL,
	[Validtime] [datetime] NULL,
	[BLNo] [varchar](30) NULL,
	[vessel] [varchar](30) NULL,
	[voy] [varchar](30) NULL,
	[ifFP] [varchar](2) NULL,
	[ifZY] [varchar](2) NULL,
	[goodsdate] [datetime] NULL,
	[DLYDate] [datetime] NULL,
	[DLYaddress] [varchar](1000) NULL,
	[MPRTBZNote] [varchar](1000) NULL,
	[Chker] [varchar](20) NULL,
	[Status] [varchar](20) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[SordQty1] [varchar](100) NULL,
	[SordQty2] [varchar](100) NULL,
	[SordQty3] [varchar](100) NULL,
	[SordQty4] [varchar](100) NULL,
PRIMARY KEY CLUSTERED 
(
	[Mainid] 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
/****** Object:  Table [dbo].[JYOrderML_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderML_Main](
	[MainId] [char](20) NOT NULL,
	[XHNo] [int] NULL,
	[PRTCode] [varchar](40) NULL,
	[PRTCodeName] [varchar](50) NULL,
	[CostomerNoName] [varchar](70) NULL,
	[PRTSpec] [varchar](100) NULL,
	[PRTType] [varchar](40) NULL,
	[PRTColor] [varchar](20) NULL,
	[PRTMF] [varchar](20) NULL,
	[PRTKZ] [varchar](20) NULL,
	[PRTOrderQty] [decimal](18, 2) NOT NULL,
	[OrderUnit] [varchar](20) NULL,
	[PRTPrice] [decimal](18, 4) NULL,
	[Qty] [decimal](18, 2) NULL,
	[XHMoney] [decimal](18, 2) NULL,
	[PriceUnit] [varchar](20) NULL,
	[PRTHX] [varchar](20) NULL,
	[StyleNo] [varchar](100) NULL,
	[filltime] [datetime] NULL,
	[filler] [varchar](60) NULL,
	[XHNote] [varchar](400) NULL,
PRIMARY KEY CLUSTERED 
(
	[MainId] 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
/****** Object:  Table [dbo].[JYOrderFy_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderFy_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[XHNo] [char](20) NULL,
	[OrderNo] [char](20) NULL,
	[PRTCode] [varchar](40) NULL,
	[PRTCodeName] [varchar](50) NULL,
	[PRTSpec] [varchar](40) NULL,
	[PRTType] [varchar](40) NULL,
	[PRTColor] [varchar](20) NULL,
	[PRTMF] [varchar](20) NULL,
	[PRTKZ] [varchar](20) NULL,
	[PRTOrderQty] [decimal](18, 2) NOT NULL,
	[PRTClothQty] [decimal](18, 2) NOT NULL,
	[OrderUnit] [varchar](20) NULL,
	[PRTPrice] [decimal](10, 4) NOT NULL,
	[PriceUnit] [varchar](20) NULL,
	[SOrdQty1] [decimal](18, 2) NOT NULL,
	[SOrdQty2] [decimal](18, 2) NOT NULL,
	[SOrdQty3] [decimal](18, 2) NOT NULL,
	[SOrdQty4] [decimal](18, 2) NOT NULL,
	[SOrdQty5] [decimal](18, 2) NOT NULL,
	[SOrdQty6] [decimal](18, 2) NOT NULL,
	[SOrdQty7] [decimal](18, 2) NOT NULL,
	[SOrdQty8] [decimal](18, 2) NOT NULL,
	[SOrdQty9] [decimal](18, 2) NOT NULL,
	[SOrdQty10] [decimal](18, 2) NOT NULL,
	[SOrddefstr1] [varchar](50) NULL,
	[SOrddefstr2] [varchar](50) NULL,
	[SOrddefstr3] [varchar](50) NULL,
	[SOrddefstr4] [varchar](100) NULL,
	[SOrddefstr5] [varchar](50) NULL,
	[SOrddefstr6] [varchar](50) NULL,
	[SOrddefstr7] [varchar](20) NULL,
	[SOrddefstr8] [varchar](20) NULL,
	[SOrddefstr9] [varchar](20) NULL,
	[SOrddefstr10] [varchar](20) NULL,
	[SOrdDefNote1] [varchar](1000) NULL,
	[SOrdDefNote2] [varchar](40) NULL,
	[SOrdDefNote3] [varchar](40) NULL,
	[SOrdDefNote4] [varchar](40) NULL,
	[SOrdDefNote5] [varchar](40) NULL,
	[SOrdDefNote6] [varchar](40) NULL,
	[SOrdDefNote7] [varchar](40) NULL,
	[SOrdDefNote8] [varchar](40) NULL,
	[SOrdDefNote9] [varchar](40) NULL,
	[SOrdDefNote10] [varchar](40) NULL,
	[SOrdDefNote11] [varchar](40) NULL,
	[SOrdDefNote12] [varchar](40) NULL,
	[SOrdDefNote13] [varchar](40) NULL,
	[SOrdDefNote14] [varchar](40) NULL,
	[SOrdDefNote15] [varchar](40) NULL,
	[SOrdDefNote16] [varchar](40) NULL,
	[SOrdDefNote17] [varchar](40) NULL,
	[SOrdDefNote18] [varchar](40) NULL,
	[SOrdDefNote19] [varchar](40) NULL,
	[SOrdDefNote20] [varchar](40) NULL,
	[SOrdFlag1] [bit] NOT NULL,
	[SOrdFlag2] [bit] NOT NULL,
	[SOrdFlag3] [bit] NOT NULL,
	[SOrdFlag4] [bit] NOT NULL,
	[SOrdFlag5] [bit] NOT NULL,
	[SOrdFlag6] [bit] NOT NULL,
	[SOrdFlag7] [bit] NOT NULL,
	[SOrdFlag8] [bit] NOT NULL,
	[SOrdFlag9] [bit] NOT NULL,
	[SOrdFlag10] [bit] NOT NULL,
	[SOrdFlag11] [bit] NOT NULL,
	[SOrdFlag12] [bit] NOT NULL,
	[SOrdFlag13] [bit] NOT NULL,
	[SOrdFlag14] [bit] NOT NULL,
	[SOrdFlag15] [bit] NOT NULL,
	[SOrdFlag16] [bit] NOT NULL,
	[SOrdFlag17] [bit] NOT NULL,
	[SOrdFlag18] [bit] NOT NULL,
	[SOrdFlag19] [bit] NOT NULL,
	[SOrdFlag20] [bit] NOT NULL,
	[SubStatus] [varchar](20) NULL,
	[SubValid] [char](1) NOT NULL,
	[SLbName] [varchar](20) NULL,
	[SLbInt] [int] NULL,
	[PRTHX] [varchar](20) NULL,
	[KgQty] [decimal](18, 2) NOT NULL,
	[KgPrice] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_JYOrderFy_Sub] PRIMARY KEY CLUSTERED 
(
	[SubId] 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
/****** Object:  Table [dbo].[JYOrderFy_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderFy_Main](
	[MainId] [char](20) NOT NULL,
	[OrderNo] [char](20) NOT NULL,
	[JGFactory] [varchar](20) NULL,
	[JGFactoryName] [varchar](40) NULL,
	[ConNo] [char](20) NULL,
	[CustomerNo] [char](20) NULL,
	[CustomerNoName] [varchar](40) NULL,
	[DlyDate] [datetime] NULL,
	[DlyPlace] [varchar](100) NULL,
	[OrdDate] [datetime] NULL,
	[OrdUpDate] [datetime] NULL,
	[MPRTCode] [varchar](40) NULL,
	[MPRTCodeName] [varchar](50) NULL,
	[MPRTSpec] [varchar](100) NULL,
	[MPRTCF] [varchar](40) NULL,
	[MPRTMF] [varchar](40) NULL,
	[MPRTKZ] [varchar](40) NULL,
	[MPRTSL] [varchar](40) NULL,
	[OrdDefDate1] [datetime] NULL,
	[OrdDefDate2] [datetime] NULL,
	[OrdDefDate3] [datetime] NULL,
	[OrdDefDate4] [datetime] NULL,
	[OrdDefDate5] [datetime] NULL,
	[Note] [varchar](1000) NULL,
	[OrdDefStr1] [varchar](40) NULL,
	[OrdDefStr2] [varchar](40) NULL,
	[OrdDefStr3] [varchar](40) NULL,
	[OrdDefStr4] [varchar](40) NULL,
	[OrdDefStr5] [varchar](40) NULL,
	[OrdDefStr6] [varchar](40) NULL,
	[OrdDefStr7] [varchar](40) NULL,
	[OrdDefStr8] [varchar](40) NULL,
	[OrdDefStr9] [varchar](40) NULL,
	[OrdDefStr10] [varchar](40) NULL,
	[OrdDefStr11] [varchar](40) NULL,
	[OrdDefStr12] [varchar](40) NULL,
	[OrdDefStr13] [varchar](40) NULL,
	[OrdDefStr14] [varchar](40) NULL,
	[OrdDefStr15] [varchar](40) NULL,
	[OrdDefNote1] [varchar](5000) NULL,
	[OrdDefNote2] [varchar](40) NULL,
	[OrdDefNote3] [varchar](40) NULL,
	[OrdDefNote4] [varchar](40) NULL,
	[OrdDefNote5] [varchar](40) NULL,
	[OrdDefNote6] [varchar](40) NULL,
	[OrdDefNote7] [varchar](40) NULL,
	[OrdDefNote8] [varchar](40) NULL,
	[OrdDefNote9] [varchar](40) NULL,
	[OrdDefNote10] [varchar](40) NULL,
	[OrdDefNote11] [varchar](40) NULL,
	[OrdDefNote12] [varchar](40) NULL,
	[OrdDefNote13] [varchar](40) NULL,
	[OrdDefNote14] [varchar](40) NULL,
	[OrdDefNote15] [varchar](40) NULL,
	[OrdPerson1] [varchar](20) NULL,
	[OrdPerson2] [varchar](20) NULL,
	[OrdPerson3] [varchar](20) NULL,
	[OrdPerson4] [varchar](20) NULL,
	[OrdPerson5] [varchar](20) NULL,
	[OrdPerson6] [varchar](20) NULL,
	[OrdPerson7] [varchar](20) NULL,
	[OrdPerson8] [varchar](20) NULL,
	[OrdPerson9] [varchar](20) NULL,
	[OrdPerson10] [varchar](20) NULL,
	[OrdFlag1] [bit] NOT NULL,
	[OrdFlag2] [bit] NOT NULL,
	[OrdFlag3] [bit] NOT NULL,
	[OrdFlag4] [bit] NOT NULL,
	[OrdFlag5] [bit] NOT NULL,
	[OrdFlag6] [bit] NOT NULL,
	[OrdFlag7] [bit] NOT NULL,
	[OrdFlag8] [bit] NOT NULL,
	[OrdFlag9] [bit] NOT NULL,
	[OrdFlag10] [bit] NOT NULL,
	[OrdFlag11] [bit] NOT NULL,
	[OrdFlag12] [bit] NOT NULL,
	[OrdFlag13] [bit] NOT NULL,
	[OrdFlag14] [bit] NOT NULL,
	[OrdFlag15] [bit] NOT NULL,
	[OrdFlag16] [bit] NOT NULL,
	[OrdFlag17] [bit] NOT NULL,
	[OrdFlag18] [bit] NOT NULL,
	[OrdFlag19] [bit] NOT NULL,
	[OrdFlag20] [bit] NOT NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NULL,
	[LbName] [varchar](20) NULL,
	[LbInt] [int] NULL,
	[YSYBMoneyFZ] [decimal](18, 2) NOT NULL,
	[YSYBFlag] [bit] NOT NULL,
	[YCLFactory] [varchar](50) NULL,
	[PBFactory] [varchar](50) NULL,
	[RanFactory] [varchar](50) NULL,
	[HZLFactory] [varchar](50) NULL,
	[MPRTColorLaoDu] [varchar](50) NULL,
	[MPRTNiuDu] [varchar](50) NULL,
	[MPRTPH] [varchar](50) NULL,
	[MPRTZHName] [varchar](50) NULL,
	[MPRTBZNote] [varchar](1000) NULL,
	[MPRTKaiJian] [varchar](50) NULL,
	[MPRTChuanY] [varchar](50) NULL,
	[MPRTYaoFeng] [varchar](50) NULL,
	[MPRTJiBenNote] [varchar](100) NULL,
	[MPRTTeBieNote] [varchar](100) NULL,
	[MPRTQtyNote] [varchar](50) NULL,
	[MPRTColorLaoDu1] [varchar](40) NULL,
	[MPRTColorLaoDu2] [varchar](40) NULL,
	[MPRTColorLaoDu3] [varchar](40) NULL,
	[MPRTColorLaoDu4] [varchar](40) NULL,
	[MPRTDuiSeGY] [varchar](40) NULL,
	[MPRTKQiQiu] [varchar](40) NULL,
	[MPRTDingPoLv] [varchar](40) NULL,
	[MPRTZuRanXing] [varchar](40) NULL,
	[MPRTKuanNO] [varchar](40) NULL,
	[LBNameNote] [varchar](200) NULL,
	[MaiTouNote] [varchar](200) NULL,
	[MPRTTangJin] [varchar](40) NULL,
	[MPRTSCTeBieNote] [varchar](1000) NULL,
	[PiZhong] [decimal](18, 2) NOT NULL,
	[SYRName] [varchar](60) NULL,
	[CPCFBi] [varchar](60) NULL,
	[EditCnt] [int] NOT NULL,
	[OrdQty1] [decimal](18, 2) NOT NULL,
	[OrdQty2] [decimal](18, 2) NOT NULL,
	[OrdQty3] [decimal](18, 2) NOT NULL,
	[OrdQty4] [decimal](18, 2) NOT NULL,
	[OrdQty5] [decimal](18, 2) NOT NULL,
	[OrdQty6] [decimal](18, 2) NOT NULL,
	[OrdQty7] [decimal](18, 2) NOT NULL,
	[OrdQty8] [decimal](18, 2) NOT NULL,
	[OrdQty9] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_JYOrderFy_Main] PRIMARY KEY CLUSTERED 
(
	[MainId] 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
/****** Object:  Table [dbo].[JYOrderFPPI_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderFPPI_Sub](
	[PISID] [varchar](50) NOT NULL,
	[FPNo] [varchar](60) NULL,
	[khConNo] [varchar](60) NULL,
	[StyleNo] [varchar](60) NULL,
	[YFName] [varchar](60) NULL,
	[Qty] [decimal](18, 2) NULL,
	[QtyUnit] [varchar](60) NULL,
	[Price] [decimal](18, 2) NULL,
	[BZType] [varchar](60) NULL,
	[KPMoney] [decimal](18, 2) NULL,
	[P_CodeName] [varchar](200) NULL,
	[P_Spec] [varchar](60) NULL,
	[PRTColor] [varchar](60) NULL,
	[PRTMF] [varchar](60) NULL,
	[PRTKZ] [varchar](60) NULL,
	[Note] [varchar](600) NULL,
	[FPID] [varchar](60) NULL,
	[YFID] [varchar](60) NULL,
	[MQty] [decimal](18, 2) NULL,
	[JQty] [decimal](18, 2) NULL,
	[HYPrice] [decimal](18, 2) NULL,
	[FPPrice] [decimal](18, 2) NULL,
	[SPName] [varchar](50) NULL,
	[HYMoney] [decimal](18, 2) NULL,
PRIMARY KEY CLUSTERED 
(
	[PISID] 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
/****** Object:  Table [dbo].[JYOrderFPPI_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderFPPI_Main](
	[FPID] [varchar](50) NOT NULL,
	[FPType] [varchar](50) NULL,
	[filler] [varchar](50) NULL,
	[filltime] [datetime] NULL,
	[ComTaiTou] [varchar](60) NULL,
	[KHName] [varchar](60) NULL,
	[GSAddress] [varchar](500) NULL,
	[GSTel] [varchar](60) NULL,
	[GSFax] [varchar](60) NULL,
	[BankNo] [varchar](60) NULL,
	[BankName] [varchar](60) NULL,
	[BankAddress] [varchar](500) NULL,
	[BankDaiMa] [varchar](60) NULL,
	[TelexNo] [varchar](60) NULL,
	[FJTiaoKuan] [varchar](1000) NULL,
	[HZConNO] [varchar](50) NULL,
	[TKNote] [varchar](60) NULL,
	[Chkstatus] [varchar](60) NULL,
	[ChkNote] [varchar](100) NULL,
PRIMARY KEY CLUSTERED 
(
	[FPID] 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
/****** Object:  Table [dbo].[JYOrderFPCI_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderFPCI_Sub](
	[CISID] [varchar](50) NOT NULL,
	[khConNo] [varchar](60) NULL,
	[StyleNo] [varchar](60) NULL,
	[YFName] [varchar](60) NULL,
	[Qty] [decimal](18, 2) NULL,
	[QtyUnit] [varchar](60) NULL,
	[Price] [decimal](18, 2) NULL,
	[BZType] [varchar](60) NULL,
	[KPMoney] [decimal](18, 2) NULL,
	[P_CodeName] [varchar](200) NULL,
	[P_Spec] [varchar](60) NULL,
	[PRTColor] [varchar](60) NULL,
	[PRTMF] [varchar](60) NULL,
	[PRTKZ] [varchar](60) NULL,
	[Note] [varchar](600) NULL,
	[FPID] [varchar](60) NULL,
	[YFID] [varchar](60) NULL,
	[MQty] [decimal](18, 2) NULL,
	[JQty] [decimal](18, 2) NULL,
	[HYPrice] [decimal](18, 2) NULL,
	[FPPrice] [decimal](18, 2) NULL,
	[SPName] [varchar](50) NULL,
	[HYMoney] [decimal](18, 2) NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [CIID] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [PS] [decimal](18, 0) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [MMQty] [decimal](18, 2) NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [HSCode] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [DJMoney] [decimal](18, 2) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [conSubid] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [ConYFID] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [ZhenZhiSJFee] [decimal](18, 2) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [YinHuaSJFee] [decimal](18, 2) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [BaoGangFee] [decimal](18, 2) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD [ZhiWangZhiBanFee] [decimal](18, 2) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Sub] ADD PRIMARY KEY CLUSTERED 
(
	[CISID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[JYOrderFPCI_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderFPCI_Main](
	[CIID] [varchar](50) NOT NULL,
	[FPType] [varchar](50) NULL,
	[filler] [varchar](50) NULL,
	[filltime] [datetime] NULL,
	[ComTaiTou] [varchar](60) NULL,
	[KHName] [varchar](60) NULL,
	[GSAddress] [varchar](500) NULL,
	[GSTel] [varchar](60) NULL,
	[GSFax] [varchar](60) NULL,
	[BankNo] [varchar](60) NULL,
	[BankName] [varchar](60) NULL,
	[BankAddress] [varchar](60) NULL,
	[BankDaiMa] [varchar](60) NULL,
	[TelexNo] [varchar](60) NULL,
	[FJTiaoKuan] [varchar](1000) NULL,
	[HZConNO] [varchar](200) NULL,
	[TKNote] [varchar](60) NULL,
	[Chkstatus] [varchar](60) NULL,
	[ChkNote] [varchar](100) NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [FPNo] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [FromPlace] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [ToPlace] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [LCNo] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [LCDate] [datetime] NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [KHAddress] [varchar](500) NULL
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [MaiTou] [varchar](500) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [DHMiao] [varchar](500) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [CINote] [varchar](500) NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [ZHMiao] [varchar](50) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [BGMoney] [decimal](18, 2) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [TSDate] [datetime] NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [DQTSMoney] [decimal](18, 2) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD [SJTSMoney] [decimal](18, 2) NULL
ALTER TABLE [dbo].[JYOrderFPCI_Main] ADD PRIMARY KEY CLUSTERED 
(
	[CIID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[JYOrderFHXX_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderFHXX_Main](
	[FHID] [varchar](50) NOT NULL,
	[FPNO] [varchar](50) NULL,
	[XYZNo] [varchar](50) NULL,
	[filler] [varchar](50) NULL,
	[filltime] [datetime] NULL,
	[KHName] [varchar](60) NULL,
	[CQDate] [datetime] NULL,
	[DGDate] [datetime] NULL,
	[JiaoDDate] [datetime] NULL,
	[JIDDate] [datetime] NULL,
	[FPMoney] [decimal](18, 2) NULL,
	[SCDDate] [datetime] NULL,
	[CDFKDate] [datetime] NULL,
	[GNKMoney] [decimal](18, 2) NULL,
	[GWKMoney] [decimal](18, 2) NULL,
	[SJSDate] [datetime] NULL,
	[SHDate] [datetime] NULL,
	[TDNote] [varchar](200) NULL,
	[TDJG] [varchar](100) NULL,
PRIMARY KEY CLUSTERED 
(
	[FHID] 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
/****** Object:  Table [dbo].[JYOrderFH_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderFH_Main](
	[MainId] [char](20) NOT NULL,
	[JGFactory] [varchar](20) NULL,
	[JGFactoryName] [varchar](40) NULL,
	[ConNo] [char](20) NULL,
	[CustomerNo] [char](20) NULL,
	[CustomerNoName] [varchar](40) NULL,
	[DlyDate] [datetime] NULL,
	[DlyPlace] [varchar](100) NULL,
	[OrdDate] [datetime] NULL,
	[OrdUpDate] [datetime] NULL,
	[MPRTCode] [varchar](40) NULL,
	[MPRTCodeName] [varchar](50) NULL,
	[MPRTSpec] [varchar](100) NULL,
	[MPRTCF] [varchar](40) NULL,
	[MPRTMF] [varchar](40) NULL,
	[MPRTKZ] [varchar](40) NULL,
	[MPRTSL] [varchar](40) NULL,
	[OrdDefDate1] [datetime] NULL,
	[OrdDefDate2] [datetime] NULL,
	[OrdDefDate3] [datetime] NULL,
	[OrdDefDate4] [datetime] NULL,
	[OrdDefDate5] [datetime] NULL,
	[Note] [varchar](1000) NULL,
	[OrdDefStr1] [varchar](40) NULL,
	[OrdDefStr2] [varchar](40) NULL,
	[OrdDefStr3] [varchar](40) NULL,
	[OrdDefStr4] [varchar](40) NULL,
	[OrdDefStr5] [varchar](40) NULL,
	[OrdDefStr6] [varchar](40) NULL,
	[OrdDefStr7] [varchar](40) NULL,
	[OrdDefStr8] [varchar](40) NULL,
	[OrdDefStr9] [varchar](40) NULL,
	[OrdDefStr10] [varchar](40) NULL,
	[OrdDefStr11] [varchar](40) NULL,
	[OrdDefStr12] [varchar](40) NULL,
	[OrdDefStr13] [varchar](40) NULL,
	[OrdDefStr14] [varchar](40) NULL,
	[OrdDefStr15] [varchar](40) NULL,
	[OrdDefNote1] [varchar](5000) NULL,
	[OrdDefNote2] [varchar](40) NULL,
	[OrdDefNote3] [varchar](40) NULL,
	[OrdDefNote4] [varchar](40) NULL,
	[OrdDefNote5] [varchar](40) NULL,
	[OrdDefNote6] [varchar](40) NULL,
	[OrdDefNote7] [varchar](40) NULL,
	[OrdDefNote8] [varchar](40) NULL,
	[OrdDefNote9] [varchar](40) NULL,
	[OrdDefNote10] [varchar](40) NULL,
	[OrdDefNote11] [varchar](40) NULL,
	[OrdDefNote12] [varchar](40) NULL,
	[OrdDefNote13] [varchar](40) NULL,
	[OrdDefNote14] [varchar](40) NULL,
	[OrdDefNote15] [varchar](40) NULL,
	[OrdPerson1] [varchar](20) NULL,
	[OrdPerson2] [varchar](20) NULL,
	[OrdPerson3] [varchar](20) NULL,
	[OrdPerson4] [varchar](20) NULL,
	[OrdPerson5] [varchar](20) NULL,
	[OrdPerson6] [varchar](20) NULL,
	[OrdPerson7] [varchar](20) NULL,
	[OrdPerson8] [varchar](20) NULL,
	[OrdPerson9] [varchar](20) NULL,
	[OrdPerson10] [varchar](20) NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[PBFactory] [varchar](50) NULL,
	[RanFactory] [varchar](50) NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [CustomerJC] [varchar](70) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [FHLXR] [varchar](70) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [YWY] [varchar](70) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [KHConNO] [varchar](70) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [styleno] [varchar](70) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [OrderUnit] [varchar](70) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [PRTOrderQty] [decimal](18, 2) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [FHPrice] [decimal](18, 2) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [BZType] [varchar](60) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [PrtCodeName] [varchar](60) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [PRTSpec] [varchar](60) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [PRTColor] [varchar](60) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD [PRTCode] [varchar](60) NULL
ALTER TABLE [dbo].[JYOrderFH_Main] ADD  CONSTRAINT [PK_JYOrderFH_Main] PRIMARY KEY CLUSTERED 
(
	[MainId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[JYOrderFb_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderFb_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[XHNo] [char](20) NULL,
	[OrderNo] [char](20) NULL,
	[PRTCode] [varchar](40) NULL,
	[PRTCodeName] [varchar](50) NULL,
	[PRTSpec] [varchar](40) NULL,
	[PRTType] [varchar](40) NULL,
	[PRTColor] [varchar](20) NULL,
	[PRTMF] [varchar](20) NULL,
	[PRTKZ] [varchar](20) NULL,
	[PRTOrderQty] [decimal](18, 2) NOT NULL,
	[PRTClothQty] [decimal](18, 2) NOT NULL,
	[OrderUnit] [varchar](20) NULL,
	[PRTPrice] [decimal](10, 4) NOT NULL,
	[PRTMoney] [decimal](10, 4) NOT NULL,
	[PriceUnit] [varchar](20) NULL,
	[SOrdQty1] [decimal](18, 2) NOT NULL,
	[SOrdQty2] [decimal](18, 2) NOT NULL,
	[SOrdQty3] [decimal](18, 2) NOT NULL,
	[SOrdQty4] [decimal](18, 2) NOT NULL,
	[SOrdQty5] [decimal](18, 2) NOT NULL,
	[SOrdQty6] [decimal](18, 2) NOT NULL,
	[SOrdQty7] [decimal](18, 2) NOT NULL,
	[SOrdQty8] [decimal](18, 2) NOT NULL,
	[SOrdQty9] [decimal](18, 2) NOT NULL,
	[SOrdQty10] [decimal](18, 2) NOT NULL,
	[SOrddefstr1] [varchar](50) NULL,
	[SOrddefstr2] [varchar](50) NULL,
	[SOrddefstr3] [varchar](50) NULL,
	[SOrddefstr4] [varchar](100) NULL,
	[SOrddefstr5] [varchar](50) NULL,
	[SOrddefstr6] [varchar](50) NULL,
	[SOrddefstr7] [varchar](20) NULL,
	[SOrddefstr8] [varchar](20) NULL,
	[SOrddefstr9] [varchar](20) NULL,
	[SOrddefstr10] [varchar](20) NULL,
	[SOrdDefNote1] [varchar](40) NULL,
	[SOrdDefNote2] [varchar](40) NULL,
	[SOrdDefNote3] [varchar](40) NULL,
	[SOrdDefNote4] [varchar](40) NULL,
	[SOrdDefNote5] [varchar](40) NULL,
	[SOrdDefNote6] [varchar](40) NULL,
	[SOrdDefNote7] [varchar](40) NULL,
	[SOrdDefNote8] [varchar](40) NULL,
	[SOrdDefNote9] [varchar](40) NULL,
	[SOrdDefNote10] [varchar](40) NULL,
	[SOrdDefNote11] [varchar](40) NULL,
	[SOrdDefNote12] [varchar](40) NULL,
	[SOrdDefNote13] [varchar](40) NULL,
	[SOrdDefNote14] [varchar](40) NULL,
	[SOrdDefNote15] [varchar](40) NULL,
	[SOrdDefNote16] [varchar](40) NULL,
	[SOrdDefNote17] [varchar](40) NULL,
	[SOrdDefNote18] [varchar](40) NULL,
	[SOrdDefNote19] [varchar](40) NULL,
	[SOrdDefNote20] [varchar](40) NULL,
	[SOrdFlag1] [bit] NOT NULL,
	[SOrdFlag2] [bit] NOT NULL,
	[SOrdFlag3] [bit] NOT NULL,
	[SOrdFlag4] [bit] NOT NULL,
	[SOrdFlag5] [bit] NOT NULL,
	[SubStatus] [varchar](20) NULL,
	[SubValid] [char](1) NOT NULL,
	[SLbName] [varchar](20) NULL,
	[SLbInt] [int] NULL,
	[PRTHX] [varchar](20) NULL,
	[KgQty] [decimal](18, 2) NOT NULL,
	[KgPrice] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_JYOrderFb_Sub] PRIMARY KEY CLUSTERED 
(
	[SubId] 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
/****** Object:  Table [dbo].[JYOrderFb_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderFb_Main](
	[MainId] [char](20) NOT NULL,
	[InvoiceNO] [char](20) NOT NULL,
	[CYNO] [char](20) NULL,
	[OrderNo] [char](20) NULL,
	[JGFactory] [varchar](20) NULL,
	[JGFactoryName] [varchar](40) NULL,
	[ConNo] [char](20) NULL,
	[KHConNo] [varchar](30) NULL,
	[CustomerNo] [char](20) NULL,
	[CustomerNoName] [varchar](40) NULL,
	[DlyDate] [datetime] NULL,
	[DlyPlace] [varchar](100) NULL,
	[OrdDate] [datetime] NULL,
	[OrdUpDate] [datetime] NULL,
	[MPRTCode] [varchar](40) NULL,
	[MPRTCodeName] [varchar](50) NULL,
	[MPRTSpec] [varchar](100) NULL,
	[MPRTCF] [varchar](40) NULL,
	[MPRTMF] [varchar](40) NULL,
	[MPRTKZ] [varchar](40) NULL,
	[MPRTSL] [varchar](40) NULL,
	[OrdDefDate1] [datetime] NULL,
	[OrdDefDate2] [datetime] NULL,
	[OrdDefDate3] [datetime] NULL,
	[OrdDefDate4] [datetime] NULL,
	[OrdDefDate5] [datetime] NULL,
	[Note] [varchar](500) NULL,
	[OrdDefStr1] [varchar](40) NULL,
	[OrdDefStr2] [varchar](40) NULL,
	[OrdDefStr3] [varchar](500) NULL,
	[OrdDefStr4] [varchar](40) NULL,
	[OrdDefStr5] [varchar](40) NULL,
	[OrdDefStr6] [varchar](40) NULL,
	[OrdDefStr7] [varchar](40) NULL,
	[OrdDefStr8] [varchar](40) NULL,
	[OrdDefStr9] [varchar](40) NULL,
	[OrdDefStr10] [varchar](40) NULL,
	[OrdDefStr11] [varchar](40) NULL,
	[OrdDefStr12] [varchar](40) NULL,
	[OrdDefStr13] [varchar](40) NULL,
	[OrdDefStr14] [varchar](40) NULL,
	[OrdDefStr15] [varchar](40) NULL,
	[OrdDefNote1] [varchar](5000) NULL,
	[OrdDefNote2] [varchar](40) NULL,
	[OrdDefNote3] [varchar](40) NULL,
	[OrdDefNote4] [varchar](40) NULL,
	[OrdDefNote5] [varchar](40) NULL,
	[OrdDefNote6] [varchar](40) NULL,
	[OrdDefNote7] [varchar](40) NULL,
	[OrdDefNote8] [varchar](40) NULL,
	[OrdDefNote9] [varchar](40) NULL,
	[OrdDefNote10] [varchar](40) NULL,
	[OrdDefNote11] [varchar](40) NULL,
	[OrdDefNote12] [varchar](40) NULL,
	[OrdDefNote13] [varchar](40) NULL,
	[OrdDefNote14] [varchar](40) NULL,
	[OrdDefNote15] [varchar](40) NULL,
	[OrdPerson1] [varchar](20) NULL,
	[OrdPerson2] [varchar](20) NULL,
	[OrdPerson3] [varchar](20) NULL,
	[OrdPerson4] [varchar](20) NULL,
	[OrdPerson5] [varchar](20) NULL,
	[OrdPerson6] [varchar](20) NULL,
	[OrdPerson7] [varchar](20) NULL,
	[OrdPerson8] [varchar](20) NULL,
	[OrdPerson9] [varchar](20) NULL,
	[OrdPerson10] [varchar](20) NULL,
	[OrdFlag1] [bit] NOT NULL,
	[OrdFlag2] [bit] NOT NULL,
	[OrdFlag3] [bit] NOT NULL,
	[OrdFlag4] [bit] NOT NULL,
	[OrdFlag5] [bit] NOT NULL,
	[OrdFlag6] [bit] NOT NULL,
	[OrdFlag7] [bit] NOT NULL,
	[OrdFlag8] [bit] NOT NULL,
	[OrdFlag9] [bit] NOT NULL,
	[OrdFlag10] [bit] NOT NULL,
	[OrdFlag11] [bit] NOT NULL,
	[OrdFlag12] [bit] NOT NULL,
	[OrdFlag13] [bit] NOT NULL,
	[OrdFlag14] [bit] NOT NULL,
	[OrdFlag15] [bit] NOT NULL,
	[OrdFlag16] [bit] NOT NULL,
	[OrdFlag17] [bit] NOT NULL,
	[OrdFlag18] [bit] NOT NULL,
	[OrdFlag19] [bit] NOT NULL,
	[OrdFlag20] [bit] NOT NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NULL,
	[LbName] [varchar](20) NULL,
	[LbInt] [int] NULL,
	[YSYBMoneyFZ] [decimal](18, 2) NOT NULL,
	[YSYBFlag] [bit] NOT NULL,
	[YCLFactory] [varchar](50) NULL,
	[PBFactory] [varchar](50) NULL,
	[RanFactory] [varchar](50) NULL,
	[HZLFactory] [varchar](50) NULL,
	[MPRTColorLaoDu] [varchar](50) NULL,
	[MPRTNiuDu] [varchar](50) NULL,
	[MPRTPH] [varchar](50) NULL,
	[MPRTZHName] [varchar](50) NULL,
	[MPRTBZNote] [varchar](1000) NULL,
	[MPRTKaiJian] [varchar](50) NULL,
	[MPRTChuanY] [varchar](50) NULL,
	[MPRTYaoFeng] [varchar](50) NULL,
	[MPRTJiBenNote] [varchar](100) NULL,
	[MPRTTeBieNote] [varchar](100) NULL,
	[MPRTQtyNote] [varchar](50) NULL,
	[MPRTColorLaoDu1] [varchar](40) NULL,
	[MPRTColorLaoDu2] [varchar](40) NULL,
	[MPRTColorLaoDu3] [varchar](40) NULL,
	[MPRTColorLaoDu4] [varchar](40) NULL,
	[MPRTDuiSeGY] [varchar](40) NULL,
	[MPRTKQiQiu] [varchar](40) NULL,
	[MPRTDingPoLv] [varchar](40) NULL,
	[MPRTZuRanXing] [varchar](40) NULL,
	[MPRTKuanNO] [varchar](40) NULL,
	[LBNameNote] [varchar](200) NULL,
	[MaiTouNote] [varchar](200) NULL,
	[MPRTTangJin] [varchar](40) NULL,
	[MPRTSCTeBieNote] [varchar](1000) NULL,
	[PiZhong] [decimal](18, 2) NOT NULL,
	[SYRName] [varchar](60) NULL,
	[CPCFBi] [varchar](60) NULL,
	[EditCnt] [int] NOT NULL,
	[ConPerson1] [varchar](20) NULL,
	[ConPerson2] [varchar](20) NULL,
	[ConPerson3] [varchar](20) NULL,
	[conDefstr1] [varchar](200) NULL,
	[conDefstr2] [varchar](200) NULL,
	[conDefstr3] [varchar](200) NULL,
 CONSTRAINT [PK_JYOrderFb_Main] PRIMARY KEY CLUSTERED 
(
	[MainId] 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
/****** Object:  Table [dbo].[JYOrderCy_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderCy_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[XHNo] [char](20) NULL,
	[OrderNo] [char](20) NULL,
	[PRTCode] [varchar](40) NULL,
	[PRTCodeName] [varchar](50) NULL,
	[PRTSpec] [varchar](40) NULL,
	[PRTType] [varchar](40) NULL,
	[PRTColor] [varchar](20) NULL,
	[PRTMF] [varchar](20) NULL,
	[PRTKZ] [varchar](20) NULL,
	[PRTOrderQty] [decimal](18, 2) NOT NULL,
	[PRTClothQty] [decimal](18, 2) NOT NULL,
	[OrderUnit] [varchar](20) NULL,
	[PRTPrice] [decimal](10, 4) NOT NULL,
	[PRTMoney] [decimal](10, 4) NOT NULL,
	[PriceUnit] [varchar](20) NULL,
	[SOrdQty1] [decimal](18, 2) NOT NULL,
	[SOrdQty2] [decimal](18, 2) NOT NULL,
	[SOrdQty3] [decimal](18, 2) NOT NULL,
	[SOrdQty4] [decimal](18, 2) NOT NULL,
	[SOrdQty5] [decimal](18, 2) NOT NULL,
	[SOrdQty6] [decimal](18, 2) NOT NULL,
	[SOrdQty7] [decimal](18, 2) NOT NULL,
	[SOrdQty8] [decimal](18, 2) NOT NULL,
	[SOrdQty9] [decimal](18, 2) NOT NULL,
	[SOrdQty10] [decimal](18, 2) NOT NULL,
	[SOrddefstr1] [varchar](50) NULL,
	[SOrddefstr2] [varchar](50) NULL,
	[SOrddefstr3] [varchar](50) NULL,
	[SOrddefstr4] [varchar](100) NULL,
	[SOrddefstr5] [varchar](50) NULL,
	[SOrddefstr6] [varchar](50) NULL,
	[SOrddefstr7] [varchar](20) NULL,
	[SOrddefstr8] [varchar](20) NULL,
	[SOrddefstr9] [varchar](20) NULL,
	[SOrddefstr10] [varchar](20) NULL,
	[SOrdDefNote1] [varchar](40) NULL,
	[SOrdDefNote2] [varchar](40) NULL,
	[SOrdDefNote3] [varchar](40) NULL,
	[SOrdDefNote4] [varchar](40) NULL,
	[SOrdDefNote5] [varchar](40) NULL,
	[SOrdDefNote6] [varchar](40) NULL,
	[SOrdDefNote7] [varchar](40) NULL,
	[SOrdDefNote8] [varchar](40) NULL,
	[SOrdDefNote9] [varchar](40) NULL,
	[SOrdDefNote10] [varchar](40) NULL,
	[SOrdDefNote11] [varchar](40) NULL,
	[SOrdDefNote12] [varchar](40) NULL,
	[SOrdDefNote13] [varchar](40) NULL,
	[SOrdDefNote14] [varchar](40) NULL,
	[SOrdDefNote15] [varchar](40) NULL,
	[SOrdDefNote16] [varchar](40) NULL,
	[SOrdDefNote17] [varchar](40) NULL,
	[SOrdDefNote18] [varchar](40) NULL,
	[SOrdDefNote19] [varchar](40) NULL,
	[SOrdDefNote20] [varchar](40) NULL,
	[SOrdFlag1] [bit] NOT NULL,
	[SOrdFlag2] [bit] NOT NULL,
	[SOrdFlag3] [bit] NOT NULL,
	[SOrdFlag4] [bit] NOT NULL,
	[SOrdFlag5] [bit] NOT NULL,
	[SubStatus] [varchar](20) NULL,
	[SubValid] [char](1) NOT NULL,
	[SLbName] [varchar](20) NULL,
	[SLbInt] [int] NULL,
	[PRTHX] [varchar](20) NULL,
	[KgQty] [decimal](18, 2) NOT NULL,
	[KgPrice] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_JYOrderCY_Sub] PRIMARY KEY CLUSTERED 
(
	[SubId] 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
/****** Object:  Table [dbo].[JYOrderCy_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderCy_Main](
	[MainId] [char](20) NOT NULL,
	[CYNO] [char](20) NOT NULL,
	[OrderNo] [char](20) NULL,
	[JGFactory] [varchar](20) NULL,
	[JGFactoryName] [varchar](40) NULL,
	[ConNo] [char](20) NULL,
	[KHConNo] [varchar](30) NULL,
	[CustomerNo] [char](20) NULL,
	[CustomerNoName] [varchar](40) NULL,
	[DlyDate] [datetime] NULL,
	[DlyPlace] [varchar](100) NULL,
	[OrdDate] [datetime] NULL,
	[OrdUpDate] [datetime] NULL,
	[MPRTCode] [varchar](40) NULL,
	[MPRTCodeName] [varchar](50) NULL,
	[MPRTSpec] [varchar](100) NULL,
	[MPRTCF] [varchar](40) NULL,
	[MPRTMF] [varchar](40) NULL,
	[MPRTKZ] [varchar](40) NULL,
	[MPRTSL] [varchar](40) NULL,
	[OrdDefDate1] [datetime] NULL,
	[OrdDefDate2] [datetime] NULL,
	[OrdDefDate3] [datetime] NULL,
	[OrdDefDate4] [datetime] NULL,
	[OrdDefDate5] [datetime] NULL,
	[Note] [varchar](500) NULL,
	[OrdDefStr1] [varchar](40) NULL,
	[OrdDefStr2] [varchar](40) NULL,
	[OrdDefStr3] [varchar](40) NULL,
	[OrdDefStr4] [varchar](40) NULL,
	[OrdDefStr5] [varchar](40) NULL,
	[OrdDefStr6] [varchar](40) NULL,
	[OrdDefStr7] [varchar](40) NULL,
	[OrdDefStr8] [varchar](40) NULL,
	[OrdDefStr9] [varchar](40) NULL,
	[OrdDefStr10] [varchar](40) NULL,
	[OrdDefStr11] [varchar](40) NULL,
	[OrdDefStr12] [varchar](40) NULL,
	[OrdDefStr13] [varchar](40) NULL,
	[OrdDefStr14] [varchar](40) NULL,
	[OrdDefStr15] [varchar](40) NULL,
	[OrdDefNote1] [varchar](5000) NULL,
	[OrdDefNote2] [varchar](40) NULL,
	[OrdDefNote3] [varchar](40) NULL,
	[OrdDefNote4] [varchar](40) NULL,
	[OrdDefNote5] [varchar](40) NULL,
	[OrdDefNote6] [varchar](40) NULL,
	[OrdDefNote7] [varchar](40) NULL,
	[OrdDefNote8] [varchar](40) NULL,
	[OrdDefNote9] [varchar](40) NULL,
	[OrdDefNote10] [varchar](40) NULL,
	[OrdDefNote11] [varchar](40) NULL,
	[OrdDefNote12] [varchar](40) NULL,
	[OrdDefNote13] [varchar](40) NULL,
	[OrdDefNote14] [varchar](40) NULL,
	[OrdDefNote15] [varchar](40) NULL,
	[OrdPerson1] [varchar](20) NULL,
	[OrdPerson2] [varchar](20) NULL,
	[OrdPerson3] [varchar](20) NULL,
	[OrdPerson4] [varchar](20) NULL,
	[OrdPerson5] [varchar](20) NULL,
	[OrdPerson6] [varchar](20) NULL,
	[OrdPerson7] [varchar](20) NULL,
	[OrdPerson8] [varchar](20) NULL,
	[OrdPerson9] [varchar](20) NULL,
	[OrdPerson10] [varchar](20) NULL,
	[OrdFlag1] [bit] NOT NULL,
	[OrdFlag2] [bit] NOT NULL,
	[OrdFlag3] [bit] NOT NULL,
	[OrdFlag4] [bit] NOT NULL,
	[OrdFlag5] [bit] NOT NULL,
	[OrdFlag6] [bit] NOT NULL,
	[OrdFlag7] [bit] NOT NULL,
	[OrdFlag8] [bit] NOT NULL,
	[OrdFlag9] [bit] NOT NULL,
	[OrdFlag10] [bit] NOT NULL,
	[OrdFlag11] [bit] NOT NULL,
	[OrdFlag12] [bit] NOT NULL,
	[OrdFlag13] [bit] NOT NULL,
	[OrdFlag14] [bit] NOT NULL,
	[OrdFlag15] [bit] NOT NULL,
	[OrdFlag16] [bit] NOT NULL,
	[OrdFlag17] [bit] NOT NULL,
	[OrdFlag18] [bit] NOT NULL,
	[OrdFlag19] [bit] NOT NULL,
	[OrdFlag20] [bit] NOT NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NULL,
	[LbName] [varchar](20) NULL,
	[LbInt] [int] NULL,
	[YSYBMoneyFZ] [decimal](18, 2) NOT NULL,
	[YSYBFlag] [bit] NOT NULL,
	[YCLFactory] [varchar](50) NULL,
	[PBFactory] [varchar](50) NULL,
	[RanFactory] [varchar](50) NULL,
	[HZLFactory] [varchar](50) NULL,
	[MPRTColorLaoDu] [varchar](50) NULL,
	[MPRTNiuDu] [varchar](50) NULL,
	[MPRTPH] [varchar](50) NULL,
	[MPRTZHName] [varchar](50) NULL,
	[MPRTBZNote] [varchar](1000) NULL,
	[MPRTKaiJian] [varchar](50) NULL,
	[MPRTChuanY] [varchar](50) NULL,
	[MPRTYaoFeng] [varchar](50) NULL,
	[MPRTJiBenNote] [varchar](100) NULL,
	[MPRTTeBieNote] [varchar](100) NULL,
	[MPRTQtyNote] [varchar](50) NULL,
	[MPRTColorLaoDu1] [varchar](40) NULL,
	[MPRTColorLaoDu2] [varchar](40) NULL,
	[MPRTColorLaoDu3] [varchar](40) NULL,
	[MPRTColorLaoDu4] [varchar](40) NULL,
	[MPRTDuiSeGY] [varchar](40) NULL,
	[MPRTKQiQiu] [varchar](40) NULL,
	[MPRTDingPoLv] [varchar](40) NULL,
	[MPRTZuRanXing] [varchar](40) NULL,
	[MPRTKuanNO] [varchar](40) NULL,
	[LBNameNote] [varchar](200) NULL,
	[MaiTouNote] [varchar](200) NULL,
	[MPRTTangJin] [varchar](40) NULL,
	[MPRTSCTeBieNote] [varchar](1000) NULL,
	[PiZhong] [decimal](18, 2) NOT NULL,
	[SYRName] [varchar](60) NULL,
	[CPCFBi] [varchar](60) NULL,
	[EditCnt] [int] NOT NULL,
	[ConPerson1] [varchar](20) NULL,
	[ConPerson2] [varchar](20) NULL,
	[ConPerson3] [varchar](20) NULL,
	[conDefstr1] [varchar](200) NULL,
	[conDefstr2] [varchar](200) NULL,
	[conDefstr3] [varchar](200) NULL,
 CONSTRAINT [PK_JYOrderCY_Main] PRIMARY KEY CLUSTERED 
(
	[MainId] 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
/****** Object:  Table [dbo].[JYOrderCon_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderCon_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[XHNo] [int] NULL,
	[PRTCode] [varchar](40) NULL,
	[PRTCodeName] [varchar](50) NULL,
	[PRTSpec] [varchar](100) NULL,
	[PRTType] [varchar](40) NULL,
	[PRTColor] [varchar](20) NULL,
	[PRTMF] [varchar](20) NULL,
	[PRTKZ] [varchar](20) NULL,
	[PRTOrderQty] [decimal](18, 2) NOT NULL,
	[PRTClothQty] [decimal](18, 2) NOT NULL,
	[OrderUnit] [varchar](20) NULL,
	[PRTPrice] [decimal](18, 4) NULL,
	[PriceUnit] [varchar](20) NULL,
	[SOrdQty1] [decimal](18, 2) NOT NULL,
	[SOrdQty2] [decimal](18, 2) NOT NULL,
	[SOrdQty3] [decimal](18, 2) NOT NULL,
	[SOrdQty4] [decimal](18, 2) NOT NULL,
	[SOrdQty5] [decimal](18, 2) NOT NULL,
	[SOrdQty6] [decimal](18, 2) NOT NULL,
	[SOrdQty7] [decimal](18, 2) NOT NULL,
	[SOrdQty8] [decimal](18, 2) NOT NULL,
	[SOrdQty9] [decimal](18, 2) NOT NULL,
	[SOrdQty10] [decimal](18, 2) NOT NULL,
	[SOrddefstr1] [varchar](20) NULL,
	[SOrddefstr2] [varchar](20) NULL,
	[SOrddefstr3] [varchar](20) NULL,
	[SOrddefstr4] [varchar](100) NULL,
	[SOrddefstr5] [varchar](20) NULL,
	[SOrddefstr6] [varchar](20) NULL,
	[SOrddefstr7] [varchar](20) NULL,
	[SOrddefstr8] [varchar](20) NULL,
	[SOrddefstr9] [varchar](20) NULL,
	[SOrddefstr10] [varchar](20) NULL,
	[SOrdDefNote1] [varchar](40) NULL,
	[SOrdDefNote2] [varchar](40) NULL,
	[SOrdDefNote3] [varchar](40) NULL,
	[SOrdDefNote4] [varchar](40) NULL,
	[SOrdDefNote5] [varchar](40) NULL,
	[SOrdDefNote6] [varchar](40) NULL,
	[SOrdDefNote7] [varchar](40) NULL,
	[SOrdDefNote8] [varchar](40) NULL,
	[SOrdDefNote9] [varchar](40) NULL,
	[SOrdDefNote10] [varchar](40) NULL,
	[SOrdDefNote11] [varchar](40) NULL,
	[SOrdDefNote12] [varchar](40) NULL,
	[SOrdDefNote13] [varchar](40) NULL,
	[SOrdDefNote14] [varchar](40) NULL,
	[SOrdDefNote15] [varchar](40) NULL,
	[SOrdDefNote16] [varchar](40) NULL,
	[SOrdDefNote17] [varchar](40) NULL,
	[SOrdDefNote18] [varchar](40) NULL,
	[SOrdDefNote19] [varchar](40) NULL,
	[SOrdDefNote20] [varchar](40) NULL,
	[SOrdFlag1] [bit] NOT NULL,
	[SOrdFlag2] [bit] NOT NULL,
	[SOrdFlag3] [bit] NOT NULL,
	[SOrdFlag4] [bit] NOT NULL,
	[SOrdFlag5] [bit] NOT NULL,
	[SOrdFlag6] [bit] NOT NULL,
	[SOrdFlag7] [bit] NOT NULL,
	[SOrdFlag8] [bit] NOT NULL,
	[SOrdFlag9] [bit] NOT NULL,
	[SOrdFlag10] [bit] NOT NULL,
	[SOrdFlag11] [bit] NOT NULL,
	[SOrdFlag12] [bit] NOT NULL,
	[SOrdFlag13] [bit] NOT NULL,
	[SOrdFlag14] [bit] NOT NULL,
	[SOrdFlag15] [bit] NOT NULL,
	[SOrdFlag16] [bit] NOT NULL,
	[SOrdFlag17] [bit] NOT NULL,
	[SOrdFlag18] [bit] NOT NULL,
	[SOrdFlag19] [bit] NOT NULL,
	[SOrdFlag20] [bit] NOT NULL,
	[SubStatus] [varchar](20) NULL,
	[SubValid] [char](1) NOT NULL,
	[SLbName] [varchar](20) NULL,
	[SLbInt] [int] NULL,
	[PRTHX] [varchar](20) NULL,
	[KGQty] [decimal](18, 2) NOT NULL,
	[KGPrice] [decimal](18, 2) NOT NULL,
	[StyleNo] [varchar](100) NULL,
	[ZhenZhiSJFee] [decimal](18, 2) NULL,
	[YinHuaSJFee] [decimal](18, 2) NULL,
	[BaoGangFee] [decimal](18, 2) NULL,
	[ZhiWangZhiBanFee] [decimal](18, 2) NULL,
	[TaoQty] [decimal](18, 0) NULL,
	[ConMXMoney] [decimal](18, 2) NULL,
	[PRTColorNo] [varchar](40) NULL,
	[PRTColorOK] [varchar](20) NULL,
	[HYPrice] [decimal](18, 2) NULL,
	[YJPrice] [decimal](18, 2) NULL,
	[YJBLi] [decimal](18, 2) NULL,
	[HXQty] [decimal](18, 2) NULL,
	[ColQty] [decimal](18, 2) NULL,
	[MSQty] [decimal](18, 2) NULL,
	[PRTCodeNameEng] [varchar](80) NULL,
	[TiaoQty] [varchar](80) NULL,
	[ZXChiCun] [varchar](80) NULL,
	[MXTQty] [decimal](18, 2) NULL,
	[MaoQty] [varchar](80) NULL,
	[JQty] [varchar](80) NULL,
	[XQty] [decimal](18, 2) NULL,
	[MXNote] [varchar](300) NULL,
	[PKGFee] [decimal](18, 2) NULL,
	[PRTGY] [varchar](100) NULL,
	[BZYQNote] [varchar](100) NULL,
 CONSTRAINT [PK_JYOrderCon_Sub] PRIMARY KEY CLUSTERED 
(
	[SubId] 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
/****** Object:  Table [dbo].[JYOrderCon_Main_Note]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderCon_Main_Note](
	[MainId] [char](20) NOT NULL,
	[MNId] [char](20) NOT NULL,
	[XHNo] [char](20) NULL,
	[MNType] [varchar](40) NULL,
	[MNote] [varchar](500) NULL,
 CONSTRAINT [PK_JYOrderCon_Main_Note] PRIMARY KEY CLUSTERED 
(
	[MNId] 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
/****** Object:  Table [dbo].[JYOrderCon_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrderCon_Main](
	[MainId] [char](20) NOT NULL,
	[ConNo] [char](20) NULL,
	[CustomerNo] [char](20) NULL,
	[CustomerNoName] [varchar](80) NULL,
	[FromPlace] [varchar](80) NULL,
	[ToPlace] [varchar](80) NULL,
	[PayMent] [varchar](200) NULL,
	[ShippMent] [varchar](20) NULL,
	[OrdDate] [datetime] NULL,
	[DlyDate] [datetime] NULL,
	[DlyPlace] [varchar](100) NULL,
	[SYRName] [varchar](100) NULL,
	[SYRAddress] [varchar](100) NULL,
	[SYRTel] [varchar](20) NULL,
	[SYRFax] [varchar](20) NULL,
	[BankNo] [varchar](20) NULL,
	[BankName] [varchar](100) NULL,
	[BankAddress] [varchar](100) NULL,
	[BankFastNo] [varchar](20) NULL,
	[PostNo] [varchar](20) NULL,
	[MPRTCode] [varchar](40) NULL,
	[MPRTCodeName] [varchar](50) NULL,
	[MPRTSpec] [varchar](40) NULL,
	[MPRTCF] [varchar](40) NULL,
	[MPRTMF] [varchar](40) NULL,
	[MPRTKZ] [varchar](40) NULL,
	[MPRTSL] [varchar](40) NULL,
	[ConDefDate1] [datetime] NULL,
	[ConDefDate2] [datetime] NULL,
	[ConDefDate3] [datetime] NULL,
	[ConDefDate4] [datetime] NULL,
	[ConDefDate5] [datetime] NULL,
	[Note] [varchar](250) NULL,
	[ConDefStr1] [varchar](40) NULL,
	[ConDefStr2] [varchar](1000) NULL,
	[ConDefStr3] [varchar](500) NULL,
	[ConDefStr4] [varchar](40) NULL,
	[ConDefStr5] [varchar](40) NULL,
	[ConDefStr6] [varchar](200) NULL,
	[ConDefStr7] [varchar](40) NULL,
	[ConDefStr8] [varchar](40) NULL,
	[ConDefStr9] [varchar](40) NULL,
	[ConDefStr10] [varchar](40) NULL,
	[ConDefNote1] [varchar](100) NULL,
	[ConDefNote2] [varchar](100) NULL,
	[ConDefNote3] [varchar](100) NULL,
	[ConDefNote4] [varchar](500) NULL,
	[ConDefNote5] [varchar](100) NULL,
	[ConPerson1] [varchar](20) NULL,
	[ConPerson2] [varchar](100) NULL,
	[ConPerson3] [varchar](20) NULL,
	[ConPerson4] [varchar](20) NULL,
	[ConPerson5] [varchar](20) NULL,
	[ConFlag1] [bit] NOT NULL,
	[ConFlag2] [bit] NOT NULL,
	[ConFlag3] [bit] NOT NULL,
	[ConFlag4] [bit] NOT NULL,
	[ConFlag5] [bit] NOT NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NULL,
	[DlyNote] [varchar](100) NULL,
	[QtyNote] [varchar](100) NULL,
	[PriceNote] [varchar](100) NULL,
	[TelNo] [varchar](100) NULL,
	[FaxNo] [varchar](100) NULL,
	[EmailNo] [varchar](100) NULL,
	[MidBanck] [varchar](100) NULL,
	[MidBank] [varchar](100) NULL,
	[MPRTTYpe] [varchar](20) NULL,
	[CPCFNo] [varchar](20) NULL,
	[CPTanLi] [varchar](20) NULL,
	[CPRanYin] [varchar](20) NULL,
	[CPRanHouGY] [varchar](20) NULL,
	[CPType] [varchar](20) NULL,
	[CPZHName] [varchar](80) NULL,
	[ZhiLiangNote] [varchar](500) NULL,
	[ChuanYangNote] [varchar](100) NULL,
	[YSBiaoZhunNote] [varchar](500) NULL,
	[OtherNote] [varchar](100) NULL,
	[CTMAddress] [varchar](100) NULL,
	[CTMTelNo] [varchar](100) NULL,
	[CTMFaxNo] [varchar](100) NULL,
	[QianDPlace] [varchar](20) NULL,
	[SelfBankNo] [varchar](40) NULL,
	[BankSelfFastNo] [varchar](40) NULL,
	[KHConNo] [varchar](100) NULL,
	[CPCFBi] [varchar](20) NULL,
	[CTMBankNo] [varchar](30) NULL,
	[CTMBankName] [varchar](60) NULL,
	[ConType] [varchar](20) NULL,
	[FKPerson] [varchar](20) NULL,
	[XFLXPerson] [varchar](20) NULL,
	[XFLXTel] [varchar](20) NULL,
	[GFLXPerson] [varchar](20) NULL,
	[GFLXTel] [varchar](20) NULL,
	[ConMoney] [decimal](18, 2) NULL,
	[FillerCode] [varchar](20) NULL,
	[HuoDai] [varchar](40) NULL,
	[KeFu] [varchar](20) NULL,
	[ChuanYQty] [varchar](20) NULL,
	[XSType] [varchar](20) NULL,
	[ConNLBName] [varchar](60) NULL,
	[ConLBName] [varchar](60) NULL,
	[QDDate] [datetime] NULL,
	[SLYangPing] [varchar](80) NULL,
	[YDZhuang] [varchar](80) NULL,
	[MaiTou] [varchar](200) NULL,
	[DEPORT] [varchar](80) NULL,
	[ZUOFEIFLAG] [bit] NULL,
	[PiChang] [varchar](100) NULL,
	[FHTuJin] [varchar](100) NULL,
	[WCStatus] [varchar](50) NULL,
	[IFCK] [varchar](10) NULL,
	[MPRTSCTeBieNote] [varchar](100) NULL,
 CONSTRAINT [PK_JJYOrderCon_Main] PRIMARY KEY CLUSTERED 
(
	[MainId] 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
/****** Object:  Table [dbo].[JYOrder_Sub_AnPai]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[JYOrder_Sub_AnPai](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[APID] [char](20) NOT NULL,
	[GangNo] [varchar](20) NULL,
	[XHNo] [char](20) NULL,
	[OrderNo] [char](20) NULL,
	[AOrdQty1] [decimal](18, 2) NOT NULL,
	[AOrdQty2] [decimal](18, 2) NOT NULL,
	[AOrdQty3] [decimal](18, 2) NOT NULL,
	[AOrdQty4] [decimal](18, 2) NOT NULL,
	[AOrdQty5] [decimal](18, 2) NOT NULL,
	[AOrdQty6] [decimal](18, 2) NOT NULL,
	[AOrdQty7] [decimal](18, 2) NOT NULL,
	[AOrdQty8] [decimal](18, 2) NOT NULL,
	[AOrdQty9] [decimal](18, 2) NOT NULL,
	[AOrdQty10] [decimal](18, 2) NOT NULL,
	[AOrddefstr1] [varchar](20) NULL,
	[AOrddefstr2] [varchar](20) NULL,
	[AOrddefstr3] [varchar](20) NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrddefstr4] [varchar](100) NULL
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrddefstr5] [varchar](20) NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrddefstr6] [varchar](100) NULL
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrddefstr7] [varchar](20) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrddefstr8] [varchar](20) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrddefstr9] [varchar](20) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrddefstr10] [varchar](20) NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote1] [varchar](200) NULL
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote2] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote3] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote4] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote5] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote6] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote7] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote8] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote9] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote10] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote11] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote12] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote13] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote14] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote15] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote16] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote17] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote18] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote19] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote20] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote21] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote22] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote23] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote24] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote25] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote26] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote27] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote28] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote29] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote30] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote31] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote32] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote33] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote34] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote35] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote36] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote37] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote38] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote39] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdDefNote40] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdFlag1] [bit] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdFlag2] [bit] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdFlag3] [bit] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdFlag4] [bit] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdFlag5] [bit] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdFlag6] [bit] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdFlag7] [bit] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdFlag8] [bit] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdFlag9] [bit] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AOrdFlag10] [bit] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ADefDate1] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ADefDate2] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ADefDate3] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ADefDate4] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ADefDate5] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ADefDate6] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ADefDate7] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ADefDate8] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ADefDate9] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ADefDate10] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [Chker] [varchar](20) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ChkStatus] [varchar](20) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ChkNote] [varchar](200) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [Chktime] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [Filler] [varchar](20) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [Filltime] [datetime] NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [Editer] [varchar](20) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [Edittime] [datetime] NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AStatus] [varchar](20) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [AValid] [char](1) NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [ZSXS] [decimal](18, 4) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [HCYZQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [HCMQty] [decimal](18, 2) NOT NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [LLID] [varchar](20) NULL
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [LBName] [varchar](40) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [JYMF] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [JYKZ] [decimal](18, 2) NOT NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [APType] [varchar](20) NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD [JGPrice] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  CONSTRAINT [PK_JYOrder_Sub_AnPai] PRIMARY KEY CLUSTERED 
(
	[APID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[JYOrder_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrder_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[XHNo] [char](20) NULL,
	[OrderNo] [char](20) NULL,
	[PRTCode] [varchar](40) NULL,
	[PRTCodeName] [varchar](50) NULL,
	[PRTSpec] [varchar](40) NULL,
	[PRTType] [varchar](40) NULL,
	[PRTColor] [varchar](20) NULL,
	[PRTMF] [varchar](20) NULL,
	[PRTKZ] [varchar](20) NULL,
	[PRTOrderQty] [decimal](18, 2) NOT NULL,
	[PRTClothQty] [decimal](18, 2) NOT NULL,
	[OrderUnit] [varchar](20) NULL,
	[PRTPrice] [decimal](10, 4) NOT NULL,
	[PriceUnit] [varchar](20) NULL,
	[SOrdQty1] [decimal](18, 2) NOT NULL,
	[SOrdQty2] [decimal](18, 2) NOT NULL,
	[SOrdQty3] [decimal](18, 2) NOT NULL,
	[SOrdQty4] [decimal](18, 2) NOT NULL,
	[SOrdQty5] [decimal](18, 2) NOT NULL,
	[SOrdQty6] [decimal](18, 2) NOT NULL,
	[SOrdQty7] [decimal](18, 2) NOT NULL,
	[SOrdQty8] [decimal](18, 2) NOT NULL,
	[SOrdQty9] [decimal](18, 2) NOT NULL,
	[SOrdQty10] [decimal](18, 2) NOT NULL,
	[SOrddefstr1] [varchar](50) NULL,
	[SOrddefstr2] [varchar](50) NULL,
	[SOrddefstr3] [varchar](50) NULL,
	[SOrddefstr4] [varchar](100) NULL,
	[SOrddefstr5] [varchar](50) NULL,
	[SOrddefstr6] [varchar](50) NULL,
	[SOrddefstr7] [varchar](20) NULL,
	[SOrddefstr8] [varchar](20) NULL,
	[SOrddefstr9] [varchar](20) NULL,
	[SOrddefstr10] [varchar](20) NULL,
	[SOrdDefNote1] [varchar](200) NULL,
	[SOrdDefNote2] [varchar](40) NULL,
	[SOrdDefNote3] [varchar](40) NULL,
	[SOrdDefNote4] [varchar](40) NULL,
	[SOrdDefNote5] [varchar](40) NULL,
	[SOrdDefNote6] [varchar](40) NULL,
	[SOrdDefNote7] [varchar](40) NULL,
	[SOrdDefNote8] [varchar](40) NULL,
	[SOrdDefNote9] [varchar](40) NULL,
	[SOrdFlag1] [bit] NOT NULL,
	[SOrdFlag2] [bit] NOT NULL,
	[SOrdFlag3] [bit] NOT NULL,
	[SOrdFlag4] [bit] NOT NULL,
	[SOrdFlag5] [bit] NOT NULL,
	[SubStatus] [varchar](20) NULL,
	[SubValid] [char](1) NOT NULL,
	[SLbName] [varchar](20) NULL,
	[SLbInt] [int] NULL,
	[PRTHX] [varchar](100) NULL,
	[KgQty] [decimal](18, 2) NOT NULL,
	[KgPrice] [decimal](18, 2) NOT NULL,
	[PRTKuanNO] [varchar](60) NULL,
	[XHInt] [int] NULL,
	[PRTColorNo] [varchar](20) NULL,
	[PRTColorEng] [varchar](50) NULL,
	[StyleNo] [varchar](20) NULL,
	[ColorOk] [varchar](50) NULL,
	[HXTuGao] [varchar](50) NULL,
	[OrdNote] [varchar](200) NULL,
	[FilesOther] [varchar](50) NULL,
	[OrdMSQty] [decimal](18, 2) NULL,
	[OrdColQty] [decimal](18, 2) NULL,
	[PBFK] [varchar](50) NULL,
	[PBKZ] [varchar](50) NULL,
	[PBSpec] [varchar](50) NULL,
	[PRTGY] [varchar](80) NULL,
	[ZXChiCun] [varchar](60) NULL,
	[PBQty] [decimal](18, 2) NULL,
	[CJNote] [varchar](100) NULL,
	[PBQtyUnit] [varchar](50) NULL,
 CONSTRAINT [PK_JYOrder_Sub] PRIMARY KEY CLUSTERED 
(
	[SubId] 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
/****** Object:  Table [dbo].[JYOrder_Process]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[JYOrder_Process](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NULL,
	[PSId] [char](20) NOT NULL,
	[PSName] [varchar](20) NULL,
	[PSXH] [int] NULL,
	[PSSH] [decimal](18, 2) NOT NULL,
	[PSSJSH] [decimal](18, 2) NOT NULL,
	[LiDanPerson] [varchar](20) NULL,
	[GenDanPerson] [varchar](20) NULL,
	[PSNote] [varchar](800) NULL,
	[MFQty] [decimal](18, 2) NOT NULL,
	[KZQty] [decimal](18, 2) NOT NULL,
	[KgZM] [decimal](18, 4) NOT NULL,
	[PSSJQty] [decimal](18, 2) NOT NULL,
	[PSSJMoney] [decimal](18, 2) NOT NULL,
	[PSSJPrice] [decimal](18, 2) NOT NULL,
	[PSSJNote] [varchar](100) NULL,
	[ZPQty] [decimal](18, 2) NULL,
	[LDMoney] [decimal](18, 2) NULL,
	[SHMoney] [decimal](18, 2) NULL,
	[LDPrice] [decimal](18, 3) NULL,
	[SHPrice] [decimal](18, 2) NULL,
	[PJFenShu] [decimal](18, 0) NULL,
	[SHFuDong] [decimal](18, 2) NULL,
 CONSTRAINT [PK_JYOrder_Process] PRIMARY KEY CLUSTERED 
(
	[PSId] 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
/****** Object:  Table [dbo].[JYOrder_PCS_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrder_PCS_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NULL,
	[CGConId] [char](20) NULL,
	[PSId] [char](20) NOT NULL,
	[PFId] [char](20) NOT NULL,
	[FactoryNo] [varchar](20) NULL,
	[FactoryName] [varchar](50) NULL,
	[PFDlyDate] [datetime] NULL,
	[PFSH] [decimal](18, 2) NOT NULL,
	[PFSJSH] [decimal](18, 2) NOT NULL,
	[PFTPQty] [decimal](18, 2) NOT NULL,
	[PFTPUnit] [varchar](20) NULL,
	[PFTPPS] [decimal](18, 2) NOT NULL,
	[PFNote] [varchar](200) NULL,
	[PFGenDanPerson] [varchar](20) NULL,
	[CKName] [varchar](20) NULL,
	[PFTPMQty] [decimal](18, 2) NOT NULL,
	[WCMQty] [decimal](18, 2) NOT NULL,
	[TJMQty] [decimal](18, 2) NOT NULL,
	[TJOutFlag] [bit] NOT NULL,
	[Filler] [varchar](20) NULL,
	[Editer] [varchar](20) NULL,
	[FillTime] [datetime] NOT NULL,
	[EditTime] [datetime] NOT NULL,
	[XDFactoryNo] [varchar](20) NULL,
	[XDFactoryName] [varchar](20) NULL,
	[PFDate] [datetime] NULL,
	[DYFlag] [bit] NOT NULL,
	[PRTHX] [varchar](90) NULL,
	[PRTColor] [varchar](90) NULL,
	[OrderUnit] [varchar](50) NULL,
	[APOrderQty] [decimal](18, 2) NULL,
	[TOGYSName] [varchar](80) NULL,
 CONSTRAINT [PK_JYOrder_PCS_Sub] PRIMARY KEY CLUSTERED 
(
	[PFId] 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
/****** Object:  Table [dbo].[JYOrder_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrder_Main](
	[MainId] [char](20) NOT NULL,
	[OrderNo] [char](20) NOT NULL,
	[JGFactory] [varchar](20) NULL,
	[JGFactoryName] [varchar](40) NULL,
	[ConNo] [char](20) NULL,
	[CustomerNo] [char](20) NULL,
	[CustomerNoName] [varchar](40) NULL,
	[DlyDate] [datetime] NULL,
	[DlyPlace] [varchar](100) NULL,
	[OrdDate] [datetime] NULL,
	[OrdUpDate] [datetime] NULL,
	[MPRTCode] [varchar](40) NULL,
	[MPRTCodeName] [varchar](50) NULL,
	[MPRTSpec] [varchar](100) NULL,
	[MPRTCF] [varchar](40) NULL,
	[MPRTMF] [varchar](40) NULL,
	[MPRTKZ] [varchar](40) NULL,
	[MPRTSL] [varchar](40) NULL,
	[OrdDefDate1] [datetime] NULL,
	[OrdDefDate2] [datetime] NULL,
	[OrdDefDate3] [datetime] NULL,
	[OrdDefDate4] [datetime] NULL,
	[OrdDefDate5] [datetime] NULL,
	[Note] [varchar](500) NULL,
	[OrdDefStr1] [varchar](40) NULL,
	[OrdDefStr2] [varchar](40) NULL,
	[OrdDefStr3] [varchar](40) NULL,
	[OrdDefStr4] [varchar](40) NULL,
	[OrdDefStr5] [varchar](40) NULL,
	[OrdDefStr6] [varchar](40) NULL,
	[OrdDefStr7] [varchar](40) NULL,
	[OrdDefStr8] [varchar](40) NULL,
	[OrdDefStr9] [varchar](40) NULL,
	[OrdDefStr10] [varchar](40) NULL,
	[OrdDefStr11] [varchar](40) NULL,
	[OrdDefStr12] [varchar](40) NULL,
	[OrdDefStr13] [varchar](40) NULL,
	[OrdDefStr14] [varchar](40) NULL,
	[OrdDefStr15] [varchar](40) NULL,
	[OrdDefNote1] [varchar](5000) NULL,
	[OrdDefNote2] [varchar](1000) NULL,
	[OrdDefNote3] [varchar](40) NULL,
	[OrdDefNote4] [varchar](40) NULL,
	[OrdDefNote5] [varchar](40) NULL,
	[OrdDefNote6] [varchar](40) NULL,
	[OrdDefNote7] [varchar](40) NULL,
	[OrdDefNote8] [varchar](40) NULL,
	[OrdDefNote9] [varchar](40) NULL,
	[OrdDefNote10] [varchar](40) NULL,
	[OrdDefNote11] [varchar](40) NULL,
	[OrdDefNote12] [varchar](40) NULL,
	[OrdDefNote13] [varchar](40) NULL,
	[OrdDefNote14] [varchar](40) NULL,
	[OrdDefNote15] [varchar](40) NULL,
	[OrdPerson1] [varchar](20) NULL,
	[OrdPerson2] [varchar](20) NULL,
	[OrdPerson3] [varchar](20) NULL,
	[OrdPerson4] [varchar](20) NULL,
	[OrdPerson5] [varchar](20) NULL,
	[OrdPerson6] [varchar](20) NULL,
	[OrdPerson7] [varchar](20) NULL,
	[OrdPerson8] [varchar](20) NULL,
	[OrdPerson9] [varchar](20) NULL,
	[OrdPerson10] [varchar](20) NULL,
	[OrdFlag1] [bit] NOT NULL,
	[OrdFlag2] [bit] NOT NULL,
	[OrdFlag3] [bit] NOT NULL,
	[OrdFlag4] [bit] NOT NULL,
	[OrdFlag5] [bit] NOT NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NULL,
	[LbName] [varchar](20) NULL,
	[LbInt] [int] NULL,
	[YSYBMoneyFZ] [decimal](18, 2) NOT NULL,
	[YSYBFlag] [bit] NOT NULL,
	[YCLFactory] [varchar](50) NULL,
	[PBFactory] [varchar](50) NULL,
	[RanFactory] [varchar](50) NULL,
	[HZLFactory] [varchar](50) NULL,
	[MPRTColorLaoDu] [varchar](50) NULL,
	[MPRTNiuDu] [varchar](50) NULL,
	[MPRTPH] [varchar](50) NULL,
	[MPRTZHName] [varchar](50) NULL,
	[MPRTBZNote] [varchar](1000) NULL,
	[MPRTKaiJian] [varchar](50) NULL,
	[MPRTChuanY] [varchar](50) NULL,
	[MPRTYaoFeng] [varchar](50) NULL,
	[MPRTJiBenNote] [varchar](100) NULL,
	[MPRTTeBieNote] [varchar](100) NULL,
	[MPRTQtyNote] [varchar](50) NULL,
	[MPRTColorLaoDu1] [varchar](40) NULL,
	[MPRTColorLaoDu2] [varchar](40) NULL,
	[MPRTColorLaoDu3] [varchar](40) NULL,
	[MPRTColorLaoDu4] [varchar](40) NULL,
	[MPRTDuiSeGY] [varchar](40) NULL,
	[MPRTKQiQiu] [varchar](40) NULL,
	[MPRTDingPoLv] [varchar](40) NULL,
	[MPRTZuRanXing] [varchar](40) NULL,
	[MPRTKuanNO] [varchar](40) NULL,
	[LBNameNote] [varchar](200) NULL,
	[MaiTouNote] [varchar](200) NULL,
	[MPRTTangJin] [varchar](40) NULL,
	[MPRTSCTeBieNote] [varchar](1000) NULL,
	[PiZhong] [decimal](18, 2) NOT NULL,
	[SYRName] [varchar](60) NULL,
	[CPCFBi] [varchar](60) NULL,
	[EditCnt] [int] NOT NULL,
	[NLBName] [varchar](60) NULL,
	[KouFenQty] [int] NOT NULL,
	[xs] [decimal](18, 4) NOT NULL,
	[xsType] [varchar](20) NULL,
	[ChuanY] [varchar](20) NULL,
	[LiDanPerson] [varchar](20) NULL,
	[YWY] [varchar](20) NULL,
	[MPRTGYHZ] [varchar](20) NULL,
	[ZLLevel] [varchar](20) NULL,
	[SCYaoSu] [varchar](200) NULL,
	[ComTaiTou] [varchar](50) NULL,
	[FillerCode] [varchar](20) NULL,
	[MPRTMFNOte] [varchar](50) NULL,
	[MPRTKZNOte] [varchar](50) NULL,
	[BZNote] [varchar](50) NULL,
	[KHNameJC] [varchar](20) NULL,
	[BPPiZhong] [varchar](20) NULL,
	[LengUnit] [varchar](60) NULL,
	[fillCode] [varchar](80) NULL,
	[conSubid] [varchar](200) NULL,
	[ToFactoryName] [varchar](80) NULL,
	[WCStatus] [varchar](10) NULL,
	[WCER] [varchar](20) NULL,
	[WCdate] [datetime] NULL,
	[chkdate] [datetime] NULL,
	[gankou] [varchar](80) NULL,
	[KHConNo] [varchar](80) NULL,
	[CJJGBiLV] [decimal](18, 2) NULL,
	[IFCK] [varchar](10) NULL,
 CONSTRAINT [PK_JYOrder_Main] PRIMARY KEY CLUSTERED 
(
	[MainId] 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
/****** Object:  Table [dbo].[JYOrder_HuiLV]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrder_HuiLV](
	[HLID] [varchar](50) NOT NULL,
	[filler] [varchar](50) NULL,
	[filltime] [datetime] NULL,
	[BegDate] [datetime] NULL,
	[Enddate] [datetime] NULL,
	[HuiLv] [decimal](18, 4) NULL,
	[note] [varchar](100) NULL,
	[GSType] [varchar](50) NULL,
PRIMARY KEY CLUSTERED 
(
	[HLID] 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
/****** Object:  Table [dbo].[JYOrder_FYMX]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrder_FYMX](
	[FYID] [varchar](70) NOT NULL,
	[FYDate] [datetime] NULL,
	[FYName] [varchar](70) NULL,
	[FYMoney] [decimal](18, 2) NULL,
	[FYHuilv] [decimal](18, 2) NULL,
	[FYRMBMoney] [decimal](18, 2) NULL,
	[FYNote] [varchar](200) NULL,
	[ConMainid] [varchar](50) NULL,
	[strdef1] [varchar](80) NULL,
	[strdef2] [varchar](80) NULL,
	[strdef3] [varchar](80) NULL,
PRIMARY KEY CLUSTERED 
(
	[FYID] 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
/****** Object:  Table [dbo].[JYOrder_ConORD]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrder_ConORD](
	[MainId] [char](20) NULL,
	[SubId] [char](20) NULL,
	[ConMainId] [char](20) NULL,
	[ConSubId] [char](20) NULL,
	[COId] [char](20) NOT NULL,
	[Filler] [varchar](20) NULL,
	[FillTime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[EditTime] [datetime] NULL,
 CONSTRAINT [PK_JYOrder_ConORD] PRIMARY KEY CLUSTERED 
(
	[COId] 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
/****** Object:  Table [dbo].[JYOrder_BaoGuan_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[JYOrder_BaoGuan_Sub](
	[BGId] [char](20) NOT NULL,
	[BSId] [char](20) NOT NULL,
	[C2HSNO] [varchar](40) NULL,
	[C3BGName] [varchar](80) NULL,
	[C4BGQty] [decimal](18, 2) NULL,
	[C5BGUnit] [varchar](20) NULL,
	[C6BGPrice] [decimal](18, 3) NULL,
	[C7BGMoney] [decimal](18, 2) NULL,
	[E1BZQty] [decimal](18, 0) NULL,
	[E1BZUnit] [varchar](20) NULL,
	[E2ChiMaQty] [decimal](18, 2) NULL,
	[E2ChiMaUnit] [varchar](20) NULL,
	[E3MaoZ] [decimal](18, 2) NULL,
	[E4JingZ] [decimal](18, 2) NULL,
	[E5MaiTou] [varchar](40) NULL,
	[YSZhiZaoType] [varchar](40) NULL,
	[YSChenFen] [varchar](80) NULL,
	[YSFuKuan] [decimal](18, 0) NULL,
	[YSPinPai] [varchar](80) NULL,
	[YSShengChanShang] [varchar](80) NULL,
	[SFiller] [varchar](20) NULL,
	[SFilltime] [datetime] NOT NULL,
	[SEditer] [varchar](20) NULL,
	[SEdittime] [datetime] NULL,
	[SStatus] [varchar](20) NULL,
	[SValid] [char](1) NULL,
	[YSRanZhengType] [varchar](40) NULL,
	[ZheSuanMiQty] [decimal](18, 2) NULL,
	[C3BGNameEng] [varchar](80) NULL,
	[XHInt] [int] NULL,
 CONSTRAINT [PK_JYOrder_BaoGuan_Sub] PRIMARY KEY CLUSTERED 
(
	[BSId] 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
/****** Object:  Table [dbo].[JYOrder_BaoGuan_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JYOrder_BaoGuan_Main](
	[BGId] [char](20) NOT NULL,
	[A1ChuKouShang] [varchar](80) NULL,
	[A2ShuiHao] [varchar](40) NULL,
	[A3HaiGuanBM] [varchar](40) NULL,
	[A4FPNO] [varchar](40) NULL,
	[A5ConNO] [varchar](40) NULL,
	[A6PONO] [varchar](40) NULL,
	[A7FPDate] [datetime] NULL,
	[B1HangBan] [varchar](40) NULL,
	[B2TiDanHao] [varchar](40) NULL,
	[B3KaiHangDate] [datetime] NULL,
	[B4XiangNO] [varchar](40) NULL,
	[B5HuoGui] [varchar](40) NULL,
	[B6ChuYunGang] [varchar](40) NULL,
	[B7DaoHuoGang] [varchar](40) NULL,
	[B8MaoYiGuo] [varchar](40) NULL,
	[B9DiYunGuo] [varchar](40) NULL,
	[B10YunShuType] [varchar](40) NULL,
	[D1HuoYunDiJN] [varchar](40) NULL,
	[D2MaoYiType] [varchar](40) NULL,
	[D3JiHuiType] [varchar](40) NULL,
	[F1BaoGuanTK] [varchar](40) NULL,
	[F2YunFee] [decimal](18, 2) NULL,
	[F3BaoFee] [decimal](18, 2) NULL,
	[F4HuoYunDaiLi] [varchar](40) NULL,
	[F5ChuanGongSi] [varchar](40) NULL,
	[Note] [varchar](200) NULL,
	[C7BGMoneyHZ] [decimal](18, 2) NULL,
	[E1BZQtyHZ] [decimal](18, 0) NULL,
	[E2ChiMaQtyHZ] [decimal](18, 2) NULL,
	[E3MaoZHZ] [decimal](18, 2) NULL,
	[E4JingZHZ] [decimal](18, 2) NULL,
	[Chker] [varchar](20) NULL,
	[ChkTime] [datetime] NULL,
	[ChkStatus] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[FillerCode] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[EditerCode] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NULL,
	[EditCount] [int] NULL,
	[SSTime] [datetime] NULL,
	[SChker] [varchar](20) NULL,
	[OKTime] [datetime] NULL,
	[OKPerson] [varchar](20) NULL,
	[OKFlag] [bit] NOT NULL,
	[HTDate] [datetime] NULL,
	[KHName] [varchar](200) NULL,
 CONSTRAINT [PK_JYOrder_BaoGuan_Main] PRIMARY KEY CLUSTERED 
(
	[BGId] 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
/****** Object:  Table [dbo].[JYCon_Sub_AnPai]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[JYCon_Sub_AnPai](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[APID] [char](20) NOT NULL,
	[APDate] [datetime] NULL,
	[CarNo] [varchar](20) NULL,
	[SCPerson] [varchar](20) NULL,
	[ZhuanQty] [decimal](18, 0) NOT NULL,
	[JYFlag] [bit] NOT NULL,
	[PRTFlag] [bit] NOT NULL,
	[PRTFlagTwo] [bit] NOT NULL,
	[PRTDateTwo] [datetime] NULL,
	[PRTDateTwoPerson] [varchar](20) NULL,
	[PRTCount] [decimal](18, 0) NOT NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[AStatus] [varchar](20) NULL,
	[AValid] [char](1) NOT NULL,
	[JGPrice] [decimal](18, 2) NOT NULL,
	[ZhuanOne] [decimal](18, 0) NULL,
	[APXH] [int] NULL,
 CONSTRAINT [PK_JYCon_Sub_AnPai] PRIMARY KEY CLUSTERED 
(
	[APID] 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
/****** Object:  Table [dbo].[JF_Material]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JF_Material](
	[MNumber] [char](20) NOT NULL,
	[Mname] [nvarchar](30) NOT NULL,
	[Model] [nvarchar](40) NULL,
	[InvSortcode] [char](12) NULL,
	[primaryUnitName] [varchar](20) NULL,
	[PurUnitName] [varchar](20) NULL,
	[PurInvCon1] [decimal](18, 6) NULL,
	[PurInvCon2] [decimal](18, 6) NULL,
	[WhCode] [char](10) NULL,
	[Cess] [decimal](18, 0) NOT NULL,
	[Factory] [char](20) NULL,
	[StopFlag] [bit] NOT NULL,
	[Note] [varchar](100) NULL,
 CONSTRAINT [PK_FX_Material] PRIMARY KEY CLUSTERED 
(
	[MNumber] 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
/****** Object:  Table [dbo].[JF_KcNow]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[JF_KcNow](
	[NowQuanId] [int] NOT NULL,
	[WhCode] [char](10) NOT NULL,
	[MNumber] [char](20) NOT NULL,
	[MArea] [char](20) NOT NULL,
	[Factory] [char](20) NULL,
	[FactoryName] [varchar](60) NULL,
	[BatchNum] [nvarchar](20) NOT NULL,
	[EndQuan] [decimal](18, 6) NOT NULL,
	[SafeQuan] [decimal](18, 6) NOT NULL,
	[FzEndQuan] [decimal](18, 2) NULL,
	[HighQuan] [decimal](18, 6) NOT NULL,
	[LowQuan] [decimal](18, 6) NOT NULL,
	[InventState] [char](4) NOT NULL,
	[Price] [decimal](18, 4) NOT NULL,
	[kcPrice] [decimal](18, 4) NOT NULL,
	[P_Color] [varchar](60) NULL,
	[Note] [varchar](100) NULL,
	[Grade] [varchar](20) NULL,
	[Fstr1] [varchar](20) NULL,
	[Fstr2] [varchar](20) NULL,
	[Fstr3] [varchar](20) NULL,
 CONSTRAINT [PK_JF_KcNow] PRIMARY KEY CLUSTERED 
(
	[NowQuanId] 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
/****** Object:  UserDefinedFunction [dbo].[getPinYin]    Script Date: 12/17/2021 15:51:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create FUNCTION [dbo].[getPinYin](@HZ NVARCHAR(4000))
RETURNS NVARCHAR(4000)
AS
BEGIN
DECLARE @word NCHAR(1)
DECLARE @PY NVARCHAR(4000)
SET @PY = ''
WHILE LEN(@HZ) > 0
  BEGIN
   SET @word = LEFT(@HZ,1)
   SET @PY = @PY + (CASE WHEN UNICODE(@word) BETWEEN 19968 AND 19968+20901
                        THEN (SELECT  TOP 1 PY 
                              FROM ( select 'A' as PY,N'驁' as word 
          union all select 'B',N'簿' 
          union all select 'C',N'錯' 
          union all select 'D',N'鵽' 
          union all select 'E',N'樲' 
          union all select 'F',N'鰒' 
          union all select 'G',N'腂' 
          union all select 'H',N'夻' 
          union all select 'J',N'攈' 
          union all select 'K',N'穒' 
          union all select 'L',N'鱳' 
          union all select 'M',N'旀' 
          union all select 'N',N'桛' 
          union all select 'O',N'漚' 
          union all select 'P',N'曝' 
          union all select 'Q',N'囕' 
          union all select 'R',N'鶸' 
          union all select 'S',N'蜶' 
          union all select 'T',N'籜' 
          union all select 'W',N'鶩' 
          union all select 'X',N'鑂' 
          union all select 'Y',N'韻' 
          union all select 'Z',N'咗' 
                                   ) T  
                               WHERE  word>=@word collate Chinese_PRC_CS_AS_KS_WS 
                               order by PY ASC) 
                           ELSE @word
                           END
                            )
     SET @HZ = RIGHT(@HZ,LEN(@HZ)-1)
  END
  RETURN @PY
END
GO
/****** Object:  Table [dbo].[CP_YDang_MTBJ_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[CP_YDang_MTBJ_Sub](
	[Mainid] [varchar](30) NOT NULL,
	[Subid] [varchar](30) NOT NULL,
	[YPName] [varchar](50) NULL,
	[PRTCode] [varchar](40) NULL,
	[PRTCodeName] [varchar](50) NULL,
	[PRTSpec] [decimal](18, 2) NULL,
	[PRTCF] [varchar](40) NULL,
	[PRTMF] [varchar](40) NULL,
	[PRTKZ] [decimal](18, 2) NULL,
	[PRTColor] [varchar](40) NULL,
	[EPRTColor] [varchar](40) NULL,
	[PRTOrderQty] [decimal](18, 2) NOT NULL,
	[OrderUnit] [varchar](40) NULL,
	[BJPrice] [decimal](18, 2) NOT NULL,
	[BJEPrice] [decimal](18, 2) NOT NULL,
	[PriceUnit] [varchar](40) NULL,
	[Note] [varchar](1000) NULL,
	[SOrdQty1] [decimal](18, 2) NOT NULL,
	[SOrdQty2] [decimal](18, 2) NOT NULL,
	[SOrdQty3] [decimal](18, 2) NOT NULL,
	[SOrdQty4] [decimal](18, 2) NOT NULL,
	[SOrddefstr1] [varchar](50) NULL,
	[SOrddefstr2] [varchar](50) NULL,
	[SOrddefstr3] [varchar](50) NULL,
	[SOrddefstr4] [varchar](50) NULL,
	[SOrddefstr5] [varchar](50) NULL,
	[SOrdQty5] [decimal](18, 2) NOT NULL,
	[SOrdQty6] [decimal](18, 2) NOT NULL,
	[SOrdQty7] [decimal](18, 2) NOT NULL,
	[SOrdQty8] [decimal](18, 2) NOT NULL,
	[SOrdQty9] [decimal](18, 2) NOT NULL,
	[SOrdQty10] [decimal](18, 2) NOT NULL,
	[SOrdQty11] [decimal](18, 2) NOT NULL,
	[SOrdQty12] [decimal](18, 2) NOT NULL,
	[SOrdQty13] [decimal](18, 2) NOT NULL,
	[BJXS] [decimal](18, 2) NOT NULL,
	[CBPrice] [decimal](18, 2) NOT NULL,
	[PBMF] [decimal](18, 2) NOT NULL,
	[PBKZ] [decimal](18, 2) NOT NULL,
	[PBSPEC] [varchar](50) NULL,
	[SOrdQty14] [decimal](18, 2) NOT NULL,
	[SOrdQty15] [decimal](18, 2) NOT NULL,
	[HuiLv] [decimal](18, 2) NOT NULL,
	[QDLQty] [decimal](18, 2) NOT NULL,
	[PBFK] [decimal](18, 2) NULL,
	[JQDate] [datetime] NULL,
	[HCPrice] [decimal](18, 2) NULL,
	[PBPrice] [decimal](18, 2) NULL,
PRIMARY KEY CLUSTERED 
(
	[Subid] 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
/****** Object:  Table [dbo].[CP_YDang_MTBJ_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CP_YDang_MTBJ_Main](
	[Mainid] [varchar](30) NOT NULL,
	[CustomerNoName] [varchar](30) NULL,
	[Chker] [varchar](30) NULL,
	[chktime] [datetime] NULL,
	[filler] [varchar](20) NULL,
	[filltime] [datetime] NULL,
	[status] [varchar](10) NULL,
	[ConPerson1] [varchar](40) NULL,
	[ConPerson2] [varchar](40) NULL,
	[ConPerson3] [varchar](40) NULL,
	[ConPerson4] [varchar](40) NULL,
	[Sdefstr1] [varchar](200) NULL,
	[Sdefstr2] [varchar](200) NULL,
	[Sdefstr3] [varchar](200) NULL,
	[Sdefstr4] [varchar](200) NULL,
	[BJNote] [varchar](1000) NULL,
	[BJtime] [datetime] NULL,
	[SQdate] [datetime] NULL,
	[CustomerNo] [varchar](30) NULL,
	[YWTel] [varchar](50) NULL,
PRIMARY KEY CLUSTERED 
(
	[Mainid] 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
/****** Object:  Table [dbo].[CP_YDang_KHGet]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CP_YDang_KHGet](
	[CYID] [char](20) NOT NULL,
	[CKID] [char](20) NOT NULL,
	[KHName] [varchar](40) NULL,
	[CKDate] [datetime] NULL,
	[CKPrice] [decimal](18, 2) NOT NULL,
	[CKBZ] [varchar](20) NULL,
	[CKValid] [char](1) NOT NULL,
	[CKNote] [varchar](200) NULL,
	[DefStr1] [varchar](20) NULL,
	[DefStr2] [varchar](20) NULL,
	[DefStr3] [varchar](20) NULL,
	[DefFlt1] [decimal](18, 2) NOT NULL,
	[DefFlt2] [decimal](18, 2) NOT NULL,
	[DefFlt3] [decimal](18, 2) NOT NULL,
	[DefFlt4] [int] NOT NULL,
	[Filler] [varchar](20) NULL,
	[FillTime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[EditTime] [datetime] NOT NULL,
 CONSTRAINT [PK_CP_YDang_KHGet] PRIMARY KEY CLUSTERED 
(
	[CKID] 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
/****** Object:  Table [dbo].[CP_YDang_BJ_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[CP_YDang_BJ_Sub](
	[Mainid] [varchar](30) NOT NULL,
	[Subid] [varchar](30) NOT NULL,
	[YPName] [varchar](50) NULL,
	[PRTCode] [varchar](40) NULL,
	[PRTCodeName] [varchar](50) NULL,
	[PRTSpec] [varchar](60) NULL,
	[PRTCF] [varchar](40) NULL,
	[PRTMF] [varchar](40) NULL,
	[PRTKZ] [varchar](40) NULL,
	[PRTColor] [varchar](40) NULL,
	[EPRTColor] [varchar](40) NULL,
	[PRTOrderQty] [decimal](18, 2) NOT NULL,
	[OrderUnit] [varchar](40) NULL,
	[BJPrice] [decimal](18, 2) NOT NULL,
	[BJEPrice] [decimal](18, 2) NOT NULL,
	[PriceUnit] [varchar](40) NULL,
	[Note] [varchar](1000) NULL,
	[SOrdQty1] [decimal](18, 2) NOT NULL,
	[SOrdQty2] [decimal](18, 2) NOT NULL,
	[SOrdQty3] [decimal](18, 2) NOT NULL,
	[SOrdQty4] [decimal](18, 2) NOT NULL,
	[SOrddefstr1] [varchar](50) NULL,
	[SOrddefstr2] [varchar](50) NULL,
	[SOrddefstr3] [varchar](50) NULL,
	[SOrddefstr4] [varchar](50) NULL,
	[SOrddefstr5] [varchar](50) NULL,
	[SOrdQty5] [decimal](18, 2) NOT NULL,
	[SOrdQty6] [decimal](18, 2) NOT NULL,
	[SOrdQty7] [decimal](18, 2) NOT NULL,
	[SOrdQty8] [decimal](18, 2) NOT NULL,
	[SOrdQty9] [decimal](18, 2) NOT NULL,
	[SOrdQty10] [decimal](18, 2) NOT NULL,
	[SOrdQty11] [decimal](18, 2) NOT NULL,
	[SOrdQty12] [decimal](18, 2) NOT NULL,
	[SOrdQty13] [decimal](18, 2) NOT NULL,
	[BJXS] [decimal](18, 2) NOT NULL,
	[CBPrice] [decimal](18, 2) NOT NULL,
	[PBMF] [decimal](18, 2) NOT NULL,
	[PBKZ] [decimal](18, 2) NOT NULL,
	[PBSPEC] [varchar](50) NULL,
	[SOrdQty14] [decimal](18, 2) NOT NULL,
	[SOrdQty15] [decimal](18, 2) NOT NULL,
	[HuiLv] [decimal](18, 2) NOT NULL,
	[QDLQty] [decimal](18, 2) NOT NULL,
	[PBFK] [decimal](18, 2) NULL,
	[JQDate] [datetime] NULL,
	[HCPrice] [decimal](18, 2) NULL,
	[PBPrice] [decimal](18, 2) NULL,
PRIMARY KEY CLUSTERED 
(
	[Subid] 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
/****** Object:  Table [dbo].[CP_YDang_BJ_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CP_YDang_BJ_Main](
	[Mainid] [varchar](30) NOT NULL,
	[CustomerNoName] [varchar](30) NULL,
	[Chker] [varchar](30) NULL,
	[chktime] [datetime] NULL,
	[filler] [varchar](20) NULL,
	[filltime] [datetime] NULL,
	[status] [varchar](10) NULL,
	[ConPerson1] [varchar](40) NULL,
	[ConPerson2] [varchar](40) NULL,
	[ConPerson3] [varchar](40) NULL,
	[ConPerson4] [varchar](40) NULL,
	[Sdefstr1] [varchar](200) NULL,
	[Sdefstr2] [varchar](200) NULL,
	[Sdefstr3] [varchar](200) NULL,
	[Sdefstr4] [varchar](200) NULL,
	[BJNote] [varchar](1000) NULL,
	[BJtime] [datetime] NULL,
	[SQdate] [datetime] NULL,
	[CustomerNo] [varchar](30) NULL,
	[YWTel] [varchar](50) NULL,
PRIMARY KEY CLUSTERED 
(
	[Mainid] 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
/****** Object:  Table [dbo].[CP_YDang]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CP_YDang](
	[CYID] [char](20) NOT NULL,
	[CYNo] [varchar](100) NULL,
	[CYName] [varchar](200) NULL,
	[CYEName] [varchar](200) NULL,
	[CYSpec] [varchar](200) NULL,
	[CYCF] [varchar](200) NULL,
	[CYECF] [varchar](200) NULL,
	[CYType] [varchar](50) NULL,
	[CYColor] [varchar](100) NULL,
	[CYMF] [varchar](50) NULL,
	[CYKZ] [varchar](50) NULL,
	[CYPrice] [decimal](18, 2) NOT NULL,
	[CYPUnit] [varchar](20) NULL,
	[CYValid] [char](2) NOT NULL,
	[CYNote] [varchar](200) NULL,
	[TPFlag] [bit] NOT NULL,
	[CYHX] [varchar](100) NULL,
	[CYColorEng] [varchar](100) NULL,
	[CYPriceM] [decimal](18, 2) NOT NULL,
	[CYPriceKg] [decimal](18, 2) NOT NULL,
	[DefStr1] [varchar](100) NULL,
	[DefStr2] [varchar](100) NULL,
	[DefStr3] [varchar](100) NULL,
	[DefStr4] [varchar](100) NULL,
	[DefStr5] [varchar](100) NULL,
	[DefNote1] [varchar](200) NULL,
	[DefNote2] [varchar](200) NULL,
	[DefNote3] [varchar](200) NULL,
	[DefNote4] [varchar](200) NULL,
	[DefNote5] [varchar](200) NULL,
	[Price1] [decimal](18, 2) NOT NULL,
	[Price2] [decimal](18, 2) NOT NULL,
	[Price3] [decimal](18, 2) NOT NULL,
	[Price4] [decimal](18, 2) NOT NULL,
	[Price5] [decimal](18, 2) NOT NULL,
	[Price6] [decimal](18, 2) NOT NULL,
	[Price7] [decimal](18, 2) NOT NULL,
	[Price8] [decimal](18, 2) NOT NULL,
	[Price9] [decimal](18, 2) NOT NULL,
	[Price10] [decimal](18, 2) NOT NULL,
	[PBMF] [varchar](30) NULL,
	[PBKZ] [varchar](30) NULL,
	[DefStr6] [varchar](200) NULL,
	[DefStr7] [varchar](200) NULL,
	[DefStr8] [varchar](200) NULL,
	[DefStr9] [varchar](200) NULL,
	[DefStr10] [varchar](200) NULL,
	[DefStr11] [varchar](200) NULL,
	[DefStr12] [varchar](200) NULL,
	[DefStr13] [varchar](200) NULL,
	[KHName] [varchar](50) NULL,
	[LXTel] [varchar](50) NULL,
	[GongYi] [varchar](100) NULL,
	[TiaoZhong] [varchar](100) NULL,
	[FKNote] [varchar](100) NULL,
	[SKJiLu] [varchar](100) NULL,
	[FKJiLu] [varchar](100) NULL,
	[ZMoney] [varchar](100) NULL,
	[KHQQ] [varchar](50) NULL,
	[KHWeiXin] [varchar](50) NULL,
	[KHEmail] [varchar](50) NULL,
	[KHWangWang] [varchar](50) NULL,
	[KHAdd] [varchar](50) NULL,
	[FJFlag] [bit] NULL,
 CONSTRAINT [PK_CP_YDang] PRIMARY KEY CLUSTERED 
(
	[CYID] 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
/****** Object:  Table [dbo].[CP_Type]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CP_Type](
	[CPID] [char](20) NOT NULL,
	[CPNo] [char](20) NOT NULL,
	[CPName] [varchar](40) NOT NULL,
	[CPParent] [char](20) NOT NULL,
	[CPLevel] [int] NULL,
	[Valid] [char](1) NOT NULL,
	[CPOrder] [int] NOT NULL,
	[DefStr1] [varchar](20) NULL,
	[DefStr2] [varchar](20) NULL,
	[DefStr3] [varchar](20) NULL,
 CONSTRAINT [PK_CP_Type] PRIMARY KEY CLUSTERED 
(
	[CPID] 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
/****** Object:  StoredProcedure [dbo].[P_Label_PrintSet]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--功能：获取样品打印标签用
--著者：李
--时间：2009-07-23
CREATE         PROCEDURE [dbo].[P_Label_PrintSet]
  @splcode  varchar(30)=''
AS
BEGIN
  SELECT A.TmId as BarCode,
         A.JH as 卷号,
         A.OrderNo as 订单号,
         A.CPCode as 品名编号,
         A.CPName as 品名,
         A.Color as 颜色,
         A.GangNo as 缸号,
         A.HX as 花型,
         A.MF1 as 门幅上限,
         A.MF2 as 门幅下限,
         A.MFunit as 门幅单位,
         A.KZ1   as 克重上限,
         A.KZ2   as 克重下限,
         A.KZUnit as 克重单位,
         A.QtyMi as 米数,
	 A.QtyMa as 码数,
	 A.QtyJZ as 公斤,
         A.QtyMZ as 毛重,
         A.QtyPZ as 皮重,
      CASE
         WHEN (A.MF1 > 0 AND A.MF2 > 0) THEN CAST(CAST(A.MF1 AS FLOAT) AS VARCHAR) + '-' + CAST(CAST(A.MF1 AS FLOAT) AS VARCHAR) + A.MFunit
         WHEN A.MF1 > 0 THEN  CAST(CAST(A.MF1 AS FLOAT) AS VARCHAR) + A.MFunit
         WHEN A.MF2 > 0 THEN CAST(CAST(A.MF2 AS FLOAT) AS VARCHAR)+ A.MFunit
         ELSE ''
       END AS 门幅,
       CASE
         WHEN (A.KZ1 > 0 AND A.KZ2 > 0) THEN CAST(CAST(A.KZ1 AS FLOAT) AS VARCHAR) + '-' +CAST(CAST(A.KZ2 AS FLOAT) AS VARCHAR) + A.KZUnit
         WHEN A.KZ1 > 0 THEN  CAST(CAST(A.KZ1 AS FLOAT) AS VARCHAR) + A.KZUnit
         WHEN A.KZ2 > 0 THEN  CAST(CAST(A.KZ2 AS FLOAT) AS VARCHAR)+ A.KZUnit
         ELSE ''
       END AS 克重                 
   from CP_JY A
   WHERE rtrim(A.TmId)=@splcode


END
GO
/****** Object:  Table [dbo].[CP_InOut_MX]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[CP_InOut_MX](
	[CRNO] [varchar](20) NULL,
	[CRID] [int] NULL,
	[MJID] [varchar](20) NOT NULL,
	[MJXH] [varchar](20) NOT NULL,
	[RollNum] [decimal](18, 2) NOT NULL,
	[Qty] [decimal](18, 2) NOT NULL,
	[QtyUnit] [varchar](20) NULL,
 CONSTRAINT [FK_CP_InOut_MX] PRIMARY KEY CLUSTERED 
(
	[MJID] ASC,
	[MJXH] 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
/****** Object:  Table [dbo].[CP_InOut]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CP_InOut](
	[CRNO] [varchar](20) NOT NULL,
	[CRID] [int] NOT NULL,
	[CKName] [varchar](20) NULL,
	[MainId] [char](20) NULL,
	[SubId] [char](20) NULL,
	[CRTime] [datetime] NULL,
	[CRFlag] [varchar](20) NULL,
	[CRType] [varchar](20) NULL,
	[KCID] [int] NULL,
	[MJID] [varchar](20) NULL,
	[MJXH] [varchar](20) NULL,
	[CPType] [varchar](20) NULL,
	[P_Code] [varchar](20) NULL,
	[P_CodeName] [varchar](60) NULL,
	[P_spec] [varchar](20) NULL,
	[P_MF] [decimal](18, 2) NOT NULL,
	[P_KZ] [decimal](18, 2) NOT NULL,
	[P_Color] [varchar](20) NULL,
	[RollNum] [decimal](18, 2) NOT NULL,
	[Qty] [decimal](18, 2) NOT NULL,
	[QtyUnit] [varchar](20) NULL,
	[note] [varchar](200) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valid] [varchar](5) NOT NULL,
	[FromMainID] [varchar](20) NULL,
	[FromSubID] [varchar](20) NULL,
	[Price] [decimal](18, 3) NOT NULL,
	[Money] [decimal](18, 2) NOT NULL,
	[InOutNo] [varchar](20) NULL,
	[CustNo] [varchar](20) NULL,
	[CustName] [varchar](20) NULL,
	[ToCustNo] [varchar](20) NULL,
	[ToCustName] [varchar](20) NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[CP_InOut] ADD [IsYjx] [varchar](20) NULL
ALTER TABLE [dbo].[CP_InOut] ADD [YjxYG] [varchar](20) NULL
ALTER TABLE [dbo].[CP_InOut] ADD [Yjxdate] [datetime] NULL
ALTER TABLE [dbo].[CP_InOut] ADD [PackFee] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[CP_InOut] ADD [YbFee] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[CP_InOut] ADD [OtherFee] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[CP_InOut] ADD [XjNum] [decimal](18, 2) NOT NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[CP_InOut] ADD [status] [varchar](10) NOT NULL
ALTER TABLE [dbo].[CP_InOut] ADD [FHAddress] [varchar](100) NULL
ALTER TABLE [dbo].[CP_InOut] ADD [LXFS] [varchar](100) NULL
ALTER TABLE [dbo].[CP_InOut] ADD [IsTax] [bit] NOT NULL
ALTER TABLE [dbo].[CP_InOut] ADD  CONSTRAINT [PK_CP_InOut] PRIMARY KEY CLUSTERED 
(
	[CRNO] ASC,
	[CRID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ContractSX_Sub_Mx]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ContractSX_Sub_Mx](
	[SubId] [char](20) NOT NULL,
	[MxId] [char](20) NOT NULL,
	[ComeDate] [datetime] NULL,
	[BatchNo] [char](20) NULL,
	[MxQty] [decimal](18, 2) NOT NULL,
	[Qty1] [decimal](18, 2) NOT NULL,
	[Qty2] [decimal](18, 2) NOT NULL,
	[Qty3] [decimal](18, 2) NOT NULL,
	[MxUnit] [varchar](20) NULL,
	[MxNote] [varchar](200) NULL,
	[MxValid] [char](1) NOT NULL,
	[RKPlace] [varchar](40) NULL,
	[FZUnit] [varchar](20) NULL,
	[KCID] [int] NOT NULL,
	[RKPLCode] [varchar](40) NULL,
	[MXMQty] [decimal](18, 2) NOT NULL,
	[MXPrice] [decimal](18, 2) NOT NULL,
	[DHType] [varchar](20) NULL,
	[QJGDHID] [varchar](20) NULL,
 CONSTRAINT [PK_ContractSX_Sub_Mx] PRIMARY KEY CLUSTERED 
(
	[SubId] ASC,
	[MxId] 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
/****** Object:  Table [dbo].[ContractSX_Sub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ContractSX_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[ConNo] [char](20) NULL,
	[XHNo] [char](20) NULL,
	[C_Code] [char](20) NULL,
	[C_CodeName] [varchar](50) NULL,
	[C_Spec] [varchar](40) NULL,
	[C_Color] [varchar](20) NULL,
	[MF] [varchar](20) NULL,
	[KZ] [varchar](20) NULL,
	[C_Qty] [decimal](18, 2) NOT NULL,
	[C_Unit] [varchar](20) NULL,
	[Price] [decimal](18, 2) NOT NULL,
	[PriceUnit] [varchar](20) NULL,
	[MFUnit] [varchar](20) NULL,
	[KZUnit] [varchar](20) NULL,
	[Qty1] [decimal](18, 2) NOT NULL,
	[Qty2] [decimal](18, 2) NOT NULL,
	[Qty3] [decimal](18, 2) NOT NULL,
	[MainUnit] [varchar](20) NULL,
	[C_Status] [varchar](20) NULL,
	[C_Valid] [char](1) NOT NULL,
	[C_Note] [varchar](200) NULL,
	[MFQty] [decimal](18, 2) NULL,
	[KZQty] [decimal](18, 2) NULL,
	[MQty] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_ContractSX_Sub] PRIMARY KEY CLUSTERED 
(
	[MainId] ASC,
	[SubId] 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
/****** Object:  Table [dbo].[ContractSX_Main]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ContractSX_Main](
	[MainId] [char](20) NOT NULL,
	[ConNo] [char](20) NOT NULL,
	[ClothCode] [char](20) NULL,
	[ClothCodeName] [char](20) NULL,
	[QDTime] [datetime] NULL,
	[QDPalce] [varchar](200) NULL,
	[DeliveryDate] [datetime] NULL,
	[FactoryNo] [char](60) NULL,
	[FactoryNoName] [char](60) NULL,
	[CompanyName] [char](60) NULL,
	[ConTK1] [varchar](200) NULL,
	[ConTK2] [varchar](200) NULL,
	[ConTK3] [varchar](200) NULL,
	[ConTK4] [varchar](200) NULL,
	[ConTK5] [varchar](200) NULL,
	[ConTK6] [varchar](200) NULL,
	[ConTK7] [varchar](200) NULL,
	[ConTK8] [varchar](200) NULL,
	[ConTK9] [varchar](200) NULL,
	[ConTK10] [varchar](200) NULL,
	[Note] [varchar](250) NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NOT NULL,
	[LXPerson] [varchar](20) NULL,
	[LXTel] [varchar](20) NULL,
	[JHPlace] [varchar](40) NULL,
 CONSTRAINT [PK_ContractSX_Main] PRIMARY KEY CLUSTERED 
(
	[MainId] 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
/****** Object:  Table [dbo].[ContractSX_Cloth_LLMx]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ContractSX_Cloth_LLMx](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[DHId] [char](20) NOT NULL,
	[MXId] [char](20) NOT NULL,
	[OrdSubId] [char](20) NULL,
	[TPQty] [decimal](18, 2) NOT NULL,
	[SXQty] [decimal](18, 2) NOT NULL,
	[SXMQty] [decimal](18, 2) NOT NULL,
	[SXPS] [decimal](18, 0) NOT NULL,
	[ZSXS] [decimal](18, 2) NOT NULL,
	[SXUnit] [varchar](20) NULL,
	[PBName] [varchar](40) NULL,
	[PBSpec] [varchar](40) NULL,
	[PBMF] [decimal](18, 2) NOT NULL,
	[PBKZ] [decimal](18, 2) NOT NULL,
	[TPUnit] [varchar](20) NULL,
	[TPDate] [datetime] NULL,
	[TPNote] [varchar](200) NULL,
	[TPPerson] [varchar](20) NULL,
	[ToValid] [char](1) NOT NULL,
	[Qty1] [decimal](18, 2) NOT NULL,
	[Qty2] [decimal](18, 2) NOT NULL,
	[Qty3] [decimal](18, 2) NOT NULL,
	[TPPS] [decimal](18, 0) NOT NULL,
	[HCID] [varchar](20) NULL,
	[HCQty] [decimal](18, 2) NOT NULL,
	[HCPS] [decimal](18, 0) NOT NULL,
	[TPMQty] [decimal](18, 2) NOT NULL,
	[MQty2] [decimal](18, 2) NOT NULL,
	[TPYZQty] [decimal](18, 2) NOT NULL,
	[YZQty2] [decimal](18, 2) NOT NULL,
	[ToNo] [varchar](40) NULL,
	[ToName] [varchar](40) NULL,
	[JGPrice] [decimal](18, 2) NOT NULL,
	[GangFee] [decimal](18, 2) NOT NULL,
	[HCFlag] [bit] NOT NULL,
 CONSTRAINT [PK_ContractSX_Cloth_LLMx] PRIMARY KEY CLUSTERED 
(
	[MXId] 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
/****** Object:  Table [dbo].[ContractSX_Cloth_LL]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[ContractSX_Cloth_LL](
	[DHId] [char](20) NULL,
	[OrdSubId] [char](20) NULL,
	[LLId] [char](20) NOT NULL,
	[TPPS] [decimal](18, 0) NOT NULL,
	[BCPQty] [decimal](18, 2) NOT NULL,
	[TPQty] [decimal](18, 2) NOT NULL,
	[TPUnit] [varchar](20) NULL,
	[HCQty] [decimal](18, 2) NOT NULL,
	[HCPS] [decimal](18, 0) NOT NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [FirstNo] [varchar](40) NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [FirstName] [varchar](40) NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [LLIdx] [decimal](18, 0) NOT NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [TPMQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [BCPMQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [HCMQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [HXPS] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [HXQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [HXMQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [HXUnit] [varchar](20) NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [ToNo] [varchar](40) NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [ToName] [varchar](40) NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [JXJGFlag] [bit] NOT NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD [DHIDHelp] [varchar](20) NULL
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  CONSTRAINT [PK_ContractSX_Cloth_LL] PRIMARY KEY CLUSTERED 
(
	[LLId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ContractSX_Cloth_DH]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ContractSX_Cloth_DH](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[DHId] [char](20) NOT NULL,
	[FirstNo] [varchar](40) NULL,
	[FirstName] [varchar](40) NULL,
	[BatchNo] [varchar](20) NULL,
	[DHQty] [decimal](18, 2) NOT NULL,
	[DHUnit] [varchar](20) NULL,
	[TPQtyHZ] [decimal](18, 2) NOT NULL,
	[Qty1] [decimal](18, 2) NOT NULL,
	[Qty2] [decimal](18, 2) NOT NULL,
	[Qty3] [decimal](18, 2) NOT NULL,
	[DHStatus] [varchar](20) NULL,
	[DHValid] [char](1) NOT NULL,
	[DHNote] [varchar](200) NULL,
	[DHPS] [decimal](18, 0) NOT NULL,
	[TPPSHZ] [decimal](18, 0) NOT NULL,
	[DHMQty] [decimal](18, 2) NOT NULL,
	[TPMQtyHZ] [decimal](18, 2) NOT NULL,
	[DHType] [varchar](20) NULL,
	[QJGDHID] [varchar](20) NULL,
 CONSTRAINT [PK_ContractSX_Cloth_DH] PRIMARY KEY CLUSTERED 
(
	[DHId] 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
/****** Object:  Table [dbo].[ContractHZ_Sub]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ContractHZ_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[XHNo] [char](20) NULL,
	[C_Code] [char](20) NULL,
	[C_CodeName] [varchar](50) NULL,
	[C_Spec] [varchar](40) NULL,
	[C_Color] [varchar](20) NULL,
	[MF] [varchar](20) NULL,
	[KZ] [varchar](20) NULL,
	[C_Qty] [decimal](18, 2) NOT NULL,
	[C_Unit] [varchar](20) NULL,
	[Price] [decimal](18, 2) NOT NULL,
	[PriceUnit] [varchar](20) NULL,
	[MFUnit] [varchar](20) NULL,
	[KZUnit] [varchar](20) NULL,
	[Qty1] [decimal](18, 2) NOT NULL,
	[Qty2] [decimal](18, 2) NOT NULL,
	[Qty3] [decimal](18, 2) NOT NULL,
	[MainUnit] [varchar](20) NULL,
	[C_Status] [varchar](20) NULL,
	[C_Valid] [char](1) NOT NULL,
	[C_Note] [varchar](200) NULL,
	[MFQty] [decimal](18, 2) NULL,
	[KZQty] [decimal](18, 2) NULL,
	[MQty] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_ContractHZ_Sub] PRIMARY KEY CLUSTERED 
(
	[MainId] ASC,
	[SubId] 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
/****** Object:  Table [dbo].[ContractHZ_Main]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[ContractHZ_Main](
	[MainId] [char](20) NOT NULL,
	[ConNo] [char](20) NOT NULL,
	[ClothCode] [char](20) NULL,
	[ClothCodeName] [char](20) NULL,
	[QDTime] [datetime] NULL,
	[QDPalce] [varchar](200) NULL,
	[ConType] [varchar](20) NULL,
	[DeliveryDate] [datetime] NULL,
	[FactoryNo] [char](60) NULL,
	[FactoryNoName] [char](60) NULL,
	[CompanyName] [char](60) NULL,
	[ConTK1] [varchar](200) NULL,
	[ConTK2] [varchar](200) NULL,
	[ConTK3] [varchar](200) NULL,
	[ConTK4] [varchar](200) NULL,
	[ConTK5] [varchar](200) NULL,
	[ConTK6] [varchar](200) NULL,
	[ConTK7] [varchar](200) NULL,
	[ConTK8] [varchar](200) NULL,
	[ConTK9] [varchar](200) NULL,
	[ConTK10] [varchar](200) NULL,
	[Note] [varchar](250) NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NOT NULL,
	[LXPerson] [varchar](20) NULL,
	[LXTel] [varchar](20) NULL,
	[JHPlace] [varchar](40) NULL,
 CONSTRAINT [PK_ContractHZ_Main] PRIMARY KEY CLUSTERED 
(
	[MainId] 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
/****** Object:  Table [dbo].[Contract_Sub_Mxto]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[Contract_Sub_Mxto](
	[MxId] [char](20) NOT NULL,
	[ToId] [char](20) NOT NULL,
	[OrdSubId] [char](20) NULL,
	[TPQty] [decimal](18, 2) NOT NULL,
	[TPDate] [datetime] NULL,
	[TPNote] [varchar](200) NULL,
	[TPPerson] [varchar](20) NULL,
	[ToValid] [char](1) NOT NULL,
	[Qty1] [decimal](18, 2) NOT NULL,
	[Qty2] [decimal](18, 2) NOT NULL,
	[Qty3] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_Contract_Sub_Mxto] PRIMARY KEY CLUSTERED 
(
	[MxId] ASC,
	[ToId] 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
/****** Object:  Table [dbo].[Contract_Sub_Mx]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Contract_Sub_Mx](
	[SubId] [char](20) NOT NULL,
	[MxId] [char](20) NOT NULL,
	[ComeDate] [datetime] NULL,
	[BatchNo] [char](20) NULL,
	[MxQty] [decimal](18, 2) NOT NULL,
	[Qty1] [decimal](18, 2) NOT NULL,
	[Qty2] [decimal](18, 2) NOT NULL,
	[Qty3] [decimal](18, 2) NOT NULL,
	[MxUnit] [varchar](20) NULL,
	[MxNote] [varchar](200) NULL,
	[MxValid] [char](1) NOT NULL,
	[RKPlace] [varchar](40) NULL,
	[FZUnit] [varchar](20) NULL,
	[KCID] [int] NOT NULL,
	[RKPLCode] [varchar](40) NULL,
	[MXMQty] [decimal](18, 2) NOT NULL,
 CONSTRAINT [PK_Contract_Sub_Mx] PRIMARY KEY CLUSTERED 
(
	[SubId] ASC,
	[MxId] 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
/****** Object:  Table [dbo].[Contract_Sub]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[Contract_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[XHNo] [char](20) NULL,
	[C_Code] [char](20) NULL,
	[C_CodeName] [varchar](50) NULL,
	[C_Spec] [varchar](40) NULL,
	[C_Color] [varchar](20) NULL,
	[MF] [varchar](20) NULL,
	[KZ] [varchar](20) NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[Contract_Sub] ADD [MFQty] [varchar](50) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [KZQty] [varchar](50) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [MQty] [decimal](18, 2) NOT NULL
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[Contract_Sub] ADD [Jing] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [Wei] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [ChiMa] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [C_Qty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [PS] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [C_Unit] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [Price] [decimal](18, 4) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [PriceUnit] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [MFUnit] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [KZUnit] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [Qty1] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [Qty2] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [Qty3] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [MainUnit] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [C_Status] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [C_Valid] [char](1) NOT NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [C_Note] [varchar](200) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [C_CF] [varchar](100) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [HBLenStr] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [HBWidthStr] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [JGGY] [varchar](50) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [ConPrice] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [ConUnit] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [ConQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [Gang] [varchar](40) NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[Contract_Sub] ADD [MaChi] [varchar](50) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [PBMoney] [decimal](18, 2) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [IFHX] [varchar](10) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [IFHS] [varchar](10) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [C_ColorEng] [varchar](60) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [C_SeNo] [varchar](60) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [PiZhong] [decimal](18, 2) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [SChker] [varchar](50) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [SChkstatus] [varchar](50) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [SChkdate] [datetime] NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [OrdSubid] [varchar](50) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [OrderNo] [varchar](50) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [IFCK] [varchar](10) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD [CGMoney] [decimal](18, 2) NULL
ALTER TABLE [dbo].[Contract_Sub] ADD  CONSTRAINT [PK_Contract_Sub] PRIMARY KEY CLUSTERED 
(
	[SubId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Contract_Main]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Contract_Main](
	[MainId] [char](20) NOT NULL,
	[ConNo] [char](20) NOT NULL,
	[ConType] [varchar](20) NULL,
	[ClothCode] [char](20) NULL,
	[ClothCodeName] [char](20) NULL,
	[QDTime] [datetime] NULL,
	[QDPalce] [varchar](200) NULL,
	[DLYDate] [datetime] NULL,
	[FactoryNo] [char](60) NULL,
	[FactoryNoName] [char](60) NULL,
	[CompanyNo] [char](60) NULL,
	[CompanyName] [char](60) NULL,
	[ComTel] [varchar](20) NULL,
	[ComFAX] [varchar](20) NULL,
	[ComAddress] [varchar](40) NULL,
	[JieSuanNote] [varchar](200) NULL,
	[PRTZhiLiang] [varchar](200) NULL,
	[FaHuoNote] [varchar](200) NULL,
	[QtyNote] [varchar](200) NULL,
	[JiaoHuoNote] [varchar](200) NULL,
	[PayMent] [varchar](200) NULL,
	[NoKangLiNote] [varchar](500) NULL,
	[WeiYueNote] [varchar](200) NULL,
	[ConTK1] [varchar](200) NULL,
	[ConTK2] [varchar](200) NULL,
	[ConTK3] [varchar](200) NULL,
	[ConTK4] [varchar](200) NULL,
	[ConTK5] [varchar](200) NULL,
	[Note] [varchar](250) NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NOT NULL,
	[ConTypeOther] [varchar](20) NULL,
	[ONID] [varchar](20) NULL,
	[FileFlag] [bit] NOT NULL,
	[JYType] [varchar](20) NULL,
	[JYNote] [varchar](200) NULL,
	[SSTime] [datetime] NULL,
	[SSPerson] [varchar](200) NULL,
	[PChker] [varchar](20) NULL,
	[PChkTime] [datetime] NULL,
	[PChkStatus] [varchar](20) NULL,
	[PChkNote] [varchar](200) NULL,
	[FuZePerson] [varchar](40) NULL,
	[CGNo] [varchar](50) NULL,
	[DDDate] [datetime] NULL,
	[FJNote] [varchar](400) NULL,
	[SQType] [varchar](50) NULL,
	[JGGX] [varchar](50) NULL,
 CONSTRAINT [PK_Contract_Main] PRIMARY KEY CLUSTERED 
(
	[MainId] 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
/****** Object:  Table [dbo].[Contract_Cloth_LLMx]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[Contract_Cloth_LLMx](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[DHId] [char](20) NOT NULL,
	[MXId] [char](20) NOT NULL,
	[OrdSubId] [char](20) NULL,
	[TPQty] [decimal](18, 2) NOT NULL,
	[TPUnit] [varchar](20) NULL,
	[TPDate] [datetime] NULL,
	[TPNote] [varchar](200) NULL,
	[TPPerson] [varchar](20) NULL,
	[ToValid] [char](1) NOT NULL,
	[Qty1] [decimal](18, 2) NOT NULL,
	[Qty2] [decimal](18, 2) NOT NULL,
	[Qty3] [decimal](18, 2) NOT NULL,
	[TPPS] [decimal](18, 2) NOT NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [HCID] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [HCQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [HCPS] [decimal](18, 0) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [TPMQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [MQty2] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [TPYZQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [YZQty2] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [ToNo] [varchar](40) NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [ToName] [varchar](40) NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [JGPrice] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [GangFee] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [HCFlag] [bit] NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [SXMainId] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [SXDHID] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [HJGType] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [BCGangNO] [varchar](30) NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD [RCGangNO] [varchar](30) NULL
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  CONSTRAINT [PK_Contract_Cloth_LLMx] PRIMARY KEY CLUSTERED 
(
	[MXId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Contract_Cloth_LL]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[Contract_Cloth_LL](
	[DHId] [char](20) NULL,
	[OrdSubId] [char](20) NULL,
	[LLId] [char](20) NOT NULL,
	[TPPS] [decimal](18, 0) NOT NULL,
	[BCPQty] [decimal](18, 2) NOT NULL,
	[TPQty] [decimal](18, 2) NOT NULL,
	[TPUnit] [varchar](20) NULL,
	[HCQty] [decimal](18, 2) NOT NULL,
	[HCPS] [decimal](18, 0) NOT NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [FirstNo] [varchar](40) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [FirstName] [varchar](40) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [LLIdx] [decimal](18, 0) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [TPMQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [BCPMQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [HCMQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [HXPS] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [HXQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [HXMQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [HXUnit] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [ToNo] [varchar](40) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [ToName] [varchar](40) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [JXJGFlag] [bit] NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [DHIDHelp] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [SXMainId] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [SXDHID] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [HJGType] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [BCGangNO] [varchar](30) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD [RCGangNO] [varchar](30) NULL
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  CONSTRAINT [PK_Contract_Cloth_LL] PRIMARY KEY CLUSTERED 
(
	[LLId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Contract_Cloth_DH]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Contract_Cloth_DH](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[DHId] [char](20) NOT NULL,
	[FirstNo] [varchar](40) NULL,
	[FirstName] [varchar](40) NULL,
	[BatchNo] [varchar](20) NULL,
	[DHQty] [decimal](18, 2) NOT NULL,
	[DHUnit] [varchar](20) NULL,
	[TPQtyHZ] [decimal](18, 2) NOT NULL,
	[Qty1] [decimal](18, 2) NOT NULL,
	[Qty2] [decimal](18, 2) NOT NULL,
	[Qty3] [decimal](18, 2) NOT NULL,
	[DHStatus] [varchar](20) NULL,
	[DHValid] [char](1) NOT NULL,
	[DHNote] [varchar](200) NULL,
	[DHPS] [decimal](18, 0) NOT NULL,
	[TPPSHZ] [decimal](18, 0) NOT NULL,
	[DHMQty] [decimal](18, 2) NOT NULL,
	[TPMQtyHZ] [decimal](18, 2) NOT NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD [DHTYpe] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD [SXDHID] [varchar](20) NULL
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD [SXTPQty] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD [PBName] [varchar](40) NULL
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD [PBSpec] [varchar](40) NULL
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD [PBMF] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD [PBKZ] [decimal](18, 2) NOT NULL
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD [SXMainId] [varchar](40) NULL
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  CONSTRAINT [PK_Contract_Cloth_DH] PRIMARY KEY CLUSTERED 
(
	[DHId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Contract_Cloth_BefChkHX]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Contract_Cloth_BefChkHX](
	[HXId] [char](20) NOT NULL,
	[LLId] [char](20) NOT NULL,
	[HXDate] [datetime] NULL,
	[HXPS] [decimal](18, 2) NOT NULL,
	[HXQty] [decimal](18, 2) NOT NULL,
	[HXMQty] [decimal](18, 2) NOT NULL,
	[HXUnit] [varchar](20) NULL,
	[ZSXS] [decimal](18, 2) NOT NULL,
	[HXFactory] [varchar](40) NULL,
	[HXNote] [varchar](40) NULL,
	[HXType] [varchar](40) NULL,
	[HXStatus] [varchar](40) NULL,
	[GangNo] [varchar](20) NULL,
 CONSTRAINT [PK_Contract_Cloth_BefChkHX] PRIMARY KEY CLUSTERED 
(
	[HXId] 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
/****** Object:  Table [dbo].[Config]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Config](
	[WorkDays] [nvarchar](7) NULL,
	[BeginTime] [nvarchar](5) NULL,
	[EndTime] [nvarchar](5) NULL,
	[ReportInterval] [int] NULL
) ON [PRIMARY]
GO
/****** Object:  StoredProcedure [dbo].[ClothContractSX_QryList]    Script Date: 12/17/2021 15:51:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from JYOrder_Main
Create  Procedure [dbo].[ClothContractSX_QryList]
  @MainId  varchar(20),
  @WSql    varchar(200)
AS
  DECLARE @MSql varchar(1000)
  Set @MSql='select   OM.*,OS.*,
                      OM.ConNo ConNoM,OS.C_CodeName C_CodeNameM,
                      Money=Isnull(OS.C_Qty,0)*isnull(OS.Price,0),
                      CPQty=(select sum(PRTOrderQty) from JYOrder_Sub A inner join JYOrder_Main B on 
                             A.MainId=B.MainId where B.OrderNo=OM.ConNo),
                      CPUnit=(select Top 1 OrderUnit from JYOrder_Sub A inner join JYOrder_Main B on 
                             A.MainId=B.MainId where B.OrderNo=OM.ConNo),
                      CPDate=(select Top 1 DlyDate from  JYOrder_Main B  where B.OrderNo=OM.ConNo),
                      YWY=(select Top 1 Filler from  JYOrder_Main B  where B.OrderNo=OM.ConNo)
                from ContractSX_Main OM 
                     Left join ContractSX_Sub OS on OM.MainId=OS.MainId 
                where 1=1 '
   
  IF RTRim(@MainId)<>''
  Begin
    Set @MSql=@MSql+' and OM.MainId='''+RTRIM(@MainId)+''''
  End
  
  Set @MSql=@MSql+@WSql
 
  Exec(@MSql)
GO
/****** Object:  StoredProcedure [dbo].[ClothContract_QryList]    Script Date: 12/17/2021 15:51:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  Procedure [dbo].[ClothContract_QryList]
  @MainId  varchar(20),
  @WSql    varchar(200)
AS
  DECLARE @MSql varchar(4000)
  Set @MSql='select   OM.*,OS.*,
                      OM.ConNo ConNoM,OS.C_CodeName C_CodeNameM,
                      Money=Isnull(OS.C_Qty,0)*isnull(OS.Price,0),
                      CPQty=(select sum(PRTOrderQty) from JYOrder_Sub A inner join JYOrder_Main B on 
                             A.MainId=B.MainId where B.OrderNo=OM.ConNo),
                      CPUnit=(select Top 1 OrderUnit from JYOrder_Sub A inner join JYOrder_Main B on 
                             A.MainId=B.MainId where B.OrderNo=OM.ConNo),
                      CPDate=(select Top 1 DlyDate from  JYOrder_Main B  where B.OrderNo=OM.ConNo),
                      YWY=(select Top 1 Filler from  JYOrder_Main B  where B.OrderNo=OM.ConNo),
                      MxQty=(select Sum(MX.MxQty) from Contract_Sub_Mx MX where MX.Subid=OS.Subid),
                      DHQty=(select Sum(MX.Qty1) from Contract_Sub_Mx MX where MX.Subid=OS.Subid)
                from Contract_Main OM 
                inner join Contract_Sub OS on OM.MainId=OS.MainId 
                where 1=1 '
   
  IF RTRim(@MainId)<>''
  Begin
    Set @MSql=@MSql+' and OM.MainId='''+RTRIM(@MainId)+''''
  End
  
  Set @MSql=@MSql+@WSql
 
  Exec(@MSql)
GO
/****** Object:  Table [dbo].[Cloth_YCL_PB]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[Cloth_YCL_PB](
	[MainId] [char](20) NULL,
	[SubId] [char](20) NULL,
	[PBId] [char](20) NOT NULL,
	[YCLName] [varchar](50) NULL,
	[PBName] [varchar](200) NULL,
	[YCLSpec] [varchar](40) NULL,
	[PBQty] [decimal](18, 2) NULL,
	[PBNote] [varchar](200) NULL,
	[CIShu] [int] NULL,
	[Filler] [varchar](20) NULL,
	[Editer] [varchar](20) NULL,
	[EditTime] [datetime] NULL,
	[FillTime] [datetime] NULL,
	[PinPai] [varchar](50) NULL,
	[BegPBQty] [decimal](18, 2) NULL,
	[SJPBQty] [decimal](18, 2) NULL,
 CONSTRAINT [PK_Cloth_YCL_PB] PRIMARY KEY CLUSTERED 
(
	[PBId] 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
/****** Object:  Table [dbo].[Cloth_Sub]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[Cloth_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[XHNo] [char](20) NULL,
	[C_Code] [char](20) NULL,
	[C_CodeName] [varchar](50) NULL,
	[C_Spec] [varchar](40) NULL,
	[C_Color] [varchar](20) NULL,
	[MF] [varchar](20) NULL,
	[KZ] [varchar](20) NULL,
	[C_Qty] [decimal](18, 2) NOT NULL,
	[C_Unit] [varchar](20) NULL,
	[Price] [decimal](18, 2) NOT NULL,
	[PriceUnit] [varchar](20) NULL,
	[MFUnit] [varchar](20) NULL,
	[KZUnit] [varchar](20) NULL,
	[Qty1] [decimal](18, 2) NOT NULL,
	[Qty2] [decimal](18, 2) NOT NULL,
	[Qty3] [decimal](18, 2) NOT NULL,
	[MainUnit] [varchar](20) NULL,
	[C_Status] [varchar](20) NULL,
	[C_Valid] [char](1) NOT NULL,
	[C_Note] [varchar](200) NULL,
	[MFQty] [decimal](18, 2) NULL,
	[KZQty] [decimal](18, 2) NULL,
	[MQty] [decimal](18, 2) NOT NULL,
	[ConDefStr1] [varchar](40) NULL,
	[ConDefStr2] [varchar](40) NULL,
	[ConDefStr3] [varchar](40) NULL,
	[ConDefStr4] [varchar](40) NULL,
	[ConDefStr5] [varchar](40) NULL,
	[ConDefStr6] [varchar](40) NULL,
	[ConDefStr7] [varchar](40) NULL,
	[ConDefStr8] [varchar](40) NULL,
	[ConDefStr9] [varchar](40) NULL,
	[ConDefStr10] [varchar](40) NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[Cloth_Sub] ADD [ChouZhenYT] [varchar](20) NULL
ALTER TABLE [dbo].[Cloth_Sub] ADD [HuaWei] [varchar](20) NULL
ALTER TABLE [dbo].[Cloth_Sub] ADD  CONSTRAINT [PK_Cloth_Sub] PRIMARY KEY CLUSTERED 
(
	[SubId] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  StoredProcedure [dbo].[Cloth_QryList]    Script Date: 12/17/2021 15:51:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  Procedure [dbo].[Cloth_QryList]
  @MainId  varchar(20),
  @WSql    varchar(200)
AS
--select * from CLoth_Main
  DECLARE @MSql varchar(6000)
  Set @MSql='select   OM.*,OS.*,MainIdTM=substring(OM.MainId,3,10),JGPriceYS=isnull(OM.JGPrice,-99.99),
                      OM.ConNo ConNoM,OS.C_CodeName C_CodeNameM,
                      XSConNO=JCM.ConNo,XSPrice=JCS.PRTPrice,--KHName=JCM.CustomerNoName,
                     -- Case when isnull(JCM.CustomerNoName,'''')<>'''' then JCM.CustomerNoName else
                      --isnull((select CustomerNoName from JYOrder_Main JM where JM.OrderNo=OM.OrderNo),'''')
                      --end as KHName,
                      XSBZType=JCS.PriceUnit,
                      PS=(select Sum(Qty1) from Cloth_Sub CS where CS.MainId=OM.MainId),
                      QtyHZ=(select Sum(C_Qty) from Cloth_Sub CS where CS.MainId=OM.MainId),
                      APPS=(select Count(*) from JYCon_Sub_AnPai A where A.SubId=OS.SubId),
                      RKPS=(select Count(*) from CK_PBCP_CR A where A.SubId=OS.SubId and CRFlag=''入库''),
                      RKQty=(select sum(KGQty) from CK_PBCP_CR A where A.SubId=OS.SubId and CRFlag=''入库''),
                      CKPS=(select Count(*) from CK_PBCP_CR A where A.SubId=OS.SubId and CRFlag=''出库''),
                      CKQty=(select sum(KGQty) from CK_PBCP_CR A where A.SubId=OS.SubId and CRFlag=''出库''),
                      KCPS=isnull((select Count(*) from CK_PBCP_CR A where A.SubId=OS.SubId and CRFlag=''入库''),0)
                           -isnull((select Count(*) from CK_PBCP_CR A where A.SubId=OS.SubId and CRFlag=''出库''),0),
                      KCQty=isnull((select sum(KGQty) from CK_PBCP_CR A where A.SubId=OS.SubId and CRFlag=''入库''),0)
                           -isnull((select sum(KGQty) from CK_PBCP_CR A where A.SubId=OS.SubId and CRFlag=''出库''),0),
                      KHNameJC=(select ZdyNameZ from KH_Zdy_Attachment KZA where KZA.ZdyName=JCM.CustomerNoName
                                and isnull(Type,'''')=''KHName'' ),
                      KHName=(select ZdyNameZ from KH_Zdy_Attachment KZA where KZA.ZdyName=JCM.CustomerNoName
                                and isnull(Type,'''')=''KHName'' ),
                     -- Case when isnull(JCM.CustomerNoName,'''')<>'''' then
                      --(select ZdyNameZ from KH_Zdy_Attachment KZA where KZA.ZdyName=JCM.CustomerNoName
                          --      and isnull(Type,'''')=''KHName'' ) else
                     -- (select ZdyNameZ from KH_Zdy_Attachment KZA 
                      --where KZA.ZdyName=(select CustomerNoName from JYOrder_Main JM where JM.OrderNo=OM.OrderNo)
                            --    and isnull(Type,'''')=''KHName'' ) end as KHNameJC,
                      Case when isnull((select count(*) from Cloth_Process where MainId=OM.MainID),0)>0 
                       then Cast(1 as bit) else Cast(0 as bit) end as GXFlag,
                      Case when isnull((select count(*) from Cloth_PCS_Sub where MainId=OM.MainID),0)>0 
                       then Cast(1 as bit) else Cast(0 as bit) end as SLFlag,
                      Case when isnull((select count(*) from TP_File where WBID=OM.MainID and TFType=''白坯单'' ),0)>0 
                      then Cast(1 as bit) else Cast(0 as bit) end as FJFlag,
                      APJT=dbo.F_Get_Order_SubStr(OM.MainId,''APJT''),
                      QYJT=dbo.F_Get_Order_SubStr(OM.MainId,''QYJT''),
                      TYJT=dbo.F_Get_Order_SubStr(OM.MainId,''TYJT''),
                      APInfo=dbo.F_Get_Order_SubStr(OM.MainId,''APInfo'')
                from Cloth_Main OM 
                     Left join Cloth_Sub OS on OM.MainId=OS.MainId 
                     left join JYOrderCon_Main JCM on OM.ConMainId=JCM.MainId
                     left join JYOrderCon_Sub JCS on OM.ConSubId=JCS.SubId
                where 1=1 '
   
  IF RTRim(@MainId)<>''
  Begin
    Set @MSql=@MSql+' and OM.MainId='''+RTRIM(@MainId)+''''
  End
  
  Set @MSql=@MSql+@WSql
 
  Exec(@MSql)
GO
/****** Object:  Table [dbo].[Cloth_Process]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[Cloth_Process](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NULL,
	[PSId] [char](20) NOT NULL,
	[PSName] [varchar](20) NULL,
	[PSXH] [int] NULL,
	[PSSH] [decimal](18, 2) NULL,
	[PSSJSH] [decimal](18, 2) NULL,
	[LiDanPerson] [varchar](20) NULL,
	[GenDanPerson] [varchar](20) NULL,
	[PSNote] [varchar](800) NULL,
	[PSSJQty] [decimal](18, 2) NULL,
	[PSSJMoney] [decimal](18, 2) NULL,
	[PSSJPrice] [decimal](18, 2) NULL,
	[PSSJNote] [varchar](100) NULL,
	[ZPQty] [decimal](18, 2) NULL,
	[LDMoney] [decimal](18, 2) NULL,
	[SHMoney] [decimal](18, 2) NULL,
	[LDPrice] [decimal](18, 3) NULL,
	[SHPrice] [decimal](18, 2) NULL,
	[PJFenShu] [decimal](18, 0) NULL,
	[SHFuDong] [decimal](18, 2) NULL,
 CONSTRAINT [PK_Cloth_Process] PRIMARY KEY CLUSTERED 
(
	[PSId] 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
/****** Object:  Table [dbo].[Cloth_PCS_Sub]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[Cloth_PCS_Sub](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NULL,
	[CGConId] [char](20) NULL,
	[PSId] [char](20) NOT NULL,
	[PFId] [char](20) NOT NULL,
	[PFCPName] [varchar](40) NULL,
	[FactoryNo] [varchar](20) NULL,
	[FactoryName] [varchar](40) NULL,
	[PFDlyDate] [datetime] NULL,
	[PFTPQty] [decimal](18, 2) NULL,
	[PFTPUnit] [varchar](20) NULL,
	[PFTPPS] [decimal](18, 2) NULL,
	[PFSH] [decimal](18, 2) NULL,
	[PFSJSH] [decimal](18, 2) NULL,
	[PFNote] [varchar](200) NULL,
	[PFGenDanPerson] [varchar](20) NULL,
	[CKName] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[Editer] [varchar](20) NULL,
	[FillTime] [datetime] NOT NULL,
	[EditTime] [datetime] NULL,
	[XDFactoryNo] [varchar](20) NULL,
	[XDFactoryName] [varchar](40) NULL,
 CONSTRAINT [PK_Cloth_PCS_Sub] PRIMARY KEY CLUSTERED 
(
	[PFId] 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
/****** Object:  Table [dbo].[Cloth_Main]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Cloth_Main](
	[MainId] [char](20) NOT NULL,
	[ConNo] [char](20) NOT NULL,
	[ClothCode] [char](20) NULL,
	[ClothCodeName] [char](20) NULL,
	[QDTime] [datetime] NULL,
	[QDPalce] [varchar](200) NULL,
	[DeliveryDate] [datetime] NULL,
	[FactoryNo] [char](60) NULL,
	[FactoryNoName] [char](60) NULL,
	[CompanyName] [char](60) NULL,
	[ConTK1] [varchar](200) NULL,
	[ConTK2] [varchar](200) NULL,
	[ConTK3] [varchar](200) NULL,
	[ConTK4] [varchar](200) NULL,
	[ConTK5] [varchar](200) NULL,
	[Note] [varchar](250) NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkNote] [varchar](200) NULL,
	[Chktime] [datetime] NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Status] [varchar](20) NULL,
	[Valid] [char](1) NOT NULL,
	[LXPerson] [varchar](20) NULL,
	[LXTel] [varchar](20) NULL,
	[JHPlace] [varchar](40) NULL,
	[ConType] [varchar](20) NULL,
	[ZhuanStr] [varchar](20) NULL,
	[ZhuanMM] [int] NULL,
	[LBName] [varchar](20) NULL,
	[C_CodeNameCW] [varchar](40) NULL,
	[BegTime] [datetime] NULL,
	[BegPerson] [varchar](20) NULL,
	[BegFlag] [bit] NOT NULL,
	[EndTime] [datetime] NULL,
	[EndPerson] [varchar](20) NULL,
	[EndFlag] [bit] NOT NULL,
	[ComTaiTou] [varchar](40) NULL,
	[OrderNo] [varchar](20) NULL,
	[ConSubId] [varchar](20) NULL,
	[ConMainId] [varchar](20) NULL,
	[WCFlag] [bit] NOT NULL,
	[WCPerson] [varchar](20) NULL,
	[WCDate] [datetime] NULL,
	[PBYongTu] [varchar](20) NULL,
	[CostPrice] [decimal](18, 2) NULL,
	[JGPrice] [decimal](18, 3) NULL,
 CONSTRAINT [PK_Cloth_Main] PRIMARY KEY CLUSTERED 
(
	[MainId] 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
/****** Object:  Table [dbo].[Cloth_JiTaiZShu]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Cloth_JiTaiZShu](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[ZSID] [char](20) NOT NULL,
	[ZSDate] [datetime] NULL,
	[ConNo] [varchar](40) NULL,
	[SCPerson] [varchar](40) NULL,
	[CarNo] [varchar](40) NULL,
	[JBQty] [decimal](18, 2) NULL,
	[BegQty] [decimal](18, 2) NULL,
	[EndQty] [decimal](18, 2) NULL,
	[Qty] [decimal](18, 2) NULL,
	[GJPrice] [decimal](18, 2) NULL,
	[BTMoney] [decimal](18, 2) NULL,
	[Filler] [varchar](200) NULL,
	[BTNote] [varchar](20) NULL,
	[YGMoney] [decimal](18, 2) NULL,
	[Note] [varchar](200) NULL,
	[Filltime] [datetime] NOT NULL,
	[APID] [varchar](50) NULL,
	[SCDate] [datetime] NULL,
	[MPZQty] [decimal](18, 2) NULL,
	[PS] [decimal](18, 0) NULL,
	[JYDate] [datetime] NULL,
	[WCDate] [datetime] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Cloth_JiTai]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Cloth_JiTai](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[JTID] [char](20) NOT NULL,
	[JTDate] [datetime] NULL,
	[CarNo] [varchar](20) NULL,
	[StopFlag] [bit] NOT NULL,
	[DOTime] [datetime] NULL,
	[DOPerson] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
 CONSTRAINT [PK_Cloth_JiTai] PRIMARY KEY CLUSTERED 
(
	[JTID] 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
/****** Object:  Table [dbo].[CK_SXPB_KC]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[CK_SXPB_KC](
	[CRID] [int] NOT NULL,
	[BatchNO] [varchar](40) NULL,
	[SPType] [varchar](20) NULL,
	[SPName] [varchar](40) NULL,
	[SPSpec] [varchar](40) NULL,
	[SPCF] [varchar](40) NULL,
	[SPMF] [varchar](40) NULL,
	[SPKZ] [varchar](40) NULL,
	[ShaZhi] [varchar](40) NULL,
	[FactoryNo] [varchar](40) NULL,
	[FactoryName] [varchar](40) NULL,
	[KuWei] [varchar](40) NULL,
	[KCKGQty] [decimal](18, 2) NULL,
	[KCPiQty] [decimal](18, 0) NULL,
	[KCKeQty] [decimal](18, 0) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valid] [varchar](5) NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[CK_SXPB_KC] ADD [KCNote] [varchar](200) NULL
ALTER TABLE [dbo].[CK_SXPB_KC] ADD [CKName] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_KC] ADD [SeBie] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_KC] ADD [KCQty] [decimal](18, 2) NULL
ALTER TABLE [dbo].[CK_SXPB_KC] ADD [SPColor] [varchar](40) NULL
ALTER TABLE [dbo].[CK_SXPB_KC] ADD [SPHX] [varchar](40) NULL
ALTER TABLE [dbo].[CK_SXPB_KC] ADD  CONSTRAINT [PK_CK_SXPB_KC] PRIMARY KEY CLUSTERED 
(
	[CRID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[CK_SXPB_CRID]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CK_SXPB_CRID](
	[CRID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[CRID] 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
/****** Object:  Table [dbo].[CK_SXPB_CR]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CK_SXPB_CR](
	[MainId] [char](20) NULL,
	[SubId] [char](20) NULL,
	[CKName] [varchar](40) NULL,
	[SPID] [char](20) NOT NULL,
	[BatchNO] [varchar](40) NULL,
	[CRTime] [datetime] NULL,
	[CRQtyFlag] [decimal](18, 0) NULL,
	[CRFlag] [varchar](20) NULL,
	[CRType] [varchar](20) NULL,
	[CRID] [int] NULL,
	[SPType] [varchar](20) NULL,
	[SPCode] [varchar](20) NULL,
	[SPName] [varchar](40) NULL,
	[SPCF] [varchar](40) NULL,
	[SPSpec] [varchar](40) NULL,
	[SPMF] [varchar](20) NULL,
	[SPKZ] [varchar](20) NULL,
	[ShaZhi] [varchar](40) NULL,
	[FactoryNo] [varchar](40) NULL,
	[FactoryName] [varchar](40) NULL,
	[KuWei] [varchar](40) NULL,
	[BZSpec] [varchar](40) NULL,
	[BaoQty] [decimal](18, 0) NULL,
	[PiQty] [decimal](18, 0) NULL,
	[KeQty] [decimal](18, 0) NULL,
	[KgQty] [decimal](18, 2) NULL,
	[Qty] [decimal](18, 2) NULL,
	[QtyUnit] [varchar](20) NULL,
	[Price] [decimal](18, 4) NULL,
	[CostPrice] [decimal](18, 2) NULL,
	[Money] [decimal](18, 2) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valid] [varchar](5) NULL,
	[Note] [varchar](200) NULL,
	[FromFactoryName] [varchar](40) NULL,
	[FromFactoryNo] [varchar](40) NULL,
	[FZSPID] [varchar](20) NULL,
	[CGMainId] [varchar](20) NULL,
	[CGSubId] [varchar](20) NULL,
	[SeBie] [varchar](20) NULL,
	[MXKCPiQty] [decimal](18, 0) NULL,
	[MXKCKgQty] [decimal](18, 2) NULL,
	[SChker] [varchar](20) NULL,
	[SChkStatus] [varchar](20) NULL,
	[SChkTime] [datetime] NULL,
	[Chker] [varchar](20) NULL,
	[ChkStatus] [varchar](20) NULL,
	[ChkTime] [datetime] NULL,
	[OldOrderNo] [varchar](20) NULL,
	[SPColor] [varchar](40) NULL,
	[SPHX] [varchar](40) NULL,
	[SSType] [varchar](20) NULL,
	[ORDMainIdRK] [varchar](20) NULL,
	[ORDSubIdRK] [varchar](20) NULL,
	[ORDMainIdCK] [varchar](20) NULL,
	[ORDSubIdCK] [varchar](20) NULL,
	[ToFactoryNo] [varchar](20) NULL,
	[ToFactoryName] [varchar](40) NULL,
	[QCorderNo] [varchar](40) NULL,
	[MXKCQty] [decimal](18, 2) NULL,
	[CKorderNo] [varchar](40) NULL,
	[PYID] [varchar](20) NULL,
	[RCGangNo] [varchar](20) NULL,
	[GangNo] [varchar](20) NULL,
	[CPID] [varchar](20) NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [SCMainIdRK] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [SCSubIdRK] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [QCSCOrderNo] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [ComTaiTou] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [CGMainIdFZ] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [CGSubIdFZ] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [SCMainIdCK] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [SCSubIdCK] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [CKSCorderNo] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [THSCOrderNo] [varchar](20) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [THSPID] [varchar](20) NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [ConCKID] [varchar](60) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [ConNo] [varchar](60) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [KuanNo] [varchar](70) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [IFPrint] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [PBPrice] [decimal](18, 2) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [PBMoney] [decimal](18, 2) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [PBNote] [varchar](200) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [BPType] [varchar](60) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [MCType] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [CGNo] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [MaChi] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [SMDDate] [datetime] NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [SJDHDate] [datetime] NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [DJER] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [DJDate] [datetime] NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [FromGX] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [TOGX] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [GenDanName] [varchar](80) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [PBSubid] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [KPQK] [varchar](100) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [YFee] [decimal](18, 2) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [YGName] [varchar](60) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [PS] [int] NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [ZPZhong] [decimal](18, 2) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [BZNote] [varchar](100) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [SunHao] [decimal](18, 2) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [TiaoQty] [decimal](18, 2) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [PRTHX] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [PRTSeHao] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD [SHStatus] [varchar](50) NULL
ALTER TABLE [dbo].[CK_SXPB_CR] ADD  CONSTRAINT [PK_CK_SXPB_CR] PRIMARY KEY CLUSTERED 
(
	[SPID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[CK_SX_KC]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[CK_SX_KC](
	[CRID] [int] NOT NULL,
	[CGConMainId] [varchar](20) NULL,
	[CGConSubId] [varchar](20) NULL,
	[SXID] [varchar](20) NULL,
	[SXType] [varchar](20) NULL,
	[SXCode] [varchar](20) NULL,
	[SXName] [varchar](40) NULL,
	[SXBatchNO] [varchar](40) NULL,
	[SXSpec] [varchar](40) NULL,
	[FactoryNo] [varchar](40) NULL,
	[FactoryName] [varchar](40) NULL,
	[KuWei] [varchar](40) NULL,
	[KCKGQty] [decimal](18, 2) NULL,
	[KCKeQty] [decimal](18, 0) NULL,
	[Price] [decimal](18, 2) NULL,
	[Money] [decimal](18, 2) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valid] [varchar](5) NULL,
	[KCNote] [varchar](200) NULL,
 CONSTRAINT [PK_CK_SX_KC] PRIMARY KEY CLUSTERED 
(
	[CRID] 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
/****** Object:  Table [dbo].[CK_SX_CRID]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CK_SX_CRID](
	[CRID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[CRID] 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
/****** Object:  Table [dbo].[CK_SX_CR]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CK_SX_CR](
	[MainId] [char](20) NULL,
	[SubId] [char](20) NULL,
	[SXID] [char](20) NOT NULL,
	[FZSXID] [char](20) NULL,
	[CRTime] [datetime] NULL,
	[CRQtyFlag] [decimal](18, 0) NULL,
	[CRFlag] [varchar](20) NULL,
	[CRType] [varchar](20) NULL,
	[CRID] [int] NULL,
	[CGConMainId] [varchar](20) NULL,
	[CGConSubId] [varchar](20) NULL,
	[SCConMainId] [varchar](20) NULL,
	[SXType] [varchar](20) NULL,
	[SXCode] [varchar](20) NULL,
	[SXName] [varchar](40) NULL,
	[SXBatchNO] [varchar](40) NULL,
	[SXSpec] [varchar](40) NULL,
	[FactoryNo] [varchar](40) NULL,
	[FactoryName] [varchar](40) NULL,
	[KuWei] [varchar](40) NULL,
	[BZSpec] [varchar](40) NULL,
	[OneBaoKeQty] [decimal](18, 0) NULL,
	[OneKeQty] [decimal](18, 2) NULL,
	[BaoQty] [decimal](18, 0) NULL,
	[KeQty] [decimal](18, 0) NULL,
	[KgQty] [decimal](18, 2) NULL,
	[QtyUnit] [varchar](20) NULL,
	[Price] [decimal](18, 2) NULL,
	[Money] [decimal](18, 2) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valid] [varchar](5) NULL,
	[Note] [varchar](20) NULL,
	[FZOutId] [varchar](20) NULL,
	[HCKGQty] [decimal](18, 2) NULL,
	[HCKeQty] [decimal](18, 2) NULL,
	[ZDKGQty] [decimal](18, 2) NULL,
	[ZDKeQty] [decimal](18, 2) NULL,
	[HCBaoQty] [decimal](18, 2) NULL,
	[ZDBaoQty] [decimal](18, 2) NULL,
	[CarNo] [varchar](20) NULL,
 CONSTRAINT [PK_CK_SX_CR] PRIMARY KEY CLUSTERED 
(
	[SXID] 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
/****** Object:  Table [dbo].[CK_PBCP_KC]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[CK_PBCP_KC](
	[CRID] [int] NOT NULL,
	[BCID] [char](20) NOT NULL,
	[KCKGQty] [decimal](18, 2) NOT NULL,
	[KCQty] [decimal](18, 2) NOT NULL,
	[KCQtyUnit] [varchar](20) NULL,
	[ZDYStr1] [varchar](20) NULL,
	[ZDYStr2] [varchar](20) NULL,
	[ZDYStr3] [varchar](20) NULL,
	[ZDYStr4] [varchar](20) NULL,
	[ZDYStr5] [varchar](20) NULL,
	[ZDYFlote1] [decimal](18, 2) NOT NULL,
	[ZDYFlote2] [decimal](18, 2) NOT NULL,
	[ZDYFlote3] [decimal](18, 2) NOT NULL,
	[ZDYFlote4] [decimal](18, 2) NOT NULL,
	[ZDYFlote5] [decimal](18, 2) NOT NULL,
	[KCNote] [varchar](250) NULL,
	[KCStatus] [char](2) NULL,
	[KCValid] [char](1) NOT NULL,
	[MJID] [varchar](20) NULL,
PRIMARY KEY CLUSTERED 
(
	[CRID] 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
/****** Object:  Table [dbo].[CK_PBCP_CRID]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CK_PBCP_CRID](
	[CRID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[CRID] 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
/****** Object:  Table [dbo].[CK_PBCP_CR_Log]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CK_PBCP_CR_Log](
	[MainId] [char](20) NULL,
	[SubId] [char](20) NULL,
	[MJID] [char](20) NOT NULL,
	[APID] [char](20) NOT NULL,
	[BCID] [char](20) NOT NULL,
	[CRTime] [datetime] NULL,
	[CRFlag] [varchar](20) NULL,
	[CRType] [varchar](20) NULL,
	[CRID] [int] NULL,
	[KGQty] [decimal](18, 2) NOT NULL,
	[Qty] [decimal](18, 2) NOT NULL,
	[QtyUnit] [varchar](20) NULL,
	[CPType] [varchar](20) NULL,
	[BCCode] [varchar](20) NULL,
	[BCName] [varchar](20) NULL,
	[BCFK] [decimal](18, 2) NOT NULL,
	[BCKZ] [decimal](18, 2) NOT NULL,
	[BCColor] [varchar](20) NULL,
	[BCHW] [varchar](20) NULL,
	[BCWKMS] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valid] [varchar](5) NULL,
	[JTType] [varchar](20) NULL,
	[BaoId] [varchar](20) NULL,
	[DBKCType] [varchar](20) NULL,
	[NowOutFlag] [bit] NOT NULL,
	[CKOrdNo] [varchar](20) NULL,
	[SHCompany] [varchar](40) NULL,
	[ZDPerson] [varchar](20) NULL,
	[ZDTime] [varchar](20) NULL,
	[THPerson] [varchar](20) NULL,
	[ToOrderNo] [varchar](20) NULL,
	[ToKHName] [varchar](100) NULL,
	[ToGYSName] [varchar](40) NULL,
	[CRNote] [varchar](50) NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[CK_PBCP_CR_Log] ADD [Note] [varchar](200) NULL
ALTER TABLE [dbo].[CK_PBCP_CR_Log] ADD  CONSTRAINT [PK_CK_PBCP_CR_Log] PRIMARY KEY CLUSTERED 
(
	[BCID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[CK_PBCP_CR]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[CK_PBCP_CR](
	[MainId] [char](20) NULL,
	[SubId] [char](20) NULL,
	[MJID] [char](20) NOT NULL,
	[APID] [char](20) NOT NULL,
	[BCID] [char](20) NOT NULL,
	[CRTime] [datetime] NULL,
	[CRFlag] [varchar](20) NULL,
	[CRType] [varchar](20) NULL,
	[CRID] [int] NULL,
	[KGQty] [decimal](18, 2) NOT NULL,
	[Qty] [decimal](18, 2) NOT NULL,
	[QtyUnit] [varchar](20) NULL,
	[CPType] [varchar](20) NULL,
	[BCCode] [varchar](20) NULL,
	[BCName] [varchar](20) NULL,
	[BCFK] [decimal](18, 2) NOT NULL,
	[BCKZ] [decimal](18, 2) NOT NULL,
	[BCColor] [varchar](20) NULL,
	[BCHW] [varchar](20) NULL,
	[BCWKMS] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valid] [varchar](5) NULL,
	[JTType] [varchar](20) NULL,
	[BaoId] [varchar](20) NULL,
	[DBKCType] [varchar](20) NULL,
	[NowOutFlag] [bit] NOT NULL,
	[CKOrdNo] [varchar](20) NULL,
	[SHCompany] [varchar](40) NULL,
	[ZDPerson] [varchar](20) NULL,
	[ZDTime] [varchar](20) NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[CK_PBCP_CR] ADD [THPerson] [varchar](20) NULL
ALTER TABLE [dbo].[CK_PBCP_CR] ADD [ToOrderNo] [varchar](20) NULL
ALTER TABLE [dbo].[CK_PBCP_CR] ADD [ToKHName] [varchar](100) NULL
ALTER TABLE [dbo].[CK_PBCP_CR] ADD [ToGYSName] [varchar](40) NULL
ALTER TABLE [dbo].[CK_PBCP_CR] ADD [CRNote] [varchar](50) NULL
ALTER TABLE [dbo].[CK_PBCP_CR] ADD [Note] [varchar](200) NULL
ALTER TABLE [dbo].[CK_PBCP_CR] ADD  CONSTRAINT [PK_CK_PBCP_CR] PRIMARY KEY CLUSTERED 
(
	[BCID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[CK_BanCP_KC]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CK_BanCP_KC](
	[CRID] [int] NOT NULL,
	[BCID] [char](20) NOT NULL,
	[KCKGQty] [decimal](18, 2) NOT NULL,
	[KCQty] [decimal](18, 2) NOT NULL,
	[KCQtyUnit] [varchar](20) NULL,
	[ZDYStr1] [varchar](20) NULL,
	[ZDYStr2] [varchar](20) NULL,
	[ZDYStr3] [varchar](20) NULL,
	[ZDYStr4] [varchar](20) NULL,
	[ZDYStr5] [varchar](20) NULL,
	[ZDYFlote1] [decimal](18, 2) NOT NULL,
	[ZDYFlote2] [decimal](18, 2) NOT NULL,
	[ZDYFlote3] [decimal](18, 2) NOT NULL,
	[ZDYFlote4] [decimal](18, 2) NOT NULL,
	[ZDYFlote5] [decimal](18, 2) NOT NULL,
	[KCNote] [varchar](250) NULL,
	[KCStatus] [char](2) NULL,
	[KCValid] [char](1) NOT NULL,
	[MJID] [varchar](20) NULL,
PRIMARY KEY CLUSTERED 
(
	[CRID] 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
/****** Object:  Table [dbo].[CK_BanCP_CRID]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[CK_BanCP_CRID](
	[CRID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[CRID] 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
/****** Object:  Table [dbo].[CK_BanCP_CR]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[CK_BanCP_CR](
	[MainId] [char](20) NULL,
	[SubId] [char](20) NULL,
	[MJID] [char](20) NOT NULL,
	[APID] [char](20) NOT NULL,
	[BCID] [char](20) NOT NULL,
	[CRTime] [datetime] NULL,
	[CRFlag] [varchar](20) NULL,
	[CRType] [varchar](20) NULL,
	[CRID] [int] NULL,
	[KGQty] [decimal](18, 2) NOT NULL,
	[Qty] [decimal](18, 2) NOT NULL,
	[QtyUnit] [varchar](20) NULL,
	[CPType] [varchar](20) NULL,
	[BCCode] [varchar](20) NULL,
	[BCName] [varchar](20) NULL,
	[BCFK] [decimal](18, 2) NOT NULL,
	[BCKZ] [decimal](18, 2) NOT NULL,
	[BCColor] [varchar](50) NULL,
	[BCHW] [varchar](20) NULL,
	[BCWKMS] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valid] [varchar](5) NULL,
	[JTType] [varchar](20) NULL,
	[BaoId] [varchar](20) NULL,
	[DBKCType] [varchar](20) NULL,
	[NowOutFlag] [bit] NOT NULL,
	[CKOrdNo] [varchar](20) NULL,
	[RKOrdID] [varchar](20) NULL,
	[BaoNo] [varchar](20) NULL,
	[RKPlace] [varchar](20) NULL,
	[ZDPerson] [varchar](20) NULL,
	[ZDTime] [datetime] NULL,
	[CRNote] [varchar](200) NULL,
	[ConPerson2] [varchar](70) NULL,
	[conDefstr2] [varchar](70) NULL,
	[conDefstr3] [varchar](70) NULL,
	[ConNo] [varchar](70) NULL,
	[KHConNO] [varchar](70) NULL,
	[StyleNo] [varchar](70) NULL,
	[ConID] [varchar](50) NULL,
	[MPRTCodeName] [varchar](90) NULL,
 CONSTRAINT [PK_CK_BanCP_CR] PRIMARY KEY CLUSTERED 
(
	[BCID] 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
/****** Object:  Table [dbo].[BD_Staff]    Script Date: 12/17/2021 15:51:43 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[BD_Staff](
	[UserID] [char](20) NOT NULL,
	[UserName] [char](20) NULL,
	[PassWord] [varchar](1000) NULL,
	[IdNo] [varchar](20) NULL,
	[Address] [varchar](1000) NULL,
	[Phone] [varchar](40) NULL,
	[IsYwy] [bit] NOT NULL,
	[EMail] [char](50) NULL,
	[note] [varchar](500) NULL,
	[Valid] [char](2) NOT NULL,
	[Udept] [varchar](30) NULL,
	[UType] [varchar](30) NULL,
	[sex] [varchar](10) NULL,
	[Edu] [varchar](10) NULL,
	[position] [varchar](20) NULL,
	[inTime] [datetime] NULL,
	[fstr1] [varchar](100) NULL,
	[fstr2] [varchar](100) NULL,
	[fstr3] [varchar](100) NULL,
PRIMARY KEY CLUSTERED 
(
	[UserID] 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
/****** Object:  Table [dbo].[YF_Money_KC]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[YF_Money_KC](
	[CRID] [int] NOT NULL,
	[KCQty] [decimal](18, 2) NOT NULL,
	[KCMoney] [decimal](18, 2) NOT NULL,
	[KCBBMoney] [decimal](18, 2) NOT NULL,
	[BZType] [varchar](20) NULL,
	[FactoryNo] [varchar](20) NULL,
	[FactoryName] [varchar](80) NULL,
	[ZDYStr1] [varchar](20) NULL,
	[ZDYStr2] [varchar](20) NULL,
	[ZDYStr3] [varchar](20) NULL,
	[ZDYStr4] [varchar](20) NULL,
	[ZDYStr5] [varchar](20) NULL,
	[ZDYFlote1] [decimal](18, 2) NOT NULL,
	[ZDYFlote2] [decimal](18, 2) NOT NULL,
	[ZDYFlote3] [decimal](18, 2) NOT NULL,
	[ZDYFlote4] [decimal](18, 2) NOT NULL,
	[ZDYFlote5] [decimal](18, 2) NOT NULL,
	[KCNote] [varchar](250) NULL,
	[KCStatus] [char](2) NULL,
	[KCValid] [char](1) NOT NULL,
	[KCKPMoney] [decimal](18, 2) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[CRID] 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
/****** Object:  Table [dbo].[YF_Money_CRID]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[YF_Money_CRID](
	[CRID] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[CRID] 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
/****** Object:  Table [dbo].[YF_Money_CR]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[YF_Money_CR](
	[MainId] [char](20) NULL,
	[SubId] [char](20) NULL,
	[YFID] [char](20) NOT NULL,
	[CRTime] [datetime] NULL,
	[QtyFlag] [int] NOT NULL,
	[CRFlag] [varchar](20) NULL,
	[CRType] [varchar](20) NULL,
	[CRID] [int] NULL,
	[Qty] [decimal](18, 2) NOT NULL,
	[Price] [decimal](18, 4) NULL,
	[HuiLv] [decimal](18, 4) NOT NULL,
	[BZType] [varchar](20) NULL,
	[Money] [decimal](18, 2) NOT NULL,
	[BBMoney] [decimal](18, 2) NOT NULL,
	[QtyUnit] [varchar](20) NULL,
	[FactoryNo] [varchar](20) NULL,
	[FactoryName] [varchar](80) NULL,
	[YFType] [varchar](20) NULL,
	[YFCode] [varchar](20) NULL,
	[YFName] [varchar](40) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valid] [varchar](5) NULL,
	[NowOutFlag] [bit] NOT NULL,
	[OrdMainId] [varchar](20) NULL,
	[OrdSubId] [varchar](20) NULL,
	[KPMoney] [decimal](18, 2) NOT NULL,
	[KCKPMoney] [decimal](18, 2) NOT NULL,
	[PS] [decimal](18, 0) NOT NULL,
	[BatchNo] [varchar](40) NULL,
	[Note] [varchar](200) NULL,
	[PayMent] [varchar](40) NULL,
	[YFTypeID] [varchar](20) NULL,
	[YFDefFlag1] [bit] NOT NULL,
	[YFDefFlag2] [bit] NOT NULL,
	[YFDefFlag3] [bit] NOT NULL,
	[ComTaiTou] [varchar](50) NULL,
	[CPName] [varchar](20) NULL,
	[CPSpec] [varchar](20) NULL,
	[KPNO] [varchar](40) NULL,
	[DerateMoney] [decimal](18, 2) NOT NULL,
	[defstr1] [varchar](20) NULL,
	[defstr2] [varchar](20) NULL,
	[defstr3] [varchar](20) NULL,
	[P_CodeName] [varchar](100) NULL,
	[P_spec] [varchar](100) NULL,
	[P_color] [varchar](100) NULL,
	[HxNum] [decimal](18, 2) NOT NULL,
	[status] [varchar](20) NULL,
	[OrderNo] [varchar](30) NULL,
	[JSQty] [decimal](18, 2) NULL,
	[MaoQty] [decimal](18, 2) NULL,
	[JZQty] [decimal](18, 2) NULL,
	[PBNote] [varchar](200) NULL,
	[YFConNO] [varchar](50) NULL,
	[KPDMNo] [varchar](70) NULL,
	[MQty] [decimal](18, 2) NULL,
	[ConID] [varchar](50) NULL,
	[FeeType] [varchar](50) NULL,
	[ConNo] [varchar](50) NULL,
	[GYSName] [varchar](50) NULL,
	[PBChang] [varchar](50) NULL,
	[SLV] [decimal](18, 2) NULL,
	[ChkStatus] [varchar](70) NULL,
	[YRLMoney] [decimal](18, 2) NULL,
	[WRLMoney] [decimal](18, 2) NULL,
	[YKFPMoney] [decimal](18, 2) NULL,
	[FPYFID] [varchar](50) NULL,
	[KPType] [varchar](60) NULL,
	[KPStatus] [varchar](60) NULL,
	[FKType] [varchar](50) NULL,
	[ChkNote] [varchar](500) NULL,
	[SPMonth] [varchar](50) NULL,
	[GCPrice] [decimal](18, 5) NULL,
	[GCMoney] [decimal](18, 2) NULL,
	[KPName] [varchar](50) NULL,
	[BankName] [varchar](50) NULL,
	[BankNo] [varchar](50) NULL,
	[FKTaiTou] [varchar](60) NULL,
	[KHDKMoney] [decimal](18, 2) NULL,
	[SXMoney] [decimal](18, 2) NULL,
	[SQPerpon] [varchar](60) NULL,
	[GSType] [varchar](50) NULL,
	[ZSDSubid] [varchar](50) NULL,
	[QPDate] [datetime] NULL,
	[GZMonth] [varchar](20) NULL,
	[GZName] [varchar](20) NULL,
	[GangWei] [varchar](20) NULL,
	[Dept] [varchar](20) NULL,
	[GWMoney] [decimal](18, 2) NULL,
	[JXMoney] [decimal](18, 2) NULL,
	[KouKuan] [decimal](18, 2) NULL,
	[BTMoney] [decimal](18, 2) NULL,
	[JBMoney] [decimal](18, 2) NULL,
	[SZYFID] [varchar](60) NULL,
	[ZGDay] [decimal](18, 2) NULL,
	[SQNo] [varchar](60) NULL,
	[FXMoney] [decimal](18, 2) NULL,
	[HXStatus] [varchar](50) NULL,
	[Chker] [varchar](50) NULL,
	[FYType] [varchar](50) NULL,
	[HYMoney] [decimal](18, 2) NULL,
	[YJBLi] [decimal](18, 2) NULL,
	[ShuiMoney] [decimal](18, 2) NULL,
	[ShuiHouMoney] [decimal](18, 2) NULL,
 CONSTRAINT [PK_YF_Money_CR] PRIMARY KEY CLUSTERED 
(
	[YFID] 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
/****** Object:  Table [dbo].[YF_log]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[YF_log](
	[AutoID] [char](20) NOT NULL,
	[ListNo] [varchar](20) NULL,
	[ToNo] [varchar](20) NULL,
	[Num] [decimal](18, 2) NULL,
	[Type] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[FillDate] [datetime] NULL,
 CONSTRAINT [FK_YF_log] PRIMARY KEY CLUSTERED 
(
	[AutoID] 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
/****** Object:  Table [dbo].[XD_File]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[XD_File](
	[XFID] [char](20) NOT NULL,
	[CYID] [varchar](20) NULL,
	[CYNo] [char](20) NOT NULL,
	[FileName] [varchar](50) NOT NULL,
	[FileDate] [datetime] NOT NULL,
	[FileType] [varchar](50) NOT NULL,
	[HZStr] [varchar](60) NULL,
 CONSTRAINT [PK_XD_File] PRIMARY KEY CLUSTERED 
(
	[XFID] 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
/****** Object:  Table [dbo].[WFB_MJJY_PB_Log]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[WFB_MJJY_PB_Log](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[MJID] [char](20) NOT NULL,
	[MJMaoZ] [decimal](18, 2) NOT NULL,
	[MJLen] [decimal](18, 2) NOT NULL,
	[MJFK] [decimal](18, 2) NOT NULL,
	[MJSJKZ] [decimal](18, 2) NOT NULL,
	[MJBanZu] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valie] [varchar](5) NOT NULL,
	[PrtAgnFlag] [bit] NOT NULL,
	[PrtAgnDate] [datetime] NULL,
	[JTType] [varchar](20) NULL,
	[PrtAgnPerson] [varchar](20) NULL,
	[MJType] [varchar](20) NULL,
	[ZDMJID] [varchar](20) NULL,
	[HJMJID] [varchar](20) NULL,
	[MJTypeOther] [varchar](20) NULL,
	[APID] [varchar](20) NULL,
	[MJQty1] [decimal](18, 2) NOT NULL,
	[MJQty2] [decimal](18, 2) NOT NULL,
	[MJQty3] [decimal](18, 2) NOT NULL,
	[MJQty4] [decimal](18, 2) NOT NULL,
	[MJQty5] [decimal](18, 2) NOT NULL,
	[MJXH] [int] NOT NULL,
	[MJStr1] [varchar](20) NULL,
	[MJStr2] [varchar](20) NULL,
	[MJStr3] [varchar](20) NULL,
	[MJStr4] [varchar](20) NULL,
	[MJStr5] [varchar](20) NULL,
	[LYFlag] [bit] NOT NULL,
	[HXFlag] [bit] NOT NULL,
	[HXID] [varchar](20) NULL,
	[AddMoney] [decimal](18, 2) NULL,
	[DelMoney] [decimal](18, 2) NULL,
	[JGPrice] [decimal](18, 4) NULL,
	[ZhuanOne] [int] NULL,
	[FOrderNo] [varchar](20) NULL,
	[SCXH] [int] NULL,
	[BanZu] [varchar](20) NULL,
	[JBStr] [varchar](20) NULL,
	[JBZhuanQty] [int] NULL,
	[JBSCPerson] [varchar](20) NULL,
	[LBDate] [datetime] NULL,
	[CDQK] [varchar](500) NULL,
	[CDGS] [int] NULL,
	[CDHZQty] [decimal](18, 2) NULL,
	[JBPerson] [varchar](20) NULL,
	[CDHZKgQty] [decimal](18, 2) NULL,
	[FeiPinQtyKg] [decimal](18, 2) NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD [Note] [varchar](200) NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD [CDQKBak] [varchar](2000) NULL
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[WFB_MJJY_PB]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING OFF
GO
CREATE TABLE [dbo].[WFB_MJJY_PB](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[MJID] [char](20) NOT NULL,
	[MJMaoZ] [decimal](18, 2) NOT NULL,
	[MJLen] [decimal](18, 2) NOT NULL,
	[MJFK] [decimal](18, 2) NOT NULL,
	[MJSJKZ] [decimal](18, 2) NOT NULL,
	[MJBanZu] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valie] [varchar](5) NOT NULL,
	[PrtAgnFlag] [bit] NOT NULL,
	[PrtAgnDate] [datetime] NULL,
	[JTType] [varchar](20) NULL,
	[PrtAgnPerson] [varchar](20) NULL,
	[MJType] [varchar](20) NULL,
	[ZDMJID] [varchar](20) NULL,
	[HJMJID] [varchar](20) NULL,
	[MJTypeOther] [varchar](20) NULL,
	[APID] [varchar](20) NULL,
	[MJQty1] [decimal](18, 2) NOT NULL,
	[MJQty2] [decimal](18, 2) NOT NULL,
	[MJQty3] [decimal](18, 2) NOT NULL,
	[MJQty4] [decimal](18, 2) NOT NULL,
	[MJQty5] [decimal](18, 2) NOT NULL,
	[MJXH] [int] NOT NULL,
	[MJStr1] [varchar](20) NULL,
	[MJStr2] [varchar](20) NULL,
	[MJStr3] [varchar](20) NULL,
	[MJStr4] [varchar](20) NULL,
	[MJStr5] [varchar](20) NULL,
	[LYFlag] [bit] NOT NULL,
	[HXFlag] [bit] NOT NULL
) ON [PRIMARY]
SET ANSI_PADDING ON
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [HXID] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [AddMoney] [decimal](18, 2) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [DelMoney] [decimal](18, 2) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [JGPrice] [decimal](18, 4) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [ZhuanOne] [int] NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [FOrderNo] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [SCXH] [int] NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [BanZu] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [JBStr] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [JBZhuanQty] [int] NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [JBSCPerson] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [LBDate] [datetime] NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [CDQK] [varchar](500) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [CDGS] [int] NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [CDHZQty] [decimal](18, 2) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [JBPerson] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [CDHZKgQty] [decimal](18, 2) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [FeiPinQtyKg] [decimal](18, 2) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [Note] [varchar](200) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD [CDQKBak] [varchar](2000) NULL
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  CONSTRAINT [PK_WFB_MJJY_PB] PRIMARY KEY CLUSTERED 
(
	[MJID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[WFB_MJJY_CD_PB_Log]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[WFB_MJJY_CD_PB_Log](
	[MJID] [char](20) NOT NULL,
	[MCID] [char](20) NOT NULL,
	[CDbeg] [varchar](20) NULL,
	[CDend] [varchar](20) NULL,
	[CDQty] [decimal](18, 2) NULL,
	[CDName] [varchar](20) NULL,
	[CDCode] [varchar](20) NULL,
	[CDReason] [varchar](50) NULL,
	[ZZPerson] [varchar](20) NULL,
	[CDGS] [int] NULL,
	[CDKgQty] [decimal](18, 2) NULL,
 CONSTRAINT [PK_WFB_MJJY_CD_PB_Log] PRIMARY KEY CLUSTERED 
(
	[MCID] 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
/****** Object:  Table [dbo].[WFB_MJJY_CD_PB]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[WFB_MJJY_CD_PB](
	[MJID] [char](20) NOT NULL,
	[MCID] [char](20) NOT NULL,
	[CDbeg] [varchar](20) NULL,
	[CDend] [varchar](20) NULL,
	[CDQty] [decimal](18, 2) NULL,
	[CDName] [varchar](20) NULL,
	[CDCode] [varchar](20) NULL,
	[CDReason] [varchar](50) NULL,
	[ZZPerson] [varchar](20) NULL,
	[CDGS] [int] NULL,
	[CDKgQty] [decimal](18, 2) NULL,
 CONSTRAINT [PK_WFB_MJJY_CD_PB] PRIMARY KEY CLUSTERED 
(
	[MCID] 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
/****** Object:  Table [dbo].[WFB_MJJY_CD]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[WFB_MJJY_CD](
	[MJID] [char](20) NOT NULL,
	[MCID] [char](20) NOT NULL,
	[CDQty] [decimal](18, 2) NULL,
	[CDName] [varchar](20) NULL,
	[CDCode] [varchar](20) NULL,
	[CDReason] [varchar](50) NULL,
	[KouFenType] [varchar](40) NULL,
	[KouFenQty] [decimal](18, 1) NOT NULL,
	[CDBeg] [decimal](18, 2) NULL,
	[CDend] [decimal](18, 2) NULL,
 CONSTRAINT [PK_WFB_MJJY_CD] PRIMARY KEY CLUSTERED 
(
	[MCID] 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
/****** Object:  Table [dbo].[WFB_MJJY]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[WFB_MJJY](
	[MainId] [char](20) NOT NULL,
	[SubId] [char](20) NOT NULL,
	[MJID] [char](20) NOT NULL,
	[MJMaoZ] [decimal](18, 2) NOT NULL,
	[MJLen] [decimal](18, 2) NOT NULL,
	[MJFK] [decimal](18, 2) NOT NULL,
	[MJSJKZ] [decimal](18, 2) NOT NULL,
	[MJBanZu] [varchar](20) NULL,
	[Filler] [varchar](20) NULL,
	[Filltime] [datetime] NOT NULL,
	[Editer] [varchar](20) NULL,
	[Edittime] [datetime] NULL,
	[Valie] [varchar](5) NOT NULL,
	[PrtAgnFlag] [bit] NOT NULL,
	[PrtAgnDate] [datetime] NULL,
	[JTType] [varchar](20) NULL,
	[PrtAgnPerson] [varchar](20) NULL,
	[MJType] [varchar](20) NULL,
	[ZDMJID] [varchar](20) NULL,
	[HJMJID] [varchar](20) NULL,
	[MJTypeOther] [varchar](20) NULL,
	[APID] [varchar](20) NULL,
	[MJQty1] [decimal](18, 2) NOT NULL,
	[MJQty2] [decimal](18, 2) NOT NULL,
	[MJQty3] [decimal](18, 2) NOT NULL,
	[MJQty4] [decimal](18, 2) NOT NULL,
	[MJQty5] [decimal](18, 2) NOT NULL,
	[MJXH] [int] NOT NULL
) ON [PRIMARY]
SET ANSI_PADDING OFF
ALTER TABLE [dbo].[WFB_MJJY] ADD [MJStr1] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [MJStr2] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [MJStr3] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [MJStr4] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [MJStr5] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [LYFlag] [bit] NOT NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [HXFlag] [bit] NOT NULL
SET ANSI_PADDING ON
ALTER TABLE [dbo].[WFB_MJJY] ADD [HXID] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [PanDing] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [MKXs] [decimal](18, 4) NOT NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [baoID] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [baoNo] [varchar](20) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [FHConNo] [varchar](70) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [FHKHConNo] [varchar](70) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [FHMainid] [varchar](70) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [FHSubid] [varchar](70) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [FHPlace] [varchar](70) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [FZCMainid] [varchar](70) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [CONID] [varchar](50) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD [WCStatus] [varchar](90) NULL
ALTER TABLE [dbo].[WFB_MJJY] ADD  CONSTRAINT [PK_WFB_MJJY] PRIMARY KEY CLUSTERED 
(
	[MJID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TP_File]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TP_File](
	[TFID] [varchar](50) NOT NULL,
	[WBID] [varchar](50) NULL,
	[TFDate] [datetime] NULL,
	[Files] [image] NULL,
	[Filler] [char](10) NULL,
	[FillTime] [datetime] NOT NULL,
	[Editer] [char](10) NULL,
	[EditTime] [datetime] NULL,
	[FileType] [varchar](20) NULL,
	[TFType] [varchar](20) NULL,
	[FilesOther] [image] NULL,
	[TFIdx] [int] NULL,
	[FileName] [varchar](100) NULL,
 CONSTRAINT [PK_TP_File] PRIMARY KEY CLUSTERED 
(
	[TFID] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[TBSubID]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[TBSubID](
	[SubId] [char](20) NOT NULL,
	[DName] [varchar](40) NOT NULL,
 CONSTRAINT [PK_S_[TBSubID] PRIMARY KEY CLUSTERED 
(
	[SubId] ASC,
	[DName] 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
/****** Object:  Table [dbo].[SY_Syslog]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SY_Syslog](
	[AutoID] [int] IDENTITY(1,1) NOT NULL,
	[Operor] [char](20) NOT NULL,
	[OperTime] [datetime] NOT NULL,
	[Model] [char](50) NULL,
	[Acction] [varchar](40) NULL,
	[OPEvent] [varchar](200) NULL,
	[Result] [varchar](40) NULL,
 CONSTRAINT [PK_S_SYSLOG] PRIMARY KEY CLUSTERED 
(
	[AutoID] 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
/****** Object:  Table [dbo].[SY_SET]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SY_SET](
	[Id] [int] NOT NULL,
	[IsYGCodezdsc] [bit] NOT NULL,
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]
GO
/****** Object:  Table [dbo].[SY_Purview]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SY_Purview](
	[UserID] [char](20) NOT NULL,
	[ModuleID] [char](2) NOT NULL,
	[ModuleSubID] [char](2) NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[UserID] ASC,
	[ModuleID] ASC,
	[ModuleSubID] 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
/****** Object:  Table [dbo].[SY_ModuleSub]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SY_ModuleSub](
	[ModuleID] [char](2) NOT NULL,
	[ModuleSubID] [char](2) NOT NULL,
	[FormName] [char](30) NOT NULL,
	[FormFile] [char](30) NOT NULL,
	[FormID] [int] NOT NULL,
	[FormType] [int] NOT NULL,
	[Idx] [int] NOT NULL,
	[FormPara] [varchar](100) NULL,
	[FormPara1] [varchar](100) NULL,
	[FormPara2] [varchar](100) NULL,
	[FormPara3] [varchar](100) NULL,
	[FormPara4] [varchar](100) NULL,
	[FormPara5] [varchar](100) NULL,
	[FormPara6] [varchar](100) NULL,
	[FormPara7] [varchar](100) NULL,
	[FormPara8] [varchar](100) NULL,
	[FormPara9] [varchar](100) NULL,
	[FormPara10] [varchar](100) NULL,
	[FormPara11] [varchar](500) NULL,
	[Note] [varchar](1000) NULL,
 CONSTRAINT [PK__SY_ModuleSub] PRIMARY KEY CLUSTERED 
(
	[ModuleID] ASC,
	[ModuleSubID] 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
/****** Object:  Table [dbo].[SY_ModuleMain]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SY_ModuleMain](
	[ModuleID] [char](2) NOT NULL,
	[ModuleName] [varchar](60) NOT NULL,
	[Idx] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[ModuleID] 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
/****** Object:  Table [dbo].[SY_Module_Note]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SY_Module_Note](
	[MNID] [char](20) NOT NULL,
	[MNType] [varchar](40) NULL,
	[MNDate] [datetime] NULL,
	[MNNote] [varchar](200) NULL,
	[FillTime] [datetime] NOT NULL,
	[Filler] [varchar](20) NULL,
	[EditTime] [datetime] NULL,
	[Editer] [varchar](20) NULL,
PRIMARY KEY CLUSTERED 
(
	[MNID] 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
/****** Object:  Table [dbo].[SY_MaxBH]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[SY_MaxBH](
	[BHStr] [char](10) NOT NULL,
	[BHType] [varchar](20) NOT NULL,
	[BHDate] [char](6) NULL,
	[BHNo] [int] NULL,
	[Type] [int] NOT NULL,
PRIMARY KEY CLUSTERED 
(
	[BHStr] ASC,
	[BHType] ASC,
	[Type] 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
/****** Object:  Table [dbo].[Sheet1$]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Sheet1$](
	[zdyName] [nvarchar](255) NULL,
	[Type] [nvarchar](255) NULL,
	[BH] [nvarchar](255) NULL
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[RT_FileUpdate]    Script Date: 12/17/2021 15:51:44 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[RT_FileUpdate](
	[FileName] [varchar](50) NOT NULL,
	[FileEditDate] [datetime] NOT NULL,
	[FileSize] [decimal](18, 2) NOT NULL,
	[Files] [image] NULL,
	[Filler] [char](10) NULL,
	[FillTime] [datetime] NOT NULL,
	[LastEditer] [char](10) NULL,
	[LastEditTime] [datetime] NULL,
	[FileCreateDate] [datetime] NULL,
	[FilePath] [varchar](50) NULL,
	[FileType] [varchar](20) NULL,
 CONSTRAINT [PK_RT_FileUpdate] PRIMARY KEY CLUSTERED 
(
	[FileName] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  StoredProcedure [dbo].[P_YSSK_ListTT]    Script Date: 12/17/2021 15:51:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec [P_YSSK_ListTT] '2012-01-01','2013-10-10'
CREATE Procedure [dbo].[P_YSSK_ListTT] 
  @begdate varchar(20),
  @enddate varchar(20)
AS
SELECT KCBBMoney=BQMoney,KCMoney=BQMoneyYB,AA.*,SQMoney=isnull(BQMoney,0)-isnull(YFMoney,0)+isnull(FKMoney,0),
            SQMoneyYB=isnull(BQMoneyYB,0)-isnull(YFMoneyYB,0)+isnull(FKMoneyYB,0),
            WKP=isnull(FKMoneyHZ,0)-isnull(KCKPMoney,0) from(
  select A.KCBBMoney,A.CRID,A.FactoryName,A.ComTaiTou,A.KCKPMoney,A.KCMoney,
  BQMoney=isnull(A.KCBBMoney,0)-(select isnull(Sum(BBMoney*QtyFlag),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou
                            and B.CRTime>=@enddate --and B.CRTime<getdate()+1
                      ),
  BQMoneyYB=isnull(A.KCMoney,0)-(select isnull(Sum(BBMoney*QtyFlag),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou
                            and B.CRTime>=@enddate --and B.CRTime<getdate()+1
                       ),
  YFMoney=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou and B.CRType='应收款登记'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate
                       ),
  YFMoneyYB=(select isnull(Sum(Money),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou and B.CRType='应收款登记'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate
                       ),
  BQKP=(select isnull(Sum(KPMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou and B.CRFlag='应收收'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate
                       ),
  FKMoney=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou and B.CRType='收款登记'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate
                       ),
  FKMoneyYB=(select isnull(Sum(Money),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou and B.CRType='收款登记'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate
                       ),
  FKMoneyHZ=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou and B.CRType='应收款登记'
                           )
  ,KHZJM=dbo.getPinYin(A.FactoryName)
  from (select CRID,FactoryName,ComTaiTou=isnull(ComTaiTou,''),KCBBMoney=isnull(sum(BBMoney*QtyFlag),0),KCMoney=isnull(sum(Money*QtyFlag),0),
               KCKPMoney=isnull(sum(KPMoney),0) 
      from YF_Money_CR
      where CRFlag='应收收' 
      Group by CRID,FactoryName,ComTaiTou
      ) A
  )AA

--select * from YF_Money_CR
GO
/****** Object:  StoredProcedure [dbo].[P_YSSK_List]    Script Date: 12/17/2021 15:51:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[P_YSSK_List] 
  @begdate varchar(20),
  @enddate varchar(20)
AS 
  select *,RMBWKP=isnull(RMBZ_FKMoney,0)-isnull(RMBSQKP,0)-isnull(RMBBQKP,0)
          ,USDWKP=isnull(USDZ_FKMoney,0) from
  (select A.FactoryName,
             USDSQMoney=(select isnull(Sum(Qtyflag*Money),0)-isnull(SUM(SXMoney),0) 
                       from YF_Money_CR B 
                       where B.CRTime<@Begdate
                             and B.Status=(case when B.CRType='应收款登记' and (B.YFName='成品销售金额' or Isnull(B.FeeType,'')='其他费用') then '3' else '2' end)
                             and B.BZType<>'RMB' and B.BZType<>'￥'
                             and B.factoryName=A.factoryName and B.CRFlag='应收收' and B.YFName<>'坯布虚拟费'),
             RMBSQMoney=(select isnull(Sum(Qtyflag*Money),0)-isnull(SUM(SXMoney),0) 
                       from YF_Money_CR B 
                       where B.CRTime<@Begdate 
                             and B.Status=(case when B.CRType='应收款登记' and (B.YFName='成品销售金额' or Isnull(B.FeeType,'')='其他费用') then '3' else '2' end)
                             and B.BZType<>'USD' and B.BZType<>'$'
                             and B.factoryName=A.factoryName and B.CRFlag='应收收' and B.YFName<>'坯布虚拟费'),
             USDYFMoney=(select isnull(Sum(Money),0) 
                       from YF_Money_CR B 
                       where B.CRTime>=@Begdate and B.CRTime<@Enddate and B.CRType='应收款登记' 
                             and B.Status=(case when B.YFName='成品销售金额' or Isnull(B.FeeType,'')='其他费用' then '3' else '2' end)
                             and B.BZType<>'RMB' and B.BZType<>'￥'
                             and B.factoryName=A.factoryName  and B.CRFlag='应收收' and B.YFName<>'坯布虚拟费'),
             RMBYFMoney=(select isnull(Sum(Money),0) 
                       from YF_Money_CR B 
                       where B.CRTime>=@Begdate and B.CRTime<@Enddate and B.CRType='应收款登记' 
                             and B.Status=(case when B.YFName='成品销售金额' or Isnull(B.FeeType,'')='其他费用' then '3' else '2' end)
                             and B.BZType<>'USD' and B.BZType<>'$'
                             and B.factoryName=A.factoryName  and B.CRFlag='应收收' and B.YFName<>'坯布虚拟费'),
             USDFKMoney=(select isnull(Sum(Money),0)+isnull(Sum(SXMoney),0) 
                       from YF_Money_CR B 
                       where B.CRTime>=@Begdate and B.CRTime<@Enddate and B.CRType='收款登记' and B.Status='2'
                            and B.BZType<>'RMB' and B.BZType<>'￥'
                             and B.factoryName=A.factoryName  and B.CRFlag='应收收' and B.YFName<>'坯布虚拟费'),
             RMBFKMoney=(select isnull(Sum(Money),0)+isnull(Sum(SXMoney),0)  
                       from YF_Money_CR B 
                       where B.CRTime>=@Begdate and B.CRTime<@Enddate and B.CRType='收款登记' and B.Status='2'
                            and B.BZType<>'USD' and B.BZType<>'$'
                              and B.factoryName=A.factoryName  and B.CRFlag='应收收' and B.YFName<>'坯布虚拟费'),
             USDBQMoney=(select isnull(Sum(Qtyflag*Money),0)-isnull(SUM(SXMoney),0) 
                       from YF_Money_CR B 
                       where B.CRTime<@Enddate 
                       and B.Status=(case when B.CRType='应收款登记' and (B.YFName='成品销售金额' or Isnull(B.FeeType,'')='其他费用') then '3' else '2' end)
                       and B.BZType<>'RMB' and B.BZType<>'￥'
                       and B.factoryName=A.factoryName  and B.CRFlag='应收收' and B.YFName<>'坯布虚拟费'),
             RMBBQMoney=(select isnull(Sum(Qtyflag*Money),0)-isnull(SUM(SXMoney),0)  
                       from YF_Money_CR B 
                       where B.CRTime<@Enddate 
                       and B.Status=(case when B.CRType='应收款登记' and (B.YFName='成品销售金额' or Isnull(B.FeeType,'')='其他费用') then '3' else '2' end)
                       and B.BZType<>'USD' and B.BZType<>'$'
                       and B.factoryName=A.factoryName  and B.CRFlag='应收收' and B.YFName<>'坯布虚拟费'),
             USDZ_FKMoney=(select isnull(Sum(Money),0) 
                       from YF_Money_CR B 
                       where B.CRTime<@Enddate and B.CRType='应收款登记' 
                            and B.Status=(case when B.YFName='成品销售金额' or Isnull(B.FeeType,'')='其他费用' then '3' else '2' end)
                            and B.BZType<>'RMB' and B.BZType<>'￥'
                            and B.factoryName=A.factoryName 
                            and B.CRFlag='应收收' and KPType='需开'),
             RMBZ_FKMoney=(select isnull(Sum(Money),0) 
                       from YF_Money_CR B 
                       where B.CRTime<@Enddate and B.CRType='应收款登记' 
                            and B.Status=(case when B.YFName='成品销售金额' or Isnull(B.FeeType,'')='其他费用' then '3' else '2' end)
                            and B.BZType<>'USD' and B.BZType<>'$'
                            and B.factoryName=A.factoryName 
                            and B.CRFlag='应收收' and KPType='需开'),
             RMBBQKP=(select isnull(Sum(KPMoney),0) 
                       from YF_Money_CR B 
                       where B.CRTime>=@Begdate and B.CRTime<@Enddate 
                             and B.factoryName=A.factoryName
                             and B.BZType<>'USD' and B.BZType<>'$'
                             and B.CRFlag='应收收' and CRType in('应收款发票登记')),
             RMBSQKP=(select isnull(Sum(KPMoney),0) 
                       from YF_Money_CR B 
                       where B.CRTime<@Begdate 
                             and B.BZType<>'USD' and B.BZType<>'$'
                             and B.factoryName=A.factoryName 
                             and B.CRFlag='应收收' and CRType in('应收款发票登记'))                
    from (select distinct factoryName from YF_Money_CR where CRFlag='应收收' and YFName<>'坯布虚拟费')A) AA
GO
/****** Object:  StoredProcedure [dbo].[P_YFFK_ListTT]    Script Date: 12/17/2021 15:51:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec [P_YFFK_ListTT] '2012-01-01','2013-10-10'
CREATE Procedure [dbo].[P_YFFK_ListTT] 
  @begdate varchar(20),
  @enddate varchar(20)
AS
 SELECT KCBBMoney=BQMoney,AA.* ,SQMoney=isnull(BQMoney,0)-isnull(YFMoney,0)+isnull(FKMoney,0),WKP=isnull(YFKMoneyHZ,0)-isnull(KPMoney,0)
  from
  ( 
   select A.*,
      BQMoney=isnull(A.KCBBMoney,0)-(select isnull(Sum(BBMoney*QtyFlag),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou
                            and B.CRTime>=@Enddate --and B.CRTime<getdate()+1
                           ),
     YFMoney=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou and B.CRType='应付款登记'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate
                       ),
     BQKP=(select isnull(Sum(KPMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou and B.CRFlag='应付付'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate
                      ),
     FKMoney=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou and B.CRType='付款登记'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate
                       ),
     YFKMoneyHZ=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and isnull(B.ComTaiTou,'')=A.ComTaiTou  and B.CRType='应付款登记'
                       ),
     KHZJM=dbo.getPinYin(A.FactoryName)
     from
     (select CRID,FactoryName,ComTaiTou=isnull(ComTaiTou,''),KCBBMoney=isnull(sum(BBMoney*QtyFlag),0),KPMoney=isnull(sum(KPMoney),0) 
      from YF_Money_CR
      where CRFlag='应付付' 
      Group by CRID,FactoryName,ComTaiTou
      ) A 
   )AA




set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO
/****** Object:  StoredProcedure [dbo].[P_YFFK_ListBAK]    Script Date: 12/17/2021 15:51:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create Procedure [dbo].[P_YFFK_ListBAK] 
  @begdate varchar(20),
  @enddate varchar(20)
AS
SELECT AA.*,WKP=YFKMoneyHZ-KPHZ ,BQMoney=isnull(YFMoney,0)-isnull(FKMoney,0),
       BQWKP=isnull(YFMoney,0)-isnull(BQKP,0)-isnull(FKMoneyXJ,0)
FROM(
  select A.KCBBMoney,A.CRID,A.FactoryName,A.KCKPMoney,
  SQMoney=(select isnull(Sum(BBMoney*QtyFlag),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID
                            and B.CRTime<@begdate),
  YFMoney=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRType='应付款登记'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate),
  BQKP=(select isnull(Sum(KPMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRFlag='应付付'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate),
  KPHZ=(select isnull(Sum(KPMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRFlag='应付付'),
  FKMoney=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRType='付款登记'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate),
  FKMoneyHZ=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRType='付款登记'
                             and isnull(B.PayMent,'')<>'现金'),
  FKMoneyXJ=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRType='付款登记' and B.PayMent='现金'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate),
  YFKMoneyHZ=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRType='应付款登记'
                            )
  ,KHZJM=dbo.getPinYin(A.FactoryName)
  
  from YF_Money_KC A 
  where  A.ZdyStr1='应付付')AA
GO
/****** Object:  StoredProcedure [dbo].[P_YFFK_List10]    Script Date: 12/17/2021 15:51:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_YFFK_List10'2013-10-01','2015-10-01',''
CREATE Procedure [dbo].[P_YFFK_List10] 
  @begdate varchar(20),
  @enddate varchar(20),
  @flag varchar(10)
AS
BEGIN
  SELECT *,WKP=isnull(Z_FKMoney,0)-isnull(SQKP,0)-isnull(BQKP,0)
  ,KHType=(select Top 1 C.DEFstr5 from KH_Zdy_Attachment C where C.Type='GYS' and C.ZdyName=AA.FactoryName)
  FROM(
      select A.FactoryName,
             SQMoney=(select isnull(Sum( (case when B.CRType='付款登记' then -1 else 1 end )*(Money-isnull(FXMoney,0)-isnull(SXMoney,0))),0) 
                       from YF_Money_CR B 
                       where B.CRTime<@Begdate and isnull(B.status,'')='2'
                             and B.factoryName=A.factoryName --and  B.YFDefFlag1=A.YFDefFlag1
                             and B.CRFlag='应付付' and CRType in('付款登记','应付款登记')),
              
             SQKP=(select isnull(Sum(KPMoney),0) 
                       from YF_Money_CR B 
                       where B.CRTime<@Begdate 
                             and B.factoryName=A.factoryName --and  B.YFDefFlag1=A.YFDefFlag1
                             and B.CRFlag='应付付' and CRType in('应付款发票登记')),
                             
             YFMoney=(select isnull(Sum(Money),0) 
                       from YF_Money_CR B 
                       where B.CRTime>=@Begdate and B.CRTime<@Enddate and B.CRType='应付款登记' and isnull(B.status,'')='2'
                            and B.factoryName=A.factoryName --and  B.YFDefFlag1=A.YFDefFlag1 
                            and B.CRFlag='应付付' ),
             FKMoney=(select isnull(Sum(Money),0) 
                       from YF_Money_CR B 
                       where B.CRTime>=@Begdate and B.CRTime<@Enddate and B.CRType='付款登记' and isnull(B.status,'')='2'
                            and B.factoryName=A.factoryName --and  B.YFDefFlag1=A.YFDefFlag1
                            and B.CRFlag='应付付' ),
             BQFXMoney=(select isnull(Sum(FXMoney),0) 
                       from YF_Money_CR B 
                       where B.CRTime>=@Begdate and B.CRTime<@Enddate and B.CRType='付款登记' and isnull(B.status,'')='2'
                            and B.factoryName=A.factoryName --and  B.YFDefFlag1=A.YFDefFlag1
                            and B.CRFlag='应付付' ),
             BQSXMoney=(select isnull(Sum(SXMoney),0) 
                       from YF_Money_CR B 
                       where B.CRTime>=@Begdate and B.CRTime<@Enddate and B.CRType='付款登记' and isnull(B.status,'')='2'
                            and B.factoryName=A.factoryName --and  B.YFDefFlag1=A.YFDefFlag1
                            and B.CRFlag='应付付' ),
             BQMoney=(select isnull(Sum((case when B.CRType='付款登记' then -1 else 1 end )*(Money-isnull(FXMoney,0)-isnull(SXMoney,0))),0) 
                       from YF_Money_CR B 
                       where  B.CRTime<@Enddate and isnull(B.status,'')='2'
                              and B.factoryName=A.factoryName --and B.YFDefFlag1=A.YFDefFlag1
                              and B.CRFlag='应付付' and CRType in('付款登记','应付款登记')),
             BQKP=(select isnull(Sum(KPMoney),0) 
                       from YF_Money_CR B 
                       where B.CRTime>=@Begdate and B.CRTime<@Enddate 
                             and B.factoryName=A.factoryName --and  B.YFDefFlag1=A.YFDefFlag1
                             and B.CRFlag='应付付' and CRType in('应付款发票登记')),
             Z_FKMoney=(select isnull(Sum(Money),0) 
                       from YF_Money_CR B 
                       where B.CRTime<@Enddate and B.CRType='应付款登记' and isnull(B.status,'')='2'
                            and B.factoryName=A.factoryName --and  B.YFDefFlag1=A.YFDefFlag1
                            and B.CRFlag='应付付' and KPType='需开')
    from (select distinct factoryName,YFDefFlag1 from YF_Money_CR where CRFlag='应付付' and CRType='应付款登记')A
    )AA
    where SQMoney<>0 or YFMoney<>0 or FKMoney<>0 or BQMoney<>0

end
GO
/****** Object:  StoredProcedure [dbo].[P_YFFK_List]    Script Date: 12/17/2021 15:51:34 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[P_YFFK_List] 
  @begdate varchar(20),
  @enddate varchar(20)
AS
SELECT AA.*,WKP=YFKMoneyHZ-KPHZ ,BQMoney=isnull(YFMoney,0)-isnull(FKMoney,0),
       BQWKP=isnull(YFMoney,0)-isnull(BQKP,0)-isnull(FKMoneyXJ,0)
FROM(
  SELECT TJName,KCBBMoney=isnull(sum(KCBBMoney),0),KCKPMoney=isnull(sum(KCKPMoney),0), 
                SQMoney=isnull(sum(SQMoney),0),YFMoney=isnull(sum(YFMoney),0), 
                BQKP=isnull(sum(BQKP),0),KPHZ=isnull(sum(KPHZ),0), 
                FKMoney=isnull(sum(FKMoney),0),FKMoneyHZ=isnull(sum(FKMoneyHZ),0), 
                FKMoneyXJ=isnull(sum(FKMoneyXJ),0),YFKMoneyHZ=isnull(sum(YFKMoneyHZ),0),
         KHZJM=dbo.getPinYin(TJName)    
  FROM(
  select A.KCBBMoney,A.CRID,A.FactoryName,A.KCKPMoney,
  SQMoney=(select isnull(Sum(BBMoney*QtyFlag),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID
                            and B.CRTime<@begdate),
  YFMoney=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRType='应付款登记'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate),
  BQKP=(select isnull(Sum(KPMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRFlag='应付付'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate),
  KPHZ=(select isnull(Sum(KPMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRFlag='应付付'),
  FKMoney=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRType='付款登记'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate),
  FKMoneyHZ=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRType='付款登记'
                             and isnull(B.PayMent,'')<>'现金'),
  FKMoneyXJ=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRType='付款登记' and B.PayMent='现金'
                            and B.CRTime>=@Begdate and B.CRTime<@Enddate),
  YFKMoneyHZ=(select isnull(Sum(BBMoney),0) 
                       from YF_Money_CR B 
                       where B.CRID=A.CRID and B.CRType='应付款登记'
                            )
  ,TJName=(select Top 1 ZDYNameTj from KH_Zdy_Attachment KZ where KZ.ZdyName=A.FactoryName and KZ.Type='GYS' and isnull(ZDYNameTj,'')<>'' )
  from YF_Money_KC A 
  where  A.ZdyStr1='应付付')BB
  Group by TJName
)AA
GO
/****** Object:  StoredProcedure [dbo].[Get_SY_MaxBH]    Script Date: 12/17/2021 15:51:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  PROCEDURE [dbo].[Get_SY_MaxBH]
  @BHstr varchar(10),
  @BHType varchar(20),
  @Len   int =3,
  @status varchar(10)='0'
AS
begin 
  if @status='0'
  begin
    IF EXISTS (SELECT * FROM SY_MaxBH WHERE BHstr=@BHstr AND BHType=@BHType And Type='0')
    BEGIN
      UPDATE SY_MaxBH SET BHNo=BHNo+1 WHERE BHstr=@BHstr AND BHType=@BHType And Type='0'
      SELECT MaxBH = rtrim(BHstr) + RIGHT(cast('1'+replicate('0',@Len) as int) + BHNo, @Len) FROM SY_MaxBH  WHERE BHstr=@BHstr AND BHType=@BHType And Type='0'
    END
    ELSE
    BEGIN
      INSERT SY_MaxBH (BHstr, BHType, BHNo,Type) VALUES (@BHstr, @BHType,1,0)
      SELECT MaxBH = rtrim(BHstr) + RIGHT(cast('1'+replicate('0',@Len) as int) + BHNo, @Len) FROM SY_MaxBH  WHERE BHstr=@BHstr AND BHType=@BHType And Type='0'
    END
  end
  else
  begin
    DECLARE @Date DATETIME 
    DECLARE @Datestr CHAR(6)
    SET @Date = GETDATE()  
    SET @Datestr = RIGHT(YEAR(@Date) * 10000 + MONTH(@Date) * 100 + DAY(@Date), 6)
    IF EXISTS (SELECT * FROM SY_MaxBH WHERE BHstr=@BHstr AND BHType=@BHType AND BHDate=@Datestr And Type='1')
    BEGIN
	UPDATE SY_MaxBH SET BHNo=BHNo+1 WHERE BHstr=@BHstr AND BHType=@BHType AND BHDate=@Datestr And Type='1'
	SELECT MaxBH = rtrim(BHstr) + BHDate + RIGHT(cast('1'+replicate('0',@Len) as int) + BHNo, @Len) FROM SY_MaxBH  WHERE BHstr=@BHstr AND BHType=@BHType And Type='1'
    END
    ELSE IF EXISTS (SELECT * FROM SY_MaxBH WHERE BHstr=@BHstr AND BHType=@BHType And Type='1')
    BEGIN
    UPDATE SY_MaxBH SET BHDate=@Datestr, BHNo=1 WHERE BHstr=@BHstr AND BHType=@BHType And Type='1'
	SELECT MaxBH = rtrim(BHstr) + BHDate + RIGHT(cast('1'+replicate('0',@Len) as int) + BHNo, @Len) FROM SY_MaxBH  WHERE BHstr=@BHstr AND BHType=@BHType And Type='1'
    END
    ELSE
    BEGIN
	INSERT SY_MaxBH (BHstr, BHType,BHDate, BHNo,type) VALUES (@BHstr, @BHType,@Datestr, 1,1)
	SELECT MaxBH = rtrim(BHstr) + BHDate + RIGHT(cast('1'+replicate('0',@Len) as int) + BHNo, @Len) FROM SY_MaxBH  WHERE BHstr=@BHstr AND BHType=@BHType And Type='1'
    END
  end
end
GO
/****** Object:  UserDefinedFunction [dbo].[F_Get_Yfk_Ye]    Script Date: 12/17/2021 15:51:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from YF_Money_CR
--select dbo.[F_Get_Yfk_Ye]('杭州吉顺纺织有限公司','2014-08-22','应付付','PF140825006')
  
CREATE  function [dbo].[F_Get_Yfk_Ye](@factoryName varchar(100),@CRTime dateTime,@CRFlag varchar(20),@YFID varchar(30))
RETURNS decimal(18,2) as
begin

  DECLARE @ye as decimal(18,2) 
  DECLARE @NewFactoryName varchar(200)
  
  SET @ye=0
  
  
  IF @CRFlag='应收收'
  BEGIN
    SELECT @Ye=SUM(YEMoney)
    FROM(    
      SELECT YEMoney=isnull((case when CRType='应收款登记' then 1*(money )
                         when CRType='收款登记'   then -1*(money + DerateMoney)                         
                    end),0)
      from YF_Money_CR A 
      where CRTime<@CRTime AND factoryName=@factoryName AND CRFlag =@CRFlag
      UNION ALL
      SELECT YEMoney=isnull((case when CRType='应收款登记' then 1*(money )
                         when CRType='收款登记'   then -1*(money + DerateMoney)
                       
                    end),0)
      from YF_Money_CR A 
      where CRTime=@CRTime and A.YFID<=@YFID and  factoryName=@factoryName AND CRFlag =@CRFlag
      
      )AA
   END
   
  IF @CRFlag='应付付'
  BEGIN
  
    SELECT @NewFactoryName=ISNULL((select max(Note) from KH_Zdy  where ZdyName=@FactoryName and Type='Factory' and isnull(Note,'')<>''),'')
           
    SELECT @Ye=SUM(YEMoney)
    FROM(    
      SELECT YEMoney=isnull( (case when CRType='应付款登记' then 1*(money )
                         when CRType='付款登记'   then -1*(money + DerateMoney)
                         
                    end),0)
      from YF_Money_CR A 
      where CRTime<@CRTime  AND CRFlag =@CRFlag
            and exists(select ZdyName from KH_Zdy X 
                       where X.ZdyName=A.FactoryName and X.Type='Factory' and isnull(X.Note,'')=@NewFactoryName)
      UNION ALL
      SELECT YEMoney=isnull((case
                         when CRType='应付款登记' then 1*(money )
                         when CRType='付款登记'   then -1*(money + DerateMoney)
                         
                    end),0)
      from YF_Money_CR A 
      where CRTime=@CRTime and A.YFID<=@YFID  AND CRFlag =@CRFlag
            and exists(select ZdyName from KH_Zdy X 
                       where X.ZdyName=A.FactoryName and X.Type='Factory' and isnull(X.Note,'')=@NewFactoryName)
      
      )AA
   END
    return @ye         
end
GO
/****** Object:  StoredProcedure [dbo].[F_Get_Print_Order]    Script Date: 12/17/2021 15:51:27 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from JYOrder_Main
--exec F_Get_Print_Order'JM140605001         '
CREATE  Procedure [dbo].[F_Get_Print_Order]
 @mainID varchar(20)=''
as
begin
  SELECT A.*,B.*,
        ZQty=(select Sum(PRTOrderQty) from JYOrder_Sub B where B.MainId=A.MainId ),
        OrderUnit=(select Top 1 OrderUnit  from JYOrder_Sub B where B.MainId=A.MainId),
        khconNo=(select Top 1 khconNo  from JYOrdercon_main B where B.conNO=A.conNo)
  FROM JYOrder_Main A
  inner join JYOrder_Sub B on B.MainId=A.MainId
  where A.MainId=@mainID
 
end
GO
/****** Object:  UserDefinedFunction [dbo].[F_Get_Order_SubStr_PB]    Script Date: 12/17/2021 15:51:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  function [dbo].[F_Get_Order_SubStr_PB](@IdValue AS varchar(100),@FieldName varchar(20))
returns varchar(1000) as
begin
    declare @a as varchar(1000) 
    set @a=''
    declare @b as int
  
  if RTRIM(@FieldName)='MJCDHZSLPB'
  Begin
    select @a=@a+','+''+RTrim(isnull(ZZperson,''))+'→'+RTrim(CDName)+' '+Case when isnull(Cast(CDEnd as decimal(18,2)),0)>0 and isnull(Cast(CDBeg as decimal(18,2)),0)>0 and CDQty>0 
                                              then '从'+RTRIM(Cast(CDBeg as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))
                                                               +'到'+RTRIM(Cast(CDEnd as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))
                                                               +'长度:'+RTRIM(Cast(CDQty as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))
                                              when (isnull(Cast(CDEnd as decimal(18,2)),0)=0 or isnull(Cast(CDBeg as decimal(18,2)),0)=0) and CDQty>0 
                                              then '长度:'+RTRIM(Cast(CDQty as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))
                                               when isnull(Cast(CDEnd as decimal(18,2)),0)=0 and isnull(Cast(CDBeg as decimal(18,2)),0)>0  then 
                                                    RTRIM(Cast(CDBeg as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))+'处'
                                               else ' ' end
    from WFB_MJJY_CD_PB A inner join WFB_MJJY_PB B on A.MJID=B.MJID  where A.MJID=@IdValue
    select @b=Count(*)
    from WFB_MJJY_CD_PB where MJID=@IdValue
  End Else
  if RTRIM(@FieldName)='MJCDHZFM'
  Begin
    select @a=@a+','+''+RTrim(isnull(AA.ZZperson,''))+'→'+RTrim(AA.CDName)+':'+RTRIM(Cast(isnull(AA.CDGS,0) as varchar(20)))+'个'+AA.CDQty
    from(
    select A.ZZperson,A.CDName,A.CDGS,Case when isnull(A.CDQty,0)<>0 then ','+RTRIM(Cast(isnull(A.CDQty,0) as varchar(20)))+'米' else '' end as CDQty
    from WFB_MJJY_CD_PB A inner join WFB_MJJY_PB B on A.MJID=B.MJID  where A.MJID=@IdValue)AA
    Set @b=0
  End 
   if @b>1 
   begin
     Set @a=Cast(@b as varchar(20))+'个<'+substring(@a,2,len(@a))+'>'
   end else
   begin
     set @a=substring(@a,2,len(@a))
   end
   return @a         
end
GO
/****** Object:  UserDefinedFunction [dbo].[F_Get_Order_SubStr]    Script Date: 12/17/2021 15:51:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  function [dbo].[F_Get_Order_SubStr](@IdValue AS varchar(100),@FieldName varchar(30))
returns varchar(8000) as
begin
    declare @a as varchar(8000) 
    set @a=''
    declare @b as int
  if RTRIM(@FieldName)='MJCDHZ'
  Begin
    select @a=@a+','+'<'+RTrim(CDName)+' '+Case when CDEnd>0 then '从'+RTRIM(Cast(CDBeg as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))
                                                               +'到'+RTRIM(Cast(CDEnd as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))
                                                               +'长度:'+RTRIM(Cast(CDQty as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))+'>'
                                                else RTRIM(Cast(CDBeg as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))+'处>' end
    from WFB_MJJY_CD A inner join WFB_MJJY B on A.MJID=B.MJID  where A.MJID=@IdValue
    select @b=0 
  End Else
  if RTRIM(@FieldName)='MJCDHZSL'
  Begin
    select @a=@a+','+''+RTrim(CDName)+' '+Case when isnull(Cast(CDEnd as decimal(18,2)),0)>0 and isnull(Cast(CDBeg as decimal(18,2)),0)>0 and CDQty>0 
                                              then '从'+RTRIM(Cast(CDBeg as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))
                                                               +'到'+RTRIM(Cast(CDEnd as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))
                                                               +'长度:'+RTRIM(Cast(CDQty as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))
                                              when (isnull(Cast(CDEnd as decimal(18,2)),0)=0 or isnull(Cast(CDBeg as decimal(18,2)),0)=0) and CDQty>0 
                                              then '长度:'+RTRIM(Cast(CDQty as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))
                                               when isnull(Cast(CDEnd as decimal(18,2)),0)=0 and isnull(Cast(CDBeg as decimal(18,2)),0)>0  then 
                                                    RTRIM(Cast(CDBeg as varchar(20)))+RTRIM(isnull(B.MJTypeOther,''))+'处'
                                               else ' ' end
    from WFB_MJJY_CD A inner join WFB_MJJY B on A.MJID=B.MJID  where A.MJID=@IdValue
    select @b=Count(*)
    from WFB_MJJY_CD where MJID=@IdValue
  End Else
  if RTRIM(@FieldName)='QDHZ'
  Begin
    select @a=@a+','+''+RTrim(A.CDName)+cast(cast(A.CDBeg as int) as varchar(30))+'个'
    from WFB_MJJY_CD A inner join WFB_MJJY B on A.MJID=B.MJID  where A.MJID=@IdValue
    select @b=Count(*)
    from WFB_MJJY_CD where MJID=@IdValue
  End Else
  if RTRIM(@FieldName)='TPColor'
  Begin
    select @a=@a+','+''+RTrim(PRTColor)
    from Contract_Cloth_LLMX A inner join JYOrder_Sub B on A.OrdSubID=B.SubID  where B.MainID=@IdValue group by A.OrdSubID,B.PRTColor
    select @b=Count(*) from
    (select OrdSubID 
    from Contract_Cloth_LLMX A inner join JYOrder_Sub B on A.OrdSubID=B.SubID  where B.MainID=@IdValue group by A.OrdSubID,B.PRTColor) AA
  End Else
  if RTRIM(@FieldName)='OrdColor'
  Begin
    select @a=@a+','+''+RTrim(PRTColor)
    from  JYOrder_Sub B   where B.MainID=@IdValue group by B.SubID,B.PRTColor
    select @b=Count(*) from
    (select SubID 
    from  JYOrder_Sub B   where B.MainID=@IdValue group by B.SubID,B.PRTColor) AA
  End Else
  if RTRIM(@FieldName)='HCColor'
  Begin
    select @a=@a+','+''+RTrim(PRTColor)
    from  JYOrder_Sub_AnPai B  inner join JYOrder_Sub C on B.SubId=C.SubId where C.MainID=@IdValue group by B.SubID,C.PRTColor
    select @b=Count(*) from
    (select B.SubID 
    from  JYOrder_Sub_AnPai B  inner join JYOrder_Sub C on B.SubId=C.SubId where C.MainID=@IdValue group by B.SubID,C.PRTColor) AA
  End Else
  if RTRIM(@FieldName)='RKColor1'
  Begin
    select @a=@a+','+''+RTrim(PRTColor)
    from  CK_BanCp_CR B  inner join JYOrder_Sub C on B.SubId=C.SubId where C.MainID=@IdValue and B.CRType='检验入库'  group by B.SubID,C.PRTColor
    select @b=Count(*) from
    (select B.SubID 
    from  CK_BanCp_CR B  inner join JYOrder_Sub C on B.SubId=C.SubId where C.MainID=@IdValue and B.CRType='检验入库' group by B.SubID,C.PRTColor) AA
  End Else
  if RTRIM(@FieldName)='CKColor'
  Begin
    select @a=@a+','+''+RTrim(PRTColor)
    from  CK_BanCp_CR B  inner join JYOrder_Sub C on B.SubId=C.SubId where C.MainID=@IdValue and B.CRType='正常出库'  group by B.SubID,C.PRTColor
    select @b=Count(*) from
    (select B.SubID 
    from  CK_BanCp_CR B  inner join JYOrder_Sub C on B.SubId=C.SubId where C.MainID=@IdValue and B.CRType='正常出库' group by B.SubID,C.PRTColor) AA
  End
  Else
  if RTRIM(@FieldName)='ORdPrice'
  Begin
    select @a=@a+','+''+RTrim(Cast(PRTPrice as varchar(20)))
    from  JYOrder_Sub B   where B.MainID=@IdValue   group by B.PRTPrice
    select @b=Count(*) from
    (select PRTPrice from JYOrder_Sub B   where B.MainID=@IdValue   group by B.PRTPrice) AA
  End 
  Else
  if RTRIM(@FieldName)='ConOrdCPCode'
  Begin
    select @a=@a+','+''+RTrim(Cast(PrtCode as varchar(20)))
    from  JYOrderCon_Sub B   where B.MainID=@IdValue   group by B.PrtCode
    select @b=Count(*) from
    (select PrtCode from JYOrderCon_Sub B   where B.MainID=@IdValue   group by B.PrtCode) AA
  End 
  ELSE
  if RTRIM(@FieldName)='BNColor'
  Begin
    select @a=@a+','+''+RTrim(PRTColor)
    from  WFB_MJJY A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by B.PRTColor
    select @b=Count(*) from
   (select PRTColor from WFB_MJJY A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by B.PRTColor) AA
  End
  ELSE
  if RTRIM(@FieldName)='BNSOrddefstr1'
  Begin
    select @a=@a+','+''+RTrim(SOrddefstr1)
    from  WFB_MJJY A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by B.SOrddefstr1
    select @b=Count(*) from
   (select SOrddefstr1 from WFB_MJJY A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by B.SOrddefstr1) AA
  End
  ELSE
  if RTRIM(@FieldName)='BNSOrddefstr4'
  Begin
    select @a=@a+','+''+RTrim(SOrddefstr4)
    from  WFB_MJJY A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by B.SOrddefstr4
    select @b=Count(*) from
   (select SOrddefstr4 from WFB_MJJY A inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by B.SOrddefstr4) AA
  End
  ELSE
  if RTRIM(@FieldName)='BNPRtHX'
  Begin
    select @a=@a+','+''+RTrim(PRtHX)
    from  WFB_MJJY A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by B.PRtHX
    select @b=Count(*) from
   (select PRtHX from WFB_MJJY A inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by B.PRtHX) AA
  End
  ELSE
  if RTRIM(@FieldName)='BNMJLENLIST'
  Begin
    select @a=@a+'  '+cast(cast(MJLen as float) as varchar)
    from  WFB_MJJY A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue  -- group by A.MJLen
    select @b=Count(*) from
   (select MJLen from WFB_MJJY A inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue ) AA
  End
  ELSE
  if RTRIM(@FieldName)='BNGangNo'
  Begin
    select @a=@a+','+''+RTrim(A.MJstr4)
    from  WFB_MJJY A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by A.MJstr4
    select @b=1
  End
  ELSE
  if RTRIM(@FieldName)='BNPrtkuanno'
  Begin
    select @a=@a+','+''+RTrim(prtkuanNo)
    from  WFB_MJJY A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by B.prtkuanNo
    select @b=Count(*) from
   (select prtkuanNo from WFB_MJJY A inner join JYOrder_Sub B on B.subID=A.SubID   where A.BaoID=@IdValue   group by B.prtkuanNo) AA
  End
   ELSE
  if RTRIM(@FieldName)='RKColor'
  Begin
    select @a=@a+','+''+RTrim(Cast(PRTColor as varchar))
    from  CK_BanCP_CR A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.RKOrdID=@IdValue   group by B.PRTColor
    select @b=Count(*) from
   (select PRTColor from CK_BanCP_CR A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.RKOrdID=@IdValue   group by B.PRTColor) AA
  End
  ELSE
  if RTRIM(@FieldName)='RKSOrddefstr1'
  Begin
    select @a=@a+','+''+RTrim(Cast(SOrddefstr1 as varchar))
    from  CK_BanCP_CR A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.RKOrdID=@IdValue   group by B.SOrddefstr1
    select @b=Count(*) from
   (select SOrddefstr1 from CK_BanCP_CR A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.RKOrdID=@IdValue   group by B.SOrddefstr1) AA
  End
  ELSE
  if RTRIM(@FieldName)='RKSOrddefstr4'
  Begin
    select @a=@a+','+''+RTrim(Cast(SOrddefstr4 as varchar))
    from  CK_BanCP_CR A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.RKOrdID=@IdValue   group by B.SOrddefstr4
    select @b=Count(*) from
   (select SOrddefstr4 from CK_BanCP_CR A inner join JYOrder_Sub B on B.subID=A.SubID   where A.RKOrdID=@IdValue   group by B.SOrddefstr4) AA
  End
  ELSE
  if RTRIM(@FieldName)='RKPRtHX'
  Begin
    select @a=@a+','+''+RTrim(Cast(PRtHX as varchar))
    from  CK_BanCP_CR A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.RKOrdID=@IdValue   group by B.PRtHX
    select @b=Count(*) from
   (select PRtHX from CK_BanCP_CR A inner join JYOrder_Sub B on B.subID=A.SubID   where A.RKOrdID=@IdValue   group by B.PRtHX) AA
  End
  ELSE
  if RTRIM(@FieldName)='RKGangNO'
  Begin
    select @a=@a+','+''+RTrim(Cast(MJstr4 as varchar))
    from  CK_BanCP_CR A  inner join WFB_MJJY B on B.MJID=A.MJID   where A.RKOrdID=@IdValue and MJstr4<>''   group by B.MJstr4
    select @b=Count(*) from
   (select MJstr4 from CK_BanCP_CR A inner join WFB_MJJY B on B.MJID=A.MJID   where A.RKOrdID=@IdValue and MJstr4<>''   group by B.MJstr4) AA
  End
  ELSE
  if RTRIM(@FieldName)='RKPrtkuanno'
  Begin
    select @a=@a+','+''+RTrim(Cast(Prtkuanno as varchar))
    from  CK_BanCP_CR A  inner join JYOrder_Sub B on B.subID=A.SubID   where A.RKOrdID=@IdValue   group by B.prtkuanNo
    select @b=Count(*) from
   (select Prtkuanno from CK_BanCP_CR A inner join JYOrder_Sub B on B.subID=A.SubID   where A.RKOrdID=@IdValue   group by B.Prtkuanno) AA
  End
  ELSE
  if RTRIM(@FieldName)='ConNoHZ'
  Begin
    select @a=@a+','+''+RTrim(Cast(A.ConNo as varchar))
    from  JYOrderCon_Main A  inner join JYOrder_ConORD B on A.MainId=B.ConMainId   
    where B.MainId=@IdValue and isnull(B.Mainid,'')<>''   
    group by A.ConNo
    select @b=Count(*) from
   (select A.ConNo from  JYOrderCon_Main A  inner join JYOrder_ConORD B on A.MainId=B.ConMainId   
    where B.MainId=@IdValue   
    group by A.ConNo) AA
  End
  ELSE
  if RTRIM(@FieldName)='KHConNoHZ'
  Begin
    select @a=@a+','+''+RTrim(Cast(A.KHConNo as varchar))
    from  JYOrderCon_Main A  inner join JYOrder_ConORD B on A.MainId=B.ConMainId   
    where B.MainId=@IdValue and isnull(B.Mainid,'')<>''    
    group by A.KHConNo
    select @b=Count(*) from
   (select A.KHConNo from  JYOrderCon_Main A  inner join JYOrder_ConORD B on A.MainId=B.ConMainId   
    where B.MainId=@IdValue   
    group by A.KHConNo) AA
  End
  ELSE
  if RTRIM(@FieldName)='MDMJLENLIST'
  Begin
    select @a=@a+'/'+cast(cast(MJLen as float) as varchar)
    from  WFB_MJJY A  
    where exists(select MainID from WFB_MJJY X where X.MJID=@IdValue and X.baoNO=A.baoNo and X.Mjstr4=A.Mjstr4 and X.subID=A.Subid and isnull(baoNO,'')<>'')
    select @b=Count(*) from
   (select MJLen from WFB_MJJY A  where exists(select MainID from WFB_MJJY X where X.MJID=@IdValue and X.baoNO=A.baoNo and X.Mjstr4=A.Mjstr4 and X.subID=A.Subid and isnull(baoNO,'')<>'') ) AA
  End
  ELSE
  if RTRIM(@FieldName)='MDJZLIST'
  Begin
    select @a=@a+'/'+cast(cast(MJQty4 as float) as varchar)
    from  WFB_MJJY A  
    where exists(select MainID from WFB_MJJY X where X.MJID=@IdValue and X.baoNO=A.baoNo and X.Mjstr4=A.Mjstr4 and X.subID=A.Subid and isnull(baoNO,'')<>'')
    select @b=Count(*) from
   (select MJQty4 from WFB_MJJY A  where exists(select MainID from WFB_MJJY X where X.MJID=@IdValue and X.baoNO=A.baoNo and X.Mjstr4=A.Mjstr4 and X.subID=A.Subid and isnull(baoNO,'')<>'') ) AA
  End ELSE
  if RTRIM(@FieldName)='APJT'
  Begin
    select @a=@a+','+A.CarNo+','
    from  JYCon_Sub_AnPai A  
    where A.MainId=@IdValue
    Group by A.CarNo
    Set @b=1
  End  ELSE
  if RTRIM(@FieldName)='QYJT'
  Begin
    select @a=@a+','+A.CarNo+','
    from  Cloth_JiTai A  
    where A.MainId=@IdValue and StopFlag=0
    Group by A.CarNo
    Set @b=1
  End  ELSE
  if RTRIM(@FieldName)='TYJT'
  Begin
    select @a=@a+','+A.CarNo+','
    from  Cloth_JiTai A  
    where A.MainId=@IdValue and StopFlag=1
    Group by A.CarNo
    Set @b=1
  End  ELSE
  if RTRIM(@FieldName)='APInfo'
  Begin
    select @a=@a+','+A.CarNo+'→'+Cast(Count(*) as Varchar(20))+'匹'
    from  JYCon_Sub_AnPai A  
    where A.MainId=@IdValue
    Group by A.CarNo
    Set @b=1
  End
  
   if @b>1 
   begin
   --  Set @a=Cast(@b as varchar(20))+'个<'+substring(@a,2,len(@a))+'>'
      set @a=substring(@a,2,len(@a))
   end else
   begin
     set @a=substring(@a,2,len(@a))
   end
   return ltrim(@a)      
end
GO
/****** Object:  UserDefinedFunction [dbo].[F_Get_Order_MFKZ]    Script Date: 12/17/2021 15:51:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  function [dbo].[F_Get_Order_MFKZ](@IdValue AS varchar(100),@MFKZName varchar(20))
returns decimal(18,2) as
begin
    declare @a as decimal(18,2)
    declare @b as Varchar(20)
    if RTrim(@MFKZName)='MF'
    begin
      select @b=RTrim(MPRTMF) from JYOrder_Main where MainId=@IdValue
      Set @b=Substring(@b,charindex('/',@b)+1,2)
      Set @a=Cast(@b as decimal(18,2))*2.54
    end
    if RTrim(@MFKZName)='KZ'
    begin
      select @b=RTrim(MPRTKZ) from JYOrder_Main where MainId=@IdValue
      Set @b=Substring(@b,1,charindex('g',@b)-1)
      Set @a=Cast(@b as decimal(18,2))
    end
   return @a         
end
GO
/****** Object:  UserDefinedFunction [dbo].[F_Get_MFKZStr]    Script Date: 12/17/2021 15:51:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from CP_YDang where CYID='80003967'
--select  [dbo].[F_Get_MFKZStr]('80003967                      ')
CREATE  function [dbo].[F_Get_MFKZStr](@CYID AS varchar(30))
returns varchar(100) as
begin
  DECLARE @Str1 varchar(100) 
  DECLARE @M1 decimal(18,2)
  DECLARE @Y1 decimal(18,2)
  
  declare @MFUNIT varchar(20)
  declare @MF decimal(18,2)
  declare @MF1 varchar(20)
  declare @MF2 varchar(20)
  
  declare @KZUNIT varchar(20)
  declare @KZ decimal(18,2)
  declare @KZ1 varchar(20)
  declare @KZ2 varchar(20)
     
  select 
       @MF1=case when ISNULL(CYMF,'')='' then '0'
            when charindex('-',CYMF)>0 then '0'
            when charindex('/',CYMF)>0 then Substring(CYMF,1,charindex('/',CYMF)-1)
            when charindex('"',CYMF)>0 then Substring(CYMF,1,charindex('"',CYMF)-1)
            when charindex('”',CYMF)>0 then Substring(CYMF,1,charindex('”',CYMF)-1)
            when charindex('“',CYMF)>0 then Substring(CYMF,1,charindex('“',CYMF)-1)
            when charindex('''',CYMF)>0 then Substring(CYMF,1,charindex('''',CYMF)-1)
            when charindex('CM',CYMF)>0 then Substring(CYMF,1,charindex('CM',CYMF)-1)
            ELSE '0'
            end,
       @MF2=case when ISNULL(CYMF,'')='' then '0'
            when charindex('-',CYMF)>0 then '0'
            when charindex('/',CYMF)>0 and charindex('"',CYMF)>0 then Substring(CYMF,charindex('/',CYMF)+1,charindex('"',CYMF)-charindex('/',CYMF)-1)
            when charindex('/',CYMF)>0 and charindex('"',CYMF)>0 then Substring(CYMF,charindex('/',CYMF)+1,charindex('"',CYMF)-charindex('/',CYMF)-1)
            when charindex('/',CYMF)>0 and charindex('“',CYMF)>0 then Substring(CYMF,charindex('/',CYMF)+1,charindex('“',CYMF)-charindex('/',CYMF)-1)
            when charindex('/',CYMF)>0 and charindex('''',CYMF)>0 then Substring(CYMF,charindex('/',CYMF)+1,charindex('''',CYMF)-charindex('/',CYMF)-1)
            when charindex('/',CYMF)>0 and charindex('CM',CYMF)>0 then Substring(CYMF,charindex('/',CYMF)+1,charindex('CM',CYMF)-charindex('/',CYMF)-1)
            when charindex('/',CYMF)>0 then Substring(CYMF,charindex('/',CYMF)+1,len(CYMF)-charindex('/',CYMF))
            when charindex('"',CYMF)>0 then Substring(CYMF,1,charindex('"',CYMF)-1)
            when charindex('”',CYMF)>0 then Substring(CYMF,1,charindex('”',CYMF)-1)
            when charindex('“',CYMF)>0 then Substring(CYMF,1,charindex('“',CYMF)-1)
            when charindex('''',CYMF)>0 then Substring(CYMF,1,charindex('''',CYMF)-1)
            when charindex('CM',CYMF)>0 then Substring(CYMF,1,charindex('CM',CYMF)-1)
            ELSE '0'
            end,   
       @MFUNIT=case when ISNULL(CYMF,'')='' then ''
            when charindex('"',CYMF)>0 then Substring(CYMF,charindex('"',CYMF),len(CYMF)-charindex('"',CYMF)+1)
            when charindex('''',CYMF)>0 then Substring(CYMF,charindex('''',CYMF),len(CYMF)-charindex('''',CYMF)+1)
            when charindex('CM',CYMF)>0 then Substring(CYMF,charindex('CM',CYMF),len(CYMF)-charindex('CM',CYMF)+1)
            ELSE '0'
            end,       
       @KZ1=case when ISNULL(CYKZ,'')='' then '0'
            when charindex('G',CYKZ)<=0 then '0'
            when charindex('-',CYKZ)>0 then Substring(CYKZ,1,charindex('-',CYKZ)-1)
            when charindex('G',CYKZ)>0 then Substring(CYKZ,1,charindex('G',CYKZ)-1)
            ELSE '0'
            end ,
       @KZ2=case when ISNULL(CYKZ,'')='' then '0'
            when charindex('G',CYKZ)<=0 then '0'
            when charindex('-',CYKZ)>0 and charindex('G',CYKZ)>0 then Substring(CYKZ,charindex('-',CYKZ)+1,charindex('G',CYKZ)-charindex('-',CYKZ)-1)       
            when charindex('G',CYKZ)>0 then Substring(CYKZ,1,charindex('G',CYKZ)-1)
            ELSE '0'
            end,
       @KZUNIT=case when ISNULL(CYKZ,'')='' then ''
            when charindex('G',CYKZ)>0 then Substring(CYKZ,charindex('G',CYKZ),len(CYKZ)-charindex('G',CYKZ)+1)
            end            
   from CP_YDang
   where CYID=@CYID
   
   
   IF ISNUMERIC(@MF2)<1  SET @MF2='0'
   IF ISNUMERIC(@KZ2)<1  SET @KZ2='0'
       
  SELECT  @MF=CAST(isnull(@MF2,0) as DECIMAL(18,2)),@KZ=CAST(isnull(@KZ2,0) as DECIMAL(18,2))
  
  
  IF ISNULL(@MFUNIT,'')<>'' and ISNULL(@KZUNIT,'')<>'' AND @MF>0 and @KZ>0
  BEGIN
    IF ISNULL(@MFUNIT,'')<>'CM' and  ISNULL(@KZUNIT,'')='G/M'
    SET @m1=1*1.0000/(@MF*2.54/100)/(@KZ/(@MF*2.54/100)/1000)
    IF ISNULL(@MFUNIT,'')<>'CM' and  ISNULL(@KZUNIT,'')<>'G/M'
    SET @m1=1*1.0000/(@MF*2.54/100)/(@KZ/1000)  
    IF ISNULL(@MFUNIT,'')='CM' and  ISNULL(@KZUNIT,'')='G/M'
    SET @m1=1*1.0000/(@MF/100)/(@KZ/(@MF/100)/1000)
    IF ISNULL(@MFUNIT,'')='CM' and  ISNULL(@KZUNIT,'')<>'G/M'
    SET @m1=1*1.0000/(@MF/100)/(@KZ/1000)     
   
  END
  ELSE
  SET @m1=0
  
  SET @Y1=@m1/0.9144   
  
  SET @Str1=''
  IF @m1>0 SET @Str1=cast(@m1 as varchar)+' MT   '+cast(@Y1 as varchar)+' YDS'
  return @Str1         
end
GO
/****** Object:  UserDefinedFunction [dbo].[F_Get_JF_Price]    Script Date: 12/17/2021 15:51:47 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
create   FUNCTION [dbo].[F_Get_JF_Price](@mdate datetime,
                                              @mNumber  varchar(20),
                                              @whCode  varchar(40),
                                              @marea   varchar(40),
                                              @batchNum varchar(40),
                                              @factory  varchar(40),
                                              @P_Color    varchar(60),
                                              @flagtype int)
  RETURNS decimal(18,4)
AS
BEGIN
   DECLARE @qcNum    decimal(18,3)
   DECLARE @qcMoney  decimal(18,2)
   DECLARE @rkNum    decimal(18,3)
   DECLARE @ckNum    decimal(18,3)
   DECLARE @rkMoney  decimal(18,2)
   DECLARE @ckMoney  decimal(18,2)
   DECLARE @rkPrice  decimal(18,4)
    
   SELECT 
        @rkNum=SUM(case  x1.inoutflag WHEN '1' THEN x2.FactReceiptQuan ELSE 0 END),
        @ckNum=SUM(case  x1.inoutflag WHEN '0' THEN x2.FactIssueQuan ELSE 0 END),
        @rkMoney=SUM(case  x1.inoutflag WHEN '1' THEN isnull(x2.Emoney,0) ELSE 0 END),
        @ckMoney=SUM(case  x1.inoutflag WHEN '0' THEN isnull(x2.IssueMoney,0) ELSE 0 END)
   FROM JF_CRKmain x1,JF_CRKsub x2
          WHERE x1.inoutmainid=x2.inoutmainid   
                and x1.FillTime<@mdate
                and x2.mNumber=@mNumber 
                and x1.whcode=@whCode
                and x2.marea=@marea 
                and x2.batchnum=@batchnum 
                and x2.factory=@factory
                and X2.P_Color=@P_Color
          GROUP BY x1.whcode,x2.mNumber, x2.Marea, x2.BatchNum,x2.factory,X2.P_Color

  --0 入库平均；
  IF @flagtype=0 
  BEGIN
    IF isnull(@rkNum,0)>0
    	SET @rkPrice=cast(isnull(@rkMoney,0)/isnull(@rkNum,0) as decimal(18,4))
    ELSE
    	SET @rkPrice=0

  END
  ELSE IF @flagtype=1
  BEGIN
    IF abs(isnull(@rkNum,0)-isnull(@ckNum,0))>0
    	SET @rkPrice=cast((isnull(@rkMoney,0) - isnull(@ckMoney,0))/(isnull(@rkNum,0) - isnull(@ckNum,0)) as decimal(18,4))
    ELSE
    	SET @rkPrice=0 
   
  END

  RETURN ABS(@rkPrice)

END
GO
/****** Object:  StoredProcedure [dbo].[P_OrderNo_YSK]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[P_OrderNo_YSK]
  @Begdate varchar(20),
  @Enddate varchar(20)
AS
select A.MainId,A.OrderNo,A.MPRTCodeName,
       CRTime=(select Top 1 CRTime from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记' ),
       Qty=(select isnull(sum(Qty),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记') ,
       Price=(select Top 1 Price from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记') ,
       --HuiLv=(select Top 1 HuiLv from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记') ,
       HuiLv=(select sum(Money*HuiLv)*1.00/sum(Money) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='收款登记' 
                  and isnull(YFName,'')<>'退税' and isnull(YC.BZType,'')='USD') ,
       BZType=(select Top 1 BZType from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRFlag='应收收') ,
       QtyUnit=(select Top 1 QtyUnit from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记'),
       YSYBMoney=(select isnull(sum(Money),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记' 
                  and isnull(BZType,'')='USD') ,
       KPMoney=(select isnull(sum(KPMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款发票登记') ,
       YSBBMoney=(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记') ,
       SKYBMoney=(select isnull(sum(Money),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='收款登记' 
                  and isnull(YFName,'')<>'退税' and isnull(BZType,'')='USD') ,
       PJMoney=(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='收款登记' 
                  and isnull(YFName,'')<>'退税' and isnull(BZType,'')='USD') ,
       SKBBMoney=(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='收款登记') ,
       YSYBYMoney=(select isnull(sum(Money),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记' 
                   and isnull(BZType,'')='USD')
                  -(select isnull(sum(Money),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='收款登记' 
                    and isnull(YFName,'')<>'退税' and isnull(BZType,'')='USD'),
       SKTSBBMoney=(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='收款登记' and isnull(YFName,'')='退税') ,
       FKFS=(select Top 1 PayMent from JYOrderCon_Main C where C.ConNo=A.OrderNo) ,
       A.Filler ,
       A.OrdDefNote3,
       A.OrdDefNote4
from JYOrder_Main A
where exists(select * from YF_Money_CR B where B.MainId=A.MainId and B.CRFlag='应收收' 
             and B.CRTime>=@begdate and B.CRTime<@enddate)
      and not exists(select * from YF_Money_CR B where B.Mainid=A.Mainid and B.CRType='收款登记' and B.YFDefFlag1=1)
GO
/****** Object:  StoredProcedure [dbo].[P_View_YFK]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_YFK '2012-01-01','2014-01-01','1',''
CREATE Procedure [dbo].[P_View_YFK]
  @begdate varchar(20),
  @enddate varchar(20),
  @PState  int,
  @OrderNo  varchar(300)
AS
 if @PState=1
 begin
 DECLARE @MSql varchar(8000)
  Set @MSql=
         'select C.OrderNo 
         ,PBName=isnull((select Top 1 C_CodeName from Contract_Sub_MX CSM 
                   inner join Contract_Sub CS on CSM.SubId=CS.SubId 
                   where CSM.MXId=A.YFTypeID and A.YFName=''坯布费用''),A.P_CodeName)
         ,defstr1=(case when isnull(defstr1,'''')<>'''' then defstr1
                       when crType=''应付款登记'' and  isnull((select count(X.MXId) from Contract_Sub_MX X where X.MXId=A.YFTypeID),0)>0 then ''坯布费''
                       when crType=''应付款登记'' then ''加工费''
                       else '''' end) 
         ,A.CRID,A.YFId,A.Mainid,A.Subid,A.CRType,A.CRTIME,A.FactoryNo,A.FactoryName,A.YFName,
          A.PS,A.Qty,A.QtyUnit,A.Price,A.BZType,A.HuiLv,A.KPMoney,A.DerateMoney,A.PayMent,A.YFCode,
          A.ComTaiTou,A.YFDefFlag1,A.Note,A.YFType,A.QtyFlag,A.BBMoney
         ,fk_money=(case when isnull(A.CRType,'''')=''付款登记'' then Money else null end)
         ,Money=(case when isnull(A.CRType,'''')=''应付款登记'' then Money else null end)
         ,PRTColor=(select JS.PRTColor from JYOrder_Sub_AnPai JSA 
                    inner join JYOrder_Sub JS on JSA.SubId=JS.SubId where JSA.APID=A.YFTypeID )
         ,CPZHName=(select Top 1 CPZHName from JYOrderCon_Main JM where JM.ConNo=C.ConNo)
         ,CPCFBi=(select Top 1 CPCFBi from JYOrderCon_Main JM where JM.ConNo=C.ConNo)
         ,TJName=(select Top 1 ZDYNameTj from KH_Zdy_Attachment KZ where KZ.ZdyName=A.FactoryName and KZ.Type=''GYS'' and isnull(ZDYNameTj,'''')<>'''')
         ,YEMoney=dbo.F_Get_Yfk_Ye(A.FactoryName,A.crtime,A.crflag,A.YFID)
  from YF_Money_CR A
       inner join YF_Money_KC B on A.CRID=B.CRID
       left join JYOrder_Main C on A.MainId=C.MainId
  where A.CRType IN (''应付款登记'',''付款登记'')
  and A.CRTime>='''+@Begdate+''' and  A.CRTime<'''+@enddate+''' '
  if @OrderNo<>''
  Set @MSql=@MSql+@OrderNo
  
  Set @MSql=@MSql+' Order by A.CRTIME,A.YFID '
  
  PRINT(@MSql)
  exec(@MSql) 

 end
 if @PState=2
 begin
 select C.OrderNo 
         ,PBName=isnull((select Top 1 C_CodeName from Contract_Sub_MX CSM 
                   inner join Contract_Sub CS on CSM.SubId=CS.SubId 
                  where CSM.MXId=A.YFTypeID and A.YFName='坯布费用' ),A.P_codename)
         ,A.CRID,A.YFId,A.Mainid,A.Subid,A.CRType,A.CRTIME,A.FactoryNo,A.FactoryName,A.YFName,
          A.PS,A.Qty,A.QtyUnit,A.Price,A.BZType,A.HuiLv,A.KPMoney,A.DerateMoney,A.PayMent,
          A.ComTaiTou,A.YFDefFlag1,A.Note,A.YFType,A.QtyFlag,A.BBMoney,A.defstr1
         ,fk_money=(case when isnull(A.CRType,'''')='付款登记' then Money else null end)
         ,Money=(case when isnull(A.CRType,'''')='应付款登记' then Money else null end)
         ,PRTColor=(select JS.PRTColor from JYOrder_Sub_AnPai JSA 
                    inner join JYOrder_Sub JS on JSA.SubId=JS.SubId where JSA.APID=A.YFTypeID )
         ,CPZHName=(select Top 1 CPZHName from JYOrderCon_Main JM where JM.ConNo=C.ConNo)
         ,CPCFBi=(select Top 1 CPCFBi from JYOrderCon_Main JM where JM.ConNo=C.ConNo)
         ,TJName=(select Top 1 ZDYNameTj from KH_Zdy_Attachment KZ where KZ.ZdyName=A.FactoryName and KZ.Type='GYS' and isnull(ZDYNameTj,'')<>'')
  from YF_Money_CR A
       inner join YF_Money_KC B on A.CRID=B.CRID
       left join JYOrder_Main C on A.MainId=C.MainId
  where C.OrderNo like @OrderNo and A.CRType IN ('应付款登记','付款登记')
  end
GO
/****** Object:  StoredProcedure [dbo].[P_View_PBJGMoney]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec [P_View_PBJGMoney] '2015-02-23','2015-03-23'
Create Procedure [dbo].[P_View_PBJGMoney]
  @begdate varchar(20),
  @enddate varchar(20)
AS
  select AAA.*,
         ConNo=(select ConNo from Cloth_Main where MainId=AAA.MainId ),
         C_CodeName=(select Top 1 C_CodeName  from Cloth_Sub where MainId=AAA.MainId ),
         ConDefStr2=(select Top 1 ConDefStr2  from Cloth_Sub where MainId=AAA.MainId ),
         ConDefStr3=(select Top 1 ConDefStr3  from Cloth_Sub where MainId=AAA.MainId ),
         ConDefStr4=(select Top 1 ConDefStr4  from Cloth_Sub where MainId=AAA.MainId ),
         ConDefStr1=(select Top 1 ConDefStr1  from Cloth_Sub where MainId=AAA.MainId ),
         CarType=(select Top 1 ConDefStr2 from Cloth_Sub CS where CS.MainId=AAA.MainId),
         Money=Cast(((SumMJMaoZ*1.00/MaxMJMaoZ)*ZhuanQty-SumDelZhuan+SumAddZhuan)*1.00/ZhuanOne*JGPrice+SumAddMoney-SumDelMoney
                    as decimal(18,2))
  from(
  select AA.*  from (
  select B.MainId,APDate=Convert(varchar(10),AP.APDate,120),AP.SCPerson,MaxMJMaoZ=max(B.MJMaoZ),
       SumMJMaoZ=Sum(B.MJMaoZ),SumDelZhuan=sum(B.MJQty4),SumAddZhuan=sum(B.MJQty5),
       SumAddMoney=sum(isnull(B.AddMoney,0)),SumDelMoney=sum(isnull(B.DelMoney,0)),
       ZhuanOne=(select Top 1 DEFFlt2 from KH_Zdy_Attachment 
                 where Type='C_CodeName' and OrderNo=CM.ConNo and DEFstr3=AP.CarNo),
       JGPrice=(select Top 1 DEFFlt3 from KH_Zdy_Attachment 
                 where Type='C_CodeName' and OrderNo=CM.ConNo and DEFstr3=AP.CarNo),
       ZhuanQty=Cast(CM.ZhuanStr as int),--alter table KH_Zdy_Attachment Add OrderNo varchar(20) Null 
       AP.CarNo
  from WFB_MJJY_PB B 
  inner join JYCon_Sub_AnPai AP on B.APID=AP.APID
  inner join Cloth_Sub CS on AP.SubId=AP.SubId
  inner join Cloth_Main CM on CS.MainId=CM.MainId
  where AP.APDate>=@begdate and AP.APDate<@enddate
  group by B.MainId,Convert(varchar(10),AP.APDate,120),AP.CarNo,AP.SCPerson,CM.ZhuanStr,CM.ConNo) AA)AAA
GO
/****** Object:  StoredProcedure [dbo].[P_View_Order_JDSub]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec [P_View_Order_JD] ' and A.OrdDate>=''2017-02-14'' and A.OrdDate<=''2017-04-29''',''
CREATE Procedure [dbo].[P_View_Order_JDSub]
  @Mainid varchar(20)
AS
BEGIN
  DECLARE @MSql varchar(8000)
  DECLARE @TA varchar(500)
  
  CREATE TABLE #Tab_main
  (mainID  varchar(30),
   subID   varchar(30)
  )
  
  SET @MSql=' INSERT INTO #Tab_main
              SELECT MainID,Subid
              from JYOrder_Sub A 
              where Mainid='+@Mainid +' '
  EXEC (@MSql)
  
  --坯布入库
  SELECT A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType,SUM(A.piQty) as piQty,SUM(A.Qty) as Qty,max(A.QtyUnit) as QtyUnit
  INTO #Tab_PBRK
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='坯布' and A.CRFlag='入库' and A.CRType<>'生产退回'
  GROUP BY A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType
  
  --坯布出库
  SELECT A.ordMainIDCK,A.ordSubIDCK,A.CKName,A.CRType,SUM(A.piQty*CRQtyFlag*-1) as piQty,SUM(A.Qty*CRQtyFlag*-1) as Qty,max(A.QtyUnit) as QtyUnit
  INTO #Tab_PB
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDCK)
        and A.CKName='坯布' and (A.CRFlag='出库' or CRType='生产退回')
  GROUP BY A.ordMainIDCK,A.ordSubIDCK,A.CKName,A.CRType
  
  --坯布库存
  SELECT A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType,SUM(A.PiQty*A.CRQtyFlag) as piQty,SUM(A.Qty*A.CRQtyFlag) as Qty,max(A.QtyUnit) as QtyUnit
  INTO #Tab_PBKC
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='坯布' 
  GROUP BY A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType
  
  
  --待检入库
  SELECT A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType,SUM(piQty*CRQtyFlag) as piQty,SUM(Qty*CRQtyFlag) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_HC
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='待检布' and ((A.CRFlag='入库' and A.CRType not in ('检验退回','成品退回')) or A.CRType='采购退货')
  GROUP BY A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType
  
  --待检出库
  SELECT A.ordMainIDCK,A.ordSubIDCK,A.CKName,A.CRType,SUM(A.piQty*CRQtyFlag*-1) as piQty,SUM(A.Qty*CRQtyFlag*-1) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_HCCK
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDCK)
        and A.CKName='待检布' and ((A.CRFlag='出库' and A.CRType<>'采购退货') or A.CRType in ('检验退回','成品退回'))
  GROUP BY A.ordMainIDCK,A.ordSubIDCK,A.CKName,A.CRType
  
  --待检库存
  SELECT A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType,SUM(A.PiQty*A.CRQtyFlag) as piQty,SUM(A.Qty*A.CRQtyFlag) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_HCKC
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='待检布' 
  GROUP BY A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType
  
  --成品入库
  SELECT A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType,SUM(piQty) as piQty,SUM(Qty) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_CPRK
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='成品' and A.CRFlag='入库'
  GROUP BY A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType
  
  --成品出库
  SELECT A.ordMainIDCK,A.ordSubIDCK,A.CKName,A.CRType,SUM(piQty) as piQty,SUM(Qty) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_CPCK
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDCK)
        and A.CKName='成品' and A.CRFlag='出库'
  GROUP BY A.ordMainIDCK,A.ordSubIDCK,A.CKName,A.CRType
  
  --成品库存
  SELECT A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType,SUM(A.PiQty*A.CRQtyFlag) as piQty,SUM(A.Qty*A.CRQtyFlag) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_CPKC
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='成品' 
  GROUP BY A.ordMainIDRK,A.ordSubIDRK,A.CKName,A.CRType
      
     SELECT AA.*,
         TP_SH=TP_Qty-HC_Qty,
         TP_SL=CASE when TP_Qty>0 then (TP_Qty-HC_Qty)/TP_Qty*100 end,
         JY_SH=HCCK_Qty-isnull(CPRKQty,0),
         JY_SL=case when isnull(HCCK_Qty,0)>0 then (HCCK_Qty-isnull(CPRKQty,0))/HCCK_Qty*100 end
     INTO #Tab_ZCX
     from(
     select A.mainID,B.Subid,
                A.orderNO,A.CustomerNoName,A.OrdPerson1,A.OrdPerson2,A.YWY,A.Filler,A.FillTime,A.OrdDate,
                A.DlyDate,A.Note,A.MPRTCode,A.MPRTCodeName,A.MPRTSpec,A.ConNO,A.OrderUnit,A.PrtOrderQty,
                PBRKPS=(select SUM(piQty) from #Tab_PBRK X where X.ordSubidRK=B.Subid),
                PBRKQty=isnull((select SUM(Qty) from #Tab_PBRK X where X.ordSubidRK=B.Subid),0),
                TP_RollNum=(select SUM(piQty) from #Tab_PB X where X.ordSubidCK=B.Subid),
                TP_Qty=isnull((select SUM(Qty) from #Tab_PB X where X.ordSubidCK=B.Subid),0),
                TP_Unit=(select Top 1 QtyUnit from #Tab_PB X where X.ordSubidCK=B.Subid),
                PBKCPS=(select SUM(piQty) from #Tab_PBKC X where X.ordSubidRK=B.Subid),
                PBKCQty=isnull((select SUM(Qty) from #Tab_PBKC X where X.ordSubidRK=B.Subid),0),
                HC_RollNum=(select SUM(piQty) from #Tab_HC X where X.ordSubidRK=B.Subid),
                HC_Qty=isnull((select SUM(Qty) from #Tab_HC X where X.ordSubidRK=B.Subid),0),
                HC_Unit=(select Top 1 QtyUnit from #Tab_HC X where X.ordSubidRK=B.Subid),
                HCCK_RollNum=(select SUM(piQty) from #Tab_HCCK X where X.ordSubidCK=B.Subid),
                HCCK_Qty=isnull((select SUM(Qty) from #Tab_HCCK X where X.ordSubidCK=B.Subid),0),
                HCCK_Unit=(select Top 1 QtyUnit from #Tab_HCCK X where X.ordSubidCK=B.Subid),
                DJKCPS=(select SUM(piQty) from #Tab_HCKC X where X.ordSubidRK=B.Subid ),
                DJKCQty=isnull((select SUM(Qty) from #Tab_HCKC X where X.ordSubidRK=B.Subid),0),
                CPRKPS=(select SUM(piQty) from #Tab_CPRK X where X.ordSubidRK=B.Subid ),
                CPRKQty=isnull((select SUM(Qty) from #Tab_CPRK X where X.ordSubidRK=B.Subid ),0),
                CPCKPS=(select SUM(piQty) from #Tab_CPCK X where X.ordSubidCK=B.Subid),
                CPCKQty=isnull((select SUM(Qty) from #Tab_CPCK X where X.ordSubidCK=B.Subid ),0),
                CPKCPS=(select SUM(piQty) from #Tab_CPKC X where X.ordSubidRK=B.Subid),
                CPKCQty=isnull((select SUM(Qty) from #Tab_CPKC X where X.ordSubidRK=B.Subid),0)
        from JYOrder_Main A 
        inner join JYOrder_Sub B on A.MainId=B.Mainid
         where exists(select X.MainId from #Tab_main X where X.mainID=A.MainID)
         )AA 
   drop table #Tab_PB
   drop table #Tab_HC
   drop table #Tab_HCCK
   drop table #Tab_ZCX
   drop table #Tab_HCKC
   drop table #Tab_PBRK
   drop table #Tab_PBKC
   drop table #Tab_main
END
GO
/****** Object:  StoredProcedure [dbo].[P_View_Order_JD]    Script Date: 12/17/2021 15:51:33 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec [P_View_Order_JD] ' and A.OrdDate>=''2017-12-14'' and A.OrdDate<=''2018-04-29''',''
CREATE Procedure [dbo].[P_View_Order_JD]
  @WSql    varchar(2000),
  @Than    varchar(3)
AS
BEGIN
  DECLARE @MSql varchar(8000)
  DECLARE @TA varchar(500)
  
  CREATE TABLE #Tab_main
  (mainID  varchar(30),
   subID   varchar(30)
  )
  
  SET @MSql=' INSERT INTO #Tab_main(mainID)
              SELECT MainID
              from JYOrder_Main A 
              where 1=1 '+@WSql +' '
  EXEC (@MSql)
  
  --坯布入库
  SELECT A.ordMainIDRK,A.CKName,A.CRType,SUM(A.piQty) as piQty,SUM(A.Qty) as Qty,max(A.QtyUnit) as QtyUnit
  INTO #Tab_PBRK
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='坯布' and A.CRFlag='入库' and A.CRType<>'生产退回'
  GROUP BY A.ordMainIDRK,A.CKName,A.CRType
  
  --坯布出库
  SELECT A.ordMainIDCK,A.CKName,A.CRType,SUM(A.piQty*CRQtyFlag*-1) as piQty,SUM(A.Qty*CRQtyFlag*-1) as Qty,max(A.QtyUnit) as QtyUnit
  INTO #Tab_PB
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDCK)
        and A.CKName='坯布' and (A.CRFlag='出库' or CRType='生产退回')
  GROUP BY A.ordMainIDCK,A.CKName,A.CRType
  
  --坯布库存
  SELECT A.ordMainIDRK,A.CKName,A.CRType,SUM(A.PiQty*A.CRQtyFlag) as piQty,SUM(A.Qty*A.CRQtyFlag) as Qty,max(A.QtyUnit) as QtyUnit
  INTO #Tab_PBKC
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='坯布' 
  GROUP BY A.ordMainIDRK,A.CKName,A.CRType
  
  
  --待检入库
  SELECT A.ordMainIDRK,A.CKName,A.CRType,SUM(piQty*CRQtyFlag) as piQty,SUM(Qty*CRQtyFlag) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_HC
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='待检布' and ((A.CRFlag='入库' and A.CRType not in ('检验退回','成品退回')) or A.CRType='采购退货')
  GROUP BY A.ordMainIDRK,A.CKName,A.CRType
  
  --待检出库
  SELECT A.ordMainIDCK,A.CKName,A.CRType,SUM(A.piQty*CRQtyFlag*-1) as piQty,SUM(A.Qty*CRQtyFlag*-1) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_HCCK
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDCK)
        and A.CKName='待检布' and ((A.CRFlag='出库' and A.CRType<>'采购退货') or A.CRType in ('检验退回','成品退回'))
  GROUP BY A.ordMainIDCK,A.CKName,A.CRType
  
  --待检库存
  SELECT A.ordMainIDRK,A.CKName,A.CRType,SUM(A.PiQty*A.CRQtyFlag) as piQty,SUM(A.Qty*A.CRQtyFlag) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_HCKC
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='待检布' 
  GROUP BY A.ordMainIDRK,A.CKName,A.CRType
  
  --裁剪
  SELECT A.ordMainIDRK,A.CKName,A.CRType,SUM(piQty*CRQtyFlag) as piQty,SUM(Qty*CRQtyFlag) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_CJ
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='裁剪' and A.CRFlag='入库' and A.CRType<>'生产退回'
  GROUP BY A.ordMainIDRK,A.CKName,A.CRType
  
  --车工
  SELECT A.ordMainIDRK,A.CKName,A.CRType,SUM(piQty*CRQtyFlag) as piQty,SUM(Qty*CRQtyFlag) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_CG
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='车工' and A.CRFlag='入库' and A.CRType<>'生产退回'
  GROUP BY A.ordMainIDRK,A.CKName,A.CRType
  
  --包装
  SELECT A.ordMainIDRK,A.CKName,A.CRType,SUM(piQty*CRQtyFlag) as piQty,SUM(Qty*CRQtyFlag) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_BZ
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='包装' and A.CRFlag='入库' and A.CRType<>'生产退回'
  GROUP BY A.ordMainIDRK,A.CKName,A.CRType
  
  --成品入库
  SELECT A.ordMainIDRK,A.CKName,A.CRType,SUM(piQty) as piQty,SUM(Qty) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_CPRK
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='成品' and A.CRFlag='入库'
  GROUP BY A.ordMainIDRK,A.CKName,A.CRType
  
  --成品出库
  SELECT A.ordMainIDCK,A.CKName,A.CRType,SUM(piQty) as piQty,SUM(Qty) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_CPCK
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDCK)
        and A.CKName='成品' and A.CRFlag='出库'
  GROUP BY A.ordMainIDCK,A.CKName,A.CRType
  
  --成品库存
  SELECT A.ordMainIDRK,A.CKName,A.CRType,SUM(A.PiQty*A.CRQtyFlag) as piQty,SUM(A.Qty*A.CRQtyFlag) as Qty,max(QtyUnit) as QtyUnit
  INTO #Tab_CPKC
  FROM CK_SXPB_CR A
  WHERE exists(select X.MainId from #Tab_main X where X.mainID=A.ordMainIDRK)
        and A.CKName='成品' 
  GROUP BY A.ordMainIDRK,A.CKName,A.CRType
      
     SELECT AA.*,
         TP_SH=TP_Qty-(case when HC_Unit='Y' then HC_Qty/1.0936 else HC_Qty end),IFSH=cast('' as varchar(5)),
         TP_SL=CASE when TP_Qty>0 then (TP_Qty-(case when HC_Unit='Y' then HC_Qty/1.0936 else HC_Qty end))/TP_Qty*100 end,
         JY_SH=(case when HCCK_Unit='Y' then HCCK_Qty/1.0936 else HCCK_Qty end)-(case when CPRK_Unit='Y' then isnull(CPRKQty,0)/1.0936 else isnull(CPRKQty,0) end),
         JY_SL=case when isnull(HCCK_Qty,0)>0 then ((case when HCCK_Unit='Y' then HCCK_Qty/1.0936 else HCCK_Qty end)-
               (case when CPRK_Unit='Y' then isnull(CPRKQty,0)/1.0936 else isnull(CPRKQty,0) end))/(case when HCCK_Unit='Y' then HCCK_Qty/1.0936 else HCCK_Qty end)*100 end
     INTO #Tab_ZCX
     from(
     select A.mainID,
                A.orderNO,A.CustomerNoName,A.OrdPerson1,A.OrdPerson2,A.YWY,A.Filler,A.FillTime,A.OrdDate,
                A.DlyDate,A.Note,A.MPRTCode,A.MPRTCodeName,A.MPRTSpec,A.ConNO,A.WCStatus,
                ConMainid=(select X.Mainid from JYOrderCon_Main X where X.ConNo=A.ConNo),
                OrderUnit=(select top 1 OrderUnit from JYOrder_sub X where X.mainID=A.mainID),
                PrtOrderQty=(select sum(PrtOrderQty) from JYOrder_sub X where X.mainID=A.mainID),
                PBRKPS=(select SUM(piQty) from #Tab_PBRK X where X.ordMainIDRK=A.mainID),
                PBRKQty=isnull((select SUM(Qty) from #Tab_PBRK X where X.ordMainIDRK=A.mainID),0),
                TP_RollNum=(select SUM(piQty) from #Tab_PB X where X.ordMainIDCK=A.mainID),
                TP_Qty=isnull((select SUM(Qty) from #Tab_PB X where X.ordMainIDCK=A.mainID),0),
                TP_Unit=(select Top 1 QtyUnit from #Tab_PB X where X.ordMainIDCK=A.mainID),
                PBKCPS=(select SUM(piQty) from #Tab_PBKC X where X.ordMainIDRK=A.mainID),
                PBKCQty=isnull((select SUM(Qty) from #Tab_PBKC X where X.ordMainIDRK=A.mainID),0),
                CJQty=isnull((select SUM(Qty) from #Tab_CJ X where X.ordMainIDRK=A.mainID),0),
                CGQty=isnull((select SUM(Qty) from #Tab_CG X where X.ordMainIDRK=A.mainID),0),
                BZQty=isnull((select SUM(Qty) from #Tab_BZ X where X.ordMainIDRK=A.mainID),0),
                HC_RollNum=(select SUM(piQty) from #Tab_HC X where X.ordMainIDRK=A.mainID),
                HC_Qty=isnull((select SUM(Qty) from #Tab_HC X where X.ordMainIDRK=A.mainID),0),
                HC_Unit=(select Top 1 QtyUnit from #Tab_HC X where X.ordMainIDRK=A.mainID),
                HCCK_RollNum=(select SUM(piQty) from #Tab_HCCK X where X.ordMainIDCK=A.mainID),
                HCCK_Qty=isnull((select SUM(Qty) from #Tab_HCCK X where X.ordMainIDCK=A.mainID),0),
                HCCK_Unit=(select Top 1 QtyUnit from #Tab_HCCK X where X.ordMainIDCK=A.mainID),
                DJKCPS=(select SUM(piQty) from #Tab_HCKC X where X.ordMainIDRK=A.mainID ),
                DJKCQty=isnull((select SUM(Qty) from #Tab_HCKC X where X.ordMainIDRK=A.mainID),0),
                CPRKPS=(select SUM(piQty) from #Tab_CPRK X where X.ordMainIDRK=A.mainID ),
                CPRKQty=isnull((select SUM(Qty) from #Tab_CPRK X where X.ordMainIDRK=A.mainID ),0),
                CPRK_Unit=(select Top 1 QtyUnit from #Tab_CPRK X where X.ordMainIDRK=A.mainID ),
                CPCKPS=(select SUM(piQty) from #Tab_CPCK X where X.ordMainIDCK=A.mainID),
                CPCKQty=isnull((select SUM(Qty) from #Tab_CPCK X where X.ordMainIDCK=A.mainID ),0),
                CPKCPS=(select SUM(piQty) from #Tab_CPKC X where X.ordMainIDRK=A.mainID),
                CPKCQty=isnull((select SUM(Qty) from #Tab_CPKC X where X.ordMainIDRK=A.mainID),0)
        from JYOrder_Main A 
         where exists(select X.MainId from #Tab_main X where X.mainID=A.MainID)
         )AA 
   if RTRIM(@Than)='1'
   begin
     select * from #Tab_ZCX 
     where isnull(TP_RollNum,0)>isnull(HC_RollNum,0) 
   end
   if RTRIM(@Than)='2'
   begin
     select * from #Tab_ZCX 
     where isnull(TP_RollNum,0)<=isnull(HC_RollNum,0) 
   end
   if RTRIM(@Than)=''
   begin
     select * from #Tab_ZCX where 1=1
   end
   drop table #Tab_PB
   drop table #Tab_HC
   drop table #Tab_HCCK
   drop table #Tab_ZCX
   drop table #Tab_HCKC
   drop table #Tab_PBRK
   drop table #Tab_PBKC
   drop table #Tab_main
   drop table #Tab_CJ
   drop table #Tab_CG
   drop table #Tab_BZ
END
GO
/****** Object:  StoredProcedure [dbo].[P_View_DJClothKC]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_DJClothKC
CREATE Procedure [dbo].[P_View_DJClothKC]
AS
select A.MainId,A.SubId,A.APID,A.GangNo,A.AOrddefstr1,A.AOrdQty1,A.AOrdQty2,A.AOrddefstr2,A.ADefDate1,
       B.OrderNo,B.CustomerNoName,B.DlyDate,B.OrdDate,B.MPRTCode,B.MPRTCodeName,B.MPRTSpec,
       B.MPRTMF,B.MPRTKZ,B.OrdPerson1,B.OrdPerson2,
       C.PRTColor,C.PRTHX
from JYOrder_Sub_AnPai A
inner join JYOrder_Main B on A.MainId=B.MainId
inner join JYOrder_Sub C  on A.SubId=C.SubId
where not exists(select * from WFB_MJJY D where D.APID=A.APID)
GO
/****** Object:  StoredProcedure [dbo].[P_View_DJBKCBak]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_DJBKC
Create Procedure [dbo].[P_View_DJBKCBak]
AS

select A.MainId,A.SubId,A.GangNo,isnull(sum(A.AOrdQty1),0) HCQty,isnull(Sum(A.AOrdQty2),0) HCPS,A.AOrddefstr2 
into #Temp1   
from JYOrder_Sub_AnPai A
where not exists(select * from WFB_MJJY D where D.APID=A.APID)
group by MainId,SubId,GangNo,AOrddefstr2

select C.MainId,C.SubId,A.GangNo,isnull(sum(A.HXQty),0) HXQty,isnull(Sum(A.HXPS),0) HXPS
into #Temp2   
from Contract_Cloth_BefChkHX A
inner join Contract_Cloth_LL B on A.LLID=B.LLID
inner join JYOrder_Sub C  on B.OrdSubId=C.SubId
where exists(select * from #Temp1 D where D.SubId=C.SubId and D.GangNo=A.GangNo)
group by C.MainId,C.SubId,A.GangNo

select AA.*,BB.HXPS,BB.HXQty,KCQty=isnull(HCQty,0)-isnull(HXQty,0),KCPS=isnull(HCPS,0)-isnull(HXPS,0),
B.OrderNo,B.CustomerNoName,B.DlyDate,B.OrdDate,B.MPRTCode,B.MPRTCodeName,B.MPRTSpec,
       B.MPRTMF,B.MPRTKZ,B.OrdPerson1,B.OrdPerson2,
       C.PRTColor,C.PRTHX 
from #Temp1 AA
left join #Temp2 BB on AA.Mainid=BB.MainId and AA.SubId=BB.SubId and AA.GangNo=BB.GangNo
inner join JYOrder_Main B on AA.MainId=B.MainId
inner join JYOrder_Sub C  on AA.SubId=C.SubId
GO
/****** Object:  StoredProcedure [dbo].[P_View_DJBKC]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_DJBKC
CREATE Procedure [dbo].[P_View_DJBKC]
AS
select MainId,SubId,AOrddefstr2,isnull(sum(AOrdQty1),0) HCQty,isnull(Sum(AOrdQty2),0) HCPS,
       JY_ps=SUM(JY_ps),JY_Qty=SUM(JY_Qty)
into #Temp1
from(
  select A.MainId,A.SubId,A.AOrdQty1,A.AOrdQty2,A.AOrddefstr2,
       JY_ps=(select count(D.mainID) from  WFB_MJJY D where D.APID=A.APID),
       JY_Qty=(select sum(D.MJMaoZ) from WFB_MJJY D where D.APID=A.APID)  
    from JYOrder_Sub_AnPai A
)AA
group by MainId,SubId,AOrddefstr2

/*
select C.MainId,C.SubId,isnull(sum(A.HXQty),0) HXQty,isnull(Sum(A.HXPS),0) HXPS
into #Temp2   
from Contract_Cloth_BefChkHX A
inner join Contract_Cloth_LL B on A.LLID=B.LLID
inner join JYOrder_Sub C  on B.OrdSubId=C.SubId
where exists(select * from #Temp1 D where D.SubId=C.SubId )
group by C.MainId,C.SubId
*/

select AA.*,KCQty=isnull(HCQty,0)-isnull(Jy_Qty,0),KCPS=isnull(HCPS,0)-isnull(jy_ps,0),
       B.OrderNo,B.CustomerNoName,B.DlyDate,B.OrdDate,B.MPRTCode,B.MPRTCodeName,B.MPRTSpec,
       B.MPRTMF,B.MPRTKZ,B.OrdPerson1,B.OrdPerson2,
       C.PRTColor,C.PRTHX 
from #Temp1 AA
inner join JYOrder_Main B on AA.MainId=B.MainId
inner join JYOrder_Sub C  on AA.SubId=C.SubId
GO
/****** Object:  StoredProcedure [dbo].[P_View_CPXGKC]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_View_CPXGKC '全棉',0

CREATE Procedure [dbo].[P_View_CPXGKC]
  @MPTCodeName varchar(100),
  @PState int --0模糊，1精确
AS

Create Table #TempOrderNo(MainId varchar(20),OrderNo varchar(100))
if @PState=0
begin
  insert into #TempOrderNo
  select MainId,Orderno
  from JYOrder_Main where MPRTCodeName like '%'+@MPTCodeName+'%'
end
if @PState=1
begin
  insert into #TempOrderNo
  select MainId,Orderno
  from JYOrder_Main where MPRTCodeName=@MPTCodeName
end
Select BB.* from(
Select AA.SPName,CKName,CFDD,QtyUnit,QtyKC=SUM(Qty*CRQtyFlag),Case when CKName='坯布' then CAST (1 AS int) 
                 when CKName='外加工' then CAST (2 AS int) 
                 when CKName='待检布' then CAST (3 AS int) 
                 when CKName='成品' then CAST (4 AS int) end as XH 
from(
select CKName='坯布',SPName,QtyUnit,CFDD=(case when CRQtyFlag=1 then ToFactoryName else FromFactoryName end),CRQtyFlag,Qty from CK_SXPB_CR A 
where CKName='坯布'
and SPName in(select SPName from CK_SXPB_CR B 
               where B.ORDMainIdCK in(select MainId from #TempOrderNo)
               and CKName='坯布' and CRFlag='出库')
Union All
select CKName,SPName,QtyUnit,CFDD=(case when CRQtyFlag=1 then ToFactoryName else FromFactoryName end),CRQtyFlag,Qty from CK_SXPB_CR A 
where CKName<>'坯布' and ORDMainIdRK in(select MainId from #TempOrderNo)
) AA Group by SPName,CKName,QtyUnit,CFDD)BB where QtyKC<>0 order by XH
   
Drop table #TempOrderNo
GO
/****** Object:  StoredProcedure [dbo].[P_View_BaoGuanData]    Script Date: 12/17/2021 15:51:32 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--Alter table JYOrder_BaoGuan_Main Add HTDate datetime null
--Alter table JYOrder_BaoGuan_Main Add KHName varchar(200) null
-- exec P_View_BaoGuanData 'BG170325008'
CREATE Procedure [dbo].[P_View_BaoGuanData]
  @BGID varchar(20)
AS
select A.*,B.*,Case when C5BGUnit='MTR' then C4BGQty else ZheSuanMiQty end as C4BGQtyJS
,Case when C5BGUnit='KG' then ZheSuanMiQty else Null  end as C4BGQtyJSKG
,Case when C5BGUnit='KG' then 'MTRS' else Null  end as C4BGQtyJSKGUnit
,Case when C5BGUnit='KG' then 'MTR' else 'KG'  end as C4BGZLFZUnit
,Case when C5BGUnit='KG' then ZheSuanMiQty else E4JingZ  end as C4BGZLFZQty
,Case when C5BGUnit<>'KG' then  E4JingZ else Null End As E4JingZJS
,Case when C5BGUnit<>'KG' then  'KGS' else Null End As JZUnit
,Case when C5BGUnit='KG' then  'KGS' else C5BGUnit End As C5BGUnitJS
 ,A1ChuKouShangEng=(select Note from KH_Zdy where Type='A1ChuKouShang' and ZdyName=A.A1ChuKouShang )
 ,A1ChuKouShangAddressEng=(select ZdyStr2 from KH_Zdy where Type='A1ChuKouShang' and ZdyName=A.A1ChuKouShang )
 ,A1ChuKouShangAddress=(select ZdyStr1 from KH_Zdy where Type='A1ChuKouShang' and ZdyName=A.A1ChuKouShang )
 ,B6ChuYunGangEng=(select Note from KH_Zdy where Type='B6ChuYunGang' and ZdyName=A.B6ChuYunGang )
,A.HTDate,KHNameEng=(select Note from KH_Zdy where Type='KHName' and ZdyName=A.KHName )
 ,Case when F1BaoGuanTK='FOB' then (select RTrim(Note)+',CHINA' from KH_Zdy where Type='B6ChuYunGang' and ZdyName=A.B6ChuYunGang ) 
            else B7DaoHuoGang end as B6B7
 ,Case when (select count(*) from (select E1BZUnit from JYOrder_BaoGuan_Sub BS where BS.BGId=A.BGId GROUP by E1BZUnit) AA)>1 then
       'PKGS' else (select Top 1 E1BZUnit from JYOrder_BaoGuan_Sub BS where BS.BGId=A.BGId) end as E1BZUnitJS
 from JYOrder_BaoGuan_Main A inner join JYOrder_BaoGuan_Sub B on A.BGId=B.BGId 
 where A.BGId=@BGID
GO
/****** Object:  StoredProcedure [dbo].[P_JYOrder_HZFX10]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from WFB_MJJY
--exec P_JYOrder_HZFX  '2012-01-01','2013-12-30',3

CREATE Procedure [dbo].[P_JYOrder_HZFX10]
  @begdate varchar(20),
  @enddate varchar(20),
  @PState  int  --1 按订单，2 按生产单, 3 按卷,4 按订单个数,5按生产单个数
As
  
  Create Table #Temp1(ORDID varchar(20),CDQty decimal(18,2) not null default(0))

  Create Table #Temp2(AutoId int identity(1,1) not null,CDName varchar(20))
  
  insert into #Temp2(CDName)
  select distinct(CDName) from WFB_MJJY_CD 

  DECLARE @Min int
  DECLARE @Max int
  
  select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
  --------------------------------------------------------------------------更新表结构
  DECLARE @Msql varchar(500)
  DECLARE @FileldName varchar(20)
  While @Min<=@Max 
  Begin
    select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
    Set @Msql='Alter table #Temp1 Add '+@FileldName+' decimal(18,2) not null default(0) '
    --print(@Msql)
    exec(@Msql)
    set @Min=@Min+1
  End
  --------------------------------------------------------------------------更新表结构

  --------------------------------------------------------------------------更新疵点数量
  IF @PState=1
  BEGIN
    insert into #Temp1(ORDID)
    select distinct(SubId) from WFB_MJJY where FillTime>=@begdate and FillTime<@enddate

    select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @Msql='Update #Temp1 Set '+@FileldName+'='
              +'(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
                inner join WFB_MJJY B on A.MJID=B.MJID 
                where B.SubId=#Temp1.ORDID and A.CDName='''+@FileldName+''')'
      --print(@Msql)
      exec(@Msql)
      set @Min=@Min+1
    End
    UPdate #Temp1 Set CDQty=(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
    inner join WFB_MJJY B on A.MJID=B.MJID where B.SubId=#Temp1.ORDID)
  END ELSE
  IF @PState=2
  BEGIN
    insert into #Temp1(ORDID)
    select distinct(APID) from WFB_MJJY where FillTime>=@begdate and FillTime<@enddate

    select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @Msql='Update #Temp1 Set '+@FileldName+'='
              +'(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
                inner join WFB_MJJY B on A.MJID=B.MJID 
                where B.APID=#Temp1.ORDID and A.CDName='''+@FileldName+''')'
      exec(@Msql)
      set @Min=@Min+1
    End
    UPdate #Temp1 Set CDQty=(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
    inner join WFB_MJJY B on A.MJID=B.MJID where B.APId=#Temp1.ORDID)
  END
  ELSE
  IF @PState=3
  BEGIN
    insert into #Temp1(ORDID)
    select distinct(MJID) from WFB_MJJY where FillTime>=@begdate and FillTime<@enddate

    select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @Msql='Update #Temp1 Set '+@FileldName+'='
              +'(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
                where A.MJID=#Temp1.ORDID and A.CDName='''+@FileldName+''')'
      exec(@Msql)
      set @Min=@Min+1
    End
    UPdate #Temp1 Set CDQty=(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
    where A.MJId=#Temp1.ORDID)
  END 
  Else
  IF @PState=4
  BEGIN
    insert into #Temp1(ORDID)
    select distinct(SubId) from WFB_MJJY where FillTime>=@begdate and FillTime<@enddate

    select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @Msql='Update #Temp1 Set '+@FileldName+'='
              +'(select isnull(count(*),0) from WFB_MJJY_CD A 
                inner join WFB_MJJY B on A.MJID=B.MJID 
                where B.SubId=#Temp1.ORDID and A.CDName='''+@FileldName+''')'
      --print(@Msql)
      exec(@Msql)
      set @Min=@Min+1
    End
    UPdate #Temp1 Set CDQty=(select isnull(count(*),0) from WFB_MJJY_CD A 
    inner join WFB_MJJY B on A.MJID=B.MJID where B.SubId=#Temp1.ORDID)
  END ELSE
  IF @PState=5
  BEGIN
    insert into #Temp1(ORDID)
    select distinct(APID) from WFB_MJJY where FillTime>=@begdate and FillTime<@enddate

    select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @Msql='Update #Temp1 Set '+@FileldName+'='
              +'(select isnull(count(*),0) from WFB_MJJY_CD A 
                inner join WFB_MJJY B on A.MJID=B.MJID 
                where B.APID=#Temp1.ORDID and A.CDName='''+@FileldName+''')'
      exec(@Msql)
      set @Min=@Min+1
    End
    UPdate #Temp1 Set CDQty=(select isnull(count(*),0) from WFB_MJJY_CD A 
    inner join WFB_MJJY B on A.MJID=B.MJID where B.APId=#Temp1.ORDID)
  END
  --------------------------------------------------------------------------更新疵点数量
  --------------------------------------------------------------------------显示数据
    DECLARE @ViewSql varchar(500)
    Set @ViewSql=''
    select @Min=Min(AutoId),@Max=Max(AutoId) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName='A.'+RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @ViewSql=@ViewSql+','+@FileldName
      set @Min=@Min+1
    End
  DECLARE @MainSql varchar(8000)
  IF @PState=1 or @PState=4
  BEGIN
    Set @MainSql='
    select C.OrderNo,gangno='''',RTrim(PRTColor) PRTColor,RTrim(MPRTMF) MPRTMF,RTrim(MPRTKZ) MPRTKZ,
           Rtrim(MPRTCodeName) MPRTCodeName,A.CDQty,
           MJMaoZ=(select Cast(sum(MJMaoZ) as decimal(18,2)) from WFB_MJJY WM where WM.SubID=A.ORDID),
           MJLen=(select Cast(sum(MJLen) as decimal(18,2)) from WFB_MJJY WM where WM.SubID=A.ORDID),
           JQty=(select count(*) from WFB_MJJY WM where WM.SubID=A.ORDID group by WM.SubId),
           CDUnit=(select Top 1 MJTypeOther from WFB_MJJY WM where WM.SubID=A.ORDID and isnull(WM.MJTypeOther,'''')<>'''')'+@ViewSql+' 
    from #Temp1 A 
    inner join JYOrder_Sub B on A.ORDID=B.SubId
    inner join JYOrder_Main C on B.MainId=C.MainId'
    exec(@MainSql)
   
  END ELSE
  IF @PState=2 or @PState=5
  BEGIN
    Set @MainSql='
    select CC.OrderNo,RTrim(B.gangno) gangno,RTrim(PRTColor) PRTColor,RTrim(MPRTMF) MPRTMF,RTrim(MPRTKZ) MPRTKZ,
           Rtrim(MPRTCodeName) MPRTCodeName,A.CDQty,
           MJMaoZ=(select Cast(sum(MJMaoZ) as decimal(18,2)) from WFB_MJJY WM where WM.APID=A.ORDID),
           MJLen=(select Cast(sum(MJLen) as decimal(18,2)) from WFB_MJJY WM where WM.APID=A.ORDID),
           JQty=(select count(*) from WFB_MJJY WM where WM.APID=A.ORDID group by WM.APID),
           CDUnit=(select Top 1 MJTypeOther from WFB_MJJY WM where WM.APID=A.ORDID and isnull(WM.MJTypeOther,'''')<>'''')'+@ViewSql+' 
    from #Temp1 A 
    inner join JYOrder_Sub_AnPai B on A.ORDID=B.APID
    inner join JYOrder_Sub BB on B.SubId=BB.SubId
    inner join JYOrder_Main CC on B.MainId=CC.MainId'
    exec(@MainSql)
   
  END ELSE
  IF @PState=3
  BEGIN
    Set @MainSql='
    select CC.OrderNo,B.GangNo,CC.MPRTCodeName,CC.MPRTMF,CC.MPRTKZ,
           C.*,BB.PRTColor,A.CDQty,CDQK=dbo.F_Get_Order_SubStr(A.ORDID,''MJCDHZSL'') '+@ViewSql+' 
    from #Temp1 A 
    inner join WFB_MJJY C on A.ORDID=C.MJID
    inner join JYOrder_Sub_AnPai B on C.APID=B.APID
    inner join JYOrder_Sub BB on C.SubId=BB.SubId
    inner join JYOrder_Main CC on C.MainId=CC.MainId'
    exec(@MainSql)
   
  END
  
  --------------------------------------------------------------------------显示数据
  Drop table #Temp1
  Drop table #Temp2
  



/****** 对象:  UserDefinedFunction [dbo].[F_Get_Order_SubStr]    脚本日期: 12/24/2012 14:36:05 ******/
SET ANSI_NULLS ON
GO
/****** Object:  StoredProcedure [dbo].[P_JYOrder_HZFX]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--select * from WFB_MJJY
--exec P_JYOrder_HZFX  '2016-01-01','2016-12-30',3,''
 --1 按订单，2 按生产单, 3 按卷,4 按订单个数,5按生产单个数,6单个按订单查询
CREATE Procedure [dbo].[P_JYOrder_HZFX]
  @begdate varchar(20),
  @enddate varchar(20),
  @PState  int,
  @FFWSql   varchar(200)

As
Create Table #Temp1(ORDID varchar(20),CDQty decimal(18,2) not null default(0))

  Create Table #Temp2(AutoId int identity(1,1) not null,CDName varchar(20))
  
  insert into #Temp2(CDName)
  select distinct(CDName) from WFB_MJJY_CD 

  DECLARE @Min int
  DECLARE @Max int
  
  select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
  --------------------------------------------------------------------------更新表结构
  DECLARE @Msql varchar(5000)
  DECLARE @FileldName varchar(20)
  While @Min<=@Max 
  Begin
    select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
    Set @Msql='Alter table #Temp1 Add '+@FileldName+' decimal(18,2) not null default(0) '
    --print(@Msql)
    exec(@Msql)
    set @Min=@Min+1
  End
  --------------------------------------------------------------------------更新表结构

  --------------------------------------------------------------------------更新疵点数量
  IF @PState=1
  BEGIN
    insert into #Temp1(ORDID)
    select distinct(SubId) from WFB_MJJY where FillTime>=@begdate and FillTime<@enddate

    select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @Msql='Update #Temp1 Set '+@FileldName+'='
              +'(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
                inner join WFB_MJJY B on A.MJID=B.MJID 
                where B.SubId=#Temp1.ORDID and A.CDName='''+@FileldName+''')'
      --print(@Msql)
      exec(@Msql)
      set @Min=@Min+1
    End
    UPdate #Temp1 Set CDQty=(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
    inner join WFB_MJJY B on A.MJID=B.MJID where B.SubId=#Temp1.ORDID)
  END ELSE
  IF @PState=2
  BEGIN
    insert into #Temp1(ORDID)
    select distinct(APID) from WFB_MJJY where FillTime>=@begdate and FillTime<@enddate

    select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @Msql='Update #Temp1 Set '+@FileldName+'='
              +'(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
                inner join WFB_MJJY B on A.MJID=B.MJID 
                where B.APID=#Temp1.ORDID and A.CDName='''+@FileldName+''')'
      exec(@Msql)
      set @Min=@Min+1
    End
    UPdate #Temp1 Set CDQty=(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
    inner join WFB_MJJY B on A.MJID=B.MJID where B.APId=#Temp1.ORDID)
  END
  ELSE
  IF @PState=3
  BEGIN
    insert into #Temp1(ORDID)
    select distinct(MJID) from WFB_MJJY where FillTime>=@begdate and FillTime<@enddate

    select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @Msql='Update #Temp1 Set '+@FileldName+'='
              +'(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
                where A.MJID=#Temp1.ORDID and A.CDName='''+@FileldName+''')'
      exec(@Msql)
      set @Min=@Min+1
    End
    UPdate #Temp1 Set CDQty=(select isnull(Sum(isnull(CDQty,0)),0) from WFB_MJJY_CD A 
    where A.MJId=#Temp1.ORDID)
  END 
  Else
  IF @PState=4
  BEGIN
    insert into #Temp1(ORDID)
    select distinct(SubId) from WFB_MJJY where FillTime>=@begdate and FillTime<@enddate

    select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @Msql='Update #Temp1 Set '+@FileldName+'='
              +'(select isnull(count(*),0) from WFB_MJJY_CD A 
                inner join WFB_MJJY B on A.MJID=B.MJID 
                where B.SubId=#Temp1.ORDID and A.CDName='''+@FileldName+''')'
      --print(@Msql)
      exec(@Msql)
      set @Min=@Min+1
    End
    UPdate #Temp1 Set CDQty=(select isnull(count(*),0) from WFB_MJJY_CD A 
    inner join WFB_MJJY B on A.MJID=B.MJID where B.SubId=#Temp1.ORDID)
  END ELSE
  IF @PState=5
  BEGIN
    insert into #Temp1(ORDID)
    select distinct(APID) from WFB_MJJY where FillTime>=@begdate and FillTime<@enddate

    select @Min=isnull(Min(AutoId),0),@Max=isnull(Max(AutoId),0) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName=RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @Msql='Update #Temp1 Set '+@FileldName+'='
              +'(select isnull(count(*),0) from WFB_MJJY_CD A 
                inner join WFB_MJJY B on A.MJID=B.MJID 
                where B.APID=#Temp1.ORDID and A.CDName='''+@FileldName+''')'
      exec(@Msql)
      set @Min=@Min+1
    End
    UPdate #Temp1 Set CDQty=(select isnull(count(*),0) from WFB_MJJY_CD A 
    inner join WFB_MJJY B on A.MJID=B.MJID where B.APId=#Temp1.ORDID)
  END
  --------------------------------------------------------------------------更新疵点数量
  --------------------------------------------------------------------------显示数据
    DECLARE @ViewSql varchar(500)
    Set @ViewSql=''
    select @Min=Min(AutoId),@Max=Max(AutoId) from #Temp2
    While @Min<=@Max 
    Begin
      select @FileldName='A.'+RTrim(CDName) from #Temp2 where AutoId=@Min
      Set @ViewSql=@ViewSql+','+@FileldName
      set @Min=@Min+1
    End
  DECLARE @MainSql varchar(8000)
  IF @PState=1 or @PState=4
  BEGIN
    Set @MainSql='
    select C.OrderNo,gangno='''',RTrim(PRTColor) PRTColor,RTrim(MPRTMF) MPRTMF,RTrim(MPRTKZ) MPRTKZ,
           Rtrim(MPRTCodeName) MPRTCodeName,A.CDQty,
           gangQty=(select Count(*) from JYOrder_Sub_AnPai AA where AA.SubId=B.SubId),
           MJMaoZ=(select Cast(sum(MJMaoZ) as decimal(18,2)) from WFB_MJJY WM where WM.SubID=A.ORDID),
           MJLen=(select Cast(sum(MJLen) as decimal(18,2)) from WFB_MJJY WM where WM.SubID=A.ORDID),
           ZPQty=(select Cast(sum(MJLen) as decimal(18,2)) from WFB_MJJY WM where WM.SubID=A.ORDID and WM.MJType=''正品''),
           CPQty=(select Cast(sum(MJLen) as decimal(18,2)) from WFB_MJJY WM where WM.SubID=A.ORDID and WM.MJType=''次品''),
           LYQty=(select Cast(sum(MJLen) as decimal(18,2)) from WFB_MJJY WM where WM.SubID=A.ORDID and WM.MJType=''留样''),
           JQty=(select count(*) from WFB_MJJY WM where WM.SubID=A.ORDID group by WM.SubId),
           ZPPS=(select count(*) from WFB_MJJY WM where WM.SubID=A.ORDID and WM.MJType=''正品'' group by WM.SubID ),
           CPPS=(select count(*) from WFB_MJJY WM where WM.SubID=A.ORDID and WM.MJType=''次品'' group by WM.SubID ),
           LYPS=(select count(*) from WFB_MJJY WM where WM.SubID=A.ORDID and WM.MJType=''留样'' group by WM.SubID ),
           CDUnit=(select Top 1 MJTypeOther from WFB_MJJY WM where WM.SubID=A.ORDID and isnull(WM.MJTypeOther,'''')<>'''')'+@ViewSql+' 
    from #Temp1 A 
    inner join JYOrder_Sub B on A.ORDID=B.SubId
    inner join JYOrder_Main C on B.MainId=C.MainId'
    exec(@MainSql+@FFWSql)
   
  END ELSE
  IF @PState=2 or @PState=5
  BEGIN
    Set @MainSql='
    select C.OrderNo,RTrim(B.AOrdDefStr1) gangno,RTrim(PRTColor) PRTColor,RTrim(MPRTMF) MPRTMF,RTrim(MPRTKZ) MPRTKZ,
           Rtrim(MPRTCodeName) MPRTCodeName,A.CDQty,gangQty=1,
           MJMaoZ=(select Cast(sum(MJMaoZ) as decimal(18,2)) from WFB_MJJY WM where WM.APID=A.ORDID),
           MJLen=(select Cast(sum(MJLen) as decimal(18,2)) from WFB_MJJY WM where WM.APID=A.ORDID),
           ZPQty=(select Cast(sum(MJLen) as decimal(18,2)) from WFB_MJJY WM where WM.APID=A.ORDID and WM.MJType=''正品''),
           CPQty=(select Cast(sum(MJLen) as decimal(18,2)) from WFB_MJJY WM where WM.APID=A.ORDID and WM.MJType=''次品''),
           LYQty=(select Cast(sum(MJLen) as decimal(18,2)) from WFB_MJJY WM where WM.APID=A.ORDID and WM.MJType=''留样''),
           JQty=(select count(*) from WFB_MJJY WM where WM.APID=A.ORDID group by WM.APID),
           ZPPS=(select count(*) from WFB_MJJY WM where WM.APID=A.ORDID and WM.MJType=''正品'' group by WM.APID ),
           CPPS=(select count(*) from WFB_MJJY WM where WM.APID=A.ORDID and WM.MJType=''次品'' group by WM.APID ),
           LYPS=(select count(*) from WFB_MJJY WM where WM.APID=A.ORDID and WM.MJType=''留样'' group by WM.APID ),
           CDUnit=(select Top 1 MJTypeOther from WFB_MJJY WM where WM.APID=A.ORDID and isnull(WM.MJTypeOther,'''')<>'''')'+@ViewSql+' 
    from #Temp1 A 
    inner join JYOrder_Sub_AnPai B on A.ORDID=B.APID
    inner join JYOrder_Sub BB on B.SubId=BB.SubId
    inner join JYOrder_Main C on B.MainId=C.MainId '
    exec(@MainSql+@FFWSql)
   
  END ELSE
  IF @PState=3
  BEGIN
    Set @MainSql='
    select CC.OrderNo,CC.conNO,B.GangNo,B.AOrdDefStr1,CC.MPRTCodeName,CC.MPRTMF,CC.MPRTKZ,CC.MPRTKuanNO,B.AOrddefstr6,B.AOrddefstr4,
           khconNO=(select top 1 khconNo from JYOrderCon_Main X where X.conNO=CC.conNO),
           ISHz=case when ISNULL(CC.koufenQty,0)=0 then ''合格'' 
                    when CC.koufenQty>isnull((select Sum(KouFenQty) from WFB_MJJY_CD X where X.MJID=C.MJID),0) then ''合格'' 
                    else ''不合格''end,
           C.*,BB.PRTColor,BB.SOrddefstr4,A.CDQty,CDQK=dbo.F_Get_Order_SubStr(A.ORDID,''MJCDHZSL''),CC.CustomerNoName,C.PanDing,
           KouFenQty=(select Sum(KouFenQty) from WFB_MJJY_CD CD where CD.MJID=C.MJID),C.MainId,C.SubId '+@ViewSql+' 
    from #Temp1 A 
    inner join WFB_MJJY C on A.ORDID=C.MJID
    inner join JYOrder_Sub_AnPai B on C.APID=B.APID
    inner join JYOrder_Sub BB on C.SubId=BB.SubId
    inner join JYOrder_Main CC on C.MainId=CC.MainId'
    
    exec(@MainSql+@FFWSql)
   
  END
  
  --------------------------------------------------------------------------显示数据
  Drop table #Temp1
  Drop table #Temp2
  

--select Top 100 * from JYOrder_Main

/****** 对象:  UserDefinedFunction [dbo].[F_Get_Order_SubStr]    脚本日期: 12/24/2012 14:36:05 ******/
SET ANSI_NULLS ON
GO
/****** Object:  StoredProcedure [dbo].[P_GX_PBKC]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
Create Procedure [dbo].[P_GX_PBKC]
  @ConNo varchar(20)
AS
DECLARE @i int
DECLARE @ZJS int 
DECLARE @PZ decimal(18,2)
DECLARE @APID varchar(20)
DECLARE @MainId varchar(20)
DECLARE @SubId varchar(20)
DECLARE @MFQty decimal(18,2)
DECLARE @KZQty decimal(18,2)
select @MainId=B.MainId,@SubId=B.SubId,@MFQty=B.MFQty,@KZQty=B.KZQty  from Cloth_Main  A 
inner join Cloth_Sub  B on A.MainId=B.MainId where A.ConNo=@ConNo
Set @ZJS=(select Cast(Qty1 as int) from Cloth_Main A inner join Cloth_Sub  B on A.MainId=B.MainId where A.ConNo=@ConNo)
Set @PZ=(select Qty2 from Cloth_Main A inner join Cloth_Sub  B on A.MainId=B.MainId where A.ConNo=@ConNo)
Set @i=1
while @i<=@ZJS
begin
  Set @APID=SUBSTRING(@ConNo,3,LEN(@ConNo)-2)+RIGHT('0000'+CAST(@i as varchar(5)),4)
  insert into  JYCon_Sub_AnPai(MainId,SubId,APID,APDate,CarNo,SCPerson,JYFlag,Filler,Filltime,APXH)
  select @MainId,@SubId,@APID,'2016-03-01','999','ADMIN',1,'ADMIN','2016-03-01',@i
  insert into  WFB_MJJY_PB(MainId,SubId,MJID,MJMaoZ,MJFK,MJSJKZ,Filler,Filltime,MJType,APID,MJXH)
  select @MainId,@SubId,@APID,@PZ,@MFQty,@KZQty,'ADMIN','2016-03-01','正品',@APID,@i
  Set @i=@i+1
end
GO
/****** Object:  StoredProcedure [dbo].[P_Get_WJGKC]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Get_WJGKC
CREATE procedure [dbo].[P_Get_WJGKC]
AS
select A.GenDanName,A.OrdSubidRK,A.SSType,A.ORDMainIdRK,A.FactoryName,A.SPCode,A.SPName,A.SPSpec,A.SPMF,A.SPKZ,A.SPCF 
     --,FromGX=(case when A.CRType in ('平移入库','平移出库') then '平移' else A.FromGX end)
     ,A.FromGX 
     ,ToFactoryName=(case when A.CRQtyFlag=1 then A.ToFactoryName else A.FromFactoryName end) 
     ,A.QtyUnit,A.KuWei,A.PiQty*A.CRQtyFlag MXKCPiQty,A.Qty*A.CRQtyFlag MXKCQty 
     ,B.OrderNo,B.ConnO,C.PRTColorNo,C.PRTColor,C.PRTHX
into #Temp1
from CK_SXPB_CR A 
     inner join JYOrder_Main B on B.Mainid=A.OrdMainidRK
     inner join JYOrder_Sub C on C.SubId=A.ORDSubIdRK
     where isnull(CKName,'')='外加工' 
      
 select PRTColorNo,PRTColor,PRTHX,OrdSubidRK,OrderNo,SPCode,
              ConNO,ORDMainIdRK,SPName, SPSpec,SPMF,SPKZ,ToFactoryName,QtyUnit,
              SUM(MXKCPiQty) MXKCPiQty,SUM(MXKCQty) MXKCQty
              ,FactoryName=(select Top 1 B.FactoryName from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='外加工'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'') 
                          order by B.filltime desc)
              ,FromGX=(select Top 1 B.FromGX from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='外加工'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'') 
                          order by B.filltime desc)
              ,GenDanName=(select Top 1 B.GenDanName from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='外加工'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'') 
                          order by B.filltime desc)
              ,Note=(select Top 1 B.Note from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='外加工'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'') 
                          order by B.Note desc)
              ,CCRKDate=(select Top 1 B.CRTime from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='外加工'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'') 
                          order by B.CRTime)
 from #Temp1 AA
 group by PRTColorNo,PRTColor,PRTHX,OrdSubidRK,OrderNo,SPCode,ConNO,ORDMainIdRK,
 SPName,SPSpec,SPMF,SPKZ,ToFactoryName,QtyUnit
 having Sum(MXKCPiQty)<>0 or SUM(MXKCQty)<>0
 
 drop table #Temp1
GO
/****** Object:  StoredProcedure [dbo].[P_Get_PBKC]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Get_PBKC
CREATE procedure [dbo].[P_Get_PBKC]
AS
select A.SSType,A.ORDMainIdRK,A.FactoryName,A.SPCode,A.SPName,A.SPSpec,A.SPMF,A.SPKZ
     ,A.RCGangNo,A.BPType
     ,ToFactoryName=(case when A.CRQtyFlag=1 then A.ToFactoryName else A.FromFactoryName end) 
     ,A.QtyUnit,A.PiQty*A.CRQtyFlag MXKCPiQty,A.Qty*A.CRQtyFlag MXKCQty 
     ,B.OrderNo,B.ConnO
into #Temp1
from CK_SXPB_CR A 
     inner join JYOrder_Main B on B.Mainid=A.OrdMainidRK
     where isnull(CKName,'')='坯布'
      
select OrderNo,ConNO,ORDMainIdRK,SPCode,SPName,SPSpec,SPMF,SPKZ,ToFactoryName,QtyUnit,
              SUM(MXKCPiQty) MXKCPiQty,SUM(MXKCQty) MXKCQty
              ,FactoryName=(select Top 1 B.FactoryName from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='坯布'
                          and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'') 
                          order by B.filltime desc)
              ,MaChi=(select Top 1 B.MaChi from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='坯布'
                          and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'')
                          order by B.filltime desc)
              ,Note=(select Top 1 B.Note from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='坯布'
                          and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'')
                          order by B.Note desc)
              ,CCRKDate=(select Top 1 B.CRTime from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='坯布'
                          and B.ORDMainIdRK=AA.ORDMainIdRK and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'')
                          order by B.CRTime)
 from #Temp1 AA
 group by OrderNo,ConNO,ORDMainIdRK,SPCode,SPName,SPSpec,SPMF,SPKZ,ToFactoryName,QtyUnit
 having Sum(MXKCPiQty)<>0 or Sum(MXKCQty)<>0
 
 drop table #Temp1
GO
/****** Object:  StoredProcedure [dbo].[P_Get_MaxInvoiceNo]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Get_MaxInvoiceNo'内销'
CREATE PROCEDURE  [dbo].[P_Get_MaxInvoiceNo]
  @MPRTType varchar(100)
as
begin
  DECLARE @I int
  declare @maxI int
  declare @NO int 
  declare @Str1 varchar(100)
  
  create table #tab1
  ( invoiceNO int )

  IF @MPRTType='内销' 
  begin
    insert into #tab1(invoiceNO)
    SELECT CAST(RIGHT(left(RTRIM(invoiceNo),6),3) AS INT) as invoiceNO
    FROM JYOrderFB_Main 
    WHERE OrdDefStr15=@MPRTType 
        and Left(convert(varchar(10),FillTime,120),4)=left(convert(varchar(10),getdate(),120),4)
        and FillTime>='2015-05-02'

  end
  else
  begin
    insert into #tab1(invoiceNO)
    SELECT CAST(RIGHT(RTRIM(invoiceNo),3) AS INT) as invoiceNO
 
    FROM JYOrderFB_Main 
    WHERE Left(convert(varchar(10),FillTime,120),4)=left(convert(varchar(10),getdate(),120),4)
          and FillTime<'2015-05-02'
          
    insert into #tab1(invoiceNO)
    SELECT CAST(RIGHT(left(RTRIM(invoiceNo),6),3) AS INT) as invoiceNO
    FROM JYOrderFB_Main 
    WHERE OrdDefStr15=@MPRTType 
          and Left(convert(varchar(10),FillTime,120),4)=left(convert(varchar(10),getdate(),120),4)
          and FillTime>='2015-05-02'

  end

    
    
  --  select *from #tab1
 
  SET @I=1
  select @maxI=isnull(MAX(invoiceNO),0) from #tab1
  SET @NO=0
  while @I<=@maxI
  begin
    if isnull((select max(invoiceNO) from #tab1 where invoiceNO=@i),0)<1
    begin
      SET @NO=@I
      SET @I=@maxI+10
    end
    SET @I=@I+1
  end;
 
  SET @Str1='XXX'
  
  IF @NO>0 
  begin
     IF @MPRTType='内销' 
     begin
       SET @Str1='Q'+left(convert(varchar(10),getdate(),12),2)+RIGHT(cast(1000+@no as varchar),3)
     end 
     else
     begin
       SET @Str1=left(convert(varchar(10),getdate(),12),2)+RIGHT(cast(1000+@no as varchar),3)
     end
  end
  SELECT @Str1 AS maxStr
end
GO
/****** Object:  StoredProcedure [dbo].[P_Get_MaxFYNo]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE PROCEDURE  [dbo].[P_Get_MaxFYNo]
  @MPRTType varchar(100)
as
begin
  DECLARE @I int
  declare @maxI int
  declare @NO int 
  declare @Str1 varchar(100)
  
  create table #tab1
  (OrderNo varchar(30)
  )
  
  insert into #tab1(OrderNo)
  SELECT CAST(REPLACE(REPLACE(RIGHT(RTRIM(OrderNo),3),'A',''),'B','') AS INT) as OrderNo
  FROM JYOrderFY_Main A
  WHERE OrdDefStr1=@MPRTType 
    and Left(convert(varchar(10),FillTime,120),4)=left(convert(varchar(10),getdate(),120),4)
    and A.FillTime<'2015-05-20'
    
  insert into #tab1(OrderNo)
  SELECT CAST(RIGHT(left(RTRIM(OrderNo),7),3) AS INT) as OrderNo
  FROM JYOrderFY_Main A
  WHERE OrdDefStr1=@MPRTType 
    and Left(convert(varchar(10),FillTime,120),4)=left(convert(varchar(10),getdate(),120),4)
    and A.FillTime>='2015-05-20'  
 
  --  select *from #tab1
 
  SET @I=1
  select @maxI=isnull(MAX(OrderNo),0) from #tab1
  SET @NO=0
  while @I<=@maxI
  begin
    if isnull((select max(OrderNo) from #tab1 where OrderNo=@i),0)<1
    begin
      SET @NO=@I
      SET @I=@maxI+10
    end
    SET @I=@I+1
  end;
 
  SET @Str1='XXX'
  
  IF @NO>0 
  begin
   -- IF @MPRTType='内销'  SET @Str1='BQ'+left(convert(varchar(10),getdate(),12),2)+RIGHT(cast(1000+@no as varchar),3)
      SET @Str1=left(convert(varchar(10),getdate(),12),2)+RIGHT(cast(1000+@no as varchar),3)
  end
  SELECT @Str1 AS maxStr
  
  --select OrdDefStr1,max(CAST(REPLACE(REPLACE(RIGHT(RTRIM(OrderNo),3),'A',''),'B','') AS INT))OrderNo from JYOrderFY_Main group by OrdDefStr1
end
GO
/****** Object:  StoredProcedure [dbo].[P_Get_MaxConNo]    Script Date: 12/17/2021 15:51:30 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Get_MaxConNo'内销'
CREATE PROCEDURE  [dbo].[P_Get_MaxConNo]
  @MPRTType varchar(100)
as
begin
  DECLARE @I int
  declare @maxI int
  declare @NO int 
  declare @Str1 varchar(100)
  
  SELECT CAST(RIGHT(RTRIM(CONnO),3) AS INT) as conNo
  into #tab1
  FROM JYOrderCon_Main 
  WHERE MPRTType=@MPRTType
  and Left(convert(varchar(10),FillTime,120),4)=left(convert(varchar(10),getdate(),120),4)
 
  SET @I=1
  select @maxI=isnull(MAX(conNo),0) from #tab1
  SET @NO=0
  while @I<=@maxI
  begin
    if isnull((select max(conNo) from #tab1 where conNo=@i),0)<1
    begin
      SET @NO=@I
      SET @I=@maxI+10
    end
    SET @I=@I+1
  end;
 
  SET @Str1='XXX'
  
  IF @NO>0 
  begin
    IF @MPRTType='内销'  SET @Str1='BQ'+left(convert(varchar(10),getdate(),12),2)+RIGHT(cast(1000+@no as varchar),3)
    IF @MPRTType='外销'  SET @Str1='BK'+left(convert(varchar(10),getdate(),12),2)+RIGHT(cast(1000+@no as varchar),3)
  end
  SELECT @Str1 AS maxStr
end
GO
/****** Object:  StoredProcedure [dbo].[P_Get_JYMJID_Main]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Get_JYMJID_Main'','0','dsa'
CREATE procedure [dbo].[P_Get_JYMJID_Main]
  @MJID varchar(100),
  @flag varchar(10)='0',
  @UserID varchar(30)
as
begin


  SELECT AAA.*
  FROM(
  select AA.*,
          BMKF=case when @flag='0' and MJLen* isnull(MJFK,0)>0 then cast(KouFenQty*3600/(MJLen* isnull(MJFK,0)) AS decimal(18,2))    
                    when @flag='1' and MJLen* isnull(MJFK,0)>0 then cast(KouFenQty*100000/(MJLen* isnull(MJFK,0)*10)AS decimal(18,2))  
               else 0 end,
          ISHz=case when ISNULL(BZkoufenQty,0)=0 then '合格' 
                    when BZkoufenQty>KouFenQty then '合格' 
                    else '不合格'end,
          ISHzEng=case when ISNULL(BZkoufenQty,0)=0 then 'APPROVED' 
                       when BZkoufenQty>KouFenQty then 'APPROVED' 
                       else 'REJECTED'end,
       /*   MKZ=case when Mjlen<=0 then 0
                   when MJTypeother='M' then CAST(MjQty4*1000/Mjlen AS int) 
                   else CAST(MjQty4*1000/(Mjlen*0.9144) AS int) end, 
          M2KZ=case when Mjlen<=0 then 0
                    when CFK<=0 then 0
                   when MJTypeother='M' then CAST(MjQty4*1000/Mjlen/CFK*100 AS int) 
                   else CAST(MjQty4*1000/(Mjlen*0.9144)/CFK*100 AS int) end   */
          MKZ=cast(MJSJKZ * MJFK/100.0 as Int),
          M2KZ=MJSJKZ   
  from(
   select D.OrderNo,D.conNO,D.MPRTCodeName,D.MPRTSpec,D.MPRTMF,C.PRTColor,C.SOrddefstr4,C.SOrddefstr1,D.DLYDate,D.MPRTSL,B.ADefDate1,
          B.AOrdDefNote1,D.koufenQty as BZkoufenQty,
          A.MjQty4,A.MjQty2,A.Mjstr4,A.MJLen,A.MJFK,A.MJID,A.MJXH,A.MJTypeother,A.MJSJKZ,
          Filler=(select top 1 userID from SY_User X where X.UserName=A.Filler),
          KHconNo=(select Top 1 KHConNo from JYOrderCon_Main X where X.ConNo=D.conNO),
          KouFenQty=isnull((select Sum(KouFenQty) from WFB_MJJY_CD X where X.MJID=A.MJID),0),
          CDQty=isnull((select Sum(CDQty) from WFB_MJJY_CD X where X.MJID=A.MJID),0),
          CFK=isnull((select min(CDQty) from WFB_MJJY_CD X where X.MJID=A.MJID and X.CDName='测幅宽' and CDQty>0),0),
          PT1=isnull((select count(MJID) from WFB_MJJY_CD X where X.MJID=A.MJID and X.KouFenQty=1),0),
          PT2=isnull((select count(MJID) from WFB_MJJY_CD X where X.MJID=A.MJID and X.KouFenQty=2),0),
          PT3=isnull((select count(MJID) from WFB_MJJY_CD X where X.MJID=A.MJID and X.KouFenQty=3),0),
          PT4=isnull((select count(MJID) from WFB_MJJY_CD X where X.MJID=A.MJID and X.KouFenQty=4),0),
          PT=isnull((select count(MJID) from WFB_MJJY_CD X where X.MJID=A.MJID and X.KouFenQty>=1),0),
          C.MainId,C.SubId
    from WFB_MJJY A 
    inner join JYOrder_Sub_AnPai B on B.APID=A.APID
    inner join JYOrder_Sub C on C.SubId=A.SubId
    inner join JYOrder_Main D on D.MainId=A.MainId
    where exists(select SubId from TBSubID X where X.SubId=A.MJID and X.DName=@UserID)
  )AA
  )AAA
  order by ISHzEng,MPRTCodeName,SOrddefstr4,SOrddefstr1,Mjstr4,CAST(MJXH as int)
end
GO
/****** Object:  StoredProcedure [dbo].[P_Get_JYMJID]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Get_JYMJID'1504080304','3'
CREATE procedure [dbo].[P_Get_JYMJID]
  @MJID varchar(30),
  @flag   varchar(10)='0'
as
begin
  declare @i integer

  create table #tabMain
   (
     N  int,
     N1  varchar(10),
     N2  varchar(10),
     N3  varchar(10),
     H1  varchar(10),
     H2  varchar(10),
     H3  varchar(10),
     H4  varchar(10),
     H5  varchar(10),
     H6  varchar(10),
     H7  varchar(10),
     H8  varchar(10),
     H9  varchar(10),
     H10  varchar(10),
     H11  varchar(10),
     H12  varchar(10),
     E1  varchar(10),
     E2  varchar(10),
     E3  varchar(10),
   )
 
  select *,
         IDENTITY(Int,1,1) as KeyNo
  into #tab1
  from( 
   select Distinct CDName,Note as EngCDName 
   from WFB_MJJY_CD A
   inner join KH_ZDY B ON B.zdyName=A.CDName and B.Type='WFBCD' and B.zdyName<>'测幅宽'
   where A.MJID=@MJID
   UNION ALL
   SELECT distinct zdyName as CDName,Note as EngCDName
   from KH_ZDY A
   where Type='WFBCD' and A.zdyName<>'测幅宽'
       and not exists(select * from WFB_MJJY_CD X where X.CDName=A.zdyName and X.MJID=@MJID)
     )AA
  IF @flag=0
    SELECT * from #tabMain
  ELSE
  IF @flag=1
    select CDName as CDName,KeyNo from #tab1 where keyNo<=12
  ELSE
  IF @flag=2
    select EngCDName as CDName,KeyNo from #tab1 where keyNo<=12
  ELSE
  IF @flag=3
  begin
    select AA.*
    from
    (
    select A.*,keyNO,CAST(ISNULL(A.CDBeg,0)/B.MJLen*150 as int)as H,CAST(ISNULL(A.CDEnd,0)/B.MJLen*150 as int)as H1,B.MJLen
    from WFB_MJJY_CD A
    inner join WFB_MJJY B on B.MJID=A.MJID
    inner join #tab1 C on C.CDName=A.CDName and C.keyNO<=12 
    where A.MJID=@mjID and A.koufenType<>'1米内连续出现瑕疵'
    UNION ALL
    select A.*,keyNO=-10,CAST(ISNULL(A.CDBeg,0)/B.MJLen*150 as int)as H,CAST(ISNULL(A.CDEnd,0)/B.MJLen*150 as int)as H1,B.MJLen
    from WFB_MJJY_CD A
    inner join WFB_MJJY B on B.MJID=A.MJID
    where A.MJID=@mjID and CDName='测幅宽'
    UNION ALL
    select A.*,keyNO,CAST(ISNULL(A.CDBeg,0)/B.MJLen*150 as int)as H,CAST(ISNULL(A.CDEnd,0)/B.MJLen*150 as int)as H1,B.MJLen
    from WFB_MJJY_CD A
    inner join WFB_MJJY B on B.MJID=A.MJID
    inner join #tab1 C on C.CDName=A.CDName and C.keyNO<=12 
    where A.MJID=@mjID and A.koufenType='1米内连续出现瑕疵' 
    )AA
    order by H 

  end
  ELSE
  IF @flag=4
  BEGIN
    select A.*,
           Num=(select COUNT(MCID) from WFB_MJJY_CD X where X.MJID=@MJID and X.CDName=A.CDName and X.KouFenQty>0)
    from #tab1 A
    where A.keyNO<=12
  END
  
  drop table #tabMain
  drop table #tab1  
  
end
GO
/****** Object:  StoredProcedure [dbo].[P_Get_JF_KcNow]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
--exec P_Get_JF_KCNow'where 1=1 and AA.whCode=''假捻丝仓库''and abs(AA.endquan)>0.0','2013-09-01'



--exec P_Get_JF_KcNow '','2011-12-01'
CREATE   procedure [dbo].[P_Get_JF_KcNow]
  @wherestr varchar(300),
  @curMonthFirstDate  varchar(10)
as    
  DECLARE @Tmpsql    VARCHAR(4000)

  CREATE TABLE #TEMPTABLE1  (
        whcode     char(20),
        mNumber    char(20),
        Marea      char(20),
        BatchNum   char(20),
        factory    char(20),
        P_Color    varchar(60),
        Grade    varchar(60),
        fstr1    varchar(60),
        fstr2    varchar(60),
        fstr3    varchar(60),
	    qcs       numeric(19,4)DEFAULT(0),
        fzqcs       numeric(19,4)DEFAULT(0),
        qcsMoney  numeric(19,3)DEFAULT(0),
        flag      int          DEFAULT(0)

  )
  CREATE TABLE #TEMPTABLE2  (
        whcode     char(20),
        mNumber    char(20),
        Marea      char(20),
        BatchNum   char(20),
        factory    char(20),
        P_Color    varchar(60),
        Grade    varchar(60),
        fstr1    varchar(60),
        fstr2    varchar(60),
        fstr3    varchar(60),
	    rks  NUMERIC(19,2) DEFAULT(0),
        cks  NUMERIC(19,2) DEFAULT(0), 
        fzrks NUMERIC(19,2) DEFAULT(0),
        fzcks NUMERIC(19,2) DEFAULT(0),
        rkMoney    numeric(19,3)DEFAULT(0),
        ckMoney    numeric(19,3)DEFAULT(0)
  )
  
--期初数

--到上月止出库数
  INSERT INTO #TEMPTABLE1(whcode,mNumber,mAREA,batchNum,factory,P_Color,Grade,fstr1,fstr2,fstr3,qcs,fzqcs,qcsMoney,flag) 
    SELECT AA.whcode,AA.mNumber, AA.Marea, AA.BatchNum,AA.factory,P_Color, Grade,fstr1,fstr2,fstr3,rks-cks,fzrks-fzcks,rkMoney-ckMoney,Flag
     FROM
      (
        SELECT 
            x1.whcode,x2.mNumber, x2.Marea, x2.BatchNum, x2.factory,X2.P_Color,X2.Grade,X2.fstr1,X2.fstr2,X2.fstr3,
            rks=SUM(case  x1.inoutflag WHEN '1' THEN x2.FactReceiptQuan ELSE 0 END),
            fzrks=SUM(case  x1.inoutflag WHEN '1' THEN x2.fzRkNum ELSE 0 END),
           cks=SUM(case  x1.inoutflag WHEN '0' THEN x2.FactIssueQuan ELSE 0 END),
           fzcks=SUM(case  x1.inoutflag WHEN '0' THEN x2.fzCkNum ELSE 0 END),
           rkMoney=SUM(case  x1.inoutflag WHEN '1' THEN x2.Emoney ELSE 0 END),
           ckMoney=SUM(case  x1.inoutflag WHEN '0' THEN x2.IssueMoney ELSE 0 END),
           1 AS FLAG
         FROM JF_crkmain x1,JF_crksub x2
         WHERE x1.inoutmainid=x2.inoutmainid      
            AND billDate<@curMonthFirstDate         
         GROUP BY x1.whcode,x2.mNumber, x2.Marea, x2.BatchNum,X2.factory,X2.P_Color,Grade,fstr1,fstr2,fstr3,X2.Grade,X2.fstr1,X2.fstr2,X2.fstr3
      )AA
  
 --当前月出入库数
  INSERT INTO #TEMPTABLE2(whcode,mNumber,mAREA,batchNum,factory,P_Color,Grade,fstr1,fstr2,fstr3,rks,fzRks,cks,fzCks,rkmoney,ckmoney) 
    SELECT 
         x1.whcode,x2.mNumber, x2.Marea, x2.BatchNum,x2.factory,X2.P_Color,X2.Grade,X2.fstr1,X2.fstr2,X2.fstr3,
         rks=SUM(case  x1.inoutflag WHEN '1' THEN x2.FactReceiptQuan ELSE 0 END),
         fzrks=SUM(case  x1.inoutflag WHEN '1' THEN x2.fzRkNum ELSE 0 END),
         cks=SUM(case  x1.inoutflag WHEN '0' THEN x2.FactIssueQuan ELSE 0 END),
         fzcks=SUM(case  x1.inoutflag WHEN '0' THEN x2.fzCkNum ELSE 0 END),
         rkMoney=SUM(case  x1.inoutflag WHEN '1' THEN x2.Emoney ELSE 0 END),
         ckMoney=SUM(case  x1.inoutflag WHEN '0' THEN x2.IssueMoney ELSE 0 END)

      FROM JF_crkmain x1,JF_crksub x2
      WHERE x1.inoutmainid=x2.inoutmainid  
      and billDate>=@curMonthFirstDate    
      and billDate<dateADD(month,1,@curMonthFirstDate)           
      GROUP BY x1.whcode,x2.mNumber, x2.Marea, x2.BatchNum,x2.factory,X2.P_Color,X2.Grade,X2.fstr1,X2.fstr2,X2.fstr3
      


  --起初数汇总  
 INSERT INTO #TEMPTABLE1(whcode,mNumber,mAREA,batchNum,factory,P_Color,Grade,fstr1,fstr2,fstr3,qcs,fzqcs,qcsMoney,flag) 
    SELECT A.whcode,A.mnumber,A.Marea,A.Batchnum,factory,P_Color,Grade,fstr1,fstr2,fstr3,
        sum(isnull(qcs,0)), sum(isnull(fzqcs,0)),sum(isnull(qcsMoney,0)),2 as flag
      FROM #TEMPTABLE1 A
      GROUP BY whcode, mNumber, Marea, BatchNum,factory,P_Color,Grade,fstr1,fstr2,fstr3

 --删除不是汇总数据
 DELETE #TEMPTABLE1 WHERE flag<2
 

  SET @Tmpsql='select AA.* ,D.qcs,d.fzqcs,E.fzRks,E.fzcks,
               case when D.qcs=0 then 0
                    else D.qcsMoney end as qcsMoney, 
               E.rks,E.cks,E.rkMoney,E.ckMoney,
               --price=dbo.F_Get_Wl_RkPrice(A.mnumber),                 
               EndMoney1=isnull(D.qcsMoney,0)+isnull(E.rkMoney,0)-isnull(E.ckMoney,0),
               
               money_B=isnull(D.qcsMoney,0)+isnull(E.rkMoney,0)-isnull(E.ckMoney,0),
               
               kc_B=isnull(D.qcs,0)+isnull(E.rks,0)-isnull(E.cks,0),
               fzkc_B=isnull(D.fzqcs,0)+isnull(E.fzRks,0)-isnull(E.fzcks,0),
               kcMoney=round((kcPrice * AA.endQuan),2),
               factoryName=(select zdyName from kH_Zdy where zdyNo=AA.factory ),
               case when abs(AA.endquan)>0.0 then
                      round(abs(isnull(D.qcsMoney,0)+isnull(E.rkMoney,0)-isnull(E.ckMoney,0))/abs(AA.endquan),3)
               else
                      0
               end as kcPjPrice,
               rkPrice=case when rks<>0 then round((rkmoney / rks),2) else 0 end,
               ckPrice=case when cks<>0 then round((ckmoney / cks),2) else 0 end
            from
              (  SELECT A.nowquanid,A.whcode,A.mnumber,A.marea,A.batchnum,A.factory,A.P_Color,
               A.endquan,A.fzEndQuan,A.highquan,A.lowquan,A.safequan,A.Grade,A.fstr1,A.fstr2,A.fstr3,
               round(A.price,3) as price,round(A.kcPrice,3) as kcPrice,            
               A.WhCode as whName,
               C.mname,C.model,C.primaryunitname,C.purUnitName,
               C.InvSortcode,  
               mareaname=(select zdyName from kH_Zdy where zdyNo=A.marea),
               P_ColorName=ISNULL((SELECT zdyName from kH_Zdy X WHERE X.zdyNo=A.P_Color),A.P_Color),
               '''' as rq,
               
               endMoney=price * endQuan
         FROM  JF_kcnow A 
         INNER JOIN JF_material C ON C.mnumber=A.mnumber 
         )AA
         LEFT JOIN #TEMPTABLE1 D ON D.whcode=AA.whcode 
                           and D.mNumber=AA.mNumber AND D.Marea=AA.Marea
                           and D.BatchNum=AA.BatchNum and d.factory=AA.factory and d.P_Color=AA.P_Color 
                           and ISNULL(D.Grade,'''')=ISNULL(AA.Grade,'''') and ISNULL(D.fstr1,'''')=ISNULL(AA.fstr1,'''')
                           and ISNULL(D.fstr2,'''')=ISNULL(AA.fstr2,'''') and ISNULL(D.fstr3,'''')=ISNULL(AA.fstr3,'''')
         LEFT JOIN #TEMPTABLE2 E ON E.whcode=AA.whcode 
                           and E.mNumber=AA.mNumber AND E.Marea=AA.Marea
                           and E.BatchNum=AA.BatchNum and E.factory=AA.factory and E.P_Color=AA.P_Color 
                           and ISNULL(E.Grade,'''')=ISNULL(AA.Grade,'''') and ISNULL(E.fstr1,'''')=ISNULL(AA.fstr1,'''')
                           and ISNULL(E.fstr2,'''')=ISNULL(AA.fstr2,'''') and ISNULL(E.fstr3,'''')=ISNULL(AA.fstr3,'''') '+@wherestr

  EXEC(@Tmpsql)
  drop table #TEMPTABLE1
  drop table #TEMPTABLE2
GO
/****** Object:  StoredProcedure [dbo].[P_Get_JF_Kc_Warning]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
--exec P_Get_JF_Kc_Warning '纱线仓库','10',''
CREATE   procedure [dbo].[P_Get_JF_Kc_Warning]
  @whCode varchar(20),
  @days int,
  @days2 int,
  @otherwhere varchar(100)=''
as
begin 
  DECLARE @Tmpsql    VARCHAR(4000)
  
  
  select A.nowquanID,cast(sum(factIssuequan)/@days*@days2 as decimal(18,2)) as factIssuequan
  into #tab1
  from JF_CRksub A
  inner join JF_CRkmain B on B.inoutMainID=A.InoutMainID
  where Billdate>=convert(char(10),dateADD(day,-1*@days,getdate()),120)
        and inoutFlag=0
        and whCode=@whCode
  group by A.nowquanID
  
  
  select A.*,B.factIssuequan,
         A.WhCode as whName,
         C.mname,C.model,C.primaryunitname,C.purUnitName,
         C.InvSortcode,  
         mareaname=(select zdyName from kH_Zdy where zdyNo=A.marea),
         P_ColorName=ISNULL((SELECT zdyName from kH_Zdy X WHERE X.zdyNo=A.P_Color),A.P_Color)
  from JF_KCNow A
  inner join #tab1 B on B.nowquanID=A.nowquanID
  INNER JOIN JF_material C ON C.mnumber=A.mnumber 
  where A.endQuan<B.factIssuequan 
  
end
GO
/****** Object:  StoredProcedure [dbo].[P_Get_JF_CRkList]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER OFF
GO
--exec P_Get_JF_CRkList'2013-01-05','2013-09-06','100','',100,'test'

CREATE       PROCEDURE [dbo].[P_Get_JF_CRkList]
  @begDate varchar(20),
  @endDate varchar(20),
  @timeFlag int=0, --0:入库时间；1：填单时间
  @whCode varchar(20)='',
  @InOutFlag int=0 , --0:出；1：入
  @UserId varchar(20)=''
AS
   IF @timeFlag=0 
   BEGIN
     SELECT A.inoutmainid,A.billdate,A.sxcust,
       A.receiptnum,A.purtypecode,A.personcode,A.kfchecker,
       A.maker,A.chalkitupman,A.redblueflag,A.whcode,
       A.billnum,A.suppliercode,A.deptcode,A.IssueNum,
       A.inoutclasscode,A.transferwaycode,A.filltime, 
       A.trancompanycode,A.remark,A.checkflag, 
       B.mnumber,B.inoutsubid,B.factreceiptquan,B.fzRkNum,
       B.price,B.emoney,b.quanissue,B.FactIssueQuan,B.issuemoney,B.fzCkNum,B.netFactIssueQuan,
       B.marea,B.batchnum,B.invaliddate,B.Grade,B.fstr1,B.fstr2,B.fstr3,
       D.mname,D.PrimaryUnitName,D.purUnitName,B.JFNote,
       D.model,D.invsortcode,
       suppliercodeName=(select zdyName from KH_ZDY where ZDYNO=A.suppliercode ),
       factoryName=(select zdyName from KH_ZDY where ZDYNO=B.factory ),
       deptCodeName=(select zdyName from KH_ZDY where ZDYNO=A.deptCode),
       mareaName=(select zdyName from KH_ZDY where ZDYNO=B.Marea ),    
       sortname=D.invsortcode,
       P_ColorName=ISNULL((SELECT zdyName from KH_ZDY X WHERE X.ZDYNO=B.P_Color),B.P_Color)       
     FROM JF_CRKmain A 
     INNER JOIN JF_CRKsub B ON A.inoutmainid=B.inoutmainid and A.InoutFlag=@InOutFlag 
     INNER JOIN JF_material D on B.mnumber=D.mnumber 
     WHERE billDate>=@begDate and BillDate<@endDate
     ORDER BY A.billDate desc
   END
   ELSE IF @timeFlag=1 
   BEGIN
     SELECT A.inoutmainid,A.billdate,A.sxcust,
       A.receiptnum,A.purtypecode,A.personcode,A.kfchecker,
       A.maker,A.chalkitupman,A.redblueflag,A.whcode,
       A.billnum,A.suppliercode,A.deptcode,A.IssueNum,
       A.inoutclasscode,A.transferwaycode,A.filltime, 
       A.trancompanycode,A.remark,A.checkflag, 
       B.mnumber,B.inoutsubid,B.factreceiptquan,B.fzRkNum,
       B.price,B.emoney,b.quanissue,B.FactIssueQuan,B.issuemoney,B.fzCkNum,B.netFactIssueQuan,
       B.marea,B.batchnum,B.invaliddate, B.Grade,B.fstr1,B.fstr2,B.fstr3,
       D.mname,D.PrimaryUnitName,D.purUnitName,B.JFNote,
       D.model,D.invsortcode,
       suppliercodeName=(select zdyName from KH_ZDY where ZDYNO=A.suppliercode ),
       factoryName=(select zdyName from KH_ZDY where ZDYNO=B.factory ),
       deptCodeName=(select zdyName from KH_ZDY where ZDYNO=A.deptCode),
       mareaName=(select zdyName from KH_ZDY where ZDYNO=B.Marea ),    
       sortname=D.invsortcode, 
       P_ColorName=ISNULL((SELECT zdyName from KH_ZDY X WHERE X.ZDYNO=B.P_Color),B.P_Color)  
     FROM JF_CRKmain A 
     INNER JOIN JF_CRKsub B ON A.inoutmainid=B.inoutmainid and A.InoutFlag=@InOutFlag 
     INNER JOIN JF_material D on B.mnumber=D.mnumber 
     WHERE filltime>=@begDate and filltime<@endDate
     ORDER BY A.filltime desc
   END
   ELSE
   BEGIN
      SELECT A.inoutmainid,A.billdate,A.sxcust,A.inoutFlag,
       A.receiptnum,A.purtypecode,A.personcode,A.kfchecker,
       A.maker,A.chalkitupman,A.redblueflag,A.whcode,
       A.billnum,A.suppliercode,A.deptcode,A.IssueNum,
       A.inoutclasscode,A.transferwaycode,A.filltime, 
       A.trancompanycode,A.remark,A.checkflag, 
       B.mnumber,B.inoutsubid,B.factreceiptquan,B.fzRkNum,
       B.price,B.emoney,b.quanissue,B.FactIssueQuan,B.issuemoney,B.fzCkNum,B.netFactIssueQuan,
       B.marea,B.batchnum,B.invaliddate, B.Grade,B.fstr1,B.fstr2,B.fstr3,
       D.mname,D.PrimaryUnitName,D.purUnitName,B.JFNote,
       D.model,D.invsortcode,
       suppliercodeName=(select zdyName from KH_ZDY where ZDYNO=A.suppliercode ),
       factoryName=(select zdyName from KH_ZDY where ZDYNO=B.factory ),
       deptCodeName=(select zdyName from KH_ZDY where ZDYNO=A.deptCode),
       mareaName=(select zdyName from KH_ZDY where ZDYNO=B.Marea ),    
       sortname=D.invsortcode, 
       P_ColorName=ISNULL((SELECT zdyName from KH_ZDY X WHERE X.ZDYNO=B.P_Color),B.P_Color)  
     FROM JF_CRKmain A 
     INNER JOIN JF_CRKsub B ON A.inoutmainid=B.inoutmainid 
     INNER JOIN JF_material D on B.mnumber=D.mnumber 
     WHERE filltime>=@begDate and filltime<@endDate
     ORDER BY A.filltime 
   
   END
GO
/****** Object:  StoredProcedure [dbo].[P_Get_JF_CRkd_Sub]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE     PROCEDURE [dbo].[P_Get_JF_CRkd_Sub]
  @mKeyNo  int=0
AS
   SELECT A.BillNum,A.sxcust,B.*,
       C.mName,C.Model,C.purUnitName,
       C.PrimaryUnitName,
       taxPrice=(price * (1+tax/100.0)),
       factoryName=(select zdyName from KH_ZDY where ZDYNO=B.factory ),
       mareaName=(select zdyName from KH_ZDY where ZDYNO=B.Marea ),    
       P_ColorName=ISNULL((SELECT zdyName from KH_ZDY X WHERE X.ZDYNO=B.P_Color),B.P_Color)
  FROM JF_crkmain A
    INNER JOIN JF_crksub B on A.InOutMainId=B.InOutMainId
    INNER JOIN JF_material C on C.mNumber=B.mNumber
    WHERE  A.InOutMainId=@mKeyNo
GO
/****** Object:  StoredProcedure [dbo].[P_Get_JF_CRkd_Main]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE      PROCEDURE [dbo].[P_Get_JF_CRkd_Main]
  @mKeyNo  int=0,
  @Inoutflag int=0  
AS
  select  InOutMainId, BillCode, BillNum,A.WhCode, InoutFlag, RedBlueFlag, PurTypeCode, 
       OperType, OperbillNum, ChargeFlag, BillDate, InoutClassCode, TransferWayCode, 
       TranCompanyCode, BusNum, A.DeptCode, PersonCode, CusCode, SupplierCode, 
       ReceiptNum, ReceiptId, Consignbillnum, Consignbillid, ProduceDate, IssueNum, 
       IssueId, IssueUse, KfChecker, CheckFlag, ChhsChecker, ChalkitupMan, Maker, 
       CheckandacceptMan, KeepMan, KjYear, Period, A.Remark, PurplanId, PurorderId, 
       BanlanceType, BanlanCeId, InvoiceNum, InvoiceId,fillTime,
       A.whCode as whName,
       DeptCodeName=(select zdyName from KH_ZDY where ZDYNO=A.DeptCode),
       personcodeName=ISNULL((select userName from SY_USER where userID=A.PersonCode),A.PersonCode),
       InOutClassCode as InOutClassName,
       supplyName=(select zdyName from KH_ZDY where ZDYNO=A.SupplierCode ),
       customName=(select zdyName from KH_ZDY where ZDYNO=A.SupplierCode ),
       transferwayName='',
       -- 领料用途 
       issueuseName='',
       sxcust
  from JF_crkmain A
    WHERE  A.InOutMainId=@mKeyNo and A.InoutFlag=@Inoutflag
GO
/****** Object:  StoredProcedure [dbo].[P_Get_invoice]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE Procedure [dbo].[P_Get_invoice]
  @InvoiceFlag varchar(10)
as
begin

IF @InvoiceFlag='0'
begin
    select AA.*,Wkpmoney=ISNULL(money,0)-ISNULL(kpmoney,0)
    from(
    select A.FactoryName,
           FactoryNameTJ=(SELECT tOP 1 ZDYNameTj from KH_Zdy_Attachment X where X.zdyName=A.factoryName ),
           SUM(BBMoney) as money
           ,kpMoney=(select SUM(KPMoney) from YF_Money_CR B where B.FactoryName=A.FactoryName and B.CRType='应付款发票登记')
           from YF_Money_CR A
           where A.CRFlag='应付付' and A.CRType='应付款登记' and ISNULL(A.status,'0')<>'0'
           group by A.FactoryName
    )AA
 end
 else
 begin
    select AA.*,Wkpmoney=ISNULL(money,0)-ISNULL(kpmoney,0)
    from(
    select A.FactoryName,
           FactoryNameTJ=(SELECT tOP 1 ZDYNameTj from KH_Zdy_Attachment X where X.zdyName=A.factoryName ),
           SUM(Money) as money
           ,kpMoney=(select SUM(KPMoney) from YF_Money_CR B where B.FactoryName=A.FactoryName and B.CRType='应收款发票登记')
    from YF_Money_CR A
    where A.CRFlag='应收收' and A.CRType='应收款登记' and ISNULL(A.status,'0')<>'0'
    group by A.FactoryName
    )AA
   end
end
GO
/****** Object:  StoredProcedure [dbo].[P_Get_FYList]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Get_FYList'2014-01-01','2015-12-01'
CREATE procedure [dbo].[P_Get_FYList]
  @begdate varchar(30),
  @enddate varchar(30)
as
begin
  
  select AA.*,
         case when OrdFlag1=1 then AA.OrdQty5*PrtCnt+AA.OrdQty1*AA.OrdQty2+AA.OrdQty3*M_SOrdQty1+M_MLF + AA.OrdQty6 - AA.OrdQty7
              else 0
         end as ZJ
  from(
    select A.*,B.OrderNo AS OrderNoM,B.conNo,B.OrdDate,B.CustomerNo,B.CustomerNoName,B.Mprtcode,B.MPRTCodeName,B.MPRTMF,B.MPRTKZ,B.OrdDefStr1,B.OrdDefStr6,B.OrdDefStr7,
           OrdDefNote1,OrdDefDate1,B.Filltime,B.OrdQty1,B.OrdQty2,B.OrdQty3,B.OrdQty4,B.OrdQty5,B.OrdQty6,B.OrdQty7,B.OrdQty8,B.OrdQty9,B.ordflag1,B.status,B.Note,
           MLF=SOrdQty1*PRTPrice,ZWF=OrdQty2*OrdQty1,SMPYF=OrdQty3*SOrdQty1,
           PrtCnt=(select COUNT(distinct rtrim(Prtcolor)) from JYOrderFy_Sub X where  X.MainId=A.mainID),
           M_PRTOrderQty=(select sum(PRTOrderQty) from JYOrderFy_Sub X where X.mainID=A.mainID),
           M_SOrdQty1=(select sum(SOrdQty1) from JYOrderFy_Sub X where X.mainID=A.mainID),
           M_SOrdQty2=(select sum(SOrdQty2) from JYOrderFy_Sub X where X.mainID=A.mainID),
           M_MLF=(select sum(SOrdQty1*PrtPrice) from JYOrderFy_Sub X where X.mainID=A.mainID)
    from JYOrderFy_Sub A
    inner join JYOrderFy_Main B on B.MainId=A.MainId
    where B.OrdDate>=@begdate and B.OrdDate<@enddate
      ) AA
    Order by AA.OrdDate,AA.MainId
end
GO
/****** Object:  StoredProcedure [dbo].[P_Get_DJKC]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Get_DJKC
CREATE procedure [dbo].[P_Get_DJKC]
AS
select A.GenDanName,A.OrdSubidRK,A.SSType,A.ORDMainIdRK,A.FactoryName,A.SPCode,A.SPName,A.SPSpec,A.SPMF,A.SPKZ
     ,A.RCGangNo,A.BPType
     ,ToFactoryName=(case when A.CRQtyFlag=1 then A.ToFactoryName else A.FromFactoryName end) 
     ,A.QtyUnit,A.PiQty*A.CRQtyFlag MXKCPiQty,A.Qty*A.CRQtyFlag MXKCQty 
     ,B.OrderNo,B.ConnO,C.PRTColorNo,C.PRTColor,C.PRTHX
into #Temp1
from CK_SXPB_CR A 
     inner join JYOrder_Main B on B.Mainid=A.OrdMainidRK
     inner join JYOrder_Sub C on C.SubId=A.ORDSubIdRK
     where isnull(CKName,'')='待检布' 
      
 select PRTColorNo,PRTColor,PRTHX,OrdSubidRK,OrderNo,RCGangNo,BPType,SPCode,
              ConNO,ORDMainIdRK,SPName, SPSpec,SPMF,SPKZ,ToFactoryName,QtyUnit,
              SUM(MXKCPiQty) MXKCPiQty,SUM(MXKCQty) MXKCQty
              ,FactoryName=(select Top 1 B.FactoryName from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='待检布'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'') 
                          and isnull(B.RCGangNo,'')=isnull(AA.RCGangNo,'') and isnull(B.BPType,'')=isnull(AA.BPType,'')
                          order by B.filltime desc)
              ,FromGX=(select Top 1 B.FromGX from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='待检布'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'')
                          and isnull(B.RCGangNo,'')=isnull(AA.RCGangNo,'') and isnull(B.BPType,'')=isnull(AA.BPType,'')
                          order by B.filltime desc)
              ,GenDanName=(select Top 1 B.GenDanName from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='待检布'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'')
                          and isnull(B.RCGangNo,'')=isnull(AA.RCGangNo,'') and isnull(B.BPType,'')=isnull(AA.BPType,'')
                          order by B.filltime desc)
               ,MaChi=(select Top 1 B.MaChi from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='待检布'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'')
                          and isnull(B.RCGangNo,'')=isnull(AA.RCGangNo,'') and isnull(B.BPType,'')=isnull(AA.BPType,'')
                          order by B.filltime desc)
               ,Note=(select Top 1 B.Note from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='待检布'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'')
                          and isnull(B.RCGangNo,'')=isnull(AA.RCGangNo,'') and isnull(B.BPType,'')=isnull(AA.BPType,'')
                          order by B.Note desc)
               ,CCRKDate=(select Top 1 B.CRTime from CK_SXPB_CR B where B.CRQtyFlag=1 and isnull(B.CKName,'')='待检布'
                          and B.OrdSubidRK=AA.OrdSubidRK and B.ORDMainIdRK=AA.ORDMainIdRK and B.ToFactoryName=AA.ToFactoryName
                          and isnull(B.SPName,'')=isnull(AA.SPName,'') and isnull(B.SPCode,'')=isnull(AA.SPCode,'') and isnull(B.SPSpec,'')=isnull(AA.SPSpec,'') and 
                          isnull(B.SPMF,'')=isnull(AA.SPMF,'') and isnull(B.SPKZ,'')=isnull(AA.SPKZ,'')
                          and isnull(B.RCGangNo,'')=isnull(AA.RCGangNo,'') and isnull(B.BPType,'')=isnull(AA.BPType,'')
                          order by B.CRTime)
 from #Temp1 AA
 group by PRTColorNo,PRTColor,PRTHX,OrdSubidRK,OrderNo,ConNO,ORDMainIdRK,RCGangNo,BPType,SPCode,
 SPName,SPSpec,SPMF,SPKZ,ToFactoryName,QtyUnit
 having Sum(MXKCPiQty)<>0 or SUM(MXKCQty)<>0
 
 drop table #Temp1
GO
/****** Object:  StoredProcedure [dbo].[P_Select_CP_YDangBak]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--Exec P_Select_CP_YDangBak '1312090001',1,''
CREATE procedure [dbo].[P_Select_CP_YDangBak]
  @Code      char(20),  -----编号
  @PState    int,        ----0：新增，1：修改，2条码ID
  @CYType   varchar(40)
AS
  DECLARE @Tmsql         VARCHAR(8000)
  DECLARE @fsj   VARCHAR(200)
  DECLARE @CtrlStr   VARCHAR(200)
  DECLARE @Level int
  DECLARE @FCode  char(20)
IF @PState<>2
BEGIN
 IF @PState<>1
 BEGIN
  create table #Tmp1(code char(20))
  create Table #Tmp2(code char(20))
  create Table #Tmp3(code char(20))
  select @Level=CPLevel from CP_Type where CPID=@CYType
  Set @FCode=@CYType
  insert into #Tmp1 values(@FCode)
  insert into #Tmp2 values(@FCode)

  while @Level<=(select Max(CPLevel) from CP_Type)
  begin
    insert into #Tmp1(code)
    select CPID from CP_Type 
    where CPLevel=(@Level+1) and exists (select code from #Tmp2 where code=CP_Type.CPParent )
    insert into #Tmp3(code)
    select CPID from CP_Type 
    where CPLevel=@Level+1   and exists(select code from #Tmp2 where code=CP_Type.CPParent )
    delete #Tmp2
    insert into #Tmp2 select * from #Tmp3
    Delete #Tmp3
    Set @Level=@Level+1  
  end 
  
  if RTrim(@CYType)<>''
  begin
    Set @Tmsql= 'select A.*,B.CPName from CP_YDang A inner join CP_Type B On A.CYType=B.CPID  where 1=1'
    Set @Tmsql=@Tmsql+' and  Exists(select code from #Tmp1 where code=A.CYType)' 
  end             
 END ELSE
 BEGIN
   Set @Tmsql= 'select A.*,B.CPName from CP_YDang A inner join CP_Type B On A.CYType=B.CPID  where 1=1'
   set  @fsj=' and  A.CYID='''+rtrim(@Code)+''''
 END                          
  exec(@Tmsql+@fsj+@CtrlStr+'order by  A.CYName ')
  --print(@Tmsql+@fsj+@CtrlStr+'order by  A.CYName ')
  
  --print(@Tmsql+@fsj+@CtrlStr+'order by  A.CYName ')
END ELSE
BEGIN
  Set @Tmsql= 'select A.*,B.CPName from CP_YDang A inner join CP_Type B On A.CYType=B.CPID               
                          where    A.CYNO like '''+rtrim(@Code)+''' order by  A.CYName ' 
  exec(@Tmsql)
END 



/****** 对象:  StoredProcedure [dbo].[P_Select_CP_YDang_MaxNo]    脚本日期: 10/27/2013 20:08:22 ******/
SET ANSI_NULLS ON
GO
/****** Object:  StoredProcedure [dbo].[P_Select_CP_YDang_MaxNo]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--Exec P_Select_CP_YDang '',0,''
CREATE procedure [dbo].[P_Select_CP_YDang_MaxNo]
  @CYType   varchar(40)
AS
  DECLARE @Tmsql         VARCHAR(8000)
  DECLARE @fsj   VARCHAR(200)
  DECLARE @CtrlStr   VARCHAR(200)
  DECLARE @Level int
  DECLARE @FCode  char(20)
  create table #Tmp1(code char(20))
  create Table #Tmp2(code char(20))
  create Table #Tmp3(code char(20))
  select @Level=CPLevel from CP_Type where CPID=@CYType
  Set @FCode=@CYType
  insert into #Tmp1 values(@FCode)
  insert into #Tmp2 values(@FCode)

  while @Level<=(select Max(CPLevel) from CP_Type)
  begin
    insert into #Tmp1(code)
    select CPID from CP_Type 
    where CPLevel=(@Level+1) and exists (select code from #Tmp2 where code=CP_Type.CPParent )
    insert into #Tmp3(code)
    select CPID from CP_Type 
    where CPLevel=@Level+1   and exists(select code from #Tmp2 where code=CP_Type.CPParent )
    delete #Tmp2
    insert into #Tmp2 select * from #Tmp3 
    Delete #Tmp3
    Set @Level=@Level+1  
end 
  Set @Tmsql= 'select CYNO AA from CP_YDang A               
                          where Cast(CYID as int)=
                         (select isnull(Max(Cast(CYID as int)),0) from CP_YDang AA where exists (select code from #Tmp1 where code=AA.CYType))
               ' 
exec(@Tmsql+@fsj+@CtrlStr)
Drop  table #Tmp1
Drop  table #Tmp2
Drop  table #Tmp3  





/****** 对象:  UserDefinedFunction [dbo].[getPinYin]    脚本日期: 05/27/2013 11:34:09 ******/
SET ANSI_NULLS ON
GO
/****** Object:  StoredProcedure [dbo].[P_Select_CP_YDang]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- exec P_Select_CP_YDang ' ',0,'CT130623043 '
CREATE procedure [dbo].[P_Select_CP_YDang]
  @Code      char(20),  -----编号
  @PState    int,        ----0：新增，1：修改
  @CYType   varchar(40)
AS
  DECLARE @Tmsql         VARCHAR(8000)
  DECLARE @fsj   VARCHAR(200)
  DECLARE @CtrlStr   VARCHAR(200)
  DECLARE @Level int
  DECLARE @FCode  char(20)
  create table #Tmp1(code char(20))
  create Table #Tmp2(code char(20))
  create Table #Tmp3(code char(20))
  select @Level=CPLevel from CP_Type where CPID=@CYType
  Set @FCode=@CYType
  insert into #Tmp1 values(@FCode)
  insert into #Tmp2 values(@FCode)

  while @Level<=(select Max(CPLevel) from CP_Type)
  begin
    insert into #Tmp1(code)
    select CPID from CP_Type 
    where CPLevel=(@Level+1) and exists (select code from #Tmp2 where code=CP_Type.CPParent )
    insert into #Tmp3(code)
    select CPID from CP_Type 
    where CPLevel=@Level+1   and exists(select code from #Tmp2 where code=CP_Type.CPParent )
    delete #Tmp2
    insert into #Tmp2 select * from #Tmp3
    Delete #Tmp3
    Set @Level=@Level+1  
end 
  Set @Tmsql= 'select A.*,
               CPName=(select CPName from CP_Type X where X.CPID=A.CYType)
               --,KCQty=(select isnull(Sum(KCQty),0) from CK_YP_KC KC where KC.CYNO=A.CYNO)
               -- ,mfkzstr=[dbo].[F_Get_MFKZStr](A.CYID)
                from CP_YDang A 
            --    inner join CP_Type B On A.CYType=B.CPID               
                          where  Exists(select code from #Tmp1 where code=A.CYType)' 
  if @PState=1 set  @fsj=' and  A.CYID='''+rtrim(@Code)+''''
  if @PState=2 
  begin
    Set  @fsj=' and  A.CYNO like '''+rtrim(@Code)+''''
    Set @Tmsql= 'select A.*,B.CPName
               -- ,mfkzstr=[dbo].[F_Get_MFKZStr](A.CYID) 
                from CP_YDang A 
                inner join CP_Type B On A.CYType=B.CPID               
                          where 1=1 ' 
  end
exec(@Tmsql+@fsj+@CtrlStr+'order by  A.CYName ')
Drop  table #Tmp1
Drop  table #Tmp2
Drop  table #Tmp3  



/****** 对象:  StoredProcedure [dbo].[P_Select_CP_YDang_MaxNo]    脚本日期: 05/15/2013 16:04:55 ******/
SET ANSI_NULLS ON
GO
/****** Object:  StoredProcedure [dbo].[P_print_Order]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[P_print_Order]
  @mainID varchar(20)
as
begin

 select *,N=J/2+J%2
 into #tabMain
 from
 (
    select A.mainID,A.Subid,isnull(A.PrtHX,'') as PrtHX,isnull(A.PRTColorNo,'') as PRTColorNo,A.PRTColor,A.OrderUnit,A.XHNO,
         FilesOther=(select HX.FilesOther from TP_File HX where HX.WBID=A.HXTuGao),A.OrdColQty,A.OrdMSQty,A.PRTOrderQty,
         row_number() over(partition by isnull(Mainid,'') order by isnull(Mainid,''),Subid) as I,
         (select COUNT(subID) from JYOrder_Sub X where X.Mainid=A.MainId) as J,
         (select min(subID) from JYOrder_Sub X where X.Mainid=A.MainId) as MinSubID
    from JYOrder_Sub A where MainId=@mainID    
  ) AA
  order by XHNO,minsubid,Subid
  
         
   
  select A.PrtHX,A.OrderUnit,A.PRTColorNo as PRTColorNo0,A.PRTColor as PRTColor0,A.OrderUnit as OrderUnit0,A.FilesOther as FilesOther0,
         B.PRTColorNo as PRTColorNo1,B.PRTColor as PRTColor1,B.OrderUnit as OrderUnit1,B.FilesOther as FilesOther1,
         A.OrdColQty as OrdColQty0,B.OrdColQty as OrdColQty1,A.OrdMSQty as OrdMSQty0,B.OrdMSQty as OrdMSQty1,
         A.PRTOrderQty as PRTOrderQty0,B.PRTOrderQty as PRTOrderQty1,
         PRTOrderQty=(select SUM(B.PRTOrderQty) from JYOrder_Sub B where B.MainId=C.Mainid),
         C.*
  from #tabMain A
  left join #tabMain B on B.Mainid=A.Mainid and B.i-B.n=A.i
  inner join JYOrder_Main C on C.MainId=A.MainId
  where A.I<=A.N
   
  drop table #tabMain
 end
GO
/****** Object:  StoredProcedure [dbo].[P_Print_JYMD1]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Print_JYMD1 'FA16033','2'
CREATE procedure [dbo].[P_Print_JYMD1]
  @mainID varchar(200),
  @begtime varchar(40),
  @endtime varchar(40),
  @flag   varchar(10)='1'
as
begin
   select D.Mainid,C.Subid,F.CustomerNoName,F.SYRName,F.KHConNo,isnull(E.styleno,'') styleno,isnull(E.SOrdDefStr4,E.PRTColor) SOrdDefStr4,isnull(E.PRTColorNo,'') PRTColorNo,A.MJLen Qty,
   A.FillTime,A.MJTypeOther QtyUnit,ISNULL(A.BaoNo,'') AS baono,E.PRTspec,E.PRTOrderQty,E.PrtCode,E.PrtCodeName,E.XHNO,
   RollNo=A.MJXH,GangNo=A.mjstr4,A.MjQty2,A.MJQty3,A.MJQty4,A.MJMaoZ KGQty,A.MJID,D.MPRTSpec
   ,BulkQty=(case when E.OrderUnit='KG' then MJQty4 else MJLen end)
   ,DJqty=(select isnull(Sum(CC.Qty),0) from CK_SXPB_CR CC where CC.OrdSubIdRK=C.SubId and CC.CRFlag='入库' and CC.CKName='待检布')
   ,TPQty=(select isnull(Sum(CC.Qty),0) from CK_SXPB_CR CC where CC.ORDSubIdCK in (select S.SubId from JYOrder_Sub S where S.PRTColor=C.PRTColor and S.MainId=C.MainId) and CC.CRFlag='出库' and CC.CKName='坯布' and isnull(CC.CKName,'')<>'外加工')
   ,ROLLQty=(select isnull(SUM(CC.PiQty),0) from CK_SXPB_CR CC where CC.ORDSubIdCK in (select S.SubId from JYOrder_Sub S where S.PRTColor=C.PRTColor and S.MainId=C.MainId) and CC.CRFlag='出库' and CC.CKName='坯布' and isnull(CC.CKName,'')<>'外加工')
   into #tab_main
   from WFB_MJJY A
   left join CK_SXPB_CR B on B.SPID=A.APID
   left join JYOrder_Sub C on C.SubId=A.SubId
   left join JYOrder_Main D on D.MainId=A.MainId 
   left join JYOrderCon_Sub E on E.Subid=A.CONID
   left join JYOrderCon_Main F on F.Mainid=E.Mainid
   left join CK_BanCP_CR G on G.MJID=A.MJID and G.CRFlag='出库'
   where F.ConNo=@mainID and A.Filltime>=@begtime and A.Filltime<@endtime 
   and A.MJType='正品' and isnull(G.CRType,'')<>'其他出库' and isnull(G.CRType,'')<>'回修出库'
   order by cast(isnull(E.XHNO,0) as int),A.mjstr4,E.SOrdDefStr4,A.MJID,A.MJXH,cast(isnull(A.baono,0) as int)
   
   IF @flag='2' 
   begin
     select SOrdDefStr4,QtyUnit,PRTOrderQty,TPQty,DJQty,PrtCode,PrtCodeName,MPRTSpec,RollQty,SUM(Qty) as Qty,sum(KGQty) as KgQty,
     SUM(MjQty2) as MjQty2,SUM(MJQty3)as MJQty3,SUM(MJQty4) as MJQty4,COUNT(XHNO) MXRollQty,
     SUM(BulkQty) as BulkQty,
     SH=(case when isnull(TPQty,0)<>0 then (TPQty-DJQty)/TPQty*100 else 0 end),
     SumMJQty4=(select SUM(MJQty4) from #tab_main X
                      where 1=1),
     SumRollQty=(select COUNT(RollNo) from #tab_main X
                      where 1=1),
     SumQty=(select SUM(Qty) from #tab_main X
                      where 1=1)            
     from #tab_main
     group by XHNO,SOrdDefStr4,QtyUnit,PRTOrderQty,TPQty,DJQty,PrtCode,PrtCodeName,MPRTSpec,RollQty
     order by XHNO 
   end
   else
   begin
     select  A.*,
           sumLenQty=(select SUM(Qty) from #tab_main X 
                      where X.CustomerNoName=A.CustomerNoName and X.KHConNo=A.KHConNo 
                      and X.styleno=A.styleno and X.PRTspec=A.PRTspec and X.PRTColorNo=A.PRTColorNo),
           sumROLL=(select COUNT(RollNo) from #tab_main X 
                    where X.CustomerNoName=A.CustomerNoName and X.KHConNo=A.KHConNo 
                      and X.styleno=A.styleno and X.PRTspec=A.PRTspec and X.PRTColorNo=A.PRTColorNo),
           SumJZQty=(select Sum(MJQty4) from #tab_main X
                         where X.CustomerNoName=A.CustomerNoName and X.KHConNo=A.KHConNo 
                      and X.styleno=A.styleno and X.PRTspec=A.PRTspec and X.PRTColorNo=A.PRTColorNo),
           SumKGQty=(select Sum(KGQty) from #tab_main X
                         where X.CustomerNoName=A.CustomerNoName and X.KHConNo=A.KHConNo 
                      and X.styleno=A.styleno and X.PRTspec=A.PRTspec and X.PRTColorNo=A.PRTColorNo),
           SumZJ=(select COUNT(RollNo) from #tab_main X
                      where 1=1)
     from #tab_main A
     order by XHNO
   end
end
GO
/****** Object:  StoredProcedure [dbo].[P_Print_CKMD1]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Print_CKMD1 'FMP-KY-2016001','2'
CREATE procedure [dbo].[P_Print_CKMD1]
  @mainID varchar(200),
  @flag   varchar(10)='1'
as
begin
   select A.MainId,A.SubId,G.CustomerNoName,G.SYRName,isnull(G.KHConNo,'') KHConNo,isnull(F.styleno,'') styleno,isnull(F.SOrdDefStr4,F.PRTColor) SOrdDefStr4,isnull(C.PRTColorNo,'') PRTColorNo,A.Qty,
   A.CRTIME,A.KGQty,A.QtyUnit,A.RKOrdID,A.CKOrdNo,ISNULL(A.BaoNo,'') AS baono,F.PRTspec,F.PRTOrderQty,F.PrtCode,F.PrtCodeName,
   BZDATE=(select Top 1 filltime from CK_BanCP_CR CK where CK.MJID=D.MJID and CRFlag='出库'),F.XHNO,
   RollNo=D.MJXH,GangNo=D.mjstr4,D.MJLen,D.MjQty2,D.MJQty3,D.MJQty4,D.FillTime,D.MJID
   ,BulkQty=(case when F.OrderUnit='KG' then MJQty4 else MJLen end)
   ,DJqty=(select isnull(Sum(CC.Qty),0) from CK_SXPB_CR CC where CC.OrdSubIdRK=C.SubId and CC.CRFlag='入库' and CC.CKName='待检布')
   ,TPQty=(select isnull(Sum(CC.Qty),0) from CK_SXPB_CR CC where CC.ORDSubIdCK in (select S.SubId from JYOrder_Sub S where S.PRTColor=C.PRTColor and S.MainId=C.MainId) and CC.CRFlag='出库' and CC.CKName='坯布' and isnull(CC.CKName,'')<>'外加工')
   ,ROLLQty=(select isnull(SUM(CC.PiQty),0) from CK_SXPB_CR CC where CC.ORDSubIdCK in (select S.SubId from JYOrder_Sub S where S.PRTColor=C.PRTColor and S.MainId=C.MainId) and CC.CRFlag='出库' and CC.CKName='坯布' and isnull(CC.CKName,'')<>'外加工')
   into #tab_main
   from CK_BanCP_CR A 
   left join JYOrder_Main B on A.MainId=B.MainId
   left join JYOrder_Sub C on A.SubId=C.SubId
   left join WFB_MJJY D on A.MJId=D.MJId
   left join CK_SXPB_CR E on A.APID=E.SPID
   left join JYOrderCon_Sub F on F.Subid=D.CONID
   left join JYOrderCon_Main G on G.Mainid=F.Mainid
   where (A.CKOrdNo=@mainID or G.ConNo=@mainID) and A.CRFlag='出库' and D.MJType='正品' and isnull(A.CRType,'')='正常出库'
   order by cast(isnull(F.XHNO,0) as int),D.mjstr4,F.SOrdDefStr4,D.MJID,D.MJXH,cast(isnull(A.baono,0) as int)
   
   IF @flag='2' 
   begin
     select SOrdDefStr4,gangno,QtyUnit,PRTOrderQty,TPQty,DJQty,PrtCode,PrtCodeName,RollQty,SUM(Qty) as Qty,sum(KGQty) as KgQty,
     SUM(MjQty2) as MjQty2,SUM(MJQty3)as MJQty3,SUM(MJQty4) as MJQty4,COUNT(XHNO) MXRollQty,
     SUM(BulkQty) as BulkQty,
     SH=(case when isnull(TPQty,0)<>0 then (TPQty-DJQty)/TPQty*100 else 0 end),
     SumMJQty4=(select SUM(MJQty4) from #tab_main X
                      where 1=1),
     SumRollQty=(select COUNT(RollNo) from #tab_main X
                      where 1=1),
     SumQty=(select SUM(Qty) from #tab_main X
                      where 1=1)            
     from #tab_main
     group by XHNO,SOrdDefStr4,gangno,QtyUnit,PRTOrderQty,TPQty,DJQty,PrtCode,PrtCodeName,RollQty
     order by XHNO,SOrdDefStr4,gangno,QtyUnit
   end
   else
   begin
     select  A.*,
           sumLenQty=(select SUM(Qty) from #tab_main X 
                         where X.CustomerNoName=A.CustomerNoName and X.KHConNo=A.KHConNo 
                      and X.styleno=A.styleno and X.PRTspec=A.PRTspec and X.PRTColorNo=A.PRTColorNo
                      and X.GangNo=A.GangNO),
           sumROLL=(select COUNT(RollNo) from #tab_main X 
                         where X.CustomerNoName=A.CustomerNoName and X.KHConNo=A.KHConNo 
                      and X.styleno=A.styleno and X.PRTspec=A.PRTspec and X.PRTColorNo=A.PRTColorNo
                      and X.GangNo=A.GangNO),
           SumJZQty=(select Sum(MJQty4) from #tab_main X
                         where X.CustomerNoName=A.CustomerNoName and X.KHConNo=A.KHConNo 
                      and X.styleno=A.styleno and X.PRTspec=A.PRTspec and X.PRTColorNo=A.PRTColorNo
                      and X.GangNo=A.GangNO),
           SumKGQty=(select Sum(KGQty) from #tab_main X
                         where X.CustomerNoName=A.CustomerNoName and X.KHConNo=A.KHConNo 
                      and X.styleno=A.styleno and X.PRTspec=A.PRTspec and X.PRTColorNo=A.PRTColorNo
                      and X.GangNo=A.GangNO),
           SumZJ=(select COUNT(RollNo) from #tab_main X
                      where 1=1)
     from #tab_main A
   end
   
end
GO
/****** Object:  StoredProcedure [dbo].[P_Print_CKMD]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE procedure [dbo].[P_Print_CKMD]
  @mainID varchar(200),
  @DName varchar(30)
as
begin
   create table #tab_main
   (
     P_CodeName1 varchar(100),
     P_spec1 varchar(100),
     P_color1 varchar(100),
     gangNO1 varchar(100),
     packNo1 varchar(100),
     RollNo1 varchar(20),
     K1     decimal(18,2),
     M1     decimal(18,2),
     Zs1    decimal(18,2),
     KS1     decimal(18,2),
     MS1     decimal(18,2), 
     i1     int,
     P_CodeName2 varchar(100),
     P_spec2 varchar(100),
     P_color2 varchar(100),
     gangNO2 varchar(100),
     packNo2 varchar(100),
     RollNo2 varchar(20),
     K2     decimal(18,2),
     M2     decimal(18,2), 
     Zs2     decimal(18,2), 
     KS2     decimal(18,2),
     MS2     decimal(18,2),
     i2     int,
     Idx    int,
     sum1   varchar(100),
     sum2   varchar(100)
  ) 
  

   select A.*,
          B.MPRTCodeName,B.mprtspec,
          isnull(C.SOrddefstr4,'') as PRTColor,
          isnull(D.MJStr4,'')as MJStr4,D.MJQty2,D.MJXH,D.MJQty3,D.MJQty4
   into #tab1
   from CK_BanCP_CR A
   inner join JYOrder_Main B on B.MainId=A.MainId
   inner join JYOrder_Sub C on C.MainId=A.MainId and C.SubId=A.SubId
   inner join WFB_MJJY D on D.MJID=A.MJID
   where --(A.CKOrdNo=@mainID or A.RKOrdID = @mainID)
         exists(select subID from TBSubID X where X.SubId=A.BCID and X.DName=@DName)
   order by B.MprtCodeName,MprtSpec,prtcolor,MJStr4,isnull(A.BaoNo,''),MJXH
   
  
   select MPRTCodeName as P_CodeName,PRTColor as P_Color,MJStr4 as gangNO,COUNT(*) AS I,-1 as j,-1 as K,-1 as m,-1 as n,-1 as idx,
          IDENTITY(int,1,1) as keyNo
   into #tab2
   FROM #tab1 A
   GROUP BY	MPRTCodeName,PRTColor,MJStr4
   order by PRTColor,MJStr4
   
   declare @P_CodeName1 varchar(100)
   declare @P_Color1 varchar(100)  
   declare @gangNO1 varchar(100)
   
   declare @P_CodeName2 varchar(100)
   declare @P_Color2 varchar(100)  
   declare @gangNO2 varchar(100)
   
   declare @int int
   declare @i int
   declare @J int
   declare @K int
   declare @max int
   declare @idx int
   
   SET @int=1
   SET @i=0
   
   SET @idx=0
  
   select @P_CodeName1=P_CodeName,@P_Color1=P_Color,@gangNO1=gangNO from #tab2 where keyNo=1
   select @max=max(keyNo) from #tab2 
   
   while @int<=@max
   begin
     select @P_CodeName2=P_CodeName,@P_Color2=P_Color,@gangNO2=gangNO from #tab2 where keyNo=@int
     
     if rtrim(@P_CodeName1)=rtrim(@P_CodeName2) and rtrim(@P_Color1)=rtrim(@P_Color2) 
     begin
       if @i=0
       begin 
         SET @idx=@idx+1
         update #tab2 SET J=i,k=0,m=0,n=0,idx=@idx where  keyNo=@int
         SET @i=@i+1
       end
       else
       begin
         update #tab2 SET J=(select I from #tab2 where keyNO=@int-1),
                          k=0,m=1,n=0,idx=@idx
         where  keyNo=@int
         SET @i=0
       end
     end
     else
     begin
       SET @idx=@idx+1
       update #tab2 SET J=i,k=0,m=0,n=10,idx=@idx where  keyNo=@int
       SET @i=@i+1
       
       
       select @P_CodeName1=P_CodeName,@P_Color1=P_Color,@gangNO1=gangNO from #tab2 where keyNo=@int
     end;
     
     SET @int=@int+1
   end
   
  
   update #tab2 SET k=i-J   
  
   SET @int=1
   SET @i=0
   

   
   while @int<=@max
   begin
     select @i=m,@j=j,@k=k from #tab2 where keyNo=@int
          
     select A.*,IDENTITY(int,1,1) as keyNo,B.idx
     into #tab3
     from #tab1 A
     inner join #tab2 B on B.P_CodeName=A.MprtCodeName and B.P_Color=A.PrtColor and B.gangNo=A.MJStr4
     where B.keyNO=@int
     
     if @i=0 
     begin
       insert into #tab_main(P_CodeName1,P_spec1,P_color1,gangNO1,packNo1,RollNo1,K1,M1,zs1,i1,Idx)
       select MprtCodeName,MprtSpec,prtcolor,MJStr4,isnull(BaoNo,''),MJXH,MJQty4,Qty,MjQty2,KeyNo,idx
       from #tab3
     end
     else
     begin
       update #tab_main SET P_CodeName2=C.MprtCodeName,P_spec2=C.MprtSpec,P_color2=C.prtcolor,
                            gangNO2=C.MJStr4,packNo2=isnull(C.BaoNo,''),RollNo2=MJXH,K2=C.MJQty4,M2=C.Qty,Zs2=C.MjQty2,i2=C.keyNO,
                            Idx=C.idx
       from #tab_main A
       inner join #tab2 B on B.P_CodeName=A.P_CodeName1 and B.P_Color=A.P_Color1 and B.gangNo=A.gangNo1
       inner join #tab3 C on C.keyNO=A.I1
       
       where B.keyNO=@int-1
       
       IF @K>0 
       begin
         insert into #tab_main(P_CodeName2,P_spec2,P_color2,gangNO2,packNo2,RollNo2,K2,M2,zs2,i2,i1,idx)
         select MprtCodeName,MprtSpec,prtcolor,MJStr4,isnull(BaoNo,''),MJXH,MJQty4,Qty,MjQty2,KeyNo,99,idx
         from #tab3
         where keyNo>@J
       end  
        
     end
     SET @int=@int+1
     drop table #tab3
   end
   
   update #tab_main SET KS1=(select sum(k1) from #tab_main X where X.P_CodeName1=#tab_main.P_CodeName1 
                             and X.P_color1=#tab_main.P_color1 and X.gangNO1=#tab_main.gangNO1 and X.packNo1=#tab_main.packNo1),
                        MS1=(select sum(m1) from #tab_main X where X.P_CodeName1=#tab_main.P_CodeName1 
                             and X.P_color1=#tab_main.P_color1 and X.gangNO1=#tab_main.gangNO1 and X.packNo1=#tab_main.packNo1 ),
                        KS2=(select sum(k2) from #tab_main X where X.P_CodeName2=#tab_main.P_CodeName2 
                             and X.P_color2=#tab_main.P_color2 and X.gangNO2=#tab_main.gangNO2 and X.packNo2=#tab_main.packNo2),
                        MS2=(select sum(m2) from #tab_main X where X.P_CodeName2=#tab_main.P_CodeName2 
                             and X.P_color2=#tab_main.P_color2 and X.gangNO2=#tab_main.gangNO2 and X.packNo2=#tab_main.packNo2 )
                             
   insert into #tab_main(P_CodeName1,P_spec1,P_color1,gangNO1,packNo1,RollNo1,K1,M1,KS1,MS1,i1,P_CodeName2,P_spec2,P_color2,gangNO2,packNo2,RollNo2,K2,M2,Ks2,ms2,i2,Idx) 
   select '','','TOTAL','',isnull(COUNT(distinct packNo1),0),isnull(COUNT(distinct RollNo1),0),isnull(SUM(k1),0),isnull(SUM(M1),0),isnull(SUM(k1),0),isnull(SUM(M1),0),100,
          '','','TOTAL','',isnull(COUNT(distinct packNo2),0),isnull(COUNT(distinct RollNo2),0),isnull(SUM(k2),0),isnull(SUM(M2),0),isnull(SUM(k2),0),isnull(SUM(M2),0),100,
          idx
   from #tab_main
   where i1<100
   group by idx
   
   update #tab_main SET sum1=(select cast(count(packNo1)+  count(packNo2)as varchar)+'BALES/'+cast(sum(CAST(RollNo1 as int))+sum(CAST(RollNo2 as int)) as varchar)+'ROLLS/'+  
                              cast(sum(k1+K2) as varchar)+'KGS/'+ cast(sum(m1+M2) as varchar)+'MTS'
                             from #tab_main X where i1=100 and X.Idx=#tab_main.idx),
                        sum2=(select cast(count(packNo1)+  count(packNo2)as varchar)+'BALES/'+cast(sum(CAST(RollNo1 as int))+sum(CAST(RollNo2 as int)) as varchar)+'ROLLS/'+  
                              cast(sum(k1+K2) as varchar)+'KGS/'+ cast(sum(m1+M2) as varchar)+'MTS'
                             from #tab_main where i1=100)
   
   select * from #tab_main order by Idx,i1
   
end
GO
/****** Object:  StoredProcedure [dbo].[P_OrderNo_YSKDL]    Script Date: 12/17/2021 15:51:31 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec [P_OrderNo_YSKDL] '2012-10-01','2013-10-10'
CREATE Procedure [dbo].[P_OrderNo_YSKDL]
  @Begdate varchar(20),
  @Enddate varchar(20)
AS
Select AAA.*,Case when YSYBFlag=0 then YSYBMoney else YSYBMoneyFZ  end as YSYBMoneyY,
       YSKPMoneyY=KPMoney-SKBBMoney
    from (
select A.MainId,A.OrderNo,A.MPRTCodeName,
       CRTime=(select Top 1 CRTime from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记' ),
       Qty=(select isnull(sum(Qty),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记') ,
       Price=(select Top 1 Price from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记') ,
       HuiLv=(select Top 1 HuiLv from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记') ,
       BZType=(select Top 1 BZType from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记') ,
       QtyUnit=(select Top 1 QtyUnit from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记'),
       YSYBMoney=(select isnull(sum(Money),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记') ,
       KPMoney=(select isnull(sum(KPMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款发票登记') ,
       --YSBBMoney=(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='应收款登记') ,
       --SKYBMoney=(select isnull(sum(Money),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='收款登记' ) ,
       SKBBMoney=(select isnull(sum(BBMoney),0) from YF_Money_CR YC where YC.MainId=A.MainId and YC.CRType='收款登记') ,
       FKFS=(select Top 1 PayMent from JYOrderCon_Main C where C.ConNo=A.OrderNo) ,
       A.Filler ,
       A.OrdDefNote3,
       A.OrdDefNote4,
       A.YSYBFlag,
       A.YSYBMoneyFZ      
from JYOrder_Main A
where exists(select * from YF_Money_CR B where B.MainId=A.MainId and B.CRType='应收款登记' 
             and B.CRTime>=@begdate and B.CRTime<@enddate)
      and   exists (select MainId from YF_Money_CR B where B.Mainid=A.Mainid and B.CRType='收款登记' and B.YFDefFlag1=1)
)AAA


--select * from JYOrder_Main

--alter table JYOrder_Main Add YSYBFlag bit not null default(0)
GO
/****** Object:  StoredProcedure [dbo].[P_Do_PrintMd20]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Do_PrintMd20'','admin','',1
CREATE  Procedure [dbo].[P_Do_PrintMd20]
  @mainID varchar(20),
  @DName varchar(20),
  @flag varchar(20),
  @CNum int =12
as
begin

  Declare @Tmpsql  varchar(8000)
  declare @mainID1 varchar(20) 
  declare @mainID2 varchar(20) 
  declare @subID1 varchar(20) 
  declare @subID2 varchar(20) 
  declare @gangNo1 varchar(20)
  declare @gangNo2 varchar(20)
  declare @baoNo1 varchar(20)
  declare @baoNo2 varchar(20)
  declare @colNo1 varchar(20)
  declare @colNo2 varchar(20)
  declare @prthx1 varchar(20)
  declare @prthx2  varchar(20)

  declare @int int
  declare @i int
  declare @max int
   
  create table #tab_main
   ( mainID varchar(30),
     subID  varchar(30),
     MJID   varchar(30),
     gangNo varchar(30),
     baoNo  varchar(30),
     colNO    varchar(30),
     prthx  varchar(100),
     Qty    decimal(18,2),
     JQty    decimal(18,2),
     keyNo  int IDENTITY(1,1) NOT NULL,
     i      int not null default(0),
     j      int,
     k      int
   )
   
   
   INSERT into #tab_main(mainID,subID,MJID,gangNO,baoNO,colNo,prthx,Qty,JQty,i,j,k)
   SELECT A.mainID,subID='',MJID,gangNO=MJstr4,ISNULL(baoNO,''),colNo=B.sorddefstr1,isnull(B.prthx,''),
          MJlen,MJQty4,i=0,j=0,k=0
   FROM WFB_MJJY A
   INNER JOIN JYOrder_Sub B on B.MainId=A.MainID and B.SubId=A.subID
 --  where cast(ISNULL(baoNO,0) as Int)=0
   WHERE EXISTS(select SubId from TBSubID X where X.SubId=A.MJID and X.DName=@DName)
   ORDER BY MainID,cast(ISNULL(baoNO,0) as Int),MJstr4
   
   SET @int=1
   SET @i=0
  
  select @mainID1=MainID,@subID1=subID,@gangNo1=gangNo,@baoNo1=ISNULL(baoNO,''),@colno1=colNO,@prthx1=prthx from #tab_main where keyNo=1
  
  select @max=max(keyNo) from #tab_main 
  
  while @int<=@max 
  begin
    select @mainID2=MainID,@subID2=subID,@gangNo2=gangNo,@baoNo2=ISNULL(baoNO,''),@colno2=colNO,@prthx2=prthx from #tab_main where keyNo=@int
    
    if @mainID1=@mainID2 and @subID1=@subID2 and @baoNo1=@baoNo2 and @gangNo1=@gangNo2 and  @colno1=@colno2 and @prthx1=@prthx2
    begin
      update #tab_main SET i=@i where keyNo=@int
      SET @i=@i+1
    end
    else
    begin
      update #tab_main SET i=0 where keyNo=@int
      select @mainID1=MainID,@subID1=subID,@gangNo1=gangNo,@baoNo1=ISNULL(baoNO,''),@colno1=colNO,@prthx1=prthx from #tab_main where keyNo=@int
      SET @i=1
    end  
    SET @int=@int+1
  end
  
  update #tab_main SET j=i%@CNum,k=i/@CNum
   
  select MainID,subID,gangNO,baoNo,colNo,Prthx,k,
         sum(m0) as m0,sum(m1) as m1,sum(m2) as m2,sum(m3) as m3,sum(m4) as m4,
         sum(m5) as m5,sum(m6) as m6,sum(m7) as m7,sum(m8) as m8,sum(m9) as m9,
         sum(m10) as m10,sum(m11) as m11,sum(m12) as m12,sum(m13) as m13,
         sum(JZ0) as JZ0,sum(JZ1) as JZ1,sum(JZ2) as JZ2,sum(JZ3) as JZ3,sum(JZ4) as JZ4,
         sum(JZ5) as JZ5,sum(JZ6) as JZ6,sum(JZ7) as JZ7,sum(JZ8) as JZ8,sum(JZ9) as JZ9,
         sum(JZ10) as JZ10,sum(JZ11) as JZ11,sum(JZ12) as JZ12,sum(JZ13) as JZ13,
         SUM(n0+n1+n2+n3+n4+n5+n6+n7+n8+n9+n10+n11+n12+n13) as MRoll, 
         sum(Qty)as MQty,
         SUM(JQty) as MJZQty,
         OrderNo=(select Top 1 OrderNo from JYOrder_Main X where X.MainId=A.mainID),
         QtyUnit=(select Top 1 MJTypeOther from WFB_MJJY X where X.MainId=A.mainID and baoNo>0),
         Z_bao=(select COUNT(distinct baoNo) from #tab_main where ISNULL(baoNo,0)>0),
         Z_Roll=(select COUNT(MainID) from #tab_main),
         Z_Qty=(select SUM(Qty) from #tab_main),
         Z_JZQty=(select SUM(JQty) from #tab_main)
  from(
  select MainID,subID,gangNO,baoNo,colNo,Prthx,Qty,JQty,K,
         case when J=0 then 1 else 0 end as n0,
         case when J=1 then 1 else 0 end as n1,
         case when J=2 then 1 else 0 end as n2,
         case when J=3 then 1 else 0 end as n3,
         case when J=4 then 1 else 0 end as n4,
         case when J=5 then 1 else 0 end as n5,
         case when J=6 then 1 else 0 end as n6,
         case when J=7 then 1 else 0 end as n7,
         case when J=8 then 1 else 0 end as n8,
         case when J=9 then 1 else 0 end as n9,
         case when J=10 then 1 else 0 end as n10,
         case when J=11 then 1 else 0 end as n11,
         case when J=12 then 1 else 0 end as n12,
         case when J=13 then 1 else 0 end as n13,
         
         case when J=0 then Qty else 0 end as m0,
         case when J=1 then Qty else 0 end as m1,
         case when J=2 then Qty else 0 end as m2,
         case when J=3 then Qty else 0 end as m3,
         case when J=4 then Qty else 0 end as m4,
         case when J=5 then Qty else 0 end as m5,
         case when J=6 then Qty else 0 end as m6,
         case when J=7 then Qty else 0 end as m7,
         case when J=8 then Qty else 0 end as m8,
         case when J=9 then Qty else 0 end as m9,
         case when J=10 then Qty else 0 end as m10,
         case when J=11 then Qty else 0 end as m11,
         case when J=12 then Qty else 0 end as m12,
         case when J=13 then Qty else 0 end as m13,
         
         case when J=0 then JQty else 0 end as JZ0,
         case when J=1 then JQty else 0 end as JZ1,
         case when J=2 then JQty else 0 end as JZ2,
         case when J=3 then JQty else 0 end as JZ3,
         case when J=4 then JQty else 0 end as JZ4,
         case when J=5 then JQty else 0 end as JZ5,
         case when J=6 then JQty else 0 end as JZ6,
         case when J=7 then JQty else 0 end as JZ7,
         case when J=8 then JQty else 0 end as JZ8,
         case when J=9 then JQty else 0 end as JZ9,
         case when J=10 then JQty else 0 end as JZ10,
         case when J=11 then JQty else 0 end as JZ11,
         case when J=12 then JQty else 0 end as JZ12,
         case when J=13 then JQty else 0 end as JZ13
    from #tab_main
    ) A
    group by MainID,subID,gangNO,baoNo,colNo,Prthx,k
    ORDER BY MainID,cast(ISNULL(baoNO,0) as Int),cast(replace(isnull(colNo,''),'#','') as int),Prthx,gangNo
    
end
GO
/****** Object:  StoredProcedure [dbo].[P_Do_PrintMd10]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Do_PrintMd10'','admin',''
CREATE  Procedure [dbo].[P_Do_PrintMd10]
  @mainID varchar(20),
  @DName varchar(20),
  @flag varchar(20)
as
begin

  Declare @Tmpsql  varchar(8000)
  declare @mainID1 varchar(20) 
  declare @mainID2 varchar(20) 
  declare @subID1 varchar(20) 
  declare @subID2 varchar(20) 
  declare @gangNo1 varchar(20)
  declare @gangNo2 varchar(20)
  declare @baoNo1 varchar(20)
  declare @baoNo2 varchar(20)

  declare @int int
  declare @i int
  declare @max int
   
  create table #tab_main
   ( mainID varchar(30),
     subID  varchar(30),
     MJID   varchar(30),
     gangNo varchar(30),
     baoNo  varchar(30),
     Qty    decimal(18,2),
     keyNo  int IDENTITY(1,1) NOT NULL,
     i      int not null default(0),
     j      int,
     k      int
   )
   
   
   INSERT into #tab_main(mainID,subID,MJID,gangNO,baoNO,Qty,i,j,k)
   SELECT mainID,subID='',MJID,gangNO=MJstr4,ISNULL(baoNO,''),Qty=MJlen,i=0,j=0,k=0
   FROM WFB_MJJY A
 --  where cast(ISNULL(baoNO,0) as Int)=0
   WHERE EXISTS(select SubId from TBSubID X where X.SubId=A.MJID and X.DName=@DName)
   ORDER BY MainID,cast(ISNULL(baoNO,0) as Int),MJstr4
   
   SET @int=1
   SET @i=0
  
  select @mainID1=MainID,@subID1=subID,@gangNo1=gangNo,@baoNo1=ISNULL(baoNO,'') from #tab_main where keyNo=1
  
  select @max=max(keyNo) from #tab_main 
  
  while @int<=@max 
  begin
    select @mainID2=MainID,@subID2=subID,@gangNo2=gangNo,@baoNo2=ISNULL(baoNO,'') from #tab_main where keyNo=@int
    
    if @mainID1=@mainID2 and @subID1=@subID2 and @baoNo1=@baoNo2 and @gangNo1=@gangNo2 
    begin
      update #tab_main SET i=@i where keyNo=@int
      SET @i=@i+1
    end
    else
    begin
      update #tab_main SET i=0 where keyNo=@int
      select @mainID1=MainID,@subID1=subID,@gangNo1=gangNo,@baoNo1=ISNULL(baoNO,'') from #tab_main where keyNo=@int
      SET @i=1
    end  
    SET @int=@int+1
  end
  
  update #tab_main SET j=i%14,k=i/14
   
  select MainID,subID,gangNO,baoNo,k,
         sum(m0) as m0,sum(m1) as m1,sum(m2) as m2,sum(m3) as m3,sum(m4) as m4,
         sum(m5) as m5,sum(m6) as m6,sum(m7) as m7,sum(m8) as m8,sum(m9) as m9,
         sum(m10) as m10,sum(m11) as m11,sum(m12) as m12,sum(m13) as m13,
         SUM(n0+n1+n2+n3+n4+n5+n6+n7+n8+n9+n10+n11+n12+n13) as MRoll, 
         sum(Qty)as MQty,
         OrderNo=(select Top 1 OrderNo from JYOrder_Main X where X.MainId=A.mainID),
         QtyUnit=(select Top 1 MJTypeOther from WFB_MJJY X where X.MainId=A.mainID and baoNo>0),
         Z_bao=(select COUNT(distinct baoNo) from #tab_main where ISNULL(baoNo,0)>0),
         Z_Roll=(select COUNT(MainID) from #tab_main),
         Z_Qty=(select SUM(Qty) from #tab_main)
  from(
  select MainID,subID,gangNO,baoNo,Qty,K,
         case when J=0 then 1 else 0 end as n0,
         case when J=1 then 1 else 0 end as n1,
         case when J=2 then 1 else 0 end as n2,
         case when J=3 then 1 else 0 end as n3,
         case when J=4 then 1 else 0 end as n4,
         case when J=5 then 1 else 0 end as n5,
         case when J=6 then 1 else 0 end as n6,
         case when J=7 then 1 else 0 end as n7,
         case when J=8 then 1 else 0 end as n8,
         case when J=9 then 1 else 0 end as n9,
         case when J=10 then 1 else 0 end as n10,
         case when J=11 then 1 else 0 end as n11,
         case when J=12 then 1 else 0 end as n12,
         case when J=13 then 1 else 0 end as n13,
         
         case when J=0 then Qty else 0 end as m0,
         case when J=1 then Qty else 0 end as m1,
         case when J=2 then Qty else 0 end as m2,
         case when J=3 then Qty else 0 end as m3,
         case when J=4 then Qty else 0 end as m4,
         case when J=5 then Qty else 0 end as m5,
         case when J=6 then Qty else 0 end as m6,
         case when J=7 then Qty else 0 end as m7,
         case when J=8 then Qty else 0 end as m8,
         case when J=9 then Qty else 0 end as m9,
         case when J=10 then Qty else 0 end as m10,
         case when J=11 then Qty else 0 end as m11,
         case when J=12 then Qty else 0 end as m12,
         case when J=13 then Qty else 0 end as m13
    from #tab_main
    ) A
    group by MainID,subID,gangNO,baoNo,k
    ORDER BY MainID,cast(ISNULL(baoNO,0) as Int),gangNo
    
end
GO
/****** Object:  StoredProcedure [dbo].[P_Do_PrintMd_HZ]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Do_PrintMd30'','admin',''
CREATE  Procedure [dbo].[P_Do_PrintMd_HZ]
  @mainID varchar(20),
  @DName varchar(20),
  @flag varchar(20)
as
begin
  IF @flag='30'
  begin
    SELECT A.mainID,gangNO=A.MJstr4,B.PRTHX,
           Qty=sum(MJlen),Roll=COUNT(A.mainID),SUM(MJQty4) as MJQty4 
    FROM WFB_MJJY A
    INNER JOIN JYOrder_Sub B on B.MainId=A.MainID and B.SubId=A.subID
    WHERE EXISTS(select SubId from TBSubID X where X.SubId=A.MJID and X.DName=@DName)
    GROUP bY A.mainID,B.PRTHX,A.MJstr4
    ORDER BY A.mainID,B.PRTHX,A.MJstr4
  end
  else
  begin
    SELECT A.mainID,B.SOrddefstr1,B.PRTHX,
           Qty=sum(MJlen),Roll=COUNT(A.mainID),SUM(MJQty4) as MJQty4  
    FROM WFB_MJJY A
    INNER JOIN JYOrder_Sub B on B.MainId=A.MainID and B.SubId=A.subID
    WHERE EXISTS(select SubId from TBSubID X where X.SubId=A.MJID and X.DName=@DName)
    GROUP bY A.mainID,B.SOrddefstr1,B.PRTHX
    ORDER BY A.mainID,cast(replace(isnull(B.sorddefstr1,''),'#','') as int),B.PRTHX
  end
 
 
end
GO
/****** Object:  StoredProcedure [dbo].[P_Do_PrintMd]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Do_PrintMd'','sa',''
CREATE  Procedure [dbo].[P_Do_PrintMd]
  @mainID varchar(20),
  @DName varchar(20),
  @flag varchar(20)
as
begin

  Declare @Tmpsql  varchar(8000)
  declare @mainID1 varchar(20) 
  declare @mainID2 varchar(20) 
  declare @subID1 varchar(20) 
  declare @subID2 varchar(20) 
  declare @gangNo1 varchar(20)
  declare @gangNo2 varchar(20)
  declare @baoNo1 varchar(20)
  declare @baoNo2 varchar(20)

  declare @int int
  declare @i int
  declare @max int
 /*  
  create table #tab_main
   ( mainID varchar(30),
     subID  varchar(30),
     MJID   varchar(30),
     gangNo varchar(30),
     baoNo  varchar(30),
     Qty    decimal(18,2),
     keyNo  int IDENTITY(1,1) NOT NULL,
     i      int not null default(0),
     j      int,
     k      int
   )
  */ 
   

   SELECT A.MJStr4,A.MJLen,A.MJTypeOther,A.baoID,A.baoNo,A.MJQty3,A.MJQty4,A.MJMaoZ,A.MJXH,A.MJID,A.MKXs,
          B.SOrddefstr1,B.PRTColor,B.SOrddefstr4,B.PRTHX,B.Sorddefstr6,
          C.Filler as zl,C.OrdPerson1,C.OrderNo,C.MPRTCodeName,
          IDENTITY(int,0,1) as keyNo,0 as i,0 as k,0 as m,0 as n,cast(0.00 as decimal(18,2)) as sumbaoQty
   INTO #tab1         
   FROM WFB_MJJY A
   inner join JYOrder_Sub B on B.MainId=A.MainId and B.SubId=A.subID
   inner join JYOrder_Main C on C.MainId=A.MainId
   WHERE EXISTS(select SubId from TBSubID X where X.SubId=A.MJID and X.DName=@DName)
   ORDER BY A.MainID,cast(ISNULL(baoNO,0) as Int),MJXH,MJstr4
   
   
   update #tab1 SET i=keyNO/64
   
   update #tab1 SET k=case when(keyNo-I*64)>=32 then (keyNo-I*64)-32 else (keyNo-I*64) end
   
   update #tab1 SET m=case when(keyNo-I*64)>=32 then 1 else 0 end
   
   update #tab1 SET sumbaoQty=(select SUM(MJlen) from #tab1 X where X.baono=#tab1.baoNo  )
   
   select A.OrderNo,A.MJTypeOther, A.MPRTCodeName,A.zl,A.OrdPerson1,
          A.baoNo as baoNo0,A.mjstr4 as gangNo0,A.MJXH as MJXh0,A.MJID as MJID0,A.MJlen as MJlen0,A.SOrddefstr1 as SH0,A.sumbaoQty as sumbaoQty0,
          B.baoNo as baoNo1,B.mjstr4 as gangNo1,B.MJXH as MJXh1,B.MJID as MJID1,B.MJlen as MJlen1,B.SOrddefstr1 as SH1,B.sumbaoQty as sumbaoQty1
   from #tab1 A
   left join #tab1 B on B.m=1 and B.i=A.i and B.k=A.k
   where A.m=0
end
GO
/****** Object:  StoredProcedure [dbo].[P_ConJDCX]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_ConJDCX '2017-08-01','2018-01-11'
CREATE procedure [dbo].[P_ConJDCX]
  @Begdate varchar(30),
  @endDate varchar(30)
As
  select A.OrdDate,A.ConNo,A.MainID,ConNoGS=(select COUNT(B.Subid) from JYOrderCon_Sub B where B.MainId=A.Mainid)
        ,OrderGS=(select COUNT(distinct C.ConSubid) from JYOrder_Main C inner join JYOrderCon_Sub B on B.SubId=C.conSubid
                where B.MainId=A.Mainid)
        ,GX=(select COUNT(B.PSId) from JYOrder_Process B inner join JYOrder_Main C on B.Mainid=C.Mainid 
                    inner join JYOrderCon_Sub D on D.SubId=C.conSubid where D.MainId=A.Mainid)
        ,CGJG=(select COUNT(B.CGNo) from Contract_Main B inner join JYOrder_Main C on B.ConNO=C.orderNo 
                    inner join JYOrderCon_Sub D on D.SubId=C.conSubid where D.MainId=A.Mainid)
        ,MD=(select COUNT(distinct B.CGNo) from CK_SXPB_CR B inner join JYOrder_Main C on B.ORDMainIdRK=C.MainId 
                    inner join JYOrderCon_Sub D on D.SubId=C.conSubid where D.MainId=A.Mainid and B.CRFlag='入库')
        ,CPRK=(select COUNT(distinct C.ConSubid) from CK_SXPB_CR B inner join JYOrder_Main C on B.ORDMainIdRK=C.MainId 
                    inner join JYOrderCon_Sub D on D.SubId=C.conSubid where D.MainId=A.Mainid and isnull(CKName,'')='成品' and B.CRFlag='入库')
        ,CPCK=(select COUNT(distinct C.ConSubid) from CK_SXPB_CR B inner join JYOrder_Main C on B.ORDMainIdRK=C.MainId 
                    inner join JYOrderCon_Sub D on D.SubId=C.conSubid where D.MainId=A.Mainid and isnull(CKName,'')='成品' and B.CRFlag='出库')
  from JYOrderCon_Main A
  where A.OrdDate>=@Begdate and A.OrdDate<@EndDate
GO
/****** Object:  StoredProcedure [dbo].[P_Chk_Tishi]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Chk_Tishi 'HF','CP006'
CREATE Procedure [dbo].[P_Chk_Tishi]
  @DName varchar(20),
  @DCode varchar(20)
AS
  Create Table #Temp1(DName varchar(20),ModuleName varchar(20),ModuleID varchar(20),ModuleSubId varchar(20))
  DECLARE @FInt integer
  --坯布采购计划审核
  Set @Fint=0
  select @Fint=isnull(Count(A.SubId),0) 
  from Contract_Sub A
  where isnull(A.SChkStatus,'0')='1' 
  and exists(select * from SY_Purview where ModuleID='07' and ModuleSubID='09' and UserID=@DCode)
  
  IF @Fint>0 --select * from SY_ModuleSub
  BEGIN
    Insert into #Temp1
    select @DName,'坯布采购计划审核','07','09'
  END 
  --坯布采购计划审核
  --合同信息审核
  Set @Fint=0
  select @Fint=isnull(Count(A.Mainid),0) 
  from JYOrderCon_Main A
  where isnull(A.status,'0')='1' 
  and exists(select * from SY_Purview where ModuleID='04' and ModuleSubID='03' and UserID=@DCode)
  
  IF @Fint>0 --select * from SY_ModuleSub
  BEGIN
    Insert into #Temp1
    select @DName,'合同信息审核','04','03'
  END 
  --合同信息审核
  --生产指示单审核
  Set @Fint=0
  select @Fint=isnull(Count(A.Mainid),0) 
  from JYOrder_Main A
  where isnull(A.ChkStatus,'')='' 
  and exists(select * from SY_Purview where ModuleID='05' and ModuleSubID='02' and UserID=@DCode)
  
  IF @Fint>0 --select * from SY_ModuleSub
  BEGIN
    Insert into #Temp1
    select @DName,'生产指示单审核','05','02'
  END 
  --生产指示单审核
  --**************************************以下是查看提醒********************************************--
  --坯布采购计划查看
  Set @Fint=0
  select @Fint=isnull(Count(A.SubId),0) 
  from Contract_Sub A inner join Contract_Main B on A.MainId=B.Mainid
  where isnull(A.SChkStatus,'0')='2' and ISNULL(A.IFCK,'')='' and B.Filler=@DName
  and exists(select * from SY_Purview where ModuleID='07' and ModuleSubID='08' and UserID=@DCode)
  
  IF @Fint>0 --select * from SY_ModuleSub
  BEGIN
    Insert into #Temp1
    select @DName,'坯布采购计划查看','07','08'
  END 
  --坯布采购计划查看
  --合同信息查看
  Set @Fint=0
  select @Fint=isnull(Count(A.Mainid),0) 
  from JYOrderCon_Main A
  where isnull(A.status,'0')='2' and ISNULL(A.IFCK,'')='' and (A.ConPerson1=@DName or A.Filler=@DName)
  and exists(select * from SY_Purview where ModuleID='04' and ModuleSubID='01' and UserID=@DCode)

  IF @Fint>0 --select * from SY_ModuleSub
  BEGIN
    Insert into #Temp1
    select @DName,'合同信息查看','04','01'
  END 
  --合同信息查看
  --生产指示单查看
  Set @Fint=0
  select @Fint=isnull(Count(A.Mainid),0) 
  from JYOrder_Main A
  where isnull(A.ChkStatus,'')='1' and ISNULL(A.IFCK,'')='' and (A.YWY=@DName or A.Filler=@DName)
  and exists(select * from SY_Purview where ModuleID='05' and ModuleSubID='01' and UserID=@DCode)
  
  IF @Fint>0 --select * from SY_ModuleSub
  BEGIN
    Insert into #Temp1
    select @DName,'生产指示单查看','05','01'
  END 
  --生产指示单查看
  select * from #Temp1
GO
/****** Object:  StoredProcedure [dbo].[P_Do_Yshx]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  PROCEDURE [dbo].[P_Do_Yshx]
  @hxFlag    INT,           --1=收款；2=调价
  @ysAutoId  VARCHAR(20),   --应收款记录
  @skAutoId  VARCHAR(20),
  @hxMoney   DECIMAL(18, 3),        
  @userId    VARCHAR(20),
  @PZNo      VARCHAR(20)    --凭证号
AS

SET NOCOUNT ON

DECLARE @iResult INT
DECLARE @ShowMsg VARCHAR(100)

BEGIN TRAN

IF @hxFlag = 1 
BEGIN
  --应收款核销
  UPDATE YF_Money_CR SET HxNum = ISNULL(HxNum, 0) + @hxMoney WHERE YFID = @ysAutoId

  SET @iResult = @@ERROR
  IF @iResult <> 0
  BEGIN
	  ROLLBACK TRAN
    SET @ShowMsg = '核销应收款记录时出错！'
		GOTO Quit
	END
	
  UPDATE YF_Money_CR SET HXStatus ='3' WHERE YFID = @ysAutoId and HxNum<>0
	
  UPDATE YF_Money_CR SET HxNum = ISNULL(HxNum, 0) + @hxMoney WHERE YFID = @skAutoId 

  SET @iResult = @@ERROR
	IF @iResult <> 0
	BEGIN
	  ROLLBACK TRAN
    SET @ShowMsg = '核销收款记录时出错！'
		GOTO Quit
	END
   UPDATE YF_Money_CR SET HXStatus ='3'  WHERE YFID = @skAutoId and HxNum<>0

END

 INSERT YF_log (AutoID, ListNo, ToNo, Num, Type, Filler, FillDate) 
  VALUES (@PZNo, @skAutoId, @ysAutoId, @hxMoney, 'SK', @userId, GETDATE()) 

  SET @iResult = @@ERROR
	IF @iResult <> 0
	BEGIN
	  ROLLBACK TRAN
		SET @ShowMsg = '写核销日志时出错！'
		GOTO Quit
	END

COMMIT TRAN

Quit:
SELECT Result = @iResult, ShowMsg = @ShowMsg

SET NOCOUNT OFF
GO
/****** Object:  StoredProcedure [dbo].[P_DO_Unit]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_DO_Unit
CREATE procedure [dbo].[P_DO_Unit]
as
begin
  declare @i int
  declare @maxi int
  declare @MJlen decimal(18,2)
  declare @MJQty4 decimal(18,2)
  DECLARE @MJFK   decimal(18,2)
  DECLARE @MJSJKZ decimal(18,2)
  
  DECLARE @Unit   varchar(10)
  DECLARE @MJID   varchar(20)
  select *,IDENTITy(int,1,1)as keyNo  
  into #tab1 
  from WFB_MJJY 
  where isnull(MJTypeOther,'')='' 
  
  SET @i=0 
  
  select @maxi=MAX(keyNO)from #tab1
  
  while @i<=@maxi 
  begin
    Print(@i)
    SET @Unit='' 
    select @MJID=MJID,@MJlen=MJLen,@MJQty4=MjQty4,@MJFK=MJFK,@MJSJKZ=MJSJKZ from #tab1 where keyNo=@i
    Print(@MJFK)
    Print(@MJSJKZ)
    IF cast(@MJFK*@MJSJKZ as decimal(18,2))>0 
    begin
      Print(@i)
      Print(cast(@MJQty4*1000*100/@MJFK/@MJSJKZ as decimal(18,0)))
      Print(cast(@MJQty4*1000*100/@MJFK/@MJSJKZ*1.0936 as decimal(18,0)))
      Print(CAST(@MJLen as decimal(18,0)))
      IF cast(@MJQty4*1000*100/@MJFK/@MJSJKZ as decimal(18,0))=CAST(@MJLen as decimal(18,0))
      begin
        SET @Unit='M' 
      end
      else IF cast(@MJQty4*1000*100/@MJFK/@MJSJKZ*1.0936 as decimal(18,0))=CAST(@MJLen as decimal(18,0))
      begin
        SET @Unit='Y'
      end
      IF @Unit<>'' 
      begin
        update WFB_MJJY SET MJTypeOther=@Unit,MJStr5='单位更新' where MJID=@MJID
      end

    end 
    SET @i=@i+1
  end
  
 
  update WFB_MJJY SET MJTypeOther=ISNULL((select max(MJTypeOther) from WFB_MJJY X where X.subID=WFB_MJJY.subID and isnull(X.MJTypeOther,'')<>''),''),
                      MJStr5='单位更新' 
  where isnull(MJTypeOther,'')='' 
  

  update CK_BanCP_CR SET QtyUnit=(select MJTypeOther from WFB_MJJY X where X.MJID=CK_BanCP_CR.MJID ) where isnull(QtyUnit,'')='' 
  update CK_BanCP_KC SET KCQtyUnit=(select MJTypeOther from WFB_MJJY X where X.MJID=CK_BanCP_KC.MJID ) where isnull(KCQtyUnit,'')='' 
end
GO
/****** Object:  StoredProcedure [dbo].[P_Do_PrintMd50]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Do_PrintMd40'','admin',''
CREATE  Procedure [dbo].[P_Do_PrintMd50]
  @mainID varchar(20),
  @DName varchar(20),
  @flag varchar(20)
as
begin


  declare @int int
  declare @i int
  declare @max int
   
  create table #tab_main
   ( mainID varchar(30),
     subID  varchar(30),
     MJID   varchar(30),
     gangNo varchar(30),
     RollNo  varchar(30),
     colNO    varchar(30),
     prthx  varchar(100),
     Qty    decimal(18,2),
     JQty    decimal(18,2),
     keyNo  int IDENTITY(0,1) NOT NULL,
     i      int,
     j      int,
     k      int
   )
   
   
   INSERT into #tab_main(mainID,subID,MJID,gangNO,RollNo,colNo,prthx,Qty,JQty,i,j,k)
   SELECT A.mainID,subID='',MJID,gangNO=MJstr4,MJXH,colNo=B.sorddefstr1,isnull(B.prthx,''),
          MJQty4,MJQty4,i=0,j=0,k=0
   FROM WFB_MJJY A
   INNER JOIN JYOrder_Sub B on B.MainId=A.MainID and B.SubId=A.subID
   WHERE EXISTS(select SubId from TBSubID X where X.SubId=A.MJID and X.DName=@DName)
   ORDER BY MainID,cast(replace(isnull(B.sorddefstr1,''),'#','') as int),MJstr4,MJXH
   
   
   IF @flag='1'
   begin
     SELECT A.*,
          OrderNo=(select Top 1 OrderNo from JYOrder_Main X where X.MainId=A.mainID),
          QtyUnit=(select Top 1 MJTypeOther from WFB_MJJY X where X.MainId=A.mainID ),
          Z_Roll=(select COUNT(MainID) from #tab_main),
          Z_Qty=(select SUM(Qty) from #tab_main),
          Z_JZQty=(select SUM(JQty) from #tab_main)
     FROM #tab_main A
   end
   ELSE
   begin
   update #tab_main SET i=keyNo/3,k=keyNO%3
  -- SELECT * FROM #tab_main
   
     SELECT A.MainID,
          A.RollNo as RollNo0,A.gangNO as gangNO0,A.colNo as colNo0,A.prthx as prthx0,A.Qty as Qty0,
          B.RollNo as RollNo1,B.gangNO as gangNO1,B.colNo as colNo1,B.prthx as prthx1,B.Qty as Qty1,
          C.RollNo as RollNo2,C.gangNO as gangNO2,C.colNo as colNo2,C.prthx as prthx2,C.Qty as Qty2,
          OrderNo=(select Top 1 OrderNo from JYOrder_Main X where X.MainId=A.mainID),
          QtyUnit=(select Top 1 MJTypeOther from WFB_MJJY X where X.MainId=A.mainID ),
          Z_Roll=(select COUNT(MainID) from #tab_main),
          Z_Qty=(select SUM(Qty) from #tab_main),
          Z_JZQty=(select SUM(JQty) from #tab_main)
     FROM #tab_main A
     left join #tab_main B on B.i=A.i and B.k=1
     left join #tab_main C on C.i=A.i and C.k=2
     where A.k=0 
   end
    
end
GO
/****** Object:  StoredProcedure [dbo].[P_Do_PrintMd40]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Do_PrintMd40'','admin',''
CREATE  Procedure [dbo].[P_Do_PrintMd40]
  @mainID varchar(20),
  @DName varchar(20),
  @flag varchar(20)
as
begin


  declare @int int
  declare @i int
  declare @max int
   
  create table #tab_main
   ( mainID varchar(30),
     subID  varchar(30),
     MJID   varchar(30),
     gangNo varchar(30),
     RollNo  varchar(30),
     colNO    varchar(30),
     prthx  varchar(100),
     Qty    decimal(18,2),
     JQty    decimal(18,2),
     keyNo  int IDENTITY(0,1) NOT NULL,
     i      int,
     j      int,
     k      int
   )
   
   
   INSERT into #tab_main(mainID,subID,MJID,gangNO,RollNo,colNo,prthx,Qty,JQty,i,j,k)
   SELECT A.mainID,subID='',MJID,gangNO=MJstr4,MJXH,colNo=B.sorddefstr1,isnull(B.prthx,''),
          MJlen,MJQty4,i=0,j=0,k=0
   FROM WFB_MJJY A
   INNER JOIN JYOrder_Sub B on B.MainId=A.MainID and B.SubId=A.subID
   WHERE EXISTS(select SubId from TBSubID X where X.SubId=A.MJID and X.DName=@DName)
   ORDER BY MainID,cast(replace(isnull(B.sorddefstr1,''),'#','') as int),MJstr4,MJXH
   
   
   IF @flag='1'
   begin
     SELECT A.*,
          OrderNo=(select Top 1 OrderNo from JYOrder_Main X where X.MainId=A.mainID),
          QtyUnit=(select Top 1 MJTypeOther from WFB_MJJY X where X.MainId=A.mainID ),
          Z_Roll=(select COUNT(MainID) from #tab_main),
          Z_Qty=(select SUM(Qty) from #tab_main),
          Z_JZQty=(select SUM(JQty) from #tab_main)
     FROM #tab_main A
   end
   ELSE
   begin
   update #tab_main SET i=keyNo/3,k=keyNO%3
  -- SELECT * FROM #tab_main
   
     SELECT A.MainID,
          A.RollNo as RollNo0,A.gangNO as gangNO0,A.colNo as colNo0,A.prthx as prthx0,A.Qty as Qty0,
          B.RollNo as RollNo1,B.gangNO as gangNO1,B.colNo as colNo1,B.prthx as prthx1,B.Qty as Qty1,
          C.RollNo as RollNo2,C.gangNO as gangNO2,C.colNo as colNo2,C.prthx as prthx2,C.Qty as Qty2,
          OrderNo=(select Top 1 OrderNo from JYOrder_Main X where X.MainId=A.mainID),
          QtyUnit=(select Top 1 MJTypeOther from WFB_MJJY X where X.MainId=A.mainID ),
          Z_Roll=(select COUNT(MainID) from #tab_main),
          Z_Qty=(select SUM(Qty) from #tab_main),
          Z_JZQty=(select SUM(JQty) from #tab_main)
     FROM #tab_main A
     left join #tab_main B on B.i=A.i and B.k=1
     left join #tab_main C on C.i=A.i and C.k=2
     where A.k=0 
   end
    
end
GO
/****** Object:  StoredProcedure [dbo].[P_Do_PrintMd30]    Script Date: 12/17/2021 15:51:28 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
--exec P_Do_PrintMd30'','sa','','7'
CREATE  Procedure [dbo].[P_Do_PrintMd30]
  @mainID varchar(20),
  @DName varchar(20),
  @flag varchar(20),
  @CNum int =12
as
begin

  declare @int int
  declare @i int
  declare @max int
   
  create table #tab_main
   ( mainID varchar(30),
     subID  varchar(30),
     MJID   varchar(30),
     gangNo varchar(30),
     PRTHX   varchar(30),
     colNo  int,
     baoNo  varchar(30),
     Qty    decimal(18,2),
     JQty    decimal(18,2),
     SQty   varchar(100),
     JSQty   varchar(100),
     keyNo  int IDENTITY(1,1) NOT NULL,
     i      int not null default(0),
     j      int,
     k      int
   )
   
  create table #tab_main1
   ( mainID varchar(30),
     subID  varchar(30),
     MJID   varchar(30),
     gangNo varchar(30),
     PRTHX   varchar(30),
     colNo  int,
     baoNo  varchar(30),
     M0   varchar(200),
     M1   varchar(200),
     M2   varchar(200),
     M3   varchar(200),
     M4   varchar(200),
     M5   varchar(200),
     M6   varchar(200),
     M7   varchar(200),
     M8   varchar(200),
     M9   varchar(200),
     M10   varchar(200),
     M11   varchar(200),
     M12   varchar(200),
     M13   varchar(200),
     M14   varchar(200),
     M15   varchar(200),
     M16   varchar(200),
     M17   varchar(200),
     M18   varchar(200),
     M19   varchar(200),
     M20   varchar(200),
     M21   varchar(200),
     M22   varchar(200),    
     M23   varchar(200),
     M24   varchar(200),
     M25   varchar(200),
     MRoll   varchar(100),
     MQty    varchar(100),
     Z_bao   int,
     Z_Roll  int,
     Z_Qty   decimal(18,2),
     OrderNo varchar(100),
     QtyUnit varchar(100),
     keyNo  int IDENTITY(1,1) NOT NULL,
     i      int not null default(0),
     j      int,
     k      int     
   )
     
   INSERT into #tab_main(mainID,subID,MJID,gangNO,PRTHX,colNo,baoNO,Qty,SQty,JQty,JSQty,i,j,k)
   SELECT A.mainID,A.subID,MJID,gangNO=A.MJstr4,isnull(B.PRTHX,''),colNo=cast(replace(isnull(B.sorddefstr1,''),'#','') as int),
          ISNULL(baoNO,''),Qty=MJlen,SQty=CAST (CAST(MJlen as float) as varchar),
          JQty=MJQty4,JSQty=CAST (CAST(MJQty4 as float) as varchar),i=0,j=0,k=0
   FROM WFB_MJJY A
   INNER JOIN JYOrder_Sub B on B.MainId=A.MainID and B.SubId=A.subID
   --where A.MainId='JM150812001                  ' 
   WHERE EXISTS(select SubId from TBSubID X where X.SubId=A.MJID and X.DName=@DName)
 
   update #Tab_main SET j=(ColNO-1)%@CNum,k=(ColNO-1)/@CNum
       
   update #Tab_main SET i=(select count(MJID) from #Tab_main X where X.mainID=#Tab_main.mainID and X.baoNO=#Tab_main.baoNo 
                          and X.gangNo=#Tab_main.gangNO and X.subID=#Tab_main.subID)
                          
  --  PRINT('1')
   UPDATE #Tab_main SET SQty=dbo.F_Get_Order_SubStr(MJID,'MDMJLENLIST'),JSQty=dbo.F_Get_Order_SubStr(MJID,'MDJZLIST') where i>1
   -- PRINT('2')
   
 --  select * from #Tab_main where baoNo=27
   
   
/*   INSERT INTO #tab_main1(MainID,subID,gangNO,baoNo,PRTHX,k,i,m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,
                          m12,m13,m14,m15,m16,m17,m18,m19,m20,m21,m22,m23,m24,m25,
                          MQty,MRoll,Z_bao,Z_Roll,Z_Qty,OrderNo,QtyUnit) */
   select MainID,subID='',gangNO,baoNo,PRTHX,k,i=1,
          max(m0) as m0,max(m1)as m1,max(m2) as m2,max(m3) as m3,max(m4)as m4,max(m5) as m5,
          max(m6)as m6,max(m7) as m7,max(m8)as m8,max(m9) as m9,max(m10)as m10,max(m11) as m11,
          max(m12)as m12,max(m13) as m13,max(m14)as m14,max(m15) as m15,max(m16)as m16,max(m17) as m17,
          max(m18)as m18,max(m19) as m19,max(m20)as m20,max(m21) as m21,max(m22)as m22,max(m23) as m23,
          max(m24) as m24,max(m25) as m25,
          
          max(JZ0) as JZ0,max(JZ1) as JZ1,max(JZ2) as JZ2,max(JZ3) as JZ3,max(JZ4) as JZ4,
          max(JZ5) as JZ5,max(JZ6) as JZ6,max(JZ7) as JZ7,max(JZ8) as JZ8,max(JZ9) as JZ9,
          max(JZ10) as JZ10,max(JZ11) as JZ11,max(JZ12) as JZ12,max(JZ13) as JZ13,
          sum(Qty)as MQty,count(Qty) as MRoll,sum(JQty)as MJZQty,
          Z_bao=(select COUNT(distinct baoNo) from #tab_main where ISNULL(baoNo,0)>0),
          Z_Roll=(select COUNT(MainID) from #tab_main),
          Z_Qty=(select SUM(Qty) from #tab_main),
          Z_JZQty=(select SUM(JQty) from #tab_main),
          OrderNo=(select Top 1 OrderNo from JYOrder_Main X where X.MainId=A.mainID),
          QtyUnit=(select Top 1 MJTypeOther from WFB_MJJY X where X.MainId=A.mainID and baoNo>0),
          @CNum as CNum
  from(
  select MainID,gangNO,baoNo,PRTHX,colNo,Qty,JQty,K,    
         case when J=0 then SQty else cast('' as varchar(100)) end as m0,
         case when J=1 then SQty else cast('' as varchar(100)) end as m1,
         case when J=2 then SQty else cast('' as varchar(100)) end as m2,
         case when J=3 then SQty else cast('' as varchar(100)) end as m3,
         case when J=4 then SQty else cast('' as varchar(100)) end as m4,
         case when J=5 then SQty else cast('' as varchar(100)) end as m5,
         case when J=6 then SQty else cast('' as varchar(100)) end as m6,
         case when J=7 then SQty else cast('' as varchar(100)) end as m7,
         case when J=8 then SQty else cast('' as varchar(100)) end as m8,
         case when J=9 then SQty else cast('' as varchar(100)) end as m9,
         case when J=10 then SQty else cast('' as varchar(100)) end as m10,
         case when J=11 then SQty else cast('' as varchar(100)) end as m11,
         case when J=12 then SQty else cast('' as varchar(100)) end as m12,
         case when J=13 then SQty else cast('' as varchar(100)) end as m13,
         case when J=14 then SQty else cast('' as varchar(100)) end as m14,
         case when J=15 then SQty else cast('' as varchar(100)) end as m15,
         case when J=16 then SQty else cast('' as varchar(100)) end as m16,
         case when J=17 then SQty else cast('' as varchar(100)) end as m17,
         case when J=18 then SQty else cast('' as varchar(100)) end as m18,
         case when J=19 then SQty else cast('' as varchar(100)) end as m19,
         case when J=20 then SQty else cast('' as varchar(100)) end as m20,
         case when J=21 then SQty else cast('' as varchar(100)) end as m21,
         case when J=22 then SQty else cast('' as varchar(100)) end as m22,
         case when J=23 then SQty else cast('' as varchar(100)) end as m23,
         case when J=24 then SQty else cast('' as varchar(100)) end as m24,
         case when J=25 then SQty else cast('' as varchar(100)) end as m25,
         
         case when J=0 then JSQty else cast('' as varchar(100)) end as JZ0,
         case when J=1 then JSQty else cast('' as varchar(100)) end as JZ1,
         case when J=2 then JSQty else cast('' as varchar(100)) end as JZ2,
         case when J=3 then JSQty else cast('' as varchar(100)) end as JZ3,
         case when J=4 then JSQty else cast('' as varchar(100)) end as JZ4,
         case when J=5 then JSQty else cast('' as varchar(100)) end as JZ5,
         case when J=6 then JSQty else cast('' as varchar(100)) end as JZ6,
         case when J=7 then JSQty else cast('' as varchar(100)) end as JZ7,
         case when J=8 then JSQty else cast('' as varchar(100)) end as JZ8,
         case when J=9 then JSQty else cast('' as varchar(100)) end as JZ9,
         case when J=10 then JSQty else cast('' as varchar(100)) end as JZ10,
         case when J=11 then JSQty else cast('' as varchar(100)) end as JZ11,
         case when J=12 then JSQty else cast('' as varchar(100)) end as JZ12,
         case when J=13 then JSQty else cast('' as varchar(100)) end as JZ13,
         case when J=14 then JSQty else cast('' as varchar(100)) end as JZ14,
         case when J=15 then JSQty else cast('' as varchar(100)) end as JZ15,
         case when J=16 then JSQty else cast('' as varchar(100)) end as JZ16,
         case when J=17 then JSQty else cast('' as varchar(100)) end as JZ17,
         case when J=18 then JSQty else cast('' as varchar(100)) end as JZ18,
         case when J=19 then JSQty else cast('' as varchar(100)) end as JZ19,
         case when J=20 then JSQty else cast('' as varchar(100)) end as JZ20,
         case when J=21 then JSQty else cast('' as varchar(100)) end as JZ21,
         case when J=22 then JSQty else cast('' as varchar(100)) end as JZ22,
         case when J=23 then JSQty else cast('' as varchar(100)) end as JZ23,
         case when J=24 then JSQty else cast('' as varchar(100)) end as JZ24,
         case when J=25 then JSQty else cast('' as varchar(100)) end as JZ25
    from #tab_main
    ) A
    group by MainID,gangNO,baoNo,PRTHX,k
    ORDER BY MainID,cast(ISNULL(baoNO,0) as Int),gangNo,PRTHX,K
 --   ORDER BY MainID,cast(ISNULL(baoNO,0) as Int),gangNo,PRTHX,
    
 
 /*  select @max=MAX(colNo) from #tab_main
   select @int=(@max-1)/12
   
   SET @i=0
   while @i<=@int 
   begin
     INSERT INTO #tab_main1(MainID,subID,gangNO,baoNo,PRTHX,k,i,m0,m1,m2,m3,m4,m5,m6,m7,m8,m9,m10,m11,
                          MQty,MRoll,Z_bao,Z_Roll,Z_Qty,OrderNo,QtyUnit)
     SELECT Top 1 MainID,subID,gangNo='LOT NO',baoNo='CTN NO',PRTHX='DSN NO',k=@i,i=0,
                 m0='C-'+cast((@i*12+1) as varchar),
                 m1='C-'+cast((@i*12+2) as varchar),
                 m2='C-'+cast((@i*12+3) as varchar),
                 m3='C-'+cast((@i*12+4) as varchar),
                 m4='C-'+cast((@i*12+5) as varchar),
                 m5='C-'+cast((@i*12+6) as varchar),
                 m6='C-'+cast((@i*12+7) as varchar),
                 m7='C-'+cast((@i*12+8) as varchar),
                 m8='C-'+cast((@i*12+9) as varchar),
                 m9='C-'+cast((@i*12+10) as varchar),
                 m10='C-'+cast((@i*12+11) as varchar),
                 m11='C-'+cast((@i*12+12) as varchar),
                 MQty='TTL '+QtyUnit,MRoll='TTL PCS',Z_bao,Z_Roll,Z_Qty,OrderNo,QtyUnit
     FROM #tab_main1
     SET @i=@i+1
   end
*/
 --  select *,@CNum as CNum from #tab_main1 order by keyNo,k,i--order by k,i--,cast(ISNULL(baoNO,0) as Int)
end
GO
/****** Object:  StoredProcedure [dbo].[P_Do_Yshx_Zd]    Script Date: 12/17/2021 15:51:29 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE  PROCEDURE [dbo].[P_Do_Yshx_Zd]
  @skAutoId  VARCHAR(20),
  @factoryName  VARCHAR(20),
  @hxMoney   DECIMAL(18, 3),        
  @userId    VARCHAR(20),
  @PZNo      VARCHAR(20)    --凭证号
AS
BEGIN
  declare @ykYe decimal(18,2)
  declare @skYe decimal(18,2)
  
  declare @bhNO varchar(20)
  declare @i int
  declare @Maxi int
  declare @intReturn int
  set @intReturn=0
  
  create table #tab_BH
  (BHNO varchar(20)
   )
  
  select *,NhxNum=Money-hxNum,curHxNum=cast(0.00 as decimal(18,2)),cast('' as varchar(20)) as bhNO,IDENTITY(int,1,1) as keyNO 
  into #tab1
  from YF_Money_CR A
  where factoryName=@factoryName
  and  CRType='应收款登记'
  and  A.Money-A.hxNum <>0 
  order by CRTime,YFID 
  
  select @skYe=Money-hxNum from YF_Money_CR where YFID=@skAutoId
  
  
  select @Maxi=MAX(keyNO) from  #tab1
  
  set @i=1
  while @i<=@Maxi and @skYe<>0
  begin
    delete from #tab_BH
    insert  #tab_BH exec Get_SY_MaxBH 'HX','YF_log',4,1
    
    select @ykYe=NhxNum from #tab1 where keyNO=@i
    IF @skYe>=@ykYe
    begin
      update #tab1 SET curHxNum= @ykYe,bhNo=(select top 1 BHNO from #tab_BH) where keyNo=@i
      SET @skYe=@skYe - @ykYe
    end
    else
    begin
      update #tab1 SET curHxNum= @skYe,bhNo=(select top 1 BHNO from #tab_BH) where keyNo=@i
      SET @skYe=@skYe - @skYe
    end   
    SET @i=@i+1
  end
  
  delete from #tab1 where curHxNum=0

BEGIN TRAN

    UPDATE YF_Money_CR SET HxNum = ISNULL(A.HxNum, 0) + isnull(B.curHxNum,0)
    FROM YF_Money_CR A
    inner join #tab1 B on B.YFID=A.YFID
    IF @@ERROR <> 0 GOTO QuitRollbackTrans
    
     
    UPDATE YF_Money_CR SET HxNum = ISNULL(HxNum, 0) + ISNULL((select sum(curHxNum) from #tab1 X ),0) 
    WHERE YFID = @skAutoId 
    
    IF @@ERROR <> 0 GOTO QuitRollbackTrans

    UPDATE YF_Money_CR SET HXStatus ='3'
    FROM YF_Money_CR A
    inner join #tab1 B on B.YFID=A.YFID
    where A.hxNUm<>0    
    IF @@ERROR <> 0 GOTO QuitRollbackTrans
	
    UPDATE YF_Money_CR SET HXStatus ='3' WHERE YFID = @skAutoId and HxNum<>0
    IF @@ERROR <> 0 GOTO QuitRollbackTrans
    

    INSERT YF_log (AutoID, ListNo, ToNo, Num, Type, Filler, FillDate) 
    select bhNO,@skAutoId,YFID,curHxNum,'SK', @userId, GETDATE()
    FROM #tab1
    IF @@ERROR <> 0 GOTO QuitRollbackTrans

COMMIT TRAN
 goto Quit

QuitRollbackTrans:
	SET @intReturn=-1
	IF @@TRANCOUNT>0 ROLLBACK TRAN
Quit:
	select  @intReturn as intReturn


END
GO
/****** Object:  Default [DF__BD_Staff__IsYwy__13DCE752]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[BD_Staff] ADD  DEFAULT ((0)) FOR [IsYwy]
GO
/****** Object:  Default [DF__CK_BanCP___KGQty__0D2FE9C3]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_CR] ADD  DEFAULT ((0)) FOR [KGQty]
GO
/****** Object:  Default [DF__CK_BanCP_CR__Qty__0E240DFC]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_CR] ADD  DEFAULT ((0)) FOR [Qty]
GO
/****** Object:  Default [DF__CK_BanCP_C__BCFK__0F183235]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_CR] ADD  DEFAULT ((0)) FOR [BCFK]
GO
/****** Object:  Default [DF__CK_BanCP_C__BCKZ__100C566E]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_CR] ADD  DEFAULT ((0)) FOR [BCKZ]
GO
/****** Object:  Default [DF__CK_BanCP___Fillt__11007AA7]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_CR] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__CK_BanCP___Valid__11F49EE0]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_CR] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__CK_BanCP___NowOu__12E8C319]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_CR] ADD  DEFAULT ((0)) FOR [NowOutFlag]
GO
/****** Object:  Default [DF__CK_BanCP___KCKGQ__058EC7FB]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_KC] ADD  DEFAULT ((0)) FOR [KCKGQty]
GO
/****** Object:  Default [DF__CK_BanCP___KCQty__0682EC34]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_KC] ADD  DEFAULT ((0)) FOR [KCQty]
GO
/****** Object:  Default [DF__CK_BanCP___ZDYFl__0777106D]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote1]
GO
/****** Object:  Default [DF__CK_BanCP___ZDYFl__086B34A6]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote2]
GO
/****** Object:  Default [DF__CK_BanCP___ZDYFl__095F58DF]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote3]
GO
/****** Object:  Default [DF__CK_BanCP___ZDYFl__0A537D18]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote4]
GO
/****** Object:  Default [DF__CK_BanCP___ZDYFl__0B47A151]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote5]
GO
/****** Object:  Default [DF__CK_BanCP___KCVal__0C3BC58A]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_BanCP_KC] ADD  DEFAULT ('Y') FOR [KCValid]
GO
/****** Object:  Default [DF__CK_PBCP_C__KGQty__7EE1CA6C]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR] ADD  DEFAULT ((0)) FOR [KGQty]
GO
/****** Object:  Default [DF__CK_PBCP_CR__Qty__7FD5EEA5]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR] ADD  DEFAULT ((0)) FOR [Qty]
GO
/****** Object:  Default [DF__CK_PBCP_CR__BCFK__00CA12DE]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR] ADD  DEFAULT ((0)) FOR [BCFK]
GO
/****** Object:  Default [DF__CK_PBCP_CR__BCKZ__01BE3717]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR] ADD  DEFAULT ((0)) FOR [BCKZ]
GO
/****** Object:  Default [DF__CK_PBCP_C__Fillt__02B25B50]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__CK_PBCP_C__Valid__03A67F89]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__CK_PBCP_C__NowOu__049AA3C2]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR] ADD  DEFAULT ((0)) FOR [NowOutFlag]
GO
/****** Object:  Default [DF__CK_PBCP_C__KGQty__7834CCDD]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR_Log] ADD  DEFAULT ((0)) FOR [KGQty]
GO
/****** Object:  Default [DF__CK_PBCP_CR___Qty__7928F116]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR_Log] ADD  DEFAULT ((0)) FOR [Qty]
GO
/****** Object:  Default [DF__CK_PBCP_CR__BCFK__7A1D154F]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR_Log] ADD  DEFAULT ((0)) FOR [BCFK]
GO
/****** Object:  Default [DF__CK_PBCP_CR__BCKZ__7B113988]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR_Log] ADD  DEFAULT ((0)) FOR [BCKZ]
GO
/****** Object:  Default [DF__CK_PBCP_C__Fillt__7C055DC1]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR_Log] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__CK_PBCP_C__Valid__7CF981FA]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR_Log] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__CK_PBCP_C__NowOu__7DEDA633]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_CR_Log] ADD  DEFAULT ((0)) FOR [NowOutFlag]
GO
/****** Object:  Default [DF__CK_PBCP_K__KCKGQ__7093AB15]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_KC] ADD  DEFAULT ((0)) FOR [KCKGQty]
GO
/****** Object:  Default [DF__CK_PBCP_K__KCQty__7187CF4E]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_KC] ADD  DEFAULT ((0)) FOR [KCQty]
GO
/****** Object:  Default [DF__CK_PBCP_K__ZDYFl__727BF387]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote1]
GO
/****** Object:  Default [DF__CK_PBCP_K__ZDYFl__737017C0]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote2]
GO
/****** Object:  Default [DF__CK_PBCP_K__ZDYFl__74643BF9]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote3]
GO
/****** Object:  Default [DF__CK_PBCP_K__ZDYFl__75586032]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote4]
GO
/****** Object:  Default [DF__CK_PBCP_K__ZDYFl__764C846B]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote5]
GO
/****** Object:  Default [DF__CK_PBCP_K__KCVal__7740A8A4]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_PBCP_KC] ADD  DEFAULT ('Y') FOR [KCValid]
GO
/****** Object:  Default [DF__CK_SX_CR__Fillti__6EAB62A3]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_SX_CR] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__CK_SX_CR__Valid__6F9F86DC]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_SX_CR] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__CK_SX_KC__Fillti__6CC31A31]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_SX_KC] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__CK_SX_KC__Valid__6DB73E6A]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_SX_KC] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__CK_SXPB_C__Fillt__6ADAD1BF]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_SXPB_CR] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__CK_SXPB_C__Valid__6BCEF5F8]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_SXPB_CR] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__CK_SXPB_K__Fillt__68F2894D]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_SXPB_KC] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__CK_SXPB_K__Valid__69E6AD86]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[CK_SXPB_KC] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__Cloth_JiT__Fillt__67FE6514]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_JiTai] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__Cloth_JiT__Fillt__670A40DB]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_JiTaiZShu] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__Cloth_Mai__Fillt__62458BBE]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Main] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__Cloth_Mai__Valid__6339AFF7]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Main] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__Cloth_Mai__BegFl__642DD430]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Main] ADD  DEFAULT ((0)) FOR [BegFlag]
GO
/****** Object:  Default [DF__Cloth_Mai__EndFl__6521F869]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Main] ADD  DEFAULT ((0)) FOR [EndFlag]
GO
/****** Object:  Default [DF__Cloth_Mai__WCFla__66161CA2]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Main] ADD  DEFAULT ((0)) FOR [WCFlag]
GO
/****** Object:  Default [DF__Cloth_PCS__FillT__61516785]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_PCS_Sub] ADD  DEFAULT (getdate()) FOR [FillTime]
GO
/****** Object:  Default [DF__Cloth_Sub__C_Qty__5AA469F6]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Sub] ADD  DEFAULT ((0)) FOR [C_Qty]
GO
/****** Object:  Default [DF__Cloth_Sub__Price__5B988E2F]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Sub] ADD  DEFAULT ((0)) FOR [Price]
GO
/****** Object:  Default [DF__Cloth_Sub__Qty1__5C8CB268]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Sub] ADD  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__Cloth_Sub__Qty2__5D80D6A1]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Sub] ADD  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__Cloth_Sub__Qty3__5E74FADA]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Sub] ADD  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__Cloth_Sub__C_Val__5F691F13]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Sub] ADD  DEFAULT ('Y') FOR [C_Valid]
GO
/****** Object:  Default [DF__Cloth_Sub__MQty__605D434C]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Cloth_Sub] ADD  DEFAULT ((0)) FOR [MQty]
GO
/****** Object:  Default [DF__Contract_C__HXPS__56D3D912]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_BefChkHX] ADD  DEFAULT ((0)) FOR [HXPS]
GO
/****** Object:  Default [DF__Contract___HXQty__57C7FD4B]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_BefChkHX] ADD  DEFAULT ((0)) FOR [HXQty]
GO
/****** Object:  Default [DF__Contract___HXMQt__58BC2184]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_BefChkHX] ADD  DEFAULT ((0)) FOR [HXMQty]
GO
/****** Object:  Default [DF__Contract_C__ZSXS__59B045BD]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_BefChkHX] ADD  DEFAULT ((1)) FOR [ZSXS]
GO
/****** Object:  Default [DF__Contract___DHQty__4A6E022D]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [DHQty]
GO
/****** Object:  Default [DF__Contract___TPQty__4B622666]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [TPQtyHZ]
GO
/****** Object:  Default [DF__Contract_C__Qty1__4C564A9F]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__Contract_C__Qty2__4D4A6ED8]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__Contract_C__Qty3__4E3E9311]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__Contract___DHVal__4F32B74A]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ('Y') FOR [DHValid]
GO
/****** Object:  Default [DF__Contract_C__DHPS__5026DB83]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [DHPS]
GO
/****** Object:  Default [DF__Contract___TPPSH__511AFFBC]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [TPPSHZ]
GO
/****** Object:  Default [DF__Contract___DHMQt__520F23F5]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [DHMQty]
GO
/****** Object:  Default [DF__Contract___TPMQt__5303482E]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [TPMQtyHZ]
GO
/****** Object:  Default [DF__Contract___SXTPQ__53F76C67]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [SXTPQty]
GO
/****** Object:  Default [DF__Contract_C__PBMF__54EB90A0]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [PBMF]
GO
/****** Object:  Default [DF__Contract_C__PBKZ__55DFB4D9]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_DH] ADD  DEFAULT ((0)) FOR [PBKZ]
GO
/****** Object:  Default [DF__Contract_C__TPPS__3E082B48]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [TPPS]
GO
/****** Object:  Default [DF__Contract___BCPQt__3EFC4F81]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [BCPQty]
GO
/****** Object:  Default [DF__Contract___TPQty__3FF073BA]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [TPQty]
GO
/****** Object:  Default [DF__Contract___HCQty__40E497F3]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [HCQty]
GO
/****** Object:  Default [DF__Contract_C__HCPS__41D8BC2C]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [HCPS]
GO
/****** Object:  Default [DF__Contract___LLIdx__42CCE065]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [LLIdx]
GO
/****** Object:  Default [DF__Contract___TPMQt__43C1049E]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [TPMQty]
GO
/****** Object:  Default [DF__Contract___BCPMQ__44B528D7]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [BCPMQty]
GO
/****** Object:  Default [DF__Contract___HCMQt__45A94D10]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [HCMQty]
GO
/****** Object:  Default [DF__Contract_C__HXPS__469D7149]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [HXPS]
GO
/****** Object:  Default [DF__Contract___HXQty__47919582]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [HXQty]
GO
/****** Object:  Default [DF__Contract___HXMQt__4885B9BB]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [HXMQty]
GO
/****** Object:  Default [DF__Contract___JXJGF__4979DDF4]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LL] ADD  DEFAULT ((0)) FOR [JXJGFlag]
GO
/****** Object:  Default [DF__Contract___TPQty__2FBA0BF1]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [TPQty]
GO
/****** Object:  Default [DF__Contract___ToVal__30AE302A]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ('Y') FOR [ToValid]
GO
/****** Object:  Default [DF__Contract_C__Qty1__31A25463]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__Contract_C__Qty2__3296789C]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__Contract_C__Qty3__338A9CD5]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__Contract_C__TPPS__347EC10E]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [TPPS]
GO
/****** Object:  Default [DF__Contract___HCQty__3572E547]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [HCQty]
GO
/****** Object:  Default [DF__Contract_C__HCPS__36670980]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [HCPS]
GO
/****** Object:  Default [DF__Contract___TPMQt__375B2DB9]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [TPMQty]
GO
/****** Object:  Default [DF__Contract___MQty2__384F51F2]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [MQty2]
GO
/****** Object:  Default [DF__Contract___TPYZQ__3943762B]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [TPYZQty]
GO
/****** Object:  Default [DF__Contract___YZQty__3A379A64]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [YZQty2]
GO
/****** Object:  Default [DF__Contract___JGPri__3B2BBE9D]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [JGPrice]
GO
/****** Object:  Default [DF__Contract___GangF__3C1FE2D6]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [GangFee]
GO
/****** Object:  Default [DF__Contract___HCFla__3D14070F]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Cloth_LLMx] ADD  DEFAULT ((0)) FOR [HCFlag]
GO
/****** Object:  Default [DF__Contract___Fillt__2CDD9F46]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Main] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__Contract___Valid__2DD1C37F]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Main] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__Contract___FileF__2EC5E7B8]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Main] ADD  DEFAULT ((0)) FOR [FileFlag]
GO
/****** Object:  Default [DF__Contract_S__MQty__2354350C]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub] ADD  DEFAULT ((0)) FOR [MQty]
GO
/****** Object:  Default [DF__Contract___C_Qty__24485945]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub] ADD  DEFAULT ((0)) FOR [C_Qty]
GO
/****** Object:  Default [DF__Contract_Sub__PS__253C7D7E]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub] ADD  DEFAULT ((0)) FOR [PS]
GO
/****** Object:  Default [DF__Contract___Price__2630A1B7]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub] ADD  DEFAULT ((0)) FOR [Price]
GO
/****** Object:  Default [DF__Contract_S__Qty1__2724C5F0]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub] ADD  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__Contract_S__Qty2__2818EA29]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub] ADD  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__Contract_S__Qty3__290D0E62]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub] ADD  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__Contract___C_Val__2A01329B]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub] ADD  DEFAULT ('Y') FOR [C_Valid]
GO
/****** Object:  Default [DF__Contract___ConPr__2AF556D4]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub] ADD  DEFAULT ((0)) FOR [ConPrice]
GO
/****** Object:  Default [DF__Contract___ConQt__2BE97B0D]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub] ADD  DEFAULT ((0)) FOR [ConQty]
GO
/****** Object:  Default [DF__Contract___MxQty__1CA7377D]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mx] ADD  DEFAULT ((0)) FOR [MxQty]
GO
/****** Object:  Default [DF__Contract_S__Qty1__1D9B5BB6]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mx] ADD  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__Contract_S__Qty2__1E8F7FEF]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mx] ADD  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__Contract_S__Qty3__1F83A428]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mx] ADD  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__Contract___MxVal__2077C861]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mx] ADD  DEFAULT ('Y') FOR [MxValid]
GO
/****** Object:  Default [DF__Contract_S__KCID__216BEC9A]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mx] ADD  DEFAULT ((0)) FOR [KCID]
GO
/****** Object:  Default [DF__Contract___MXMQt__226010D3]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mx] ADD  DEFAULT ((0)) FOR [MXMQty]
GO
/****** Object:  Default [DF__Contract___TPQty__6383C8BA]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mxto] ADD  CONSTRAINT [DF__Contract___TPQty__6383C8BA]  DEFAULT ((0)) FOR [TPQty]
GO
/****** Object:  Default [DF__Contract___ToVal__4F7CD00D]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mxto] ADD  CONSTRAINT [DF__Contract___ToVal__4F7CD00D]  DEFAULT ('Y') FOR [ToValid]
GO
/****** Object:  Default [DF__Contract_S__Qty1__19CACAD2]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mxto] ADD  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__Contract_S__Qty2__1ABEEF0B]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mxto] ADD  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__Contract_S__Qty3__1BB31344]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[Contract_Sub_Mxto] ADD  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__ContractH__Fillt__15FA39EE]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[ContractHZ_Main] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__ContractH__Valid__16EE5E27]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[ContractHZ_Main] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__ContractH__C_Qty__0F4D3C5F]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[ContractHZ_Sub] ADD  DEFAULT ((0)) FOR [C_Qty]
GO
/****** Object:  Default [DF__ContractH__Price__10416098]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[ContractHZ_Sub] ADD  DEFAULT ((0)) FOR [Price]
GO
/****** Object:  Default [DF__ContractHZ__Qty1__113584D1]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[ContractHZ_Sub] ADD  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__ContractHZ__Qty2__1229A90A]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[ContractHZ_Sub] ADD  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__ContractHZ__Qty3__131DCD43]    Script Date: 12/17/2021 15:51:43 ******/
ALTER TABLE [dbo].[ContractHZ_Sub] ADD  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__ContractH__C_Val__1411F17C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractHZ_Sub] ADD  DEFAULT ('Y') FOR [C_Valid]
GO
/****** Object:  Default [DF__ContractHZ__MQty__150615B5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractHZ_Sub] ADD  DEFAULT ((0)) FOR [MQty]
GO
/****** Object:  Default [DF__ContractS__DHQty__05C3D225]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_DH] ADD  DEFAULT ((0)) FOR [DHQty]
GO
/****** Object:  Default [DF__ContractS__TPQty__06B7F65E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_DH] ADD  DEFAULT ((0)) FOR [TPQtyHZ]
GO
/****** Object:  Default [DF__ContractSX__Qty1__07AC1A97]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_DH] ADD  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__ContractSX__Qty2__08A03ED0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_DH] ADD  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__ContractSX__Qty3__09946309]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_DH] ADD  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__ContractS__DHVal__0A888742]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_DH] ADD  DEFAULT ('Y') FOR [DHValid]
GO
/****** Object:  Default [DF__ContractSX__DHPS__0B7CAB7B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_DH] ADD  DEFAULT ((0)) FOR [DHPS]
GO
/****** Object:  Default [DF__ContractS__TPPSH__0C70CFB4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_DH] ADD  DEFAULT ((0)) FOR [TPPSHZ]
GO
/****** Object:  Default [DF__ContractS__DHMQt__0D64F3ED]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_DH] ADD  DEFAULT ((0)) FOR [DHMQty]
GO
/****** Object:  Default [DF__ContractS__TPMQt__0E591826]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_DH] ADD  DEFAULT ((0)) FOR [TPMQtyHZ]
GO
/****** Object:  Default [DF__ContractSX__TPPS__795DFB40]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [TPPS]
GO
/****** Object:  Default [DF__ContractS__BCPQt__7A521F79]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [BCPQty]
GO
/****** Object:  Default [DF__ContractS__TPQty__7B4643B2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [TPQty]
GO
/****** Object:  Default [DF__ContractS__HCQty__7C3A67EB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [HCQty]
GO
/****** Object:  Default [DF__ContractSX__HCPS__7D2E8C24]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [HCPS]
GO
/****** Object:  Default [DF__ContractS__LLIdx__7E22B05D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [LLIdx]
GO
/****** Object:  Default [DF__ContractS__TPMQt__7F16D496]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [TPMQty]
GO
/****** Object:  Default [DF__ContractS__BCPMQ__000AF8CF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [BCPMQty]
GO
/****** Object:  Default [DF__ContractS__HCMQt__00FF1D08]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [HCMQty]
GO
/****** Object:  Default [DF__ContractSX__HXPS__01F34141]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [HXPS]
GO
/****** Object:  Default [DF__ContractS__HXQty__02E7657A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [HXQty]
GO
/****** Object:  Default [DF__ContractS__HXMQt__03DB89B3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [HXMQty]
GO
/****** Object:  Default [DF__ContractS__JXJGF__04CFADEC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LL] ADD  DEFAULT ((0)) FOR [JXJGFlag]
GO
/****** Object:  Default [DF__ContractS__TPQty__60C757A0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__TPQty__60C757A0]  DEFAULT ((0)) FOR [TPQty]
GO
/****** Object:  Default [DF__ContractS__SXQty__61BB7BD9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__SXQty__61BB7BD9]  DEFAULT ((0)) FOR [SXQty]
GO
/****** Object:  Default [DF__ContractS__SXMQt__62AFA012]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__SXMQt__62AFA012]  DEFAULT ((0)) FOR [SXMQty]
GO
/****** Object:  Default [DF__ContractSX__SXPS__63A3C44B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractSX__SXPS__63A3C44B]  DEFAULT ((0)) FOR [SXPS]
GO
/****** Object:  Default [DF__ContractSX__ZSXS__6497E884]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractSX__ZSXS__6497E884]  DEFAULT ((0)) FOR [ZSXS]
GO
/****** Object:  Default [DF__ContractSX__PBMF__658C0CBD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractSX__PBMF__658C0CBD]  DEFAULT ((0)) FOR [PBMF]
GO
/****** Object:  Default [DF__ContractSX__PBKZ__668030F6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractSX__PBKZ__668030F6]  DEFAULT ((0)) FOR [PBKZ]
GO
/****** Object:  Default [DF__ContractS__ToVal__6774552F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__ToVal__6774552F]  DEFAULT ('Y') FOR [ToValid]
GO
/****** Object:  Default [DF__ContractSX__Qty1__68687968]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractSX__Qty1__68687968]  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__ContractSX__Qty2__695C9DA1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractSX__Qty2__695C9DA1]  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__ContractSX__Qty3__6A50C1DA]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractSX__Qty3__6A50C1DA]  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__ContractSX__TPPS__6B44E613]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractSX__TPPS__6B44E613]  DEFAULT ((0)) FOR [TPPS]
GO
/****** Object:  Default [DF__ContractS__HCQty__6C390A4C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__HCQty__6C390A4C]  DEFAULT ((0)) FOR [HCQty]
GO
/****** Object:  Default [DF__ContractSX__HCPS__6D2D2E85]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractSX__HCPS__6D2D2E85]  DEFAULT ((0)) FOR [HCPS]
GO
/****** Object:  Default [DF__ContractS__TPMQt__6E2152BE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__TPMQt__6E2152BE]  DEFAULT ((0)) FOR [TPMQty]
GO
/****** Object:  Default [DF__ContractS__MQty2__6F1576F7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__MQty2__6F1576F7]  DEFAULT ((0)) FOR [MQty2]
GO
/****** Object:  Default [DF__ContractS__TPYZQ__70099B30]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__TPYZQ__70099B30]  DEFAULT ((0)) FOR [TPYZQty]
GO
/****** Object:  Default [DF__ContractS__YZQty__70FDBF69]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__YZQty__70FDBF69]  DEFAULT ((0)) FOR [YZQty2]
GO
/****** Object:  Default [DF__ContractS__JGPri__71F1E3A2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__JGPri__71F1E3A2]  DEFAULT ((0)) FOR [JGPrice]
GO
/****** Object:  Default [DF__ContractS__GangF__72E607DB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__GangF__72E607DB]  DEFAULT ((0)) FOR [GangFee]
GO
/****** Object:  Default [DF__ContractS__HCFla__73DA2C14]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Cloth_LLMx] ADD  CONSTRAINT [DF__ContractS__HCFla__73DA2C14]  DEFAULT ((0)) FOR [HCFlag]
GO
/****** Object:  Default [DF__ContractS__Fillt__636EBA21]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Main] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__ContractS__Valid__6462DE5A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Main] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__ContractS__C_Qty__5CC1BC92]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub] ADD  DEFAULT ((0)) FOR [C_Qty]
GO
/****** Object:  Default [DF__ContractS__Price__5DB5E0CB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub] ADD  DEFAULT ((0)) FOR [Price]
GO
/****** Object:  Default [DF__ContractSX__Qty1__5EAA0504]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub] ADD  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__ContractSX__Qty2__5F9E293D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub] ADD  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__ContractSX__Qty3__60924D76]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub] ADD  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__ContractS__C_Val__618671AF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub] ADD  DEFAULT ('Y') FOR [C_Valid]
GO
/****** Object:  Default [DF__ContractSX__MQty__627A95E8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub] ADD  DEFAULT ((0)) FOR [MQty]
GO
/****** Object:  Default [DF__ContractS__MxQty__119F9925]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub_Mx] ADD  CONSTRAINT [DF__ContractS__MxQty__119F9925]  DEFAULT ((0)) FOR [MxQty]
GO
/****** Object:  Default [DF__ContractSX__Qty1__1293BD5E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub_Mx] ADD  CONSTRAINT [DF__ContractSX__Qty1__1293BD5E]  DEFAULT ((0)) FOR [Qty1]
GO
/****** Object:  Default [DF__ContractSX__Qty2__1387E197]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub_Mx] ADD  CONSTRAINT [DF__ContractSX__Qty2__1387E197]  DEFAULT ((0)) FOR [Qty2]
GO
/****** Object:  Default [DF__ContractSX__Qty3__147C05D0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub_Mx] ADD  CONSTRAINT [DF__ContractSX__Qty3__147C05D0]  DEFAULT ((0)) FOR [Qty3]
GO
/****** Object:  Default [DF__ContractS__MxVal__15702A09]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub_Mx] ADD  CONSTRAINT [DF__ContractS__MxVal__15702A09]  DEFAULT ('Y') FOR [MxValid]
GO
/****** Object:  Default [DF__ContractSX__KCID__16644E42]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub_Mx] ADD  CONSTRAINT [DF__ContractSX__KCID__16644E42]  DEFAULT ((0)) FOR [KCID]
GO
/****** Object:  Default [DF__ContractS__MXMQt__1758727B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub_Mx] ADD  CONSTRAINT [DF__ContractS__MXMQt__1758727B]  DEFAULT ((0)) FOR [MXMQty]
GO
/****** Object:  Default [DF__ContractS__MXPri__5614BF03]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[ContractSX_Sub_Mx] ADD  CONSTRAINT [DF__ContractS__MXPri__5614BF03]  DEFAULT ((0)) FOR [MXPrice]
GO
/****** Object:  Default [DF__CP_InOut__P_MF__47C69FAC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [P_MF]
GO
/****** Object:  Default [DF__CP_InOut__P_KZ__48BAC3E5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [P_KZ]
GO
/****** Object:  Default [DF__CP_InOut__RollNu__49AEE81E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [RollNum]
GO
/****** Object:  Default [DF__CP_InOut__Qty__4AA30C57]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [Qty]
GO
/****** Object:  Default [DF__CP_InOut__Fillti__4B973090]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__CP_InOut__Valid__4C8B54C9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__CP_InOut__Price__4D7F7902]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [Price]
GO
/****** Object:  Default [DF__CP_InOut__Money__4E739D3B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [Money]
GO
/****** Object:  Default [DF__CP_InOut__PackFe__4F67C174]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [PackFee]
GO
/****** Object:  Default [DF__CP_InOut__YbFee__505BE5AD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [YbFee]
GO
/****** Object:  Default [DF__CP_InOut__OtherF__515009E6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [OtherFee]
GO
/****** Object:  Default [DF__CP_InOut__XjNum__52442E1F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [XjNum]
GO
/****** Object:  Default [DF__CP_InOut__status__53385258]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ('0') FOR [status]
GO
/****** Object:  Default [DF__CP_InOut__IsTax__542C7691]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut] ADD  DEFAULT ((0)) FOR [IsTax]
GO
/****** Object:  Default [DF__CP_InOut___RollN__45DE573A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut_MX] ADD  DEFAULT ((0)) FOR [RollNum]
GO
/****** Object:  Default [DF__CP_InOut_MX__Qty__46D27B73]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_InOut_MX] ADD  DEFAULT ((0)) FOR [Qty]
GO
/****** Object:  Default [DF__CP_Type__Valid__43F60EC8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_Type] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__CP_Type__CPOrder__44EA3301]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_Type] ADD  DEFAULT ((99)) FOR [CPOrder]
GO
/****** Object:  Default [DF__CP_YDang__CYPric__7E6CC920]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  CONSTRAINT [DF__CP_YDang__CYPric__7E6CC920]  DEFAULT ((0)) FOR [CYPrice]
GO
/****** Object:  Default [DF__CP_YDang__CYVali__7F60ED59]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  CONSTRAINT [DF__CP_YDang__CYVali__7F60ED59]  DEFAULT ('Y') FOR [CYValid]
GO
/****** Object:  Default [DF__CP_YDang__TPFlag__0425A276]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  CONSTRAINT [DF__CP_YDang__TPFlag__0425A276]  DEFAULT ((0)) FOR [TPFlag]
GO
/****** Object:  Default [DF__CP_YDang__CYPric__38845C1C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [CYPriceM]
GO
/****** Object:  Default [DF__CP_YDang__CYPric__39788055]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [CYPriceKg]
GO
/****** Object:  Default [DF__CP_YDang__Price1__3A6CA48E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [Price1]
GO
/****** Object:  Default [DF__CP_YDang__Price2__3B60C8C7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [Price2]
GO
/****** Object:  Default [DF__CP_YDang__Price3__3C54ED00]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [Price3]
GO
/****** Object:  Default [DF__CP_YDang__Price4__3D491139]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [Price4]
GO
/****** Object:  Default [DF__CP_YDang__Price5__3E3D3572]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [Price5]
GO
/****** Object:  Default [DF__CP_YDang__Price6__3F3159AB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [Price6]
GO
/****** Object:  Default [DF__CP_YDang__Price7__40257DE4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [Price7]
GO
/****** Object:  Default [DF__CP_YDang__Price8__4119A21D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [Price8]
GO
/****** Object:  Default [DF__CP_YDang__Price9__420DC656]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [Price9]
GO
/****** Object:  Default [DF__CP_YDang__Price1__4301EA8F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang] ADD  DEFAULT ((0)) FOR [Price10]
GO
/****** Object:  Default [DF__CP_YDang___PRTOr__2F4FF79D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [PRTOrderQty]
GO
/****** Object:  Default [DF__CP_YDang___BJPri__30441BD6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [BJPrice]
GO
/****** Object:  Default [DF__CP_YDang___BJEPr__3138400F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [BJEPrice]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__322C6448]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty1]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__33208881]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty2]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__3414ACBA]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty3]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__3508D0F3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty4]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__35FCF52C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty5]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__36F11965]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty6]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__37E53D9E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty7]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__38D961D7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty8]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__39CD8610]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty9]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__3AC1AA49]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty10]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__3BB5CE82]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty11]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__3CA9F2BB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty12]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__3D9E16F4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty13]
GO
/****** Object:  Default [DF__CP_YDang_B__BJXS__3E923B2D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [BJXS]
GO
/****** Object:  Default [DF__CP_YDang___CBPri__3F865F66]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [CBPrice]
GO
/****** Object:  Default [DF__CP_YDang_B__PBMF__407A839F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [PBMF]
GO
/****** Object:  Default [DF__CP_YDang_B__PBKZ__416EA7D8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [PBKZ]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__4262CC11]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty14]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__4356F04A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty15]
GO
/****** Object:  Default [DF__CP_YDang___HuiLv__444B1483]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [HuiLv]
GO
/****** Object:  Default [DF__CP_YDang___QDLQt__453F38BC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_BJ_Sub] ADD  DEFAULT ('0') FOR [QDLQty]
GO
/****** Object:  Default [DF__CP_YDang___CKPri__2E06CDA9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_KHGet] ADD  DEFAULT ((0)) FOR [CKPrice]
GO
/****** Object:  Default [DF__CP_YDang___CKVal__2EFAF1E2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_KHGet] ADD  DEFAULT ('Y') FOR [CKValid]
GO
/****** Object:  Default [DF__CP_YDang___DefFl__2FEF161B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_KHGet] ADD  DEFAULT ((0)) FOR [DefFlt1]
GO
/****** Object:  Default [DF__CP_YDang___DefFl__30E33A54]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_KHGet] ADD  DEFAULT ((0)) FOR [DefFlt2]
GO
/****** Object:  Default [DF__CP_YDang___DefFl__31D75E8D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_KHGet] ADD  DEFAULT ((0)) FOR [DefFlt3]
GO
/****** Object:  Default [DF__CP_YDang___DefFl__32CB82C6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_KHGet] ADD  DEFAULT ((0)) FOR [DefFlt4]
GO
/****** Object:  Default [DF__CP_YDang___FillT__33BFA6FF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_KHGet] ADD  DEFAULT (getdate()) FOR [FillTime]
GO
/****** Object:  Default [DF__CP_YDang___EditT__34B3CB38]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_KHGet] ADD  DEFAULT (getdate()) FOR [EditTime]
GO
/****** Object:  Default [DF__CP_YDang___PRTSp__679450C0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [PRTSpec]
GO
/****** Object:  Default [DF__CP_YDang___PRTOr__54817C4C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [PRTOrderQty]
GO
/****** Object:  Default [DF__CP_YDang___BJPri__5575A085]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [BJPrice]
GO
/****** Object:  Default [DF__CP_YDang___BJEPr__5669C4BE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [BJEPrice]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__575DE8F7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty1]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__58520D30]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty2]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__59463169]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty3]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__5A3A55A2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty4]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__5B2E79DB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty5]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__5C229E14]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty6]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__5D16C24D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty7]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__5E0AE686]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty8]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__5EFF0ABF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty9]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__5FF32EF8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty10]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__60E75331]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty11]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__61DB776A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty12]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__62CF9BA3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty13]
GO
/****** Object:  Default [DF__CP_YDang_M__BJXS__63C3BFDC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [BJXS]
GO
/****** Object:  Default [DF__CP_YDang___CBPri__64B7E415]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [CBPrice]
GO
/****** Object:  Default [DF__CP_YDang_M__PBMF__65AC084E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [PBMF]
GO
/****** Object:  Default [DF__CP_YDang_M__PBKZ__66A02C87]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [PBKZ]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__688874F9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty14]
GO
/****** Object:  Default [DF__CP_YDang___SOrdQ__697C9932]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [SOrdQty15]
GO
/****** Object:  Default [DF__CP_YDang___HuiLv__6A70BD6B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [HuiLv]
GO
/****** Object:  Default [DF__CP_YDang___QDLQt__6B64E1A4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[CP_YDang_MTBJ_Sub] ADD  DEFAULT ('0') FOR [QDLQty]
GO
/****** Object:  Default [DF__JF_CRKMai__PurTy__0DEF03D2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [PurTypeCode]
GO
/****** Object:  Default [DF__JF_CRKMai__Operb__0EE3280B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [OperbillNum]
GO
/****** Object:  Default [DF__JF_CRKMai__Charg__0FD74C44]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [ChargeFlag]
GO
/****** Object:  Default [DF__JF_CRKMai__BusNu__10CB707D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [BusNum]
GO
/****** Object:  Default [DF__JF_CRKMai__Recei__11BF94B6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [ReceiptNum]
GO
/****** Object:  Default [DF__JF_CRKMai__Consi__12B3B8EF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [Consignbillnum]
GO
/****** Object:  Default [DF__JF_CRKMai__Issue__13A7DD28]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [IssueNum]
GO
/****** Object:  Default [DF__JF_CRKMai__KfChe__149C0161]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [KfChecker]
GO
/****** Object:  Default [DF__JF_CRKMai__ChhsC__1590259A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [ChhsChecker]
GO
/****** Object:  Default [DF__JF_CRKMai__Chalk__168449D3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [ChalkitupMan]
GO
/****** Object:  Default [DF__JF_CRKMai__Maker__17786E0C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [Maker]
GO
/****** Object:  Default [DF__JF_CRKMai__Check__186C9245]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [CheckandacceptMan]
GO
/****** Object:  Default [DF__JF_CRKMai__KeepM__1960B67E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [KeepMan]
GO
/****** Object:  Default [DF__JF_CRKMai__KjYea__1A54DAB7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ((0)) FOR [KjYear]
GO
/****** Object:  Default [DF__JF_CRKMai__Perio__1B48FEF0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ((0)) FOR [Period]
GO
/****** Object:  Default [DF__JF_CRKMai__Remar__1C3D2329]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [Remark]
GO
/****** Object:  Default [DF__JF_CRKMai__Purpl__1D314762]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ((0)) FOR [PurplanId]
GO
/****** Object:  Default [DF__JF_CRKMai__Puror__1E256B9B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ((0)) FOR [PurorderId]
GO
/****** Object:  Default [DF__JF_CRKMai__Banla__1F198FD4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ((0)) FOR [BanlanCeId]
GO
/****** Object:  Default [DF__JF_CRKMai__Invoi__200DB40D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ((0)) FOR [InvoiceId]
GO
/****** Object:  Default [DF__JF_CRKMai__Invoi__2101D846]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT ('') FOR [InvoiceNum]
GO
/****** Object:  Default [DF__JF_CRKMai__fillT__21F5FC7F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CRKMain] ADD  DEFAULT (getdate()) FOR [fillTime]
GO
/****** Object:  Default [DF__JF_CrkSub__InOut__705EA0EB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [InOutSubId]
GO
/****** Object:  Default [DF__JF_CrkSub__InOut__7152C524]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [InOutMainId]
GO
/****** Object:  Default [DF__JF_CrkSub__MNumb__7246E95D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ('') FOR [MNumber]
GO
/****** Object:  Default [DF__JF_CrkSub__Marea__733B0D96]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ('') FOR [Marea]
GO
/****** Object:  Default [DF__JF_CrkSub__QuanI__742F31CF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [QuanIssue]
GO
/****** Object:  Default [DF__JF_CrkSub__fzRkN__75235608]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [fzRkNum]
GO
/****** Object:  Default [DF__JF_CrkSub__fzCkN__76177A41]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [fzCkNum]
GO
/****** Object:  Default [DF__JF_CrkSub__QuanR__770B9E7A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [QuanReceipt]
GO
/****** Object:  Default [DF__JF_CrkSub__FactR__77FFC2B3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [FactReceiptQuan]
GO
/****** Object:  Default [DF__JF_CrkSub__FactI__78F3E6EC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [FactIssueQuan]
GO
/****** Object:  Default [DF__JF_CrkSub__Price__79E80B25]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [Price]
GO
/****** Object:  Default [DF__JF_CrkSub__PlanP__7ADC2F5E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [PlanPrice]
GO
/****** Object:  Default [DF__JF_CrkSub__Batch__7BD05397]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ('') FOR [BatchNum]
GO
/****** Object:  Default [DF__JF_CrkSub__Chhsb__7CC477D0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ('') FOR [Chhsbz]
GO
/****** Object:  Default [DF__JF_CrkSub__Balan__7DB89C09]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [BalanceQuan]
GO
/****** Object:  Default [DF__JF_CrkSub__Proje__7EACC042]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ('') FOR [ProjectCode]
GO
/****** Object:  Default [DF__JF_CrkSub__Costo__7FA0E47B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ('') FOR [CostobjectCode]
GO
/****** Object:  Default [DF__JF_CrkSub__Addup__009508B4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [AddupIssueQuan]
GO
/****** Object:  Default [DF__JF_CrkSub__Balan__01892CED]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [BalanceYear]
GO
/****** Object:  Default [DF__JF_CrkSub__Balan__027D5126]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [BalancePeriod]
GO
/****** Object:  Default [DF__JF_CrkSub__GbjjZ__0371755F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [GbjjZbid]
GO
/****** Object:  Default [DF__JF_CrkSub__Charg__04659998]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ('') FOR [ChargeMaterial]
GO
/****** Object:  Default [DF__JF_CrkSub__AssiR__0559BDD1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [AssiReceiptQuan]
GO
/****** Object:  Default [DF__JF_CrkSub__AssiI__064DE20A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [AssiIssueQuan]
GO
/****** Object:  Default [DF__JF_CrkSub__Perce__07420643]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [PercentConversion]
GO
/****** Object:  Default [DF__JF_CrkSub__Balan__08362A7C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ('0') FOR [BalanceStatus]
GO
/****** Object:  Default [DF__JF_CrkSub__Check__092A4EB5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [CheckFlag]
GO
/****** Object:  Default [DF__JF_CrkSub__Tax__0A1E72EE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((17)) FOR [Tax]
GO
/****** Object:  Default [DF__JF_CrkSub__NetFa__0B129727]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_CrkSub] ADD  DEFAULT ((0)) FOR [NetFactIssueQuan]
GO
/****** Object:  Default [DF__SX_NowQua__WhCod__2C81A546]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__WhCod__2C81A546]  DEFAULT ('') FOR [WhCode]
GO
/****** Object:  Default [DF__SX_NowQua__MNumb__2D75C97F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__MNumb__2D75C97F]  DEFAULT ('') FOR [MNumber]
GO
/****** Object:  Default [DF__SX_NowQua__MArea__2E69EDB8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__MArea__2E69EDB8]  DEFAULT ('') FOR [MArea]
GO
/****** Object:  Default [DF__SX_NowQua__Batch__2F5E11F1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__Batch__2F5E11F1]  DEFAULT ('') FOR [BatchNum]
GO
/****** Object:  Default [DF__SX_NowQua__EndQu__3052362A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__EndQu__3052362A]  DEFAULT ((0)) FOR [EndQuan]
GO
/****** Object:  Default [DF__SX_NowQua__SafeQ__31465A63]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__SafeQ__31465A63]  DEFAULT ((0)) FOR [SafeQuan]
GO
/****** Object:  Default [DF__SX_NowQua__HighQ__323A7E9C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__HighQ__323A7E9C]  DEFAULT ((0)) FOR [HighQuan]
GO
/****** Object:  Default [DF__SX_NowQua__LowQu__332EA2D5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__LowQu__332EA2D5]  DEFAULT ((0)) FOR [LowQuan]
GO
/****** Object:  Default [DF__SX_NowQua__Inven__3422C70E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__Inven__3422C70E]  DEFAULT ('') FOR [InventState]
GO
/****** Object:  Default [DF__SX_NowQua__Price__3516EB47]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__Price__3516EB47]  DEFAULT ((0)) FOR [Price]
GO
/****** Object:  Default [DF__SX_NowQua__kcPri__360B0F80]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_KcNow] ADD  CONSTRAINT [DF__SX_NowQua__kcPri__360B0F80]  DEFAULT ((0)) FOR [kcPrice]
GO
/****** Object:  Default [DF__JF_Materia__Cess__21A0F6C4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_Material] ADD  DEFAULT ((0)) FOR [Cess]
GO
/****** Object:  Default [DF__JF_Materi__StopF__22951AFD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JF_Material] ADD  DEFAULT ((0)) FOR [StopFlag]
GO
/****** Object:  Default [DF__JYCon_Sub__Zhuan__19FFD4FC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYCon_Sub_AnPai] ADD  DEFAULT ((0)) FOR [ZhuanQty]
GO
/****** Object:  Default [DF__JYCon_Sub__JYFla__1AF3F935]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYCon_Sub_AnPai] ADD  DEFAULT ((0)) FOR [JYFlag]
GO
/****** Object:  Default [DF__JYCon_Sub__PRTFl__1BE81D6E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYCon_Sub_AnPai] ADD  DEFAULT ((0)) FOR [PRTFlag]
GO
/****** Object:  Default [DF__JYCon_Sub__PRTFl__1CDC41A7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYCon_Sub_AnPai] ADD  DEFAULT ((0)) FOR [PRTFlagTwo]
GO
/****** Object:  Default [DF__JYCon_Sub__PRTCo__1DD065E0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYCon_Sub_AnPai] ADD  DEFAULT ((0)) FOR [PRTCount]
GO
/****** Object:  Default [DF__JYCon_Sub__Fillt__1EC48A19]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYCon_Sub_AnPai] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__JYCon_Sub__AVali__1FB8AE52]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYCon_Sub_AnPai] ADD  DEFAULT ('Y') FOR [AValid]
GO
/****** Object:  Default [DF__JYCon_Sub__JGPri__20ACD28B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYCon_Sub_AnPai] ADD  DEFAULT ((0)) FOR [JGPrice]
GO
/****** Object:  Default [DF__JYOrder_B__Fillt__17236851]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_BaoGuan_Main] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__JYOrder_B__Valid__18178C8A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_BaoGuan_Main] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__JYOrder_B__OKFla__190BB0C3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_BaoGuan_Main] ADD  DEFAULT ((0)) FOR [OKFlag]
GO
/****** Object:  Default [DF__JYOrder_B__SFill__153B1FDF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_BaoGuan_Sub] ADD  DEFAULT (getdate()) FOR [SFilltime]
GO
/****** Object:  Default [DF__JYOrder_B__SVali__162F4418]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_BaoGuan_Sub] ADD  DEFAULT ('Y') FOR [SValid]
GO
/****** Object:  Default [DF__JYOrder_C__FillT__1446FBA6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_ConORD] ADD  DEFAULT (getdate()) FOR [FillTime]
GO
/****** Object:  Default [DF__JYOrder_M__OrdFl__07E124C1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [OrdFlag1]
GO
/****** Object:  Default [DF__JYOrder_M__OrdFl__08D548FA]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [OrdFlag2]
GO
/****** Object:  Default [DF__JYOrder_M__OrdFl__09C96D33]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [OrdFlag3]
GO
/****** Object:  Default [DF__JYOrder_M__OrdFl__0ABD916C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [OrdFlag4]
GO
/****** Object:  Default [DF__JYOrder_M__OrdFl__0BB1B5A5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [OrdFlag5]
GO
/****** Object:  Default [DF__JYOrder_M__Fillt__0CA5D9DE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__JYOrder_M__Valid__0D99FE17]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__JYOrder_M__YSYBM__0E8E2250]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [YSYBMoneyFZ]
GO
/****** Object:  Default [DF__JYOrder_M__YSYBF__0F824689]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [YSYBFlag]
GO
/****** Object:  Default [DF__JYOrder_M__PiZho__10766AC2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [PiZhong]
GO
/****** Object:  Default [DF__JYOrder_M__EditC__116A8EFB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [EditCnt]
GO
/****** Object:  Default [DF__JYOrder_M__KouFe__125EB334]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [KouFenQty]
GO
/****** Object:  Default [DF__JYOrder_Main__xs__1352D76D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Main] ADD  DEFAULT ((0)) FOR [xs]
GO
/****** Object:  Default [DF__JYOrder_PC__PFSH__7D63964E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT ((0)) FOR [PFSH]
GO
/****** Object:  Default [DF__JYOrder_P__PFSJS__7E57BA87]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT ((0)) FOR [PFSJSH]
GO
/****** Object:  Default [DF__JYOrder_P__PFTPQ__7F4BDEC0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT ((0)) FOR [PFTPQty]
GO
/****** Object:  Default [DF__JYOrder_P__PFTPP__004002F9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT ((0)) FOR [PFTPPS]
GO
/****** Object:  Default [DF__JYOrder_P__PFTPM__01342732]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT ((0)) FOR [PFTPMQty]
GO
/****** Object:  Default [DF__JYOrder_P__WCMQt__02284B6B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT ((0)) FOR [WCMQty]
GO
/****** Object:  Default [DF__JYOrder_P__TJMQt__031C6FA4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT ((0)) FOR [TJMQty]
GO
/****** Object:  Default [DF__JYOrder_P__TJOut__041093DD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT ((0)) FOR [TJOutFlag]
GO
/****** Object:  Default [DF__JYOrder_P__FillT__0504B816]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT (getdate()) FOR [FillTime]
GO
/****** Object:  Default [DF__JYOrder_P__EditT__05F8DC4F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT (getdate()) FOR [EditTime]
GO
/****** Object:  Default [DF__JYOrder_P__DYFla__06ED0088]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_PCS_Sub] ADD  DEFAULT ((0)) FOR [DYFlag]
GO
/****** Object:  Default [DF__JYOrder_Pr__PSSH__10416098]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Process] ADD  CONSTRAINT [DF__JYOrder_Pr__PSSH__10416098]  DEFAULT ((0)) FOR [PSSH]
GO
/****** Object:  Default [DF__JYOrder_P__PSSJS__113584D1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Process] ADD  CONSTRAINT [DF__JYOrder_P__PSSJS__113584D1]  DEFAULT ((0)) FOR [PSSJSH]
GO
/****** Object:  Default [DF__JYOrder_P__MFQty__2A01329B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Process] ADD  CONSTRAINT [DF__JYOrder_P__MFQty__2A01329B]  DEFAULT ((0)) FOR [MFQty]
GO
/****** Object:  Default [DF__JYOrder_P__KZQty__2AF556D4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Process] ADD  CONSTRAINT [DF__JYOrder_P__KZQty__2AF556D4]  DEFAULT ((0)) FOR [KZQty]
GO
/****** Object:  Default [DF__JYOrder_Pr__KgZM__2BE97B0D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Process] ADD  CONSTRAINT [DF__JYOrder_Pr__KgZM__2BE97B0D]  DEFAULT ((0)) FOR [KgZM]
GO
/****** Object:  Default [DF__JYOrder_P__PSSJQ__1F4E99FE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Process] ADD  CONSTRAINT [DF__JYOrder_P__PSSJQ__1F4E99FE]  DEFAULT ((0)) FOR [PSSJQty]
GO
/****** Object:  Default [DF__JYOrder_P__PSSJM__2042BE37]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Process] ADD  CONSTRAINT [DF__JYOrder_P__PSSJM__2042BE37]  DEFAULT ((0)) FOR [PSSJMoney]
GO
/****** Object:  Default [DF__JYOrder_P__PSSJP__2136E270]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Process] ADD  CONSTRAINT [DF__JYOrder_P__PSSJP__2136E270]  DEFAULT ((0)) FOR [PSSJPrice]
GO
/****** Object:  Default [DF__JYOrder_S__PRTOr__0C85DE4D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__PRTOr__0C85DE4D]  DEFAULT ((0)) FOR [PRTOrderQty]
GO
/****** Object:  Default [DF__JYOrder_S__PRTCl__0D7A0286]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__PRTCl__0D7A0286]  DEFAULT ((0)) FOR [PRTClothQty]
GO
/****** Object:  Default [DF__JYOrder_S__PRTPr__0E6E26BF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__PRTPr__0E6E26BF]  DEFAULT ((0)) FOR [PRTPrice]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdQ__0F624AF8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdQ__0F624AF8]  DEFAULT ((0)) FOR [SOrdQty1]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdQ__10566F31]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdQ__10566F31]  DEFAULT ((0)) FOR [SOrdQty2]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdQ__114A936A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdQ__114A936A]  DEFAULT ((0)) FOR [SOrdQty3]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdQ__123EB7A3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdQ__123EB7A3]  DEFAULT ((0)) FOR [SOrdQty4]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdQ__1332DBDC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdQ__1332DBDC]  DEFAULT ((0)) FOR [SOrdQty5]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdQ__14270015]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdQ__14270015]  DEFAULT ((0)) FOR [SOrdQty6]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdQ__151B244E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdQ__151B244E]  DEFAULT ((0)) FOR [SOrdQty7]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdQ__160F4887]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdQ__160F4887]  DEFAULT ((0)) FOR [SOrdQty8]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdQ__17036CC0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdQ__17036CC0]  DEFAULT ((0)) FOR [SOrdQty9]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdQ__17F790F9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdQ__17F790F9]  DEFAULT ((0)) FOR [SOrdQty10]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdF__18EBB532]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdF__18EBB532]  DEFAULT ((0)) FOR [SOrdFlag1]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdF__19DFD96B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdF__19DFD96B]  DEFAULT ((0)) FOR [SOrdFlag2]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdF__1AD3FDA4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdF__1AD3FDA4]  DEFAULT ((0)) FOR [SOrdFlag3]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdF__1BC821DD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdF__1BC821DD]  DEFAULT ((0)) FOR [SOrdFlag4]
GO
/****** Object:  Default [DF__JYOrder_S__SOrdF__1CBC4616]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SOrdF__1CBC4616]  DEFAULT ((0)) FOR [SOrdFlag5]
GO
/****** Object:  Default [DF__JYOrder_S__SubVa__2BFE89A6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  CONSTRAINT [DF__JYOrder_S__SubVa__2BFE89A6]  DEFAULT ('Y') FOR [SubValid]
GO
/****** Object:  Default [DF__JYOrder_S__KgQty__73DA2C14]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  DEFAULT ((0)) FOR [KgQty]
GO
/****** Object:  Default [DF__JYOrder_S__KgPri__74CE504D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub] ADD  DEFAULT ((0)) FOR [KgPrice]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdQ__4707859D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdQty1]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdQ__47FBA9D6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdQty2]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdQ__48EFCE0F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdQty3]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdQ__49E3F248]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdQty4]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdQ__4AD81681]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdQty5]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdQ__4BCC3ABA]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdQty6]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdQ__4CC05EF3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdQty7]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdQ__4DB4832C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdQty8]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdQ__4EA8A765]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdQty9]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdQ__4F9CCB9E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdQty10]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdF__5090EFD7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdFlag1]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdF__51851410]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdFlag2]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdF__52793849]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdFlag3]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdF__536D5C82]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdFlag4]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdF__546180BB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdFlag5]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdF__5555A4F4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdFlag6]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdF__5649C92D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdFlag7]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdF__573DED66]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdFlag8]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdF__5832119F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdFlag9]
GO
/****** Object:  Default [DF__JYOrder_S__AOrdF__592635D8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [AOrdFlag10]
GO
/****** Object:  Default [DF__JYOrder_S__Fillt__5A1A5A11]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__JYOrder_S__AVali__5B0E7E4A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ('Y') FOR [AValid]
GO
/****** Object:  Default [DF__JYOrder_Su__ZSXS__5C02A283]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((1)) FOR [ZSXS]
GO
/****** Object:  Default [DF__JYOrder_S__HCYZQ__5CF6C6BC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [HCYZQty]
GO
/****** Object:  Default [DF__JYOrder_S__HCMQt__5DEAEAF5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [HCMQty]
GO
/****** Object:  Default [DF__JYOrder_Su__JYMF__5EDF0F2E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [JYMF]
GO
/****** Object:  Default [DF__JYOrder_Su__JYKZ__5FD33367]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [JYKZ]
GO
/****** Object:  Default [DF__JYOrder_S__JGPri__60C757A0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrder_Sub_AnPai] ADD  DEFAULT ((0)) FOR [JGPrice]
GO
/****** Object:  Default [DF__JYOrderCo__ConFl__5C6CB6D7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Main] ADD  CONSTRAINT [DF__JYOrderCo__ConFl__5C6CB6D7]  DEFAULT ((0)) FOR [ConFlag1]
GO
/****** Object:  Default [DF__JYOrderCo__ConFl__5D60DB10]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Main] ADD  CONSTRAINT [DF__JYOrderCo__ConFl__5D60DB10]  DEFAULT ((0)) FOR [ConFlag2]
GO
/****** Object:  Default [DF__JYOrderCo__ConFl__5E54FF49]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Main] ADD  CONSTRAINT [DF__JYOrderCo__ConFl__5E54FF49]  DEFAULT ((0)) FOR [ConFlag3]
GO
/****** Object:  Default [DF__JYOrderCo__ConFl__5F492382]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Main] ADD  CONSTRAINT [DF__JYOrderCo__ConFl__5F492382]  DEFAULT ((0)) FOR [ConFlag4]
GO
/****** Object:  Default [DF__JYOrderCo__ConFl__603D47BB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Main] ADD  CONSTRAINT [DF__JYOrderCo__ConFl__603D47BB]  DEFAULT ((0)) FOR [ConFlag5]
GO
/****** Object:  Default [DF__JYOrderCo__Fillt__61316BF4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Main] ADD  CONSTRAINT [DF__JYOrderCo__Fillt__61316BF4]  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__JYOrderCo__Valid__6225902D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Main] ADD  CONSTRAINT [DF__JYOrderCo__Valid__6225902D]  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__JYOrderCo__PRTOr__1E05700A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [PRTOrderQty]
GO
/****** Object:  Default [DF__JYOrderCo__PRTCl__1EF99443]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [PRTClothQty]
GO
/****** Object:  Default [DF__JYOrderCo__PRTPr__1FEDB87C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [PRTPrice]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdQ__20E1DCB5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty1]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdQ__21D600EE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty2]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdQ__22CA2527]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty3]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdQ__23BE4960]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty4]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdQ__24B26D99]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty5]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdQ__25A691D2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty6]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdQ__269AB60B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty7]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdQ__278EDA44]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty8]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdQ__2882FE7D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty9]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdQ__297722B6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty10]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__2A6B46EF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag1]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__2B5F6B28]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag2]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__2C538F61]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag3]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__2D47B39A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag4]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__2E3BD7D3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag5]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__2F2FFC0C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag6]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__30242045]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag7]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__3118447E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag8]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__320C68B7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag9]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__33008CF0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag10]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__33F4B129]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag11]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__34E8D562]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag12]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__35DCF99B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag13]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__36D11DD4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag14]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__37C5420D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag15]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__38B96646]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag16]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__39AD8A7F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag17]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__3AA1AEB8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag18]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__3B95D2F1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag19]
GO
/****** Object:  Default [DF__JYOrderCo__SOrdF__3C89F72A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag20]
GO
/****** Object:  Default [DF__JYOrderCo__SubVa__3D7E1B63]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ('Y') FOR [SubValid]
GO
/****** Object:  Default [DF__JYOrderCo__KGQty__3E723F9C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [KGQty]
GO
/****** Object:  Default [DF__JYOrderCo__KGPri__3F6663D5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCon_Sub] ADD  DEFAULT ((0)) FOR [KGPrice]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__0539C240]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag1]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__062DE679]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag2]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__07220AB2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag3]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__08162EEB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag4]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__090A5324]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag5]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__09FE775D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag6]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__0AF29B96]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag7]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__0BE6BFCF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag8]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__0CDAE408]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag9]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__0DCF0841]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag10]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__0EC32C7A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag11]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__0FB750B3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag12]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__10AB74EC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag13]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__119F9925]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag14]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__1293BD5E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag15]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__1387E197]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag16]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__147C05D0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag17]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__15702A09]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag18]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__16644E42]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag19]
GO
/****** Object:  Default [DF__JYOrderCy__OrdFl__1758727B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag20]
GO
/****** Object:  Default [DF__JYOrderCy__Fillt__184C96B4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__JYOrderCy__Valid__1940BAED]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__JYOrderCy__YSYBM__1A34DF26]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [YSYBMoneyFZ]
GO
/****** Object:  Default [DF__JYOrderCy__YSYBF__1B29035F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [YSYBFlag]
GO
/****** Object:  Default [DF__JYOrderCy__PiZho__1C1D2798]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [PiZhong]
GO
/****** Object:  Default [DF__JYOrderCy__EditC__1D114BD1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Main] ADD  DEFAULT ((0)) FOR [EditCnt]
GO
/****** Object:  Default [DF__JYOrderCy__PRTOr__703EA55A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [PRTOrderQty]
GO
/****** Object:  Default [DF__JYOrderCy__PRTCl__7132C993]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [PRTClothQty]
GO
/****** Object:  Default [DF__JYOrderCy__PRTPr__7226EDCC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [PRTPrice]
GO
/****** Object:  Default [DF__JYOrderCy__PRTMo__731B1205]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [PRTMoney]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdQ__740F363E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty1]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdQ__75035A77]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty2]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdQ__75F77EB0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty3]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdQ__76EBA2E9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty4]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdQ__77DFC722]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty5]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdQ__78D3EB5B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty6]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdQ__79C80F94]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty7]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdQ__7ABC33CD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty8]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdQ__7BB05806]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty9]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdQ__7CA47C3F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty10]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdF__7D98A078]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag1]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdF__7E8CC4B1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag2]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdF__7F80E8EA]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag3]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdF__00750D23]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag4]
GO
/****** Object:  Default [DF__JYOrderCy__SOrdF__0169315C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag5]
GO
/****** Object:  Default [DF__JYOrderCy__SubVa__025D5595]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ('Y') FOR [SubValid]
GO
/****** Object:  Default [DF__JYOrderCy__KgQty__035179CE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [KgQty]
GO
/****** Object:  Default [DF__JYOrderCy__KgPri__04459E07]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderCy_Sub] ADD  DEFAULT ((0)) FOR [KgPrice]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__5772F790]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag1]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__58671BC9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag2]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__595B4002]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag3]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__5A4F643B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag4]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__5B438874]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag5]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__5C37ACAD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag6]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__5D2BD0E6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag7]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__5E1FF51F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag8]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__5F141958]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag9]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__60083D91]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag10]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__60FC61CA]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag11]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__61F08603]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag12]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__62E4AA3C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag13]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__63D8CE75]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag14]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__64CCF2AE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag15]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__65C116E7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag16]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__66B53B20]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag17]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__67A95F59]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag18]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__689D8392]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag19]
GO
/****** Object:  Default [DF__JYOrderFb__OrdFl__6991A7CB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [OrdFlag20]
GO
/****** Object:  Default [DF__JYOrderFb__Fillt__6A85CC04]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__JYOrderFb__Valid__6B79F03D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__JYOrderFb__YSYBM__6C6E1476]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [YSYBMoneyFZ]
GO
/****** Object:  Default [DF__JYOrderFb__YSYBF__6D6238AF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [YSYBFlag]
GO
/****** Object:  Default [DF__JYOrderFb__PiZho__6E565CE8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [PiZhong]
GO
/****** Object:  Default [DF__JYOrderFb__EditC__6F4A8121]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Main] ADD  DEFAULT ((0)) FOR [EditCnt]
GO
/****** Object:  Default [DF__JYOrderFb__PRTOr__4277DAAA]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [PRTOrderQty]
GO
/****** Object:  Default [DF__JYOrderFb__PRTCl__436BFEE3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [PRTClothQty]
GO
/****** Object:  Default [DF__JYOrderFb__PRTPr__4460231C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [PRTPrice]
GO
/****** Object:  Default [DF__JYOrderFb__PRTMo__45544755]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [PRTMoney]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdQ__46486B8E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty1]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdQ__473C8FC7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty2]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdQ__4830B400]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty3]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdQ__4924D839]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty4]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdQ__4A18FC72]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty5]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdQ__4B0D20AB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty6]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdQ__4C0144E4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty7]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdQ__4CF5691D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty8]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdQ__4DE98D56]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty9]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdQ__4EDDB18F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty10]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdF__4FD1D5C8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag1]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdF__50C5FA01]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag2]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdF__51BA1E3A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag3]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdF__52AE4273]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag4]
GO
/****** Object:  Default [DF__JYOrderFb__SOrdF__53A266AC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag5]
GO
/****** Object:  Default [DF__JYOrderFb__SubVa__54968AE5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ('Y') FOR [SubValid]
GO
/****** Object:  Default [DF__JYOrderFb__KgQty__558AAF1E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [KgQty]
GO
/****** Object:  Default [DF__JYOrderFb__KgPri__567ED357]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFb_Sub] ADD  DEFAULT ((0)) FOR [KgPrice]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__2116E6DF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag1]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__220B0B18]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag2]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__22FF2F51]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag3]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__23F3538A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag4]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__24E777C3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag5]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__25DB9BFC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag6]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__26CFC035]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag7]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__27C3E46E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag8]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__28B808A7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag9]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__29AC2CE0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag10]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__2AA05119]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag11]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__2B947552]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag12]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__2C88998B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag13]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__2D7CBDC4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag14]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__2E70E1FD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag15]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__2F650636]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag16]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__30592A6F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag17]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__314D4EA8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag18]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__324172E1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag19]
GO
/****** Object:  Default [DF__JYOrderFy__OrdFl__3335971A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdFlag20]
GO
/****** Object:  Default [DF__JYOrderFy__Fillt__3429BB53]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__JYOrderFy__Valid__351DDF8C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__JYOrderFy__YSYBM__361203C5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [YSYBMoneyFZ]
GO
/****** Object:  Default [DF__JYOrderFy__YSYBF__370627FE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [YSYBFlag]
GO
/****** Object:  Default [DF__JYOrderFy__PiZho__37FA4C37]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [PiZhong]
GO
/****** Object:  Default [DF__JYOrderFy__EditC__38EE7070]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [EditCnt]
GO
/****** Object:  Default [DF__JYOrderFy__OrdQt__39E294A9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ('0') FOR [OrdQty1]
GO
/****** Object:  Default [DF__JYOrderFy__OrdQt__3AD6B8E2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ('0') FOR [OrdQty2]
GO
/****** Object:  Default [DF__JYOrderFy__OrdQt__3BCADD1B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ('0') FOR [OrdQty3]
GO
/****** Object:  Default [DF__JYOrderFy__OrdQt__3CBF0154]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ('0') FOR [OrdQty4]
GO
/****** Object:  Default [DF__JYOrderFy__OrdQt__3DB3258D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ('0') FOR [OrdQty5]
GO
/****** Object:  Default [DF__JYOrderFy__OrdQt__3EA749C6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ('0') FOR [OrdQty6]
GO
/****** Object:  Default [DF__JYOrderFy__OrdQt__3F9B6DFF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdQty7]
GO
/****** Object:  Default [DF__JYOrderFy__OrdQt__408F9238]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdQty8]
GO
/****** Object:  Default [DF__JYOrderFy__OrdQt__4183B671]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Main] ADD  DEFAULT ((0)) FOR [OrdQty9]
GO
/****** Object:  Default [DF__JYOrderFy__PRTOr__7EC1CEDB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [PRTOrderQty]
GO
/****** Object:  Default [DF__JYOrderFy__PRTCl__7FB5F314]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [PRTClothQty]
GO
/****** Object:  Default [DF__JYOrderFy__PRTPr__00AA174D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [PRTPrice]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdQ__019E3B86]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty1]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdQ__02925FBF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty2]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdQ__038683F8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty3]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdQ__047AA831]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty4]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdQ__056ECC6A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty5]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdQ__0662F0A3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty6]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdQ__075714DC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty7]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdQ__084B3915]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty8]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdQ__093F5D4E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty9]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdQ__0A338187]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdQty10]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__0B27A5C0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag1]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__0C1BC9F9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag2]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__0D0FEE32]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag3]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__0E04126B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag4]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__0EF836A4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag5]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__0FEC5ADD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag6]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__10E07F16]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag7]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__11D4A34F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag8]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__12C8C788]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag9]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__13BCEBC1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag10]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__14B10FFA]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag11]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__15A53433]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag12]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__1699586C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag13]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__178D7CA5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag14]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__1881A0DE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag15]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__1975C517]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag16]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__1A69E950]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag17]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__1B5E0D89]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag18]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__1C5231C2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag19]
GO
/****** Object:  Default [DF__JYOrderFy__SOrdF__1D4655FB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [SOrdFlag20]
GO
/****** Object:  Default [DF__JYOrderFy__SubVa__1E3A7A34]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ('Y') FOR [SubValid]
GO
/****** Object:  Default [DF__JYOrderFy__KgQty__1F2E9E6D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [KgQty]
GO
/****** Object:  Default [DF__JYOrderFy__KgPri__2022C2A6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderFy_Sub] ADD  DEFAULT ((0)) FOR [KgPrice]
GO
/****** Object:  Default [DF__JYOrderWT___ifFP__7CD98669]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderWT_Main] ADD  DEFAULT ('F') FOR [ifFP]
GO
/****** Object:  Default [DF__JYOrderWT___ifZY__7DCDAAA2]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[JYOrderWT_Main] ADD  DEFAULT ('F') FOR [ifZY]
GO
/****** Object:  Default [DF__KH_DaYang__Fillt__7AF13DF7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_DaYang] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__KH_DaYang__Valid__7BE56230]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_DaYang] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__KH_ZDY__OrderNo__6B99EBCE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_ZDY] ADD  DEFAULT ((0)) FOR [OrderNo]
GO
/****** Object:  Default [DF__KH_ZDY__Valid__6C8E1007]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_ZDY] ADD  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__KH_ZDY__ZdyFlag__6D823440]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_ZDY] ADD  DEFAULT ((0)) FOR [ZdyFlag]
GO
/****** Object:  Default [DF__KH_Zdy_At__Fillt__2DE6D218]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD  CONSTRAINT [DF__KH_Zdy_At__Fillt__2DE6D218]  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__KH_Zdy_At__Valid__2EDAF651]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD  CONSTRAINT [DF__KH_Zdy_At__Valid__2EDAF651]  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__KH_Zdy_At__Mrate__7720AD13]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD  DEFAULT ((0)) FOR [Mrate]
GO
/****** Object:  Default [DF__KH_Zdy_At__DefFl__7814D14C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD  DEFAULT ((0)) FOR [DefFlt1]
GO
/****** Object:  Default [DF__KH_Zdy_At__DefFl__7908F585]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD  DEFAULT ((0)) FOR [DefFlt2]
GO
/****** Object:  Default [DF__KH_Zdy_At__DefFl__79FD19BE]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_Zdy_Attachment] ADD  DEFAULT ((0)) FOR [DefFlt3]
GO
/****** Object:  Default [DF__KH_Zdy_At__fillt__4A03EDD9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[KH_Zdy_Attachment_Sub] ADD  DEFAULT (getdate()) FOR [filltime]
GO
/****** Object:  Default [DF_P_Label_Valid]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[P_Label] ADD  CONSTRAINT [DF_P_Label_Valid]  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__RT_FileUp__FileS__66D536B1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[RT_FileUpdate] ADD  DEFAULT ((0)) FOR [FileSize]
GO
/****** Object:  Default [DF__RT_FileUp__FillT__67C95AEA]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[RT_FileUpdate] ADD  DEFAULT (getdate()) FOR [FillTime]
GO
/****** Object:  Default [DF__RT_FileUp__FileP__68BD7F23]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[RT_FileUpdate] ADD  DEFAULT ('') FOR [FilePath]
GO
/****** Object:  Default [DF__SY_MaxBH__BHNo__64ECEE3F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[SY_MaxBH] ADD  DEFAULT ((0)) FOR [BHNo]
GO
/****** Object:  Default [DF__SY_MaxBH__Type__65E11278]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[SY_MaxBH] ADD  DEFAULT ((0)) FOR [Type]
GO
/****** Object:  Default [DF__SY_Module__FillT__63F8CA06]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[SY_Module_Note] ADD  DEFAULT (getdate()) FOR [FillTime]
GO
/****** Object:  Default [DF_SY_ModuleMain_Idx__0A3F39D6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[SY_ModuleMain] ADD  CONSTRAINT [DF_SY_ModuleMain_Idx__0A3F39D6]  DEFAULT ((0)) FOR [Idx]
GO
/****** Object:  Default [PK__SY_ModuleSub__FormI__6DB809C1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[SY_ModuleSub] ADD  CONSTRAINT [PK__SY_ModuleSub__FormI__6DB809C1]  DEFAULT ((0)) FOR [FormID]
GO
/****** Object:  Default [DF_XS_Modules_FormType_sdswe]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[SY_ModuleSub] ADD  CONSTRAINT [DF_XS_Modules_FormType_sdswe]  DEFAULT ((0)) FOR [FormType]
GO
/****** Object:  Default [PK__SY_ModuleSub__Idx__0B335E0F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[SY_ModuleSub] ADD  CONSTRAINT [PK__SY_ModuleSub__Idx__0B335E0F]  DEFAULT ((0)) FOR [Idx]
GO
/****** Object:  Default [DF__SY_SET__IsYGCode__5F3414E9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[SY_SET] ADD  DEFAULT ((1)) FOR [IsYGCodezdsc]
GO
/****** Object:  Default [DF__SY_User__IsYwy__26BAB19C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[SY_User] ADD  DEFAULT ((1)) FOR [IsYwy]
GO
/****** Object:  Default [DF__TP_File__FillTim__5E3FF0B0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[TP_File] ADD  DEFAULT (getdate()) FOR [FillTime]
GO
/****** Object:  Default [DF__WFB_MJJY__MJMaoZ__321755AF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  CONSTRAINT [DF__WFB_MJJY__MJMaoZ__321755AF]  DEFAULT ((0)) FOR [MJMaoZ]
GO
/****** Object:  Default [DF__WFB_MJJY__MJLen__330B79E8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  CONSTRAINT [DF__WFB_MJJY__MJLen__330B79E8]  DEFAULT ((0)) FOR [MJLen]
GO
/****** Object:  Default [DF__WFB_MJJY__MJFK__33FF9E21]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  CONSTRAINT [DF__WFB_MJJY__MJFK__33FF9E21]  DEFAULT ((0)) FOR [MJFK]
GO
/****** Object:  Default [DF__WFB_MJJY__MJSJKZ__34F3C25A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  CONSTRAINT [DF__WFB_MJJY__MJSJKZ__34F3C25A]  DEFAULT ((0)) FOR [MJSJKZ]
GO
/****** Object:  Default [DF__WFB_MJJY__Fillti__35E7E693]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  CONSTRAINT [DF__WFB_MJJY__Fillti__35E7E693]  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__WFB_MJJY__Valie__36DC0ACC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  CONSTRAINT [DF__WFB_MJJY__Valie__36DC0ACC]  DEFAULT ('Y') FOR [Valie]
GO
/****** Object:  Default [DF__WFB_MJJY__PrtAgn__6D381B7D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  CONSTRAINT [DF__WFB_MJJY__PrtAgn__6D381B7D]  DEFAULT ((0)) FOR [PrtAgnFlag]
GO
/****** Object:  Default [DF__WFB_MJJY__MJQty1__55AAAAAF]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  DEFAULT ((0)) FOR [MJQty1]
GO
/****** Object:  Default [DF__WFB_MJJY__MJQty2__569ECEE8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  DEFAULT ((0)) FOR [MJQty2]
GO
/****** Object:  Default [DF__WFB_MJJY__MJQty3__5792F321]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  DEFAULT ((0)) FOR [MJQty3]
GO
/****** Object:  Default [DF__WFB_MJJY__MJQty4__5887175A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  DEFAULT ((0)) FOR [MJQty4]
GO
/****** Object:  Default [DF__WFB_MJJY__MJQty5__597B3B93]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  DEFAULT ((0)) FOR [MJQty5]
GO
/****** Object:  Default [DF__WFB_MJJY__MJXH__5A6F5FCC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  DEFAULT ((0)) FOR [MJXH]
GO
/****** Object:  Default [DF__WFB_MJJY__LYFlag__5B638405]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  DEFAULT ((0)) FOR [LYFlag]
GO
/****** Object:  Default [DF__WFB_MJJY__HXFlag__5C57A83E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  DEFAULT ((0)) FOR [HXFlag]
GO
/****** Object:  Default [DF__WFB_MJJY__MKXs__5D4BCC77]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY] ADD  DEFAULT ((0)) FOR [MKXs]
GO
/****** Object:  Default [DF__WFB_MJJY___CDQty__025D5595]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_CD] ADD  CONSTRAINT [DF__WFB_MJJY___CDQty__025D5595]  DEFAULT ((0)) FOR [CDQty]
GO
/****** Object:  Default [DF__WFB_MJJY___KouFe__4E0988E7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_CD] ADD  DEFAULT ((0)) FOR [KouFenQty]
GO
/****** Object:  Default [DF__WFB_MJJY___CDQty__4C214075]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_CD_PB] ADD  DEFAULT ((0)) FOR [CDQty]
GO
/****** Object:  Default [DF__WFB_MJJY___MJMao__3DD3211E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [MJMaoZ]
GO
/****** Object:  Default [DF__WFB_MJJY___MJLen__3EC74557]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [MJLen]
GO
/****** Object:  Default [DF__WFB_MJJY_P__MJFK__3FBB6990]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [MJFK]
GO
/****** Object:  Default [DF__WFB_MJJY___MJSJK__40AF8DC9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [MJSJKZ]
GO
/****** Object:  Default [DF__WFB_MJJY___Fillt__41A3B202]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__WFB_MJJY___Valie__4297D63B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ('Y') FOR [Valie]
GO
/****** Object:  Default [DF__WFB_MJJY___PrtAg__438BFA74]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [PrtAgnFlag]
GO
/****** Object:  Default [DF__WFB_MJJY___MJQty__44801EAD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [MJQty1]
GO
/****** Object:  Default [DF__WFB_MJJY___MJQty__457442E6]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [MJQty2]
GO
/****** Object:  Default [DF__WFB_MJJY___MJQty__4668671F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [MJQty3]
GO
/****** Object:  Default [DF__WFB_MJJY___MJQty__475C8B58]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [MJQty4]
GO
/****** Object:  Default [DF__WFB_MJJY___MJQty__4850AF91]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [MJQty5]
GO
/****** Object:  Default [DF__WFB_MJJY_P__MJXH__4944D3CA]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [MJXH]
GO
/****** Object:  Default [DF__WFB_MJJY___LYFla__4A38F803]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [LYFlag]
GO
/****** Object:  Default [DF__WFB_MJJY___HXFla__4B2D1C3C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB] ADD  DEFAULT ((0)) FOR [HXFlag]
GO
/****** Object:  Default [DF__WFB_MJJY___MJMao__2F8501C7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [MJMaoZ]
GO
/****** Object:  Default [DF__WFB_MJJY___MJLen__30792600]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [MJLen]
GO
/****** Object:  Default [DF__WFB_MJJY_P__MJFK__316D4A39]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [MJFK]
GO
/****** Object:  Default [DF__WFB_MJJY___MJSJK__32616E72]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [MJSJKZ]
GO
/****** Object:  Default [DF__WFB_MJJY___Fillt__335592AB]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__WFB_MJJY___Valie__3449B6E4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ('Y') FOR [Valie]
GO
/****** Object:  Default [DF__WFB_MJJY___PrtAg__353DDB1D]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [PrtAgnFlag]
GO
/****** Object:  Default [DF__WFB_MJJY___MJQty__3631FF56]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [MJQty1]
GO
/****** Object:  Default [DF__WFB_MJJY___MJQty__3726238F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [MJQty2]
GO
/****** Object:  Default [DF__WFB_MJJY___MJQty__381A47C8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [MJQty3]
GO
/****** Object:  Default [DF__WFB_MJJY___MJQty__390E6C01]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [MJQty4]
GO
/****** Object:  Default [DF__WFB_MJJY___MJQty__3A02903A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [MJQty5]
GO
/****** Object:  Default [DF__WFB_MJJY_P__MJXH__3AF6B473]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [MJXH]
GO
/****** Object:  Default [DF__WFB_MJJY___LYFla__3BEAD8AC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [LYFlag]
GO
/****** Object:  Default [DF__WFB_MJJY___HXFla__3CDEFCE5]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[WFB_MJJY_PB_Log] ADD  DEFAULT ((0)) FOR [HXFlag]
GO
/****** Object:  Default [DF__XD_File__FileDat__1C873BEC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[XD_File] ADD  CONSTRAINT [DF__XD_File__FileDat__1C873BEC]  DEFAULT (getdate()) FOR [FileDate]
GO
/****** Object:  Default [DF__YF_Money___QtyFl__24E777C3]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___QtyFl__24E777C3]  DEFAULT ((1)) FOR [QtyFlag]
GO
/****** Object:  Default [DF__YF_Money_CR__Qty__25DB9BFC]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money_CR__Qty__25DB9BFC]  DEFAULT ((0)) FOR [Qty]
GO
/****** Object:  Default [DF__YF_Money___Price__26CFC035]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___Price__26CFC035]  DEFAULT ((0)) FOR [Price]
GO
/****** Object:  Default [DF__YF_Money___HuiLv__27C3E46E]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___HuiLv__27C3E46E]  DEFAULT ((0)) FOR [HuiLv]
GO
/****** Object:  Default [DF__YF_Money___Money__28B808A7]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___Money__28B808A7]  DEFAULT ((0)) FOR [Money]
GO
/****** Object:  Default [DF__YF_Money___BBMon__29AC2CE0]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___BBMon__29AC2CE0]  DEFAULT ((0)) FOR [BBMoney]
GO
/****** Object:  Default [DF__YF_Money___Fillt__2AA05119]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___Fillt__2AA05119]  DEFAULT (getdate()) FOR [Filltime]
GO
/****** Object:  Default [DF__YF_Money___Valid__2B947552]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___Valid__2B947552]  DEFAULT ('Y') FOR [Valid]
GO
/****** Object:  Default [DF__YF_Money___NowOu__2C88998B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___NowOu__2C88998B]  DEFAULT ((0)) FOR [NowOutFlag]
GO
/****** Object:  Default [DF__YF_Money___KPMon__2D7CBDC4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___KPMon__2D7CBDC4]  DEFAULT ((0)) FOR [KPMoney]
GO
/****** Object:  Default [DF__YF_Money___KCKPM__2E70E1FD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___KCKPM__2E70E1FD]  DEFAULT ((0)) FOR [KCKPMoney]
GO
/****** Object:  Default [DF__YF_Money_CR__PS__2F650636]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money_CR__PS__2F650636]  DEFAULT ((0)) FOR [PS]
GO
/****** Object:  Default [DF__YF_Money___YFDef__5772F790]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___YFDef__5772F790]  DEFAULT ((0)) FOR [YFDefFlag1]
GO
/****** Object:  Default [DF__YF_Money___YFDef__58671BC9]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___YFDef__58671BC9]  DEFAULT ((0)) FOR [YFDefFlag2]
GO
/****** Object:  Default [DF__YF_Money___YFDef__595B4002]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  CONSTRAINT [DF__YF_Money___YFDef__595B4002]  DEFAULT ((0)) FOR [YFDefFlag3]
GO
/****** Object:  Default [DF__YF_Money___Derat__2CA8951C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  DEFAULT ('0') FOR [DerateMoney]
GO
/****** Object:  Default [DF__YF_Money___HxNum__2D9CB955]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_CR] ADD  DEFAULT ('0') FOR [HxNum]
GO
/****** Object:  Default [DF__YF_Money___KCQty__14D10B8B]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_KC] ADD  DEFAULT ((0)) FOR [KCQty]
GO
/****** Object:  Default [DF__YF_Money___KCMon__15C52FC4]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_KC] ADD  DEFAULT ((0)) FOR [KCMoney]
GO
/****** Object:  Default [DF__YF_Money___KCBBM__16B953FD]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_KC] ADD  DEFAULT ((0)) FOR [KCBBMoney]
GO
/****** Object:  Default [DF__YF_Money___ZDYFl__17AD7836]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote1]
GO
/****** Object:  Default [DF__YF_Money___ZDYFl__18A19C6F]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote2]
GO
/****** Object:  Default [DF__YF_Money___ZDYFl__1995C0A8]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote3]
GO
/****** Object:  Default [DF__YF_Money___ZDYFl__1A89E4E1]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote4]
GO
/****** Object:  Default [DF__YF_Money___ZDYFl__1B7E091A]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_KC] ADD  DEFAULT ((0)) FOR [ZDYFlote5]
GO
/****** Object:  Default [DF__YF_Money___KCVal__1C722D53]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_KC] ADD  DEFAULT ('Y') FOR [KCValid]
GO
/****** Object:  Default [DF__YF_Money___KCKPM__1D66518C]    Script Date: 12/17/2021 15:51:44 ******/
ALTER TABLE [dbo].[YF_Money_KC] ADD  DEFAULT ((0)) FOR [KCKPMoney]
GO
