private void buttonShowCourseVisits_Click(object sender, EventArgs e) { string id = textBoxCourseVisits.Text; if (id.All(char.IsDigit) && id != "") { using (DataTable dataTable = Courses.GetCourseVisits(_sqlConnection, id)) { if (dataTable != null) { dataGridViewCourses.DataSource = dataTable; } else { MessageBox.Show("Kurs o podanych danych nie istnieje!"); } } } else { MessageBox.Show("ID musi być liczbą!"); textBoxCourseVisits.Text = ""; } }
private void buttonSearchAtoB_Click(object sender, EventArgs e) { string cityA = textBoxCityA.Text, cityB = textBoxCityB.Text; if (!cityA.Any(char.IsDigit) && !cityB.Any(char.IsDigit) && cityA.Any(char.IsLetter) && cityB.Any(char.IsLetter)) { using (var dataTable = Courses.GetAvaibleCoursesFromAtoB(_sqlConnection, cityA, cityB)) { if (dataTable != null) { dataGridViewCourses.DataSource = dataTable; } else { MessageBox.Show("Kurs o podanych danych nie istnieje!"); } } } else { MessageBox.Show("Nazwy stacji nie zawierają cyfr!"); } }