private async void AddData(object obj) { //_katmodel.KategoriHall = Katname; //_katmodel.katNumber = Katnumber; if (string.IsNullOrEmpty(FeesVal)) { Coloring = new SolidColorBrush(Color.FromRgb(231, 76, 60)); Visibility = true; Message = " Input wajib di isi "; var cs = await delayid(); if (cs) { Visibility = false; } } else { if (!Regex.IsMatch(FeesVal, "[0-9]")) { Coloring = new SolidColorBrush(Color.FromRgb(231, 76, 60)); Visibility = true; Message = " Input wajib berupa nomor "; var cs = await delayid(); if (cs) { Visibility = false; } return; } FeesData = (ObservableCollection <FeesModel>)obj; var cvd = FeesData.Where(cv => cv.FeesValue.ToString() == FeesVal).Count(); Console.WriteLine(cvd); if (cvd < 1) { var dataadd = _services.insertData(Convert.ToInt32(FeesVal)); if (dataadd) { FeesModel fe = new FeesModel(); getFeesData(); Coloring = new SolidColorBrush(Color.FromRgb(46, 204, 113)); Visibility = true; Message = "data berhasil disimpan"; FeesVal = ""; var cs = await delayid(); if (cs) { Visibility = false; } } else { Coloring = new SolidColorBrush(Color.FromRgb(231, 76, 60)); Visibility = true; Message = "data gagal disimpan"; FeesVal = ""; var cs = await delayid(); if (cs) { Visibility = false; } } } else { Coloring = new SolidColorBrush(Color.FromRgb(231, 76, 60)); Visibility = true; Message = "data sudah ada"; FeesVal = ""; var cs = await delayid(); if (cs) { Visibility = false; } } } }
private async void Saveedit(object obj) { if (!Regex.IsMatch(FeesVal.ToString(), "[0-9]")) { Coloring = new SolidColorBrush(Color.FromRgb(231, 76, 60)); Visibility = true; Message = " Input wajib berupa nomor "; var cs = await delayid(); if (cs) { Visibility = false; } return; } if (FeesVal.Equals(0)) { Coloring = new SolidColorBrush(Color.FromRgb(231, 76, 60)); Visibility = true; Message = " Input wajib di isi "; var cs = await delayid(); if (cs) { Visibility = false; } } else { FeesData = (ObservableCollection <FeesModel>)obj; var dft = FeesData.Where(vf => vf.FeesValue.ToString() == FeesVal).Count(); if (dft >= 0) { var dataadd = _services.EditSave(ids, Convert.ToInt32(FeesVal)); if (dataadd) { FeesModel fe = new FeesModel(); getFeesData(); Coloring = new SolidColorBrush(Color.FromRgb(46, 204, 113)); Visibility = true; Message = "data berhasil disimpan"; FeesVal = ""; var cs = await delayid(); if (cs) { Visibility = false; } } else { Coloring = new SolidColorBrush(Color.FromRgb(231, 76, 60)); Visibility = true; Message = "data gagal disimpan"; FeesVal = ""; var cs = await delayid(); if (cs) { Visibility = false; } } } else { Coloring = new SolidColorBrush(Color.FromRgb(231, 76, 60)); Visibility = true; Message = "data sudah ada"; FeesVal = ""; var cs = await delayid(); if (cs) { Visibility = false; } } } }