ALTER TABLE TiposDocCons ADD ClaveTecDian VARCHAR(250)
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paInsTiposDocCons]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paInsTiposDocCons]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paUpTiposDocCons]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paUpTiposDocCons]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryTiposDocCons]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryTiposDocCons]
GO
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[paQryTiposDocConsLta]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
 DROP PROCEDURE [dbo].[paQryTiposDocConsLta]
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[paInsTiposDocCons] @pmIdDoc VARCHAR(3),@pmIdCia CHAR(2),@pmLDesde INT,@pmLHasta INT,@pmResolucion VARCHAR(30)
,@pmRangoNum VARCHAR(50),@pmFechaRes SMALLDATETIME,@pmPrefijo VARCHAR(5),@pmNumero INT,@pmNumManual BIT,@pmIntLotes BIT
,@pmConfigFecha VARCHAR(10),@pmFormato VARCHAR(20),@pmTipoPapel INT,@pmOrientacion INT,@pmVistaPrevia BIT,@pmVerSetup BIT
,@pmNumCopias INT,@pmFechaVigRes SMALLDATETIME,@pmClaveTecDian VARCHAR(250),@pmFechaAdd SMALLDATETIME
 AS 
 INSERT INTO TiposDocCons (IdDoc,IdCia,LDesde,LHasta,Resolucion,RangoNum,FechaRes,Prefijo,Numero,NumManual,IntLotes,ConfigFecha
,Formato,TipoPapel,Orientacion,VistaPrevia,VerSetup,NumCopias,FechaAdd,FechaVigRes,ClaveTecDian)
 VALUES (@pmIdDoc,@pmIdCia,@pmLDesde,@pmLHasta,@pmResolucion,@pmRangoNum,@pmFechaRes,@pmPrefijo,@pmNumero
,@pmNumManual,@pmIntLotes,@pmConfigFecha,@pmFormato,@pmTipoPapel,@pmOrientacion,@pmVistaPrevia,@pmVerSetup,@pmNumCopias,@pmFechaAdd,@pmFechaVigRes,@pmClaveTecDian)
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[paUpTiposDocCons] @pmIdDoc VARCHAR(3),@pmIdCia CHAR(2),@pmLDesde INT,@pmLHasta INT,@pmResolucion VARCHAR(30),@pmRangoNum VARCHAR(50),@pmFechaRes SMALLDATETIME
,@pmPrefijo VARCHAR(5),@pmNumero INT,@pmNumManual BIT,@pmIntLotes BIT,@pmConfigFecha VARCHAR(10),@pmFormato VARCHAR(20),@pmTipoPapel INT,@pmOrientacion INT,@pmVistaPrevia BIT
,@pmVerSetup BIT,@pmNumCopias INT,@pmFechaVigRes SMALLDATETIME,@pmClaveTecDian VARCHAR(250),@pmFechaUpdate SMALLDATETIME
 AS 
 UPDATE TiposDocCons SET LDesde=@pmLDesde,LHasta=@pmLHasta,Resolucion=@pmResolucion,RangoNum=@pmRangoNum,FechaRes=@pmFechaRes,Prefijo=@pmPrefijo
,Numero=@pmNumero,NumManual=@pmNumManual,IntLotes=@pmIntLotes,ConfigFecha=@pmConfigFecha,Formato=@pmFormato,TipoPapel=@pmTipoPapel
,Orientacion=@pmOrientacion,VistaPrevia=@pmVistaPrevia,VerSetup=@pmVerSetup,NumCopias=@pmNumCopias,FechaUpdate=@pmFechaUpdate,FechaVigRes=@pmFechaVigRes,ClaveTecDian=@pmClaveTecDian
 WHERE IdDoc=@pmIdDoc AND IdCia=@pmIdCia
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[paQryTiposDocCons] @pmIdDoc VARCHAR(3),@pmIdCia CHAR(2)
 AS 
 SELECT IdDoc,IdCia,LDesde,LHasta,Resolucion,RangoNum,FechaRes,Prefijo,Numero
,NumManual,IntLotes,ConfigFecha,Formato,TipoPapel,Orientacion,VistaPrevia
,VerSetup,NumCopias,FechaVigRes,ClaveTecDian,FechaAdd,FechaUpdate
 FROM TiposDocCons
 WHERE IdDoc=@pmIdDoc AND IdCia=@pmIdCia
GO
SET ANSI_NULLS OFF
GO
SET QUOTED_IDENTIFIER OFF
GO
CREATE PROCEDURE [dbo].[paQryTiposDocConsLta] @pmIdDoc VARCHAR(3)=Null,@pmIdCia CHAR(2)=Null
 AS 
 SELECT N.IdDoc AS CdDoc,TipoDoc,N.IdCia AS CdCia,Compania,LDesde,LHasta,Resolucion,RangoNum,FechaRes,Prefijo,Numero
,NumManual,IntLotes,ConfigFecha,Formato,TipoPapel,Orientacion,VistaPrevia,VerSetup,NumCopias
,ConsUnico,Leyenda,FechaVigRes,ClaveTecDian,N.FechaAdd AS Fec_Add,N.FechaUpdate AS Fec_Update
 FROM TiposDocCons AS N INNER JOIN Sys_TiposDoc AS T ON N.IdDoc=T.IdDoc
 INNER JOIN Companias AS C ON N.IdCia=C.IdCia
 WHERE T.Inactivo=0 AND N.IdDoc LIKE ISNULL(@pmIdDoc,'%')  AND N.IdCia LIKE ISNULL(@pmIdCia,'%%')
 ORDER BY N.IdDoc,N.IdCia
GO
