//デリート押された async void OnDelete_Clicked(object sender, EventArgs args) { string no = ((CustomButtonDelete)sender).NoText; string name = ((CustomButtonDelete)sender).NameText; /* * DisplayAlert("Delete", "主キー" + no + " " + name, "ok"); * * /***試し***/ /* * int s_no = int.Parse(no); * StockFoodModel.DeleteStock(s_no); * * Title = "保存食品リスト"; * * InitializeComponent(); */ /*********/ var result = await DisplayAlert("削除", "この保存食品を削除しますか", "OK", "キャンセル"); if (result == true) { int s_no = int.Parse(no); StockFoodModel.DeleteStock(s_no); Title = "保存食品リスト"; InitializeComponent(); } }
public StockPageViewModel() { if (StockFoodModel.SelectStock() != null) { var query = StockFoodModel.SelectStock(); Stocks = new ObservableCollection <Stock>(); foreach (var stock in query) { Stock s = new Stock { S_no = stock.S_no,//試し S_name = stock.S_name, S_num = stock.S_num, S_unit = stock.S_unit }; Stocks.Add(s); } } else { Stocks = new ObservableCollection <Stock> { new Stock { S_name = "NoData", S_num = 0, S_unit = "個" } }; } }
//プラスがクリックされた void OnPlus_Clicked(object sender, EventArgs args) { int num = Convert.ToInt32(((CustomButton)sender).CountText) + 1; string name = ((CustomButton)sender).NameText; //DisplayAlert("1足しました", name+" "+num.ToString(), "ok"); /***ここから試し02***/ List <StockFoodModel> n = StockFoodModel.SelectStock02(name, num - 1); StockFoodModel.UpdateStockPlus02(n); Title = "保存"; InitializeComponent(); /***ここまで試し02***/ /***ここから試し***/ /* * StockFoodModel.UpdateStockPlus(); * * Title = "保存"; * * InitializeComponent(); */ /***ここまで試し***/ }
/***************「登録ボタン」が押された時*********************/ private void Insert01_Clicked(object sender, EventArgs e) { /* * if (!s_switch)//食材の登録だったら * { * FoodModel.InsertFood(1, NameEntry.Text, result, yyyymmdd);//試し * DisplayAlert(NameEntry.Text + yyyymmdd.ToString("yyyy/MM/dd"), "あと" + result.ToString() + "日", "OK"); * * NameEntry.Text = ""; * * FoodPicker.Date = new DateTime(now.Year, now.Month, now.Day);// * } * else//保存食品の登録だったら * { * qty = int.Parse(NumEntry.Text); * StockFoodModel.InsertStock(1, NameEntry.Text, qty, UnitEntry.Text); * DisplayAlert(NameEntry.Text, qty.ToString() + UnitEntry.Text, "OK"); * * NameEntry.Text = ""; * NumEntry.Text = ""; * UnitEntry.Text = ""; * } */ if (!(NameEntry.Text == null) && !(NameEntry.Text.Equals(""))) { if (!s_switch) //食材の登録だったら { FoodModel.InsertFood(1, NameEntry.Text, result, yyyymmdd); //試し DisplayAlert(NameEntry.Text + yyyymmdd.ToString("yyyy/MM/dd"), "あと" + result.ToString() + "日", "OK"); NameEntry.Text = ""; FoodPicker.Date = new DateTime(now.Year, now.Month, now.Day);// } else//保存食品の登録だったら { qty = int.Parse(NumEntry.Text); StockFoodModel.InsertStock(1, NameEntry.Text, qty, UnitEntry.Text); DisplayAlert(NameEntry.Text, qty.ToString() + UnitEntry.Text, "OK"); NameEntry.Text = ""; NumEntry.Text = ""; UnitEntry.Text = ""; } } else { DisplayAlert("入力エラー", "食品名を入力してください", "OK"); } }
//マイナスがクリックされた void OnMinus_Clicked(object sender, EventArgs args) { string no2 = ((CustomButtonMinus)sender).NoText; string name2 = ((CustomButtonMinus)sender).NameText; int num2 = Convert.ToInt32(((CustomButtonMinus)sender).CountText); string unit2 = ((CustomButtonMinus)sender).UnitText; int s_no2 = int.Parse(no2);// StockFoodModel.UpdateStockMinus(s_no2, name2, num2, unit2); Title = "保存食品リスト"; InitializeComponent(); }
//プラスがクリックされた void OnPlus_Clicked(object sender, EventArgs args) { string no1 = ((CustomButton)sender).NoText; string name1 = ((CustomButton)sender).NameText; int num1 = Convert.ToInt32(((CustomButton)sender).CountText); string unit1 = ((CustomButton)sender).UnitText; int s_no1 = int.Parse(no1);// /***ここから試し***/ StockFoodModel.UpdateStockPlus(s_no1, name1, num1, unit1); Title = "保存食品リスト"; InitializeComponent(); /***ここまで試し***/ }
/***************「登録ボタン」が押された時*********************/ private void Insert01_Clicked(object sender, EventArgs e) { if (!s_switch) //食材の登録だったら { FoodModel.InsertFood(1, NameEntry.Text, result, yyyymmdd); //試し DisplayAlert(NameEntry.Text + yyyymmdd.ToString(), "あと" + result.ToString() + "日", "OK"); NameEntry.Text = ""; FoodPicker.Date = new DateTime(now.Year, now.Month, now.Day);// } else//保存食品の登録だったら { qty = int.Parse(NumEntry.Text); StockFoodModel.InsertStock(1, NameEntry.Text, qty, UnitEntry.Text); DisplayAlert(NameEntry.Text, qty.ToString() + UnitEntry.Text, "OK"); NameEntry.Text = ""; NumEntry.Text = ""; UnitEntry.Text = ""; } }
/***************「登録ボタン」が押された時*********************/ private void Insert01_Clicked(object sender, EventArgs e) { if (!(NameEntry.Text == null) && !(NameEntry.Text.Equals(""))) { if (!s_switch) //食材の登録だったら { if (!(yyyymmdd.ToString("yyyy/MM/dd").Equals("0001/01/01"))) //日付が入力されている { FoodModel.InsertFood(1, NameEntry.Text, result, yyyymmdd); //試し DisplayAlert(NameEntry.Text + yyyymmdd.ToString("yyyy/MM/dd"), "あと" + result.ToString() + "日", "OK"); NameEntry.Text = ""; FoodPicker.Date = new DateTime(now.Year, now.Month, now.Day); } else { yyyymmdd = now; FoodModel.InsertFood(1, NameEntry.Text, result, yyyymmdd);//試し DisplayAlert(NameEntry.Text + yyyymmdd.ToString("yyyy/MM/dd"), "あと" + result.ToString() + "日", "OK"); NameEntry.Text = ""; FoodPicker.Date = new DateTime(now.Year, now.Month, now.Day); } } else//保存食品の登録だったら { if ((!(NumEntry.Text == null) && !(NumEntry.Text.Equals(""))) && (!(UnitEntry.Text == null) && !(UnitEntry.Text.Equals("")))) { if (!(yyyymmdd.ToString("yyyy/MM/dd").Equals("0001/01/01")))//日付が入力されている { qty = int.Parse(NumEntry.Text); StockFoodModel.InsertStock(1, NameEntry.Text, qty, UnitEntry.Text); DisplayAlert(NameEntry.Text, qty.ToString() + UnitEntry.Text, "OK"); NameEntry.Text = ""; NumEntry.Text = ""; UnitEntry.Text = ""; } else { yyyymmdd = now; qty = int.Parse(NumEntry.Text); StockFoodModel.InsertStock(1, NameEntry.Text, qty, UnitEntry.Text); DisplayAlert(NameEntry.Text, qty.ToString() + UnitEntry.Text, "OK"); NameEntry.Text = ""; NumEntry.Text = ""; UnitEntry.Text = ""; } } else { DisplayAlert("入力エラー", "数量・単位を入力してください", "OK"); } } } else { DisplayAlert("入力エラー", "食品名を入力してください", "OK"); } }
/***************「登録ボタン」が押された時*********************/ private void Insert01_Clicked(object sender, EventArgs e) { if (!(NameEntry.Text == null) && !(NameEntry.Text.Equals(""))) { if (!s_switch) //食材の登録だったら { if (!(yyyymmdd.ToString("yyyy/MM/dd").Equals("0001/01/01"))) //日付が入力されている { if (result < 0) { DisplayAlert("期限入力エラー", "日付が現在より前のものになっています", "OK"); } else { FoodModel.InsertFood(1, NameEntry.Text, result, yyyymmdd);//試し DisplayAlert(NameEntry.Text + yyyymmdd.ToString("yyyy/MM/dd"), "あと" + result.ToString() + "日", "OK"); NameEntry.Text = ""; FoodPicker.Date = new DateTime(now.Year, now.Month, now.Day); } } else { yyyymmdd = now; FoodModel.InsertFood(1, NameEntry.Text, result, yyyymmdd); //試し DisplayAlert(NameEntry.Text + yyyymmdd.ToString("yyyy/MM/dd"), "あと" + result.ToString() + "日", "OK"); NameEntry.Text = ""; FoodPicker.Date = new DateTime(now.Year, now.Month, now.Day); //FoodPicker.Date = new DateTime(now.Year, now.Month, now.Day); } } else//保存食品の登録だったら { if ((!(NumEntry.Text == null) && !(NumEntry.Text.Equals(""))) && (!(UnitEntry.Text == null) && !(UnitEntry.Text.Equals("")))) { qty = int.Parse(NumEntry.Text); if (qty >= 0) //数量がプラス { /*if (!(yyyymmdd.ToString("yyyy/MM/dd").Equals("0001/01/01")))//日付が入力されている * { * StockFoodModel.InsertStock(1, NameEntry.Text, qty, UnitEntry.Text); * DisplayAlert(NameEntry.Text, qty.ToString() + UnitEntry.Text, "OK"); * * NameEntry.Text = ""; * NumEntry.Text = ""; * UnitEntry.Text = ""; * } * else * { * yyyymmdd = now;*/ StockFoodModel.InsertStock(1, NameEntry.Text, qty, UnitEntry.Text); DisplayAlert(NameEntry.Text, qty.ToString() + UnitEntry.Text, "OK"); NameEntry.Text = ""; NumEntry.Text = ""; UnitEntry.Text = ""; // } } else { DisplayAlert("入力エラー", "数量がマイナスです", "OK"); } } else { DisplayAlert("入力エラー", "数量・単位を入力してください", "OK"); } } } else { DisplayAlert("入力エラー", "食品名を入力してください", "OK"); } }