Пример #1
0
        private void PrintMethod(string parameter)
        {
            Mouse.OverrideCursor = Cursors.Wait;
            DS ds = new DS();

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

            foreach (var item in _saleCategories)
            {
                ds.Sale.Rows.Add();
                ds.Sale[i]["ID"]           = ID;
                ds.Sale[i]["Date"]         = _selectedSale.Date;
                ds.Sale[i]["Client"]       = _selectedSale.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.Price), 2);
                ds.Sale[i]["TotalPrice"]   = Math.Round(Convert.ToDecimal(item.PriceTotal), 2);
                ds.Sale[i]["BillPrice"]    = _selectedSale.Price;
                ds.Sale[i]["OldDebt"]      = Math.Abs(Convert.ToDecimal(_selectedSale.OldDebt));
                ds.Sale[i]["BillTotal"]    = Math.Abs(Convert.ToDecimal(_selectedSale.PriceTotal));
                ds.Sale[i]["Paid"]         = _selectedSale.CashPaid;
                ds.Sale[i]["DiscountPaid"] = _selectedSale.DiscountPaid;
                ds.Sale[i]["NewDebt"]      = Math.Abs(Convert.ToDecimal(_selectedSale.NewDebt));
                if (_selectedSale.NewDebt > 0)
                {
                    ds.Sale[i]["Type"] = "له";
                }
                else if (_selectedSale.NewDebt < 0)
                {
                    ds.Sale[i]["Type"] = "عليه";
                }

                if (_selectedSale.OldDebt > 0)
                {
                    ds.Sale[i]["Type2"] = "له";
                }
                else if (_selectedSale.OldDebt < 0)
                {
                    ds.Sale[i]["Type2"] = "عليه";
                }
                i++;
            }
            ReportWindow rpt = new ReportWindow();

            if (parameter == "Client")
            {
                SaleReport saleRPT = new SaleReport();
                saleRPT.SetDataSource(ds.Tables["Sale"]);
                rpt.crv.ViewerCore.ReportSource = saleRPT;
                Mouse.OverrideCursor            = null;
            }
            else
            {
                SaleReport2 saleRPT = new SaleReport2();
                saleRPT.SetDataSource(ds.Tables["Sale"]);
                rpt.crv.ViewerCore.ReportSource = saleRPT;
                Mouse.OverrideCursor            = null;
            }
            _currentWindow.Hide();
            rpt.ShowDialog();
            _currentWindow.ShowDialog();
        }
Пример #2
0
        private void ExecuteSave(string parameter)
        {
            try
            {
                Mouse.OverrideCursor = Cursors.Wait;
                DateTime _dt = DateTime.Now;
                _newSale.RegistrationDate = _dt;
                _saleServ.AddSale(_newSale);
                int _saleID = _saleServ.GetLastSaleID();

                foreach (var item in _saleCategories)
                {
                    SaleCategory _saleCategory = new SaleCategory
                    {
                        CategoryID = item.CategoryID,
                        Cost       = item.Cost,
                        CostTotal  = item.CostTotal,
                        Price      = item.Price,
                        PriceTotal = item.PriceTotal,
                        SaleID     = _saleID,
                        Qty        = item.Qty
                    };
                    _saleCategoryServ.AddSaleCategory(_saleCategory);

                    Category cat = _categoryServ.GetCategory(item.CategoryID);
                    cat.Qty = cat.Qty - item.Qty;
                    _categoryServ.UpdateCategory(cat);
                }

                ClientAccount _account = new ClientAccount
                {
                    ClientID         = _newSale.ClientID,
                    Date             = _newSale.Date,
                    RegistrationDate = _dt,
                    Statement        = "فاتورة مبيعات رقم " + _saleID,
                    Credit           = _newSale.CashPaid + _newSale.DiscountPaid,
                    Debit            = _newSale.Price
                };
                _clientAccountServ.AddAccount(_account);

                if (_newSale.CashPaid > 0)
                {
                    Safe _safe = new Safe
                    {
                        Date             = _newSale.Date,
                        RegistrationDate = _dt,
                        Statement        = "فاتورة مبيعات رقم " + _saleID + " للعميل: " + _selectedClient.Name,
                        Amount           = _newSale.CashPaid,
                        Source           = 4
                    };
                    _safeServ.AddSafe(_safe);
                }

                DS ds = new DS();
                ds.Sale.Rows.Clear();
                int i = 0;
                foreach (var item in _saleCategories)
                {
                    ds.Sale.Rows.Add();
                    ds.Sale[i]["ID"]           = _saleID;
                    ds.Sale[i]["Date"]         = _newSale.Date;
                    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.Price), 2);
                    ds.Sale[i]["TotalPrice"]   = Math.Round(Convert.ToDecimal(item.PriceTotal), 2);
                    ds.Sale[i]["BillPrice"]    = Math.Round(Convert.ToDecimal(_newSale.Price), 2);;
                    ds.Sale[i]["OldDebt"]      = Math.Abs(Convert.ToDecimal(_newSale.OldDebt));
                    ds.Sale[i]["BillTotal"]    = Math.Abs(Math.Round(Convert.ToDecimal(_newSale.PriceTotal), 2));
                    ds.Sale[i]["Paid"]         = _newSale.CashPaid;
                    ds.Sale[i]["DiscountPaid"] = _newSale.DiscountPaid;
                    ds.Sale[i]["NewDebt"]      = Math.Abs(Math.Round(Convert.ToDecimal(_newSale.NewDebt), 2));
                    if (_newSale.NewDebt > 0)
                    {
                        ds.Sale[i]["Type"] = "له";
                    }
                    else if (_newSale.NewDebt < 0)
                    {
                        ds.Sale[i]["Type"] = "عليه";
                    }

                    if (_newSale.OldDebt > 0)
                    {
                        ds.Sale[i]["Type2"] = "له";
                    }
                    else if (_newSale.OldDebt < 0)
                    {
                        ds.Sale[i]["Type2"] = "عليه";
                    }

                    i++;
                }
                ReportWindow rpt = new ReportWindow();
                if (parameter == "Client")
                {
                    SaleReport saleRPT = new SaleReport();
                    saleRPT.SetDataSource(ds.Tables["Sale"]);
                    rpt.crv.ViewerCore.ReportSource = saleRPT;
                    Mouse.OverrideCursor            = null;
                }
                else
                {
                    SaleReport2 saleRPT = new SaleReport2();
                    saleRPT.SetDataSource(ds.Tables["Sale"]);
                    rpt.crv.ViewerCore.ReportSource = saleRPT;
                    Mouse.OverrideCursor            = null;
                }
                _currentWindow.Hide();
                rpt.ShowDialog();
                NewSale         = new Sale();
                NewSaleCategory = new SaleCategoryVM();
                SaleCategories  = new ObservableCollection <SaleCategoryVM>();
                NewSale.Date    = DateTime.Now;
                OldPrices       = new ObservableCollection <SaleCategory>();
                _currentWindow.ShowDialog();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }