public void Search(string text) { string sql_like = '%' + text + '%'; List <ListItem> list = conn.Query <ListItem>("select * from ListItem " + "where title like ? " + "or detail like ? " + "or date like ?", sql_like, sql_like, sql_like); Allitems.Clear(); foreach (var item in list) { Allitems.Add(item); } }
public List <ListItem> Search(string text) { Regex reg = new Regex(text); SQLiteCommand cmd = conn.CreateCommand("select * from ListItem"); List <ListItem> list = cmd.ExecuteQuery <ListItem>(); List <ListItem> list2 = new List <ListItem>(); Allitems.Clear(); foreach (var item in list) { if (reg.IsMatch(item.title) || reg.IsMatch(item.detail) || reg.IsMatch(item.date)) { Allitems.Add(item); } } return(list2); }
public async void DeleteListItem(ListItem item = null) { try { if (item != null) { conn.Delete(item); Allitems.Remove(item); } else { conn.Delete(select_item); Allitems.Remove(select_item); select_item = null; } UpdateTile(); } catch { MessageDialog dialog = new MessageDialog("数据库异常,删除数据失败"); await dialog.ShowAsync(); } }
public async void AddListItem(ListItem item = null) { try { if (item != null) { conn.Insert(item); Allitems.Add(item); } else { conn.Insert(select_item); Allitems.Add(select_item); select_item = null; } UpdateTile(); } catch { MessageDialog dialog = new MessageDialog("数据库异常,插入数据失败"); await dialog.ShowAsync(); } }