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

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

                return;
            }
            _saleOfferCategories.Add(_newSaleOfferCategory);
            NewSaleOfferCategory            = new SaleOfferCategoryVM();
            NewSaleOffer.PriceAfterDiscount = SaleOfferCategories.Sum(s => s.PriceTotalAfterDiscount);
            NewSaleOffer.Price = SaleOfferCategories.Sum(s => s.PriceTotal);
            OldPrices          = new ObservableCollection <SaleCategory>();
        }
        private void ExecuteSave()
        {
            Mouse.OverrideCursor = Cursors.Wait;
            DateTime _dt = DateTime.Now;

            _saleOfferServ.AddSaleOffer(_newSaleOffer);
            int _saleOfferID = _saleOfferServ.GetLastSaleOfferID();

            foreach (var item in _saleOfferCategories)
            {
                SaleOfferCategory _saleOfferCategory = new SaleOfferCategory
                {
                    CategoryID              = item.CategoryID,
                    PriceAfterDiscount      = item.PriceAfterDiscount,
                    PriceTotalAfterDiscount = item.PriceTotalAfterDiscount,
                    Price              = item.Price,
                    PriceTotal         = item.PriceTotal,
                    Discount           = item.Discount,
                    DiscountValue      = item.DiscountValue,
                    DiscountValueTotal = item.DiscountValueTotal,
                    SaleOfferID        = _saleOfferID,
                    Qty = item.Qty
                };
                _saleOfferCategoryServ.AddSaleOfferCategory(_saleOfferCategory);
            }

            DS ds = new DS();

            ds.Sale.Rows.Clear();
            int i = 0;

            foreach (var item in _saleOfferCategories)
            {
                ds.Sale.Rows.Add();
                ds.Sale[i]["Client"]     = _selectedClient.Name;
                ds.Sale[i]["Serial"]     = i + 1;
                ds.Sale[i]["Category"]   = item.Category + " " + item.Company;
                ds.Sale[i]["Qty"]        = item.Qty;
                ds.Sale[i]["Price"]      = Math.Round(Convert.ToDecimal(item.PriceAfterDiscount), 2);
                ds.Sale[i]["TotalPrice"] = Math.Round(Convert.ToDecimal(item.PriceTotalAfterDiscount), 2);
                ds.Sale[i]["BillPrice"]  = Math.Round(Convert.ToDecimal(_newSaleOffer.PriceAfterDiscount), 2);;
                i++;
            }
            ReportWindow    rpt          = new ReportWindow();
            SaleOfferReport saleOfferRPT = new SaleOfferReport();

            saleOfferRPT.SetDataSource(ds.Tables["Sale"]);
            rpt.crv.ViewerCore.ReportSource = saleOfferRPT;
            Mouse.OverrideCursor            = null;
            _currentWindow.Hide();
            rpt.ShowDialog();
            NewSaleOffer         = new SaleOffer();
            NewSaleOfferCategory = new SaleOfferCategoryVM();
            SaleOfferCategories  = new ObservableCollection <SaleOfferCategoryVM>();
            NewSaleOffer.Date    = DateTime.Now;
            OldPrices            = new ObservableCollection <SaleCategory>();
            _currentWindow.ShowDialog();
        }
 private async void ExecuteBrowseCategoriesAsync()
 {
     OldPrices            = new ObservableCollection <SaleCategory>();
     NewSaleOfferCategory = new SaleOfferCategoryVM();
     Key = "";
     Load();
     _categoriesDialog.DataContext = this;
     await _currentWindow.ShowMetroDialogAsync(_categoriesDialog);
 }