/* * NAME * * Help_Reader_Form::Student_List_SelectedIndexChanged - event that changes the reading level * based on the student. * * SYNOPSIS * * void Help_Reader_Form::Student_List_SelectedIndexChanged(object sender, EventArgs e); * * sender --> object sending the event. * e --> the event arguments. * * DESCRIPTION * * This function triggers when the selected student has changed. It loads their current * reading level from the database into a textbox to be viewed. * */ private void Student_List_SelectedIndexChanged(object sender, EventArgs e) { //Save id in hidden textbox int id = students.ElementAt(Student_List.SelectedIndex).ID; Student_ID_Box.Text = id.ToString(); //Load current reading lvl char lvl = Database_Interface.Query_Student(id).CurrentLevel; Reading_Lvl_Txtbox.Text = lvl.ToString(); }
/* * NAME * * Help_Reader_Form::Level_Up_Button_Click - event that increases the reading level * of that student by 1. * * SYNOPSIS * * void Help_Reader_Form::Level_Up_Button_Click(object sender, EventArgs e); * * sender --> object sending the event. * e --> the event arguments. * * DESCRIPTION * * This function triggers when the user clicks the "Level Up!" button. It increases the student * level by 1, or does nothing if they've reached the maximum reading level. * */ private void Level_Up_Button_Click(object sender, EventArgs e) { DialogResult result = MessageBox.Show("Are you sure you want to level up this student?", "Are you sure?", MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { //Increase reading level by 1 string student_id = Student_ID_Box.Text; int id = Convert.ToInt32(Student_ID_Box.Text); char current_level = Database_Interface.Query_Reading_Level(id); if (!current_level.Equals('Z')) { char new_level = (char)(Convert.ToUInt16(current_level) + 1); Database_Interface.Update_Reading_Lvl(student_id, new_level); //Refresh current level char lvl = Database_Interface.Query_Student(id).CurrentLevel; Reading_Lvl_Txtbox.Text = lvl.ToString(); } } }