Esempio n. 1
0
        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;
        }
Esempio n. 2
0
        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;
        }
Esempio n. 3
0
        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();
            }
        }
Esempio n. 4
0
 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();
     }
 }
Esempio n. 5
0
 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();
     }
 }