/// <summary>
        /// Populate the data grid with information for a single car
        /// </summary>
        /// <param name="car">A single car used to populate the data grid</param>
        private void DataPopulatorSingle(Car car)
        {
            EngineBusiness engineBusiness = new EngineBusiness();
            var            engine         = engineBusiness.GetEngineById(car.EngineId);
            CarBusiness    carBusiness    = new CarBusiness();

            string[] row =
            {
                car.Id.ToString(),
                car.Manufacturer,
                car.Model,
                carBusiness.GetDealershipName(car.CarDealershipId),
                engine.Name,
                engine.Power.ToString(),
                engine.Displacement.ToString(),
                FuelENGToBG(engine.FuelType),
                engine.EconomyPerHundredKm.ToString(),
                car.TransmissionType,
                car.TransmissionGears.ToString(),
                car.Color,
                car.Price.ToString() + " лв.",
                carBusiness.GetOwnerName(car.OwnerId),
            };
            dataGridView.Rows.Add(row);
        }
Exemplo n.º 2
0
        private void btnCars_Click(object sender, EventArgs e)
        {
            HideSpecificInfo();
            lblInfoCar.Visible = true;
            btnNewCar.Visible  = true;

            dataGridView.Rows.Clear();

            dataGridView.ColumnCount = 13;

            dataGridView.Columns[0].Name  = "ID";
            dataGridView.Columns[1].Name  = "Марка";
            dataGridView.Columns[2].Name  = "Модел";
            dataGridView.Columns[3].Name  = "ID на автокъща";
            dataGridView.Columns[4].Name  = "Автокъща";
            dataGridView.Columns[5].Name  = "ID на двигател";
            dataGridView.Columns[6].Name  = "Двигател";
            dataGridView.Columns[7].Name  = "Скоростна кутия";
            dataGridView.Columns[8].Name  = "Предавки";
            dataGridView.Columns[9].Name  = "Цвят";
            dataGridView.Columns[10].Name = "Цена";
            dataGridView.Columns[11].Name = "ID на собственик";
            dataGridView.Columns[12].Name = "Собственик";

            dataGridView.AutoSizeRowsMode =
                DataGridViewAutoSizeRowsMode.DisplayedCellsExceptHeaders;
            dataGridView.ColumnHeadersBorderStyle =
                DataGridViewHeaderBorderStyle.Single;
            dataGridView.CellBorderStyle   = DataGridViewCellBorderStyle.Single;
            dataGridView.RowHeadersVisible = false;
            dataGridView.SelectionMode     =
                DataGridViewSelectionMode.FullRowSelect;
            dataGridView.MultiSelect = false;

            CarBusiness carBusiness = new CarBusiness();
            var         carList     = carBusiness.GetAllCars();

            foreach (var car in carList)
            {
                string[] row =
                {
                    car.Id.ToString(),
                    car.Manufacturer,
                    car.Model,
                    car.CarDealershipId.ToString(),
                    carBusiness.GetDealershipName(car.CarDealershipId),
                    car.EngineId.ToString(),
                    carBusiness.GetEngineName(car.EngineId),
                    car.TransmissionType,
                    car.TransmissionGears.ToString(),
                    car.Color,
                    car.Price.ToString(),
                    car.OwnerId.ToString(),
                    carBusiness.GetOwnerName(car.OwnerId)
                };
                dataGridView.Rows.Add(row);
            }
        }