private void BakerContractorCmb_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (BakerContractorCmb.SelectedItem != null) { if (BakerContractorCmb.SelectedItem == "In-shop baker") { List <Staff> bakerList = new List <Staff>(); foreach (Staff bkr in DB.GetListOfStaffMembers()) { if (bkr.getIsBaker()) { bakerList.Add(bkr); } } BakerIDCmb.ItemsSource = bakerList; Staff baker = null; if (!customOrder.getOrderOutsourced()) { foreach (Staff bkr in bakerList) { if (bkr.getPersonID() == customOrder.getBakerID()) { baker = bkr; } } if (baker != null) { BakerIDCmb.SelectedItem = baker; } } } if (BakerContractorCmb.SelectedItem == "Contractor") { BakerIDCmb.ItemsSource = DB.GetListOfContractors(); ExternalBusiness contractor = null; if (customOrder.getOrderOutsourced()) { foreach (ExternalBusiness cntrctr in DB.GetListOfContractors()) { if (cntrctr.getPersonID() == customOrder.getBakerID()) { contractor = cntrctr; } } if (contractor != null) { BakerIDCmb.SelectedItem = contractor; } } } } ValidateData(); }
private void ContractorsView_SelectionChanged(object sender, SelectionChangedEventArgs e) { ExternalBusiness contractor = (ExternalBusiness)ContractorsView.SelectedItem; if (contractor != null) { EditContractor.IsEnabled = true; RemoveContractor.IsEnabled = true; } }
public EditContractor(ExternalBusiness contractorToEdit) { InitializeComponent(); contractor = contractorToEdit; BusinessNameTextBox.Text = contractorToEdit.GetBusinessName(); FirstNameTextBox.Text = contractorToEdit.getFirstName(); SurnameTextBox.Text = contractorToEdit.getSurname(); AddressTextBox.Text = contractorToEdit.getAddress(); PhoneNumberTextBox.Text = contractorToEdit.getPhone(); EmailTextBox.Text = contractorToEdit.getEmail(); SaveButton.IsEnabled = false; }
private void RemoveContractor_Click(object sender, RoutedEventArgs e) { ExternalBusiness contractor = (ExternalBusiness)ContractorsView.SelectedItem; if (contractor != null) { if (contractor.getOrderIDsCount() != 0) { MessageBox.Show("Please reassign their orders to other bakers!"); } else if (MessageBox.Show("Are you sure you want to delete this contractor from the system?", "", MessageBoxButton.YesNo) == MessageBoxResult.Yes) { DB.GetListOfContractors().Remove(contractor); UpdateContractorsView(); } } }
private void EditContractor_Click(object sender, RoutedEventArgs e) { ExternalBusiness contractor = (ExternalBusiness)ContractorsView.SelectedItem; if (contractor != null) { EditContractor window = new EditContractor(contractor); window.ShowDialog(); if (window.DialogResult != null) { if ((bool)window.DialogResult) { UpdateContractorsView(); } } } }
private void BakerIDCmb_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (BakerContractorCmb.SelectedItem == "Contractor" && BakerIDCmb.SelectedItem != null) { ExternalBusiness contractor = (ExternalBusiness)BakerIDCmb.SelectedItem; BakerDetailsTextBlock.Text = contractor.GetBusinessName() + ", " + contractor.getFirstName() + " " + contractor.getSurname(); BakerOK = true; WartingBlock.Text = ""; } else if (BakerContractorCmb.SelectedItem == "In-shop baker" && BakerIDCmb.SelectedItem != null) { Staff baker = (Staff)BakerIDCmb.SelectedItem; BakerDetailsTextBlock.Text = baker.getFirstName() + " " + baker.getSurname(); BakerOK = true; WartingBlock.Text = ""; } ValidateData(); }
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); }
public void AddExternalBusiness(string FirstName, string Surname, string Address, string Number, string Email, string BusinessName, bool IsBaker) { int ID = 0; if (IsBaker) { if (ListOfContractors.Count != 0) { ID = ListOfContractors[ListOfContractors.Count - 1].getPersonID() + 1; } ExternalBusiness Contractor = new ExternalBusiness(ID, FirstName, Surname, Address, Number, Email, BusinessName, IsBaker); ListOfContractors.Add(Contractor); } else { if (ListofSuppliers.Count != 0) { ID = ListofSuppliers[ListofSuppliers.Count - 1].getPersonID() + 1; } ExternalBusiness Supplier = new ExternalBusiness(ID, FirstName, Surname, Address, Number, Email, BusinessName, IsBaker); ListofSuppliers.Add(Supplier); } }
public void DisplayOrderDetails() { Customer orderCustomer = null; Staff orderStaff = null; ExternalBusiness orderContractor = null; string customerDetails = ""; string bakerDetails = ""; foreach (Customer customer in DB.GetListOfCustomers()) { if (customer.getPersonID() == customOrder.getCustomerID()) { orderCustomer = customer; } } if (customOrder.getOrderOutsourced()) { foreach (ExternalBusiness contractor in DB.GetListOfContractors()) { if (contractor.getPersonID() == customOrder.getBakerID()) { orderContractor = contractor; } } } else { foreach (Staff baker in DB.GetListOfStaffMembers()) { if (baker.getPersonID() == customOrder.getBakerID()) { orderStaff = baker; } } } if (customOrder.getActiveOrder()) { ActiveOrderTextBlock.Text = "Active"; } else { ActiveOrderTextBlock.Text = "Inactive"; } IDTextBlock.Text = customOrder.getOrderID().ToString(); CustIDTextBlock.Text = customOrder.getCustomerID().ToString(); if (orderCustomer != null) { customerDetails = orderCustomer.getFirstName() + " " + orderCustomer.getSurname(); if (orderCustomer.getPhone() != "") { customerDetails = customerDetails + ", " + orderCustomer.getPhone(); } if (orderCustomer.getEmail() != "") { customerDetails = customerDetails + ", " + orderCustomer.getEmail(); } } CustDetailsTextBlock.Text = customerDetails; BakerIDTextBlock.Text = customOrder.getBakerID().ToString(); if (orderStaff != null) { BakerContractorTextBlock.Text = "In-shop baker"; bakerDetails = orderStaff.getFirstName() + " " + orderStaff.getSurname(); } else { try { BakerContractorTextBlock.Text = "Contractor"; if (orderContractor.GetBusinessName() != "") { bakerDetails = orderContractor.GetBusinessName() + ", "; } bakerDetails = bakerDetails + orderContractor.getFirstName() + " " + orderContractor.getSurname(); } catch { } } BakerDetailsTextBlock.Text = bakerDetails; SizeTextBlock.Text = customOrder.getOrderSize(); DescriptionTextBlock.Text = customOrder.getOrderDescription(); PriceTextBlock.Text = "£" + customOrder.getOrderPrice().ToString(); if (customOrder.getIsPaid()) { PaidTextBlock.Text = "Paid"; } else { PaidTextBlock.Text = "Not paid"; } if (customOrder.getReadyToCollect()) { ReadyToCollectTextBlock.Text = "Ready for collection"; } else { ReadyToCollectTextBlock.Text = "Not ready"; } if (customOrder.getCollected()) { CollectedBlock.Text = "Collected"; } else { CollectedBlock.Text = "Not collected"; } }
public void LoadData() { Customer customer = null; string customerDetails = ""; Staff baker = null; ExternalBusiness contractor = null; List <Staff> bakerList = new List <Staff>(); List <ExternalBusiness> contractorList = new List <ExternalBusiness>(); foreach (Customer cust in DB.GetListOfCustomers()) { if (cust.getPersonID() == customOrder.getCustomerID()) { customer = cust; } } if (customer != null) { customerDetails = customer.getFirstName() + " " + customer.getSurname(); if (customer.getPhone() != "") { customerDetails = customerDetails + ", " + customer.getPhone(); } if (customer.getEmail() != "") { customerDetails = customerDetails + ", " + customer.getEmail(); } } if (!customOrder.getOrderOutsourced()) { foreach (Staff bkr in DB.GetListOfStaffMembers()) { if (bkr.getPersonID() == customOrder.getBakerID()) { baker = bkr; } if (bkr.getIsBaker() == true) { bakerList.Add(bkr); } } } if (customOrder.getOrderOutsourced()) { foreach (ExternalBusiness cntrctr in DB.GetListOfContractors()) { if (cntrctr.getPersonID() == customOrder.getBakerID()) { contractor = cntrctr; } contractorList.Add(cntrctr); } } ; CustIDCmb.ItemsSource = DB.GetListOfCustomers(); if (customer != null) { CustIDCmb.SelectedItem = customer; } CustDetailsTextBlock.Text = customerDetails; if (customOrder.getOrderOutsourced()) { BakerContractorCmb.SelectedItem = "Contractor"; BakerIDCmb.ItemsSource = contractorList; if (contractor != null) { BakerIDCmb.SelectedItem = contractor; BakerDetailsTextBlock.Text = contractor.GetBusinessName() + ", " + contractor.getFirstName() + " " + contractor.getSurname(); } } else { BakerContractorCmb.SelectedItem = "In-shop baker"; BakerIDCmb.ItemsSource = bakerList; if (baker != null) { BakerIDCmb.SelectedItem = baker; BakerDetailsTextBlock.Text = baker.getFirstName() + " " + baker.getSurname(); } } SizeCmb.SelectedItem = customOrder.getOrderSize(); DescriptionTextBox.Text = customOrder.getDescription(); PriceTextBox.Text = customOrder.getOrderPrice().ToString(); }
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; }