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 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;
                }
            }
        }
예제 #3
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;
            }
        }
예제 #4
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";
        }