/// <summary>
        /// Populate the data grid with information for a single worker
        /// </summary>
        /// <param name="worker">A single worker used to populate the data grid</param>
        private void DataPopulatorSingle(Worker worker)
        {
            WorkerBusiness workerBusiness = new WorkerBusiness();

            string[] row =
            {
                worker.Id.ToString(),
                worker.FirstName,
                worker.LastName,
                worker.Position,
                worker.Salary.ToString(),
                workerBusiness.GetDealershipName(worker.CarDealershipId)
            };
            dataGridView.Rows.Add(row);
        }
Ejemplo n.º 2
0
        private void btnWorkers_Click(object sender, EventArgs e)
        {
            HideSpecificInfo();
            lblInfoWorker.Visible = true;
            btnNewWorker.Visible  = true;

            dataGridView.Rows.Clear();

            dataGridView.ColumnCount = 7;

            dataGridView.Columns[0].Name = "ID";
            dataGridView.Columns[1].Name = "Име";
            dataGridView.Columns[2].Name = "Фамилия";
            dataGridView.Columns[3].Name = "Длъжност";
            dataGridView.Columns[4].Name = "Заплата";
            dataGridView.Columns[5].Name = "ID на автокъща";
            dataGridView.Columns[6].Name = "Автокъща";

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

            WorkerBusiness workerBusiness = new WorkerBusiness();
            var            workersList    = workerBusiness.GetAllWorkers();

            foreach (var worker in workersList)
            {
                string[] row =
                {
                    worker.Id.ToString(),
                    worker.FirstName,
                    worker.LastName,
                    worker.Position,
                    worker.Salary.ToString(),
                    worker.CarDealershipId.ToString(),
                    workerBusiness.GetDealershipName(worker.CarDealershipId)
                };
                dataGridView.Rows.Add(row);
            }
        }