public void LoadData()
 {
     try
     {
         var sql = "SELECT id, title, detail,size, date, selected FROM " + TABLE_NAME;
         using (var statement = _connection.Prepare(sql))
         {
             while (SQLiteResult.ROW == statement.Step())
             {
                 string          id       = (string)statement[0];
                 string          title    = (string)statement[1];
                 string          detail   = (string)statement[2];
                 double          size     = (double)statement[3];
                 DateTime        date     = Convert.ToDateTime(statement[4]);
                 bool            selected = Convert.ToBoolean(statement[5]);
                 Models.myItem   temp     = new Models.myItem(id, title, detail, size, date, selected);
                 Models.TodoItem todoitem = new Models.TodoItem(temp);
                 ViewModels.TodoItemViewModel.GetInstance().AllItems.Add(todoitem);
             }
         }
     }
     catch (Exception)
     {
         throw;
     }
 }
        public async Task <TodoItem> AddTodoItem(Models.TodoItem value, int userId)
        {
            var existingTags = await _context.Tags
                               .Where(t => value.Tags.Contains(t))
                               .ToDictionaryAsync(t => t.Name);

            var item = new TodoItem
            {
                Title       = value.Title,
                Description = value.Description,
                OwnerId     = userId,

                Completed = null,
                Created   = DateTime.Now,
            };

            await UpdateTodoTags(item, value.Tags);

            _context.Add(item);

            await _context.SaveChangesAsync();

            StopTracking(item);

            return(item);
        }
Exemple #3
0
 public void UpadateTodoItem(string _id, string _jobName, DateTime _remindAt, DateTime _deadline, bool _hasdeadline, string _listid)
 {
     try
     {
         var db = App.myMidProject;
         using (var statement = db.Prepare("UPDATE TodoItem SET JobName = ?, RemindAt = ?, Deadline = ?, HasDeadline = ?, Complete = ?, ListId = ? WHERE Id = ?"))
         {
             statement.Bind(1, _jobName);
             statement.Bind(2, _remindAt.ToString());
             statement.Bind(3, _deadline.ToString());
             statement.Bind(4, _hasdeadline == true ? "1" : "0");
             statement.Bind(5, selectedItem.completed == true ? "1" : "0");
             statement.Bind(6, _listid);
             statement.Bind(7, _id);
             statement.Step();
         }
         for (int x = 0; x < allItems.Count; x++)
         {
             if (allItems[x].id == _id)
             {
                 selectedItem            = allItems[x];
                 allItems[x].jobName     = _jobName;
                 allItems[x].remindAt    = _remindAt;
                 allItems[x].deadline    = _deadline;
                 allItems[x].hasDeadline = _hasdeadline;
                 allItems[x].listid      = _listid;
                 break;
             }
         }
     }
     catch (Exception ex)
     {
         var i = new MessageDialog(ex.ToString()).ShowAsync();
     }
 }
