
    i                       S SK Jr  S SKJr  S rS rS rS rS rS r	S	 r
S
 rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS rS r S  r!S! r"S" r#S# r$S$ r%S%\&S&\\&   4S' jr'S( r(S\S) jr)S* r*S\S+ jr+S\S, jr,S- r-S. r.S\S/ jr/S0 r0S\S1 jr1S\S2 jr2S\S3 jr3S4 r4S5 r5S6 r6S\S7 jr7S8 r8S9 r9S: r:S; r;S\S< jr<S= r=S\S> jr>S]S? jr?S\S@ jr@S\SA jrASB rBSC rCS\SD jrDS\SE jrESF rFS\SG jrGS\SH jrHSI rISJ rJS\SK jrKSL rLS\SM jrMS\SN jrNS\SO jrOSP rPSQ rQS\SR jrRS\SS jrSST rTSU rUSV rVSW rWSX rXSY rYSZ rZg[)^    )get_connection)Listc                     Sn  [        5       nU(       d  [        S5      eUR                  5       nUR                  U 5        UR	                  5       nU Vs/ s H  oDS   US   S.PM     snU(       a  UR                  5         $ $ s  snf ! [         a2  n[        SU 35        / s SnAW(       a  UR                  5         $ $ SnAff = f! W(       a  UR                  5         f f = f)zaObtiene los tipos de combustibles disponibles.
Retorna una lista de diccionarios con ID y Nombre.aP  
    SELECT DISTINCT
        CZE_FuelType.FuelTypeID,
        CZE_FuelType.Front
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_FuelType.Front IS NOT NULL
        AND CZE_GensetCost.Evaluator >= 1
    4   No se pudo establecer conexión con la base de datosr      )idFueltypez:[Error inesperado] Error obteniendo tipos de combustible: N)r   ConnectionErrorcursorexecutefetchallclose	Exceptionprint)queryconnr   resultsrowes         jC:\Users\victor.barrera\Documents\proyectos\elepV3\Elep\src\Consultas_SQL\Ventas\VentasEUA\CotizadorSQL.pyget_fueltyper      s    E&!"XYYu//#>EFgs1v3q62gF
 JJL  G J1#NO	JJL 	 JJL sB   AB	 B)B	 B	 	
CC "C#C  CC C"c            	      N   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  o3S   US   US   US   S.PM     snsS S S 5        $ s  snf ! , (       d  f       g = f! [         a  n[        SU 35        / s S nA$ S nAff = f)Nz(select * from StopButtonEnclosureOptionsr   r         )stop_idstop_decription
stop_pricestop_technicalSheet"Error obteniendo marcas de motor: r   r   r   r   r   r   r   r   r   r   r   s        r   getAll_StopButtonEnclosurer"   0   s    5E[[]FNN5! DJ  DS  DS  DU  V  DU|A3q6QTUVQWpstupvw  DU  V  V   21#67	L   
B  4A/A*A/ 	B  *A//
A=9B  =B   
B$
BB$B$c            	      N   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  o3S   US   US   US   S.PM     snsS S S 5        $ s  snf ! , (       d  f       g = f! [         a  n[        SU 35        / s S nA$ S nAff = f)Nzselect * from louvers_inr   r   r   r   )louvers_in_idlouvers_in_decriptionlouvers_in_pricelouvers_in_technicalSheetr   r    r!   s        r   getAll_louvers_inr)   <   s    %E[[]FNN5! \b  \k  \k  \m  n  \m  UX!fs1vcfghci  IL  MN  IO  P  \m  n  n   21#67	r#   c            	      N   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  o3S   US   US   US   S.PM     snsS S S 5        $ s  snf ! , (       d  f       g = f! [         a  n[        SU 35        / s S nA$ S nAff = f)Nzselect * from louvers_outr   r   r   r   )louvers_out_idlouvers_out_decriptionlouvers_out_pricelouvers_out_technicalSheetr   r    r!   s        r   getAll_louvers_outr/   H   s    &E[[]FNN5! `f  `o  `o  `q  r  `q  Y\1vQfijkfl  MP  QR  MS  T  `q  r  r   21#67	r#   c                 <   Sn [        5        nUR                  5       nUR                  X5        UR                  5       nU Vs/ s H
  nSUS   0PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)zObtiene las capacidades KW disponibles para un tipo de combustible.
Args:
    fuel_type (str): Tipo de combustible seleccionado
Returns:
    list: Lista de diccionarios con las capacidades KW disponibles
aS  
    SELECT DISTINCT
        CZE_Genset.KWOutput
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_Genset.KWOutput;
    KWr   Nz!Error obteniendo capacidades KW: r    )	fuel_typer   r   r   r   r   r   s          r   get_kw_by_fuelr3   V   s    E(	[[]FNN5,oo'G.56gsT3q6Ng6 
 7   1!56	sL   
A7 6A&A!A&	A7 !A&&
A40A7 4A7 7
BBBBc                 B   Sn [        5        nUR                  5       nUR                  X U45        UR                  5        Vs/ s H  oUS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)u  Obtiene las marcas de motor disponibles según el tipo de combustible y KW seleccionados.
Args:
    fuel_type (str): Tipo de combustible seleccionado
    kw_output (int): Capacidad KW seleccionada
Returns:
    list: Lista de diccionarios con id y marca de los motores disponibles
a7  
    SELECT DISTINCT
        CZE_EngineBrand.EngineBrandID,
        CZE_EngineBrand.EngineBrand
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_EngineBrand.EngineBrand
    r   r   r   brandNr   r    )r2   	kw_outputr   r   r   r   r   s          r   get_engine_brandsr8   |   s    E2[[]FNN5i"89?E?PQ?Pq6CF3?PQ  R   21#67	L   
A: 6A)A$A)	A: $A))
A73A: 7A: :
BBBBc                 B   Sn [        5        nUR                  5       nUR                  X0X45        UR                  5        Vs/ s H  ofS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)uW  Obtiene las marcas de alternador disponibles según los parámetros seleccionados.
Args:
    fuel_type (str): Tipo de combustible seleccionado
    kw_output (int): Capacidad KW seleccionada
    engine_brand_id (str): ID de la marca del motor seleccionado
Returns:
    list: Lista de diccionarios con id y marca de los alternadores disponibles
a  
    SELECT DISTINCT
        CZE_AlternatorBrand.AlternatorBrandID,
        CZE_AlternatorBrand.AlternatorBrand
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN 
        CZE_AlternatorBrand ON CZE_Genset.AlternatorBrandID = CZE_AlternatorBrand.AlternatorBrandID
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_AlternatorBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_EngineBrand.EngineBrandID = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_AlternatorBrand.AlternatorBrand
    r   r   r5   Nz'Error obteniendo marcas de alternador: r    )r2   r7   engine_brand_idr   r   r   r   r   s           r   get_alternator_brandsr<      s    E:[[]FNN5i"IJ?E?PQ?Pq6CF3?PQ  R   7s;<	r9   c                 D   Sn [        5        nUR                  5       nUR                  X@XU45        UR                  5        Vs/ s H  owS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)u  Obtiene los voltajes disponibles según los parámetros seleccionados.
Args:
    fuel_type (str): Tipo de combustible seleccionado
    kw_output (int): Capacidad KW seleccionada
    engine_brand_id (str): ID de la marca del motor seleccionado
    alternator_brand_id (str): ID de la marca del alternador seleccionado
Returns:
    list: Lista de diccionarios con id y voltaje disponibles
a|  
    SELECT DISTINCT
        CZE_Voltage.VoltageID,
        CZE_Voltage.Voltage_Front
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN 
        CZE_AlternatorBrand ON CZE_Genset.AlternatorBrandID = CZE_AlternatorBrand.AlternatorBrandID
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_Voltage ON CZE_GensetConfig.VoltageID = CZE_Voltage.VoltageID
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_AlternatorBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_EngineBrand.EngineBrandID = ?
        AND CZE_AlternatorBrand.AlternatorBrandID = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_Voltage.Voltage_Front
    r   r   )r   voltageNzError obteniendo voltajes: r    )	r2   r7   r;   alternator_brand_idr   r   r   r   r   s	            r   get_voltagesr@      s    E@[[]FNN5iJ]"^_AGARSAR#q6c!f5ARS  T   +A3/0	L   
A; 7A*A%A*	A; %A**
A84A; 8A; ;
BBBBc           	      D   Sn [        5        nUR                  5       nUR                  XPXX445        UR                  5        Vs/ s H  oS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n	[        SU	 35        / s Sn	A	$ Sn	A	ff = f)u  Obtiene las certificaciones disponibles según los parámetros seleccionados.
Args:
    fuel_type (str): Tipo de combustible seleccionado
    kw_output (int): Capacidad KW seleccionada
    engine_brand_id (str): ID de la marca del motor seleccionado
    alternator_brand_id (str): ID de la marca del alternador seleccionado
    voltage_id (int): ID del voltaje seleccionado
Returns:
    list: Lista de diccionarios con id y certificación disponibles
a&  
    SELECT DISTINCT
        CZE_Certification.CertificationID,
        CZE_Certification.Certification
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN 
        CZE_AlternatorBrand ON CZE_Genset.AlternatorBrandID = CZE_AlternatorBrand.AlternatorBrandID
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_Voltage ON CZE_GensetConfig.VoltageID = CZE_Voltage.VoltageID
    JOIN 
        CZE_Certification ON CZE_GensetConfig.CertificationID = CZE_Certification.CertificationID
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_AlternatorBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_EngineBrand.EngineBrandID = ?
        AND CZE_AlternatorBrand.AlternatorBrandID = ?
        AND CZE_Voltage.VoltageID = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_Certification.Certification
    r   r   )r   certificationNz"Error obteniendo certificaciones: r    )
r2   r7   r;   r?   
voltage_idr   r   r   r   r   s
             r   get_certificationsrE     s    "EF[[]FNN5iJ]"jkGMGXYGXq6CF;GXY  Z   21#67	rA   c            	          Sn [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  o3S   US   US   US   S.PM     snsS S S 5        $ s  snf ! , (       d  f       g = f)Na.  
    SELECT 
        [CZE_BreakersCatalog].[Item_breaker],
        [CZE_BreakersCatalog].[description],
        ISNULL([CZE_BreakersCatalog].[price], 0) AS price,
        [CZE_BreakersCatalog].[type]
    FROM 
        [CZE_BreakersCatalog]
    ORDER BY 
        [CZE_BreakersCatalog].[description]
    r   r   r   r   )r   descriptionpricetyper   r   r   r   )r   r   r   r   s       r   get_breaker_catalogrK   ?  sw    
E 
	Tubhbqbqbstbs[^1vc!fs1vsSTvVbst 
	 u 
	s   4A.A)A.)A..
A<c                     Sn[        5        nUR                  5       nUR                  X5        UR                  5        Vs/ s H  oDS   US   US   S.PM     snsS S S 5        $ s  snf ! , (       d  f       g = f)Na  
    SELECT 
        [CZE_BreakerProtectionType].[Item_breaker_Protection],
        [CZE_BreakerProtectionType].[description],
        ISNULL([CZE_BreakerProtectionType].[price], 0) AS price
    FROM 
        [CZE_BreakerProtectionType]
    WHERE
        [CZE_BreakerProtectionType].[TypeBreaker] = ?
    ORDER BY 
        [CZE_BreakerProtectionType].[Item_breaker_Protection] asc
    r   r   r   )r   rG   rH   rJ   )breaker_typer   r   r   r   s        r   get_protection_typesrN   P  so    E 
	Tu+RXRaRaRcdRc31vc!fs1vFRcd 
	 e 
	s   4A*A%A*%A**
