コード例 #1
0
        //open add from and pass the child and parent object
        private void btnadd_Click(object sender, EventArgs e)
        {
            CustomerDB custdb = new CustomerDB(db);
            Customer   cust   = custdb.getSpecificCustomer(kids[kidslistbox.SelectedIndex].Forename);
            KidsDB     kiddb  = new KidsDB(db);
            Kid        child  = kiddb.getSpecificKid(kids[kidslistbox.SelectedIndex].Forename);

            Booking book = new Booking(cust, child);

            book.Show();
            this.Hide();
        }
コード例 #2
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;
         }
     }
 }
コード例 #3
0
ファイル: ViewBooking.cs プロジェクト: SlOneRPC/A2Coursework
        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;
            }
        }