예제 #1
0
 public AddWaypointForm(Form source, DatabaseCommunicator.DatabaseCommunicator dbCommunicator, HashSet <string> existingWaypointNames)
 {
     this.source = source;
     InitializeComponent();
     this.dbCommunicator        = dbCommunicator;
     returnWaypoint             = null;
     errorLabel.Text            = "";
     this.existingWaypointNames = existingWaypointNames;
 }
예제 #2
0
 public void saveButton_Click(object sender, EventArgs e)
 {
     if (waypointName.Text == "" || airportName.Text == "" || longitude.Text == "" || latitude.Text == "")
     {
         errorLabel.Text = "You must fill in all of the fields.";
     }
     else
     {
         Boolean added = existingWaypointNames.Contains(waypointName.Text.ToUpper());
         if (!added)
         {
             existingWaypointNames.Add(waypointName.Text.ToUpper());
             Importer.Point newPoint = new Importer.Point(waypointName.Text.ToUpper(), airportName.Text.ToUpper(), Double.Parse(latitude.Text), Double.Parse(longitude.Text));
             dbCommunicator.SavePoint(newPoint);
             returnWaypoint    = newPoint;
             this.DialogResult = DialogResult.OK;
             this.Close();
         }
         else
         {
             errorLabel.Text = "Waypoint with name " + waypointName.Text.ToUpper() + " already exists!";
         }
     }
 }