Beispiel #1
0
        private void UpDateGroupsListBox()
        {
            GroupList gr = new GroupList("");

            GroupListBox.Items.Clear();
            PupilPeriodList ppl     = new PupilPeriodList();
            string          struser = Context.User.Identity.Name;
            //struser = @"challoners\cc";
            Utility u = new Utility();
            string  s = "";
            //Guid personID = u.GetPersonID(struser,out s);
            Guid personID = u.GetPersonIdfromRequest(Request);

            s = u.GetsStaffCodefromRequest(Request);
            if (personID != Guid.Empty)
            {
                struser = s;
            }
            //struser = "******";
            Cerval_Configuration c = new Cerval_Configuration("StaffIntranet_Predicted_Grade_Type");

            s = c.Value;
            if (!c.valid)//try revert to config file
            {
                System.Configuration.AppSettingsReader ar = new System.Configuration.AppSettingsReader();
                s = ar.GetValue("Predicted Grade Type", typeof(string)).ToString();
            }

            //if s =SL then do the lockdown mode for SL
            //if s = staff then do sets for staff
            //if s = ""... ignore...
            if (s == "SL")
            {
                this.Label1.Text = "Select Set. Only Subject Leaders can now change values.";
                //this code to list sets of a subject...
                if ((struser.Trim() == "CC") || (struser.Trim() == "DCO"))
                {
                    struser = "";                                                       //allow all sets
                }
                GroupList_SL grsl = new GroupList_SL(struser);
                foreach (Group g in grsl._groups)
                {
                    if ((g._StartDate < DateTime.Now) && (g._EndDate > DateTime.Now) && (g._GroupCode.StartsWith("13")))
                    {
                        ListItem Item = new ListItem(g._GroupCode, g._GroupID.ToString());
                        GroupListBox.Items.Add(Item);
                    }
                }
            }

            if (s == "STAFF")
            {
                this.Label1.Text = "Select Set ";
                //this code lists sets the user is timetabled to teach....
                ppl.LoadList("StaffCode", struser, false, DateTime.Now);
                bool add = false;
                foreach (Group g in gr._groups)
                {
                    add = false;
                    if ((g._StartDate < DateTime.Now) && (g._EndDate > DateTime.Now))
                    {
                        foreach (ScheduledPeriod p in ppl.m_pupilTTlist)
                        {
                            if ((p.m_groupcode == g._GroupCode) && (g._GroupCode.StartsWith("13")))
                            {
                                add = true;
                            }
                        }
                        if (add)
                        {
                            ListItem Item = new ListItem(g._GroupCode, g._GroupID.ToString());
                            GroupListBox.Items.Add(Item);
                        }
                    }
                }
            }

            GroupListBox.SelectedIndex = 0;
        }
