private async void ExecuteAddToBillAsync()
        {
            if (NewSaleCategory.PriceTotalAfterDiscount == null || NewSaleCategory.Category == null)
            {
                return;
            }
            var mySettings = new MetroDialogSettings()
            {
                AffirmativeButtonText = "موافق",
                DialogMessageFontSize = 25,
                DialogTitleFontSize   = 30
            };

            if (_saleCategories.SingleOrDefault(s => s.CategoryID == _newSaleCategory.CategoryID) != null)
            {
                MessageDialogResult result = await _currentWindow.ShowMessageAsync("خطأ", "هذا الصنف موجود مسبقاً فى الفاتورة", MessageDialogStyle.Affirmative, mySettings);

                return;
            }
            if (_newSaleCategory.Qty > _selectedCategory.Qty)
            {
                MessageDialogResult result = await _currentWindow.ShowMessageAsync("خطأ", "هذه الكمية غير متوفرة فى المخزن", MessageDialogStyle.Affirmative, mySettings);

                return;
            }
            _saleCategories.Add(_newSaleCategory);
            NewSaleCategory            = new SaleCategoryVM();
            NewSale.Cost               = SaleCategories.Sum(s => s.CostTotal);
            NewSale.PriceAfterDiscount = SaleCategories.Sum(s => s.PriceTotalAfterDiscount);
            NewSale.Price              = SaleCategories.Sum(s => s.PriceTotal);
            OldPrices = new ObservableCollection <SaleCategory>();
        }
 private void EditMethod()
 {
     NewSaleCategory = SelectedSaleCategory;
     _saleCategories.Remove(_selectedSaleCategory);
     _selectedCategory = _categoryServ.GetCategory(_newSaleCategory.CategoryID);
     SelectedSale.Cost = SaleCategories.Sum(s => s.CostTotal);
     SelectedSale.PriceAfterDiscount = SaleCategories.Sum(s => s.PriceTotalAfterDiscount);
     SelectedSale.Price = SaleCategories.Sum(s => s.PriceTotal);
     OldPrices          = new ObservableCollection <SaleCategory>(_saleCategoryServ.GetOldPrices(_newSaleCategory.CategoryID, _selectedSale.ClientID));
 }
Пример #3
0
 private void EditMethod()
 {
     try
     {
         NewSaleCategory = SelectedSaleCategory;
         _saleCategories.Remove(_selectedSaleCategory);
         _selectedCategory  = _categoryServ.GetCategory(_newSaleCategory.CategoryID);
         SelectedSale.Cost  = SaleCategories.Sum(s => s.CostTotal);
         SelectedSale.Price = SaleCategories.Sum(s => s.PriceTotal);
         OldPrices          = new ObservableCollection <SaleCategory>(_saleCategoryServ.GetOldPrices(_newSaleCategory.CategoryID, _selectedSale.ClientID));
     }
     catch (Exception ex)
     {
         MessageBox.Show(ex.ToString());
     }
 }
        private async void DeleteMethodAsync()
        {
            MessageDialogResult result = await _currentWindow.ShowMessageAsync("تأكيد الحذف", "هل تـريــد حــذف هـذا الصنف؟", MessageDialogStyle.AffirmativeAndNegative, new MetroDialogSettings()
            {
                AffirmativeButtonText = "موافق",
                NegativeButtonText    = "الغاء",
                DialogMessageFontSize = 25,
                DialogTitleFontSize   = 30
            });

            if (result == MessageDialogResult.Affirmative)
            {
                _saleCategories.Remove(_selectedSaleCategory);
                NewSale.Cost = SaleCategories.Sum(s => s.CostTotal);
                NewSale.PriceAfterDiscount = SaleCategories.Sum(s => s.PriceTotalAfterDiscount);
                NewSale.Price = SaleCategories.Sum(s => s.PriceTotal);
            }
        }
        public SaleOfferConvertViewModel()
        {
            _currentWindow    = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault();
            _categoriesDialog = new CategoriesShowDialog();
            _categoryDialog   = new SaleCategoryInfromationDialog();
            Clients           = new ObservableCollection <Client>(_clientServ.GetClients());
            Salespersons      = new ObservableCollection <Salesperson>(_salespersonServ.GetSalespersons());
            NewSale.Date      = DateTime.Now;
            var saleOffer = _saleOfferServ.GetSaleOffer(ID);

            NewSale.ClientID = saleOffer.ClientID;

            var saleOfferCategories = _saleOfferCategoryServ.GetSaleOfferCategories(ID);

            foreach (var item in saleOfferCategories)
            {
                var cat = _categoryServ.GetCategory(item.CategoryID);
                _saleCategories.Add(new SaleCategoryVM
                {
                    Category           = item.Category,
                    CategoryID         = item.CategoryID,
                    Company            = item.Company,
                    Discount           = item.Discount,
                    DiscountValue      = item.DiscountValue,
                    DiscountValueTotal = item.DiscountValueTotal,
                    Price = item.Price,
                    PriceAfterDiscount      = item.PriceAfterDiscount,
                    PriceTotal              = item.PriceTotal,
                    PriceTotalAfterDiscount = item.PriceTotalAfterDiscount,
                    Qty       = item.Qty,
                    Cost      = cat.Cost,
                    CostTotal = cat.Cost * item.Qty
                });
            }
            NewSale.Cost = SaleCategories.Sum(s => s.CostTotal);
            NewSale.PriceAfterDiscount = SaleCategories.Sum(s => s.PriceTotalAfterDiscount);
            NewSale.Price   = SaleCategories.Sum(s => s.PriceTotal);
            NewSale.OldDebt = _clientAccountServ.GetClientAccount(saleOffer.Client.ID) + saleOffer.Client.AccountStart;
            Report          = "تقرير الفاتورة";
            currencies.Add(new CurrencyInfo(CurrencyInfo.Currencies.Egypt));
        }
Пример #6
0
        private async void ExecuteAddToBillAsync()
        {
            try
            {
                if (NewSaleCategory.Price == null || NewSaleCategory.Qty == null || NewSaleCategory.Category == null)
                {
                    return;
                }
                var mySettings = new MetroDialogSettings()
                {
                    AffirmativeButtonText = "موافق",
                    DialogMessageFontSize = 25,
                    DialogTitleFontSize   = 30
                };
                //if (_saleCategories.SingleOrDefault(s => s.CategoryID == _newSaleCategory.CategoryID) != null)
                //{
                //    MessageDialogResult result = await _currentWindow.ShowMessageAsync("خطأ", "هذا الصنف موجود مسبقاً فى الفاتورة", MessageDialogStyle.Affirmative, mySettings);
                //    return;
                //}
                if (_newSaleCategory.Qty > _selectedCategory.Qty + _saleCategoryServ.GetCategoryQty(ID, _newSaleCategory.CategoryID))
                {
                    MessageDialogResult result = await _currentWindow.ShowMessageAsync("خطأ", "هذه الكمية غير متوفرة فى المخزن", MessageDialogStyle.Affirmative, mySettings);

                    return;
                }
                _saleCategories.Add(_newSaleCategory);
                NewSaleCategory    = new SaleCategoryVM();
                SelectedSale.Cost  = SaleCategories.Sum(s => s.CostTotal);
                SelectedSale.Price = SaleCategories.Sum(s => s.PriceTotal);
                OldPrices          = new ObservableCollection <SaleCategory>();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }