Пример #1
0
        //DateTime yyyymmdd;//追加



        /********************ここから追加******************************************/

        async Task Handle_ClickedAsync(object sender, System.EventArgs e)
        {
            try
            {
                if (bWeight.Text == null)
                {
                    DisplayAlert("", "体重を入力してください", "OK");
                }
                else if (bFat.Text == null)
                {
                    DisplayAlert("", "体脂肪率を入力してください", "OK");
                }


                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 = DateTime.Today;


                TodoItem sameDateItem = await db.GetItemByCreatedAsync(dCreated);

                if (sameDateItem == null)
                {
                    TodoItem item = new TodoItem()
                    {
                        Created = dCreated, Bweight = B_Weight, Bfat = B_Fat
                    };
                    await db.SaveItemAsync(item);
                    await DisplayAlert("", "記録されました:" + item.Created, "OK");
                }
                else
                {
                    await db.DeleteItemAsync(sameDateItem);

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

                    //await DisplayAlert("", "更新されました:{" + sameDateItem.Created + "}→{" + item.Created + "}", "OK");
                    await DisplayAlert("", "更新されました", "OK");
                }

                Application.Current.MainPage = new MainPage();
            }
            catch (Exception)
            {
                DisplayAlert("", "数値を入力してください", "OK");
            }

            /*private void eCreated_DateSelected(object sender, DateChangedEventArgs e)//追加
             * {
             *  yyyymmdd = new DateTime(eCreated.Date.Year, eCreated.Date.Month, eCreated.Date.Day);
             * }*/
        }
Пример #2
0
 public static TodoItemDatabase getDatabase()
 {
     if (db == null)
     {
         db = new TodoItemDatabase(DependencyService.Get <IFileHelper>().GetLocalFilePath("TodoSQLite.db3"));
     }
     return(db);
 }
Пример #3
0
        //DateTime yyyymmdd;//追加



        /********************ここから追加******************************************/

        public async void Handle_ClickedAsync(object sender, System.EventArgs e)
        {
            try
            {
                if (bWeight.Text == null)
                {
                    DisplayAlert("", "体重を入力してください", "OK");
                }
                else if (bFat.Text == null)
                {
                    DisplayAlert("", "体脂肪率を入力してください", "OK");
                }


                var      db       = TodoItemDatabase.getDatabase();
                int      B_Weight = int.Parse(bWeight.Text);
                int      B_Fat    = int.Parse(bFat.Text);
                DateTime dCreated = DateTime.Today;


                TodoItem sameDateItem = await db.GetItemByCreatedAsync(dCreated);

                if (sameDateItem == null)
                {
                    TodoItem item = new TodoItem()
                    {
                        Created = dCreated, Bweight = B_Weight, Bfat = B_Fat
                    };
                    await db.SaveItemAsync(item);
                    await DisplayAlert("", "記録されました:" + item.Created, "OK");
                }
                else
                {
                    await db.DeleteItemAsync(sameDateItem);

                    TodoItem item = new TodoItem()
                    {
                        Created = dCreated, Bweight = B_Weight, Bfat = B_Fat
                    };
                    await db.SaveItemAsync(item);
                    await DisplayAlert("", "更新されました:{" + sameDateItem.Created + "}→{" + item.Created + "}", "OK");
                }

                Application.Current.MainPage = new MainPage();
            }
            catch (Exception)
            {
                DisplayAlert("", "数値を入力してください", "OK");
            }
        }
Пример #4
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);
        }
Пример #5
0
        private static DataPoint[] getBFatList()
        {
            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)
            {
                double Today = DateTimeAxis.ToDouble(item.Created);

                points[i++] = new DataPoint(Today, item.Bfat);//  X軸 Y軸
            }
            return(points);
        }
Пример #6
0
        /********************ここから追加******************************************/

        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("", "記録されました", "OK");
            Application.Current.MainPage = new MainPage();
        }