// Refresh the goal date label. private void RefreshGoalDate() { GuardTime guard = new GuardTime(); // Tell GuardTime to set the config. guard.setConfig(); // Initialize SQLize class and pass it the command. SQLize calc = new SQLize("SELECT * FROM Dates ORDER BY datetime DESC LIMIT 1"); // Tell SQLize to return OneDate and set it equal to a string. string aDate = calc.Read_OneDate(); // If the date is null, we don't want to be doing operations on it. // This could happen when Guard starts for the first time. if (aDate != null) { // Parse the string into a 64 bit integer. Int64 n; Int64.TryParse(aDate, out n); // Assign our original date -> necessary for the counting UP process. eventDateInt = n; // Tell guard to calculate the release date and set the goalDate string. goalDate = guard.CalcReleaseDate(n); // set our int value goalDateInt = guard.CalcReleaseDateInt(n); // Display the goal date without GMT information nextGoalLabel.Text = guard.RemoveGMT(goalDate); } }
// READ_DATES() // This method reads dates from the dates table into the 'aReturn' string and // includes formatting for new lines so that the text can be displayed in // a textbox control. public void Read_Dates() { // Start GuardTime GuardTime guard = new GuardTime(); // Create a connection to the DB. SQLiteConnection m_dbConnection; m_dbConnection = new SQLiteConnection("Data Source=GuardDB.sqlite;Version=3;"); m_dbConnection.Open(); // Create our command SQLiteCommand command = new SQLiteCommand(commandString, m_dbConnection); // Start the reader SQLiteDataReader reader = command.ExecuteReader(); // While the reader has data to read, append the text to the 'aReturn' string while (reader.Read()) { // Declare holder string string holder = ""; // Grab the value and feed it to GuardTime which will convert it to a string that's human readable // and set our holder string to this. holder = guard.EpochToDateString(reader.GetInt64(0)); // Remove the GMT info from the output (it's not really necessary for the user to see and takes up space). holder = guard.RemoveGMT(holder); // Append the values for every date we encounter. aReturn += holder + "\r\n"; } // Close the connection to the DB m_dbConnection.Close(); }