protected void GridView1_DataBound(object sender, EventArgs e)
        {
            //going to check if any need teacher marks.
            string s = "";

            foreach (GridViewRow r in GridView1.Rows)
            {
                Exam_ResitEntry exr1 = new Exam_ResitEntry();
                Guid            g1   = new Guid(r.Cells[1].Text);
                exr1.Load(g1);
                ExamOption exo1 = new ExamOption(); exo1.Load(exr1.m_OptionId);
                if (exo1.NeedsTeacherMarks())
                {
                    s += "WARNING: Option " + r.Cells[2].Text + " requires Teacher Marks!   ";
                }
            }
            Label_Error.Text = s;
        }
        /*
         *  private void RenderModuleResultLine(HttpResponse Response, Result r1,bool retake)
         *  {
         *      string s = "";
         *      ExamOption exo1 = new ExamOption();
         *      Response.Write("<TR>");
         *      s = r1.Date.ToShortDateString(); Response.Write("<TD>" + s + "</TD>");
         *      s = r1.Coursename; Response.Write("<TD>" + s + "</TD>");
         *      s = r1.OptionTitle; Response.Write("<TD>" + s + "</TD>");
         *      s = r1.OptionCode; Response.Write("<TD>" + s + "</TD>");
         *      s = r1.Value; Response.Write("<TD>" + s + "</TD>");
         *      s = r1.OptionMaximumMark; Response.Write("<TD>" + s + "</TD>");
         *
         *      s = "";
         *      if (r1.Resulttype == 27)//UMS mark for GCSE
         *      {
         *          try
         *          {
         *              double v1 = System.Convert.ToDouble(r1.Value);
         *              double v2 = System.Convert.ToDouble(r1.OptionMaximumMark);
         *              v1 = v1 / v2;
         *              if (v1 >= 0.9) s = "a*";
         *              if ((v1 < 0.9) && (v1 >= 0.8)) s = "a";
         *              if ((v1 < 0.8) && (v1 >= 0.7)) s = "b";
         *              if ((v1 < 0.7) && (v1 >= 0.6)) s = "c";
         *              if ((v1 < 0.6) && (v1 >= 0.5)) s = "d";
         *              if ((v1 < 0.5) && (v1 >= 0.4)) s = "e";
         *              if ((v1 < 0.4)) s = "u";
         *          }
         *          catch (Exception exc1)
         *          {
         *              s = exc1.Message;
         *          }
         *      }
         *      if (r1.Resulttype == 11)//GCE module mark
         *      {
         *          try
         *          {
         *              double v1 = System.Convert.ToDouble(r1.Value);
         *              double v2 = System.Convert.ToDouble(r1.OptionMaximumMark);
         *              v1 = v1 / v2;
         *              if (v1 >= 0.8) s = "a";
         *              if ((v1 < 0.8) && (v1 >= 0.7)) s = "b";
         *              if ((v1 < 0.7) && (v1 >= 0.6)) s = "c";
         *              if ((v1 < 0.6) && (v1 >= 0.5)) s = "d";
         *              if ((v1 < 0.5) && (v1 >= 0.4)) s = "e";
         *              if ((v1 < 0.4)) s = "u";
         *          }
         *          catch (Exception exc1)
         *          {
         *              s = exc1.Message;
         *          }
         *      }
         *
         *      Response.Write("<TD>" + s + "</TD>");
         *      exo1.Load(r1.OptionId);
         *      Exam_Board exb1 = new Exam_Board(exo1.m_ExamBoardID);
         *      Response.Write("<TD>" + exb1.m_OrganisationFriendlyName + "</TD>");
         *      if (retake)
         *      {
         *          CheckBox cb1 = new CheckBox();
         *          cb1.ID = "CheckBox-" + r1.OptionId.ToString() ;
         *          Response.Write("<TD><asp:CheckBox ID=\"" + cb1.ID.ToString() + "\"  runat=\"server\" /></TD>");
         *      }
         *      Response.Write("</TR>");
         *  }
         *
         *  private void RenderModuleResultTableHeader(HttpResponse Response, Guid PersonId,bool retake)
         *  {
         *      Utility u1 = new Utility();
         *      Response.Write("<H1><center> Module Results for " + u1.GetPersonName(PersonID) + "</H1></center><BR>");
         *      Response.Write("<BR><p  align=\"center\"><TABLE BORDER><TR>");
         *      Response.Write("<TD>Date</TD>");
         *      Response.Write("<TD>Subject</TD>");
         *      Response.Write("<TD>Option Title</TD>");
         *      Response.Write("<TD>Option Code</TD>");
         *      Response.Write("<TD>Result</TD>");
         *      Response.Write("<TD>Max Mark</TD>");
         *      Response.Write("<TD>Grade</TD>");
         *      Response.Write("<TD>Exam Board</TD>");
         *      if (retake) Response.Write("<TD>Retake ?</TD>");
         *      Response.Write("</TR>");
         *  }
         */
        protected void Button_submit_Click(object sender, EventArgs e)
        {
            Guid PersonID = (Guid)ViewState["PersonID"];

            Table1.Visible        = false;
            Label1.Visible        = false;
            TextBox_cost.Visible  = false;
            Button_submit.Visible = false;
            Label_title.Visible   = false;
            ExamOption           exo1 = new ExamOption();
            ExamCompononent_List ecl1 = new ExamCompononent_List();
            string  dates             = "";
            double  cost  = 0;
            double  total = 0;
            Utility u1    = new Utility();

            Guid[]       list1 = new Guid[100]; int no_list1 = 0; bool in_list1 = false;
            PupilDetails pupil1 = new PupilDetails(u1.GetStudentId(PersonID).ToString());

            int    cover_cost = RetakeCoverCost();
            string season     = RetakeSeason();
            string year       = RetakeYear();
            string s1         = RetakeMessage();
            string s2         = "";

            s2  = "<H2><center>Entry Requests for " + u1.GetPersonName(PersonID) + "  " + u1.Get_Form(pupil1.m_StudentId.ToString()) + "(" + pupil1.m_examNo.ToString() + ")</H2></center><BR>";
            s2 += "<H3><center>You should print this page and take it with your cheque ";
            s2 += "made out to DCGS to the Exams Office.</H3></center><BR><H3><center>" + s1 + "</H3></center><BR>";


            s2 += "<BR><p  align=\"center\"><TABLE BORDER><TR><TD>Option Code</TD><TD>Option Title</TD>";
            s2 += "<TD>Exam Board</TD><TD>Date</TD><TD>Cost</TD><TD>Comment</TD></TR>";

            resultlist1 = (ResultsList)ViewState["ResultList"];
            string   s   = "";
            CheckBox cb1 = new CheckBox();

            foreach (Result r1 in resultlist1._results)
            {
                s   = r1.OptionId.ToString(); cb1 = null;
                cb1 = (CheckBox)content.FindControl(s);
                if (cb1 != null)
                {
                    if (cb1.Checked)
                    {
                        exo1.Load(r1.OptionId);
                        ecl1.m_list.Clear();
                        ecl1.Load(r1.OptionId);
                        Exam_ResitEntry exres1 = new Exam_ResitEntry();
                        exres1.Load(r1.StudentID, r1.OptionId);
                        in_list1 = false;
                        for (int i = 0; i < no_list1; i++)
                        {
                            if (list1[i] == r1.OptionId)
                            {
                                in_list1 = true;
                            }
                        }

                        if (in_list1)
                        {
                            //already entered......
                        }
                        else
                        {
                            s2 += "<TR><TD>" + r1.OptionCode + "</TD><TD>" + r1.OptionTitle + "</TD>";
                            Exam_Board exb1 = new Exam_Board(exo1.m_ExamBoardID);
                            s2   += "<TD>" + exb1.m_OrganisationFriendlyName + "</TD>";
                            dates = "";
                            foreach (ExamComponent c1 in ecl1.m_list)
                            {
                                if (c1.m_Timetabled == "T")
                                {
                                    dates += c1.m_TimetableDate.ToShortDateString();
                                }
                            }
                            s2  += "<TD>" + dates + "</TD>";
                            cost = (double)exo1.m_feeInt + cover_cost;
                            exres1.Load(r1.StudentID, r1.OptionId);
                            if (!exres1.m_valid)
                            {
                                exres1.m_cost        = (int)cost;
                                exres1.m_DateCreated = DateTime.Now;
                                exres1.m_OptionId    = r1.OptionId;//has been updated when we loaded it to be the new one..
                                exres1.m_season      = season;
                                exres1.m_year        = year;
                                exres1.m_StudentId   = u1.GetStudentId(PersonID);
                                exres1.m_version     = 1;
                                exres1.Save();
                            }
                            cost   = cost / 100;
                            total += cost;
                            s2    += "<TD>" + cost.ToString() + "</TD>";
                            if (exo1.NeedsTeacherMarks())
                            {
                                s2 += "<TD>Warning - Needs CW</TD></TR>";
                            }
                            else
                            {
                                s2 += "<TD></TD></TR>";
                            }
                            list1[no_list1] = r1.OptionId; no_list1++;
                        }
                    }
                    else
                    {
                        Exam_ResitEntry exres1 = new Exam_ResitEntry();
                        exres1.Load(r1.StudentID, r1.OptionId);
                        if (exres1.m_valid)
                        {
                            exres1.Delete();                 //need to delete it!!!;
                        }
                    }
                }
            }
            s2 += "</TABLE> <H3><center>Total Cost : £" + total.ToString() + "</H3></center><H3><center>Dates are provisional!</H3></center>";
            servercontent.InnerHtml = s2;
        }