protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Process") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = GridView1.Rows[index]; string s = row.Cells[4].Text; Exam_Board eb1 = new Exam_Board(s); s = eb1.m_OrganisationFriendlyName; string series = row.Cells[2].Text; if (ProcessFile(eb1, series, ref s)) { s = "success"; Label_message.Text = "Success! "; } else { Label_message.Text = s; } Encode en = new Encode(); Exam_Entry_CountbyBoardList el1 = new Exam_Entry_CountbyBoardList(); el1.Load(SeasonCode.ToString(), Year.ToString(), "4", false); //ie NOT sent if (el1.m_list.Count > 0) //ie entries to send { SqlDataSource1.SelectCommand = GetSummaryString(); SqlDataSource1.ConnectionString = en.GetDbConnection(); SqlDataSource1.DataBind(); } else { Label_message.Text = "All Entries sent!"; } } }
public ExamOption Find_Option(string code, Exam_Board eb, string season, string year) { //find the entry in db... or search basedata files code = code + " "; if (code.Length > 6) { code = code.Substring(0, 6); } ExamOption exo1 = new ExamOption(); exo1.Load(code, season, year, eb.m_ExamBoardId); if (exo1.m_valid) { return(exo1); } string search = "O" + season + "?" + year + "_" + eb.m_LegacyExamBdId + ".X??"; string[] filelist = System.IO.Directory.GetFiles(path, search); foreach (string s1 in filelist) { int n = s1.ToUpper().IndexOf("O"); n = s1.ToUpper().LastIndexOf("O"); string s = s1.Substring(n); string series = s.Substring(1, 2); exo1 = Find_OptionEntry1(s, code, eb, season, series, year); if (exo1 != null) { return(exo1); } } return(null); }
protected void DropDownList_data_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList_data.SelectedIndex > -1) { string id = DropDownList_ExamBoards.SelectedValue; string s = ""; Exam_Board eb = new Exam_Board(new Guid(id)); ExamFiles ef = new ExamFiles(); foreach (ExamBaseOption ebo in ef.ExamsOptionsFromBaseData(eb, SeasonCode.ToString(), YearCode.ToString())) { if (ebo.m_OptionEntryCode == DropDownList_data.SelectedValue) { s = "Option Code: " + ebo.m_OptionEntryCode + Environment.NewLine; s += "Option Title: " + ebo.m_Title + Environment.NewLine; s += "Qualification/Level: " + ebo.m_Qualification + ebo.m_Level + Environment.NewLine; s += "Cost: " + ebo.m_Fee + Environment.NewLine; s += "SyllabusCode: " + ebo.m_SyllabusCode + Environment.NewLine; s += "Item (C=Cert.): " + ebo.m_Item + Environment.NewLine; s += "QCA Number: " + ebo.m_QCANumber + Environment.NewLine; ExamOption eo1 = new ExamOption(); if (eo1.Load(DropDownList_data.SelectedValue, SeasonCode.ToString(), YearCode.ToString(), eb.m_ExamBoardId)) { s += Environment.NewLine + Environment.NewLine + "Option is known to Cerval"; } else { s += Environment.NewLine + Environment.NewLine + "Option is NOT known to Cerval"; } TextBox1.Text = s; } } } }
protected void Button_Upload_Click(object sender, EventArgs e) { string id = DropDownList_ExamBoards.SelectedValue; Exam_Board eb1 = new Exam_Board(new Guid(id)); string s1 = DropDownList_data.SelectedValue; ExamOption exo1 = new ExamOption(); ExamFiles ef1 = new ExamFiles(); exo1.Load(s1, SeasonCode.ToString(), YearCode.ToString(), eb1.m_LegacyExamBdId); if (!exo1.m_valid) { ExamOption exo2 = ef1.Find_Option(s1, eb1, SeasonCode.ToString(), YearCode.ToString()); if (exo2 != null) { //Label_Result.Text = "Successfully uploaded " + exo.m_OptionCode + " : " + exo.m_OptionTitle + " to Cerval"; //DropDownList1.SelectedIndex = -1; //ListItem l = DropDownList1.SelectedItem; //DropDownList1.Items.Remove(l); } else { //Label_Result.Text = "Failed to upload " + exo.m_OptionCode + " : " + exo.m_OptionTitle + " to Cerval"; } } }
protected bool CheckComponents(Exam_Board eb) { ExamFiles ef = new Cerval_Library.ExamFiles(); List <ExamComponent> BaseComponentList = new List <ExamComponent>(); ExamCompononent_List ecl1 = new ExamCompononent_List(); ecl1.LoadAllComponents_IncNonTimetabled(YearCode.ToString(), SeasonCode.ToString()); BaseComponentList = ef.ExamsComponentsFromBaseData(eb, SeasonCode.ToString(), YearCode.ToString()); foreach (ExamComponent c in ecl1.m_list) { foreach (ExamComponent c1 in BaseComponentList) { if (c.m_ComponentCode == c1.m_ComponentCode) { c.m_Teachermarks = c1.m_Teachermarks; c.m_Due_Date = c1.m_Due_Date; c.m_ExamBoardID = c1.m_ExamBoardID; c.m_MaximumMark = c1.m_MaximumMark; c.m_Teachermarks = c1.m_Teachermarks; c.m_ComponentTitle = c1.m_ComponentTitle; c.m_Timetabled = c1.m_Timetabled; c.m_TimetableSession = c1.m_TimetableSession; c.m_Time = c1.m_Time; c.m_TimetableDate = c1.m_TimetableDate; c.Save(); } } } return(true);; }
private void SetUpForReatkes() { List <ExamOption> list1 = new List <ExamOption>(); int no_new = 0; int no_found = 0; string Errors = "The following Options seem not to be offered this summer: "; ExamOption_List exoL1 = new ExamOption_List(); ExamFiles ef1 = new ExamFiles(); ExamOption exo1 = new ExamOption(); //load results for last JUNE sitting now. exoL1.Load((YearCode - 1).ToString(), SeasonCode.ToString()); foreach (ExamOption exo in exoL1.m_list) { Exam_Board eb1 = new Exam_Board(exo.m_ExamBoardID); exo1.Load(exo.m_OptionCode, SeasonCode.ToString(), YearCode.ToString(), eb1.m_LegacyExamBdId); if (exo1.m_valid) { no_found++; } else { if (!exo.NeedsTeacherMarks()) { ExamOption exo2 = ef1.Find_Option(exo.m_OptionCode, eb1, SeasonCode.ToString(), YearCode.ToString()); if (exo2 != null) { no_new++; } else { Errors += exo.m_OptionCode + ", "; } } else { list1.Add(exo); //list has those needing teacher marks } } } Label_Result.Text = "We made " + no_new.ToString() + " new options and found already " + no_found.ToString(); Label_Error.Text = Errors; //now need to offer those with coursework... if (list1.Count > 0) { DropDownList1.Visible = true; Button_Upload.Visible = true; foreach (ExamOption e in list1) { ListItem l = new ListItem(e.m_OptionCode + e.m_OptionTitle, e.m_OptionID.ToString()); DropDownList1.Items.Add(l); } LabelDropDown.Text = "The list below are options that require Teacher marks... select and add any you want students to see."; } }
protected void Button_Upload_Click(object sender, EventArgs e) { foreach (GridViewRow r in GridView1.Rows) { if (r.BackColor == System.Drawing.Color.Red) { string ErrorMsg = ""; Label_Error.Text = ""; 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); Exam_Board exbde1 = new Exam_Board(exo1.m_ExamBoardID); Guid g2 = new Guid(); g2 = Guid.Empty; ExamsUtility u = new ExamsUtility(); try { if (u.AddEntry(new Guid(StudentID), exbde1, Year, YearCode, SeasonCode, r.Cells[2].Text, 1, true, ref ErrorMsg, ref g2)) { //it worked so delete the resit entry exr1.Delete(); Encode en = new Encode(); SqlDataSource1.SelectCommand = GetQueryString(); SqlDataSource1.ConnectionString = en.GetDbConnection(); SqlDataSource1.DataBind(); } else { //it didn't Label_Error.Text = ErrorMsg; break; } } catch (Exception ex) { Label_Error.Text = ex.ToString(); break; } } } int cost = 0; foreach (GridViewRow r in GridView1.Rows) { if (r.BackColor == System.Drawing.Color.Red) { cost += System.Convert.ToInt32(r.Cells[5].Text); } } double costd = (double)cost / 100; Label_cost.Text = " Total cost of selected = £" + costd.ToString(); }
public Exam_Board GetExamBoard(string board) { string exam_bde = ""; int i = -1; try { i = System.Convert.ToInt32(board); exam_bde = board; } catch { } if (i < 0) { switch (board.ToUpper()) { case "OCR": exam_bde = "01"; break; case "CIE": exam_bde = "02"; break; case "EDEXCEL GCSE": exam_bde = "10"; break; case "EDEXCEL GCE": exam_bde = "11"; break; case "Edexcel BTEC": exam_bde = "15"; break; case "WJEC GCSE": exam_bde = "40"; break; case "WJEC GCE": exam_bde = "41"; break; case "CCEA": exam_bde = "61"; break; case "AQA": exam_bde = "70"; break; case "STEP": exam_bde = "98"; break; case "DCGS": exam_bde = "99"; break; default: break; } } Exam_Board exbde1 = new Exam_Board(exam_bde); if (exbde1.m_valid) { return(exbde1); } return(null); }
private ExamOption Find_OptionEntry1(string f, string code, Exam_Board eb, string season, string series, string year) { ExamOption exo1 = new ExamOption(); if (exo1.Load(code, season, year, eb.m_ExamBoardId)) { return(exo1); } Stream myStream; string s = ""; string s1 = ""; string s2 = ""; string s_file = "S" + f.Substring(1, f.Length - 1); string line; string Qualification; int JCQ_Version = 0; if ((myStream = File.Open(path + f, FileMode.Open)) != null) { using (StreamReader sr = new StreamReader(myStream)) { //ExamFiles exfiles1 = new ExamFiles(); while ((line = sr.ReadLine()) != null) { s = line.Substring(0, 2); Qualification = line.Substring(14, 4); s1 = line.Substring(2, 6); if (code.Length > 6) { code = code.Substring(0, 6); } s2 = line.Substring(8, 6);//syllabus code.. if (s == "O1") { JCQ_Version = Convert.ToInt32(line.Substring(24, 2)); } if ((s1.Trim().ToUpper() == code.Trim().ToUpper()) && (s == "O5")) { Load_Option(line, eb, season, series, year, s_file, path, JCQ_Version); if (exo1.Load(s1, season, year, eb.m_ExamBoardId)) { return(exo1); } } } } } return(null);//not found }
protected void DropDownList_ExamBoards_SelectedIndexChanged(object sender, EventArgs e) { if (DropDownList_ExamBoards.SelectedIndex > -1) { string id = DropDownList_ExamBoards.SelectedValue; Exam_Board eb = new Exam_Board(new Guid(id)); ExamFiles ef = new ExamFiles(); DropDownList_data.Items.Clear(); foreach (ExamBaseOption ebo in ef.ExamsOptionsFromBaseData(eb, SeasonCode.ToString(), YearCode.ToString())) { ListItem l = new ListItem(ebo.ToString(), ebo.m_OptionEntryCode); DropDownList_data.Items.Add(l); } } }
protected void Button_Enter_Click(object sender, EventArgs e) { //do the entry.... List <Guid> students = new List <Guid>(); students = (List <Guid>)ViewState["studentlist"]; List <Guid> Options = new List <Guid>(); foreach (ListItem item in ListBox_Options.Items) { if (item.Selected) { Options.Add(new Guid(item.Value)); } } ExamsUtility u = new ExamsUtility(); string Errors = ""; Guid g2 = new Guid(); int n = 0; foreach (Guid g in Options) { ExamOption eo1 = new ExamOption(); eo1.Load(g); Exam_Board eb1 = new Exam_Board(eo1.m_ExamBoardID); foreach (Guid g1 in students) { //try { u.AddEntry(g1, eb1, Year, YearCode, SeasonCode, eo1.m_OptionCode, 2, false, ref Errors, ref g2); n++; //} //catch //{ // n = n; // } } } TextBox2.Text = ""; TextBox2.Visible = false; TextBox1.Text = " Made " + n.ToString() + " Entries"; ButtonTest.Visible = false; Button_Enter.Visible = false; DropDownList_Course.SelectedIndex = -1; foreach (ListItem item in ListBox_Options.Items) { if (item.Selected) { item.Selected = false; } } }
public bool CombinationDisallowed(Exam_Board eb, string option1, string option2, string series, string year) { string search = "D" + series + year + "_" + eb.m_LegacyExamBdId + ".X??"; string[] filelist = System.IO.Directory.GetFiles(path, search); string line = ""; string code1 = ""; string code2 = ""; bool disallowed = false; foreach (string f in filelist) { Stream myStream; if ((myStream = File.Open(f, FileMode.Open)) != null) { using (StreamReader sr = new StreamReader(myStream)) { while ((line = sr.ReadLine()) != null) { if (line.Substring(0, 2) == "D5") { code1 = line.Substring(2, 6); //may have * in it...... if (code1.IndexOf("*") > 0) { code1 = code1.Substring(0, code1.IndexOf("*")); } code2 = line.Substring(8, 6); //may have * in it...... if (code2.IndexOf("*") > 0) { code2 = code2.Substring(0, code2.IndexOf("*")); } if (code1 == option1.Substring(0, code1.Length)) { //first code matches.......... if (code2 == option2.Substring(0, code2.Length)) { disallowed = true; } } } } } } } return(disallowed); }
public void Load_Option(string line, Exam_Board eb, string season, string series, string year, string syl_file, string path, int JCQ_Version) { //to load from line (from basedata file) to make a new option string component_file = "c" + syl_file.Substring(1, syl_file.Length - 1); string link_file = "l" + syl_file.Substring(1, syl_file.Length - 1); ExamBaseOption ebo1 = new ExamBaseOption(); ExamSyllabus syl = new ExamSyllabus(); string s = line.Substring(0, 2); if (s == "O5") { if (!ebo1.Load(line, JCQ_Version)) { return; } syl = Find_SyllabusID(ebo1.m_SyllabusCode, year, season, eb, path + syl_file); // will find or make if (syl == null) { return; } s = "INSERT INTO dbo.tbl_Exams_Options (SyllabusID ,OptionCode , OptionTitle, "; s += "OptionQualification, OptionLevel, OptionItem, OptionProcess, "; s += "QCAClassificationCode, QCAAccreditationNumber, OptionFee, OptionMaximumMark, YearCode, SeasonCode, SeriesIdentifier, Version )"; s += "VALUES ('" + syl.m_SyllabusId.ToString() + "' , '"; s += ebo1.m_OptionEntryCode + "' , '" + ebo1.m_Title + "' , '" + ebo1.m_Qualification + "' , '"; s += ebo1.m_Level + "' , '" + ebo1.m_Item + "' , '" + ebo1.m_Process + "' , '"; s += ebo1.m_QCACode + "' , '" + ebo1.m_QCANumber + "' , '"; if (ebo1.m_FeeValid) { s += ebo1.m_Fee.ToString(); } else { s += "-"; } s += "' , '" + ebo1.m_MaximiumMark + "' ,'"; s += year + "' , '" + season + "' , '" + series + "', '2' ) "; ExecuteSQL(s); Install_Components(ebo1.m_OptionEntryCode, path + link_file, path + component_file, eb, season, year); } }
protected bool CheckOptions(Exam_Board eb) { ExamFiles ef = new Cerval_Library.ExamFiles(); ExamOption_List examOl1 = new ExamOption_List(); examOl1.Load(eb.m_ExamBoardId.ToString(), YearCode.ToString(), SeasonCode.ToString()); System.Collections.ArrayList ExamOptionsList = new System.Collections.ArrayList(); ExamOptionsList = ef.ExamsOptionsFromBaseData(eb, SeasonCode.ToString(), YearCode.ToString()); int m1 = 0; int m2 = 0; foreach (ExamOption examo1 in examOl1.m_list) { foreach (ExamBaseOption eb1 in ExamOptionsList) { if (eb1.m_OptionEntryCode == examo1.m_OptionCode) { m1 = 0; m2 = 0; try { m1 = System.Convert.ToInt32(eb1.m_MaximiumMark); } catch { } try { m2 = System.Convert.ToInt32(examo1.m_OptionMaximumMark); } catch { } try { if (m1 != m2) { examo1.m_OptionMaximumMark = eb1.m_MaximiumMark; examo1.UpdateMaxMark(); } //ought to check we have all the components for this... string component_file = ef.path + "c" + eb1.m_file_path.Substring(1, eb1.m_file_path.Length - 1); string link_file = ef.path + "l" + eb1.m_file_path.Substring(1, eb1.m_file_path.Length - 1); ef.Install_Components(examo1.m_OptionCode, link_file, component_file, eb, SeasonCode.ToString(), YearCode.ToString()); } catch { } } } } return(true); }
public System.Collections.ArrayList ExamsOptionsFromBaseData(Exam_Board eb, string season, string year) { System.Collections.ArrayList temp = new System.Collections.ArrayList(); while (year.Length > 2) { year = year.Substring(1, year.Length - 1); } string search = "O" + season + "?" + year + "_" + eb.m_LegacyExamBdId + ".X??"; string[] filelist = System.IO.Directory.GetFiles(path, search); foreach (string f in filelist) { Stream myStream; string line; int JCQ_Version = 0; if ((myStream = File.Open(f, FileMode.Open)) != null) { using (StreamReader sr = new StreamReader(myStream)) { while ((line = sr.ReadLine()) != null) { if (line.Substring(0, 2) == "O1") { JCQ_Version = System.Convert.ToInt32(line.Substring(24, 2)); } if (line.Substring(0, 2) == "O5") { ExamBaseOption ebo1 = new ExamBaseOption(); if (ebo1.Load(line, JCQ_Version)) { ebo1.m_file_path = f.Substring(path.Length); temp.Add(ebo1); } } } } } } temp.Sort(); return(temp); }
public List <ExamLinkComponent> ExamsLinkComponentsFromBaseData(Exam_Board eb, string season, string year) { List <ExamLinkComponent> temp = new List <ExamLinkComponent>(); while (year.Length > 2) { year = year.Substring(1, year.Length - 1); } string search = "L" + season + "?" + year + "_" + eb.m_LegacyExamBdId + ".X??"; string[] filelist = System.IO.Directory.GetFiles(path, search); foreach (string f in filelist) { Stream myStream; string line; int JCQ_Version = 0; if ((myStream = File.Open(f, FileMode.Open)) != null) { using (StreamReader sr = new StreamReader(myStream)) { while ((line = sr.ReadLine()) != null) { if (line.Substring(0, 2) == "L1") { JCQ_Version = System.Convert.ToInt32(line.Substring(24, 2)); } if (line.Substring(0, 2) == "L5") { ExamLinkComponent eco1 = new ExamLinkComponent(); eco1.LoadFromBaseData(line, JCQ_Version, eb.m_ExamBoardId.ToString()); temp.Add(eco1); } } } } } //temp.Sort(); return(temp); }
public List <ExamSyllabus> ExamSyllabusFromBaseData(Exam_Board eb, string season, string year) { System.Collections.Generic.List <ExamSyllabus> temp = new List <ExamSyllabus>(); while (year.Length > 2) { year = year.Substring(1, year.Length - 1); } string search = "S" + season + "?" + year + "_" + eb.m_LegacyExamBdId + ".X??"; string[] filelist = System.IO.Directory.GetFiles(path, search); foreach (string f in filelist) { Stream myStream; string line; int JCQ_Version = 0; if ((myStream = File.Open(f, FileMode.Open)) != null) { using (StreamReader sr = new StreamReader(myStream)) { while ((line = sr.ReadLine()) != null) { if (line.Substring(0, 2) == "S1") { JCQ_Version = System.Convert.ToInt32(line.Substring(24, 2)); } if (line.Substring(0, 2) == "S5") { ExamSyllabus es1 = new ExamSyllabus(); es1.LoadFromBaseData(line, JCQ_Version); temp.Add(es1); } } } } } temp.Sort(); return(temp); }
protected void Button_PullEntries_Click(object sender, EventArgs e) { ISAMS_SimpleExamEntry_List IEntries = new ISAMS_SimpleExamEntry_List(); int c = 0; c = System.Convert.ToInt32(TextBox_CycleNumber.Text); IEntries.LoadList(c); foreach (ISAMS_SimpleExamEntry Ien in IEntries.m_list) { //need to find Guids for Pupil, OPtion etc... Utility u = new Utility(); Guid SId = new Guid(); SId = u.GetStudentIDfromiSAMS(Ien.m_PupilId); Exam_Board eb1 = new Exam_Board(Ien.m_UABCode); ExamOption eo1 = new ExamOption(); eo1.Load(Ien.m_OptionCode, SeasonCode.ToString(), YearCode.ToString(), Ien.m_UABCode.ToString()); Exam_Entry Ex1 = new Exam_Entry(); Ex1.Load(Ien.m_OptionCode, SeasonCode.ToString(), YearCode.ToString(), eb1.m_ExamBoardId, SId); if (!Ex1.m_valid) { Ex1.m_Date_Created = DateTime.Now; Ex1.m_OptionID = eo1.m_OptionID; Ex1.m_season = SeasonCode.ToString(); Ex1.m_StudentID = SId; Ex1.m_withdrawn = false; Ex1.m_year = Year.ToString(); Ex1.m_EntryStatus = 7; Ex1.Save(); } else { bool f = Ex1.m_valid; } } }
private StreamWriter OpenFile(Exam_Board exb1, char type, ref Exam_File ef1, int Record_Length, string series, string centre_number, string jcqVersion) { //open file and write header records... int sequence_no = ef1.FindSequencNumber(exb1.m_ExamBoardId.ToString()) + 1; string s = type + centre_number + exb1.m_LegacyExamBdId + ".X"; string s1 = sequence_no.ToString(); s1 = "000" + s1; s1 = s1.Substring(s1.Length - 2, 2); string filename = s + s1; string path = Server.MapPath("ExamFiles"); StreamWriter fs = new StreamWriter(path + "//" + filename); s = type + "1" + centre_number + exb1.m_LegacyExamBdId.Trim() + series + Year.ToString().Substring(2, 2); s += "S" + centre_number + " 103" + jcqVersion.ToString(); while (s.Length < Record_Length - 2) { s += " "; } fs.WriteLine(s); s = type + "3" + centre_number + exb1.m_LegacyExamBdId + series + Year.ToString().Substring(2, 2); s1 = sequence_no.ToString(); s1 = "000" + s1; s1 = s1.Substring(s1.Length - 3, 3); s += s1; s += "HP65HA "; while (s.Length < Record_Length - 2) { s += " "; } fs.WriteLine(s); ef1.m_DateCreated = DateTime.Now; ef1.m_Fileame = filename; ef1.m_SequenceNo = sequence_no; ef1.m_ExamBoardID = exb1.m_ExamBoardId; ef1.Save(); return(fs); }
/* * 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; }
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"; }
protected void Button_PullBaseData_Click(object sender, EventArgs e) { // so first we are going to get a list of all options used... int c = 0; c = System.Convert.ToInt32(TextBox_CycleNumber.Text); ISAMS_OptionsUsed_List list1 = new ISAMS_OptionsUsed_List(); list1.LoadList(c); string s = ""; foreach (ISAMS_OptionUsed o in list1.m_list) { s += o.m_OptionCode; //need the Cerval ExamBde Guid Exam_Board CExamBoard = new Exam_Board(o.m_UABCode); // so load option / link /components ISAMS_ExamOption Opt = new ISAMS_ExamOption(); Opt.Load(c, o.m_OptionCode, o.m_UABCode); s += " : " + Opt.m_OptionTitle; ISAMS_ExamSyllabus Syl = new ISAMS_ExamSyllabus(); Syl.Load(Opt.m_cycle, Opt.m_ExamBoardCode, Opt.m_Syllabus_Code); ISAMS_ExamLink_List Link = new ISAMS_ExamLink_List(); Link.LoadList_Option(Opt.m_OptionCode, Opt.m_ExamBoardCode, Opt.m_cycle); //so try to find the Ceral Syllabus ExamSyllabus CSyllabus = new ExamSyllabus(); CSyllabus.Load(Syl.m_SyllabusCode, SeasonCode.ToString(), YearCode.ToString(), CExamBoard.m_ExamBoardId); if (!CSyllabus.m_valid) { CSyllabus.m_ExamBoardId = CExamBoard.m_ExamBoardId; CSyllabus.m_Syllabus_Code = Syl.m_SyllabusCode; CSyllabus.m_Syllabus_Title = Syl.m_SyllabusTitle; CSyllabus.m_SyllabusId = CSyllabus.CreateNew("22"); } //now try to find the option ExamOption COption = new ExamOption(); COption.Load(Opt.m_OptionCode, SeasonCode.ToString(), YearCode.ToString(), Opt.m_ExamBoardCode); if (COption.m_valid) { //option found... } else { //option not found need to create... COption.m_SyllabusID = CSyllabus.m_SyllabusId; COption.m_OptionCode = Opt.m_OptionCode; COption.m_OptionTitle = Opt.m_OptionTitle; COption.m_OptionQualification = Opt.m_OptionQualification; COption.m_OptionLevel = Opt.m_OptionLevel; COption.m_Item = Opt.m_Item; COption.m_Process = Opt.m_Process; COption.m_QCACode = Opt.m_QCACode; COption.m_QCANumber = Opt.m_QCANumber; COption.m_fee = Opt.m_fee; COption.m_OptionMaximumMark = Opt.m_OptionMaximumMark; COption.m_year_Code = YearCode.ToString(); COption.m_Season_code = SeasonCode.ToString(); COption.m_SeriesIdentifier = Opt.m_SeriesIdentifier; COption.m_OptionID = COption.CreateNew("22"); } foreach (ISAMS_ExamLink el1 in Link.m_list) { ISAMS_ExamComponent ec1 = new ISAMS_ExamComponent(); ec1.Load(el1.m_ComponentCode, Opt.m_cycle, Opt.m_ExamBoardCode); s += " & " + ec1.m_ComponentTitle; //so should be able to insert into Cerval //OK so now the components... ExamComponent CComp = new ExamComponent(); CComp.Load(ec1.m_ComponentCode, SeasonCode.ToString(), YearCode.ToString()); if (!CComp.m_valid) { //so need to create CComp.m_ComponentCode = ec1.m_ComponentCode; CComp.m_ComponentTitle = ec1.m_ComponentTitle; CComp.m_ExamBoardID = CExamBoard.m_ExamBoardId; CComp.m_year = YearCode.ToString(); CComp.m_season = SeasonCode.ToString(); CComp.m_Teachermarks = ec1.m_Teachermarks; CComp.m_MaximumMark = ec1.m_MaximumMark; CComp.m_Due_Date = ec1.m_Due_Date; CComp.m_Timetabled = ec1.m_Timetabled; CComp.m_TimetableSession = ec1.m_TimetableSession; CComp.m_Time = ec1.m_TimeAllowed; DateTime t1 = new DateTime(); t1 = System.Convert.ToDateTime(ec1.m_TimetableDate); CComp.m_TimetableDate = t1; CComp.m_ComponentID = CComp.CreateNew(); } ExamLinkComponent_List l2 = new ExamLinkComponent_List(); l2.LoadList_OptionComponent(COption.m_OptionID, CComp.m_ComponentID); if (l2.m_list.Count == 0) { //need to make the link ExamLinkComponent Clink = new ExamLinkComponent(); Clink.m_OptionId = COption.m_OptionID; Clink.m_ComponentId = CComp.m_ComponentID; Clink.CreateNew("22"); } } s += Environment.NewLine; } TextBox_test.Text = s; }
protected void Button1_Click(object sender, EventArgs e) { //file has Board short name/optioncode/grade/mark if (!FileUpload1.HasFile) { return; } Cerval_Library.TextReader TxtRd1 = new Cerval_Library.TextReader(); TextRecord t = new TextRecord(); int l = 0; int n = 0; string s1 = ""; char ct = (char)0x09; int n_Board = 0; int n_OptionCode = 0; int n_Grade = 0; int n_Mark = 0; bool f_Board = false; bool f_OptionCode = false; bool f_Grade = false; bool f_Mark = false; while (TxtRd1.ReadTextLine(FileUpload1.FileContent, ref t) == Cerval_Library.TextReader.READ_LINE_STATUS.VALID) { l = s1.Length; for (int i = 0; i <= t.number_fields; i++) { s1 += t.field[i] + ct; } if (s1.Length > l) { s1 += Environment.NewLine; } if (n == 0) { //going to look for our columns: for (int i = 0; i <= t.number_fields; i++) { switch (t.field[i]) { case "Board": n_Board = i; f_Board = true; break; case "Option": n_OptionCode = i; f_OptionCode = true; break; case "Mark": n_Mark = i; f_Mark = true; break; case "Grade": n_Grade = i; f_Grade = true; break; default: break; } } // so do we have all the required columns?? if (!(f_Board && f_OptionCode && f_Grade && f_Mark)) { Label_Text.Text = "Can't recognise the format of this file. "; if (!f_Board) { Label_Text.Text += "No Board Column"; } if (!f_OptionCode) { Label_Text.Text += "No Option Column"; } if (!f_Mark) { Label_Text.Text += "No Mark Column"; } if (!f_Grade) { Label_Text.Text += "No Grade Column"; } return; } else { Label_Text.Text = "File Format Fine: "; } } } //so process the file... string s2 = ""; char[] ct1 = new char[1]; ct1[0] = (char)0x09; string[] fields = new string[20]; using (StringReader sr = new StringReader(s1)) { string firstline = sr.ReadLine(); string line; while ((line = sr.ReadLine()) != null) { fields = line.Split(ct1); bool found = false; Exam_Board eb1 = new Exam_Board(); eb1.Load(fields[n_Board]); ExamOption eo1 = new ExamOption(); if (eo1.Load(fields[n_OptionCode], SeasonCode.ToString(), YearCode.ToString(), eb1.m_ExamBoardId)) { //valid option cod ExamTQMBoundaryList l1 = new ExamTQMBoundaryList(); l1.LoadList(eo1.m_OptionID, YearCode.ToString(), SeasonCode.ToString()); foreach (ExamTQMBoundary b in l1.m_list) { if (b.Grade == fields[n_Grade]) { b.Mark = Convert.ToInt32(fields[n_Mark]); b.Save(); found = true; s2 += eb1.m_OrganisationFriendlyName + ct + eo1.m_OptionCode + ct + eo1.m_OptionTitle + ct + b.Grade + ct + b.Mark + ct + "Updated" + System.Environment.NewLine; } } if (!found) { ExamTQMBoundary etqm1 = new ExamTQMBoundary(); etqm1.OptionId = eo1.m_OptionID; etqm1.Mark = Convert.ToInt32(fields[n_Mark]); etqm1.Grade = fields[n_Grade]; etqm1.OptionCode = eo1.m_OptionCode; etqm1.OptionTitle = eo1.m_OptionTitle; etqm1.Season = SeasonCode.ToString(); etqm1.Year = YearCode.ToString(); etqm1.Version = 22; etqm1.Save(); s2 += eb1.m_OrganisationFriendlyName + ct + eo1.m_OptionCode + ct + eo1.m_OptionTitle + ct + etqm1.Grade + ct + etqm1.Mark + ct + "New Entry" + System.Environment.NewLine; } } } Label_Text.Text = " Completed... saved as below:"; TextBox1.Text = s2; } }
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"; }
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); }
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); }
private ExamSyllabus Find_SyllabusID(string syllabus_code, string year, string season, Exam_Board eb, string s_file) { bool found = false; string s; Stream myStream; ExamSyllabus syl = new ExamSyllabus(); //syl.Load(syllabus_code, season, year, eb.m_ExamBoardId); //going to ignore the season and year for these records...???? syl.Load(syllabus_code, season, year, eb.m_ExamBoardId);//find any with this code & board.. ignore season and year if (syl.m_valid) { return(syl); } //not in cerval... need to make it... string line = ""; try { if ((myStream = File.Open(s_file, FileMode.Open)) != null) { using (StreamReader sr = new StreamReader(myStream)) { while (((line = sr.ReadLine()) != null) && (!found)) { syl.LoadFromBaseData(line, 11); if (syl.m_Syllabus_Code == syllabus_code) { s = "INSERT INTO dbo.tbl_Exams_Syllabus "; s += "(ExamBoardID, SyllabusCode, SyllabusTitle ,Version)"; s += "VALUES ( '" + eb.m_ExamBoardId.ToString() + "' , '"; s += syl.m_Syllabus_Code + "' , '" + syl.m_Syllabus_Title + "' ,'1' )"; ExecuteSQL(s); found = true; //scary - call ourselves to get Guid with no sifle to stop infinite recursion!!!! return(Find_SyllabusID(syllabus_code, year, season, eb, "")); } }//end of while more lines } } } catch (Exception e1) { System.Windows.Forms.MessageBox.Show("Error writing the syllabus file... " + e1.Message, "File Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation); } //not found!! //MessageBox.Show("Error finding the syllabus id.. ", "File Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(null); }
public void Install_Components(string OptionCode, string l_file, string c_file, Exam_Board ExamBoard, string season, string year) { string s, line; Stream myStream; string LinkOption = ""; string LinkComponent = ""; ExamOption opt1 = new ExamOption(); Guid opt1ID = new Guid(); Guid com1ID = new Guid(); opt1.Load(OptionCode, season, year, ExamBoard.m_ExamBoardId); opt1ID = opt1.m_OptionID; //TODO ADD EXCEPTION HANDLING... IF LINE <12 if ((myStream = File.Open(l_file, FileMode.Open)) != null) { using (StreamReader sr = new StreamReader(myStream)) { while ((line = sr.ReadLine()) != null) { s = line.Substring(0, 2); LinkOption = line.Substring(2, 6); if ((s == "L5") && (LinkOption == OptionCode)) { LinkComponent = line.Substring(8, 12); com1ID = Find_Component(c_file, LinkComponent, ExamBoard.m_ExamBoardId.ToString(), season, year, true);//forceupdate = true means it will search basedata to check OK //now check the link file ExamLinkComponent_List elcl1 = new ExamLinkComponent_List(); elcl1.LoadList_Option(opt1.m_OptionID); bool found = false; foreach (ExamLinkComponent ec1 in elcl1.m_list) { if (ec1.m_ComponentId == com1ID) { found = true; } } if (!found) { s = " INSERT INTO dbo.tbl_Exams_Link ( OptionID, ComponentID ) "; s += " VALUES ('" + opt1ID.ToString() + "' , '" + com1ID.ToString() + "' )"; if ((opt1.m_valid) && (com1ID != Guid.Empty)) { ExecuteSQL(s); } } } } } } return; }