private void CarCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     if (CarCheckBox.Checked == true)
     {
         CarGridView.Rows.Clear();
         i = 0;
         ReserveTile.Enabled = false;
         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);
             }
         }
     }
     else
     {
         CarGridView.Rows.Clear();
         i = 0;
         ReserveTile.Enabled = true;
         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 Exitbutton_Click(object sender, EventArgs e)
 {
     foreach (CarModel car in DbController.GetCars())
     {
         DbController.SetStatus(car.id, "Free");
     }
     this.Close();
 }
        private void MainForm_Load(object sender, EventArgs e)
        {
            CarGridView.SelectionMode      = DataGridViewSelectionMode.FullRowSelect;
            CarGridView.AllowUserToAddRows = false;
            BlockButton.Enabled            = false;

            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 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);

                //}
            }
        }