using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Exferia_EntityFramework.Script_Actualizacion
{
    public class Scripts_Version_1116
    {
        public static Version G_VRS_VERSION = new Version("1.1.1.6");
        public static long G_LNG_VERSION = 1116;
        public static int G_INT_TIPO = 0;
        public static string G_STR_SCRIPT =

                                    //AÑADIR el campo operacion a la tabla MAE_Articulos_Embalajes
                                    "IF not exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='operacion' AND TABLE_NAME = 'MAE_Articulos_Embalajes' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE [MAE_Articulos_Embalajes]ADD[operacion] varchar(1) NULL " +
                                    "END " +
                                    //AÑADIR el campo liquido a la tabla PER_Nominas
                                    "IF not exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='liquido' AND TABLE_NAME = 'PER_Nominas' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE [PER_Nominas]ADD[liquido] decimal(18,2) NULL " +
                                    "END " +
                                    //AÑADIR el campo concepto a la tabla PER_Nominas
                                    "IF not exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='concepto' AND TABLE_NAME = 'PER_Nominas' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE [PER_Nominas]ADD[concepto] varchar(5000) NULL " +
                                    "END " +
                                    //MODIFICAR el campo idEmpleado a la tabla PER_Nominas
                                    "IF exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='idEmpleado' AND TABLE_NAME = 'PER_Nominas' AND IS_NULLABLE='NO' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE [PER_Nominas] ALTER COLUMN [idEmpleado] BIGINT NULL " +
                                    "END " +
                                    //AÑADIR el campo idProveedor a la tabla PER_Nominas
                                    "IF not exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='idProveedor' AND TABLE_NAME = 'PER_Nominas' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE [PER_Nominas]ADD[idProveedor] bigint NULL " +
                                         //Relaciones
                                         " ALTER TABLE PER_Nominas WITH CHECK ADD CONSTRAINT [FK_PER_Nominas_MAE_Proveedores] FOREIGN KEY([idProveedor]) REFERENCES MAE_Proveedores ([id]) " +
                                        " ALTER TABLE PER_Nominas CHECK CONSTRAINT [FK_PER_Nominas_MAE_Proveedores] " +
                                    "END " +
                                     //BORRAR campo estado a la tabla PER_NominasVencimientos
                                     "IF exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='estado' AND TABLE_NAME = 'PER_NominasVencimientos' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE [PER_NominasVencimientos] DROP COLUMN [estado] " +
                                    "END " +
                                    //AÑADIR el campo idFormaPago a la tabla MAE_Empleados
                                    "IF not exists " +
                                      "( " +
                                      "    SELECT * " +
                                      "    FROM INFORMATION_SCHEMA.COLUMNS " +
                                      "    WHERE COLUMN_NAME='idFormaPago' AND TABLE_NAME = 'MAE_Empleados' " +
                                      ") " +
                                    "BEGIN " +
                                        " ALTER TABLE [MAE_Empleados]ADD[idFormaPago] bigint NULL " +
                                         //Relaciones
                                         " ALTER TABLE MAE_Empleados WITH CHECK ADD CONSTRAINT [FK_MAE_Empleados_MAE_FormasPago] FOREIGN KEY([idFormaPago]) REFERENCES MAE_FormasPago ([id]) " +
                                        " ALTER TABLE MAE_Empleados CHECK CONSTRAINT [FK_MAE_Empleados_MAE_FormasPago] " +
                                    "END ";



    }
}
