コード例 #1
0
 /// <summary>
 /// Gets the database.
 /// </summary>
 /// <returns>The database.</returns>
 public static TodoItemDatabase GetDatabase()
 {
     if (instance == null)
     {
         instance = new TodoItemDatabase();
     }
     return(instance);
 }
コード例 #2
0
        // Saves the item to the database
        public void OnSave(object sender, EventArgs e)
        {
            if (!Validate())
            {
                return;
            }

            TodoItemDatabase.GetDatabase().SaveItem(Model);
            Navigation.PopAsync();
        }
コード例 #3
0
        //On Delete. The async operator allows us to use the await operator in our method.
        public async void OnDelete(object sender, EventArgs e)
        {
            // Display a popup
            var answer = await DisplayAlert("Are You Sure?", "This data will be lost forever and ever and ever.", "Delete", "NO NO NO");

            //if true, delete the item
            if (answer)
            {
                TodoItemDatabase.GetDatabase().DeleteItem(Model.ID);
                // back button
                await Navigation.PopAsync();
            }
        }
コード例 #4
0
 public static void SetDatabaseConnection(SQLite.Net.SQLiteConnection connection)
 {
     conn     = connection;
     database = new TodoItemDatabase(conn);
 }
コード例 #5
0
ファイル: App.cs プロジェクト: Randy3W/xamarin-forms-samples
		public static void SetDatabaseConnection (SQLite.Net.SQLiteConnection connection)
		{
			conn = connection;
			database = new TodoItemDatabase (conn);
		}
コード例 #6
0
 // called when becoming visible
 protected override void OnAppearing()
 {
     base.OnAppearing();
     //refresh our items list
     Items = TodoItemDatabase.GetDatabase().GetItems();
 }
コード例 #7
0
 /// <summary>
 /// Gets the database.
 /// </summary>
 /// <returns>The database.</returns>
 public static TodoItemDatabase GetDatabase()
 {
     if(instance == null)
         instance = new TodoItemDatabase();
     return instance;
 }