Ejemplo n.º 1
0
 //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";
 }
Ejemplo n.º 2
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;
                }
            }
        }
Ejemplo n.º 3
0
        //this function triggers the creation process ending with AddStudent
        //we catch bad inputs here including empty strings
        //getting the ID of the last index and adding 1 eliminated ID duplicates
        private void createBtn_Click(object sender, EventArgs e)
        {
            //int lvl = GetEngLevel(levelBox.Text);
            int lvl  = LISC.GetEngLevel(levelBox.Text);
            int last = forCreation.Count - 1;
            int id   = 0;

            if (last != -1)
            {
                id = forCreation[last].ID + 1;
            }
            if (string.IsNullOrWhiteSpace(firstBox.Text))
            {
                MessageBox.Show("Enter First Name");
                return;
            }
            if (string.IsNullOrWhiteSpace(lastBox.Text))
            {
                MessageBox.Show("Enter Last Name");
                return;
            }
            if (string.IsNullOrEmpty(levelBox.Text))
            {
                MessageBox.Show("Select Level");
                return;
            }
            if (string.IsNullOrEmpty(classBox.Text))
            {
                MessageBox.Show("Select Class");
                return;
            }

            //Makeups are set here and we check for more than 4 selections
            //TRY catches any bad inputs where strings must be converted to integers
            try
            {
                makeup.Clear();
                SetMakeup(makeup);
                if (makeup.Count > 4)
                {
                    MessageBox.Show("Only 4 Classes Allowed");
                    return;
                }
                AddStudent(id, firstBox.Text, lastBox.Text, lvl, classBox.Text, System.Convert.ToInt32(speakingBox.Text),
                           System.Convert.ToInt32(listeningBox.Text), System.Convert.ToInt32(readingBox.Text),
                           System.Convert.ToInt32(writingBox.Text), notesBox.Text);
            }
            catch
            {
                MessageBox.Show("Invalid Score Input");
                return;
            }
            firstBox.Clear();
            lastBox.Clear();
            levelBox.SelectedValue = 0;
            this.Close();
        }