public SaleUpdateViewModel()
 {
     _currentWindow    = Application.Current.Windows.OfType <MetroWindow>().LastOrDefault();
     _categoriesDialog = new CategoriesShowDialog();
     _categoryDialog   = new SaleCategoryInfromationDialog();
     Salespersons      = new ObservableCollection <Salesperson>(_salespersonServ.GetSalespersons());
     _selectedSale     = _saleServ.GetSale(ID);
     _saleCategories   = new ObservableCollection <SaleCategoryVM>(_saleCategoryServ.GetSaleCategoriesVM(ID));
     Report            = "تقرير الفاتورة";
     currencies.Add(new CurrencyInfo(CurrencyInfo.Currencies.Egypt));
 }
 public SaleAddViewModel()
 {
     _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;
     Report            = "تقرير الفاتورة";
     currencies.Add(new CurrencyInfo(CurrencyInfo.Currencies.Egypt));
 }
        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));
        }