protected void AddSupervision(DateTime t_start, DateTime t_end, ScheduledComponent sc) { ScheduledComponent sched1 = new ScheduledComponent(); TimeSpan tgap = new TimeSpan(); tgap = t_end - t_start; if ((tgap.TotalMinutes >= 10) && (tgap.TotalDays < 2)) { ExamConversions u = new ExamConversions(); ExamComponent ec1 = new ExamComponent(); ec1.m_ComponentCode = "Super"; ec1.m_ComponentTitle = "Supervision"; ec1.m_ComponentTitle += "-" + sc.GetHashCode().ToString(); ec1.m_ExamBoardID = new Guid("436ff234-0457-430a-b1e2-b08758ff30ef"); ec1.m_year = Year.ToString().Substring(2, 2); ec1.m_season = u.GetSeasonCode(SeasonCode); ec1.m_Teachermarks = "0"; ec1.m_MaximumMark = "0"; ec1.m_Timetabled = "T"; ec1.m_TimetableDate = t_start; ec1.m_TimetableSession = "A"; ec1.m_Time = tgap.TotalMinutes.ToString(); //now if the brat has extra time we need to reduce...>!!!! StudentSENList ssen1 = new StudentSENList(sc.m_StudentId.ToString()); double extra_time = 0; double time1 = tgap.TotalMinutes; //now if the brat has extra time we need to reduce.. becasue it will be increased by code when read... foreach (StudentSEN sen1 in ssen1.m_List) { if (sen1.m_ExamsExtraTime > 0) { extra_time = (double)sen1.m_ExamsExtraTime; } } time1 = time1 / ((100 + extra_time) / 100); int i = (int)time1; ec1.m_Time = i.ToString(); ec1.Create(); ec1.m_ComponentID = ec1.Find_ComponentID(ec1.m_ComponentCode, ec1.m_ComponentTitle, ec1.m_ExamBoardID.ToString(), ec1.m_season, ec1.m_year); if (ec1.m_ComponentID != Guid.Empty) { sched1.Load(ec1.m_ComponentID, sc.m_StudentId); if (!sched1.m_valid) { sched1.m_StudentId = sc.m_StudentId; sched1.m_ComponentId = ec1.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 = t_start; sched1.m_Desk = ""; sched1.m_Will_Type = false;// do these later... sched1.Save(); } } } }
private string GetFilename() { ExamConversions c = new ExamConversions(); string s_filename = ""; string s = YearCode.ToString(); s_filename = c.GetSeasonCode(SeasonCode) + "a" + s + "_99"; return(s_filename); }
protected string GetQueryString(string Year, int SeasonCode) { ExamConversions u = new ExamConversions(); string s = " SELECT DISTINCT dbo.tbl_Exams_ScheduledComponents.DateTime "; //s += ", dbo.tbl_Exams_Options.OptionCode, "; //s += " dbo.tbl_Exams_Components.ComponentTitle "; s += " FROM dbo.tbl_Exams_ScheduledComponents INNER JOIN "; s += " dbo.tbl_Exams_Components ON dbo.tbl_Exams_ScheduledComponents.ComponentId = dbo.tbl_Exams_Components.ComponentID INNER JOIN "; s += " dbo.tbl_Exams_Link ON dbo.tbl_Exams_Components.ComponentID = dbo.tbl_Exams_Link.ComponentID INNER JOIN "; s += " dbo.tbl_Exams_Options ON dbo.tbl_Exams_Link.OptionID = dbo.tbl_Exams_Options.OptionID "; s += " WHERE(dbo.tbl_Exams_ScheduledComponents.Year = '" + Year + "') "; s += " AND(dbo.tbl_Exams_ScheduledComponents.Season = '" + u.GetSeasonCode(SeasonCode) + "') "; s += " ORDER BY dbo.tbl_Exams_ScheduledComponents.DateTime"; return(s); }
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); } }
protected void Button_Process_Click(object sender, EventArgs e) { string s = TextBox1.Text; TextFileType ftype1 = TextFileType.Unknown; try { ftype1 = (TextFileType)ViewState["TextFileType"]; } catch { Label_Text.Text = "File Type not recognised"; return; } if (ftype1 == TextFileType.Unknown) { Label_Text.Text = "Board Not Set!!!"; return; } char[] ct1 = new char[1]; ct1[0] = (char)0x09; string[] fields = new string[20]; ExamsUtility u = new ExamsUtility(); PupilGroupList pgl = new PupilGroupList(); ExamConversions Ec = new ExamConversions(); SimplePupil pupil1 = new SimplePupil(); Guid g1 = new Guid(); g1 = Guid.Empty; Exam_Board eb1 = new Exam_Board(); SimplePupil p1 = new SimplePupil(); ExamComponent ec1 = new ExamComponent(); ExamOption exo1 = new ExamOption(); ExamComponentResultList ecrl1 = new ExamComponentResultList(); string component_code = ""; int adno1 = 0; string Option_Code = ""; string ScaledMark = ""; string ComponentUMS = ""; string ComponentStatus = ""; string TQM_value = ""; int n_Year = (int)ViewState["n_Year"]; int n_Season = (int)ViewState["n_Season"]; int n_OptionCode = (int)ViewState["n_OptionCode"]; int n_TQM = (int)ViewState["n_TQM"]; int n_ComponentCode = (int)ViewState["n_ComponentCode"]; int n_ComponentUMS = (int)ViewState["n_ComponentUMS"]; int n_ScaledMark = (int)ViewState["n_ScaledMark"]; int n_Status = (int)ViewState["n_Status"]; int n_CandNo = (int)ViewState["n_CandNo"]; int number_entered = 0; //get exam board.... switch (ftype1) { case TextFileType.Unknown: return; case TextFileType.AQA_GCE: eb1 = new Exam_Board("70"); break; case TextFileType.OCR_GCE: eb1 = new Exam_Board("01"); break; case TextFileType.EDEXCEL_GCE: eb1 = new Exam_Board("11"); break; case TextFileType.AQA_GCSE: eb1 = new Exam_Board("70"); break; case TextFileType.OCR_GCSE: break; case TextFileType.EDEXCEL_GCSE: eb1 = new Exam_Board("10"); break; case TextFileType.CIE: eb1 = new Exam_Board("02"); break; case TextFileType.WJEC_GCSE: eb1 = new Exam_Board("40"); break; case TextFileType.WJEC_GCE: eb1 = new Exam_Board("41"); break; default: break; } using (StringReader sr = new StringReader(s)) { string firstline = sr.ReadLine(); string line; while ((line = sr.ReadLine()) != null) { fields = line.Split(ct1); adno1 = 0; component_code = ""; Option_Code = ""; ScaledMark = ""; ComponentUMS = ""; ComponentStatus = ""; adno1 = Convert.ToInt32(fields[n_CandNo]); if (Year.ToString() != fields[n_Year]) { Label_Text.Text = "Year code mismatch in file, line" + number_entered.ToString(); return; } if (SeasonCode.ToString() != fields[n_Season].Substring(0, 1)) { Label_Text.Text = "Series code mismatch in file, line" + number_entered.ToString(); return; } component_code = fields[n_ComponentCode]; Option_Code = fields[n_OptionCode]; ScaledMark = fields[n_ScaledMark]; ComponentUMS = fields[n_ComponentUMS]; ComponentStatus = fields[n_Status]; TQM_value = fields[n_TQM]; ExamComponentResult r = new ExamComponentResult(); try { p1.Load_StudentIdOnly(adno1); ec1.Load(component_code, SeasonCode.ToString(), YearCode.ToString()); exo1.Load(Option_Code, SeasonCode.ToString(), YearCode.ToString(), eb1.m_ExamBoardId); r.OptionId = exo1.m_OptionID; r.ComponentId = ec1.m_ComponentID; r.StudentId = p1.m_StudentId; try { r.ComponentScaledMark = System.Convert.ToInt32(ScaledMark); } catch { //assume it is non integer.... double d = Convert.ToDouble(ScaledMark); r.ComponentScaledMark = Convert.ToInt32(d); } try { r.ComponentUMS = System.Convert.ToInt32(ComponentUMS); } catch { } r.ComponentStatus = ComponentStatus; switch (ecrl1.Load_OptionStudent(r.OptionId, r.StudentId, r.ComponentId)) { case 0: //so can write in r.Save(); break; case 1: //so update r.ComponentResultId = ecrl1.m_list[0].ComponentResultId; r.Save(); break; case 2: //so problem break; default: break; } //now find the result.... ResultsList rl1 = new ResultsList(); rl1.m_parameters = 0; rl1.m_where = "WHERE (dbo.tbl_Core_Students.StudentId='" + r.StudentId.ToString() + "')AND(dbo.tbl_Core_Results.ExamsOptionId='" + r.OptionId.ToString() + "') "; rl1.LoadList("", ""); Result r1 = new Result(); r1 = (Result)rl1._results[0]; r1.Text = "TQM=" + TQM_value; r1.UpdateResultTextOnly(); number_entered++; } catch (Exception ex) { Label_Text.Text = ex.ToString(); } } } Label_Text.Text = "Correctly processed... " + number_entered.ToString() + " entries"; }
protected void Button_CheckTime_Click(object sender, EventArgs e) { string s = TextBox1.Text; string ErrorMsg = ""; TextFileType ftype1 = TextFileType.Unknown; try { ftype1 = (TextFileType)ViewState["TextFileType"]; } catch { Label_Text.Text = "File Type not recognised"; return; } char[] ct1 = new char[1]; ct1[0] = (char)0x09; string[] fields = new string[20]; ExamsUtility u = new ExamsUtility(); PupilGroupList pgl = new PupilGroupList(); ExamConversions Ec = new ExamConversions(); SimplePupil pupil1 = new SimplePupil(); Guid g1 = new Guid(); g1 = Guid.Empty; DateTime t1 = new DateTime(); t1 = DateTime.Now; using (StringReader sr = new StringReader(s)) { string firstline = sr.ReadLine(); string line = sr.ReadLine(); fields = line.Split(ct1); Exam_Board exbde1 = Ec.GetExamBoard(fields[1]); switch (ftype1) { case TextFileType.Unknown: Label_Text.Text = "File Type not recognised"; break; case TextFileType.Students: //Admission Number,Surname, GivenName,Board,Syllabus,Option..."; try { pupil1.Load_StudentIdOnly(System.Convert.ToInt32(fields[0])); ///loads lft students aswell if (!u.AddEntry(pupil1.m_StudentId, exbde1, Year, YearCode, SeasonCode, fields[3], 3, true, ref ErrorMsg, ref g1)) { Label_Text.Text = ErrorMsg; return; } else { Exam_Entry en1 = new Exam_Entry(); en1.m_ExamEntryID = g1; en1.Delete(); } } catch (Exception ex) { Label_Text.Text = ex.ToString(); return; } break; case TextFileType.Sets: pgl.m_pupilllist.Clear(); pgl.AddToList(fields[0], DateTime.Now); foreach (SimplePupil p in pgl.m_pupilllist) { try { if (!u.AddEntry(p.m_StudentId, exbde1, Year, YearCode, SeasonCode, fields[3], 3, true, ref ErrorMsg, ref g1)) { Label_Text.Text = ErrorMsg; return; } else { Exam_Entry en1 = new Exam_Entry(); en1.m_ExamEntryID = g1; en1.Delete(); } } catch (Exception ex) { Label_Text.Text = ex.ToString(); return; } } break; default: break; } //done one set or one student...scale up.... TimeSpan ts1 = DateTime.Now - t1; TimeSpan ts2 = new TimeSpan(); ts2 = ts1; while ((line = sr.ReadLine()) != null) { ts2 += ts1; } TextBox_Warning.Text = "WARNING: This operation is likely to take about " + ts2.ToString() + Environment.NewLine + "Press Process Button to continue..."; TextBox_Warning.Visible = true; Button_CheckTime.Visible = false; Button_Process.Visible = true; } }
protected void Button_Process_Click(object sender, EventArgs e) { string s = TextBox1.Text; string ErrorMsg = ""; TextFileType ftype1 = TextFileType.Unknown; try { ftype1 = (TextFileType)ViewState["TextFileType"]; } catch { Label_Text.Text = "File Type not recognised"; return; } char[] ct1 = new char[1]; ct1[0] = (char)0x09; string[] fields = new string[20]; ExamsUtility u = new ExamsUtility(); PupilGroupList pgl = new PupilGroupList(); ExamConversions Ec = new ExamConversions(); SimplePupil pupil1 = new SimplePupil(); Guid g1 = new Guid(); g1 = Guid.Empty; int number_entered = 0; using (StringReader sr = new StringReader(s)) { string firstline = sr.ReadLine(); string line; while ((line = sr.ReadLine()) != null) { fields = line.Split(ct1); switch (ftype1) { case TextFileType.Unknown: Label_Text.Text = "File Type not recognised"; break; case TextFileType.Students: //Admission Number,Surname, GivenName,Board,Syllabus,Option..."; try { Exam_Board exbde1 = Ec.GetExamBoard(fields[3]); pupil1.Load_StudentIdOnly(System.Convert.ToInt32(fields[0])); ///loads lft students aswell if (!u.AddEntry(pupil1.m_StudentId, exbde1, Year, YearCode, SeasonCode, fields[5], 3, true, ref ErrorMsg, ref g1)) { Label_Text.Text = ErrorMsg; return; } else { number_entered++; } } catch (Exception ex) { Label_Text.Text = ex.ToString(); return; } break; case TextFileType.Sets: //Set, Board, Syllabus, Option. pgl.m_pupilllist.Clear(); pgl.AddToList(fields[0], DateTime.Now); foreach (SimplePupil p in pgl.m_pupilllist) { try { Exam_Board exbde1 = Ec.GetExamBoard(fields[1]); if (!u.AddEntry(p.m_StudentId, exbde1, Year, YearCode, SeasonCode, fields[3], 3, true, ref ErrorMsg, ref g1)) { Label_Text.Text = ErrorMsg; return; } else { number_entered++; } } catch (Exception ex) { Label_Text.Text = ex.ToString(); return; } } break; default: break; } } } Label_Text.Text = "Correctly processed... " + number_entered.ToString() + " entries"; }