public ObservableCollection<CDocs> GetDocs() { ObservableCollection<CDocs> docs = new ObservableCollection<CDocs>(); using (var statement = con.Prepare("SELECT id, title, information FROM CDocs")) { while (statement.Step() == SQLiteResult.ROW) { CDocs doc = new CDocs(); doc.id = (long)statement[0]; doc.title = (string)statement[1]; doc.information = (string)statement[2]; docs.Add(doc); } } return docs; }
public CDocs GetDoc(long id) { CDocs doc = null; using (var statement = con.Prepare("SELECT id, title, information FROM CDocs WHERE id=?")) { statement.Bind(1, id); if (statement.Step() == SQLiteResult.ROW) { doc = new CDocs(); doc.id = (long)statement[0]; doc.title = (string)statement[1]; doc.information = (string)statement[2]; } } return doc; }
private async void SaveDoc_Button(object sender, RoutedEventArgs e) { if (!String.IsNullOrWhiteSpace(textBoxSave.Text)) { CDocs doc = new CDocs { title = textBoxSave.Text, information = mainText }; App.repo.Insert(doc); if (Frame.CanGoBack) Frame.GoBack(); } else { MessageDialog msgbox = new MessageDialog("Write document name", "WARNING"); await msgbox.ShowAsync(); } }
public void Update(CDocs doc) { using (var statement = con.Prepare("UPDATE CDocs SET title=?, information=? WHERE id=?")) { statement.Bind(1, doc.title); statement.Bind(2, doc.information); statement.Bind(3, doc.id); statement.Step(); } }
public void Insert(CDocs doc) { using (var statement = con.Prepare("INSERT INTO CDocs(title, information) VALUES (?,?)")) { statement.Bind(1, doc.title); statement.Bind(2, doc.information); statement.Step(); } }