Exemple #1
0
        public bool ClearTimetable(string Year, int Seasoncode, ref string ErrorS, ref int number_cleared)
        {
            ExamConversions u  = new ExamConversions();
            Encode          en = new Encode();

            try
            {
                string s = "DELETE  FROM tbl_Exams_ScheduledComponents ";
                s += " WHERE (Year='" + Year + "' ) ";
                s += "  AND (Season ='" + u.GetSeasonCode(Seasoncode) + "' )";
                number_cleared = en.Execute_count_SQL(s);
            }
            catch (Exception e)
            {
                ErrorS = e.ToString(); return(false);
            }
            ErrorS = "finished deleting";
            return(true);
        }
Exemple #2
0
        public bool GetOUtlineTT(string Year, int SeasonCode, ref string ErrorS)
        {
            List <ExamOutlineTTEntry> m_list = new List <ExamOutlineTTEntry>();
            ExamConversions           u      = new ExamConversions();
            Encode en            = new Encode();
            string db_connection = en.GetDbConnection();//let sql do the heavy lifting...
            string s             = " SELECT DISTINCT dbo.tbl_Exams_ScheduledComponents.DateTime, dbo.tbl_Exams_ScheduledComponents.Year, ";

            s += " dbo.tbl_Exams_ScheduledComponents.Season, dbo.tbl_Exams_ScheduledComponents.ComponentId, dbo.tbl_Exams_Options.OptionCode, ";
            s += "dbo.tbl_Exams_Options.OptionTitle, 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";


            using (SqlConnection cn = new SqlConnection(db_connection))
            {
                cn.Open();
                using (SqlCommand cm = new SqlCommand(s, cn))
                {
                    using (SqlDataReader dr = cm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            ExamOutlineTTEntry p1 = new ExamOutlineTTEntry();
                            p1.Hydrate(dr);
                            m_list.Add(p1);
                        }
                        dr.Close();
                    }
                }
                cn.Close();
            }
            return(true);
        }
Exemple #3
0
        public bool UpdateTimetable(string Year, int Seasoncode, ref string ErrorS)
        {
            //true if succeeds
            // add scheduled components for any components not scheduled...
            //TODO also delete any withdrawn....
            ExamConversions      u      = new ExamConversions();
            string               Season = u.GetSeasonString(Seasoncode);
            ExamCompononent_List ecl1   = new ExamCompononent_List();

            ecl1.LoadAllComponents_NotScheduled(Year, Season);
            if (ecl1.m_count == 0)
            {
                ErrorS = "All Entries already scheduled..."; return(true);
            }
            ecl1.LoadAllComponents(Year, Season);

            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;
                }
            }

            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;
                                    sched1.m_Season      = Season;
                                    sched1.m_valid       = true;
                                    sched1.m_Date        = d1;
                                    sched1.m_Desk        = "";
                                    sched1.m_Will_Type   = false;// do these later...
                                    sched1.Save();
                                }
                            }
                            else
                            {
                                sched1.Load(ec.m_ComponentID, ex.m_StudentID);
                                if (sched1.m_valid)
                                {
                                    //need to delete
                                    sched1.Delete();
                                }
                            }
                        }
                    }
                }
            }

            //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='" + Year + "' ) AND (Season ='" + Season + "' )";
                en.ExecuteSQL(s);
            }
            return(true);
        }