Пример #1
0
        public int AddCarRow(Car car)
        {
            string qInsert = "INSERT INTO car ('regNr', 'make', 'model', 'year', 'forSale') VALUES (@regNr, @make, @model, @year, @forSale); ";

            SQLiteCommand dbCommand = new SQLiteCommand(qInsert, dbConn);

            OpenConnection();

            dbCommand.Parameters.AddWithValue("@regNr", car.GetRegNr());
            dbCommand.Parameters.AddWithValue("@make", car.GetMake());
            dbCommand.Parameters.AddWithValue("@model", car.GetModel());
            dbCommand.Parameters.AddWithValue("@year", car.GetYear());

            if (car.GetForSale())
            {
                dbCommand.Parameters.AddWithValue("@forSale", 1);
            }
            else
            {
                dbCommand.Parameters.AddWithValue("@forSale", 0);
            }

            int result = dbCommand.ExecuteNonQuery();

            CloseConnection();
            return(result);
        }
Пример #2
0
        public int AddCarRow(Car car)
        {
            string qInsert = "INSERT INTO CAR ('regNr', 'brand', 'model', 'year', 'forSale') VALUES (@regNr, @brand, @model, @year, @forSale);";

            SQLiteCommand dbCommand = new SQLiteCommand(qInsert, dbConn);

            OpenConnection();

            dbCommand.Parameters.AddWithValue(@"regNr", car.GetRegNr());
            dbCommand.Parameters.AddWithValue(@"brand", car.GetBrand());
            dbCommand.Parameters.AddWithValue(@"model", car.GetModel());
            dbCommand.Parameters.AddWithValue(@"year", car.GetYear());
            dbCommand.Parameters.AddWithValue(@"forSale", Convert.ToInt32(car.GetForSale()));

            int result = dbCommand.ExecuteNonQuery();

            CloseConnection();
            return(result);
        }
Пример #3
0
        private void AddCarToListview(Car car)
        {
            ListViewItem item = CreateListViewItem(car.GetRegNr(), car.GetModel(), car.GetModel(), Convert.ToString(car.GetYear()), car.GetForSale());

            lVCars.Items.Add(item);
        }