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();
        }
        protected void UpdateButtons(DateTime t0)
        {
            ExamsUtility u  = new ExamsUtility();
            DateTime     t1 = new DateTime(); t1 = t0.AddHours(8).AddMinutes(39);  //start at 8:40
            DateTime     t2 = new DateTime(); t2 = t0.AddHours(18).AddMinutes(39); //end at 18:39

            Button1.Visible       = false;
            Label_message.Visible = true;
            Label_message.Text    = "There are NO clashes!";
            if (u.AreClashes(t1, t2))
            {
                Label_message.Text = "There are clashes to resolve";
                Button1.Visible    = true;
            }
        }
        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;
                }
            }
        }
예제 #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         GetMasterValues();
         string   dateS = Request.QueryString["Date"];
         DateTime t0    = new DateTime();
         string   sess  = Request.QueryString["Session"];
         bool     Is_AM = true;
         try
         {
             t0 = Convert.ToDateTime(Request.QueryString["Date"]);
             if (sess.Contains("PM"))
             {
                 Is_AM = false;
             }
             ViewState["Session_is_AM"] = Is_AM;
             ViewState["EditDate"]      = t0;
         }
         catch
         {
             //try to get from session state?
             Is_AM = (bool)ViewState["Session_is_AM"];
             t0    = (DateTime)ViewState["EditDate"];
         }
         DateTime t1 = new DateTime();
         DateTime t2 = new DateTime();
         t1 = (Is_AM) ? t0.AddHours(8) : t0.AddHours(13);
         t2 = (Is_AM) ? t0.AddHours(13) : t0.AddHours(18);
         Label_Date.Text = t0.ToLongDateString();
         SetUp(t1, t2, Is_AM);
         ExamsUtility u = new ExamsUtility();
         bool         b = u.AreRoomsMissing(t1, t2);
         if (!b)
         {
             Label_message.Text = "All Rooms are Allocated.. you can run again if you wish";
         }
         Encode en = new Encode();
         SqlDataSource3.SelectCommand    = GetQueryStringRoomSummary(t1, t2, !b);
         SqlDataSource3.ConnectionString = en.GetDbConnection();
         SqlDataSource3.DataBind();
     }
 }
예제 #5
0
        protected void Button_AssignDesks_Click(object sender, EventArgs e)
        {
            string ErrorS = "Success!";

            bool     Is_AM = true;
            DateTime t0    = new DateTime();

            Is_AM = (bool)ViewState["Session_is_AM"];
            t0    = (DateTime)ViewState["EditDate"];
            DateTime t1 = new DateTime();
            DateTime t2 = new DateTime();

            t1 = (Is_AM) ? t0.AddHours(8) : t0.AddHours(13);
            t2 = (Is_AM) ? t0.AddHours(13) : t0.AddHours(18);
            //going to assign desks for this session
            //first clear all desks.....
            ExamsUtility u = new ExamsUtility();

            u.ClearDeskAssignments(t1, t2);

            ScheduledComponentList scl1 = new ScheduledComponentList();

            scl1.LoadList_orderbyRoom(t1, t2);

            Guid room1 = new Guid(); room1 = Guid.Empty;

            foreach (ScheduledComponent sc in scl1.m_List)
            {
                if (sc.m_RoomId != room1)
                {
                    if (!AllocateDesksRoom(sc.m_RoomId, t1, t2, ref ErrorS))
                    {
                        Label_message.Text    = ErrorS;
                        Label_message.Visible = true;
                        return;
                    }
                    room1 = sc.m_RoomId;
                }
            }
            scl1.LoadList(t1, t2);
            UpdateDeskGrid();
        }