Exemple #4
0
        public void AddTodoItem(string _jobName, DateTime _remindAt, DateTime _deadline, bool _hasDeadline, string _listid)
        {
            var db = App.myMidProject;

            try
            {
                var tmp = new Models.TodoItem(_jobName, _remindAt, _deadline, _hasDeadline, _listid);
                using (var statement = db.Prepare("INSERT INTO TodoItem (Id, JobName, RemindAt, Deadline, HasDeadline, Complete, ListId) VALUES (?, ?, ?, ?, ?, ?, ?)"))
                {
                    statement.Bind(1, tmp.id);
                    statement.Bind(2, tmp.jobName);
                    statement.Bind(3, tmp.remindAt.ToString());
                    statement.Bind(4, tmp.deadline.ToString());
                    statement.Bind(5, tmp.hasDeadline == true ? "1" : "0");
                    statement.Bind(6, tmp.completed == true ? "1" : "0");
                    statement.Bind(7, tmp.listid);
                    statement.Step();
                }
                allItems.Add(tmp);
            }
            catch (Exception ex)
            {
                var i = new MessageDialog(ex.ToString()).ShowAsync();
            }
        }
        public void UpdateTodoItem(string id, string title, string description, DateTime date, Uri img)
        {
            this.selectedItem.title  = title;
            this.selectedItem.detail = description;
            this.selectedItem.date   = date;
            img = img == null ? selectedItem.ImageUri : img;
            var str = img.ToString();

            if (str.IndexOf("Assets") == -1)
            {
                img = new Uri("ms-appx:///Assets/1.jpg");
            }
            else
            {
                img = new Uri("ms-appx:///" + str.Substring(str.IndexOf("Assets/")));
            }
            this.selectedItem.ImageUri = img;
            var db = App.conn;

            using (var statement = db.Prepare("UPDATE todolist SET Title = ?, Description = ?, Time = ?, Imguri = ? WHERE Id = ?;"))
            {
                statement.Bind(1, selectedItem.title);
                statement.Bind(2, selectedItem.detail);
                statement.Bind(3, selectedItem.date.ToString());
                var img1 = selectedItem.ImageUri == null ? new Uri("ms-appx:///Assets/1.jpg") : selectedItem.ImageUri;
                statement.Bind(4, img1.ToString());
                statement.Bind(5, selectedItem.id);
                statement.Step();
            }

            this.selectedItem = null;
        }
        public TaskDetail(Models.TodoItem item = null)
        {
            InitializeComponent();
            var context = new TaskDetailViewModel(item);

            BindingContext = context;
        }
Exemple #7
0
        //将数据库中的Item导入
        public async Task AddTodoItems(Models.TodoItem item)
        {
            await item.setImg();

            AllItems.Add(item);
            TileService.UpdateTileItem();   //更新磁贴
        }
Exemple #8
0
 public void RemoveTodoItem(string id)
 {
     // DIY
     this.allItems.Remove(this.selectedItem);
     // set selectedItem to null after remove
     this.selectedItem = null;
 }
        public Models.TodoItem Factory(string id = null, bool?complete = null, string title = null, DateTime?dueDate = null)
        {
            string imageNum = new Random().Next(5).ToString();
            // Uri format is different at design-time than at runtime - set appropriately
            Uri imageUri = null;

            if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
            {
                imageUri = new Uri("ms-appx:/Images/Placeholder" + imageNum + ".png");
            }
            else
            {
                imageUri = new Uri("ms-appx:///Images/Placeholder" + imageNum + ".png");
            }
            var item = new Models.TodoItem
            {
                Id         = id ?? Guid.NewGuid().ToString(),
                IsComplete = complete ?? false,
                Title      = title ?? string.Empty,
                ImageUri   = imageUri,
                DueDate    = DateTime.Now.AddDays(7)
            };

            return(item);
        }
Exemple #10
0
        internal Models.TodoItem SaveTodoItem(Models.TodoItem todoItem)
        {
            var sql = $"INSERT INTO Todo(Name, IsComplete) VALUES(?Name, ?IsComplete); SELECT LAST_INSERT_ID(); ";
            List <MySqlParameter> Parameters = new List <MySqlParameter>();

            MySqlCommand cmd = new MySqlCommand(sql);

            cmd.Parameters.AddWithValue("?Name", todoItem.Name);
            cmd.Parameters.AddWithValue("?IsComplete", todoItem.IsComplete);

            var DataTable = BuildDataTable(cmd);
            var obj       = DataTable.Rows[0]["LAST_INSERT_ID()"];

            todoItem.Id = int.Parse((DataTable.Rows[0]["LAST_INSERT_ID()"] != null ? DataTable.Rows[0]["LAST_INSERT_ID()"].ToString() : ""));

            if (todoItem.Id <= 0)
            {
                todoItem.Success = false;
            }

            else
            {
                //TODO BEN ideally wed do a "getone" to get the one i just added to the database.
            }

            return(todoItem);
        }
Exemple #11
0
        //@id list-id
        public void AddSingleItem(string _id, Models.TodoItem _item)
        {
            var db = App.myMidProject;

            try
            {
                for (int x = 0; x < allTodoItemLists.Count; x++)
                {
                    if (allTodoItemLists[x].id == _id)
                    {
                        allTodoItemLists[x].items.Add(_item);
                        allTodoItemLists[x].itemsid.Add(_item.id);
                        break;
                    }
                }
                using (var statement = db.Prepare("UPDATE List SET Itemsid = ? WHERE Id = ?"))
                {
                    statement.Bind(1, getAllItemId(_id));
                    statement.Bind(2, _id);
                    statement.Step();
                }
            }
            catch (Exception ex)
            {
                var i = new MessageDialog(ex.ToString()).ShowAsync();
            }
        }
