public Vehiculo(decimal id, string placa, Linea idLinea, string modelo, string numeroMotor, string color, ClaseVehiculo idClaseVehiculo, TipoServicio idTipoServicio) { this.id = id; this.placa = placa; this.idLinea = idLinea; this.modelo = modelo; this.numeroMotor = numeroMotor; this.color = color; this.idClaseVehiculo = idClaseVehiculo; this.idTipoServicio = idTipoServicio; }
public Vehiculo BuscarVehiculo(int?id) { this.error = ""; Vehiculo unVehiculo = null; SqlCommand comando = new SqlCommand(); comando.Connection = this.conexion; comando.CommandText = "SELECT * FROM VEHICULO WHERE ID=" + id; try { SqlDataReader registro = comando.ExecuteReader(); if (registro.Read()) { unVehiculo = new Vehiculo(); unVehiculo.id = Convert.ToInt32(registro.GetDecimal(0)); unVehiculo.placa = registro.GetString(1); Linea linea = new Linea(); linea.id = registro.GetDecimal(2); unVehiculo.idLinea = linea; unVehiculo.modelo = registro.GetString(3); unVehiculo.numeroMotor = registro.GetString(4); unVehiculo.color = registro.GetString(5); ClaseVehiculo clase = new ClaseVehiculo(); clase.id = registro.GetDecimal(6); unVehiculo.idClaseVehiculo = clase; TipoServicio tipo = new TipoServicio(); tipo.id = registro.GetDecimal(7); } registro.Close(); } catch (Exception ex) { this.error = ex.Message; } return(unVehiculo); }
public List <TipoServicio> listarTipodeServicios() { List <TipoServicio> listaServicios = new List <TipoServicio>(); SqlCommand comando = new SqlCommand(); comando.Connection = this.conexion; comando.CommandText = "SELECT * from TIPOSERVICIO"; try { SqlDataReader registro = comando.ExecuteReader(); while (registro.Read()) { TipoServicio tipoServicio = new TipoServicio(); tipoServicio.id = registro.GetDecimal(0); tipoServicio.descripcion = registro.GetString(1); listaServicios.Add(tipoServicio); } registro.Close(); }catch (Exception ex) { this.error = ex.Message; } return(listaServicios); }