Esempio n. 1
0
            private void UpdateNote(long noteId, string title, ObservableCollection <TodoNote.TodoEntry> TodoEntries)
            {
                string           timeStamp = TimeUtil.GetStringTimestamp();
                ISQLiteStatement statement = dbConn.Prepare(UPDATE_TODO_NOTE);

                statement.Bind(1, title);
                statement.Bind(2, timeStamp);
                statement.Bind(3, null);
                statement.Bind(4, noteId);
                statement.Step();
                TodoNote todoNote = (TodoNote)GetNoteById(noteId);

                // Delete all todo note contents
                foreach (TodoNote.TodoEntry entry in ((TodoNote)GetNoteById(noteId)).TodoEntries)
                {
                    statement.Reset();
                    statement.ClearBindings();
                    statement = dbConn.Prepare(DELETE_TODO_NOTE_CONTENT);
                    statement.Bind(1, entry.Id);
                    statement.Step();
                }
                // Add all todo note new contents
                foreach (TodoNote.TodoEntry entry in TodoEntries)
                {
                    statement.Reset();
                    statement.ClearBindings();
                    statement = dbConn.Prepare(INSERT_TODO_NOTE_CONTENT);
                    statement.Bind(1, entry.Content);
                    statement.Bind(2, ConvertBoolToInt(entry.IsDone));
                    statement.Bind(3, noteId);
                    statement.Bind(4, timeStamp);
                    statement.Step();
                }
            }
Esempio n. 2
0
            public void AddNote(string title, ObservableCollection <TodoNote.TodoEntry> entries, string schedulingId, DateTimeOffset dateTime)
            {
                long             notificationId = NotificationHelper.AddNotification(schedulingId, dateTime);
                ISQLiteStatement statement      = dbConn.Prepare(INSERT_TODO_NOTE);

                statement.Bind(1, title);
                statement.Bind(2, TimeUtil.GetStringTimestamp());
                statement.Bind(3, notificationId);
                statement.Step();
                foreach (TodoNote.TodoEntry entry in entries)
                {
                    statement = dbConn.Prepare(INSERT_TODO_NOTE_CONTENT);
                    statement.Bind(1, entry.Content);
                    int done = ConvertBoolToInt(entry.IsDone);
                    statement.Bind(2, done);
                    ISQLiteStatement stat = dbConn.Prepare(SELECT_LAST_NOTE_INSERT_ID);
                    stat.Step();
                    long noteID = (long)stat[0];
                    statement.Bind(3, noteID);
                    statement.Bind(4, TimeUtil.GetStringTimestamp());
                    statement.Step();
                    statement.Reset();
                    statement.ClearBindings();
                }
            }
Esempio n. 3
0
            public void DeleteNote(long id)
            {
                ISQLiteStatement statement = dbConn.Prepare(DELETE_PHOTO_NOTE);

                statement.Bind(1, id);
                statement.Step();
                statement.Reset();
                statement.ClearBindings();
                DeleteNotificationByNoteId(id);
            }
Esempio n. 4
0
            public void DeleteNote(long id)
            {
                ISQLiteStatement statement = dbConn.Prepare(DELETE_TODO_NOTE_CONTENT);
                TodoNote         todoNote  = (TodoNote)GetNoteById(id);

                foreach (TodoNote.TodoEntry entry in todoNote.TodoEntries)
                {
                    statement.Bind(1, entry.Id);
                    statement.Step();
                    statement.Reset();
                    statement.ClearBindings();
                }
                statement = dbConn.Prepare(DELETE_TODO_NOTE);
                statement.Bind(1, id);
                statement.Step();
                DeleteNotificationByNoteId(id);
            }
Esempio n. 5
0
            /// <summary>
            /// Bind parameters to the statement.
            /// </summary>
            /// <param name="statement">The statement to bind the parameters to.</param>
            private void BindParameters(ISQLiteStatement statement)
            {
                string currentParameterKey = string.Empty;

                statement.ClearBindings();

                try
                {
                    foreach (var parameter in this.Parameters)
                    {
                        currentParameterKey = parameter.Key;
                        object sqlParameterValue = SqlTypeHelper.ConvertManagedValueToSqlValue(parameter.Value);
                        statement.Bind(currentParameterKey, sqlParameterValue);
                    }
                }
                catch (SQLiteException ex)
                {
                    string message = string.Format("An error occurred when binding parameter '{0}'. Check if parameter is present in the query text. See inner exception for details.", currentParameterKey);
                    throw new SQLiteException(message, ex);
                }
            }
 public static void ResetAndClearBindings(this ISQLiteStatement statement)
 {
     statement.Reset();
     statement.ClearBindings();
 }