示例#1
0
        private void RefreshData()
        {
            _categoryStore.Clear();
            _taskStore.Clear();

            this._dataContext.Connection.Open();
            const string selectCategories = "select * from tblCategories";
            const string selectRecords    = "select * from tblTodoItems";

            var execute = new SQLiteCommand(selectCategories, this._dataContext.Connection);
            var reader  = execute.ExecuteReader();

            while (reader.Read())
            {
                var category = new Category(reader["categoryId"]?.ToString() ?? "null",
                                            DbItem.RestoreSpecialChars(reader["category"]?.ToString()) ?? "null",
                                            DbItem.RestoreSpecialChars(reader["description"]?.ToString()) ?? "null", true);

                _categoryStore.AppendValues(category);
            }

            execute = new SQLiteCommand(selectRecords, this._dataContext.Connection);
            reader  = execute.ExecuteReader();

            while (reader.Read())
            {
                DateTime.TryParse(reader["startDate"].ToString(), CultureInfo.CurrentCulture,
                                  DateTimeStyles.AssumeUniversal, out var start);

                DateTime.TryParse(reader["dueDate"].ToString(), CultureInfo.CurrentCulture,
                                  DateTimeStyles.AssumeUniversal, out var end);

                var item = new Activity(reader["todoId"]?.ToString() ?? "null",
                                        DbItem.RestoreSpecialChars(reader["todo"]?.ToString()) ?? "null",
                                        DbItem.RestoreSpecialChars(reader["description"]?.ToString()) ?? "null",
                                        reader["category"]?.ToString() ?? "null", reader["itemPriority"]?.ToString() ?? "null", start, end);

                _taskStore.AppendValues(item);
            }

            this._dataContext.Connection.Close();
            UpdateCalendarMarks();
        }