protected void Button_test3_Click(object sender, EventArgs e)
        {
            //remake 9year or whatever
            string YearGroup = TextBox_YearGroup.Text;
            string GroupName = YearGroup + "Year";

            int year = DateTime.Now.Year; int month = DateTime.Now.Month;

            if (month > 8)
            {
                year++;           //so
            }
            DateTime EndDate   = new DateTime(year, 7, 31);
            DateTime StartDate = new DateTime(year - 1, 9, 4);

            GroupList gl1 = new GroupList();
            Utility   u   = new Utility();
            Group     g2  = new Group(); g2.Load(GroupName, DateTime.Now);

            if (!g2._valid)
            {
                g2._GroupCode = GroupName; g2._StartDate = StartDate; g2._EndDate = EndDate; g2._GroupName = GroupName;
                g2._CourseID  = new Guid("f0e6828f-c6e1-4105-988c-83e350a39cc4"); g2._GroupRegistrationType = 3; g2._GroupRegistrationYear = System.Convert.ToInt32(YearGroup);
                g2._GroupPrimaryAdministrative = false; g2._GroupManagedBy = Guid.Empty;
                g2.Save();
            }
            gl1.LoadList(DateTime.Now, GroupList.GroupListOrder.GroupName);
            foreach (Group g in gl1._groups)
            {
                if (g._GroupCode.ToUpper().Trim() == GroupName.ToUpper())
                {
                    //going to delete all gm here
                    StudentGroupMembershipList sgml0 = new StudentGroupMembershipList();
                    sgml0.LoadList_Group(g._GroupID, DateTime.Now);
                    foreach (StudentGroupMembership sg in sgml0.m_list)
                    {
                        sg.Delete();
                    }

                    foreach (Group g1 in gl1._groups)
                    {
                        if (g1._GroupCode.Contains("RG") && (g1._GroupCode.StartsWith(YearGroup)))
                        {
                            StudentGroupMembershipList sgml1 = new StudentGroupMembershipList();
                            sgml1.LoadList_Group(g1._GroupID, DateTime.Now);
                            foreach (StudentGroupMembership sg in sgml1.m_list)
                            {
                                StudentGroupMembership sm1 = new StudentGroupMembership();
                                sm1.m_Groupid   = g._GroupID;
                                sm1.m_Studentid = sg.m_Studentid;
                                sm1.m_ValidFrom = StartDate;
                                sm1.m_ValidTo   = EndDate;
                                sm1.Save();
                            }
                        }
                    }
                    break;
                }
            }
        }
Exemple #2
0
        private void ProcessMakeGroup(string p1)
        {
            string[] parameters = new string[20];
            string[] splitchar  = new string[2];
            string[] students   = new string[200];
            //parameters are students%GroupName
            splitchar[0] = "%";
            int no_students = 0;

            parameters   = p1.Split(splitchar, StringSplitOptions.RemoveEmptyEntries);
            splitchar[0] = ":";
            splitchar[1] = ",";
            students     = parameters[0].Split(splitchar, StringSplitOptions.RemoveEmptyEntries);
            //so we have a list....how many?
            no_students = students.Length; students[0] = "";
            //get current group members
            StudentGroupMembershipList sgl1 = new StudentGroupMembershipList();
            Guid g = new Guid(GroupIDS);

            sgl1.LoadList_Group(g, DateTime.Now);
            //now if not in list delete sgm or if in list delete from list;
            bool found = false;

            foreach (StudentGroupMembership sg in sgl1.m_list)
            {
                found = false;
                for (int i = 0; i < no_students; i++)
                {
                    if (sg.m_Studentid.ToString() == students[i])
                    {
                        found = true; students[i] = "";
                    }
                }
                if (!found)
                {
                    sg.Delete();
                }
            }
            //now make new ones....
            int y = DateTime.Now.Year;

            if (DateTime.Now.Month > 7)
            {
                y++;
            }
            string id = "";

            for (int i = 0; i < no_students; i++)
            {
                if (students[i] != "")
                {
                    id = students[i];
                    StudentGroupMembership sg = new StudentGroupMembership();
                    sg.m_Groupid   = new Guid(GroupIDS);
                    sg.m_Studentid = new Guid(students[i]);
                    sg.m_ValidTo   = new DateTime(y, 7, 31);
                    sg.m_ValidFrom = DateTime.Now.AddDays(-1);
                    sg.Save();
                    //remove duplicates....
                    for (int j = 0; j < no_students; j++)
                    {
                        if (students[j] == id)
                        {
                            students[j] = "";
                        }
                    }
                }
            }
        }
