Ejemplo n.º 1
0
        private void ValidateBtn_Click(object sender, RoutedEventArgs e)
        {
            ExternalBusiness Supplier = (ExternalBusiness)SupplierMenu.SelectedItem;
            string           Type     = "";
            string           Name     = NameTextBox.Text;
            int     SupplierID        = Supplier.getPersonID();
            string  Units             = UnitsTextBox.Text;
            double  Quantity          = double.Parse(QuantityTextBox.Text);
            decimal Cost  = decimal.Parse(CostTextBox.Text);
            decimal Price = 0;

            Type = TypesComboBox.SelectedItem.ToString();
            try { Price = decimal.Parse(PriceTextBox.Text); }
            catch { IsProduct = false; };
            int Min = int.Parse(MinTextBox.Text);

            DB.AddItem(SupplierID, Name, Units, Quantity, Cost, Price, Type, Min, IsProduct);
            Content = new StockManagement(DB);
        }
Ejemplo n.º 2
0
        private void SaveButton_Click(object sender, RoutedEventArgs e)
        {
            Customer selectedCustomer = (Customer)CustIDCmb.SelectedItem;

            if (selectedCustomer.getPersonID() != customOrder.getCustomerID())
            {
                customOrder.setCustomerID(selectedCustomer.getPersonID());
            }

            if (BakerIDCmb.SelectedItem != null)
            {
                if (BakerContractorCmb.SelectedItem == "In-shop baker")
                {
                    Staff selectedBaker = (Staff)BakerIDCmb.SelectedItem;
                    if (selectedBaker.getPersonID() != customOrder.getBakerID() || customOrder.getOrderOutsourced())
                    {
                        if (customOrder.getOrderOutsourced())
                        {
                            foreach (ExternalBusiness contractor in DB.GetListOfContractors())
                            {
                                if (customOrder.getBakerID() == contractor.getPersonID())
                                {
                                    contractor.removeOrderID(customOrder.getOrderID());
                                }
                            }
                        }
                        else
                        {
                            foreach (Staff staff in DB.GetListOfStaffMembers())
                            {
                                if (customOrder.getBakerID() == staff.getPersonID())
                                {
                                    staff.removeOrderID(customOrder.getOrderID());
                                }
                            }
                        }

                        customOrder.setBakerID(selectedBaker.getPersonID());
                        selectedBaker.addOrderID(customOrder.getOrderID());
                        customOrder.setOrderOutsourced(false);
                    }
                }

                else if (BakerContractorCmb.SelectedItem == "Contractor")
                {
                    ExternalBusiness selectedBaker = (ExternalBusiness)BakerIDCmb.SelectedItem;
                    if (selectedBaker.getPersonID() != customOrder.getBakerID() || !customOrder.getOrderOutsourced())
                    {
                        if (customOrder.getOrderOutsourced())
                        {
                            foreach (ExternalBusiness contractor in DB.GetListOfContractors())
                            {
                                if (customOrder.getBakerID() == contractor.getPersonID())
                                {
                                    contractor.removeOrderID(customOrder.getOrderID());
                                }
                            }
                        }
                        else
                        {
                            foreach (Staff staff in DB.GetListOfStaffMembers())
                            {
                                if (customOrder.getBakerID() == staff.getPersonID())
                                {
                                    staff.removeOrderID(customOrder.getOrderID());
                                }
                            }
                        }

                        customOrder.setBakerID(selectedBaker.getPersonID());
                        selectedBaker.addOrderID(customOrder.getOrderID());
                        customOrder.setOrderOutsourced(true);
                    }
                }
            }

            if (SizeCmb.SelectedItem.ToString() != customOrder.getOrderSize())
            {
                customOrder.setOrderSize(SizeCmb.SelectedItem.ToString());
            }

            if (DescriptionTextBox.Text != customOrder.getDescription())
            {
                customOrder.setDescription(DescriptionTextBox.Text);
            }

            try { if (Decimal.Parse(PriceTextBox.Text) != customOrder.getOrderPrice())
                  {
                      customOrder.setOrderPrice(Decimal.Parse(PriceTextBox.Text));
                  }
            }
            catch (FormatException exception) { MessageBox.Show("Please only use numbers for price!"); }

            DialogResult = true;
        }