public Boolean ModificarDB(List <imp_ordencompra_ext_x_imp_gastosxImport_Info> lst, List <imp_ordencompra_ext_x_imp_gastosxImport_Info> LstAnterior, ref string mensaje) { Boolean res = true; try { using (EntitiesImportacion Contex = new EntitiesImportacion()) { if (LstAnterior != null && LstAnterior.Count > 0) { List <imp_ordencompra_ext_x_imp_gastosxImport_Info> listaactual = Get_List_ordencompra_ext_x_imp_gastosxImport(LstAnterior[0].IdEmpresa, LstAnterior[0].IdSucusal, LstAnterior[0].IdOrdenCompraExt); foreach (var item in listaactual) { imp_ordencompra_ext_x_imp_gastosxImport address = Contex.imp_ordencompra_ext_x_imp_gastosxImport.FirstOrDefault(p => p.IdEmpresa == item.IdEmpresa && p.IdRegistroGasto == item.IdRegistroGasto && p.IdSucusal == item.IdSucusal && p.IdOrdenCompraExt == item.IdOrdenCompraExt); Contex.imp_ordencompra_ext_x_imp_gastosxImport.Remove(address); } Contex.SaveChanges(); } } return(GuardarDB(lst, ref mensaje)); } 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); mensaje = ex.ToString() + " " + ex.Message; oDataLog.Guardar_Log_Error(Log_Error_sis, ref mensaje); throw new Exception(ex.ToString()); } }
public Boolean GuardarDB(imp_ordencompra_ext_x_imp_gastosxImport_Info info) { try { using (EntitiesImportacion Contex = new EntitiesImportacion()) { imp_ordencompra_ext_x_imp_gastosxImport address = new imp_ordencompra_ext_x_imp_gastosxImport(); address.IdEmpresa = info.IdEmpresa; address.IdRegistroGasto = info.IdRegistroGasto = GetId(info); address.IdSucusal = info.IdSucusal; address.IdOrdenCompraExt = info.IdOrdenCompraExt; address.Fecha = info.Fecha; address.Observacion = info.Observacion; address.IdProveedor = info.IdProveedor; if (info.IdBanco == 0) { address.IdBanco = null; } else { address.IdBanco = info.IdBanco; } address.IdTipoCbte = info.IdTipoCbte; address.CodDocu_Pago = info.CodDocu_Pago; address.Estado = "A"; address.IdUsuario = info.IdUsuario; address.Fecha_Transac = info.Fecha_Transac; address.Fecha_UltMod = info.Fecha_UltMod; address.IdUsuarioUltMod = info.IdUsuarioUltMod; //contac = address; Contex.imp_ordencompra_ext_x_imp_gastosxImport.Add(address); Contex.SaveChanges(); info.ListaGastos.ForEach(var => var.IdRegistroGasto = address.IdRegistroGasto); BusDetalle.GuardarDB(info.ListaGastos); Contex.Dispose(); } 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()); } }