Esempio n. 1
0
        public static Reminder QueryReminder(int ID = -1)
        {
            Reminder reminder = new Reminder();
            string   intID;

            if (ID == -1)
            {
                intID = "null";
            }
            else
            {
                intID = ID.ToString();
            }

            SqliteConnection conn    = OpenDatabase();
            SqliteCommand    command = conn.CreateCommand();

            command.CommandText = $"Select TReminders.reminderID, TReminders.reminderTitle, TReminders.reminderDescription, TReminders.reminderTime, TReminderDates.reminderDate, TReminders.isExpired, TReminders.isDeleted, TReminders.isSet From TReminders, TReminderDates Where TReminders.reminderID = TReminderDates.reminderID and TReminders.reminderID = COALESCE({intID}, TReminders.reminderID); ";
            using (SqliteDataReader reader = command.ExecuteReader())
            {
                while (reader.Read())
                {
                    reminder = Reminder.FromDataRow(reader);
                }
            }
            conn.Close();
            return(reminder);
        }
Esempio n. 2
0
        public static List <Reminder> QueryAllUnexpiredReminders()
        {
            List <Reminder> reminders = new List <Reminder>();
            string          query     = @"SELECT TReminders.reminderID, TReminders.reminderTitle, TReminders.reminderTime, TReminders.reminderDescription, TReminders.isDeleted, TReminders.IsExpired, TReminders.isSet, TReminderDates.reminderDate
                            FROM TReminders, TReminderDates
                            WHERE TReminderDates.reminderID = TReminders.reminderID AND TReminders.isDeleted <> 1 AND TReminders.isExpired <> 1
                            ORDER BY TReminderDates.reminderDate,TReminders.reminderTime;";

            using (SqliteConnection connection = OpenDatabase())
            {
                SqliteCommand command = connection.CreateCommand();
                command.CommandText = query;
                using (SqliteDataReader reader = command.ExecuteReader())
                {
                    while (reader.Read())
                    {
                        reminders.Add(Reminder.FromDataRow(reader));
                    }
                }
            }
            return(reminders);
        }