private void BlockButton_Click(object sender, EventArgs e) { SelectedCar = CarGridView.CurrentCell.RowIndex + 1; SelectedCarId = Convert.ToInt16(CarGridView.Rows[CarGridView.CurrentCell.RowIndex].Cells["CarId"].Value); DbController.SetStatus(SelectedCarId, "Blocked"); CarGridView.Rows.Clear(); i = 0; foreach (CarModel car in DbController.GetCars()) { if ((DateTime.Compare(Date1, car.date) > 0 || CarCheckBox.Checked) && car.status == "Free") { CarGridView.Rows.Add(car.id, car.brand, car.model, car.power, car.seats, car.maxv, car.price, car.gearbox, car.fuel, car.colour); } } }
private void ReserveTile_Click(object sender, EventArgs e) { SelectedCar = CarGridView.CurrentCell.RowIndex + 1; SelectedCarId = Convert.ToInt16(CarGridView.Rows[CarGridView.CurrentCell.RowIndex].Cells["CarId"].Value); DbController.SetReserved(SelectedCarId); CarGridView.Rows.Clear(); i = 0; foreach (CarModel car in DbController.GetCars()) { //if ((DateTime.Compare(Date1, car.Date) > 0 || CarCheckBox.Checked) && car.Status == "Free") //{ // CarGridView.Rows.Add(car.id, car.Brand, car.Model, car.PS, car.Seats, car.Maxspeed, car.Price, car.Gearbox, car.Fuel, car.Colour); //} } }
private void addTile_Click(object sender, EventArgs e) { // should add a car to the database and refresh the carlistbox (insert into) if (!(string.IsNullOrEmpty(brandTextBox.Text) && string.IsNullOrEmpty(modelTextBox.Text) && string.IsNullOrEmpty(priceTextBox.Text) && string.IsNullOrEmpty(gearboxTextBox.Text) && string.IsNullOrEmpty(fuelTextBox.Text) && string.IsNullOrEmpty(colourTextBox.Text) && string.IsNullOrEmpty(licenseclassTextBox.Text)) && string.IsNullOrEmpty(powerTextBox.Text) && string.IsNullOrEmpty(seatsTextBox.Text) && string.IsNullOrEmpty(maxSpeedTextBox.Text)) { DbController.InsertCar(new Car(0, brandTextBox.Text, modelTextBox.Text, Int32.Parse(powerTextBox.Text), Int32.Parse(seatsTextBox.Text), Int32.Parse(maxSpeedTextBox.Text), Int32.Parse(priceTextBox.Text), gearboxTextBox.Text, fuelTextBox.Text, colourTextBox.Text, licenseclassTextBox.Text, statusTextBox.Text, false), this); } else { MetroMessageBox.Show(this, "More details, please."); } }