public FoodPageViewModel() { /*************おかしくなったらここを解除****************/ /* * if (FoodModel.SelectFood() != null) * { * * var query = FoodModel.SelectFood(); * * Foods = new ObservableCollection<Food>(); * foreach (var food in query) * { * Food f = new Food * { * F_no = food.F_no, * F_name = food.F_name, * F_result = food.F_result, * F_date = food.F_date * }; * Foods.Add(f); * } * * } * else * { * Foods = new ObservableCollection<Food> { * new Food { * F_name = "NoData", * //F_date = new DateTime(1970,1,1) * F_result = 999 * } * }; * } */ /**********************ダメだったらここを消す********************/ if (FoodModel.SelectFood() != null) { var query01 = FoodModel.SelectFood(); Foods = new ObservableCollection <Food>(); foreach (var food01 in query01) { Food f01 = new Food { F_no = food01.F_no, F_name = food01.F_name, F_result = food01.F_result, F_date = food01.F_date }; FoodModel.UpdateF_date(food01.F_no, food01.F_name, food01.F_result, food01.F_date); Foods.Add(f01); //FoodModel.UpdateF_date(food01.F_no, food01.F_name, food01.F_result, food01.F_date); } Foods = new ObservableCollection <Food>(); foreach (var food02 in query01) { Food f02 = new Food { F_no = food02.F_no, F_name = food02.F_name, F_result = food02.F_result, F_date = food02.F_date }; Foods.Add(f02); } } else { Foods = new ObservableCollection <Food> { new Food { F_name = "NoData", //F_date = new DateTime(1970,1,1) F_result = 999 } }; } /****************************************************************/ }
/***************「すべて削除ボタン」が押された時********************/ private void Insert02_Clicked(object sender, EventArgs e) { FoodModel.DeleteAllFood(); }
/***************「登録ボタン」が押された時*********************/ private void Insert01_Clicked(object sender, EventArgs e) { //Foodテーブルにインサートする FoodModel.InsertFood(1, NameEntry.Text, d);// DisplayAlert(NameEntry.Text, d.ToString(), "ok"); }