public Boolean GuardarDB(List <fa_pre_facturacion_det_Fact_x_Gastos_Info> Lista) { try { foreach (var item in Lista) { using (Entity_Facturacion_FJ Context = new Entity_Facturacion_FJ()) { fa_pre_facturacion_det_Fact_x_Gastos Entity = new fa_pre_facturacion_det_Fact_x_Gastos(); Entity.IdEmpresa = item.IdEmpresa; Entity.IdPreFacturacion = item.IdPreFacturacion; Entity.secuencia = item.secuencia; Entity.IdCentro_Costo = item.IdCentro_Costo; Entity.IdCentroCosto_sub_centro_costo = item.IdCentroCosto_sub_centro_costo; Entity.IdPunto_cargo = item.IdPunto_cargo; Entity.IdEmpresa_og = item.IdEmpresa_og; Entity.IdTipoCbte_Ogiro = item.IdTipoCbte_Ogiro; Entity.IdCbteCble_Ogiro = item.IdCbteCble_Ogiro; Entity.Cantidad = item.Cantidad; Entity.Costo_Uni = item.Costo_Uni; Entity.Subtotal = item.Subtotal; Entity.Aplica_Iva = item.Aplica_Iva; Entity.Por_Iva = item.Por_Iva; Entity.Valor_Iva = item.Valor_Iva; Entity.Total = item.Total; Entity.Facturar = item.Facturar; Entity.IdTarifario = item.IdTarifario; Entity.Porc_ganancia = item.Porc_ganancia; Context.fa_pre_facturacion_det_Fact_x_Gastos.Add(Entity); Context.SaveChanges(); } } return(true); } catch (Exception ex) { string MensajeError = ""; 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 MensajeError); MensajeError = ex.ToString(); throw new Exception(ex.ToString()); } }
public Boolean GuardarDB(List <fa_pre_facturacion_det_Fact_x_Gastos_Info> Lista) { try { try { int secuencia = 1; foreach (var item in Lista) { using (Entity_Facturacion_FJ Context = new Entity_Facturacion_FJ()) { fa_pre_facturacion_det_Fact_x_Gastos Entity = new fa_pre_facturacion_det_Fact_x_Gastos(); Entity.IdEmpresa = item.IdEmpresa; Entity.IdPreFacturacion = item.IdPreFacturacion; Entity.secuencia = item.secuencia = secuencia; Entity.IdCentro_Costo = item.IdCentro_Costo; Entity.IdCentroCosto_sub_centro_costo = item.IdCentroCosto_sub_centro_costo; Entity.IdPunto_cargo = item.IdPunto_cargo; Entity.IdEmpresa_ct = item.IdEmpresa_ct; Entity.IdTipoCbte_ct = item.IdTipoCbte_ct; Entity.IdCbteCble_ct = item.IdCbteCble_ct; Entity.Cantidad = item.Cantidad; Entity.Costo_Uni = item.Costo_Uni; Entity.Subtotal = item.Subtotal; Entity.Por_Iva = item.Por_Iva; Entity.Valor_Iva = item.Valor_Iva; Entity.Total = item.Total; Entity.Valor_a_cobrar = item.Valor_a_cobrar; Entity.Facturar = item.Facturar; Entity.IdTarifario = item.IdTarifario; Entity.Porc_ganancia = item.Porc_ganancia; Entity.num_documento = item.num_documento; Entity.nom_proveedor = item.nom_proveedor; Entity.Fecha_documento = item.Fecha_documento; Entity.Observacion = item.Observacion; Entity.IdTipoMovi_grupo = item.IdTipoMovi_grupo; Entity.secuencia_ct = item.secuencia_ct; Entity.IdCuota = item.IdCuota; Entity.secuencia_cuota = item.secuencia_cuota; Context.fa_pre_facturacion_det_Fact_x_Gastos.Add(Entity); Context.SaveChanges(); secuencia++; } } return(true); } catch (DbEntityValidationException ex) { string mensaje = ""; 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; mensaje = "Error al Grabar" + ex.Message; throw new Exception(ex.ToString()); } } catch (Exception ex) { string MensajeError = ""; 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 MensajeError); MensajeError = ex.ToString(); throw new Exception(ex.ToString()); } }