Beispiel #2
0
        void GridView1_RowCommand(Object sender, GridViewCommandEventArgs e)
        {
            //calls here for any command - including a sort
            if (e.CommandName == "Edit_Grade")
            {
                Cerval_Configuration c = new Cerval_Configuration("StaffIntranet_Forecast_Grade_Edit");
                string s1 = c.Value;
                if (!c.valid)//try revert to config file
                {
                    System.Configuration.AppSettingsReader ar = new AppSettingsReader();
                    s1 = ar.GetValue("Exam Entries Forecast Grade Edit", s1.GetType()).ToString();
                }
                if (s1 == "none")
                {
                    visibility(4);
                    {
                        ListBox_PredictedGrades.Visible = false;
                        Button_Save_Prediction.Visible  = false;
                        Label_Title_for_Edit.Text       = "Predicted grades can't be edited at present";
                        return;
                    }
                }


                int             row      = Convert.ToInt32(e.CommandArgument);
                GridViewRow     row1     = GridView1.Rows[row];
                string          s        = Server.HtmlDecode(row1.Cells[0].Text);//is id
                Exam_Entry      ex1      = new Exam_Entry(); ex1.Load(s);
                SimplePupil     p1       = new SimplePupil(); p1.Load(ex1.m_StudentID.ToString());
                ExamOption      exo1     = new ExamOption(); exo1.Load(ex1.m_OptionID);
                Utility         u        = new Utility();
                bool            valid    = false;
                PupilPeriodList PPLlist1 = new PupilPeriodList();
                PPLlist1.LoadList("StudentID", ex1.m_StudentID.ToString(), true, DateTime.Now);
                //now I'd like to find the cse... but we dont know these
                CourseList   cselist1 = new CourseList(ex1.m_OptionID);
                GroupList_SL grplist1 = new GroupList_SL(Label_staffCode.Text.Trim());

                foreach (Course c1 in cselist1._courses)
                {
                    foreach (ScheduledPeriod scp in PPLlist1.m_pupilTTlist)
                    {
                        if (scp.m_groupcode.Substring(2, 2).ToUpper().Trim() == c1.CourseCode.ToUpper().Trim())
                        {
                            if (scp.m_staffcode.Trim().ToUpper() == Label_staffCode.Text.Trim().ToUpper())
                            {
                                if (s1 == "staff")
                                {
                                    valid = true;
                                }
                            }
                            foreach (Group g1 in grplist1._groups)
                            {
                                if (g1._GroupCode == scp.m_groupcode)
                                {
                                    valid = true;                                  //is SL
                                }
                            }
                        }
                    }
                }
                if (s1 == "all")
                {
                    valid = true;
                }
                visibility(4);
                if (!valid)
                {
                    ListBox_PredictedGrades.Visible = false;
                    Button_Save_Prediction.Visible  = false;
                    Label_Title_for_Edit.Text       = "Can't edit this grade as you don't teach the student";
                    return;
                }

                Label_Title_for_Edit.Text   = "Predicted Grade for " + p1.m_GivenName + " " + p1.m_Surname + " for " + exo1.m_OptionCode + ": " + exo1.m_OptionTitle;
                Label_EntryID_for_edit.Text = s;
                ListBox_PredictedGrades.Items.Clear();
                if (exo1.m_OptionQualification == "GCE")
                {
                    ListBox_PredictedGrades.Items.Add("A*");
                    ListBox_PredictedGrades.Items.Add("A");
                    ListBox_PredictedGrades.Items.Add("B");
                    ListBox_PredictedGrades.Items.Add("C");
                    ListBox_PredictedGrades.Items.Add("D");
                    ListBox_PredictedGrades.Items.Add("E");
                    ListBox_PredictedGrades.Items.Add("U");
                }
                if (exo1.m_OptionQualification == "GCSE")
                {
                    ListBox_PredictedGrades.Items.Add("A*");
                    ListBox_PredictedGrades.Items.Add("A");
                    ListBox_PredictedGrades.Items.Add("B");
                    ListBox_PredictedGrades.Items.Add("C");
                    ListBox_PredictedGrades.Items.Add("D");
                    ListBox_PredictedGrades.Items.Add("E");
                    ListBox_PredictedGrades.Items.Add("");
                }
                if (ListBox_PredictedGrades.Items.FindByText(Server.HtmlDecode(row1.Cells[7].Text)) != null)
                {
                    ListBox_PredictedGrades.Items.FindByText(Server.HtmlDecode(row1.Cells[7].Text)).Selected = true;
                    Button_Save_Prediction.Visible = true;
                }
                else
                {
                    //ListBox_PredictedGrades.Visible = false;
                    //Button_Save_Prediction.Visible = false;
                    //Label_Title_for_Edit.Text = "Can't edit this grade";
                }
                Button_Save_Prediction.Visible = true;
            }

            if (e.CommandName == "Edit_Button")
            {
                int         row  = Convert.ToInt32(e.CommandArgument);
                GridViewRow row1 = GridView1.Rows[row];
                string      s    = Server.HtmlDecode(row1.Cells[0].Text);//is id
                Exam_Entry  ex1  = new Exam_Entry(); ex1.Load(s);
                ExamsEntries_sql.UpdateCommand = "UPDATE  dbo.tbl_Exams_Entries  SET PredictedGrade = '?' WHERE ExamEntryID ='" + s + "' ";
            }
            if (e.CommandName == "Delete_Button")
            {
                int         row  = Convert.ToInt32(e.CommandArgument);
                GridViewRow row1 = GridView1.Rows[row];
                string      s    = Server.HtmlDecode(row1.Cells[0].Text);
                //do delete...
            }
        }