public static Model.ComunaBo GetComunaById(int idCmn) { var lista = new List <Model.ComunaBo>(); var consulta = new CnaComuna(); try { var obj = new Model.ComunaBo(); var dr = consulta.Execute(0, idCmn); bool existe = false; while (dr.Read()) { obj = new Model.ComunaBo { idCmn = int.Parse(dr["idCmn"].ToString()), NomCmn = dr["NomCmn"].ToString(), Region = GetRegiones().SingleOrDefault(x => x.idRgn == int.Parse(dr["idRgn"].ToString())) }; existe = true; } dr.Close(); return(existe ? obj : null); } catch (Exception ex) { var msg = "Excepcion Controlada: " + ex.Message; throw new Exception(msg, ex); } }
public static List <Model.ComunaBo> GetComunas(int idRgn) { var lista = new List <Model.ComunaBo>(); var consulta = new CnaComuna(); try { var dr = consulta.Execute(idRgn); while (dr.Read()) { var obj = new Model.ComunaBo { idCmn = int.Parse(dr["idCmn"].ToString()), NomCmn = dr["NomCmn"].ToString() }; lista.Add(obj); } dr.Close(); } catch (Exception ex) { var msg = "Excepcion Controlada: " + ex.Message; throw new Exception(msg, ex); } return(lista); }