protected void btn_addCourse_Click(object sender, EventArgs e) { var grade = new Grades(); string param = Request.QueryString["studentID"]; if (ddl_studCourse.SelectedValue != "0") { var studID = int.Parse(param); grade.Grade = ddl_studGrade.SelectedValue; grade.Completed = chkbox_completed.Checked; grade.CourseID = int.Parse(ddl_studCourse.SelectedValue); grade.StudentID = studID; var student = sc.StudentsByID(studID); var myBool = student.Grades.FirstOrDefault(x => x.CourseID == grade.CourseID && x.StudentID == grade.StudentID) != null; if (myBool) { var gc = new GradesControl(); gc.UpdateGrade(grade); } else { student.Grades.Add(grade); sc.UpdateStudent(student); } } Response.Redirect($"Course?StudentID={param}"); }
protected void btn_save_Click(object sender, EventArgs e) { var studentToUpdate = sc.StudentsByID(int.Parse(hf_id.Value)); studentToUpdate.People.FirstName = txtbox_firstname.Text; studentToUpdate.People.LastName = txtbox_lastname.Text; studentToUpdate.People.Address = txtbox_adress.Text; studentToUpdate.People.Email = txtbox_email.Text; studentToUpdate.StudentClass_Id = int.Parse(ddl_class.SelectedValue); studentToUpdate.EducationId = int.Parse(ddl_education.SelectedValue); sc.UpdateStudent(studentToUpdate); lbl_msg.Text = $"Updated Student {studentToUpdate.People.FirstName} {studentToUpdate.People.LastName}"; ClearTxtBoxes(); Response.Redirect("Default.aspx"); }