示例#1
0
 //populate list box with kid/parents
 private void initlistbox(bool kid)
 {
     if (kid) // populate with kid
     {
         KidsDB kidsdbaccess = new KidsDB(db);
         kids = kidsdbaccess.getallkids();
         containerlistbox.Items.Clear();
         int counter = 0;
         foreach (Kid child in kids)
         {
             if (child.ParentID == currentcustomer.CustId)
             {
                 containerlistbox.Items.Add(child.Forename + " " + child.Surname);
                 counter++;
             }
         }
         if (counter == 0)
         {
             MessageBox.Show("No kids have been booked for their parent, this could be caused by conflicting forename and surname");
             return;
         }
         if (kids.Count > 0)
         {
             containerlistbox.SelectedIndex = 0;
             subtitlelbl.Text = "Select kid:";
         }
         else // no kids added yet
         {
             MessageBox.Show("No kids yet!");
             returntomenu();
         }
     }
     else //populate with parent
     {
         CustomerDB customerdb = new CustomerDB(db);
         customers = customerdb.getallcustomers();
         containerlistbox.Items.Clear();
         foreach (Customer customer in customers)
         {
             containerlistbox.Items.Add(customer.Forename + " " + customer.Surname);
         }
         if (customers.Count > 0)
         {
             containerlistbox.SelectedIndex = 0;
         }
         else // no customers added yet
         {
             MessageBox.Show("No customers yet!");
             NoBookings = true;
         }
     }
 }
示例#2
0
        private void initlistbox()
        {
            KidsDB kiddb = new KidsDB(db);

            kids = kiddb.getallkids();
            foreach (Kid child in kids)
            {
                kidslist.Items.Add(child.Forename + " " + child.Surname);
            }
            if (kids.Count > 0)
            {
                kidslist.SelectedIndex = 0;
            }
            else
            {
                btnview.Enabled = false;
            }
        }