public cp_codigo_SRI_x_CtaCble_Info get_info(int idCodigo_SRI, int IdEmpresa) { try { cp_codigo_SRI_x_CtaCble_Info info = new cp_codigo_SRI_x_CtaCble_Info(); using (Entities_cuentas_por_pagar Context = new Entities_cuentas_por_pagar()) { cp_codigo_SRI_x_CtaCble Entity = Context.cp_codigo_SRI_x_CtaCble.FirstOrDefault(q => q.idCodigo_SRI == idCodigo_SRI && q.IdEmpresa == IdEmpresa); if (Entity == null) { return(null); } info = new cp_codigo_SRI_x_CtaCble_Info { IdEmpresa = Entity.IdEmpresa, idCodigo_SRI = Entity.idCodigo_SRI, IdCtaCble = Entity.IdCtaCble }; } return(info); } catch (Exception) { throw; } }
public Boolean GuardarDB(cp_codigo_SRI_x_CtaCble_Info info) { try { using (EntitiesCuentasxPagar Context = new EntitiesCuentasxPagar()) { cp_codigo_SRI_x_CtaCble Address = new cp_codigo_SRI_x_CtaCble(); Address.IdEmpresa = info.IdEmpresa; Address.idCodigo_SRI = info.idCodigo_SRI; Address.IdCtaCble = info.IdCtaCble; Address.idUsuario = info.idUsuario; Address.ip = info.ip; Address.nom_pc = info.nom_pc; Address.fecha_UltMod = info.fecha_UltMod; Context.cp_codigo_SRI_x_CtaCble.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()); } }
public Boolean ModificarDB(List <cp_codigo_SRI_x_CtaCble_Info> lista, int codigoSRI) { try { using (EntitiesCuentasxPagar Contex = new EntitiesCuentasxPagar()) { EntitiesCuentasxPagar param_Info = new EntitiesCuentasxPagar(); var selectBaParam = (from C in param_Info.cp_codigo_SRI_x_CtaCble where C.idCodigo_SRI == codigoSRI select C).Count(); if (selectBaParam == 0) { foreach (var item in lista) { cp_codigo_SRI_x_CtaCble address = new cp_codigo_SRI_x_CtaCble(); address.IdEmpresa = item.IdEmpresa; address.idCodigo_SRI = codigoSRI; address.IdCtaCble = item.IdCtaCble; address.idUsuario = item.idUsuario; address.ip = item.ip; address.fecha_UltMod = Convert.ToDateTime(DateTime.Now.ToShortDateString()); address.nom_pc = item.nom_pc; Contex.cp_codigo_SRI_x_CtaCble.Add(address); Contex.SaveChanges(); } } else { using (EntitiesCuentasxPagar context = new EntitiesCuentasxPagar()) { foreach (var item in lista) { var contact = context.cp_codigo_SRI_x_CtaCble.First(cot => cot.IdEmpresa == item.IdEmpresa && cot.idCodigo_SRI == item.idCodigo_SRI); contact.IdCtaCble = item.IdCtaCble; contact.idUsuario = item.idUsuario; contact.ip = item.ip; contact.fecha_UltMod = Convert.ToDateTime(DateTime.Now.ToShortDateString()); contact.nom_pc = item.nom_pc; 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.InnerException + " " + ex.Message; throw new Exception(ex.InnerException.ToString()); } }
public Boolean ModificarDB(cp_codigo_SRI_x_CtaCble_Info info) { try { using (EntitiesCuentasxPagar context = new EntitiesCuentasxPagar()) { EntitiesCuentasxPagar param = new EntitiesCuentasxPagar(); var selectBaParam = (from C in param.cp_codigo_SRI_x_CtaCble where C.IdEmpresa == info.IdEmpresa && C.idCodigo_SRI == info.idCodigo_SRI select C).Count(); if (selectBaParam == 0) { cp_codigo_SRI_x_CtaCble addressG = new cp_codigo_SRI_x_CtaCble(); addressG.IdEmpresa = info.IdEmpresa; addressG.idCodigo_SRI = info.idCodigo_SRI; addressG.IdCtaCble = info.IdCtaCble; addressG.fecha_UltMod = info.fecha_UltMod; addressG.idUsuario = info.idUsuario; addressG.ip = info.ip; addressG.nom_pc = info.nom_pc; context.cp_codigo_SRI_x_CtaCble.Add(addressG); context.SaveChanges(); } else { var contact = context.cp_codigo_SRI_x_CtaCble.FirstOrDefault(var => var.IdEmpresa == info.IdEmpresa && var.idCodigo_SRI == info.idCodigo_SRI); if (contact != null) { contact.IdEmpresa = info.IdEmpresa; contact.idCodigo_SRI = info.idCodigo_SRI; contact.IdCtaCble = info.IdCtaCble; contact.fecha_UltMod = info.fecha_UltMod; contact.idUsuario = info.idUsuario; contact.ip = info.ip; contact.nom_pc = info.nom_pc; 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()); } }
public bool guardarDB(cp_codigo_SRI_x_CtaCble_Info info) { try { using (Entities_cuentas_por_pagar Context = new Entities_cuentas_por_pagar()) { cp_codigo_SRI_x_CtaCble Entity = new cp_codigo_SRI_x_CtaCble { idCodigo_SRI = info.idCodigo_SRI, IdEmpresa = info.IdEmpresa, IdCtaCble = info.IdCtaCble, fecha_UltMod = DateTime.Now }; Context.cp_codigo_SRI_x_CtaCble.Add(Entity); Context.SaveChanges(); } return(true); } catch (Exception) { throw; } }