예제 #1
0
 public static TodoItemDatabase getDatabase()
 {
     if (db == null)
     {
         db = new TodoItemDatabase(DependencyService.Get <IFileHelper>().GetLocalFilePath("TodoSQLite.db3"));
     }
     return(db);
 }
예제 #2
0
        private static DataPoint[] getItemList()
        {
            TodoItemDatabase        itemDataBase = TodoItemDatabase.getDatabase();
            Task <List <TodoItem> > taskItemList = itemDataBase.GetItemsAsync();
            List <TodoItem>         itemList     = taskItemList.Result;

            DataPoint[] points = new DataPoint[itemList.Count];
            int         i      = 0;

            foreach (TodoItem item in itemList)
            {
                points[i++] = new DataPoint(item.ID, item.Bweight);
            }
            return(points);
        }
        /********************ここから追加******************************************/

        void Handle_Clicked(object sender, System.EventArgs e)
        {
            var db = TodoItemDatabase.getDatabase();
            //String sName = eName.Text;
            //String sNotes = eNotes.Text;
            //Boolean bDone = eDone.IsToggled;
            int      B_Weight = int.Parse(bWeight.Text);
            int      B_Fat    = int.Parse(bFat.Text);
            DateTime dCreated = eCreated.Date;

            TodoItem item = new TodoItem()
            {
                Bweight = B_Weight, Created = dCreated, Bfat = B_Fat
            };

            db.SaveItemAsync(item);
            DisplayAlert("TodoItem", "追加されたよ", "OK");
            Application.Current.MainPage = new MainPage();
        }