Exemplo n.º 1
0
        private void DynamicChangeGrade_Click(object sender, EventArgs e)
        {
            TabPage        tab          = (TabPage)((Ambiance_Button_2)sender).Parent;
            SchoolClass    currentClass = Database.classes[tab.Name];
            User           currentUser  = currentClass.students[((ComboBox)tab.Controls.Find("studentBox", false)[0]).SelectedIndex];
            Ambiance_Panel currentPanel = (Ambiance_Panel)tab.Controls.Find("studentGradesPanel", false)[0];

            ChangeGrade(tab, currentClass, currentUser, currentPanel);
        }
Exemplo n.º 2
0
        private void ChangeGrade(TabPage tab, SchoolClass currentClass, User currentUser, Ambiance_Panel currentPanel)
        {
            List <int> currentGrades = currentClass.grades[currentUser].grades;
            bool       errorShown    = false;

            Control[] gradeBoxs = currentPanel.Controls.Find("grade", false);
            for (int i = 0; i < currentGrades.Count; i++)
            {
                try
                {
                    if (Int32.Parse(gradeBoxs[i].Text) <= 100 && Int32.Parse(((Ambiance_TextBox)gradeBoxs[i]).Text) >= 0)
                    {
                        currentGrades[i] = Int32.Parse(((Ambiance_TextBox)gradeBoxs[i]).Text);
                    }
                    else
                    if (!errorShown)
                    {
                        MessageBox.Show("Grades must be 0-100");
                        errorShown = false;
                    }
                }
                catch (Exception)
                {
                    if (!errorShown)
                    {
                        MessageBox.Show("Grades can be numbers only!");
                        errorShown = true;
                    }
                }
            }
            if (!errorShown)
            {
                MessageBox.Show("Grades Successfully Updated");
            }
            Database.SaveClass(currentClass);
            tab.Controls.Find("studentGPALabel", false)[0].Text = "GPA : " + String.Format("{0:0.00}", currentUser.CalculateGPA());
        }
Exemplo n.º 3
0
        private void AddGrade(TabPage tab, SchoolClass currentClass, User currentUser, Ambiance_Panel currentPanel)
        {
            List <int> currentGrades = currentClass.grades[currentUser].grades;
            int        i             = currentGrades.Count;

            currentGrades.Add(0);
            currentPanel.Controls.Add(new Ambiance_Label
            {
                AutoSize = true,
                Location = new System.Drawing.Point(12, 48 * i + 12),
                Name     = "label" + i,
                Size     = new System.Drawing.Size(54, 20),
                Text     = ("Test " + i + " : ")
            });
            currentPanel.Controls.Add(new Ambiance_Separator
            {
                Location = new System.Drawing.Point(4, 48 * i + 42),
                Name     = "separator" + i,
                Size     = new System.Drawing.Size(139, 10)
            });
            currentPanel.Controls.Add(new Ambiance_TextBox
            {
                Location      = new System.Drawing.Point(73, 48 * i + 9),
                Name          = "grade",
                Size          = new System.Drawing.Size(69, 28),
                Text          = ("0"),
                MaxLength     = 3,
                TextAlignment = HorizontalAlignment.Center
            });
        }