예제 #1
0
파일: CarService.cs 프로젝트: wfsiew/WcfApp
        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;
        }
예제 #2
0
파일: CarService.cs 프로젝트: wfsiew/WcfApp
 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();
 }