Exemple #1
0
        //update UI code was moved from SelectedIndexChanged to this and is called here
        public void UpdateUI()
        {
            selectedItem = (Student)studentList.SelectedItem;
            if (selectedItem == null)
            {
                return;
            }
            foreach (Student i in students)
            {
                if (selectedItem.ID == i.ID)
                {
                    fLbl.Text = i.FirstName;
                    lLbl.Text = i.LastName;
                    //lvlLbl.Text = GetLevelString(i.EnLvl);
                    lvlLbl.Text       = LISC.GetLevelString(i.EnLvl);
                    mainClassLbl.Text = i.MainClass;
                    idLbl.Text        = i.ID.ToString();

                    //take a look at conditional operators for if-else
                    muLbl1.Text = 0 < i.Makeup.Count ? i.Makeup[0] : "None";
                    //if (0 < i.Makeup.Count)
                    //    muLbl1.Text = i.Makeup[0];
                    //else muLbl1.Text = "None";

                    muLbl2.Text = 1 < i.Makeup.Count ? i.Makeup[1] : "None";

                    muLbl3.Text = 2 < i.Makeup.Count ? i.Makeup[2] : "None";

                    muLbl4.Text = 3 < i.Makeup.Count ? i.Makeup[3] : "None";

                    selected = i;
                }
            }
        }
 //repopulate the boxes when editing so user doesn't have to rewrite everything
 public void UpdateEditUI(Student selected)
 {
     if (selected == null)
     {
         return;
     }
     firstBox.Text = selected.FirstName;
     lastBox.Text  = selected.LastName;
     //levelBox.Text = GetLevelString(selected.EnLvl);
     levelBox.Text     = LISC.GetLevelString(selected.EnLvl);
     classBox.Text     = selected.MainClass;
     writingBox.Text   = selected.Write.ToString();
     readingBox.Text   = selected.Read.ToString();
     listeningBox.Text = selected.Listen.ToString();
     speakingBox.Text  = selected.Speak.ToString();
     notesBox.Text     = selected.Note;
     for (int i = 0; i < selected.Makeup.Count; i++)
     {
         if (selected.Makeup[i] != null)
         {
             UpdateEditUIMakeup(selected.Makeup[i]);
         }
     }
     createBtn.Text = "Save";
 }