public VehiculoColeccion LeerTodos(string idCliente) { try { VehiculoColeccion lista = new VehiculoColeccion(); OracleConnection con; string conStr = "SELECT * FROM VEHICULO WHERE CLIENTE_id_cliente = '" + idCliente + "'"; con = CommonBC.Con; con.Open(); OracleCommand cmd = new OracleCommand(); cmd.CommandText = conStr; cmd.Connection = con; cmd.CommandType = CommandType.Text; OracleDataReader dr = cmd.ExecuteReader(); while (dr.Read()) { Vehiculo ve = new Vehiculo() { Id_vehiculo = dr.GetString(0) }; ve.Leer(); lista.Add(ve); } return(lista); } catch (Exception) { return(null); } }
public VehiculoColeccion(string xml) { XmlSerializer serializador = new XmlSerializer(typeof(VehiculoColeccion)); StringReader reader = new StringReader(xml); VehiculoColeccion lista = (VehiculoColeccion)serializador.Deserialize(reader); this.AddRange(lista); }
public bool Leer() { try { string cmd = "SELECT * FROM CLIENTE WHERE RUT = '" + this.Rut + "'"; OracleDataReader dr = CommonBC.OracleDataReader(cmd); this.Id_cliente = dr.GetString(0); this.Nombres = dr.GetString(3); this.Apellidos = dr.GetString(4); this.Correo = dr.GetString(5); this.FechaNacimiento = dr.GetString(7); this.Activo = dr.GetString(8).Equals("t"); this.Direccion = dr.GetString(9); Ciudad ciudad = new Ciudad() { Id_ciudad = dr.GetInt32(10) }; ciudad.Leer(); this.Ciudad = ciudad; VehiculoColeccion vehiculoColeccion = new VehiculoColeccion(); this.VehiculoColeccion = vehiculoColeccion.LeerTodos(this.Id_cliente); SiniestroColeccion siniestroColeccion = new SiniestroColeccion(); this.SiniestroColeccion = siniestroColeccion.LeerTodos(this.Id_cliente); CommonBC.con.Close(); return(true); } catch (Exception e) { return(false); } }