Exemplo n.º 1
0
        public void AddSupplyOrder()
        {
            int tempId = SupplyOrder.GetNextOrderId();
            SupplyOrderEntry tempEntry1 = new SupplyOrderEntry(tempId, 1, "tempName1", 1, 1000);
            SupplyOrderEntry tempEntry2 = new SupplyOrderEntry(tempId, 2, "tempName2", 1, 1000);
            SupplyOrder      newOrder   = new SupplyOrder(tempId, 1);

            newOrder.AddEntry(tempEntry1);
            newOrder.AddEntry(tempEntry2);
            newOrder.SupplierId   = 1;
            newOrder.SupplierName = "Randil";
            Assert.IsTrue(SupplyOrder.AddSupplyOrder(newOrder));
        }
Exemplo n.º 2
0
        public void CheckTheTransactionMode()
        {
            int tempId = SupplyOrder.GetNextOrderId();
            SupplyOrderEntry tempEntry1 = new SupplyOrderEntry(tempId, 1, "tempName1", 1, 1000);
            //add a item with same itemid, but when teh items are adding using gui this was prevented
            SupplyOrderEntry tempEntry2 = new SupplyOrderEntry(tempId, 1, "tempName2", 1, 1000);
            SupplyOrder      newOrder   = new SupplyOrder(tempId, 1);

            newOrder.AddEntry(tempEntry1);
            newOrder.AddEntry(tempEntry2);
            newOrder.SupplierId   = 1;
            newOrder.SupplierName = "Randil";
            Assert.IsFalse(SupplyOrder.AddSupplyOrder(newOrder));
            Assert.IsFalse(SupplyOrder.GetSupplyOrders(false, orderId: tempId.ToString()).Any());
        }
        private void AddToOrderButton_Click(object sender, RoutedEventArgs e)
        {
            if (IsAddOrderItemEligible())
            {
                _selectedOrderEntry = new SupplyOrderEntry(_orderId, _selectedItem.Id, _selectedItem.Name,
                                                           int.Parse(QuantityTextBox.Text), decimal.Parse(PriceTextBox.Text));
                if (_newOrder.AddEntry(_selectedOrderEntry))
                {
                    RefreshSupplyDataGrid();
                    TotalAmountTextBox.Text = _newOrder.Total.ToString();
                    FinalInfoRefresh();
                }
                else
                {
                    MessageBox.Show("Item Is Already in the Order", "Information", MessageBoxButton.OK,
                                    MessageBoxImage.Information);
                }
            }

            QuantityTextBox.Focus();
        }