예제 #6
0
        protected void SetupSummaryTable()
        {
            DateTime t1 = new DateTime(Year, SeasonCode - 2, 1);//so summer season might start in april???
            DateTime t0 = new DateTime(); t0 = t1;

            //advance to Monday
            while (t0.DayOfWeek != DayOfWeek.Monday)
            {
                t0 = t0.AddDays(1);
            }
            //this is our start date...
            string[] data = new string[300];//should be enough!
            for (int i = 0; i < 120; i++)
            {
                data[i] = "";
            }

            int n = 0; int nmin = 200; int nmax = -1;
            // list for the contents of this row...
            DateTime             t2        = new DateTime();
            TimeSpan             tspan1    = new TimeSpan();
            TimeSpan             tspanWeek = new TimeSpan(0, 1, 0, 0);
            ExamCompononent_List ecl1      = new ExamCompononent_List();

            ecl1.LoadAllComponentsSeason(YearCode.ToString(), SeasonCode.ToString());
            ExamsUtility u                 = new ExamsUtility();

            //ecl1.LoadAllComponents_NotScheduled(Year.ToString(), SeasonCode.ToString());
            foreach (ExamComponent ec in ecl1.m_list)
            {
                t2       = ec.m_TimetableDate; tspan1 = t2 - t0; n = tspan1.Days;
                data[n] += ec.m_ComponentTitle + ":" + ec.m_ComponentCode + ":" + ec.m_ComponentID.ToString() + (char)0x09;
                //component title:option code
                if (n > nmax)
                {
                    nmax = n;
                }
                if (n < nmin)
                {
                    nmin = n;
                }
            }
            List <ComponentNotScheduled> list1 = new List <ComponentNotScheduled>();

            //so want to do whole weeks from t0;
            n = 0; while ((nmin - n) > 7)
            {
                n += 7;
            }
            //so we start the table at n...
            t2 = t0.AddDays(n);
            while (n < nmax)
            {
                TableRow  r1 = new TableRow(); Table_Summary.Rows.Add(r1);
                TableCell c0 = new TableCell(); c0.Text = t2.ToShortDateString(); r1.Cells.Add(c0);
                for (int i = 0; i < 5; i++)
                {
                    //so date is t2
                    list1 = u.LoadComponentsNotSchedlued(Year.ToString(), SeasonCode.ToString(), t2.AddHours(-1), t2.AddHours(22));
                    TableCell c1 = new TableCell();
                    if (list1.Count > 0)
                    {
                        Button b1 = new Button();
                        b1.Text = t2.ToString("M");

                        c1.Controls.Add(b1);
                        b1.Click    += B1_Click;
                        b1.ID        = "Button" + (n + i).ToString();
                        b1.BackColor = System.Drawing.Color.AntiqueWhite;
                    }
                    r1.Cells.Add(c1); t2 = t2.AddDays(1);
                }
                n += 7; t2 = t2.AddDays(2);
            }
        }
