Exemplo n.º 1
0
        private void DeleteArea(object obj)
        {
            var confirm = MessageBox.Show(string.Format("this data {0} has ben deleted are you sure ?", SelectArea.AreaNumber), "Confirm", MessageBoxButtons.YesNo);

            if (confirm == DialogResult.Yes)
            {
                ObservableCollection <HistoryModels> ods = new ObservableCollection <HistoryModels>(_services.GetHistory());

                var ds = ods.Where(vc => vc.hist_area_id.Equals(SelectArea.AreaId)).Count();



                if (ds < 1)
                {
                    var data = _services.Delete(SelectArea.AreaId);
                    if (data)
                    {
                        var findes = AreaData.First(cv => cv.AreaId.Equals(Convert.ToInt32(obj)));
                        AreaData.Remove(findes);

                        Coloring   = new SolidColorBrush(Color.FromRgb(46, 204, 113));
                        Visibility = true;
                        Message    = "Delete Data successfull";
                    }
                    else
                    {
                        Coloring   = new SolidColorBrush(Color.FromRgb(231, 76, 60));
                        Visibility = true;
                        Message    = "Delete data failed";
                    }
                }
                else
                {
                    Coloring   = new SolidColorBrush(Color.FromRgb(231, 76, 60));
                    Visibility = true;
                    Message    = "Restricted action ! cannot delete this data";
                }
            }
        }