コード例 #1
0
        private void load()
        {
            //Set the text to the name and address
            nameChangeTxt.Text    = customer.name;
            addressChangeTxt.Text = customer.address;

            //Get all the cars
            cars = dbw.getCarObjects(customer.id);
            foreach (Car car in cars)
            {
                carList.Items.Add(car);
            }
        }
コード例 #2
0
        private void custList_Click(object sender, EventArgs e)
        {
            //Clear the customer list
            carList.Items.Clear();

            //Get the string of the selected customer
            string item = custList.GetItemText(custList.SelectedItem);

            //Since a new customer is selected we don't want the previous cars info to be displayed
            carDetailsTxt.Text = "";
            repairHist.Items.Clear();

            //Loop through the customer list until we find one that has the same toString as the item string
            foreach (Customer current in customerList)
            {
                string currentString = current.name + " " + current.address;
                if (currentString.Equals(item))
                {
                    //Make the current customer in the loop the selected customer and break the loop
                    selectedCustomer = current;
                    break;
                }
            }

            //As long as there is a selected customer we can look for their cars
            if (!(selectedCustomer == null))
            {
                //Get a list of all the cars the customers own and add them to the list
                cars = dbw.getCarObjects(selectedCustomer.id);
                foreach (Car car in cars)
                {
                    string carString = car.year + " " + car.make + " " + car.model;
                    carList.Items.Add(carString);
                }

                //Enable relevant buttons
                editCust.Enabled   = true;
                deleteCust.Enabled = true;
            }
        }