예제 #7
0
        protected void Button_Assign_Click(object sender, EventArgs e)
        {
            //now we are actually going to do it???

            string   ErrorS = "Success!";
            bool     Is_AM  = (bool)ViewState["Session_is_AM"];
            DateTime t0     = new DateTime();

            t0 = (DateTime)ViewState["EditDate"];
            DateTime t1 = new DateTime();
            DateTime t2 = new DateTime();

            t1 = (Is_AM) ? t0.AddHours(8) : t0.AddHours(13);
            t2 = (Is_AM) ? t0.AddHours(13) : t0.AddHours(18);
            DateTime time_last = new DateTime();



            List <Guid> Rooms = new List <Guid>();
            ListBox     lb    = ListBox_Rooms;

            foreach (ListItem l in lb.Items)
            {
                if (l.Selected)
                {
                    Rooms.Add(new Guid(l.Value));
                }
            }

            //if no rooms allocated flag error
            if (Rooms.Count == 0)
            {
                ErrorS = "...you haven't allocated Any rooms";
                goto ErrorExit;
            }


            ExamsUtility eu = new ExamsUtility();

            eu.ClearDeskAssignments(t1, t2);

            //ought to clear all room allocations first...
            //ought to do this by query
            int          n = 0;
            ExamsUtility u = new ExamsUtility();

            u.ClearRoomAssignments(t1, t2);

            ExamRoom er = new ExamRoom();

            n = 0;
            List <int> Room_Capacity = new List <int>();

            foreach (Guid d in Rooms)
            {
                er.Load(d);
                Room_Capacity.Add(er.m_capacity);
                n++;
            }
            int nmax = n - 1;

            ScheduledComponentList scl1 = new ScheduledComponentList();

            scl1.LoadList_Date(t1, t2);                              //order by  DateTime
            time_last = ((ScheduledComponent)scl1.m_List[0]).m_Date;
            string s = GetQueryStringDay(t0.Year, t0.Month, t0.Day); // gets from sc ordered by datetime,NUMBER

            List <Guid>     Components    = new List <Guid>();
            List <int>      number        = new List <int>();
            List <DateTime> Start_Time    = new List <DateTime>();
            Encode          en            = new Encode();
            string          db_connection = en.GetDbConnection();

            using (SqlConnection cn = new SqlConnection(db_connection))
            {
                cn.Open();
                using (SqlCommand cm = new SqlCommand(s, cn))
                {
                    using (SqlDataReader dr = cm.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            Components.Add(dr.GetGuid(1));
                            number.Add(dr.GetInt32(4));
                            Start_Time.Add(dr.GetDateTime(3));
                        }
                        dr.Close();
                    }
                }
                cn.Close();
            }

            //first apply rules... hopefully these will fit ... if not flag error back to ui

            int CurrentRoomCapacity = 0;

            string s_rule      = DropDownList_Rule1Source.SelectedItem.Text;
            Guid   rule_roomId = new Guid(DropDownList_Rule1Room.SelectedValue);

            n = 0; foreach (Guid d in Rooms)
            {
                if (d == rule_roomId)
                {
                    CurrentRoomCapacity = Room_Capacity[n]; break;
                }
            }
            if (!Apply_Rule(s_rule, rule_roomId, scl1, ref ErrorS, Components, number, ref CurrentRoomCapacity))
            {
                goto ErrorExit;
            }
            Room_Capacity[n] = CurrentRoomCapacity;
            if ((s_rule != "None") && (CheckBox1.Checked))
            {
                Rooms.Remove(rule_roomId); nmax--;
            }


            s_rule      = DropDownList_Rule2Source.SelectedItem.Text;
            rule_roomId = new Guid(DropDownList_Rule2Room.SelectedValue);
            n           = 0; foreach (Guid d in Rooms)
            {
                if (d == rule_roomId)
                {
                    CurrentRoomCapacity = Room_Capacity[n]; break;
                }
            }
            if (!Apply_Rule(s_rule, rule_roomId, scl1, ref ErrorS, Components, number, ref CurrentRoomCapacity))
            {
                goto ErrorExit;
            }
            if ((s_rule != "None") && (CheckBox2.Checked))
            {
                Rooms.Remove(rule_roomId); nmax--;
            }
            Room_Capacity[n] = CurrentRoomCapacity;


            s_rule      = DropDownList_Rule3Source.SelectedItem.Text;
            rule_roomId = new Guid(DropDownList_Rule3Room.SelectedValue);
            n           = 0; foreach (Guid d in Rooms)
            {
                if (d == rule_roomId)
                {
                    CurrentRoomCapacity = Room_Capacity[n]; break;
                }
            }
            if (!Apply_Rule(s_rule, rule_roomId, scl1, ref ErrorS, Components, number, ref CurrentRoomCapacity))
            {
                goto ErrorExit;
            }
            if ((s_rule != "None") && (CheckBox3.Checked))
            {
                Rooms.Remove(rule_roomId); nmax--;
            }
            Room_Capacity[n] = CurrentRoomCapacity;



            s_rule      = DropDownList_Rule4Source.SelectedItem.Text;
            rule_roomId = new Guid(DropDownList_Rule4Room.SelectedValue);
            n           = 0; foreach (Guid d in Rooms)
            {
                if (d == rule_roomId)
                {
                    CurrentRoomCapacity = Room_Capacity[n]; break;
                }
            }
            if (!Apply_Rule(s_rule, rule_roomId, scl1, ref ErrorS, Components, number, ref CurrentRoomCapacity))
            {
                goto ErrorExit;
            }
            if ((s_rule != "None") && (CheckBox4.Checked))
            {
                Rooms.Remove(rule_roomId); nmax--;
            }
            Room_Capacity[n] = CurrentRoomCapacity;



            s_rule      = DropDownList_Rule5Source.SelectedItem.Text;
            rule_roomId = new Guid(DropDownList_Rule5Room.SelectedValue);
            n           = 0; foreach (Guid d in Rooms)
            {
                if (d == rule_roomId)
                {
                    CurrentRoomCapacity = Room_Capacity[n]; break;
                }
            }
            if (!Apply_Rule(s_rule, rule_roomId, scl1, ref ErrorS, Components, number, ref CurrentRoomCapacity))
            {
                goto ErrorExit;
            }
            if ((s_rule != "None") && (CheckBox5.Checked))
            {
                Rooms.Remove(rule_roomId); nmax--;
            }
            Room_Capacity[n] = CurrentRoomCapacity;


            ScheduledComponentList scl2 = new ScheduledComponentList();

            foreach (ScheduledComponent c in scl1.m_List)
            {
                if (c.m_RoomId == Guid.Empty)
                {
                    scl2.m_List.Add(c);
                }
            }

            //now we apply the rest
            //idea is we find the sc with most students.... and put into biggest room first
            //first correct room capacity?
            n = 0;
            // well i think we have all the information....
            //going to assign biggest exam to biggest room first

            int index = 0;

            foreach (Guid d in Components)
            {
                //so new component....
                //if there is a complete gap before we start this component we can clear room allocations....
                //find the first (earliest) scheduled component
                foreach (ScheduledComponent c in scl2.m_List)
                {
                    if (c.m_ComponentId == d)
                    {
                        if (c.m_RoomId == Guid.Empty)
                        {
                            if (c.m_Date > time_last.AddMinutes(10))
                            {
                                //so this one starts at least 10 minutes after all sofar have finished....
                                time_last = c.m_Date.AddMinutes(c.m_TimeAllowed);
                                //so can reset rooms..... ie back to full capacity?
                                Room_Capacity.Clear(); n = 0;
                                foreach (Guid d1 in Rooms)
                                {
                                    er.Load(d1);
                                    Room_Capacity.Add(er.m_capacity);
                                    n++;
                                }
                                nmax = n - 1;
                            }
                        }
                    }
                }

                n = 0;
                while ((Room_Capacity[n] == 0) && (n <= nmax))
                {
                    n++;
                }
                if (n > nmax)
                {
                    ErrorS = "Ran out of room capacity !!"; goto ErrorExit;
                }
                //going to check if next one will fit in any room we have available... if so use it!  search smallest first?
                for (int i = nmax; i >= 0; i--)
                {
                    if (Room_Capacity[i] >= number[index])
                    {
                        n = i; break;
                    }
                }
                foreach (ScheduledComponent c in scl2.m_List)
                {
                    if (c.m_ComponentId == d)
                    {
                        if (c.m_RoomId == Guid.Empty)
                        {
                            if (c.m_Date.AddMinutes(c.m_TimeAllowed) > time_last)
                            {
                                time_last = c.m_Date.AddMinutes(c.m_TimeAllowed);
                            }

                            //really ought to check to see if he has any other componets in this session and assign the same room/...

                            foreach (ScheduledComponent c1 in scl1.m_List)
                            {
                                if (c1.m_StudentId == c.m_StudentId)
                                {
                                    c.m_RoomId = c1.m_RoomId;
                                }
                            }
                            if (c.m_RoomId == Guid.Empty)
                            {
                                c.m_RoomId = Rooms[n];
                                Room_Capacity[n]--;
                            }

                            c.Save();



                            foreach (ScheduledComponent c1 in scl2.m_List)
                            {
                                if ((c1.m_StudentId == c.m_StudentId) && (c1.m_RoomId == Guid.Empty))
                                {
                                    c.m_RoomId = Rooms[n];
                                    c.Save();
                                    //Room_Capacity[n]--;   should already have cleared clashes
                                }
                            }
                        }
                    }
                    while ((Room_Capacity[n] == 0) && (n < nmax))
                    {
                        n++;
                    }
                    if (n > nmax)
                    {
                        ErrorS = "Ran out of room capacity !!"; goto ErrorExit;
                    }
                }
                index++;
            }
            //check??
            //success;  open the summary panel

            Panel_left1.Visible             = false; Panel_right1.Visible = false;
            Label_message.Text              = "Rooms Allocated Successfully.";
            Label_message.Visible           = true;
            SqlDataSource3.SelectCommand    = GetQueryStringRoomSummary(t1, t2, true);
            SqlDataSource3.ConnectionString = en.GetDbConnection();
            SqlDataSource3.DataBind();
            return;

            ErrorExit : Label_message.Text = ErrorS;
            Label_message.BackColor        = System.Drawing.Color.Red;
            return;
        }
예제 #8
0
        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";
        }
예제 #9
0
        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;
            }
        }
예제 #10
0
        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";
        }