コード例 #1
0
ファイル: Exams.cs プロジェクト: dcgs-cc/StaffIntranet3
        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;
        }
コード例 #2
0
        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;
        }
コード例 #3
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);
            }
        }