Exemple #12
0
        public void UpdateTodoItem(string id, string title, string description)
        {
            // DIY

            // set selectedItem to null after update
            this.selectedItem = null;
        }
        public static void Initialize(IServiceProvider serviceProvider)
        {
            var context = (TodoContext)serviceProvider.
                          GetService(typeof(TodoContext));

            var todoItem1 = new Models.TodoItem
            {
                Id         = 1,
                Name       = "Luke",
                IsComplete = true
            };

            context.TodoItems.Add(todoItem1);

            var todoItem2 = new Models.TodoItem
            {
                Id         = 2,
                Name       = "Pepe",
                IsComplete = true
            };

            context.TodoItems.Add(todoItem2);

            context.SaveChanges();
        }
Exemple #14
0
 public void UpdateTodoItem(string id, string title, string description, DateTime date)
 {
     this.selectedItem.title       = title;
     this.selectedItem.description = description;
     this.selectedItem.date        = date;
     this.selectedItem             = null;
 }
Exemple #15
0
 //直接把修改过后的item传过来
 //不能改list名字
 public void UpdateSingleItem(string _id, string _itemId, Models.TodoItem _item)
 {
     try
     {
         foreach (Models.TodoItemList list in allTodoItemLists)
         {
             if (list.id == _id)
             {
                 foreach (Models.TodoItem item in list.items)
                 {
                     if (item.id == _itemId)
                     {
                         list.items.Remove(item);
                         list.items.Add(_item);
                         break;
                     }
                 }
                 break;
             }
         }
         var db = App.myMidProject;
         using (var statement = db.Prepare("UPDATE List SET Itemsid = ? WHERE Id = ?"))
         {
             statement.Bind(1, getAllItemId(_id));
             statement.Bind(2, _id);
             statement.Step();
         }
     }
     catch (Exception ex)
     {
         var i = new MessageDialog(ex.ToString()).ShowAsync();
     }
 }
 public void RemoveTodoItem(string id)
 {
     this.selectedItem = this.allItems.SingleOrDefault(i => i.id == id);
     this.allItems.Remove(this.selectedItem);
     // set selectedItem to null after remove
     this.selectedItem = null;
 }
Exemple #17
0
        public TodoItemViewModel()
        {
            this.selectedItem = null;
            var conn = App.conn;
            var sql  = "SELECT * FROM TodoItem";

            try
            {
                using (var statement = conn.Prepare(sql))
                {
                    while (SQLiteResult.ROW == statement.Step())
                    {
                        string dateStr = (string)statement[3];
                        dateStr = dateStr.Substring(0, dateStr.IndexOf(' '));
                        DateTime date = new DateTime(int.Parse(dateStr.Split('/')[0]), int.Parse(dateStr.Split('/')[1]), int.Parse(dateStr.Split('/')[2]));
                        this.AddTodoItem((long)statement[0], date, null,
                                         (string)statement[1], (string)statement[2]);
                    }
                }
            }
            catch (Exception)
            {
                throw;
            }
        }
Exemple #18
0
 public static DTO.TodoItemDTO ToDTO(this Models.TodoItem item)
 {
     return(new DTO.TodoItemDTO()
     {
         ID = item.ID,
         Name = item.Name,
         AllDay = item.AllDay,
         Content = item.Content,
         Start = item.Start,
         Duration = item.Duration,
         Completed = item.Completed,
         CategoryID = item.Category.ID,
         PriorityID = item.Priority?.ID,
         Alert = item.Alert != null ? new DTO.TodoItemAlertDTO()
         {
             AlertID = item.Alert.Alert.ID,
             PlaySound = item.Alert.PlaySound
         } : null,
         Recurrence = item.Recurrence != null ? new DTO.TodoItemRecurrenceDTO()
         {
             RecurrenceID = item.Recurrence.Recurrence.ID,
             RepeatAfterCompletion = item.Recurrence.RepeatAfterCompletion
         } : null,
     });
 }
 public void UpdateTodoItem(string id, string title, string description, DateTime date)
 {
     this.allItems.SingleOrDefault(i => i.id == id).title       = title;
     this.allItems.SingleOrDefault(i => i.id == id).description = description;
     this.allItems.SingleOrDefault(i => i.id == id).date        = date.Date;
     // set selectedItem to null after update
     this.selectedItem = null;
 }
