//! Delete a object from the Satellite and TLE Database /*! * */ private void toolStripMenuItem10_Click(object sender, EventArgs e) { string satname = satelliteDataGrid.SelectedRows[0].Cells[0].Value.ToString(); One_Sgp4.Tle tle = _MainDataBase.getTleDataFromDB(satelliteNameLabel.Text); _MainDataBase.deleteSatellite(satname); _MainDataBase.deleteTle(tle.getNoradID()); UpdateAllLists(); }
//! Satellite grid on Selection Changed /*! * Displays information about the currently selected satellite */ private void satelliteDataGrid_SelectionChanged(object sender, EventArgs e) { if (!_MainDataBase.connected()) { _MainDataBase.connectDB(); } try { satelliteNameLabel.Text = satelliteDataGrid.SelectedRows[0].Cells[0].Value.ToString(); One_Sgp4.Tle tle = _MainDataBase.getTleDataFromDB(satelliteNameLabel.Text); if (tle.getStartYear() < 85) { if (tle.getStartYear() > 10) { SatLabel1.Text = "20" + tle.getStartYear().ToString(); } else { SatLabel1.Text = "200" + tle.getStartYear().ToString(); } } else { SatLabel1.Text = "19" + tle.getStartYear().ToString(); } SatLabel2.Text = tle.getStartNr().ToString(); SatLabel3.Text = tle.getNoradID().ToString(); if (tle.getClassification() == 0) { SatLabel4.Text = "UNCLASSIFIED"; } if (tle.getClassification() == 1) { SatLabel4.Text = "CLASSIFIED"; } if (tle.getClassification() == 1) { SatLabel4.Text = "SECRET"; } SatLabel5.Text = tle.getSetNumber().ToString(); pictureBox4.Image = Drawer.MapDrawer.drawSatellite(tle); } catch { satelliteNameLabel.Text = " -- "; } }
//! Write TLE-Data to DataBase /*! * \param tleData TLEData to be writen in DataBase. */ public void writeTleData(One_Sgp4.Tle tleData) { if (!isConnected) { connectDB(); } SQLiteCommand command = new SQLiteCommand(m_dbConnection); SQLiteCommand addSatCommand = new SQLiteCommand(m_dbConnection); int count = 0; command.CommandText = String.Format("SELECT count(*) FROM {0} WHERE noradID='{1}';", Constants.TleDB, tleData.getNoradID()); try { count = Convert.ToInt32(command.ExecuteScalar()); } catch { count = 0; } if (count == 0) { command.CommandText = String.Format( Constants.insertTle, Constants.TleDB, tleData.getName(), tleData.getNoradID(), tleData.getClassification(), tleData.getStartYear(), tleData.getStartNr(), tleData.getPice(), tleData.getEpochYear(), tleData.getEpochDay(), tleData.getFirstMeanMotion(), tleData.getSecondMeanMotion(), tleData.getDrag(), tleData.getEphemeris(), tleData.getSetNumber(), tleData.getFirstCheckSum(), tleData.getSatNumber(), tleData.getInclination(), tleData.getRightAscendingNode(), tleData.getEccentriciy(), tleData.getPerigee(), tleData.getMeanAnomoly(), tleData.getMeanMotion(), tleData.getRelevationNumber(), tleData.getSecCheckSum()); command.ExecuteNonQuery(); addSatCommand.CommandText = String.Format( Constants.insertSat, Constants.SatDB, tleData.getName(), tleData.getNoradID()); addSatCommand.ExecuteNonQuery(); } else { //delet old Entry command.CommandText = String.Format( Constants.deleteTLE, Constants.TleDB, tleData.getNoradID()); command.ExecuteNonQuery(); //insert new Entry command.CommandText = String.Format( Constants.insertTle, Constants.TleDB, tleData.getName(), tleData.getNoradID(), tleData.getClassification(), tleData.getStartYear(), tleData.getStartNr(), tleData.getPice(), tleData.getEpochYear(), tleData.getEpochDay(), tleData.getFirstMeanMotion(), tleData.getSecondMeanMotion(), tleData.getDrag(), tleData.getEphemeris(), tleData.getSetNumber(), tleData.getFirstCheckSum(), tleData.getSatNumber(), tleData.getInclination(), tleData.getRightAscendingNode(), tleData.getEccentriciy(), tleData.getPerigee(), tleData.getMeanAnomoly(), tleData.getMeanMotion(), tleData.getRelevationNumber(), tleData.getSecCheckSum()); command.ExecuteNonQuery(); SQLiteCommand delcommand = new SQLiteCommand(m_dbConnection); delcommand.CommandText = String.Format( Constants.deleteSatellite2, Constants.SatDB, tleData.getNoradID()); delcommand.ExecuteNonQuery(); addSatCommand.CommandText = String.Format( Constants.insertSat, Constants.SatDB, tleData.getName(), tleData.getNoradID()); addSatCommand.ExecuteNonQuery(); } }