private void ActOK_Click(System.Object sender, System.EventArgs e)
        {
            // ----- The start city is required.
            if (StartCity.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please provide a start city.");
                StartCity.Focus();
                return;
            }

            // ----- The end city is required.
            if (EndCity.Text.Trim().Length == 0)
            {
                MessageBox.Show("Please provide an end city.");
                EndCity.Focus();
                return;
            }

            // ----- The cities can't be the same.
            if (StartCity.Text.Trim().ToUpper() == EndCity.Text.Trim().ToUpper())
            {
                MessageBox.Show("The start and end cities must be different.");
                EndCity.Focus();
                return;
            }

            // ----- Success.
            this.DialogResult = DialogResult.OK;
        }
Beispiel #2
0
 public override string ToString() => StartCity.ToString() + "-" + EndCity.ToString();