Exemple #1
0
        protected void UpdateTimetable(DateTime start, DateTime end)
        {
            // add scheduled components for any components not scheduled...
            //TODO also delete any withdrawn....
            ExamConversions      u    = new ExamConversions();
            ExamCompononent_List ecl1 = new ExamCompononent_List();

            //ecl1.LoadAllComponents(Year.ToString(), SeasonCode.ToString());
            ecl1.LoadAllComponentsSeasonDate(YearCode.ToString(), SeasonCode.ToString(), start, end);
            Encode en = new Encode();
            string s  = "";

            ScheduledComponent sched1 = new ScheduledComponent();

            s = ""; int n = 0;
            DateTime    d1 = new DateTime();

            foreach (ExamComponent ec in ecl1.m_list)
            {
                ExamLinkComponent_List elcl1 = new ExamLinkComponent_List();
                elcl1.LoadList_Component(ec.m_ComponentID);
                foreach (ExamLinkComponent elc in elcl1.m_list)
                {
                    ExamEntries_List exl1 = new ExamEntries_List();
                    //now need all entries for this option.....
                    exl1.Load_Option(elc.m_OptionId);
                    n += exl1.m_list.Count;
                }
            }

            int n1 = 0; int n2 = 0;

            foreach (ExamComponent ec in ecl1.m_list)
            {
                if (ec.m_Timetabled == "T")
                {
                    d1 = ec.m_TimetableDate;
                    if (ec.m_TimetableSession == "A")
                    {
                        d1 = d1.AddHours(8); d1 = d1.AddMinutes(50);
                    }
                    else
                    {
                        d1 = d1.AddHours(13); d1 = d1.AddMinutes(40);
                    }
                    //need to find all entries that use this component.....
                    ExamLinkComponent_List elcl1 = new ExamLinkComponent_List();
                    elcl1.LoadList_Component(ec.m_ComponentID);
                    foreach (ExamLinkComponent elc in elcl1.m_list)
                    {
                        ExamEntries_List exl1 = new ExamEntries_List();
                        //now need all entries for this option.....
                        exl1.Load_Option(elc.m_OptionId);
                        foreach (Exam_Entry ex in exl1.m_list)
                        {
                            if (!ex.m_withdrawn)
                            {
                                sched1.Load(ec.m_ComponentID, ex.m_StudentID);
                                if (!sched1.m_valid)
                                {
                                    sched1.m_StudentId   = ex.m_StudentID;
                                    sched1.m_ComponentId = ec.m_ComponentID;
                                    sched1.m_RoomId      = Guid.Empty;
                                    sched1.m_Year        = Year.ToString();
                                    sched1.m_Season      = u.GetSeasonCode(SeasonCode);
                                    sched1.m_valid       = true;
                                    sched1.m_Date        = d1;
                                    sched1.m_Desk        = "";
                                    sched1.m_Will_Type   = false;// do these later...
                                    sched1.Save();
                                    n2++;
                                }
                            }
                            else
                            {
                                sched1.Load(ec.m_ComponentID, ex.m_StudentID);
                                if (sched1.m_valid)
                                {
                                    //need to delete
                                    sched1.Delete();
                                    n1++;
                                }
                            }
                        }
                    }
                }
            }


            //now ought to update the willtype fields to agree with the cantype entry..
            //oohhh this is going to be messy.....
            //read from a querry..... then update Exams_Scheduled_components...

            CanTypeList typists = new CanTypeList();

            foreach (Guid g in typists.m_List)
            {
                s = "UPDATE dbo.tbl_Exams_ScheduledComponents SET WillType =1 WHERE (StudentId = '" + g.ToString() + "'  )AND (Year='" + YearCode.ToString() + "' ) AND (Season ='" + u.GetSeasonCode(SeasonCode) + "' )";
                en.ExecuteSQL(s);
            }
        }
