private async void UpdateCheckedTodoItem(thing item) { // This code takes a freshly completed TodoItem and updates the database. When the MobileService // responds, the item is removed from the list await todoTable.UpdateAsync(item); RefreshTodoItems(); // items.Remove(item); }
private async void fremove(thing item) { jfitems = await ftodoTable .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day && fthingItem.User == Username && fthingItem.Level == item.Level && fthingItem.Type == item.Type && fthingItem.Content == item.Content) .ToCollectionAsync(); if (jfitems.Count > 0) { await ftodoTable.DeleteAsync(jfitems.First()); } }
private async void fadd(thing item) { DateTime d = DateTime.Now; //a.Text = d.Year.ToString(); jfitems = await ftodoTable .Where(fthingItem => fthingItem.Year == year && fthingItem.Month == month && fthingItem.Day == day && fthingItem.User == Username && fthingItem.Level == item.Level && fthingItem.Type == item.Type && fthingItem.Content == item.Content) .ToCollectionAsync(); if (jfitems.Count == 0) { fthing f = new fthing { Year = year, Month = month, Day = day, User = Username, Level = item.Level, Type = item.Type, Content = item.Content, Fhour = d.Hour - item.Hour }; await ftodoTable.InsertAsync(f); } }
private void CheckBox_Checked_1(object sender, RoutedEventArgs e) { CheckBox cb = (CheckBox)sender; cb.IsChecked = false; thing item = cb.DataContext as thing; if (item.Is == "未完成") { item.Is = "已完成"; item.Text = item.Content + " " + item.Type + " " + item.Level + " " + item.Hour + " " + "已完成"; fadd(item); } else if (item.Is == "已完成") { item.Is = "未完成"; item.Text = item.Content + " " + item.Type + " " + item.Level + " " + item.Hour + " " + "未完成"; fremove(item); } // i.Text = "sadasd"; l.Add(item); UpdateCheckedTodoItem(item); }
private void Button_Click_1(object sender, RoutedEventArgs e) { String time = Time.Text; char[] s = new char[1]; s[0] = '/'; String[] t = time.Split(s); if (t.Length != 3) { MessageBox.Show("格式不匹配"); } else //Time.Text = t[0] + t[1] + t[2]; { if (t[0].Length == 4 && t[1].Length == 2 && t[2].Length == 2 && t[0].ElementAt(0) == '2' && t[0].ElementAt(1) == '0' && t[0].ElementAt(2) == '1' && (t[0].ElementAt(3) == '3' || t[0].ElementAt(3) == '4') && (int)(t[1].ElementAt(0)) - 48 >= 0 && (int)(t[1].ElementAt(0)) - 48 <= 1 && (int)(t[1].ElementAt(1)) - 48 >= 0 && (int)(t[1].ElementAt(0)) - 48 <= 9 && (int)(t[2].ElementAt(0)) - 48 >= 0 && (int)(t[2].ElementAt(0)) - 48 <= 3 && (int)(t[2].ElementAt(1)) - 48 >= 0 && (int)(t[2].ElementAt(1)) - 48 <= 9) { int year = int.Parse(t[0]); int month = int.Parse(t[1]); int day = int.Parse(t[2]); var addthing = new thing { User = Username, Content = content.Text, Month = month, Year = year, Day = day }; if (geren.IsChecked == true) { addthing.Type = "个人"; } if (tuanti.IsChecked == true) { addthing.Type = "团体"; } if (richang.IsChecked == true) { addthing.Level = "日常"; } if (zhouqi.IsChecked == true) { addthing.Level = "周期"; } if (teshu.IsChecked == true) { addthing.Level = "特殊"; } if (shengsiyouguan.IsChecked == true) { addthing.Level = "生死攸关"; } addthing.Is = "未完成"; String S = hour.Text; if ((S[0] == '0' || S[0] == '1' || S[0] == '2') && (int)(S[1]) - 48 >= 0 && (int)(S[1]) - 48 <= 9) { addthing.Hour = int.Parse(hour.Text); addthing.Text = addthing.Content + " " + addthing.Type + " " + addthing.Level + " " + addthing.Hour + " " + addthing.Is; add(addthing); } else { MessageBox.Show("格式不匹配"); } } else { MessageBox.Show("格式不匹配"); } } }
private async void add(thing addthing) { await todoTable.InsertAsync(addthing); }