Exemple #20
0
 public TodoItemViewModel()
 {
     this.selectedItem = null;
     // 加入三个用来测试的item
     this.allItems.Add(new Models.TodoItem(DateTime.Today, null, "Item1", "description1"));
     this.allItems.Add(new Models.TodoItem(DateTime.Today, null, "Item2", "description2"));
     this.allItems.Add(new Models.TodoItem(DateTime.Today, null, "好好学习", "天天向上"));
 }
Exemple #21
0
 private static TodoItemDTO ItemToDTO(Models.TodoItem todoItem)
 {
     return(new TodoItemDTO
     {
         Id = todoItem.Id,
         Name = todoItem.Name,
         IsComplete = todoItem.IsComplete
     });
 }
Exemple #22
0
        public void UpdateTodoItem(Models.TodoItem OriginTodo, Models.TodoItem UpdateInfo)
        {
            int index = this.allItems.IndexOf(OriginTodo);

            if (index >= 0 && index < this.allItems.Count)
            {
                this.allItems[index] = UpdateInfo;
            }
        }
Exemple #23
0
 public void UpdateTodoItem(string id, string title, string description, DateTime date, ImageSource img)
 {
     selectedItem.id          = id;
     selectedItem.title       = title;
     selectedItem.description = description;
     selectedItem.date        = date;
     selectedItem.img         = img;
     this.selectedItem        = null;
 }
Exemple #24
0
        private async void ExecuteRemoveItemCommand(Models.TodoItem param)
        {
            await _todoItemRepository.DeleteTodoItem(this.TodoItem);

            this.TodoItem = null;

            // Navigate back
            ((App)App.Current).NavigationService.GoBack();
        }
Exemple #25
0
 public void UpdateTodoItem(string id, string title, string description, DateTime date)
 {
     // DIY
     this.selectedItem.title       = title;
     this.selectedItem.description = description;
     this.selectedItem.date        = date;
     // set selectedItem to null after update
     this.selectedItem = null;
 }
Exemple #26
0
 protected override async void OnNavigatedTo(NavigationEventArgs e)
 {
     base.OnNavigatedTo(e);
     if (e.Parameter is string)
     {
         _TodoItem = await _todoItemRepository.RefreshTodoItemAsync(e.Parameter as string);
         await inkNotes.Load(_TodoItem.InkUri);
     }
 }
Exemple #27
0
 public void RemoveTodoItem(string id)
 {
     // DIY
     if (this.selectedItem.id == id)
     {
         this.allItems.Remove(selectedItem);
     }
     // set selectedItem to null after remove
     this.selectedItem = null;
 }
 public Models.TodoItem Clone(Models.TodoItem item)
 {
     return(Factory
            (
                Guid.Empty.ToString(),
                false,
                item.Title,
                item.DueDate
            ));
 }
Exemple #29
0
        protected override async void OnNavigatedTo(NavigationEventArgs e)
        {
            base.OnNavigatedTo(e);
            if (e.Parameter is string)
            {
                _TodoItem = await _todoItemRepository.RefreshTodoItemAsync(e.Parameter as string);

                await inkNotes.Load(_TodoItem.InkUri);
            }
        }
Exemple #30
0
        public void UpdateTodoItem(DateTime date, ImageSource img, string title, string description)
        {
            this.selectedItem.date        = date;
            this.selectedItem.img         = img;
            this.selectedItem.title       = title;
            this.selectedItem.description = description;

            // set selectedItem to null after update
            this.selectedItem = null;
        }