Exemple #3
0
        protected void Button_Save_Click(object sender, EventArgs e)
        {
            //get current group members
            StudentGroupMembershipList sgl1 = new StudentGroupMembershipList();
            string GroupIDS = (string)ViewState["group"];
            Guid   g        = new Guid(GroupIDS);

            sgl1.LoadList_Group(g, DateTime.Now);
            //now if not in list delete sgm or if in list delete from list;
            bool found = false;

            foreach (StudentGroupMembership sg in sgl1.m_list)
            {
                found = false;
                foreach (ListItem l in ListBox_SelectedNames.Items)
                {
                    if (sg.m_Studentid.ToString() == l.Value)
                    {
                        found = true;
                        ListBox_SelectedNames.Items.Remove(l); break;
                    }
                }
                if (!found)
                {
                    sg.Delete();
                }
            }
            //now make new ones....
            int y = DateTime.Now.Year;

            if (DateTime.Now.Month > 7)
            {
                y++;
            }



            foreach (ListItem l in ListBox_SelectedNames.Items)
            {
                if (l.Value != "")
                {
                    StudentGroupMembership sg = new StudentGroupMembership();
                    sg.m_Groupid   = new Guid(GroupIDS);
                    sg.m_Studentid = new Guid(l.Value);
                    sg.m_ValidTo   = new DateTime(y, 7, 31);
                    sg.m_ValidFrom = DateTime.Now.AddDays(-1);
                    sg.Save();
                    //remove duplicates....
                    for (int i = 0; i < ListBox_SelectedNames.Items.Count; i++)
                    {
                        if (l.Value == ListBox_SelectedNames.Items[i].Value)
                        {
                            ListBox_SelectedNames.Items[i].Value = "";
                        }
                    }
                }
            }
            ListBox_Names.Items.Clear();
            SetUpYearList(DropDownList_Years.SelectedValue);
            ListBox_SelectedNames.Items.Clear();
            SetUpGroupNames(GroupIDS);
        }
Exemple #4
0
        protected void Button_synClick(object sender, EventArgs e)
        {
            //sync iSAMSGroups
            //first going to mark all current student_group memberships as version 10
            //then will be able to end all those not found in iSAMS
            //ResetAllStudentGroupVersion(10); //reset all current sgms to ver 10
            DateTime EndDate = new DateTime();

            EndDate = System.Convert.ToDateTime(TextBox_EndDate.Text);
            int            year = System.Convert.ToInt32(TextBox_Year.Text);
            Utility        u = new Utility();
            string         errors = ""; bool found = false;
            ISAMS_Set_List Isetl1 = new ISAMS_Set_List();

            foreach (ISAMS_Set Is in Isetl1.m_list)
            {
                //for each set...
                if (Is.Year == year)
                {
                    ISAMS_Student_List         Isl1  = new ISAMS_Student_List(Is.Id);
                    StudentGroupMembershipList sgml1 = new StudentGroupMembershipList();
                    Group g1 = new Group();
                    g1.Load(Is.SetCode, DateTime.Now);
                    if (!g1._valid)
                    {
                        //ought to try to make the group
                        errors += "Group not found in Cerval" + Is.SetCode + Environment.NewLine;
                    }
                    else
                    {
                        sgml1.LoadList_Group(g1._GroupID, DateTime.Now);
                        foreach (ISAMS_Student iSS1 in Isl1.m_list)
                        {
                            found = false;
                            foreach (StudentGroupMembership sgm1 in sgml1.m_list)
                            {
                                string iSAMSPupilId = u.GetStudentIsamsID("StudentId", sgm1.m_Studentid.ToString());
                                if (iSAMSPupilId == "")
                                {
                                    errors += "Student not found " + sgm1.m_Studentid.ToString() + Environment.NewLine;
                                }
                                if (iSS1.ISAMS_SchoolId == iSAMSPupilId)
                                {
                                    found = true;
                                    sgm1.ResetVersion(3);// it is OK
                                    break;
                                }
                            }
                            if (!found)
                            {
                                //need to add to sgml
                                StudentGroupMembership sgm2 = new StudentGroupMembership();
                                //need to find ID for this student for the iSAMSId
                                Guid g2 = u.GetStudentIDfromiSAMS(iSS1.ISAMS_SchoolId);
                                if (g2 == Guid.Empty)
                                {
                                    errors += " Student not found in Cerval for iSAMSID " + iSS1.ISAMS_SchoolId + Environment.NewLine;
                                }
                                else
                                {
                                    sgm2.m_ValidFrom = DateTime.Now.AddHours(-10);
                                    sgm2.m_ValidTo   = EndDate;
                                    sgm2.m_Studentid = g2;
                                    sgm2.m_Groupid   = g1._GroupID;
                                    //version=4
                                    sgm2.Save();
                                }
                            }
                            errors += "Cmpleted set " + Is.SetCode + "  at   " + DateTime.Now.ToLongTimeString() + Environment.NewLine;
                        }
                        //so that iSAMS set is done....
                    }
                    errors += "Cmpleted set " + Is.SetCode + "  at   " + DateTime.Now.ToLongTimeString() + Environment.NewLine;
                }
            }
            //done iSAMS sets...
            // so those at version 10 need closing down......


            TextBox_Out.Text = errors;

            Encode en = new Encode();
            string d  = " CONVERT(DATETIME, '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', 102) ";
            string s  = " UPDATE dbo.tbl_Core_Student_Groups SET MemberUntil = " + d + "  WHERE Version ='10' ";
            //en.ExecuteSQL(s);
        }