protected void enrollButton_Click(object sender, EventArgs e)
        {
            if(!IsValid)
            {
                return;
            }

            try
            {
                StudentCourse aStudentCourse = new StudentCourse();
                aStudentCourse.RegistrationNo = registationNoTextBox.Text;
                aStudentCourse.EnrollDate = dateTextBox.Text;
                aStudentCourse.CourseId = Convert.ToInt16(enrollDropDownList.Text);
                aStudentCourse.Status = 0;
                StudentManager aStudentManager = new StudentManager();
                string msg = aStudentManager.SaveStudentCourse(aStudentCourse);
                if(msg=="Saved")
                {
                    msgLabel.ForeColor = Color.Green;
                    msgLabel.Text = msg;
                    ShowStudentAndCourseInfo();
                }
                else
                {
                    msgLabel.ForeColor = Color.Red;
                    msgLabel.Text = msg;
                }

            }
            catch (SqlException sqlException)
            {
                msgLabel.ForeColor = Color.Red;
                msgLabel.Text = "Database error.See details error: " + sqlException.Message;

            }
            catch (Exception exception)
            {
                msgLabel.ForeColor = Color.Red;
                string errorMessage = "Unknow error occured.";
                errorMessage += exception.Message;
                if (exception.InnerException != null)
                {
                    errorMessage += exception.InnerException.Message;
                }
                msgLabel.Text = errorMessage;
            }
        }
        public string SaveStudentCourse(StudentCourse aStudentCourse)
        {
            try
            {
                connection.Open();
                string query = "INSERT INTO t_StudentCourseEnroll VALUES(@regNo,@date,@courseId,@status)";
                command.CommandText = query;
                command.Parameters.Clear();
                command.Parameters.AddWithValue("@regNo", aStudentCourse.RegistrationNo);
                command.Parameters.AddWithValue("@date", aStudentCourse.EnrollDate);
                command.Parameters.AddWithValue("@courseId", aStudentCourse.CourseId);
                command.Parameters.AddWithValue("@status", aStudentCourse.Status);
                command.ExecuteNonQuery();
                return "Saved";
            }

            finally
            {
                connection.Close();
            }
        }
 public string SaveStudentCourse(StudentCourse aStudentCourse)
 {
     aStudentGateway = new StudentGateway();
     return aStudentGateway.SaveStudentCourse(aStudentCourse);
 }