//public Boolean EliminarEGPXGD(List<ro_empleado_gastos_perso_x_Gastos_deduci_Info> info, int IncrementaColumnas)
 public Boolean EliminarEGPXGD(List <ro_empleado_gastos_perso_x_Gastos_deduci_Info> info)
 {
     try
     {
         using (EntitiesRoles ro = new EntitiesRoles())
         {
             //int i = 0;
             //int Resta = info.Count - IncrementaColumnas;
             foreach (var item in info)
             {
                 //    i++;
                 //    if (i <= Resta)
                 //    {
                 //ro_empleado_gastos_perso_x_Gastos_deduci EGPXGD = ro.ro_empleado_gastos_perso_x_Gastos_deduci.First(v => v.IdEmpleado == item.IdEmpleado);
                 ro_empleado_gastos_perso_x_Gastos_deduci EGPXGD = ro.ro_empleado_gastos_perso_x_Gastos_deduci.First(v => v.IdEmpleado == item.IdEmpleado && v.IdEmpresa == item.IdEmpresa && v.Anio_fiscal == item.Anio_fiscal);
                 ro.ro_empleado_gastos_perso_x_Gastos_deduci.Remove(EGPXGD);
                 ro.SaveChanges();
                 //    }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         string arreglo = ToString();
         tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
         tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
         oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
         mensaje = ex.InnerException + " " + ex.Message;
         throw new Exception(ex.InnerException.ToString());
     }
 }
        public Boolean GrabarBD(ro_empleado_gastos_perso_x_Gastos_deduci_Info info, ref string msg)
        {
            try
            {
                using (EntitiesRoles db = new EntitiesRoles())
                {
                    ro_empleado_gastos_perso_x_Gastos_deduci item = new ro_empleado_gastos_perso_x_Gastos_deduci();

                    item.IdEmpresa      = info.IdEmpresa;
                    item.IdEmpleado     = info.IdEmpleado;
                    item.Anio_fiscal    = info.Anio_fiscal;
                    item.Secuencia      = getId(info.IdEmpresa, info.IdEmpleado, info.Anio_fiscal);
                    item.Ruc            = info.Ruc;
                    item.Num_CbteVta    = info.Num_CbteVta;
                    item.Base_Imponible = info.Base_Imponible;
                    item.IdTipoGastos   = info.IdTipoGastos;

                    db.ro_empleado_gastos_perso_x_Gastos_deduci.Add(item);
                    db.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = msg = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
        //public int GetSecuencia()
        //{
        //    try
        //    {
        //        EntitiesRoles rol = new EntitiesRoles();
        //        var numero = (from q in rol.ro_empleado_gastos_perso_x_Gastos_deduci
        //                      select q.Secuencia).Max() + 1;

        //        return numero;
        //    }
        //    catch (Exception)
        //    {

        //        return 0;
        //    }
        //}

        public Boolean Eliminar_EGPXGD(ro_empleado_gastos_perso_x_Gastos_deduci_Info info)
        {
            try
            {
                using (EntitiesRoles ro = new EntitiesRoles())
                {
                    ro_empleado_gastos_perso_x_Gastos_deduci EGPXGD = ro.ro_empleado_gastos_perso_x_Gastos_deduci.First(v => v.IdEmpleado == info.IdEmpleado && v.IdEmpresa == info.IdEmpresa && v.Anio_fiscal == info.Anio_fiscal);
                    ro.ro_empleado_gastos_perso_x_Gastos_deduci.Remove(EGPXGD);
                    ro.SaveChanges();
                }
                return(true);
            }
            catch (Exception ex)
            {
                string arreglo = ToString();
                tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
                tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
                oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
                mensaje = ex.InnerException + " " + ex.Message;
                throw new Exception(ex.InnerException.ToString());
            }
        }
 public Boolean GrabarDB_EGPXGD(List <ro_empleado_gastos_perso_x_Gastos_deduci_Info> info)
 {
     try
     {
         if (EliminarEGPXGD(info) == true || EliminarEGPXGD(info) == false)
         {
             using (EntitiesRoles rol = new EntitiesRoles())
             {
                 foreach (var item in info)
                 {
                     ro_empleado_gastos_perso_x_Gastos_deduci BD = new ro_empleado_gastos_perso_x_Gastos_deduci();
                     BD.IdEmpresa   = item.IdEmpresa;
                     BD.IdEmpleado  = item.IdEmpleado;
                     BD.Anio_fiscal = item.Anio_fiscal;
                     //BD.Secuencia = GetSecuencia();
                     BD.Secuencia      = item.Secuencia;
                     BD.Ruc            = item.Ruc;
                     BD.Num_CbteVta    = item.Num_CbteVta;
                     BD.Base_Imponible = item.Base_Imponible;
                     BD.IdTipoGastos   = item.IdTipoGastos;
                     rol.ro_empleado_gastos_perso_x_Gastos_deduci.Add(BD);
                     rol.SaveChanges();
                 }
             }
         }
         return(true);
     }
     catch (Exception ex)
     {
         string arreglo = ToString();
         tb_sis_Log_Error_Vzen_Data oDataLog      = new tb_sis_Log_Error_Vzen_Data();
         tb_sis_Log_Error_Vzen_Info Log_Error_sis = new tb_sis_Log_Error_Vzen_Info(ex.ToString(), "", arreglo, "", "", "", "", "", DateTime.Now);
         oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje);
         mensaje = ex.InnerException + " " + ex.Message;
         throw new Exception(ex.InnerException.ToString());
     }
 }