private void Add_Click(object sender, EventArgs e) { try { trainList.Add(textBox1.Text, Convert.ToInt32(textBox2.Text), TimeSpan.Parse(textBox3.Text)); TrainSortAndFind trainSort = new TrainSortAndFind("Ost", trainList); trainList = trainSort.Sort(); update(); } catch (Exception) { MessageBox.Show("Неверные данные", "Error", MessageBoxButtons.OK); } }
private void Open_Click(object sender, EventArgs e) { OpenFileDialog fileDialog = new OpenFileDialog(); fileDialog.Title = "Выберите из какого файла загрузить данные"; if (fileDialog.ShowDialog() == DialogResult.OK) { trainList.ReadFromFile(fileDialog.FileName); } TrainSortAndFind trainSort = new TrainSortAndFind("Ost", trainList); trainList = trainSort.Sort(); update(); }
private void Sort_Click(object sender, EventArgs e) { string val; if (radioButton1.Checked) { val = "Ost"; } else if (radioButton2.Checked) { val = "Number"; } else { val = "Time"; } TrainSortAndFind trainSort = new TrainSortAndFind(val, trainList); trainList = trainSort.Sort(); update(); }
private void Find_Click(object sender, EventArgs e) { List <Train> result; try { if (radioButton1.Checked) { TrainSortAndFind trainSort = new TrainSortAndFind("Ost", trainList); result = trainSort.Find(textBox1.Text); } else if (radioButton2.Checked) { TrainSortAndFind trainSort = new TrainSortAndFind("Number", trainList); result = trainSort.Find(Convert.ToInt32(textBox2.Text)); } else { TrainSortAndFind trainSort = new TrainSortAndFind("Time", trainList); result = trainSort.Find(TimeSpan.Parse(textBox3.Text)); } dataGridView2.Visible = true; dataGridView2.Rows.Clear(); for (int i = 0; i < result.Count; i++) { dataGridView2.Rows.Add(); dataGridView2.Rows[i].Cells[0].Value = i.ToString(); dataGridView2.Rows[i].Cells[1].Value = result[i].Ost; dataGridView2.Rows[i].Cells[2].Value = result[i].Number.ToString(); dataGridView2.Rows[i].Cells[3].Value = result[i].Time; } } catch (Exception) { MessageBox.Show("Неверные данные", "Error", MessageBoxButtons.OK); } }