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();
                    }
                }
            }
        }
Beispiel #2
0
        public Guid Find_Component(string c_file, string component, string ExamBoard, string season, string year, bool forceupdate)
        {
            ExamComponent com1   = new ExamComponent();
            Guid          com1ID = new Guid(); com1ID = Guid.Empty;
            Stream        myStream;
            string        line        = "";
            int           JCQ_Version = 0;

            //try to find in db
            com1ID = com1.Find_ComponentID(component, ExamBoard, season, year);
            if ((com1ID != Guid.Empty) && !forceupdate)
            {
                return(com1ID);
            }
            //so not in db... find in c_file and make...
            try
            {
                if ((myStream = File.Open(c_file, FileMode.Open)) != null)
                {
                    using (StreamReader sr = new StreamReader(myStream))
                    {
                        ExamComponent examcom1 = new ExamComponent();
                        ExamComponent examcom2 = new ExamComponent();//used for forced update
                        while ((line = sr.ReadLine()) != null)
                        {
                            if (line.Substring(0, 2) == "C1")
                            {
                                JCQ_Version = System.Convert.ToInt32(line.Substring(24, 2));
                            }
                            if ((line.Substring(0, 2) == "C5") && (line.Substring(2, 12) == component))
                            {
                                examcom1.m_ComponentCode = component;
                                examcom1.LoadFromBaseData(line, JCQ_Version, ExamBoard);
                                examcom1.m_season = season; examcom1.m_year = year;
                                if (com1ID != Guid.Empty)
                                {
                                    // we are doing a forced update..... and already know the ID....
                                    examcom2.Load(com1ID);//has current db version.....
                                    //now if any significant changes need to delete current scheduled components...
                                    examcom1.m_ComponentID = com1ID;
                                    if (!examcom1.EqualTo(examcom2))
                                    {
                                        ScheduledComponentList scl1 = new ScheduledComponentList();
                                        scl1.LoadList(com1ID);
                                        foreach (ScheduledComponent sc1 in scl1.m_List)
                                        {
                                            sc1.Delete();
                                        }
                                    }
                                    examcom1.Save();
                                }
                                else
                                {
                                    examcom1.Create();
                                }
                                return(Find_Component("", component, ExamBoard, season, year, false));
                            }
                        }
                    }
                }
            }
            catch (Exception e1)
            {
                System.Windows.Forms.MessageBox.Show("Error writing the component file... " + e1.Message, "File Error", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
            }
            //not found - this could be a poblem
            System.Windows.Forms.MessageBox.Show("Warning.... Can't find a component: " + component, "Warning", System.Windows.Forms.MessageBoxButtons.OK, System.Windows.Forms.MessageBoxIcon.Exclamation);
            return(com1ID);
        }