Ejemplo n.º 1
0
        public List<CarRecord> GetCars(int page, int pageSize)
        {
            DbLayer db = new DbLayer();
            db.OpenConnection(ConnectionStr);
            DataTable dt = db.GetCars(page, pageSize);
            db.CloseConnection();

            List<CarRecord> ls = new List<CarRecord>();
            DataTableReader rd = dt.CreateDataReader();

            while (rd.Read())
            {
                ls.Add(new CarRecord {
                    ID = (int) rd["ID"],
                    Make = (string) rd["Make"],
                    Model = (string) rd["Model"],
                    Year = (int) rd["Year"],
                    Doors = (int) rd["Doors"],
                    Colours = (string) rd["Colour"],
                    Price = (double) rd["Price"]
                });
            }

            return ls;
        }
Ejemplo n.º 2
0
 public void InsertCar(CarRecord r)
 {
     DbLayer db = new DbLayer();
     db.OpenConnection(ConnectionStr);
     db.InsertCar(new Car {
         Make = r.Make,
         Model = r.Model,
         Year = r.Year,
         Doors = r.Doors,
         Colour = r.Colours,
         Price = r.Price
     });
     db.CloseConnection();
 }