示例#1
0
文件: Reminders.cs 项目: faboo/Agent
        public void Remove(Reminder rem)
        {
            var command = DataStore.Connection.CreateCommand();

            reminders.Remove(rem);

            command.CommandText = "DELETE FROM [reminders] WHERE [name] = ?";
            command.Parameters.AddWithValue("name", rem.Name);

            command.ExecuteNonQuery();
            command.Dispose();
        }
示例#2
0
文件: Reminders.cs 项目: faboo/Agent
        public void Add(string name, string text, DateTime time, Frequency freq)
        {
            var command = DataStore.Connection.CreateCommand();
            var reminder = new Reminder(this) {
                Name = name,
                Text = text,
                Time = time,
                Frequency = freq
            };

            command.CommandText = "INSERT INTO [reminders] ([name], [text], [time], [frequency]) VALUES (?, ?, ?, ?)";
            command.Parameters.AddWithValue("name", name);
            command.Parameters.AddWithValue("text", text ?? "");
            command.Parameters.AddWithValue("time", time);
            command.Parameters.AddWithValue("freq", freq.ToString());

            command.ExecuteNonQuery();
            command.Dispose();

            reminders.Add(reminder);
            reminder.Init();
        }
示例#3
0
        public void Add(string name, string text, DateTime time, Frequency freq)
        {
            var command  = DataStore.Connection.CreateCommand();
            var reminder = new Reminder(this)
            {
                Name      = name,
                Text      = text,
                Time      = time,
                Frequency = freq
            };

            command.CommandText = "INSERT INTO [reminders] ([name], [text], [time], [frequency]) VALUES (?, ?, ?, ?)";
            command.Parameters.AddWithValue("name", name);
            command.Parameters.AddWithValue("text", text ?? "");
            command.Parameters.AddWithValue("time", time);
            command.Parameters.AddWithValue("freq", freq.ToString());

            command.ExecuteNonQuery();
            command.Dispose();

            reminders.Add(reminder);
            reminder.Init();
        }
示例#4
0
文件: Reminders.cs 项目: faboo/Agent
        public void Load()
        {
            var command = DataStore.Connection.CreateCommand();
            SqlCeDataReader reader = null;

            command.CommandText = "SELECT * FROM [reminders] ORDER BY [time]";

            reader = command.ExecuteReader();

            while(reader.Read()) {
                Reminder rem = new Reminder(this);

                rem.Name = reader.GetString("name");
                rem.Text = reader.GetString("text");
                rem.Time = reader.GetDateTime("time");
                rem.Frequency = reader.GetEnum<Frequency>("frequency");

                reminders.Add(rem);
                rem.Init();
            }

            reader.Dispose();
            command.Dispose();
        }