private async void lstCustomers_SelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
        {
            BusinessLogicLayer controller = new BusinessLogicLayer();

            if (lstCustomers.SelectedValue is CustomerViewModel customer)
            {
                SelectedCustomerID  = customer.CustomerID;
                txtName.Text        = customer.Name;
                txtAddress.Text     = customer.Address;
                txtPhoneNumber.Text = customer.PhoneNumber;

                lstDeliveries.ItemsSource = await controller.PopulateDeliveryBox(SelectedCustomerID);

                btnCreateDelivery.IsEnabled = true;
            }
        }
Example #2
0
        private async void btnCreateCustomer_Click(object sender, RoutedEventArgs e)
        {
            BusinessLogicLayer controller  = new BusinessLogicLayer();
            CustomerViewModel  newCustomer = new CustomerViewModel
            {
                Address     = txtAddress.Text,
                Name        = txtName.Text,
                PhoneNumber = txtPhoneNumber.Text
            };

            if (await controller.AddCustomer(newCustomer))
            {
                MainWindow window = (MainWindow)Application.Current.MainWindow;
                window.lstCustomers.ItemsSource = await controller.PopulateCustomerBox();

                this.Close();
            }
            else
            {
                MessageBox.Show(String.Format("The customer name '{0}' already exists, try again.", newCustomer.Name));
            }
        }
        private async void btnCreateCustomer_Click(object sender, RoutedEventArgs e)
        {
            BusinessLogicLayer controller  = new BusinessLogicLayer();
            DeliveryViewModel  newDelivery = new DeliveryViewModel
            {
                CustomerID       = this.CustomerID,
                DeliveryDate     = pckDeliveryDate.SelectedDate,
                LilliesDelivered = txtLilliesDelivered.Text,
                Note             = txtNote.Text
            };

            if (await controller.AddDelivery(newDelivery))
            {
                MainWindow window = (MainWindow)Application.Current.MainWindow;
                window.lstDeliveries.ItemsSource = await controller.PopulateDeliveryBox(CustomerID);

                this.Close();
            }
            else
            {
                MessageBox.Show("Please enter an lilly delivery quantity greater than or equal to 0");
            }
        }
        private async void lstCustomers_Initialized(object sender, EventArgs e)
        {
            BusinessLogicLayer controller = new BusinessLogicLayer();

            lstCustomers.ItemsSource = await controller.PopulateCustomerBox();
        }