public override List <Field> getFields() { string query = "SELECT Номер, Вид, Марка, Поставщик, Вес, Объём_лопаты, Объём_ковша, Габариты FROM Экскаваторы"; OleDbCommand command = new OleDbCommand(query, connection); OleDbDataReader reader = command.ExecuteReader(); List <Field> list = new List <Field>(); while (reader.Read()) { Skavator skavator = new Skavator(); skavator.id = int.Parse(reader[0].ToString()); skavator.vid = reader[1].ToString(); skavator.marka = reader[2].ToString(); skavator.postav = reader[3].ToString(); skavator.ves = reader[4].ToString(); skavator.lopata = reader[5].ToString(); skavator.kovh = reader[6].ToString(); skavator.gabarit = reader[7].ToString(); list.Add(skavator); } reader.Close(); return(list); }
private void FillTable(List <Field> list) { Output_to_Form.Rows.Clear(); if (list.Count == 0) { Output_to_Form.RowCount = 1; GW.RowCount = 1; } else { Output_to_Form.RowCount = list.Count; GW.RowCount = list.Count; } Output_to_Form.ColumnCount = list[0].count; GW.ColumnCount = list[0].count; GW.Size = Output_to_Form.Size; GW.Location = Output_to_Form.Location; GW.RowHeadersVisible = false; GW.BackgroundColor = Output_to_Form.BackgroundColor; if (list[0] is Postavki) { for (int i = 0; i < list.Count; i++) { Postavki a = list[i] as Postavki; GW.CellClick += delegate { FillInfo(a.id); }; GW[0, i].Value = a.id; GW[1, i].Value = a.postav; GW[2, i].Value = a.adress; GW[3, i].Value = a.telefon; } GW.Columns[1].HeaderText = "Поставщик"; GW.Columns[2].HeaderText = "Юридический адрес"; GW.Columns[3].HeaderText = "Телефон"; GW.Columns[0].Visible = false; } else if (list[0] is Avtokran) { for (int i = 0; i < list.Count; i++) { Avtokran a = list[i] as Avtokran; GW.CellClick += delegate { FillInfo(a.id); }; GW[0, i].Value = a.id; GW[1, i].Value = a.vid; GW[2, i].Value = a.marka; GW[3, i].Value = a.postav; GW[4, i].Value = a.gp; GW[5, i].Value = a.moment; GW[6, i].Value = a.mas; } GW.Columns[1].HeaderText = "Вид"; GW.Columns[2].HeaderText = "Марка"; GW.Columns[3].HeaderText = "Поставщик"; GW.Columns[4].HeaderText = "Г/п, мах"; GW.Columns[5].HeaderText = "Мах грузовой момент"; GW.Columns[6].HeaderText = "Масса в транспортном положении"; GW.Columns[0].Visible = false; } else if (list[0] is Buldozer) { for (int i = 0; i < list.Count; i++) { Buldozer a = list[i] as Buldozer; GW.CellClick += delegate { FillInfo(a.id); }; GW[0, i].Value = a.id; GW[1, i].Value = a.vid; GW[2, i].Value = a.marka; GW[3, i].Value = a.postav; GW[4, i].Value = a.massa; GW[5, i].Value = a.dlina; GW[6, i].Value = a.visot; } GW.Columns[1].HeaderText = "Вид"; GW.Columns[2].HeaderText = "Марка"; GW.Columns[3].HeaderText = "Поставщик"; GW.Columns[4].HeaderText = "Масса"; GW.Columns[5].HeaderText = "Габаритная длина"; GW.Columns[6].HeaderText = "Высота овала"; GW.Columns[0].Visible = false; } else if (list[0] is Gidrobur) { for (int i = 0; i < list.Count; i++) { Gidrobur a = list[i] as Gidrobur; GW.CellClick += delegate { FillInfo(a.id); }; GW[0, i].Value = a.id; GW[1, i].Value = a.vid; GW[2, i].Value = a.marka; GW[3, i].Value = a.postav; GW[4, i].Value = a.ves; GW[5, i].Value = a.davlenie; GW[6, i].Value = a.dlina; } GW.Columns[1].HeaderText = "Вид"; GW.Columns[2].HeaderText = "Марка"; GW.Columns[3].HeaderText = "Поставщик"; GW.Columns[4].HeaderText = "Вес вращателя"; GW.Columns[5].HeaderText = "Давление в гидросистеме"; GW.Columns[6].HeaderText = "Длина шнека"; GW.Columns[0].Visible = false; } else if (list[0] is Pogruzki) { for (int i = 0; i < list.Count; i++) { Pogruzki a = list[i] as Pogruzki; GW.CellClick += delegate { FillInfo(a.id); }; GW[0, i].Value = a.id; GW[1, i].Value = a.vid; GW[2, i].Value = a.marka; GW[3, i].Value = a.postav; GW[4, i].Value = a.podnim; GW[5, i].Value = a.visota; GW[6, i].Value = a.mass; } GW.Columns[1].HeaderText = "Вид"; GW.Columns[2].HeaderText = "Марка"; GW.Columns[3].HeaderText = "Поставщик"; GW.Columns[4].HeaderText = "Поднимаемый груз"; GW.Columns[5].HeaderText = "Высота подъема груза"; GW.Columns[6].HeaderText = "Масса"; GW.Columns[0].Visible = false; } else if (list[0] is Skavator) { for (int i = 0; i < list.Count; i++) { Skavator a = list[i] as Skavator; GW.CellClick += delegate { FillInfo(a.id); }; GW[0, i].Value = a.id; GW[1, i].Value = a.vid; GW[2, i].Value = a.marka; GW[3, i].Value = a.postav; GW[4, i].Value = a.ves; GW[5, i].Value = a.lopata; GW[6, i].Value = a.kovh; GW[7, i].Value = a.gabarit; } GW.Columns[1].HeaderText = "Вид"; GW.Columns[2].HeaderText = "Марка"; GW.Columns[3].HeaderText = "Поставщик"; GW.Columns[4].HeaderText = "Вес"; GW.Columns[5].HeaderText = "Объем лопаты"; GW.Columns[6].HeaderText = "Объем ковша"; GW.Columns[7].HeaderText = "Габариты"; GW.Columns[0].Visible = false; } this.Controls.Add(GW); }