Exemplo n.º 1
0
        private void PrintMethod()
        {
            Mouse.OverrideCursor = Cursors.Wait;
            DS ds = new DS();

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

            foreach (var item in _saleOfferCategories)
            {
                ds.Sale.Rows.Add();
                ds.Sale[i]["Client"]     = _selectedSaleOffer.Client.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(_selectedSaleOffer.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();
            _currentWindow.ShowDialog();
        }
        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();
        }