Exemple #2
0
        public bool AddEntry(Guid StudentId, Exam_Board exbde1, int Year, int YearCode, int Season, string option, int EntryStatusCode, bool checkDisallowed, ref string ErrorMessage, ref Guid EntryId)
        {
            //Year is 2 digit code.....
            bool       disallowed = false; ErrorMessage = "";
            ExamOption ex01       = new ExamOption();
            ExamOption ex02       = new ExamOption();
            ExamFiles  ef1        = new ExamFiles();

            ex01.Load(option, Season.ToString(), YearCode.ToString(), exbde1.m_ExamBoardId);
            if (!ex01.m_valid)
            {
                //need to search basedata...
                ex01 = ef1.Find_Option(option, exbde1, Season.ToString(), YearCode.ToString());
            }
            if (ex01 != null)
            {
                ExamEntries_List exen1 = new ExamEntries_List();
                exen1.Load(StudentId, Year.ToString(), Season.ToString());
                if (checkDisallowed)
                {
                    foreach (Exam_Entry ex1 in exen1.m_list)
                    {
                        if (!ex1.m_withdrawn)
                        {
                            ex02.Load(ex1.m_OptionID);
                            disallowed = ef1.CombinationDisallowed(exbde1, ex01.m_OptionCode, ex02.m_OptionCode, ex01.m_SeriesIdentifier, ex01.m_year_Code);
                            if (disallowed)
                            {
                                ErrorMessage = "Combination of " + ex01.m_OptionCode + " and " + ex02.m_OptionCode + " not allowed!";
                                return(false);
                            }
                        }
                    }
                }
                if (!disallowed)
                {
                    Exam_Entry entry1 = new Exam_Entry();
                    entry1.m_OptionID     = ex01.m_OptionID;
                    entry1.m_StudentID    = StudentId;
                    entry1.m_Date_Created = DateTime.Now;
                    entry1.m_season       = Season.ToString();
                    entry1.m_year         = Year.ToString();
                    entry1.m_ExamEntryID  = Guid.Empty;
                    entry1.m_EntryStatus  = EntryStatusCode;

                    foreach (Exam_Entry ex1 in exen1.m_list)
                    {
                        if (ex1.m_OptionID == ex01.m_OptionID)
                        {
                            //found this student, this series, this option
                            entry1.m_ExamEntryID = ex1.m_ExamEntryID;
                        }
                    }
                    entry1.Save();
                    EntryId = entry1.m_ExamEntryID;
                    return(true);
                }
            }
            else
            {
                ErrorMessage = "Option code  " + option + " not found"; return(false);
            }

            return(false);
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                Utility  u1 = new Utility();
                DateTime t1 = new DateTime();
                DateTime t0 = new DateTime();
                DateTime t2;
                t0 = u1.ThisExamSeasonStart(); t1 = u1.ThisExamSeasonEnd(t0);
                string season = u1.ThisSeason(t0);
                season = "3";
                ArrayList m_list = new ArrayList();
                PersonID = u1.GetPersonIdfromRequest(Request);

#if DEBUG
                u1.Is_student = true;
                u1.Is_student = true; PersonID = u1.GetPersonIDX(@"CHALLONERS\william.arnold");//development
#endif
                string s = ""; string s1 = "";
                if ((PersonID != Guid.Empty) && (u1.Is_student))
                {
                    s1 += "<br><center><h2>Exam Entries</h2></center>";
                    s1 += "<p  align=\"center\"><TABLE BORDER><Tr>";
                    s   = "Option"; s1 += "<Th>" + s + "</Th>";
                    s   = "Code"; s1 += "<Th>" + s + "</Th>";
                    s   = "Qualification"; s1 += "<Th>" + s + "</Th>";
                    s   = "Level"; s1 += "<Th>" + s + "</Th>";
                    s   = "Status"; s1 += "<Th>" + s + "</Th>";
                    s1 += "</Tr>";
                    ExamEntries_List exl1 = new ExamEntries_List();
                    exl1.Load(u1.GetStudentId(PersonID));
                    foreach (Exam_Entry ex1 in exl1.m_list)
                    {
                        ExamOption exo1 = new ExamOption(); exo1.Load(ex1.m_OptionID);
                        //if ((ex1.m_season == season) && (ex1.m_year == t0.Year.ToString())&&(!ex1.m_withdrawn))
                        if ((ex1.m_year == t0.Year.ToString()) && (!ex1.m_withdrawn))
                        {
                            //ExamOption exo1 = new ExamOption(); exo1.Load(ex1.m_OptionID);
                            //if (exo1.m_Item == "C")
                            {
                                s1 += "<TR>";
                                s   = exo1.m_OptionTitle; s1 += "<TD>" + s + "</TD>";
                                s   = exo1.m_OptionCode; s1 += "<TD>" + s + "</TD>";
                                s   = exo1.m_OptionQualification; s1 += "<TD>" + s + "</TD>";
                                if (exo1.m_OptionLevel != "B")
                                {
                                    s = exo1.m_OptionLevel; s1 += "<TD>" + s + "</TD>";
                                }
                                else
                                {
                                    s1 += "<TD></TD>";
                                }
                                if (ex1.m_EntryFileID == Guid.Empty)

                                {
                                    //if DCGS board then Mock/Internal exam
                                    if (exo1.m_ExamBoardID.ToString() == "436ff234-0457-430a-b1e2-b08758ff30ef")
                                    {
                                        //so internal.. if Jan is mocks..
                                        if (exo1.m_Season_code == "1")
                                        {
                                            s1 += "<td>Mock</td>";
                                        }
                                        else
                                        {
                                            s1 += "<td>Internal</td>";
                                        }
                                    }
                                    else
                                    {
                                        s1 += "<TD>Provisional</TD>";
                                    }
                                }
                                else
                                {
                                    s1 += "<TD>Entered</TD>";
                                }
                                s1 += "</TR>";
                            }

                            ExamCompononent_List excl1 = new ExamCompononent_List();
                            excl1.Load(ex1.m_OptionID);
                            foreach (ExamComponent ec in excl1.m_list)
                            {
                                if (ec.m_Timetabled == "T")
                                {
                                    ExamComponent ec2 = new ExamComponent(); ec2 = ec;
                                    m_list.Add(ec2); ec2.m_OptionTitle = exo1.m_Syllabus_Title;
                                }
                            }
                        }
                    }
                    s1 += "</TABLE>";
                    s1 += "<center>FC = Full Course, SC = Short(Half) Course<br>";

                    foreach (ExamComponent ec in m_list)
                    {
                        t2 = System.Convert.ToDateTime(ec.m_TimetableDate);
                        if (t2 < t1)
                        {
                            t1 = System.Convert.ToDateTime(ec.m_TimetableDate);
                        }
                        if (t2 > t0)
                        {
                            t0 = System.Convert.ToDateTime(ec.m_TimetableDate);
                        }
                    }
                    int month = t1.Month; ExamComponent ecx;
                    int day = t1.Day;
                    s1 += "<br><br><br><center><h2>Outline Exam Timetable</h2>";
                    s1 += "Full Exam Timetable can be found <a href=\"ExamTimetables.aspx?\">here</a></center>";
                    s1 += "<center>Note that for GCSE Languages the tier (Foundation or Higher) is not significant. ";
                    s1 += "<BR><p  align=\"center\"><TABLE BORDER><TR>";
                    s   = "Date"; s1 += "<Th>" + s + "</Th>";
                    s   = "AM Session"; s1 += "<Th>" + s + "</Th>";
                    s   = "PM Session"; s1 += "<Th>" + s + "</Th>";
                    s1 += "</TR>";
                    //from t1 to t0...
                    t2 = t1; t0 = t0.AddDays(1);
                    while (t2 < t0)
                    {
                        if ((t2.DayOfWeek.ToString() != "Saturday") && (t2.DayOfWeek.ToString() != "Sunday"))
                        {
                            s1 += "<TR>";
                            s   = t2.DayOfWeek.ToString(); s += "<br>" + t2.ToShortDateString(); s1 += "<TD>" + s + "</TD>"; s = ""; ecx = null;
                            foreach (ExamComponent ec in m_list)
                            {
                                if ((t2 == System.Convert.ToDateTime(ec.m_TimetableDate)) && (ec.m_TimetableSession == "A"))
                                {
                                    s += ec.m_OptionTitle + ec.m_ComponentTitle.ToLower() + "<br>"; ecx = ec;
                                }
                            }
                            if (ecx != null)
                            {
                                m_list.Remove(ecx);
                            }
                            s1 += "<TD>" + s + "</TD>"; s = ""; ecx = null;
                            foreach (ExamComponent ec in m_list)
                            {
                                if ((t2 == System.Convert.ToDateTime(ec.m_TimetableDate)) && (ec.m_TimetableSession == "P"))
                                {
                                    s += ec.m_OptionTitle + ec.m_ComponentTitle.ToLower() + "<br>"; ecx = ec;
                                }
                            }
                            m_list.Remove(ecx);
                            s1 += "<TD>" + s + "</TD>";
                            s1 += "</TR>";
                        }
                        t2 = t2.AddDays(1);
                    }
                    s1 += "</TABLE>";
                    servercontent.InnerHtml = s1;
                }
            }
        }
