示例#1
0
        /// <summary>
        /// Handles the event when the link button for "Update Grade" is clicked.
        /// Parses the input and updates the grade for the given registration.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void lnkUpdate_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
        {
            string formatClearedValue = Numeric.ClearFormatting(gradeTextBox.Text, "%");

            if (Numeric.isNumeric(formatClearedValue, System.Globalization.NumberStyles.Float))
            {
                double gradeParsed = double.Parse(formatClearedValue);
                gradeParsed = gradeParsed / 100;
                if (gradeParsed >= 0 && gradeParsed <= 1)
                {
                    Registration idToBeUpdated  = constructorData.registration;
                    int          registrationID = idToBeUpdated.RegistrationId;
                    string       notes          = idToBeUpdated.Notes;
                    ServiceReference.CollegeRegistrationClient localWS = new ServiceReference.CollegeRegistrationClient();
                    localWS.updateGrade(gradeParsed, registrationID, notes);
                    frmStudent frmStudent = new frmStudent(constructorData);
                    frmStudent.MdiParent = this.MdiParent;
                    frmStudent.Show();
                    this.Close();
                }
                else
                {
                    MessageBox.Show("Grade value is out of range, please enter a value between 0 to 1.");
                }
            }
            else
            {
                MessageBox.Show("Please enter grade in decimal format between 0 and 1. Update failed.");
            }
        }