public Boolean GuardarDB(List <cxc_cobro_Det_Info> lista) { try { if (lista != null) { using (EntitiesCuentas_x_Cobrar Contex = new EntitiesCuentas_x_Cobrar()) { int secuencia = 0; foreach (var item in lista) { var address = new cxc_cobro_det(); secuencia = secuencia + 1; address.IdEmpresa = item.IdEmpresa; address.IdSucursal = item.IdSucursal; address.IdCobro = item.IdCobro; address.secuencial = secuencia; address.dc_TipoDocumento = item.dc_TipoDocumento; address.IdBodega_Cbte = item.IdBodega_Cbte; address.IdCbte_vta_nota = item.IdCbte_vta_nota; address.dc_ValorPago = item.dc_ValorPago; address.IdUsuario = item.IdUsuario; address.Fecha_Transac = Convert.ToDateTime(DateTime.Now.ToShortDateString()); address.nom_pc = item.nom_pc; address.ip = item.ip; //Contac = address; Contex.cxc_cobro_det.Add(address); } Contex.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 ModificarDetalleCobro(List <cxc_cobro_Det_Info> lista) { try { try { List <cxc_cobro_Det_Info> listaAux = new List <cxc_cobro_Det_Info>(); cxc_cobro_Det_Info i = new cxc_cobro_Det_Info(); i = lista.First(); listaAux = Get_List_Cobro_detalle(i.IdEmpresa, i.IdSucursal, i.IdCobro); using (EntitiesCuentas_x_Cobrar context = new EntitiesCuentas_x_Cobrar()) { foreach (var item in listaAux) { var contact = context.cxc_cobro_det.First(cot => cot.IdEmpresa == item.IdEmpresa && cot.IdSucursal == item.IdSucursal && cot.IdCobro == item.IdCobro); context.cxc_cobro_det.Remove(contact); context.SaveChanges(); } } } 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; } using (EntitiesCuentas_x_Cobrar Contex = new EntitiesCuentas_x_Cobrar()) { int secuencia = 0; foreach (var item in lista) { //var Contac = cxc_cobro_det.Createcxc_cobro_det(0, 0, 0, 0, 0, 0); var address = new cxc_cobro_det(); secuencia = secuencia + 1; address.IdEmpresa = item.IdEmpresa; address.IdSucursal = item.IdSucursal; address.IdCobro = item.IdCobro; address.secuencial = secuencia; address.dc_TipoDocumento = item.dc_TipoDocumento; address.IdBodega_Cbte = item.IdBodega_Cbte; address.IdCbte_vta_nota = item.IdCbte_vta_nota; address.dc_ValorPago = item.dc_ValorPago; address.IdUsuario = item.IdUsuario; address.Fecha_Transac = Convert.ToDateTime(DateTime.Now.ToShortDateString()); //Contac = address; Contex.cxc_cobro_det.Add(address); Contex.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()); } }