Exemple #4
0
        private bool ProcessFile(Exam_Board exb1, string series, ref string Errors)
        {
            //so are we able to do E file or A file...
            string s               = "";
            string line            = "";
            Cerval_Configuration c = new Cerval_Configuration("StaffIntranet_Exams_CentreNumber");
            string centre_number   = "";

            if (c.valid)
            {
                centre_number = c.Value;
            }
            else
            {
                Errors = "Centre Number not found in cerval..." + centre_number; return(false);
            }



            //check that if we are asked for an E file we dont already have one...
            //could just check no entries have been sent for this series...
            ExamEntries_List exl0 = new ExamEntries_List();

            exl0.LoadAllSeries(Year.ToString(), series, true, exb1.m_ExamBoardId.ToString());
            char type = exl0.m_list.Count > 0 ? 'A' : 'E';

            int          n1    = 0;
            Encode       en    = new Encode();
            PupilDetails p1    = new PupilDetails();
            DateTime     date1 = new DateTime();

            date1 = DateTime.Now;


            if (centre_number.Length != 5)
            {
                Errors = "Centre Number wrong!" + centre_number; return(false);
            }

            Exam_File    ef1 = new Exam_File();
            StreamWriter fs  = OpenFile(exb1, type, ref ef1, 194, series, centre_number, "14");

            if (fs == null)
            {
                Errors = "Error opening file"; return(false);
            }
            if (type == 'A')
            {
                //going to find any not yet sent and for these students clear the sent dates...
                exl0.m_list.Clear();



                exl0.LoadAllSeries(Year.ToString(), series, false, exb1.m_ExamBoardId.ToString());


                //now for each student in this list we need to re-send entries....
                foreach (Exam_Entry ex in exl0.m_list)
                {
                    ExamOption exo0 = new ExamOption();
                    exo0.Load(ex.m_OptionID);
                    ExamEntries_List exl2 = new ExamEntries_List();
                    exl2.Load(ex.m_StudentID, Year.ToString(), series, true, exb1.m_ExamBoardId.ToString());
                    foreach (Exam_Entry ex0 in exl2.m_list)
                    {
                        s  = "UPDATE tbl_Exams_Entries SET EntryFileID = NULL , DateEntered = NULL WHERE (ExamEntryID ='" + ex0.m_ExamEntryID.ToString() + "')";
                        n1 = en.Execute_count_SQL(s);
                    }
                }
            }

            ExamEntries_List exl1 = new ExamEntries_List();

            exl1.LoadAllSeries(Year.ToString(), series, false, exb1.m_ExamBoardId.ToString());
            int  n         = 0;
            int  n_record  = -1;//don't write first one
            int  n_records = 0;
            Guid std1      = Guid.Empty;

            foreach (Exam_Entry ex1 in exl1.m_list)
            {
                if (ex1.m_StudentID != std1)
                {
                    //have a new student
                    while (line.Length < 192)
                    {
                        line += " ";
                    }
                    if (n_record >= 0)
                    {
                        fs.WriteLine(line); n_records++;
                    }
                    std1     = ex1.m_StudentID;
                    p1.m_UCI = "";
                    p1.Load(std1.ToString());
                    n_record = 0;
                    line     = "";
                }
                if (n_record == 12)
                {
                    while (line.Length < 192)
                    {
                        line += " ";
                    }
                    fs.WriteLine(line); n_records++;
                    line = ""; n_record = 0;
                }
                n++;
                if (line == "")
                {
                    line = type + "5";
                    if (p1.m_IsOnRole)
                    {
                        line += "C";
                    }
                    else
                    {
                        line += "P";
                    }
                    line += centre_number;
                    s     = p1.m_examNo.ToString();
                    while (s.Length < 4)
                    {
                        s = "0" + s;
                    }
                    line += s;
                    //going to strip , from middle names to space...
                    s = p1.m_Surname + ":" + p1.m_GivenName + " " + p1.m_MiddleName.Replace(",", " ");
                    while (s.Length < 40)
                    {
                        s += " ";
                    }
                    if (s.Length > 40)
                    {
                        s.Substring(0, 40);
                    }
                    line += s;
                    if (p1.m_Gender == "F")
                    {
                        line += "F";
                    }
                    else
                    {
                        line += "M";
                    }
                    if (p1.m_dob == null)
                    {
                        s = "000000";
                    }
                    else
                    {
                        s = p1.m_dob.ToString("ddMMyy");
                    }
                    if (s == "010101")
                    {
                        s = "000000";               //010101  appears to the the defauult date if date in NULL in db
                    }
                    line += s;
                    if ((p1.m_UCI.Length != 13) || (p1.m_examNo == 0))
                    {
                        // todo  .. need to hanlde this error
                        /// clean up or offer UCI generation....
                        Errors  = "No UCI for " + p1.m_GivenName + " " + p1.m_Surname + "(" + p1.m_adno.ToString() + ")";
                        Errors += "Please create UCI for student and re-run";
                        //first mark any entries made for this file as not made........
                        s  = "UPDATE dbo.tbl_Exams_Entries SET EntryFileID = NULL , DateEntered = NULL ";
                        s += " WHERE (EntryFileID ='" + ef1.m_EntryFileId.ToString() + "' )";
                        Encode en1 = new Encode();
                        n1 = en1.Execute_count_SQL(s);
                        fs.Close();
                        return(false);
                    }
                    s     = p1.m_UCI;
                    line += s;
                    line += p1.m_upn.Trim();

                    //TODO....
                    line += p1.m_uln.Trim();
                    //line += "          ";//uln
                    //now the guest flag..... hmm...
                    //ought to do this really for cand from collaboration...

                    line += "             ";// up to byte 108 in jcq mess...
                }
                ExamOption exo1 = new ExamOption();
                exo1.Load(ex1.m_OptionID);
                if (exo1.m_ExamBoardID == exb1.m_ExamBoardId)
                {
                    //add it to the file unless withdrawn
                    if (!ex1.m_withdrawn)
                    {
                        s     = exo1.m_OptionCode + "      "; s = s.Substring(0, 6);
                        line += s + " "; n_record++;
                    }
                    //now update the Exam Entry record...
                    s  = "UPDATE tbl_Exams_Entries SET EntryFileID ='" + ef1.m_EntryFileId.ToString() + "' ";
                    s += " , DateEntered =CONVERT(DATETIME, '" + ef1.m_DateCreated.ToString("yyyy-MM-dd HH:mm:ss") + "', 102)  ";
                    s += " , EntryStatus = '4' ";
                    s += " WHERE (ExamEntryID = '" + ex1.m_ExamEntryID.ToString() + "' )";
                    en.ExecuteSQL(s);
                }
            }
            while (line.Length < 192)
            {
                line += " ";
            }
            if (n_record >= 0)
            {
                fs.WriteLine(line); n_records++;
            }
            EndFile(type, n_records, date1, fs, 194, ef1);
            return(true);
        }