コード例 #1
0
ファイル: SaleForm.cs プロジェクト: JCMcGraw/AnimalHouse
        private void NewSaleButton_Click(object sender, EventArgs e)
        {
            this.Cursor = Cursors.WaitCursor;

            try
            {
                customer = null;
                CustomerNameLabel.Text = "";
                PhoneTextBox.Text      = "";
                AdressTextBox.Text     = "";
                EmailTextBox.Text      = "";
                TotalPriceLabel.Text   = "";
                MomsLabel.Text         = "";
                TotalInkMomsLabel.Text = "";

                sale = SaleFactory.Instance().CreateSale(customer, DateTime.Now);
                ItemListDataGridView.DataSource            = null;
                UnPaidPrescriptionsDataGridView.DataSource = null;
                UnPaidTreatmentDataGridView.DataSource     = null;
                SearchItemTextBox.Text = "";

                LoadAllItemsInListBox();
                EndButton.Enabled     = false;
                FakturaButton.Enabled = false;
            }
            catch (Exception)
            {
                MessageBox.Show("noget gik galt");
                this.Cursor = Cursors.Default;
            }

            this.Cursor = Cursors.Default;
        }
コード例 #2
0
 public Sale Execute(RegisterSaleRequest request)
 {
     try
     {
         return(SaleFactory.Make(request));
     }
     catch (Exception e)
     {
         throw e;
     }
 }
コード例 #3
0
ファイル: SaleForm.cs プロジェクト: JCMcGraw/AnimalHouse
        private void FillItemList(Item item, Prescription prescription, Treatment treatment, int amount = -1)
        {
            SaleItemForm saleItemForm = new SaleItemForm(item, prescription, treatment, amount);

            if (saleItemForm.ShowDialog() == DialogResult.OK)
            {
                SaleLineItem saleLineItem = saleItemForm.saleLineItem;

                if (sale == null)
                {
                    sale = SaleFactory.Instance().CreateSale(customer, DateTime.Now);
                }

                sale.AddSaleLineItem(saleLineItem);
                LoadeItemList();
                EndButton.Enabled = true;
            }
        }
コード例 #4
0
        public async Task <IActionResult> NewSale([FromBody] NewUpdateSale newSale)
        {
            var storeId         = GetStoreId();
            var totalCommission = await CalculateCommission(newSale);

            var sale = SaleFactory.CreateSale(storeId, totalCommission, newSale);

            try
            {
                await _saleWriteRepository.CreateAsync(sale);
            }
            catch (Exception e)
            {
                var h = e.Message;
            }

            return(Ok());
        }
コード例 #5
0
ファイル: SaleForm.cs プロジェクト: JCMcGraw/AnimalHouse
        private void SaleForm_Load(object sender, EventArgs e)
        {
            ItemListDataGridView.AutoGenerateColumns            = false;
            ItemDataGridView.AutoGenerateColumns                = false;
            UnPaidPrescriptionsDataGridView.AutoGenerateColumns = false;
            UnPaidTreatmentDataGridView.AutoGenerateColumns     = false;
            FakturaButton.Enabled = false;

            LoadAllItemsInListBox();
            sale = SaleFactory.Instance().CreateSale(customer, DateTime.Now);
            try
            {
                LastUpdate = BossController.Instance().itemController.GetLastUpdate();
                UpdateMedicineLabel.Text = "Dato for sidst opdateret medicinpriser: " + LastUpdate.ToString("dd-MM-yyyy");
            }
            catch
            {
                UpdateMedicineLabel.Text = "";
            }
        }
コード例 #6
0
 public SaleController(SaleFactory saleFactory, IRepository <Product> productRepository)
 {
     _saleFactory       = saleFactory;
     _productRepository = productRepository;
 }