Exemple #31
0
        public static void Insert(string title, string detail, DateTime date, double size, ImageSource img)
        {
            var newModel = new Models.TodoItem(title, detail, date, size, img);

            DatabaseService.GetInstance().Insert(newModel);
            SaveBitmapToFileAsync((WriteableBitmap)img, newModel.id);
            TodoItemViewModel.GetInstance().AddTodoItem(newModel);

            App.UpdateFileAndTile();
        }
 public MainPageViewModel()
 {
     for (int i = 0; i < 100; i++)
     {
         var item = new Models.TodoItem()
         {
             Title = string.Format("Task Title {0}", i)
         };
         this.Items.Add(item);
     }
 }
 static public void RemoveTodoItem(string id)
 {
     // DIY
     allItems.Remove(SelectedItem);
     // set selectedItem to null after remove
     SelectedItem = null;
     var db = App.db;
     using (var statement = db.Prepare("DELETE FROM Todoitems WHERE ID = ?"))
     {
         statement.Bind(1, id);
         statement.Step();
     }
 }
 static public ArrayList getTodoItemsByKeywords(params string[] keywords)
 {
     var db = App.db;
     ArrayList items = new ArrayList();
     foreach (var keyword in keywords)
     {
         using (var statement = db.Prepare("SELECT * FROM Todoitems WHERE Title = ? OR Description = ?"))
         {
             statement.Bind(1, keyword);
             statement.Bind(2, keyword);
             while (statement.Step() == SQLiteResult.ROW)
             {
                 string id = (string)statement["ID"];
                 string title = (string)statement["Title"];
                 string description = (string)statement["Description"];
                 bool? completed = (Int64)statement["Completed"] == 0 ? false : true;
                 DateTime date = (DateTime.Parse((string)statement["Date"]));
                 string ImageName = (string)statement["ImageName"];
                 Models.TodoItem item = new Models.TodoItem(id, title, description, completed, date, ImageName);
                 items.Add(item);
             }
         }
         //using (var statement = db.Prepare("SELECT * FROM Todoitems WHERE Description = ?"))
         //{
         //    statement.Bind(1, keyword);
         //    while (statement.Step() == SQLiteResult.ROW)
         //    {
         //        string id = (string)statement["ID"];
         //        string title = (string)statement["Title"];
         //        string description = (string)statement["Description"];
         //        bool? completed = (Int64)statement["Completed"] == 0 ? false : true;
         //        DateTime date = (DateTime.Parse((string)statement["Date"]));
         //        string ImageName = (string)statement["ImageName"];
         //        Models.TodoItem item = new Models.TodoItem(id, title, description, completed, date, ImageName);
         //        items.Add(item);
         //    }
         //}
     }
     return items;
 }
 public Models.TodoItem Factory(string id = null, bool? complete = null, string title = null, DateTime? dueDate = null)
 {
     string imageNum = new Random().Next(5).ToString();
     // Uri format is different at design-time than at runtime - set appropriately
     Uri imageUri = null;
     if (Windows.ApplicationModel.DesignMode.DesignModeEnabled)
     {
         imageUri = new Uri("ms-appx:/Images/Placeholder" + imageNum + ".png");
     }
     else
     {
         imageUri = new Uri("ms-appx:///Images/Placeholder" + imageNum + ".png");
     }
     var item = new Models.TodoItem
     {
         Id = id ?? Guid.NewGuid().ToString(),
         IsComplete = complete ?? false,
         Title = title ?? string.Empty,
         ImageUri = imageUri,
         DueDate = DateTime.Now.AddDays(7)
     };
     return item;
 }
 static async public void LoadAll()
 {
     var db = App.db;
     using (var statement = db.Prepare("SELECT * FROM TodoItems"))
     {
         while (statement.Step() == SQLitePCL.SQLiteResult.ROW)
         {
             string id = (string)statement["ID"];
             string title = (string)statement["Title"];
             string description = (string)statement["Description"];
             bool? completed = (Int64)statement["Completed"] == 0 ? false : true;
             DateTime date = (DateTime.Parse((string)statement["Date"]));
             string ImageName = (string)statement["ImageName"];
             Models.TodoItem item = new Models.TodoItem(id, title, description, completed, date, ImageName);
             await item.LoadImageAsync();
             allItems.Add(item);
         }
     }
 }