Beispiel #1
0
        private void cBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            PupilDBAccess      PDBAccess = new PupilDBAccess(db);
            BookingDBAccess    BDBAccess = new BookingDBAccess(db);
            InstrumentDBAccess IDBAccess = new InstrumentDBAccess(db);

            switch (cBox.SelectedIndex)
            {
            case 0: CreateTableResults(BDBAccess.getAllBookings(), IDBAccess.getAllInstruments(), PDBAccess.getAllPupils()); break;

            case 1:     lbl1.Visible = true;
                lbl2.Visible         = true;
                btnSearch.Visible    = true;
                txtBox1.Visible      = true;
                txtBox2.Visible      = true; break;
            }
        }
Beispiel #2
0
 private void button1_Click(object sender, EventArgs e)
 {
     try
     {   // populates the labels with information about pupil
         if (DataGrid.SelectedRows.Count == 1)
         {
             BookingDBAccess BA     = new BookingDBAccess(db);
             List <Booking>  Booked = new List <Booking>();
             Booked = BA.getAllBookings();
             int           rowNum      = DataGrid.SelectedRows[0].Index;
             int           id          = int.Parse(DataGrid.Rows[rowNum].Cells[0].Value.ToString());
             PupilDBAccess pupilAccess = new PupilDBAccess(db);
             Selected          = pupilAccess.getPupilByPupilNo(id);
             lblPupilNo.Text   = Selected.PupilNo.ToString();
             lblTitle.Text     = Selected.PupilTitle;
             lblFirstName.Text = Selected.PupilFirstName;
             lblLastName.Text  = Selected.PupilLastName;
             lblDOB.Text       = Selected.PupilDOB.ToString("d/MM/yyyy");
             int    now  = int.Parse(DateTime.Now.ToString("yyyyMMdd"));
             string date = DateTime.Now.ToShortDateString();
             int    dob  = int.Parse(Selected.PupilDOB.ToString("yyyyMMdd"));
             int    age  = (now - dob) / 10000;
             lblAge.Text = age.ToString();
             //fix this to autoNumber
             lblBookingNo.Text = Convert.ToString(Booked[Booked.Count() - 1].bookingNo + 1);
             timer1.Start();
             lblDate.Text      = date;
             groupBox4.Enabled = false;
             groupBox5.Enabled = false;
             groupBox6.Enabled = false;
             groupBox1.Enabled = true;
             groupBox2.Enabled = true;
             groupBox3.Enabled = true;
         }
     }
     catch (NullReferenceException ex)
     {
         MessageBox.Show(ex.Message);
     }
 }