public bool EliminarDB(imp_ordencompra_ext_x_imp_gastosxImport_Info Info, ref string msg)
 {
     try
     {
         using (EntitiesImportacion oEnt = new EntitiesImportacion())
         {
             var a = Get_List_ordencompra_ext_x_imp_gastosxImport_Det(Info);
             if (a != null)
             {
                 foreach (var item in a)
                 {
                     imp_ordencompra_ext_x_imp_gastosxImport_det contact = oEnt.
                                                                           imp_ordencompra_ext_x_imp_gastosxImport_det.FirstOrDefault(q => q.IdEmpresa == item.IdEmpresa && q.IdSucursal == item.IdSucusal && q.IdOrdenCompraExt == item.IdOrdenCompraExt && q.IdRegistroGasto == item.IdRegistroGasto);
                     if (contact != null)
                     {
                         oEnt.imp_ordencompra_ext_x_imp_gastosxImport_det.Remove(contact);
                     }
                 }
                 oEnt.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.ToString() + " " + ex.Message;
         throw new Exception(ex.ToString());
     }
 }
        public Boolean GuardarDB(List <imp_ordencompra_ext_x_imp_gastosxImport_Det_Info> LstDetalle)
        {
            try
            {
                int c = 1;
                foreach (var item in LstDetalle)
                {
                    using (EntitiesImportacion Context = new EntitiesImportacion())
                    {
                        var address = new imp_ordencompra_ext_x_imp_gastosxImport_det();

                        address.IdEmpresa        = item.IdEmpresa;
                        address.IdRegistroGasto  = item.IdRegistroGasto;
                        address.IdSucursal       = item.IdSucusal;
                        address.IdOrdenCompraExt = item.IdOrdenCompraExt;
                        address.Secuencia        = c;
                        address.IdGastoImp       = item.IdGastoImp;
                        address.Valor            = item.Valor;
                        c++;
                        Context.imp_ordencompra_ext_x_imp_gastosxImport_det.Add(address);
                        Context.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.ToString() + " " + ex.Message;
                throw new Exception(ex.ToString());
            }
        }