Ejemplo n.º 1
0
        private void Submit_AddUnCummGPA_Click(object sender, EventArgs e)
        {
            int studentID;

            try
            {
                studentID = int.Parse(ID_AddUnCummGPA.Text);
            }
            catch
            {
                MessageBox.Show("Please make sure a number is in the ID field!");
                return;
            }
            string ID = studentID + "";

            float GPA;

            try
            {
                GPA = float.Parse(Grade_AddUnCummGPA.Text);
            }
            catch
            {
                MessageBox.Show("Please make sure a number is in the GPA field!");
                return;
            }
            string unCumGPA = GPA + "";

            if (GPA > 100 || GPA < 0)
            {
                MessageBox.Show("Please make sure GPA is between 0 and 100!");
                return;
            }

            DateTime date   = DateTime.Now;
            string   year   = date.Year.ToString();
            string   month  = date.Month.ToString();
            string   day    = date.Day.ToString();
            string   curDay = year + '-' + month + '-' + day;

            string className = classNameDrop.Text;

            if (Model.InsertUnCumGPA(ID, unCumGPA, curDay, className))
            {
                Model.UpdateStudentTableGradeDate(ID, curDay);
                this.Close();
            }
            else
            {
                MessageBox.Show("Something went wrong in processing the GPA. Please try again.");
            }
        }