A8c           
      F   Sn [        5        nUR                  5       nUR                  X`XX4U45        UR                  5        V	s/ s H  oS   U	S   S.PM     sn	sSSS5        $ s  sn	f ! , (       d  f       g= f! [         a  n
[        SU
 35        / s Sn
A
$ Sn
A
ff = f)u  Obtiene las marcas de controlador disponibles según los parámetros seleccionados.
Args:
    fuel_type (str): Tipo de combustible seleccionado
    kw_output (int): Capacidad KW seleccionada
    engine_brand_id (str): ID de la marca del motor seleccionado
    alternator_brand_id (str): ID de la marca del alternador seleccionado
    voltage_id (int): ID del voltaje seleccionado
    certification_id (str): ID de la certificación seleccionada
Returns:
    list: Lista de diccionarios con id y marca de los controladores disponibles
a  
    SELECT DISTINCT
        CZE_ControllerBrand.BrandID,
        CZE_ControllerBrand.Brand
    FROM 
        CZE_Genset
    JOIN 
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN 
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN 
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN 
        CZE_AlternatorBrand ON CZE_Genset.AlternatorBrandID = CZE_AlternatorBrand.AlternatorBrandID
    JOIN 
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN 
        CZE_Voltage ON CZE_GensetConfig.VoltageID = CZE_Voltage.VoltageID
    JOIN 
        CZE_Certification ON CZE_GensetConfig.CertificationID = CZE_Certification.CertificationID
    JOIN 
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    JOIN 
        CZE_ControllerBrand ON CZE_GensetCost.ControllerBrandID = CZE_ControllerBrand.BrandID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_AlternatorBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_EngineBrand.EngineBrandID = ?
        AND CZE_AlternatorBrand.AlternatorBrandID = ?
        AND CZE_Voltage.VoltageID = ?
        AND CZE_Certification.CertificationID = ?
        AND CZE_GensetCost.Evaluator >= 1
    ORDER BY 
        CZE_ControllerBrand.Brand
    r   r   r5   Nz(Error obteniendo marcas de controlador: r    )r2   r7   r;   r?   rD   certification_idr   r   r   r   r   s              r   get_control_brandsrQ   b  s    %EL[[]FNN5iJ]k{"|}?E?PQ?Pq6CF3?PQ  R   8<=	sL   
A< 8A+A&A+	A< &A++
A95A< 9A< <
B BB B c                 >   Sn [        5        nUR                  5       nUR                  X5        UR                  5        Vs/ s H  oDS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)u   Obtiene los modelos de controlador disponibles para una marca específica.
Args:
    control_brand_id (str): ID de la marca del controlador
Returns:
    list: Lista de diccionarios con item y descripción de los modelos
a  
    SELECT DISTINCT
        CZE_ControllerCatalog.Item_controller,
        CZE_ControllerCatalog.description
    FROM 
        CZE_ControllerCatalog
    WHERE
        CZE_ControllerCatalog.BrandID = ?
    ORDER BY 
        CZE_ControllerCatalog.description
    r   r   itemrG   Nz)Error obteniendo modelos de controlador: r    )control_brand_idr   r   r   r   r   s         r   get_control_modelsrV     s    
E[[]FNN53GMGXYGXVCF;GXY  Z   9!=>	L   
A8 4A'A"A'	A8 "A''
A51A8 5A8 8
BBBBc            
      r   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H'  nUS   US   US   (       a  [	        US   5      OSS.PM)     snsS S S 5        $ s  snf ! , (       d  f       g = f! [
         a  n[        SU 35        / s S nA$ S nAff = f)Na#  
    SELECT 
        [CZE_ControllerPreheater].[Item_preheater_volt],
        [CZE_ControllerPreheater].[description],
        ISNULL([CZE_ControllerPreheater].[price], 0) AS price
    FROM 
        [CZE_ControllerPreheater]
    ORDER BY 
        [CZE_ControllerPreheater].[description]
    r   r   r   rT   rG   rH   z,Error obteniendo voltajes de precalentador: r   r   r   r   floatr   r   r!   s        r   get_preheater_voltagesr\     s    	E[[]FNN5!
  *	, +# A"1v*-a&s1va +	, ,   <QC@A	L   
B 4B.A<0B2	B <B
BB B 
B6B1+B61B6c            
      r   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H'  nUS   US   US   (       a  [	        US   5      OSS.PM)     snsS S S 5        $ s  snf ! , (       d  f       g = f! [
         a  n[        SU 35        / s S nA$ S nAff = f)Na-  
    SELECT 
        [CZE_ControllerBattCharger].[Item_batterycharger],
        [CZE_ControllerBattCharger].[description],
        ISNULL([CZE_ControllerBattCharger].[price], 0) AS price
    FROM 
        [CZE_ControllerBattCharger]
    ORDER BY 
        [CZE_ControllerBattCharger].[description]
    r   r   r   rY   u)   Error obteniendo cargadores de batería: rZ   r!   s        r   get_battery_chargersr_     s    	E[[]FNN5!
  *	, +# A"1v*-a&s1va +	, ,   9!=>	r]   c                 B   Sn [        5        nUR                  5       nUR                  X0X45        UR                  5        Vs/ s H  ofS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)uM   Obtiene los tipos de caseta disponibles según los parámetros seleccionados.a  
    SELECT DISTINCT
        CZE_EnclosureType.Item_Enclosuree_type,
        CZE_EnclosureType.Front
    FROM
        CZE_EnclosureType
    JOIN 
        CZE_EnclosureConfig ON CZE_EnclosureType.Item_Enclosuree_type = CZE_EnclosureConfig.Item_Enclosure_type
    JOIN 
        CZE_FuelType ON CZE_EnclosureConfig.FuelType = CZE_FuelType.Back

    WHERE
        CZE_FuelType.Front = ?
        AND CZE_EnclosureConfig.KWOutput = ?
        AND CZE_EnclosureConfig.CertificationID = ?
        AND CZE_EnclosureConfig.Evaluator >= 1
    r   r   rS   Nz"Error obteniendo tipos de caseta: r    )r2   r7   rP   r   r   r   r   r   s           r   get_enclosure_typesra     s    E"[[]FNN5i"JKGMGXYGXVCF;GXY  Z   21#67	r9   c                 D   Sn [        5        nUR                  5       nUR                  X@XU45        UR                  5        Vs/ s H  owS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)uR   Obtiene los materiales de caseta disponibles según los parámetros seleccionados.ac  
    SELECT DISTINCT
        CZE_EnclosureMaterial.Item_Eclousure_Mat,
        CZE_EnclosureMaterial.description
    FROM
        CZE_EnclosureMaterial
    JOIN 
        CZE_EnclosureConfig ON CZE_EnclosureMaterial.Item_Eclousure_Mat = CZE_EnclosureConfig.Item_Enclosure_Mat
    JOIN 
        CZE_FuelType ON CZE_EnclosureConfig.FuelType = CZE_FuelType.Back        
    WHERE
        CZE_FuelType.Front = ?
        AND CZE_EnclosureConfig.KWOutput = ?
        AND CZE_EnclosureConfig.CertificationID = ?
        AND CZE_EnclosureConfig.Item_Enclosure_type = ?
        AND CZE_EnclosureConfig.Evaluator >= 1
    r   r   rS   Nz'Error obteniendo materiales de caseta: r    )	r2   r7   rP   enclosure_typer   r   r   r   r   s	            r   get_enclosure_materialsrd     s    E"[[]FNN5i>"Z[GMGXYGXVCF;GXY  Z   7s;<	rA   c                  @   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  nUS   US   S.PM     snsS S S 5        $ s  snf ! , (       d  f       g = f! [         a  n[        SU 35        / s S nA$ S nAff = f)Nz
    SELECT DISTINCT
        [CZE_EnclosureLight].[Item_Enclosure_ligth],
        [CZE_EnclosureLight].[description]
    FROM
        [CZE_EnclosureLight]
    WHERE
        [CZE_EnclosureLight].[type] = 'AC'
    r   r   rS   z%Error obteniendo luces AC de caseta: r    r!   s        r   get_enclosure_lights_acrf          E
[[]FNN5!  *, +# A"1v +, ,   5aS9:	L   
A9 4A(A#A(	A9 #A((
A62A9 6A9 9
BBBBc                  @   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  nUS   US   S.PM     snsS S S 5        $ s  snf ! , (       d  f       g = f! [         a  n[        SU 35        / s S nA$ S nAff = f)Nz
    SELECT DISTINCT
        [CZE_EnclosureLight].[Item_Enclosure_ligth],
        [CZE_EnclosureLight].[description]
    FROM
        [CZE_EnclosureLight]
    WHERE
        [CZE_EnclosureLight].[type] = 'DC'
    r   r   rS   z%Error obteniendo luces DC de caseta: r    r!   s        r   get_enclosure_lights_dcrj   6  rg   rh   c                  @   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  nUS   US   S.PM     snsS S S 5        $ s  snf ! , (       d  f       g = f! [         a  n[        SU 35        / s S nA$ S nAff = f)Nz
    SELECT DISTINCT
        [CZE_EnclosureSpaceHeater].[Item_Enclosure_SHeater],
        [CZE_EnclosureSpaceHeater].[description]
    FROM
        [CZE_EnclosureSpaceHeater]
    r   r   rS   z*Error obteniendo calentadores de espacio: r    r!   s        r   get_enclosure_space_heatersrl   L  s    E
[[]FNN5!  *, +# A"1v +, ,   :1#>?	rh   c                  @   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  nUS   US   S.PM     snsS S S 5        $ s  snf ! , (       d  f       g = f! [         a  n[        SU 35        / s S nA$ S nAff = f)Nz
    SELECT DISTINCT
        [CZE_EnclosureLoadCenter].[Item_Enclosure_LCenter],
        [CZE_EnclosureLoadCenter].[description]
    FROM
        [CZE_EnclosureLoadCenter]
    r   r   rS   z#Error obteniendo centros de carga: r    r!   s        r   get_enclosure_load_centersrn   `  s    E
[[]FNN5!  *, +# A"1v +, ,   3A378	rh   c                  @   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  nUS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)um   Obtiene las opciones de paro de emergencia remoto.
Retorna una lista de diccionarios con item y descripción.z
    SELECT DISTINCT
        [CZE_AddAccesory_Estop].[Item_AddAccesory_Estop],
        [CZE_AddAccesory_Estop].[description]
    FROM
        [CZE_AddAccesory_Estop]
    r   r   rS   Nz1Error obteniendo opciones de paro de emergencia: r    r!   s        r   get_estop_catalogrp   t  s    E
[[]FNN5!  *, +# A"1v +, ,   A!EF	rh   c                  @   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  nUS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)ug   Obtiene las opciones de resorte de aislador.
Retorna una lista de diccionarios con item y descripción.z
    SELECT DISTINCT
        [CZE_AddAccesory_Spring].[Item_AddAccesory_Spring],
        [CZE_AddAccesory_Spring].[description]
    FROM
        [CZE_AddAccesory_Spring]
    r   r   rS   Nz2Error obteniendo opciones de resorte de aislador: r    r!   s        r   get_spring_catalogrr     s    E
[[]FNN5!  *, +# A"1v +, ,   B1#FG	rh   c                 >   Sn [        5        nUR                  5       nUR                  X5        UR                  5        Vs/ s H  oDS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)zFObtiene las capacidades de tanque disponibles para el KW seleccionado.aQ  
    SELECT DISTINCT
        CZE_TankAutonomy.Item_Tank_Autonomy,
        CZE_TankAutonomy.description
    FROM
        CZE_TankAutonomy
    JOIN 
        CZE_TankConfig ON CZE_TankAutonomy.Item_Tank_Autonomy = CZE_TankConfig.Item_Tank_Autonomy
    WHERE
        CZE_TankConfig.KWOutput = ?
        AND CZE_TankConfig.Evaluator >= 1
    r   r   rS   Nz(Error obteniendo capacidades de tanque: r    r7   r   r   r   r   r   s         r   get_tank_capacity_catalogru     s    E[[]FNN5.GMGXYGXVCF;GXY  Z   8<=	rW   c                 B   Sn [        5        nUR                  5       nUR                  X U45        UR                  5        Vs/ s H  oUS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)uM   Obtiene los tipos de tanque disponibles según los parámetros seleccionados.ag  
    SELECT DISTINCT
        CZE_TankType.Item_Tank_type,
        CZE_TankType.description
    FROM
        CZE_TankType
    JOIN 
        CZE_TankConfig ON CZE_TankType.Item_Tank_type = CZE_TankConfig.Item_Tank_type
    WHERE
        CZE_TankConfig.KWOutput = ?
        AND CZE_TankConfig.Item_Tank_Autonomy = ?
        AND CZE_TankConfig.Evaluator >= 1
    r   r   rS   Nz"Error obteniendo tipos de tanque: r    )r7   tank_autonomyr   r   r   r   r   s          r   get_tank_type_catalogrx     s    E[[]FNN5m"<=GMGXYGXVCF;GXY  Z   21#67	r9   c                  @   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  nUS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)uk   Obtiene las opciones de contención de derrames.
Retorna una lista de diccionarios con item y descripción.z
    SELECT DISTINCT
        [CZE_TankSpillCont].[Item_Tank_SpillCont],
        [CZE_TankSpillCont].[description]
    FROM
        [CZE_TankSpillCont]
    r   r   rS   Nu6   Error obteniendo opciones de contención de derrames: r    r!   s        r   get_spill_containment_catalogrz     s    E
[[]FNN5!  *, +# A"1v +, ,   FqcJK	rh   c                  @   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  nUS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)j   Obtiene las opciones de garantías disponibles.
Retorna una lista de diccionarios con item y descripción.z
    SELECT DISTINCT
        [CZE_PrjWarCountry].[Item_PrjWar_Country],
        [CZE_PrjWarCountry].[description]
    FROM
        [CZE_PrjWarCountry]
    r   r   rS   N(   Error obteniendo opciones de garantía: r    r!   s        r   get_countrysr~         E
[[]FNN5!  *, +# A"1v +, ,   8<=	rh   c                  @   Sn  [        5        nUR                  5       nUR                  U 5        UR                  5        Vs/ s H  nUS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)r|   z
    SELECT DISTINCT
        [CZE_PrjWarWarranty].[Item_PrjWar_Warranty],
        [CZE_PrjWarWarranty].[description]
    FROM
        [CZE_PrjWarWarranty]
    r   r   rS   Nr}   r    r!   s        r   get_warranty_catalogr     r   rh   c                 >   Sn [        5        nUR                  5       nUR                  X5        UR                  5        Vs/ s H  oDS   US   S.PM     snsSSS5        $ s  snf ! , (       d  f       g= f! [         a  n[        SU 35        / s SnA$ SnAff = f)z8Obtiene las pruebas disponibles para el KW seleccionado.ap  
    SELECT DISTINCT
        CZE_PrjWarTesting.Item_PrjWar_Testing,
        CZE_PrjWarTesting.description
    FROM
        CZE_PrjWarTesting
    JOIN 
        CZE_PrjWarTestConfig ON CZE_PrjWarTesting.Item_PrjWar_Testing = CZE_PrjWarTestConfig.Item_PrjWar_Testing
    WHERE
        CZE_PrjWarTestConfig.KWOutput = ?
        AND CZE_PrjWarTestConfig.Evaluator >= 1
    r   r   rS   NzError obteniendo pruebas: r    rt   s         r   get_testing_catalogr     s    E[[]FNN5.GMGXYGXVCF;GXY  Z   *1#./	rW   c                 @   Sn [        5       nU(       d  [        S5      eUR                  5       nUR                  X45        UR	                  5       nU(       aS  US   US   US   US   US   US   US	   US
   US   US   US   US   US   US   S.U(       a  UR                  5         $ $  U(       a  UR                  5         gg! [         a0  n[        SU 35         SnAW(       a  UR                  5         ggSnAff = f! W(       a  UR                  5         f f = f)uo   Obtiene la información del perfil completo del usuario.
Retorna un diccionario con la información del perfil.a#  
    SELECT 
        Users.UserID,
        Users.RequestTypeID,
        Profiles.ProfileID,
        Profiles.Discount,
        Profiles.BusinessName,
        Profiles.FiscalAddress,
        Profiles.PrimaryContact,
        Profiles.Email,
        Profiles.ContactPhone,
        Profiles.FirstName,
        Profiles.MiddleName,
        Profiles.LastName,
        Profiles.SecondLastName,
        Profiles.SellerUserID
    FROM 
        Users
    LEFT JOIN 
        Profiles ON Users.UserID = Profiles.UserID
    WHERE 
        Users.UserID = ?
    r   r   r   r   r                  	   
            )UserIDRequestTypeID	ProfileIDDiscountBusinessNameFiscalAddressPrimaryContactEmailContactPhone	FirstName
MiddleNameLastNameSecondLastNameSellerUserIDNu=   [Error inesperado] Error obteniendo información del perfil: r   r
   r   r   fetchoner   r   r   )user_idr   r   r   resultr   s         r   get_profile_infor   /  s)   E. !"XYYuj)" )!'#AY"1I &q	!'"() &q	#AY$Rj"2J"(* &r
* JJL  
 JJL 	  MaSQRJJL 	 JJL s*   BC 
D C;D ;D  D Dc                     Sn [        5       nU(       d  [        S5      eUR                  5       nUR                  X45        UR	                  5       nU(       a3  US   US   US   US   US   US   S	.U(       a  UR                  5         $ $  U(       a  UR                  5         g
g
! [         a0  n[        SU 35         S
nAW(       a  UR                  5         g
g
S
nAff = f! W(       a  UR                  5         f f = f)uy   Obtiene la información del vendedor asignado a un distribuidor.
Retorna un diccionario con la información del vendedor.z
    SELECT 
        Profiles.FirstName,
        Profiles.MiddleName,
        Profiles.LastName,
        Profiles.SecondLastName,
        Profiles.Email,
        Profiles.ContactPhone
    FROM 
        Profiles
    WHERE 
        Profiles.UserID = ?
    r   r   r   r   r   r   r   )r   r   r   r   r   r   Nu?   [Error inesperado] Error obteniendo información del vendedor: r   )seller_user_idr   r   r   r   r   s         r   get_seller_infor   k  s    E!"XYYu/0"#AY$Qi"1I"() &q	 JJL  
 JJL 	  OPQsSTJJL 	 JJL s*   A/B& &
C 0C>C# C  C# #C=c                    Sn [        5        nUR                  5       nUR                  X45        UR                  5       nU(       a  UsSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)uO   
Obtiene el valor del descuento por pais, en función del id de la cotización
a  
        SELECT
            CZE_Quotes.QuoteID,
            CZE_Quotes.Destiny_Country,
            CZE_Quotes.Destiny_State,
            CZE_Countries.isDiscount,
            CZE_Countries.percents
        FROM 
            CZE_Quotes  
            JOIN CZE_Countries 
            ON  CZE_Quotes.Destiny_Country = CZE_Countries.CountryID

        WHERE 
            CZE_Quotes.QuoteID = ?

    Nz#Error al obtener datos de Country: r   r   r   r   r   r   )quote_idr   r   r   r   r   s         r   get_discount_country_valuer     s~    
E"KKM6>>%.OO%6     3A378s@   
A. ;A		A. AA. 
A+'A. +A. .
B8BBc                    Sn [        5        nUR                  5       nUR                  UUUU 45        UR                  5         [	        S5        SSS5        g! , (       d  f       g= f! [
         a  n[	        SU  SU 35        e SnAff = f)zh
Actualiza los valores de los precios de CommercialOffer y de CountryDiscount en la 
tabla de CZE_Quote
z
    
        UPDATE CZE_Quotes 
        SET 
            Country_Discount = ?,
            Commercial_Offer = ?
        WHERE
            QuoteID  = ?

    z1EXITO, VALORES COMERCIALES ACTUALIZADOS CON EXITONu0   Error actualizado los precios de la cotizaciòn : )r   r   r   commitr   r   )r   country_discountcommercial_offerr   r   r   r   s          r    update_commercial_country_valuesr     s    	E[[]FNN5  " 
 KKMEF   @
"QCPQs5   
A) AAA) 
A&"A) &A) )
B
3BB
c                    / SQnSR                  U5      nSR                  S/[        U5      -  5      nSU SU S3nU Vs/ s H  oPR                  U5      PM     nn [        5        nUR	                  5       nUR                  XF5        UR                  5       S   n	UR                  5         U	sSSS5        $ s  snf ! , (       d  f       g= f! [         a  n
[        S	U
 35        e Sn
A
ff = f)
uF   Guarda una nueva cotización en la base de datos y retorna el QuoteID.)PlateRatingFuelTypeIDBackFuelTypeFrontKWOutputEngineBrandIDEngineBrandAlternatorBrandIDAlternatorBrand	VoltageIDVoltage_FrontCertificationIDCertification	QtyGensetQtyBreakersFrontQtyBreakersItem_breaker1Breaker1Item_Sunt_t1Shunt_trip1Item_Sunt_w1Shunt_trip_wiring1	Item_GFI1GFI1Item_Proyection_t1Protection_type1Item_Auxiliary_c1Auxiliary_contacts1Item_Breaker_L1Breaker_Lock1Item_Motorized_B1Motorized_Breaker1Item_breaker2Breaker2Item_Sunt_t2Shunt_trip2Item_Sunt_w2Shunt_trip_wiring2	Item_GFI2GFI2Item_Proyection_t2Protection_type2Item_Auxiliary_c2Auxiliary_contacts2Item_Breaker_L2Breaker_Lock2Item_Motorized_B2Motorized_Breaker2Item_breaker3Breaker3Item_Sunt_t3Shunt_trip3Item_Sunt_w3Shunt_trip_wiring3	Item_GFI3GFI3Item_Proyection_t3Protection_type3Item_Auxiliary_c3Auxiliary_contacts3Item_Breaker_L3Breaker_Lock3Item_Motorized_B3Motorized_Breaker3ControllerBrandIDControlbrandItem_controllerControlModelItem_CtrlPanelHeaterCtrlPanelHeaterItem_RempteDisplModRemoteDisplayModuleItem_AntenaAntenaItem_DSE890DSE890Item_DSE2157DSE2157
QtyDSE2157Item_DSE2548DSE2548
QtyDSE2548Item_CtrlPanelHeaterCMPCtrlPanelHeaterCMPItem_RempteDisplModCMPRemoteDisplayModuleCMPItem_AntenaCMP	AntenaCMPItem_ComapDSE890ComapDSE890Item_ComapDSE2157ComapDSE2157QtyComapDSE2157Item_ComapDSE2548ComapDSE2548QtyComapDSE2548Item_CtrlVotlOperCtrlVotlOperItem_BateryChargerBateryChargerItem_Enclosuree_type	EnclosureItem_Eclousure_MatEnclosureTypeItem_GFCI120VGFCI120VQtyGFCI120VItem_Receptable120VReceptable120VQtyReceptable120VItem_Enclosure_ligthAClightAC
QtylightACItem_Enclosure_ligthDClightDC
QtylightDCItem_Enclosure_SHeaterSpaceHeaterQtySpaceHeaterItem_Enclosure_LCenter
LoadCenterItem_PrewireAccsEnclPrewireAccsEnclousureItem_autolouversautolouversItem_ReceptautolouversReceptautolouversItem_OpeningEnclousureOpeningEnclousureItem_StopButtonEnclosureStopButtonEnclosureStopButtonEnclosure_QtyItem_BandHeater
BandHeaterItem_PMGUpdate	PMGUpdateItem_DigitalRegulatorDigitalRegulatorItem_VoltageRheostatVoltageRheostatItem_ThermalWrapThermalWrapItem_BaseHeater
BaseHeaterItem_BatterySwitchBatterySwitchItem_BatteryHolderBatteryHolderItem_OilHeater	OilHeaterItem_OilLevelSwitchOilLevelSwitchItem_CommonAlarmRelayCommonAlarmRelayItem_FunctionRelayFunctionRelayItem_CoolantCoolantItem_OilOilItem_DisconnectSwitchesDisconnectSwitchesItem_AddAccesory_EstopEStopQtyEStopItem_RemoteEStopRemoteEStopItem_AddAccesory_SpringSpringIsolatorItem_Tank_AutonomyTankCapacityItem_Tank_typeTankTypeItem_BreakTraySwitchBreakTraySwitchItem_FuelLevelSensorFuelLevelSensorItem_Tank_SpillContSpillContainmentItem_OverfillValveOverfillValveItem_DualFuelSwitchDualFuelSwitchesItem_HighFuelSwitchHighFuelSwitchItem_RemoteAlarmPRemoteAlarmPanelItem_VentPipeVentPipeItem_FlammableLFlammableLiquidsItem_NFPAIdentificatNFPAIdentificationItem_NoSmoking	NoSmokingItem_TankNumber
TankNumberItem_FluidContainmentFluidContainmentItem_louvers_in
louvers_inItem_louvers_outlouvers_outProjectItem_PrjWar_WarrantyGarantyItem_PrjWar_TestingTeastingReqCustomerr   CustomerCompanyCustomerAddressCustomerContactCustomerEmailCustomerTel
SellerNameSellerEmailSellerPhoneDestiny_CountryDestiny_Statez, ?z!
        INSERT INTO CZE_Quotes (z2)
        OUTPUT INSERTED.QuoteID
        VALUES (z)
    r   Nu   Error guardando cotización: )
joinlengetr   r   r   r   r   r   r   )datafields
field_listplaceholdersr   fieldvaluesr   r   r   r   s              r   
save_quoter    s    iFX 6"J99cUS[01L!!+ - E ,226%hhuo6F2
[[]FNN5)(+HKKM  3   -aS12s=   B8
C (AB=.	C =
CC C 
C,C''C,r   returnc                 8   [        5        nUR                  5        nUR                  SU 45        UR                  5       nU(       a  US   sSSS5        sSSS5        $  SSS5        SSS5        g! , (       d  f       O= f SSS5        g! , (       d  f       g= f)ue   
Obtiene la descripción de una cotización por su ID.
Retorna una lista con la(s) descripción(es).
z:select * from StopButtonEnclosureOptions WHERE stop_id = ?r   N)r   r   r   r   )r   r   r   r   s       r   get_descriptionr  g  su    
 
	T[[]fNNWZaYcd__&Fay	 ] 
	   
	]] 
		s.   B/A0	BA0B0
A>	:B
Bc                     Sn [        5        nUR                  5       nUR                  X45        UR                  5       sSSS5        $ ! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)<   Obtiene los datos necesarios de una cotización específica.a#  
        SELECT 
            FuelTypeIDBack,          -- 0
            KWOutput,                -- 1
            EngineBrandID,           -- 2
            AlternatorBrandID,       -- 3
            VoltageID,               -- 4
            CertificationID,         -- 5
            ControllerBrandID,       -- 6
            QtyGenset,               -- 7

            -- SECCION DE LOS BREAKERS
            -- Breaker gral
            Item_breaker1,           -- 8
            Item_breaker2,           -- 9
            Item_breaker3,           -- 10
            Item_Proyection_t1,      -- 11
            Item_Proyection_t2,      -- 12
            Item_Proyection_t3,      -- 13

            -- Breaker 1 options
            Item_Sunt_t1,            -- 14
            Shunt_trip1,             -- 15
            Item_Sunt_w1,            -- 16
            Shunt_trip_wiring1,      -- 17
            Item_GFI1,               -- 18
            GFI1,                    -- 19
            Item_Auxiliary_c1,       -- 20
            Auxiliary_contacts1,     -- 21
            Item_Breaker_L1,         -- 22
            Breaker_Lock1,           -- 23
            Item_Motorized_B1,       -- 24
            Motorized_Breaker1,      -- 25

            -- Breaker 2 options
            Item_Sunt_t2,            -- 26
            Shunt_trip2,             -- 27
            Item_Sunt_w2,            -- 28
            Shunt_trip_wiring2,      -- 29
            Item_GFI2,               -- 30
            GFI2,                    -- 31
            Item_Auxiliary_c2,       -- 32
            Auxiliary_contacts2,     -- 33
            Item_Breaker_L2,         -- 34
            Breaker_Lock2,           -- 35
            Item_Motorized_B2,       -- 36
            Motorized_Breaker2,      -- 37

            -- Breaker 3 options
            Item_Sunt_t3,            -- 38
            Shunt_trip3,             -- 39
            Item_Sunt_w3,            -- 40
            Shunt_trip_wiring3,      -- 41
            Item_GFI3,               -- 42
            GFI3,                    -- 43
            Item_Auxiliary_c3,       -- 44
            Auxiliary_contacts3,     -- 45
            Item_Breaker_L3,         -- 46
            Breaker_Lock3,           -- 47
            Item_Motorized_B3,       -- 48
            Motorized_Breaker3,      -- 49

            -- SECCION DEL CONTROLLER
            -- Controller gral
            Item_controller,         -- 50
            ControlModel,            -- 51
            Item_CtrlVotlOper,       -- 52
            CtrlVotlOper,            -- 53
            Item_BateryCharger,      -- 54
            BateryCharger,           -- 55

            -- Controller options Si/NO con cantidad
            Item_DSE2157,           -- 56
            DSE2157,                -- 57
            QtyDSE2157,             -- 58
            Item_DSE2548,           -- 59
            DSE2548,                -- 60
            QtyDSE2548,             -- 61
            Item_ComapDSE2157,      -- 62
            ComapDSE2157,           -- 63
            QtyComapDSE2157,        -- 64
            Item_ComapDSE2548,      -- 65
            ComapDSE2548,           -- 66
            QtyComapDSE2548,        -- 67

            -- Controller options Si/NO sin cantidad
            Item_ComapDSE890,       -- 68
            ComapDSE890,            -- 69
            Item_CtrlPanelHeater,   -- 70
            CtrlPanelHeater,        -- 71
            Item_RempteDisplMod,    -- 72
            RemoteDisplayModule,    -- 73
            Item_Antena,            -- 74
            Antena,                 -- 75
            Item_DSE890,            -- 76
            DSE890,                 -- 77

            -- SECCION DEL ENLOSURE
            -- Indices para Enclosure
            Item_Enclosuree_type,   -- 78
            Item_Eclousure_Mat,     -- 79

            Item_Enclosure_ligthAC, -- 80
            lightAC,                -- 81
            QtylightAC,             -- 82

            Item_Enclosure_ligthDC, -- 83
            lightDC,                -- 84
            QtylightDC,             -- 85

            Item_Enclosure_SHeater, -- 86
            SpaceHeater,            -- 87
            QtySpaceHeater,         -- 88

            Item_Enclosure_LCenter, -- 89
            LoadCenter,             -- 90

            Item_GFCI120V,          -- 91
            GFCI120V,               -- 92
            QtyGFCI120V,            -- 93

            Item_Receptable120V,    -- 94
            Receptable120V,         -- 95
            QtyReceptable120V,      -- 96

            Item_PrewireAccsEncl,   -- 97
            PrewireAccsEnclousure,  -- 98

            Item_autolouvers,       -- 99
            autolouvers,            -- 100

            Item_Receptautolouvers, -- 101
            Receptautolouvers,      -- 102
            
            -- SECCION DEL ACCESORIOS
            Item_AddAccesory_Estop, -- 103
            EStop,                  -- 104
            QtyEStop,               -- 105

            Item_AddAccesory_Spring,-- 106
            SpringIsolator,         -- 107

            Item_BandHeater,        -- 108
            BandHeater,             -- 109

            Item_PMGUpdate,         -- 110
            PMGUpdate,              -- 111

            Item_DigitalRegulator,  -- 112
            DigitalRegulator,       -- 113

            Item_VoltageRheostat,   -- 114
            VoltageRheostat,        -- 115

            Item_ThermalWrap,       -- 116
            ThermalWrap,            -- 117

            Item_BaseHeater,        -- 118
            BaseHeater,             -- 119

            Item_BatterySwitch,     -- 120
            BatterySwitch,          -- 121

            Item_BatteryHolder,     -- 122
            BatteryHolder,          -- 123

            Item_OilHeater,         -- 124
            OilHeater,              -- 125

            Item_OilLevelSwitch,    -- 126
            OilLevelSwitch,         -- 127

            Item_CommonAlarmRelay,  -- 128
            CommonAlarmRelay,       -- 129

            Item_FunctionRelay,     -- 130
            FunctionRelay,          -- 131

            Item_Coolant,           -- 132
            Coolant,                -- 133

            Item_Oil,               -- 134
            Oil,                    -- 135

            Item_DisconnectSwitches,-- 136
            DisconnectSwitches,     -- 137

            Item_RemoteEStop,       -- 138
            RemoteEStop,            -- 139
            
            -- SECCION DE TANQUE
            --Tank
            Item_Tank_Autonomy,     -- 140
            TankCapacity,           -- 141
            Item_Tank_type,         -- 142
            TankType,               -- 143

            --TankOptions
            Item_BreakTraySwitch,   -- 144
            BreakTraySwitch,        -- 145

            Item_FuelLevelSensor,   -- 146
            FuelLevelSensor,        -- 147

            Item_Tank_SpillCont,    -- 148
            SpillContainment,       -- 149

            Item_OverfillValve,     -- 150
            OverfillValve,          -- 151

            Item_DualFuelSwitch,    -- 152
            DualFuelSwitches,       -- 153

            Item_HighFuelSwitch,    -- 154
            HighFuelSwitch,         -- 155

            Item_RemoteAlarmP,      -- 156
            RemoteAlarmPanel,       -- 157

            Item_VentPipe,          -- 158
            VentPipe,               -- 159

            Item_FlammableL,        -- 160
            FlammableLiquids,       -- 161

            Item_NFPAIdentificat,   -- 162
            NFPAIdentification,     -- 163

            Item_NoSmoking,         -- 164
            NoSmoking,              -- 165

            Item_TankNumber,        -- 166
            TankNumber,             -- 167

            Item_FluidContainment,  -- 168
            FluidContainment,       -- 169
            
            -- SECCION DE ULTIMOS DETALLES
            --Warranty
            Item_PrjWar_Warranty,   -- 170
            Garanty,                -- 171
            Garanty_price,          -- 172
            Garanty_Percentage,     -- 173

            --Testing
            Item_PrjWar_Testing,    -- 174
            Teasting,               -- 175
            
            Genset_Unit_Price,      -- 176
            Discount,                -- 177

            Item_CtrlPanelHeaterCMP,   -- 178
            CtrlPanelHeaterCMP,        -- 179
            Item_RempteDisplModCMP,    -- 180
            RemoteDisplayModuleCMP,    -- 181
            Item_AntenaCMP,            -- 182
            AntenaCMP,                 -- 183
            
            Item_OpeningEnclousure,    -- 184
            OpeningEnclousure,         -- 185
            
            Item_StopButtonEnclosure,  -- 186
            StopButtonEnclosure,       -- 187
            StopButtonEnclosure_Qty,    -- 188

            Item_louvers_in,          -- 189
            louvers_in,               -- 190

            Item_louvers_out,         -- 191
            louvers_out              -- 192

        FROM CZE_Quotes
        WHERE QuoteID = ?
    N*   Error obteniendo datos de la cotización: r   )r   r   r   r   r   s        r   get_quote_datar  u  sk    QEf[[]FNN5+.??$   :1#>?s4   
A 2A
 	A 

AA A 
A9%A44A9c	                 :   Sn	 [        5        n
U
R                  5       nUR                  XXXX#XEU4
5        UR                  5       nU(       a  0 SUS   _SUS   _SUS   _SUS	   _S
US   _SUS   _SUS   _SUS   _SUS   _SUS   _SUS   _SUS   _SUS   _SUS   _SUS   _S US!   _S"US#   _US$   US%   US&   US'   US(   US)   US*   US+   S,.EsS-S-S-5        $  S-S-S-5        g-! , (       d  f       g-= f! [         a  n[        S.U 35        e S-nAff = f)/uE   Obtiene los datos del generador según los parámetros seleccionados.a	  
    SELECT DISTINCT
        CZE_GensetCost.CostID,
        ISNULL(CZE_GensetCost.Cost, 0) * ((100 - ?) / 100) AS price,
        CZE_GensetCost.TechnicalSheet,
        ((100 - ?) / 100) * ? * ISNULL(CZE_GensetCost.Cost, 0) AS Genset_PriceTot,
        CZE_Genset.EngineModel,
        CZE_EngineModel.TechnicalSheet,
        CZE_Genset.Engine_Tier,
        CZE_Genset.Engine_Rpm,
        CZE_Genset.Engine_Power,
        CZE_Genset.Engine_NumberOfCylinder,
        CZE_Genset.Engine_Aspiration,
        CZE_Genset.Engine_Governor_type,
        CZE_Genset.Engine_Control_voltage,
        CZE_Genset.Engine_Battery_type,
        CZE_Genset.Engine_Hotstart_model,
        CZE_Genset.Engine_RadiatorTemp,
        CZE_GensetConfig.AlternatorModel,
        CZE_AlternatorModel.TechnicalSheet,
        CZE_GensetConfig.Powerfactor,
        CZE_GensetConfig.Insulation_System,
        CZE_GensetConfig.Control_System,
        CZE_GensetConfig.Protection,
        CZE_GensetConfig.AvrModel,
        CZE_GensetConfig.Voltage_Regulation,
        CZE_GensetConfig.Class_temp_rise
    FROM
        CZE_Genset
    JOIN
        CZE_EngineModel ON CZE_Genset.EngineModel = CZE_EngineModel.EngineModel
    JOIN
        CZE_FuelType ON CZE_EngineModel.FuelTypeBack = CZE_FuelType.Back
    JOIN
        CZE_EngineBrand ON CZE_EngineModel.EngineBrandID = CZE_EngineBrand.EngineBrandID
    JOIN
        CZE_AlternatorBrand ON CZE_Genset.AlternatorBrandID = CZE_AlternatorBrand.AlternatorBrandID
    JOIN
        CZE_GensetConfig ON CZE_Genset.GensetModel = CZE_GensetConfig.GensetModel
    JOIN
        CZE_AlternatorModel ON CZE_GensetConfig.AlternatorModel = CZE_AlternatorModel.AlternatorModel
    JOIN
        CZE_Voltage ON CZE_GensetConfig.VoltageID = CZE_Voltage.VoltageID
    JOIN
        CZE_Certification ON CZE_GensetConfig.CertificationID = CZE_Certification.CertificationID
    JOIN
        CZE_GensetCost ON CZE_GensetConfig.ConfigID = CZE_GensetCost.ConfigID
    JOIN
        CZE_ControllerBrand ON CZE_GensetCost.ControllerBrandID = CZE_ControllerBrand.BrandID
    WHERE
        CZE_Genset.Active = 1
        AND CZE_EngineBrand.Active = 1
        AND CZE_AlternatorBrand.Active = 1
        AND CZE_FuelType.Front = ?
        AND CZE_Genset.KWOutput = ?
        AND CZE_EngineBrand.EngineBrandID = ?
        AND CZE_AlternatorBrand.AlternatorBrandID = ?
        AND CZE_Voltage.VoltageID = ?
        AND CZE_Certification.CertificationID = ?
        AND CZE_ControllerBrand.BrandID = ?
        AND CZE_GensetCost.Evaluator >= 1
    cost_idr   
unit_pricer   
tech_sheetr   Genset_PriceTotr   EngineModelr   EngineTSheetr   E_Tierr   E_Rpmr   E_Powerr   E_NumberOfCylinderr   E_Aspirationr   E_Governor_typer   E_Control_voltager   E_Battery_typer   E_Hotstart_model   E_RadiatorTemp   AlternatorModel                           )AlternatorTSheetA_PowerfactorA_Insulation_SystemA_Control_SystemA_Protection
A_AvrModelA_Voltage_RegulationA_Class_temp_riseNz&Error obteniendo datos del generador: r   )r2   r7   engine_brandalternator_brandrD   rP   controller_brandr   r   r   r   r   r   r   s                 r   get_genset_datar    s   =E~'[[]FNN5X)Xd *>N#P Q__&Fvay &) !&) &vay	
 "6!9 #F1I fQi VAY vay )&) #F2J &vbz ( %fRj 'r
  %fRj!" &vbz#$ )/r
%+BZ+1":(.r
$*2J"(*,22J)/3 F G H  6qc:;sA   
C< C	C+	C< !C+"C< +
C95C< 9C< <
DDDc                    Sn [        5        nUR                  5       nUR                  UXX4UXgXXXXUUUUUUUUUUU 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)uG   Actualiza los precios y ficha técnica del generador en la cotización.a:  
    UPDATE CZE_Quotes
    SET 
        Genset_CostID = ?,
        Genset_Unit_Price = ?,
        Genset_TSheet = ?,
        Genset_PriceTot = ?,
        EngineModel = ?,
        Engine_TSheet = ?,
        Engine_Tier = ?,
        Engine_Rpm = ?,
        Engine_Power = ?,
        Engine_NumberOfCylinder = ?,
        Engine_Aspiration = ?,
        Engine_Governor_type = ?,
        Engine_Control_voltage = ?,
        Engine_Battery_type = ?,
        Engine_Hotstart_model = ?,
        Engine_RadiatorTemp = ?,
        AlternatorModel = ?,
        Altern_TSheet = ?,
        Altern_Powerfactor = ?,
        Altern_Insulation_Sys = ?,
        Altern_Control_System = ?,
        Altern_Protection = ?,
        Altern_AvrModel = ?,
        Altern_VoltageRegulat = ?,
        Altern_Class_temp_rise = ?
    WHERE QuoteID = ?
    Nz*Error actualizando precios del generador: r   r   r   r   r   r   )r   r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r   r   r   r   s                                 r   update_genset_pricingr     s    E>[[]FNN57
U` ,eFX /N .AQS` 35E|U_ 46G#S T KKM   :1#>?s5   
A. AAA. 
A+'A. +A. .
B8BBc                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u:   Obtiene los datos del breaker según el item seleccionado.aA  
    SELECT 
        CZE_BreakersCatalog.Item_breaker,
        ISNULL(CZE_BreakersCatalog.price, 0) * ? AS price,
        CZE_BreakersCatalog.TechnicalSheet,
        ? * ? * ISNULL(CZE_BreakersCatalog.price, 0) AS price_tot
    FROM 
        CZE_BreakersCatalog
    WHERE
        CZE_BreakersCatalog.Item_breaker = ?
    r   r   r   r   rT   rH   r  	price_totNz$Error obteniendo datos del breaker: r   )item_breaker
qty_gensetr   r   r   r   r   r   s           r   get_breaker_datar  7  s    
E[[]FNN5X<"PQ__&F"1I#AY"()!'	     4QC89A   
B AA0	B &A0'B 0
A>:B >B 
BBBc                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u@   Obtiene los datos de la protección según el item seleccionado.a{  
    SELECT 
        CZE_BreakerProtectionType.Item_breaker_Protection,
        ISNULL(CZE_BreakerProtectionType.price, 0) * ? AS price,
        CZE_BreakerProtectionType.TechnicalSheet,
        ? * ? * ISNULL(CZE_BreakerProtectionType.price, 0) AS price_tot
    FROM 
        CZE_BreakerProtectionType
    WHERE
        CZE_BreakerProtectionType.Item_breaker_Protection = ?
    r   r   r   r   r  Nu*   Error obteniendo datos de la protección: r   )item_protectionr  r   r   r   r   r   r   s           r   get_protection_datar  Z  s    
E[[]FNN5X?"ST__&F"1I#AY"()!'	     :1#>?r  c                 ,   SU SU SU S3n [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        S	U S
U 35        e SnAff = f)uE   Actualiza los precios y ficha técnica del breaker en la cotización.z/
    UPDATE CZE_Quotes
    SET 
        Breakerz_Price = ?,
        Breakerz_TSheet = ?,
        Breaker(_PriceTot = ?
    WHERE QuoteID = ?
    rH   r  r  Nz'Error actualizando precios del breaker r   r  )r   breaker_numbreaker_datar   r   r   r   s          r   update_breaker_pricingr  }  s     } } } E[[]FNN5W%\*[)	#  KKM   7}BqcJK5   
A2 A A!A2 !
A/+A2 /A2 2
B<BBc                 ,   SU SU SU S3n [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        S	U S
U 35        e SnAff = f)uK   Actualiza los precios y ficha técnica de la protección en la cotización.z4
    UPDATE CZE_Quotes
    SET 
        Proyection_tz _Price = ?,
        Proyection_tz!_TSheet = ?,
        Proyection_tr  rH   r  r  Nu-   Error actualizando precios de la protección r   r  )r   protection_numprotection_datar   r   r   r   s          r   update_protection_pricingr    s     $$ %#$ %#$ %E[[]FNN5(-,	#  KKM   =n=MRPQsSTr  c                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	uH   Obtiene los datos de la opción del breaker según el item seleccionado.aQ  
    SELECT 
        CZE_BreakersOptions.Item_breaker_options,
        ISNULL(CZE_BreakersOptions.price, 0) * ? AS price,
        CZE_BreakersOptions.TechnicalSheet,
        ? * ? * ISNULL(CZE_BreakersOptions.price, 0) AS price_tot
    FROM 
        CZE_BreakersOptions
    WHERE
        CZE_BreakersOptions.Item_breaker_options = ?
    r   r   r   r   r  Nu.   Error obteniendo datos de opción de breaker: r   item_optionr  r   r   r   r   r   r   s           r   get_breaker_option_datar    s    
E[[]FNN5X;"OP__&F"1I#AY"()!'	     >qcBCr  c           
         SSSSSSS.nUR                  U5      nU(       d  [        SU 35      eS	U U S
U U SU U S3
n [        5        nUR                  5       nUR	                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n	[        SU SU SU	 35        e Sn	A	ff = f)uS   Actualiza los precios y ficha técnica de la opción del breaker en la cotización.Sunt_tSunt_wGFIAuxiliary_c	Breaker_LMotorized_B)sunt_tsunt_wgfiaux_c	breaker_l	motorized   Tipo de opción no válido: (
    UPDATE CZE_Quotes
    SET 
        _Price = ?,
        _TSheet = ?,
        r  rH   r  r  N&   Error actualizando precios de opción z del breaker r   r  
ValueErrorr   r   r   r   r   r   )
r   r  option_typeoption_dataoption_mappingsprefixr   r   r   r   s
             r   update_breaker_option_pricingr    s   
  "O   -F7}EFF	 
 		 		 E[[]FNN5G$L)K(	#  KKM   6{m=Q\P]]_`a_bcds7   
B' A BB' 
B$ B' $B' '
C1CCc                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u>   Obtiene los datos del controlador según el item seleccionado.aZ  
    SELECT DISTINCT
        CZE_ControllerCatalog.Item_controller,
        ISNULL(CZE_ControllerCatalog.price, 0) * ? AS price,
        CZE_ControllerCatalog.TechnicalSheet,
        ? * ? * ISNULL(CZE_ControllerCatalog.price, 0) AS priceTot
    FROM 
        CZE_ControllerCatalog
    WHERE
        CZE_ControllerCatalog.Item_controller = ?
    r   r   r   r   r  Nz(Error obteniendo datos del controlador: r   )item_controllerr  r   r   r   r   r   r   s           r   get_controller_datar    s    
E[[]FNN5X?"ST__&F"1I#AY"()!'	     8<=r  c                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u@   Obtiene los datos del precalentador según el item seleccionado.af  
    SELECT 
        CZE_ControllerPreheater.Item_preheater_volt,
        ISNULL(CZE_ControllerPreheater.price, 0) * ? AS price,
        CZE_ControllerPreheater.TechnicalSheet,
        ? * ? * ISNULL(CZE_ControllerPreheater.price, 0) AS priceTot
    FROM 
        CZE_ControllerPreheater
    WHERE
        CZE_ControllerPreheater.Item_preheater_volt = ?
    r   r   r   r   r  Nz*Error obteniendo datos del precalentador: r   )item_preheaterr  r   r   r   r   r   r   s           r   get_preheater_datar  $  s    
E[[]FNN5X>"RS__&F"1I#AY"()!'	     :1#>?r  c                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	uG   Obtiene los datos del cargador de batería según el item seleccionado.ar  
    SELECT 
        CZE_ControllerBattCharger.Item_batterycharger,
        ISNULL(CZE_ControllerBattCharger.price, 0) * ? AS price,
        CZE_ControllerBattCharger.TechnicalSheet,
        ? * ? * ISNULL(CZE_ControllerBattCharger.price, 0) AS priceTot
    FROM 
        CZE_ControllerBattCharger
    WHERE
        CZE_ControllerBattCharger.Item_batterycharger = ?
    r   r   r   r   r  Nu1   Error obteniendo datos del cargador de batería: r   )item_chargerr  r   r   r   r   r   r   s           r   get_battery_charger_datar  E  s    
E[[]FNN5X<"PQ__&F"1I#AY"()!'	     A!EFr  c                    Sn [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u8   Actualiza los precios del controlador en la cotización.z
    UPDATE CZE_Quotes
    SET 
        controller_Price = ?,
        controller_TSheet = ?,
        ControlModel_PriceTot = ?
    WHERE QuoteID = ?
    rH   r  r  Nz,Error actualizando precios del controlador: r  )r   controller_datar   r   r   r   s         r   update_controller_pricingr  f  s    E[[]FNN5(-,	#  KKM   <QC@A5   
A( A AA( 
A%!A( %A( (
B2BBc                    Sn [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u:   Actualiza los precios del precalentador en la cotización.z
    UPDATE CZE_Quotes
    SET 
        CtrlVotlOper_Price = ?,
        CtrlVotlOper_TSheet = ?,
        CtrlVotlOper_PriceTot = ?
    WHERE QuoteID = ?
    rH   r  r  Nz.Error actualizando precios del precalentador: r  )r   preheater_datar   r   r   r   s         r   update_preheater_pricingr    s    E[[]FNN5w'|,{+	#  KKM   >qcBCr  c                    Sn [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)uA   Actualiza los precios del cargador de batería en la cotización.z
    UPDATE CZE_Quotes
    SET 
        BateryCharger_Price = ?,
        BateryCharger_TSheet = ?,
        BateryCharger_PriceTot = ?
    WHERE QuoteID = ?
    rH   r  r  Nu5   Error actualizando precios del cargador de batería: r  )r   charger_datar   r   r   r   s         r   update_battery_charger_pricingr    s    E[[]FNN5W%\*[)	#  KKM   EaSIJr  c           	      D   Sn [        5        nUR                  5       nUR                  XCX1X 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	uJ   Obtiene los datos de la opción del controlador que tiene cantidad propia.af  
    SELECT 
        CZE_ControllerOptions.Item_controller_options,
        ISNULL(CZE_ControllerOptions.price, 0) * ? AS price,
        CZE_ControllerOptions.TechnicalSheet,
        ? * ? * ? * ISNULL(CZE_ControllerOptions.price, 0) AS priceTot
    FROM 
        CZE_ControllerOptions
    WHERE
        CZE_ControllerOptions.Item_controller_options = ?
    r   r   r   r   r  N3   Error obteniendo datos de opción del controlador: r   	r  r  qty_itemr   r   r   r   r   r   s	            r   get_controller_option_qty_datar    s    
E[[]FNN5hH"Z[__&F"1I#AY"()!'	     CA3GHr  c                    Sn [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u4   Actualiza los precios del DSE2157 en la cotización.z
    UPDATE CZE_Quotes
    SET 
        DSE2157_Price = ?,
        DSE2157_TSheet = ?,
        DSE2157_PriceTot = ?
    WHERE QuoteID = ?
    rH   r  r  Nz'Error actualizando precios de DSE2157: r  r   r  r   r   r   r   s         r   update_dse2157_pricingr        E[[]FNN5W\"[!	#  KKM   7s;<r  c                    Sn [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u4   Actualiza los precios del DSE2548 en la cotización.z
    UPDATE CZE_Quotes
    SET 
        DSE2548_Price = ?,
        DSE2548_TSheet = ?,
        DSE2548_PriceTot = ?
    WHERE QuoteID = ?
    rH   r  r  Nz'Error actualizando precios de DSE2548: r  r  s         r   update_dse2548_pricingr    r  r  c                    Sn [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u9   Actualiza los precios del ComapDSE2157 en la cotización.z
    UPDATE CZE_Quotes
    SET 
        ComapDSE2157_Price = ?,
        ComapDSE2157_TSheet = ?,
        ComapDSE2157_PriceTot = ?
    WHERE QuoteID = ?
    rH   r  r  Nz,Error actualizando precios de ComapDSE2157: r  r  s         r   update_comap_dse2157_pricingr        E[[]FNN5W\"[!	#  KKM   <QC@Ar  c                    Sn [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u9   Actualiza los precios del ComapDSE2548 en la cotización.z
    UPDATE CZE_Quotes
    SET 
        ComapDSE2548_Price = ?,
        ComapDSE2548_TSheet = ?,
        ComapDSE2548_PriceTot = ?
    WHERE QuoteID = ?
    rH   r  r  Nz,Error actualizando precios de ComapDSE2548: r  r  s         r   update_comap_dse2548_pricingr  %  r  r  c                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u0   Obtiene los datos de la opción del controlador.ab  
    SELECT 
        CZE_ControllerOptions.Item_controller_options,
        ISNULL(CZE_ControllerOptions.price, 0) * ? AS price,
        CZE_ControllerOptions.TechnicalSheet,
        ? * ? * ISNULL(CZE_ControllerOptions.price, 0) AS priceTot
    FROM 
        CZE_ControllerOptions
    WHERE
        CZE_ControllerOptions.Item_controller_options = ?
    r   r   r   r   r  Nr  r   r  s           r   get_controller_option_datar  ?  s    
E[[]FNN5X;"OP__&F"1I#AY"()!'	     CA3GHr  c           	         SSSSSSSSS	.nUR                  US
5      u  pEU(       d  [        SU 35      eSU SU SU S3n[        U5         [        5        nUR	                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n	[        SU SU	 35        e Sn	A	ff = f)uF   Actualiza los precios de la opción del controlador en la cotización.)r  r  )r   CtrlPanelHeat)RempteDisplModr   )r   r   )r   r   )r  r  )r  CtrlPanelHeatCMP)RempteDisplModCMPr"  )comap_dse890panel_heaterremote_displayantenadse890	antenaCMPpanel_heaterCMPremote_displayCMPNNr  r  r  r  r  rH   r  r  Nr  r   )r  r  r   r   r   r   r   r   
r   r  r  r  price_prefixtotal_prefixr   r   r   r   s
             r    update_controller_option_pricingr/  `  s   
 7<>&&/EG
O "1!4!4[,!OL7}EFF	 
 		 		 E 
%L[[]FNN5W\"[!	#  KKM   6{m2aSIJs7   
B1 A B B1  
B.*B1 .B1 1
C;CCc                 H   Sn [        5        nUR                  5       n	U	R                  XvXeX UX45        U	R                  5       n
U
(       a  U
S   U
S   U
S   U
S   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	uD   Obtiene los datos de la caseta según los parámetros seleccionados.a<  
    SELECT DISTINCT
        CZE_EnclosureConfig.ConfigID,
        ISNULL(CZE_EnclosureConfig.Cost, 0) * ? AS price,
        CZE_EnclosureConfig.TechnicalSheet,
        ? * ? * ISNULL(CZE_EnclosureConfig.Cost, 0) AS priceTot
    FROM
        CZE_EnclosureConfig
    WHERE
        CZE_EnclosureConfig.CertificationID = ?
        AND CZE_EnclosureConfig.Fueltype = ?
        AND CZE_EnclosureConfig.Item_Enclosure_type = ?
        AND CZE_EnclosureConfig.KWOutput = ?
        AND CZE_EnclosureConfig.Item_Enclosure_Mat = ?
        AND CZE_EnclosureConfig.Evaluator >= 1
    r   r   r   r   )	config_idrH   r  r  Nz%Error obteniendo datos de la caseta: r   )r2   r7   rP   rc   enclosure_matr  r   r   r   r   r   r   s               r   get_enclosure_datar3    s    E"[[]FNN5XCS`n )#: ;__&F!'#AY"()!'	     5aS9:sA   
B AA2	B (A2)B 2
B <B  B 
B!BB!c           	      D   Sn [        5        nUR                  5       nUR                  XSX1X 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n	[        SU	 35        e Sn	A	ff = f)	uK   Obtiene los datos de la iluminación (AC o DC) según el item seleccionado.aN  
    SELECT 
        CZE_EnclosureLight.Item_Enclosure_ligth,
        ISNULL(CZE_EnclosureLight.price, 0) * ? AS price,
        CZE_EnclosureLight.TechnicalSheet,
        ? * ? * ? * ISNULL(CZE_EnclosureLight.price, 0) AS priceTot
    FROM 
        CZE_EnclosureLight
    WHERE
        CZE_EnclosureLight.Item_Enclosure_ligth = ?
    r   r   r   r   r  Nu(   Error obteniendo datos de iluminación: r   )

item_lightr  	qty_lightr   is_acr   r   r   r   r   s
             r   get_light_datar8    s    
E[[]FNN5X9"YZ__&F"1I#AY"()!'	     8<=r  c           	      D   Sn [        5        nUR                  5       nUR                  XCX1X 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	uH   Obtiene los datos del calentador de espacio según el item seleccionado.av  
    SELECT 
        CZE_EnclosureSpaceHeater.Item_Enclosure_SHeater,
        ISNULL(CZE_EnclosureSpaceHeater.price, 0) * ? AS price,
        CZE_EnclosureSpaceHeater.TechnicalSheet,
        ? * ? * ? * ISNULL(CZE_EnclosureSpaceHeater.price, 0) AS priceTot
    FROM 
        CZE_EnclosureSpaceHeater
    WHERE
        CZE_EnclosureSpaceHeater.Item_Enclosure_SHeater = ?
    r   r   r   r   r  Nz'Error obteniendo datos del calentador: r   )	item_heaterr  
qty_heaterr   r   r   r   r   r   s	            r   get_space_heater_datar<    s    
E[[]FNN5X:"[\__&F"1I#AY"()!'	     7s;<r  c                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	uB   Obtiene los datos del centro de carga según el item seleccionado.al  
    SELECT 
        CZE_EnclosureLoadCenter.Item_Enclosure_LCenter,
        ISNULL(CZE_EnclosureLoadCenter.price, 0) * ? AS price,
        CZE_EnclosureLoadCenter.TechnicalSheet,
        ? * ? * ISNULL(CZE_EnclosureLoadCenter.price, 0) AS priceTot
    FROM 
        CZE_EnclosureLoadCenter
    WHERE
        CZE_EnclosureLoadCenter.Item_Enclosure_LCenter = ?
    r   r   r   r   r  Nz,Error obteniendo datos del centro de carga: r   )item_centerr  r   r   r   r   r   r   s           r   get_load_center_datar?    s    
E[[]FNN5X;"OP__&F"1I#AY"()!'	     <QC@Ar  c           	         Sn [        5        nUR                  5       nUR                  UUS   US   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u5   Actualiza los precios de la caseta en la cotización.z
    UPDATE CZE_Quotes
    SET 
        Enclosure_ConfigID = ?,
        Enclosure_price = ?,
        Enclosure_TSheet = ?,
        Enclosure_PriceTot = ?
    WHERE QuoteID = ?
    r1  rH   r  r  Nz)Error actualizando precios de la caseta: r  r  s         r   update_enclosure_pricingrA  	  s    E[[]FNN5[!W\"[!#  KKM   9!=>5   
A, AAA, 
A)%A, )A, ,
B
6BB
c                    SSSSS.nUR                  U5      nU(       d  [        SU 35      eSU SU S	U S
3n [        5        nUR                  5       nUR	                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU SU 35        e SnAff = f)z6Actualiza los precios de los componentes de la caseta.r  r!  r$  r'  )light_aclight_dcspace_heaterload_centeru   Tipo de componente no válido: r  z_price = ?,
        r  r  rH   r  r  Nz*Error actualizando precios del componente r   r  )	r   component_typer  component_mappingsr  r   r   r   r   s	            r   "update_enclosure_component_pricingrJ  4	  s    
 %#	  ##N3F:>:JKLL	 
 		 		 E[[]FNN5W\"[!	#  KKM   :>:J"QCPQs6   
B A BB 
BB B 
C )B;;C c           	      D   Sn [        5        nUR                  5       nUR                  XCX1X 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	zCObtiene los datos de opciones de caseta que tienen cantidad propia.aX  
    SELECT 
        CZE_EnclosureOption.Item_Enclosure_options,
        ISNULL(CZE_EnclosureOption.price, 0) * ? AS price,
        CZE_EnclosureOption.TechnicalSheet,
        ? * ? * ? * ISNULL(CZE_EnclosureOption.price, 0) AS priceTot
    FROM 
        CZE_EnclosureOption
    WHERE
        CZE_EnclosureOption.Item_Enclosure_options = ?
    r   r   r   r   r  N-   Error obteniendo datos de opción de caseta: r   r  s	            r   get_enclosure_option_qty_datarM  [	  s    
E[[]FNN5X8"YZ__&F"1I#AY"()!'	     =aSABr  c                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	z<Obtiene los datos de opciones de caseta sin cantidad propia.aT  
    SELECT 
        CZE_EnclosureOption.Item_Enclosure_options,
        ISNULL(CZE_EnclosureOption.price, 0) * ? AS price,
        CZE_EnclosureOption.TechnicalSheet,
        ? * ? * ISNULL(CZE_EnclosureOption.price, 0) AS priceTot
    FROM 
        CZE_EnclosureOption
    WHERE
        CZE_EnclosureOption.Item_Enclosure_options = ?
    r   r   r   r   r  NrL  r   r  s           r   get_enclosure_option_datarO  }	  s    
E[[]FNN5X;"OP__&F"1I#AY"()!'	     =aSABr  c                    SSSSSSSS.nUR                  US	5      u  pEU(       d  [        S
U 35      eSU SU SU S3n [        5        nUR                  5       nUR	                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n	[        SU SU	 35        e Sn	A	ff = f)z3Actualiza los precios de las opciones de la caseta.)r  r  )r  r  )PrewireAccsEncloPrewireAccsEnc)r+  r+  )ReceptautolouverReceptautolouv)r/  r/  )r1  r1  )gfci
receptableprewirer+  receptautolouversopeningEnclousurestopButtonEnclosurer+  r  r  r  r  r  rH   r  r  Nr  r   r  r,  s
             r   update_enclosure_option_pricingr[  	  s    
 ):95CGMO "1!4!4[,!OL7}EFF	 
 		 		 E[[]FNN5W\"[!	#  KKM   6{m2aSIJs7   
B% A BB% 
B"B% "B% %
C/CCc           	      D   Sn [        5        nUR                  5       nUR                  XCX1X 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u9   Obtiene los datos del E-Stop según el item seleccionado.ad  
    SELECT 
        CZE_AddAccesory_Estop.Item_AddAccesory_Estop,
        ISNULL(CZE_AddAccesory_Estop.price, 0) * ? AS price,
        CZE_AddAccesory_Estop.TechnicalSheet,
        ? * ? * ? * ISNULL(CZE_AddAccesory_Estop.price, 0) AS priceTot
    FROM 
        CZE_AddAccesory_Estop
    WHERE
        CZE_AddAccesory_Estop.Item_AddAccesory_Estop = ?
    r   r   r   r   r  Nz#Error obteniendo datos del E-Stop: r   )	
item_estopr  	qty_estopr   r   r   r   r   r   s	            r   get_estop_datar_  	  s    
E[[]FNN5X9"YZ__&F"1I#AY"()!'	     3A378r  c                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	uF   Obtiene los datos del aislador de resorte según el item seleccionado.ah  
    SELECT 
        CZE_AddAccesory_Spring.Item_AddAccesory_Spring,
        ISNULL(CZE_AddAccesory_Spring.price, 0) * ? AS price,
        CZE_AddAccesory_Spring.TechnicalSheet,
        ? * ? * ISNULL(CZE_AddAccesory_Spring.price, 0) AS priceTot
    FROM 
        CZE_AddAccesory_Spring
    WHERE
        CZE_AddAccesory_Spring.Item_AddAccesory_Spring = ?
    r   r   r   r   r  Nz0Error obteniendo datos del aislador de resorte: r   )item_springr  r   r   r   r   r   r   s           r   get_spring_isolator_datarb  	      
E[[]FNN5X;"OP__&F"1I#AY"()!'	     @DEr  c                    Sn [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u3   Actualiza los precios del E-Stop en la cotización.z
    UPDATE CZE_Quotes
    SET 
        EStop_price = ?,
        EStop_TSheet = ?,
        EStop_PriceTot = ?
    WHERE QuoteID = ?
    rH   r  r  Nz'Error actualizando precios del E-Stop: r  r  s         r   update_estop_pricingre  

  r  r  c                    Sn [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u@   Actualiza los precios del aislador de resorte en la cotización.z
    UPDATE CZE_Quotes
    SET 
        SpringIsolator_price = ?,
        SpringIsolator_TSheet = ?,
        SpringIsolator_PriceTot = ?
    WHERE QuoteID = ?
    rH   r  r  Nz4Error actualizando precios del aislador de resorte: r  r  s         r   update_spring_isolator_pricingrg  $
  s    E[[]FNN5W\"[!	#  KKM   DQCHIr  c                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u-   Obtiene los datos de la opción de accesorio.ah  
    SELECT 
        CZE_AddAccesory_Option.Item_AddAccesory_option,
        ISNULL(CZE_AddAccesory_Option.price, 0) * ? AS price,
        CZE_AddAccesory_Option.TechnicalSheet,
        ? * ? * ISNULL(CZE_AddAccesory_Option.price, 0) AS priceTot
    FROM 
        CZE_AddAccesory_Option
    WHERE
        CZE_AddAccesory_Option.Item_AddAccesory_option = ?
    r   r   r   r   r  Nu0   Error obteniendo datos de opción de accesorio: r   r  s           r   get_accessory_option_datari  >
  rc  r  c                    0 SS_SS_SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS _nUR                  US!5      u  pEU(       d  [        S"U 35      eS#U S$U S%U S&3n [        5        nUR                  5       nUR	                  UUS'   US(   US)   U 45        UR                  5         S*S*S*5        g*! , (       d  f       g*= f! [         a  n	[        S+U S,U	 35        e S*n	A	ff = f)-z4Actualiza los precios de las opciones de accesorios.band_heater)r4  r4  
pmg_update)r6  r6  digital_regulator)r8  DigitalRegulatvoltage_rheostat)r:  VoltageRheostathermal_wrap)r<  r<  base_heater)r>  r>  battery_switch)r@  r@  battery_holder)rB  rB  
oil_heater)rD  rD  oil_level_switch)rF  rF  common_alarm_relay)rH  CommonAlarmRelfunction_relay)rJ  rJ  coolant)rL  rL  oil)rN  rN  disconnect_switch)DisconnectSwitchDisconnectSwitremote_estop)rU  rU  r+  r  r  r  r  r  rH   r  r  Nr  r   r  r,  s
             r   update_accessory_option_pricingr  _
  s   30 	C 	A	
 	6 	3 	< 	< 	0 	@ 	D 	< 	) 	~ 	C  	6!O& "1!4!4[,!OL7}EFF	 
 		 		 E[[]FNN5W\"[!	#  KKM   6{m2aSIJs7   )
C 3A B<3C <
C
C 
C 
C.C))C.c           
      N   Sn [        5        nUR                  5       nUR                  XTXCXU45        UR                  5       nU(       a   US   US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n	[        S	U	 35        e Sn	A	ff = f)
uB   Obtiene los datos del tanque según los parámetros seleccionados.a  
    SELECT DISTINCT
        CZE_TankConfig.ConfigID,
        CZE_TankConfig.CapacityGAL,
        ISNULL(CZE_TankConfig.Cost, 0) * ? AS price,
        CZE_TankConfig.TechnicalSheet,
        ? * ? * ISNULL(CZE_TankConfig.Cost, 0) AS priceTot
    FROM
        CZE_TankConfig
    WHERE
        CZE_TankConfig.KWOutput = ?
        AND CZE_TankConfig.Item_Tank_Autonomy = ?
        AND CZE_TankConfig.Item_Tank_type = ?
        AND CZE_TankConfig.Evaluator >= 1
    r   r   r   r   r   )r1  capacity_galrH   r  r  Nz#Error obteniendo datos del tanque: r   )
r7   rw   	tank_typer  r   r   r   r   r   r   s
             r   get_tank_datar  
  s    E [[]FNN5X9]f"gh__&F!'$*1I#AY"()!'     3A378sA   
B AA5!	B +A5,B 5
B?B B 
B$BB$c                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	uI   Obtiene los datos del contenedor de derrames según el item seleccionado.aB  
    SELECT 
        CZE_TankSpillCont.Item_Tank_SpillCont,
        ISNULL(CZE_TankSpillCont.price, 0) * ? AS price,
        CZE_TankSpillCont.TechnicalSheet,
        ? * ? * ISNULL(CZE_TankSpillCont.price, 0) AS priceTot
    FROM 
        CZE_TankSpillCont
    WHERE
        CZE_TankSpillCont.Item_Tank_SpillCont = ?
    r   r   r   r   r  Nz3Error obteniendo datos del contenedor de derrames: r   )
item_spillr  r   r   r   r   r   r   s           r   get_spill_containment_datar  
  s    
E[[]FNN5X:"NO__&F"1I#AY"()!'	     CA3GHr  c                 D   Sn [        5        nUR                  5       nUR                  X2X!U 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u+   Obtiene los datos de la opción del tanque.a0  
    SELECT 
        CZE_TankOptions.Item_Tank_option,
        ISNULL(CZE_TankOptions.price, 0) * ? AS price,
        CZE_TankOptions.TechnicalSheet,
        ? * ? * ISNULL(CZE_TankOptions.price, 0) AS priceTot
    FROM 
        CZE_TankOptions
    WHERE
        CZE_TankOptions.Item_Tank_option = ?
    r   r   r   r   r  Nu.   Error obteniendo datos de opción del tanque: r   r  s           r   get_tank_option_datar  
  s    
E[[]FNN5X;"OP__&F"1I#AY"()!'	     >qcBCr  c           
      "   Sn [        5        nUR                  5       nUR                  UUS   US   US   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u3   Actualiza los precios del tanque en la cotización.z
    UPDATE CZE_Quotes
    SET 
        Tank_ConfigID = ?,
        Tank_CapacityGAL = ?,
        Tank_price = ?,
        Tank_TSheet = ?,
        Tank_PriceTot = ?
    WHERE QuoteID = ?
    r1  r  rH   r  r  Nz'Error actualizando precios del tanque: r  r  s         r   update_tank_pricingr  
  s    	E[[]FNN5[!^$W\"[!#  KKM   7s;<s5   
A0 AAA0 
A-)A0 -A0 0
B:B		Bc                    SSSSSSSSS	S
SSSS.nUR                  US5      u  pEU(       d  [        SU 35      eSU SU SU S3n [        5        nUR                  5       nUR	                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n	[        SU SU	 35        e Sn	A	ff = f)z1Actualiza los precios de las opciones del tanque.)r]  BreakTraySwitc)r_  FuelLevelSenso)ra  SpillContainme)rc  rc  )re  DualFuelSwitch)rg  rg  )ri  RemoteAlarmPan)rk  rk  )rm  FlammableLiqui)NFPAIdentificatNFPAIdentifica)rq  rq  )rs  rs  )ru  FluidContainme)
break_tray
fuel_level
spill_contoverfill	dual_fuel	high_fuelremote_alarm	vent_pipe	flammablenfpa
no_smokingtank_number
fluid_contr+  r  r  r  r  r  rH   r  r  Nr  r   r  r,  s
             r   update_tank_option_pricingr    s   
 <;<6;9>-;503<O  "1!4!4[,!OL7}EFF	 
 		 		 E[[]FNN5W\"[!	#  KKM   6{m2aSIJs7   
B+ A BB+ 
B($B+ (B+ +
C5CCc           	      D   Sn [        5        nUR                  5       nUR                  XCX2X45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u9   Obtiene los datos de pruebas según el item seleccionado.a  
    SELECT DISTINCT
        CZE_PrjWarTestConfig.ConfigID,
        ISNULL(CZE_PrjWarTestConfig.Cost, 0) * ? AS price,
        CZE_PrjWarTestConfig.Document,
        ? * ? * ISNULL(CZE_PrjWarTestConfig.Cost, 0) AS priceTot
    FROM
        CZE_PrjWarTestConfig
    WHERE
        CZE_PrjWarTestConfig.Item_PrjWar_Testing = ?
        AND CZE_PrjWarTestConfig.KWOutput = ?
        AND CZE_PrjWarTestConfig.Evaluator >= 1
    r   r   r   r   )r1  rH   documentr  Nz#Error obteniendo datos de pruebas: r   )	item_testingr7   r  r   r   r   r   r   r   s	            r   get_testing_datar  H  s    E[[]FNN5X<"[\__&F!'#AY &q	!'	     3A378r  c           
      L   Sn [        5        nUR                  5       nUR                  UUUUUUU 45        UR                  5       nU(       a  US   US   US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)	u>   Obtiene los datos de la garantía según el item seleccionado.a  
    SELECT 
        CZE_PrjWarWarranty.Item_PrjWar_Warranty,
        ISNULL(CZE_PrjWarWarranty.Percentage, 0) AS Percentage,
        ? * ? * ISNULL(CZE_PrjWarWarranty.Percentage, 0) AS warranty_unit_price,
        ? * ? * ? * ISNULL(CZE_PrjWarWarranty.Percentage, 0) AS warranty_price_tot
    FROM 
        CZE_PrjWarWarranty
    WHERE
        CZE_PrjWarWarranty.Item_PrjWar_Warranty = ?
    r   r   r   r   )rT   
percentagerH   r  Nu%   Error obteniendo datos de garantía: r   )	item_warrantyr  genset_unit_pricer   r   r   r   r   r   s	            r   get_warranty_datar  k  s    
E[[]FNN5!!#  __&F"1I"()#AY!'	 $ % &  5aS9:sA   
B AA4 	B *A4+B 4
B>B B 
B#BB#c           	         Sn [        5        nUR                  5       nUR                  UUS   US   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u3   Actualiza los precios de pruebas en la cotización.z
    UPDATE CZE_Quotes
    SET 
        Teasting_ConfigID = ?,
        Teasting_price = ?,
        Teasting_Document = ?,
        Teasting_PriceTot = ?
    WHERE QuoteID = ?
    r1  rH   r  r  Nz'Error actualizando precios de pruebas: r  r  s         r   update_testing_pricingr    s    E[[]FNN5[!WZ [!#  KKM   7s;<rB  c                    Sn [        5        nUR                  5       nUR                  UUS   US   US   U 45        UR                  5         SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)u8   Actualiza los precios de la garantía en la cotización.z
    UPDATE CZE_Quotes
    SET 
        Garanty_Percentage = ?,
        Garanty_price = ?,
        Garanty_PriceTot = ?
    WHERE QuoteID = ?
    r  rH   r  Nu)   Error actualizando precios de garantía: r  r  s         r   update_warranty_pricingr    s    E[[]FNN5\"W[!	#  KKM   9!=>r  c                    Sn [        5        nUR                  5       nUR                  X45        UR                   Vs/ s H  oDS   PM	     nnUR	                  5       nU(       a  [        [        XV5      5      sSSS5        $  SSS5        gs  snf ! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)r  uh  
        SELECT 
            CZE_Quotes.QuoteID,-- 1
            CZE_Quotes.PlateRating,-- 2
            CZE_Quotes.FuelTypeIDBack,-- 3
            CZE_Quotes.FuelTypeFront,-- 4
            CZE_Quotes.KWOutput,-- 5
            CZE_Quotes.EngineBrandID,-- 6
            CZE_Quotes.EngineBrand,-- 7
            CZE_Quotes.AlternatorBrandID,-- 8
            CZE_Quotes.AlternatorBrand,-- 9
            CZE_Quotes.VoltageID,-- 10
            CZE_Quotes.Voltage_Front,-- 11
            CZE_Quotes.CertificationID,-- 12
            CZE_Quotes.Certification,-- 13
            CZE_Quotes.QtyGenset,-- 14
            CZE_Quotes.ControllerBrandID,-- 15
            CZE_Quotes.Controlbrand,-- 16
            CZE_Quotes.Genset_CostID,-- 17
            CZE_Quotes.Genset_Unit_Price,-- 18
            CZE_Quotes.Genset_TSheet,-- 19
            CZE_Quotes.Genset_PriceTot,-- 20
            CZE_Quotes.QtyBreakers,-- 21
            CZE_Quotes.FrontQtyBreakers,-- 22
            CZE_Quotes.Item_breaker1,-- 23
            CZE_Quotes.Breaker1,-- 24
            CZE_Quotes.Breaker1_Price,-- 25
            CZE_Quotes.Breaker1_TSheet,-- 26
            CZE_Quotes.Breaker1_PriceTot,-- 27
            CZE_Quotes.Item_Sunt_t1,-- 28
            CZE_Quotes.Shunt_trip1,-- 29
            CZE_Quotes.Sunt_t1_Price,-- 30
            CZE_Quotes.Sunt_t1_TSheet,-- 31
            CZE_Quotes.Sunt_t1_PriceTot,-- 32
            CZE_Quotes.Item_Sunt_w1,-- 33
            CZE_Quotes.Shunt_trip_wiring1,-- 34
            CZE_Quotes.Sunt_w1_Price,-- 35
            CZE_Quotes.Sunt_w1_TSheet,-- 36
            CZE_Quotes.Sunt_w1_PriceTot,-- 37
            CZE_Quotes.Item_GFI1,-- 38
            CZE_Quotes.GFI1,-- 39
            CZE_Quotes.GFI1_Price,-- 40
            CZE_Quotes.GFI1_TSheet,-- 41
            CZE_Quotes.GFI1_PriceTot,-- 42
            CZE_Quotes.Item_Proyection_t1,-- 43
            CZE_Quotes.Protection_type1,-- 44
            CZE_Quotes.Proyection_t1_Price,-- 45
            CZE_Quotes.Proyection_t1_TSheet,-- 46
            CZE_Quotes.Proyection_t1_PriceTot,-- 47
            CZE_Quotes.Item_Auxiliary_c1,-- 48
            CZE_Quotes.Auxiliary_contacts1,-- 49
            CZE_Quotes.Auxiliary_c1_Price,-- 50
            CZE_Quotes.Auxiliary_c1_TSheet,-- 51
            CZE_Quotes.Auxiliary_c1_PriceTot,-- 52
            CZE_Quotes.Item_Breaker_L1,-- 53
            CZE_Quotes.Breaker_Lock1,-- 54
            CZE_Quotes.Breaker_L1_Price,-- 55
            CZE_Quotes.Breaker_L1_TSheet,-- 56
            CZE_Quotes.Breaker_L1_PriceTot,-- 57
            CZE_Quotes.Item_Motorized_B1,-- 58
            CZE_Quotes.Motorized_Breaker1,-- 59
            CZE_Quotes.Motorized_B1_Price,-- 60
            CZE_Quotes.Motorized_B1_TSheet,-- 61
            CZE_Quotes.Motorized_B1_PriceTot,-- 62
            CZE_Quotes.Item_breaker2,-- 63
            CZE_Quotes.Breaker2,-- 64
            CZE_Quotes.Breaker2_Price,-- 65
            CZE_Quotes.Breaker2_TSheet,-- 66
            CZE_Quotes.Breaker2_PriceTot,-- 67
            CZE_Quotes.Item_Sunt_t2,-- 68
            CZE_Quotes.Shunt_trip2,-- 69
            CZE_Quotes.Sunt_t2_Price,-- 70
            CZE_Quotes.Sunt_t2_TSheet,-- 71
            CZE_Quotes.Sunt_t2_PriceTot,-- 72
            CZE_Quotes.Item_Sunt_w2,-- 73
            CZE_Quotes.Shunt_trip_wiring2,-- 74
            CZE_Quotes.Sunt_w2_Price,-- 75
            CZE_Quotes.Sunt_w2_TSheet,-- 76
            CZE_Quotes.Sunt_w2_PriceTot,-- 77
            CZE_Quotes.Item_GFI2,-- 78
            CZE_Quotes.GFI2,-- 79
            CZE_Quotes.GFI2_Price,-- 80
            CZE_Quotes.GFI2_TSheet,-- 81
            CZE_Quotes.GFI2_PriceTot,-- 82
            CZE_Quotes.Item_Proyection_t2,-- 83
            CZE_Quotes.Protection_type2,-- 84
            CZE_Quotes.Proyection_t2_Price,-- 85
            CZE_Quotes.Proyection_t2_TSheet,-- 86
            CZE_Quotes.Proyection_t2_PriceTot,-- 87
            CZE_Quotes.Item_Auxiliary_c2,-- 88
            CZE_Quotes.Auxiliary_contacts2,-- 89
            CZE_Quotes.Auxiliary_c2_Price,-- 90
            CZE_Quotes.Auxiliary_c2_TSheet,-- 91
            CZE_Quotes.Auxiliary_c2_PriceTot,-- 92
            CZE_Quotes.Item_Breaker_L2,-- 93
            CZE_Quotes.Breaker_Lock2,-- 94
            CZE_Quotes.Breaker_L2_Price,-- 95
            CZE_Quotes.Breaker_L2_TSheet,-- 96
            CZE_Quotes.Breaker_L2_PriceTot,-- 97
            CZE_Quotes.Item_Motorized_B2,-- 98
            CZE_Quotes.Motorized_Breaker2,-- 99
            CZE_Quotes.Motorized_B2_Price,-- 100
            CZE_Quotes.Motorized_B2_TSheet,-- 101
            CZE_Quotes.Motorized_B2_PriceTot,-- 102
            CZE_Quotes.Item_breaker3,-- 103
            CZE_Quotes.Breaker3,-- 104
            CZE_Quotes.Breaker3_Price,-- 105
            CZE_Quotes.Breaker3_TSheet,-- 106
            CZE_Quotes.Breaker3_PriceTot,-- 107
            CZE_Quotes.Item_Sunt_t3,-- 108
            CZE_Quotes.Shunt_trip3,-- 109
            CZE_Quotes.Sunt_t3_Price,-- 110
            CZE_Quotes.Sunt_t3_TSheet,-- 111
            CZE_Quotes.Sunt_t3_PriceTot,-- 112
            CZE_Quotes.Item_Sunt_w3,-- 113
            CZE_Quotes.Shunt_trip_wiring3,-- 114
            CZE_Quotes.Sunt_w3_Price,-- 115
            CZE_Quotes.Sunt_w3_TSheet,-- 116
            CZE_Quotes.Sunt_w3_PriceTot,-- 117
            CZE_Quotes.Item_GFI3,-- 118
            CZE_Quotes.GFI3,-- 119
            CZE_Quotes.GFI3_Price,-- 120
            CZE_Quotes.GFI3_TSheet,-- 121
            CZE_Quotes.GFI3_PriceTot,-- 122
            CZE_Quotes.Item_Proyection_t3,-- 123
            CZE_Quotes.Protection_type3,-- 124
            CZE_Quotes.Proyection_t3_Price,-- 125
            CZE_Quotes.Proyection_t3_TSheet,-- 126
            CZE_Quotes.Proyection_t3_PriceTot,-- 127
            CZE_Quotes.Item_Auxiliary_c3,-- 128
            CZE_Quotes.Auxiliary_contacts3,-- 129
            CZE_Quotes.Auxiliary_c3_Price,-- 130
            CZE_Quotes.Auxiliary_c3_TSheet,-- 131
            CZE_Quotes.Auxiliary_c3_PriceTot,-- 132
            CZE_Quotes.Item_Breaker_L3,-- 133
            CZE_Quotes.Breaker_Lock3,-- 134
            CZE_Quotes.Breaker_L3_Price,-- 135
            CZE_Quotes.Breaker_L3_TSheet,-- 136
            CZE_Quotes.Breaker_L3_PriceTot,-- 137
            CZE_Quotes.Item_Motorized_B3,-- 138
            CZE_Quotes.Motorized_Breaker3,-- 139
            CZE_Quotes.Motorized_B3_Price,-- 140
            CZE_Quotes.Motorized_B3_TSheet,-- 141
            CZE_Quotes.Motorized_B3_PriceTot,-- 142
            CZE_Quotes.Item_controller,-- 143
            CZE_Quotes.ControlModel,-- 144
            CZE_Quotes.controller_Price,-- 145
            CZE_Quotes.controller_TSheet,-- 146
            CZE_Quotes.ControlModel_PriceTot,-- 147
            CZE_Quotes.Item_CtrlPanelHeater,-- 148
            CZE_Quotes.CtrlPanelHeater,-- 149
            CZE_Quotes.CtrlPanelHeater_Price,-- 150
            CZE_Quotes.CtrlPanelHeater_TSheet,-- 151
            CZE_Quotes.CtrlPanelHeat_PriceTot,-- 152
            CZE_Quotes.Item_RempteDisplMod,-- 153
            CZE_Quotes.RemoteDisplayModule,-- 154
            CZE_Quotes.RempteDisplMod_Price,-- 155
            CZE_Quotes.RempteDisplMod_TSheet,-- 156
            CZE_Quotes.RempteDisplMod_PriceTot,-- 157
            CZE_Quotes.Item_Antena,-- 158
            CZE_Quotes.Antena,-- 159
            CZE_Quotes.Antena_Price,-- 160
            CZE_Quotes.Antena_TSheet,-- 161
            CZE_Quotes.Antena_PriceTot,-- 162
            CZE_Quotes.Item_DSE890,-- 163
            CZE_Quotes.DSE890,-- 164
            CZE_Quotes.DSE890_Price,-- 165
            CZE_Quotes.DSE890_TSheet,-- 166
            CZE_Quotes.DSE890_PriceTot,-- 167
            CZE_Quotes.Item_DSE2157,-- 168
            CZE_Quotes.DSE2157,-- 169
            CZE_Quotes.QtyDSE2157,-- 170
            CZE_Quotes.DSE2157_Price,-- 171
            CZE_Quotes.DSE2157_TSheet,-- 172
            CZE_Quotes.DSE2157_PriceTot,-- 173
            CZE_Quotes.Item_DSE2548,-- 174
            CZE_Quotes.DSE2548,-- 175
            CZE_Quotes.QtyDSE2548,-- 176
            CZE_Quotes.DSE2548_Price,-- 177
            CZE_Quotes.DSE2548_TSheet,-- 178
            CZE_Quotes.DSE2548_PriceTot,-- 179
            
            CZE_Quotes.Item_ComapDSE890,-- 180
            CZE_Quotes.ComapDSE890,-- 181
            CZE_Quotes.ComapDSE890_Price,-- 182
            CZE_Quotes.ComapDSE890_TSheet,-- 183
            CZE_Quotes.ComapDSE890_PriceTot,-- 184

            CZE_Quotes.Item_ComapDSE2157,-- 185
            CZE_Quotes.ComapDSE2157,-- 186
            CZE_Quotes.QtyComapDSE2157,-- 187
            CZE_Quotes.ComapDSE2157_Price,-- 188
            CZE_Quotes.ComapDSE2157_TSheet,-- 189
            CZE_Quotes.ComapDSE2157_PriceTot,-- 190
            CZE_Quotes.Item_ComapDSE2548,-- 191
            CZE_Quotes.ComapDSE2548,-- 192
            CZE_Quotes.QtyComapDSE2548,-- 193
            CZE_Quotes.ComapDSE2548_Price,-- 194
            CZE_Quotes.ComapDSE2548_TSheet,-- 195
            CZE_Quotes.ComapDSE2548_PriceTot,-- 196
            CZE_Quotes.Item_CtrlVotlOper,-- 197
            CZE_Quotes.CtrlVotlOper,-- 198
            CZE_Quotes.CtrlVotlOper_Price,-- 199
            CZE_Quotes.CtrlVotlOper_TSheet,-- 200
            CZE_Quotes.CtrlVotlOper_PriceTot,-- 201
            CZE_Quotes.Item_BateryCharger,-- 202
            CZE_Quotes.BateryCharger,-- 203
            CZE_Quotes.BateryCharger_Price,-- 204
            CZE_Quotes.BateryCharger_TSheet,-- 205
            CZE_Quotes.BateryCharger_PriceTot,-- 206
            CZE_Quotes.Item_Enclosuree_type,-- 207
            CZE_Quotes.Enclosure,-- 208
            CZE_Quotes.Item_Eclousure_Mat,-- 209
            CZE_Quotes.EnclosureType,-- 210
            CZE_Quotes.Enclosure_ConfigID,-- 211
            CZE_Quotes.Enclosure_price,-- 212
            CZE_Quotes.Enclosure_TSheet,-- 213
            CZE_Quotes.Enclosure_PriceTot,-- 214
            CZE_Quotes.Item_GFCI120V,-- 215
            CZE_Quotes.GFCI120V,-- 216
            CZE_Quotes.QtyGFCI120V,-- 217
            CZE_Quotes.GFCI120V_Price,-- 218
            CZE_Quotes.GFCI120V_TSheet,-- 219
            CZE_Quotes.GFCI120V_PriceTot,-- 220
            CZE_Quotes.Item_Receptable120V,-- 221
            CZE_Quotes.Receptable120V,-- 222
            CZE_Quotes.QtyReceptable120V,-- 223
            CZE_Quotes.Receptable120V_Price,-- 224
            CZE_Quotes.Receptable120V_TSheet,-- 225
            CZE_Quotes.Receptable120V_PriceTot,-- 226
            CZE_Quotes.Item_Enclosure_ligthAC,-- 227
            CZE_Quotes.lightAC,-- 228
            CZE_Quotes.QtylightAC,-- 229
            CZE_Quotes.lightAC_price,-- 230
            CZE_Quotes.lightAC_TSheet,-- 231
            CZE_Quotes.lightAC_PriceTot,-- 232
            CZE_Quotes.Item_Enclosure_ligthDC,-- 233
            CZE_Quotes.lightDC,-- 234
            CZE_Quotes.QtylightDC,-- 235
            CZE_Quotes.lightDC_price,-- 236
            CZE_Quotes.lightDC_TSheet,-- 237
            CZE_Quotes.lightDC_PriceTot,-- 238
            CZE_Quotes.Item_Enclosure_SHeater,-- 239
            CZE_Quotes.SpaceHeater,-- 240
            CZE_Quotes.QtySpaceHeater,-- 241
            CZE_Quotes.SpaceHeater_price,-- 242
            CZE_Quotes.SpaceHeater_TSheet,-- 243
            CZE_Quotes.SpaceHeater_PriceTot,-- 244
            CZE_Quotes.Item_Enclosure_LCenter,-- 245
            CZE_Quotes.LoadCenter,-- 246
            CZE_Quotes.LoadCenter_price,-- 247
            CZE_Quotes.LoadCenter_TSheet,-- 248
            CZE_Quotes.LoadCenter_PriceTot,-- 249
            CZE_Quotes.Item_PrewireAccsEncl,-- 250
            CZE_Quotes.PrewireAccsEnclousure,-- 251
            CZE_Quotes.PrewireAccsEnclo_Price,-- 252
            CZE_Quotes.PrewireAccsEnclo_TSheet,-- 253
            CZE_Quotes.PrewireAccsEnc_PriceTot,-- 254
            CZE_Quotes.Item_autolouvers,-- 255
            CZE_Quotes.autolouvers,-- 256
            CZE_Quotes.autolouvers_Price,-- 257
            CZE_Quotes.autolouvers_TSheet,-- 258
            CZE_Quotes.autolouvers_PriceTot,-- 259
            CZE_Quotes.Item_Receptautolouvers,-- 260
            CZE_Quotes.Receptautolouvers,-- 261
            CZE_Quotes.Receptautolouver_Price,-- 262
            CZE_Quotes.Receptautolouver_TSheet,-- 263
            CZE_Quotes.Receptautolouv_PriceTot,-- 264
            CZE_Quotes.Item_BandHeater,-- 265
            CZE_Quotes.BandHeater,-- 266
            CZE_Quotes.BandHeater_Price,-- 267
            CZE_Quotes.BandHeater_TSheet,-- 268
            CZE_Quotes.BandHeater_PriceTot,-- 269
            CZE_Quotes.Item_PMGUpdate,-- 270
            CZE_Quotes.PMGUpdate,-- 271
            CZE_Quotes.PMGUpdate_Price,-- 272
            CZE_Quotes.PMGUpdate_TSheet,-- 273
            CZE_Quotes.PMGUpdate_PriceTot,-- 274
            CZE_Quotes.Item_DigitalRegulator,-- 275
            CZE_Quotes.DigitalRegulator,-- 276
            CZE_Quotes.DigitalRegulator_Price,-- 277
            CZE_Quotes.DigitalRegulator_TSheet,-- 278
            CZE_Quotes.DigitalRegulat_PriceTot,-- 279
            CZE_Quotes.Item_VoltageRheostat,-- 280
            CZE_Quotes.VoltageRheostat,-- 281
            CZE_Quotes.VoltageRheostat_Price,-- 282
            CZE_Quotes.VoltageRheostat_TSheet,-- 283
            CZE_Quotes.VoltageRheosta_PriceTot,-- 284
            CZE_Quotes.Item_ThermalWrap,-- 285
            CZE_Quotes.ThermalWrap,-- 286
            CZE_Quotes.ThermalWrap_Price,-- 287
            CZE_Quotes.ThermalWrap_TSheet,-- 288
            CZE_Quotes.ThermalWrap_PriceTot,-- 289
            CZE_Quotes.Item_BaseHeater,-- 290
            CZE_Quotes.BaseHeater,-- 291
            CZE_Quotes.BaseHeater_Price,-- 292
            CZE_Quotes.BaseHeater_TSheet,-- 293
            CZE_Quotes.BaseHeater_PriceTot,-- 294
            CZE_Quotes.Item_BatterySwitch,-- 295
            CZE_Quotes.BatterySwitch,-- 296
            CZE_Quotes.BatterySwitch_Price,-- 297
            CZE_Quotes.BatterySwitch_TSheet,-- 298
            CZE_Quotes.BatterySwitch_PriceTot,-- 299
            CZE_Quotes.Item_BatteryHolder,-- 300
            CZE_Quotes.BatteryHolder,-- 301
            CZE_Quotes.BatteryHolder_Price,-- 302
            CZE_Quotes.BatteryHolder_TSheet,-- 303
            CZE_Quotes.BatteryHolder_PriceTot,-- 304
            CZE_Quotes.Item_OilHeater,-- 305
            CZE_Quotes.OilHeater,-- 306
            CZE_Quotes.OilHeater_Price,-- 307
            CZE_Quotes.OilHeater_TSheet,-- 308
            CZE_Quotes.OilHeater_PriceTot,-- 309
            CZE_Quotes.Item_OilLevelSwitch,-- 310
            CZE_Quotes.OilLevelSwitch,-- 311
            CZE_Quotes.OilLevelSwitch_Price,-- 312
            CZE_Quotes.OilLevelSwitch_TSheet,-- 313
            CZE_Quotes.OilLevelSwitch_PriceTot,-- 314
            CZE_Quotes.Item_CommonAlarmRelay,-- 315
            CZE_Quotes.CommonAlarmRelay,-- 316
            CZE_Quotes.CommonAlarmRelay_Price,-- 317
            CZE_Quotes.CommonAlarmRelay_TSheet,-- 318
            CZE_Quotes.CommonAlarmRel_PriceTot,-- 319
            CZE_Quotes.Item_FunctionRelay,-- 320
            CZE_Quotes.FunctionRelay,-- 321
            CZE_Quotes.FunctionRelay_Price,-- 322
            CZE_Quotes.FunctionRelay_TSheet,-- 323
            CZE_Quotes.FunctionRelay_PriceTot,-- 324
            CZE_Quotes.Item_Coolant,-- 325
            CZE_Quotes.Coolant,-- 326
            CZE_Quotes.Coolant_Price,-- 327
            CZE_Quotes.Coolant_TSheet,-- 328
            CZE_Quotes.Coolant_PriceTot,-- 329
            CZE_Quotes.Item_Oil,-- 330
            CZE_Quotes.Oil,-- 331
            CZE_Quotes.Oil_Price,-- 332
            CZE_Quotes.Oil_TSheet,-- 333
            CZE_Quotes.Oil_PriceTot,-- 334
            CZE_Quotes.Item_DisconnectSwitches,-- 335
            CZE_Quotes.DisconnectSwitches,-- 336
            CZE_Quotes.DisconnectSwitch_Price,-- 337
            CZE_Quotes.DisconnectSwitch_TSheet,-- 338
            CZE_Quotes.DisconnectSwit_PriceTot,-- 339
            CZE_Quotes.Item_AddAccesory_Estop,-- 340
            CZE_Quotes.EStop,-- 341
            CZE_Quotes.QtyEStop,-- 342
            CZE_Quotes.EStop_price,-- 343
            CZE_Quotes.EStop_TSheet,-- 344
            CZE_Quotes.EStop_PriceTot,-- 345
            CZE_Quotes.Item_RemoteEStop,-- 346
            CZE_Quotes.RemoteEStop,-- 347
            CZE_Quotes.RemoteEStop_Price,-- 348
            CZE_Quotes.RemoteEStop_TSheet,-- 349
            CZE_Quotes.RemoteEStop_PriceTot,-- 350
            CZE_Quotes.Item_AddAccesory_Spring,-- 351
            CZE_Quotes.SpringIsolator,-- 352
            CZE_Quotes.SpringIsolator_price,-- 353
            CZE_Quotes.SpringIsolator_TSheet,-- 354
            CZE_Quotes.SpringIsolator_PriceTot,-- 355
            CZE_Quotes.Item_Tank_Autonomy,-- 356
            CZE_Quotes.TankCapacity,-- 357
            CZE_Quotes.Item_Tank_type,-- 358
            CZE_Quotes.TankType,-- 359
            CZE_Quotes.Tank_ConfigID,-- 360
            CZE_Quotes.Tank_CapacityGAL,-- 361
            CZE_Quotes.Tank_price,-- 362
            CZE_Quotes.Tank_TSheet,-- 363
            CZE_Quotes.Tank_PriceTot,-- 364
            CZE_Quotes.Item_BreakTraySwitch,-- 365
            CZE_Quotes.BreakTraySwitch,-- 366
            CZE_Quotes.BreakTraySwitch_Price,-- 367
            CZE_Quotes.BreakTraySwitch_TSheet,-- 368
            CZE_Quotes.BreakTraySwitc_PriceTot,-- 369
            CZE_Quotes.Item_FuelLevelSensor,-- 370
            CZE_Quotes.FuelLevelSensor,-- 371
            CZE_Quotes.FuelLevelSensor_Price,-- 372
            CZE_Quotes.FuelLevelSensor_TSheet,-- 373
            CZE_Quotes.FuelLevelSenso_PriceTot,-- 374
            CZE_Quotes.Item_Tank_SpillCont,-- 375
            CZE_Quotes.SpillContainment,-- 376
            CZE_Quotes.SpillContainment_Price,-- 377
            CZE_Quotes.SpillContainment_TSheet,-- 378
            CZE_Quotes.SpillContainme_PriceTot,-- 379
            CZE_Quotes.Item_OverfillValve,-- 380
            CZE_Quotes.OverfillValve,-- 381
            CZE_Quotes.OverfillValve_Price,-- 382
            CZE_Quotes.OverfillValve_TSheet,-- 383
            CZE_Quotes.OverfillValve_PriceTot,-- 384
            CZE_Quotes.Item_DualFuelSwitch,-- 385
            CZE_Quotes.DualFuelSwitches,-- 386
            CZE_Quotes.DualFuelSwitches_Price,-- 387
            CZE_Quotes.DualFuelSwitches_TSheet,-- 388
            CZE_Quotes.DualFuelSwitch_PriceTot,-- 389
            CZE_Quotes.Item_HighFuelSwitch,-- 390
            CZE_Quotes.HighFuelSwitch,-- 391
            CZE_Quotes.HighFuelSwitch_Price,-- 392
            CZE_Quotes.HighFuelSwitch_TSheet,-- 393
            CZE_Quotes.HighFuelSwitch_PriceTot,-- 394
            CZE_Quotes.Item_RemoteAlarmP,-- 395
            CZE_Quotes.RemoteAlarmPanel,-- 396
            CZE_Quotes.RemoteAlarmPanel_Price,-- 397
            CZE_Quotes.RemoteAlarmPanel_TSheet,-- 398
            CZE_Quotes.RemoteAlarmPan_PriceTot,-- 399
            CZE_Quotes.Item_VentPipe,-- 400
            CZE_Quotes.VentPipe,-- 401
            CZE_Quotes.VentPipe_Price,-- 402
            CZE_Quotes.VentPipe_TSheet,-- 403
            CZE_Quotes.VentPipe_PriceTot,-- 404
            CZE_Quotes.Item_FlammableL,-- 405
            CZE_Quotes.FlammableLiquids,-- 406
            CZE_Quotes.FlammableLiquids_Price,-- 407
            CZE_Quotes.FlammableLiquids_TSheet,-- 408
            CZE_Quotes.FlammableLiqui_PriceTot,-- 409
            CZE_Quotes.Item_NFPAIdentificat,-- 410
            CZE_Quotes.NFPAIdentification,-- 411
            CZE_Quotes.NFPAIdentificat_Price,-- 412
            CZE_Quotes.NFPAIdentificat_TSheet,-- 413
            CZE_Quotes.NFPAIdentifica_PriceTot,-- 414
            CZE_Quotes.Item_NoSmoking,-- 415
            CZE_Quotes.NoSmoking,-- 416
            CZE_Quotes.NoSmoking_Price,-- 417
            CZE_Quotes.NoSmoking_TSheet,-- 418
            CZE_Quotes.NoSmoking_PriceTot,-- 419
            CZE_Quotes.Item_TankNumber,-- 420
            CZE_Quotes.TankNumber,-- 421
            CZE_Quotes.TankNumber_Price,-- 422
            CZE_Quotes.TankNumber_TSheet,-- 423
            CZE_Quotes.TankNumber_PriceTot,-- 424
            CZE_Quotes.Item_FluidContainment,-- 425
            CZE_Quotes.FluidContainment,-- 426
            CZE_Quotes.FluidContainment_Price,-- 427
            CZE_Quotes.FluidContainment_TSheet,-- 428
            CZE_Quotes.FluidContainme_PriceTot,-- 429
            CZE_Quotes.Project,-- 430
            CZE_Quotes.Item_PrjWar_Warranty,-- 431
            CZE_Quotes.Garanty,-- 432
            CZE_Quotes.Garanty_Percentage,-- 433
            CZE_Quotes.Garanty_price,-- 434
            CZE_Quotes.Garanty_PriceTot,-- 435
            CZE_Quotes.Item_PrjWar_Testing,-- 436
            CZE_Quotes.Teasting,-- 437
            CZE_Quotes.Teasting_ConfigID,-- 438
            CZE_Quotes.Teasting_price,-- 439
            CZE_Quotes.Teasting_Document,-- 440
            CZE_Quotes.Teasting_PriceTot,-- 441
            CZE_Quotes.ReqCustomer,-- 442
            CZE_Quotes.EngineModel,-- 443
            CZE_Quotes.Engine_TSheet,-- 444
            CZE_Quotes.Engine_Tier,-- 445
            CZE_Quotes.Engine_Rpm,-- 446
            CZE_Quotes.Engine_Power,-- 447
            CZE_Quotes.Engine_NumberOfCylinder,-- 448
            CZE_Quotes.Engine_Aspiration,-- 449
            CZE_Quotes.Engine_Governor_type,-- 450
            CZE_Quotes.Engine_Control_voltage,-- 451
            CZE_Quotes.Engine_Battery_type,-- 452
            CZE_Quotes.Engine_Hotstart_model,-- 453
            CZE_Quotes.Engine_RadiatorTemp,-- 454
            CZE_Quotes.AlternatorModel,-- 455
            CZE_Quotes.Altern_TSheet,-- 456
            CZE_Quotes.Altern_Powerfactor,-- 457
            CZE_Quotes.Altern_Insulation_Sys,-- 458
            CZE_Quotes.Altern_Control_System,-- 459
            CZE_Quotes.Altern_Protection,-- 460
            CZE_Quotes.Altern_AvrModel,-- 461
            CZE_Quotes.Altern_VoltageRegulat,-- 462
            CZE_Quotes.Altern_Class_temp_rise,-- 463
			(
			SELECT
				CASE
					WHEN CZE_Voltage.Phases = 'Single' THEN 1
					WHEN CZE_Voltage.Phases = 2 THEN 2
					WHEN CZE_Voltage.Phases = 3 THEN 3
				END
			FROM
				CZE_Voltage
			WHERE 
				CZE_Voltage.VoltageID = CZE_Quotes.VoltageID
			) AS Phases,-- 464
			(
			SELECT
				CONCAT( UPPER (CZE_TankType.description),' - ', CZE_TankConfig.CapacityGAL, ' GAL',' - ', CZE_TankAutonomy.description)
				/*
				CZE_TankType.description,
				CZE_TankConfig.CapacityGAL,
				CZE_TankAutonomy.description
				*/
			FROM
				CZE_TankConfig
			LEFT JOIN
				CZE_TankType ON CZE_TankConfig.Item_Tank_type = CZE_TankType.Item_Tank_type
			LEFT JOIN
				CZE_TankAutonomy ON CZE_TankConfig.Item_Tank_Autonomy = CZE_TankAutonomy.Item_Tank_Autonomy
			WHERE 
				CZE_TankConfig.ConfigID = CZE_Quotes.Tank_ConfigID
			) AS BaseTank,-- 465
			(
			SELECT
				CONCAT( 'AUTONOMY ', CZE_TankAutonomy.description)
			FROM
				CZE_TankConfig
			LEFT JOIN
				CZE_TankType ON CZE_TankConfig.Item_Tank_type = CZE_TankType.Item_Tank_type
			LEFT JOIN
				CZE_TankAutonomy ON CZE_TankConfig.Item_Tank_Autonomy = CZE_TankAutonomy.Item_Tank_Autonomy
			WHERE 
				CZE_TankConfig.ConfigID = CZE_Quotes.Tank_ConfigID
			) AS TankAutonomy,-- 466
			(
			SELECT
				CONCAT (CZE_EnclosureMaterial.description, ' - ', CZE_EnclosureType.Front)
			FROM
				CZE_EnclosureConfig
			LEFT JOIN
				CZE_EnclosureMaterial ON CZE_EnclosureConfig.Item_Enclosure_Mat = CZE_EnclosureMaterial.Item_Eclousure_Mat
			LEFT JOIN
				CZE_EnclosureType ON CZE_EnclosureConfig.Item_Enclosure_type = CZE_EnclosureType.Item_Enclosuree_type
			WHERE 
				CZE_EnclosureConfig.ConfigID = CZE_Quotes.Enclosure_ConfigID
			) AS AcousticEnclosure,-- 467
            CZE_Quotes.CustomerCompany,-- 468
            CZE_Quotes.CustomerAddress,-- 469
            CZE_Quotes.CustomerContact,-- 470
            CZE_Quotes.CustomerEmail,-- 471
            CZE_Quotes.CustomerTel,-- 472
            CZE_Quotes.SellerName,-- 473
            CZE_Quotes.SellerEmail,-- 474
            CZE_Quotes.SellerPhone, -- 475
            CZE_Quotes.Destiny_Country, -- 476
            CZE_Quotes.Destiny_State, -- 477
            CZE_Quotes.Country_Discount, --478
            CZE_Quotes.Commercial_Offer, --479


            CZE_Quotes.Item_CtrlPanelHeaterCMP, --480
            CZE_Quotes.CtrlPanelHeaterCMP, --481
            CZE_Quotes.CtrlPanelHeaterCMP_Price, --482
            CZE_Quotes.CtrlPanelHeaterCMP_TSheet, --483
            CZE_Quotes.CtrlPanelHeatCMP_PriceTot, --484,

            -- Módulo de Pantalla Remota
            CZE_Quotes.Item_RempteDisplModCMP, --485
            CZE_Quotes.RemoteDisplayModuleCMP, --486
            CZE_Quotes.RempteDisplModCMP_Price, --487
            CZE_Quotes.RempteDisplModCMP_TSheet, --488
            CZE_Quotes.RempteDisplModCMP_PriceTot, --489

            -- Antena CMP GSM / GPS
            CZE_Quotes.Item_AntenaCMP, --490
            CZE_Quotes.AntenaCMP, --491
            CZE_Quotes.AntenaCMP_Price, --492
            CZE_Quotes.AntenaCMP_TSheet, --493
            CZE_Quotes.AntenaCMP_PriceTot, --494

            -- CM3 Ethernet / 4G gateway device
            CZE_Quotes.Item_ComapDSE890, --495
            CZE_Quotes.ComapDSE890, --496
            CZE_Quotes.ComapDSE890_Price, --497
            CZE_Quotes.ComapDSE890_TSheet, --498
            CZE_Quotes.ComapDSE890_PriceTot, --499

            -- CMP-IRB8 Output module
            CZE_Quotes.Item_ComapDSE2157, --500
            CZE_Quotes.ComapDSE2157, --501
            CZE_Quotes.ComapDSE2157_Price, --502
            CZE_Quotes.ComapDSE2157_TSheet, --503
            CZE_Quotes.ComapDSE2157_PriceTot, --504

            -- IGLRA15 Remote annunciator
            CZE_Quotes.Item_ComapDSE2548, --505
            CZE_Quotes.ComapDSE2548, --506
            CZE_Quotes.ComapDSE2548_Price, --507
            CZE_Quotes.ComapDSE2548_TSheet, --508
            CZE_Quotes.ComapDSE2548_PriceTot, --509

            CZE_Quotes.Item_OpeningEnclousure, --510
            CZE_Quotes.OpeningEnclousure, --511
            CZE_Quotes.OpeningEnclousure_Price, --512
            CZE_Quotes.OpeningEnclousure_TSheet, --513
            CZE_Quotes.OpeningEnclousure_PriceTot, --514

            CZE_Quotes.Item_StopButtonEnclosure, --515
            CZE_Quotes.StopButtonEnclosure, --516
            CZE_Quotes.StopButtonEnclosure_Price, --517
            CZE_Quotes.StopButtonEnclosure_TSheet, --518
            CZE_Quotes.StopButtonEnclosure_PriceTot, --519
            CZE_Quotes.StopButtonEnclosure_Qty, --520


            CZE_Quotes.Item_louvers_in, --521
            CZE_Quotes.louvers_in, --522
            CZE_Quotes.louvers_in_price, --523
            CZE_Quotes.louvers_in_tsheet, --524
            CZE_Quotes.louvers_in_pricetot, --525

            CZE_Quotes.Item_louvers_out, --526
            CZE_Quotes.louvers_out, --527
            CZE_Quotes.louvers_out_price, --528
            CZE_Quotes.louvers_out_tsheet,  --529
            CZE_Quotes.louvers_out_pricetot --530


        FROM CZE_Quotes
        WHERE QuoteID = ?
    r   Nr  	r   r   r   rG   r   dictzipr   r   r   r   r   r   columncolumnsr   r   s           r   get_Definitive_quote_datar    s    \	E|[[]FNN5+. 06/A/AB/AVay/AGB //#CC-.   
 C    :1#>?Q   
B# 1BB,B9	B# BB# B
B B#  B# #
C-B<<Cc                 $   Sn [        5        nUR                  5       nUR                  X45        UR                  5       nU(       a  US   sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)zGObtiene el GensetModel desde la tabla CZE_GensetConfig usando ConfigID.z
    SELECT 
        CZE_GensetConfig.GensetModel
    FROM 
        CZE_GensetCost
    LEFT JOIN
        CZE_GensetConfig ON CZE_GensetCost.ConfigID = CZE_GensetConfig.ConfigID
    WHERE 
        CostID = ?
    r   NzError al obtener GensetModel: r   )genset_cost_idr   r   r   r   r   s         r   get_genset_modelr  =  s    	E[[]FNN5"34__&Fay     .qc23s@   
A1 >A 	A1 A A1  
A.*A1 .A1 1
B;B

Bc                 0   Sn [        5        nUR                  5       nUR                  X45        UR                  5       nU(       a  US   US   S.sSSS5        $  SSS5        g! , (       d  f       g= f! [         a  n[        SU 35        e SnAff = f)zEObtiene la frecuencia y las fases de acuerdo al voltaje seleccionado.zh
    SELECT
        Frecuency,
        Phases
    FROM CZE_Voltage
    WHERE 
        VoltageID = ?
    r   r   )	FrecuencyPhasesNz'Error al obtener los datos de voltaje: r   )
Voltage_IDr   r   r   r   r   s         r   get_frecuencyr  Y  s    E[[]FNN5-0__&F!'$Qi     7s;<sA   
A7 AA&	A7 A&A7 &
A40A7 4A7 7
BBBc                    Sn [        5        nUR                  5       nUR                  X45        UR                   Vs/ s H  oDS   PM	     nnUR	                  5       nU(       a  [        [        XV5      5      sS S S 5        $  S S S 5        g s  snf ! , (       d  f       g = f! [         a  n[        SU 35        e S nAff = f)Nz{
            SELECT 
                CZE_Quotes.RoutePDF
            FROM CZE_Quotes
            WHERE QuoteID = ?
        r   r  r  r  s           r   get_RoutePDFr  w  s    	!Tuk2 4:3E3EF3E!93EF oo'G 12 "!  "! G "!"  	>qcBC	r  c                     Sn [        5        nUR                  5       nUR                  UU U45        UR                  5         S S S 5        g ! , (       d  f       g = f! [         a  n[        SU 35        e S nAff = f)NzO
    UPDATE CZE_Quotes
    SET 
        RoutePDF = ?
    WHERE QuoteID = ?
    zError actualizando RoutePDF: r  )RoutePDFr   r   r   r   r   s         r   update_RoutePDFr    su    E[[]FNN5#  KKM   -aS12s4   
A 5AA 
AA A 
A;'A66A;N)r   )r   T)[Consultas_SQL.conexionr   typingr   r   r"   r)   r/   r3   r8   r<   r@   rE   rK   rN   rQ   rV   r\   r_   ra   rd   rf   rj   rl   rn   rp   rr   ru   rx   rz   r~   r   r   r   r   r   r   r  strr  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r/  r3  r8  r<  r?  rA  rJ  rM  rO  r[  r_  rb  re  rg  ri  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r       r   <module>r     s  
 2 %P			$L(T-^1f5nu"e$9v60088,,((,,.006,.:x(T%NDFRS T#Y \~iX4n F F<8D'TBBB464D4444B+\$NBBB8$NDB'TBB44B0f#LBB<-` F$N82s	l8<:r  