Ejemplo n.º 1
0
        private async void DeleteMethod()
        {
            MessageDialogResult result = await _currentWindow.ShowMessageAsync("تأكيد الحذف", "هل تـريــد حــذف هـذه الفاتورة؟", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
            {
                AffirmativeButtonText = "موافق",
                NegativeButtonText    = "الغاء",
                DialogMessageFontSize = 25,
                DialogTitleFontSize   = 30
            });

            if (result == MessageDialogResult.Affirmative)
            {
                if (_supplyServ.IsExistInRecalls(_selectedSupply.ID) || !_supplyServ.IsLastSupply(_selectedSupply.ID))
                {
                    await _currentWindow.ShowMessageAsync("فشل الحذف", "لا يمكن حذف هذه الفاتورة", MessageDialogStyle.Affirmative, new MetroDialogSettings()
                    {
                        AffirmativeButtonText = "موافق",
                        DialogMessageFontSize = 25,
                        DialogTitleFontSize   = 30
                    });

                    return;
                }

                _safeServ.DeleteSafe(_selectedSupply.RegistrationDate);
                _clientAccountServ.DeleteAccount(_selectedSupply.RegistrationDate);
                var supplyCategories = _supplyCategoryServ.GetSupplyCategories(_selectedSupply.ID);
                foreach (var item in supplyCategories)
                {
                    Category cat = _categoryServ.GetCategory(item.CategoryID);
                    if (cat.Qty - item.Qty != 0)
                    {
                        cat.Cost = ((cat.Cost * cat.Qty) - item.CostTotal) / (cat.Qty - item.Qty);
                    }
                    cat.Qty = cat.Qty - item.Qty;
                    _categoryServ.UpdateCategory(cat);
                }
                _supplyServ.DeleteSupply(_selectedSupply);
                supplies.Remove(_selectedSupply);
                Load();
            }
        }
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            int bindingValue = (int)value;

            return(supplyServ.IsLastSupply(bindingValue));
        }