Beispiel #1
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (radioButton3.Checked)
            {
                //Manual Input
                DataBase.DataBase db      = new DataBase.DataBase();
                double            lat     = double.Parse(textLat.Text, CultureInfo.GetCultureInfo("en-US"));
                double            lon     = double.Parse(textLon.Text, CultureInfo.GetCultureInfo("en-US"));
                double            height  = double.Parse(textHeight.Text, CultureInfo.GetCultureInfo("en-US"));
                Ground.Station    station = new Ground.Station(textStationName.Text, lat, lon, height);

                db.writeStation(station);
                this.Close();
            }
            if (radioButton1.Checked)
            {
                using (var reader = new StreamReader(stationFilePath))
                {
                    DataBase.DataBase db = new DataBase.DataBase();
                    string            line;
                    while ((line = reader.ReadLine()) != null)
                    {
                        string   _name;
                        double   _latitude;
                        double   _longitude;
                        double   _height;
                        string[] res = line.Split(' ');
                        if (res.Count() >= 3)
                        {
                            _name      = res[0];
                            _latitude  = Convert.ToDouble(res[1]);
                            _longitude = Convert.ToDouble(res[2]);
                            if (res.Count() == 4)
                            {
                                _height = Convert.ToDouble(res[3]);
                            }
                            else
                            {
                                _height = 0.0;
                            }
                            Ground.Station station = new Ground.Station(_name, _latitude, _longitude, _height);
                            db.writeStation(station);
                        }
                    }
                }
            }
        }