コード例 #7
0
ファイル: Program.cs プロジェクト: gospella/oop_csu
        static void Main(string[] args)
        {
            User      user1 = new User("Customer", 22, 5000, 0);
            EBook     book1 = new EBook("Harry Potter 1", "J.K. Rowling", 499, Format.PDF);
            PaperBook book2 = new PaperBook("Harry Potter 2", "J.K. Rowling", 499);

            EBook     book11 = new EBook("Harry Potter 1", "J.K. Rowling", 499, Format.PDF);
            PaperBook book22 = new PaperBook("Harry Potter 2", "J.K. Rowling", 499);

            EBook     book3  = new EBook("Harry Potter 3", "J.K. Rowling", 499, Format.epub);
            PaperBook book33 = new PaperBook("Harry Potter 3", "J.K. Rowling", 499);

            EBook     book4  = new EBook("Harry Potter 4", "J.K. Rowling", 499, Format.epub);
            PaperBook book44 = new PaperBook("Harry Potter 4", "J.K. Rowling", 499);

            PaperBook book5 = new PaperBook("Harry Potter 5", "J.K. Rowling", 499);

            EBook book6 = new EBook("Harry Potter 7", "J.K. Rowling", 499, Format.PDF);

            BookRange bookRange = new BookRange();

            bookRange.AddBooks(
                book1, book2, book11, book22, book3, book33,
                book4, book44, book5, book6);

            // Создание корзины
            Cart cart = new Cart(bookRange);

            // Добавление промокодов и акций
            cart.AddBonus(PromoFactory.createPromo(IPromocode.PromoType.FreeBookPromo));
            cart.AddBonus(PromoFactory.createPromo(IPromocode.PromoType.FreeDeliveryPromo));
            cart.AddBonus(PromoFactory.createPromo(IPromocode.PromoType.MoneyPromo));
            cart.AddBonus(PromoFactory.createPromo(IPromocode.PromoType.PercentagePromo));
            cart.AddBonus(SaleFactory.createPromo(ISale.SaleType.OnePlusOneEqThreeSale));

            while (true)
            {
                // Стартовое меню
                Console.Clear();
                List <BookCard> bookList = bookRange.prepareBookCardList();
                bookList.Sort((x, y) => x.Book.Title.CompareTo(y.Book.Title));
                PrintStartInfo(user1, bookRange, cart, bookList);
                int option = readKey();

                if (option == 0) // Корзина
                {
                    Console.Clear();
                    cart.calculateCost();
                    List <BookCard> bookCards   = cart.GetAllBooksInCart();
                    bool            isCartEmpty = bookCards.Count == 0;
                    if (isCartEmpty)
                    {
                        Console.WriteLine("Корзина пуста");
                    }

                    while (!isCartEmpty)
                    {
                        Console.Clear();
                        bookCards = cart.GetAllBooksInCart();
                        cart.calculateCost();
                        PrintCartInfo(bookCards, cart.getBonuses(true), cart.GetPriceSum());
                        option = readKey();
                        switch (option)
                        {
                        case 0:
                        {
                            Console.WriteLine();
                            Console.WriteLine("Выход в главное меню");
                            isCartEmpty = true;
                            break;
                        }

                        case 1:
                        {
                            // Оплата товаров
                            double price = cart.GetPriceSum();
                            if (price < user1.Balance)
                            {
                                PrintPaymentInfo(user1, bookCards, price);
                                cart.MakePurchase(user1);
                            }
                            else
                            {
                                Console.WriteLine("У вас недостаточно средств");
                            }
                            isCartEmpty = true;
                            break;
                        }

                        case 2:
                        {
                            // Активация бонусов
                            List <IBenefit> bonuses = cart.getBonuses(false);
                            PrintBonusSelectionInfo(bonuses);
                            while (true)
                            {
                                option = readKey();
                                //bonuses.Sort((x, y) => x.CompareTo(y));
                                if (option == 0)
                                {
                                    break;
                                }
                                else if (option > 0 && option <= bonuses.Count)
                                {
                                    bonuses[option - 1].Apply(cart, bookRange);
                                    Console.WriteLine("Бонус активирован");
                                    break;
                                }
                                else
                                {
                                    Console.WriteLine("Такого бонуса не существует");
                                }
                            }
                            break;
                        }

                        case 8:
                        {
                            // Очистка бонусов
                            cart.clearBonus();
                            Console.WriteLine();
                            Console.WriteLine("Бонусы очищены");
                            break;
                        }

                        case 9:
                        {
                            // Очистка корзины
                            cart.Clear();
                            Console.WriteLine();
                            Console.WriteLine("Корзина очищена");
                            isCartEmpty = true;
                            break;
                        }

                        default:
                            continue;
                        }
                    }
                }
                else if (option > 0 && option <= bookRange.getBooksCount())
                {
                    cart.AddToCart(bookList[option - 1]);
                    Console.WriteLine("Товар добавлен в корзину");
                }
                else
                {
                    Console.WriteLine("Такого товара не существует");
                }

                Console.WriteLine("Нажмите Enter для продолжения.");
                while (Console.ReadKey().Key != ConsoleKey.Enter)
                {
                }
                Console.Clear();
            }
        }