示例#1
0
 public AdminForm(List<UserFaculty> fl, List<UserStudent> sl, List<Course> cl, UserAdmin adm)
 {
     state = adminstate.dflt;
     InitializeComponent();
     admin = adm;
     FacultyList = fl;
     StudentList = sl;
     Courses = cl;
     hidethings();
 }
示例#2
0
 public AdminForm(List<UserFaculty> fl, List<UserStudent> sl, List<Course> cl, UserAdmin adm)
 {
     state = adminstate.asadmin;
     InitializeComponent();
     admin = adm;
     FacultyList = fl;
     StudentList = sl;
     Courses = cl;
     initdgv();
 }
示例#3
0
 public AdminForm(List<UserFaculty> fl, List<UserStudent> sl, List<Course> cl, UserAdmin adm, UserStudent std)
 {
     InitializeComponent();
     state = adminstate.asstudent;
     asthisstudent = std;
     button1.Text = "Add " + asthisstudent.UserName + " to Course.";
     logoutBtn.Text = "Logout as " + asthisstudent.UserName;
     admin = adm;
     FacultyList = fl;
     StudentList = sl;
     Courses = cl;
     initdgv();
 }
示例#4
0
 public static void AddStudenttoCourse(UserStudent S, Course C, UserAdmin Me)
 {
     C.AddStudent(S, Me);
 }
示例#5
0
        static void Main()
        {
            StreamReader filereader;

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //UserAdmin u1 = new UserAdmin();
            //UserFaculty u2 = new UserFaculty();
            //UserStudent u3 = new UserStudent();

            List <UserAdmin> ads = new List <UserAdmin>();
            //ads.Add(u1);
            List <UserFaculty> fcs = new List <UserFaculty>();
            //fcs.Add(u2);
            List <UserStudent> std = new List <UserStudent>();
            //std.Add(u3);
            List <String>     timeblocks = new List <string>();
            List <Course>     Courses    = new List <Course>();
            List <PastCourse> past       = new List <PastCourse>();

            //crs.Add(new Course());

            try
            {
                filereader = new StreamReader("UserInput.txt");
                string line = "Yes";
                string username;
                string password;
                string firstn;
                string middlen;
                string lastn;
                string status;

                while (line != null)
                {
                    line = filereader.ReadLine();
                    if (line != null)
                    {
                        username = line.Substring(0, 10).Trim();
                        password = line.Substring(10, 10).Trim();
                        firstn   = line.Substring(20, 15).Trim();
                        middlen  = line.Substring(35, 15).Trim();
                        lastn    = line.Substring(50, 15).Trim();
                        status   = line.Substring(65).Trim();

                        if (status.Contains("admin"))
                        {
                            UserAdmin A = new UserAdmin(username, password, firstn, middlen, lastn);
                            ads.Add(A);
                        }
                        else if (status.Contains("faculty"))
                        {
                            UserFaculty F = new UserFaculty(username, password, firstn, middlen, lastn);
                            fcs.Add(F);
                        }
                        else
                        {
                            UserStudent S = new UserStudent(username, password, firstn, middlen, lastn, status);
                            std.Add(S);
                        }
                    }
                    else
                    {
                        filereader.Close();
                        //button1.Visible = false;
                        //MessageBox.Show("File");
                    }
                }
            }
            catch (EndOfStreamException)
            { }



            //try
            //{
            //    StreamReader freader;
            //    freader = new StreamReader("ClassInput.txt");
            //    string line = "Yes";
            //    string cName;
            //    string itle;
            //    string cInst;
            //    string cSeat;
            //    string cCred;
            //    string cNumTimes;
            //    line = freader.ReadLine();

            //    while (line != null)
            //    {
            //        if (line != null)
            //        {
            //            cName = line.Substring(0, 11).Trim();
            //            itle = line.Substring(11, 16).Trim();
            //            cInst = line.Substring(27, 11).Trim();
            //            cCred = line.Substring(38, 5).Trim();
            //            cSeat = line.Substring(43, 4).Trim();
            //            cNumTimes = line.Substring(47, 2).Trim();
            //            string timeline = line.Substring(49).Trim();
            //            int numTimes = Convert.ToInt16(cNumTimes);

            //            for (int i = 0; i < numTimes; i++)
            //            {
            //                int begin = (0 + (i * 5));
            //                timeblocks.Add(timeline.Substring(begin, 5));
            //            }

            //            Course myCourse = new Course(cName, itle, cInst,
            //                Convert.ToDouble(cCred), Convert.ToInt16(cSeat), timeblocks);
            //            Courses.Add(myCourse);

            //            //MessageBox.Show("There are " + Courses.Count + " Courses.");

            //        }

            //        line = freader.ReadLine();
            //    }
            //    freader.Close();
            //    MessageBox.Show("File is now complete.");

            //}
            //catch
            //{
            //    MessageBox.Show("There was an Error");
            //}

            //Application.Run(new Form4(ads, std,fcs));
            Application.Run(new CourseParseForm(Courses, ads, fcs, std));
            //Application.Run(new Sloppyform(ads, std, fcs));
            //Application.Run(new LoginForm(ads,fcs,std,crs));
        }
        public CourseParseForm(List<Course> C, List<UserAdmin> ad, List<UserFaculty> fac, List<UserStudent> std)
        {
            InitializeComponent();
            Courses = C;
            A = ad;
            F = fac;
            S = std;
            UserAdmin a = new UserAdmin("Automated","*****","B","P","B");
            try
            {
                filereader = new StreamReader("ClassInput.txt");

                line = filereader.ReadLine();
                while (line != null)
                {
                    List<String> timeblocks = new List<string>();
                    cName.Text = line.Substring(0, 11).Trim();
                    cTitle.Text = line.Substring(11, 16).Trim();
                    cInst.Text = line.Substring(27, 11).Trim();
                    cCred.Text = line.Substring(38, 5).Trim();
                    cSeat.Text = line.Substring(43, 4).Trim();
                    cNumTimes.Text = line.Substring(47, 2).Trim();
                    string timeline = line.Substring(49).Trim();
                    int numTimes = Convert.ToInt16(cNumTimes.Text);

                    for (int i = 0; i < numTimes; i++)
                    {
                        int begin = (0 + (i * 6)); //changed
                                        // Needed to add one for the space
                        timeblocks.Add(timeline.Substring(begin, 5));
                        //MessageBox.Show(cName.Text + " " + timeblocks[i]);
                    }

                    Course myCourse = new Course(cName.Text, cTitle.Text, cInst.Text,
                        Convert.ToDouble(cCred.Text), Convert.ToInt16(cSeat.Text), timeblocks);
                    Courses.Add(myCourse);

                    //MessageBox.Show("There are " + Courses.Count + " Courses.");

                    line = filereader.ReadLine();
                }
                filereader.Close();
                //MessageBox.Show("File is now complete.");

            }
            catch
            {
                //MessageBox.Show("There was an Error");
            }

            try
            {
                filereader = new StreamReader("HistoryInput.txt");
                line = filereader.ReadLine();
                int times;
                string name;
                string title;
                string term;
                double credit;
                string grade;

                while (line != null)
                {
                    bool studentfound = false;
                    name = line.Substring(0, 11).Trim();

                    UserStudent stud = new UserStudent();
                    foreach(UserStudent st in S)
                    {
                        if (name == st.UserName)
                        {
                            stud = st;
                            studentfound = true;
                            break;
                        }
                    }
                    if (!studentfound)
                    {
                        line = filereader.ReadLine();
                        continue;
                    }

                    times = int.Parse(line.Substring(11, 2).Trim());
                    int x = 13;
                    for (int i = 0; i < times; i++)
                    {
                        title = line.Substring(x, 11).Trim();
                        x += 11;
                        term = line.Substring(x, 4).Trim();
                        x += 4;
                        credit = double.Parse(line.Substring(x, 5));
                        x += 5;
                        grade = line.Substring(x, 4).Trim();
                        x += 4;

               //                     <user-name:10>S<num-courses:2>S
               // <course-name-1:10>S<term-1:3>S<course-credit-1:4>S<grade-1:3>…
               //S<course-name-N:10>S<term-N:3>S<course-credit-N:4>S<grade-N:3>

                        if (term == "S13")
                        {
                            foreach (Course Cn in Courses)
                            {
                                if (Cn.CourseName == title)
                                {
                                    benutil.AddStudenttoCourse(stud, Cn, a);
                                }
                            }

                        }
                        else
                        {
                            PastCourse pst = new PastCourse(term, title, grade, credit);
                            stud.MyPastCourses.Add(pst);
                        }
                    }
                    line = filereader.ReadLine();
                }
                //MessageBox.Show("Complete");
            }
            catch (EndOfStreamException)
            { }

            try
            {

            }
            catch (EndOfStreamException)
            { }

            LoginForm lgn = new LoginForm(A, F, S, C);
            if (lgn.ShowDialog() == DialogResult.OK)
            {
                Application.Run(new LoginForm(A, F, S, C));

            }
                this.Close();
        }
示例#7
0
 /// <summary>
 /// This is a superpowered administrator function. 
 /// Use with caution. 
 /// </summary>
 /// <param name="newCourseName"></param>
 /// <param name="newCourseTitle"></param>
 /// <param name="newInstructor"></param>
 /// <param name="newCredits"></param>
 /// <param name="newTimeBlocks"></param>
 /// <param name="Admin">The responsible administrator.</param>
 public void AdministerCourse(String newCourseName, String newCourseTitle, 
     String newInstructor, Double newCredits, //List<String> newTimeBlocks, 
     UserAdmin Admin)
 {
     coursename = newCourseName;
     CourseTitle = newCourseTitle;
     Instructor = newInstructor;
     credits = newCredits;
     //List<String> timeblocks = newTimeBlocks;
     //makeMeetings(timeblocks);
     Time = showMeetings();
 }
示例#8
0
 public bool AddStudent(UserStudent S, UserAdmin A)
 {
     if (!studentNames.Contains(S.UserName))
         studentNames.Add(S.UserName);
     if (!S.MyCourses.Contains(coursename))
         S.MyCourses.Add(coursename);
     return true;
 }
示例#9
0
 public static void AddStudenttoCourse(UserStudent S, Course C, UserAdmin Me)
 {
     C.AddStudent(S, Me);
 }
示例#10
0
        static void Main()
        {
            StreamReader filereader;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            //UserAdmin u1 = new UserAdmin();
            //UserFaculty u2 = new UserFaculty();
            //UserStudent u3 = new UserStudent();

            List<UserAdmin> ads = new List<UserAdmin>();
            //ads.Add(u1);
            List<UserFaculty> fcs = new List<UserFaculty>();
            //fcs.Add(u2);
            List<UserStudent> std = new List<UserStudent>();
            //std.Add(u3);
            List<String> timeblocks = new List<string>();
            List<Course> Courses = new List<Course>();
            List<PastCourse> past = new List<PastCourse>();

            //crs.Add(new Course());

            try
            {
                filereader = new StreamReader("UserInput.txt");
                string line = "Yes";
                string username;
                string password;
                string firstn;
                string middlen;
                string lastn;
                string status;

                while (line != null)
                {
                    line = filereader.ReadLine();
                    if (line != null)
                    {
                        username = line.Substring(0, 10).Trim();
                        password = line.Substring(10, 10).Trim();
                        firstn = line.Substring(20, 15).Trim();
                        middlen = line.Substring(35, 15).Trim();
                        lastn = line.Substring(50, 15).Trim();
                        status = line.Substring(65).Trim();

                        if (status.Contains("admin"))
                        {
                            UserAdmin A = new UserAdmin(username, password, firstn, middlen, lastn);
                            ads.Add(A);
                        }
                        else if (status.Contains("faculty"))
                        {
                            UserFaculty F = new UserFaculty(username, password, firstn, middlen, lastn);
                            fcs.Add(F);
                        }
                        else
                        {
                            UserStudent S = new UserStudent(username, password, firstn, middlen, lastn, status);
                            std.Add(S);
                        }
                    }
                    else
                    {
                        filereader.Close();
                        //button1.Visible = false;
                        //MessageBox.Show("File");
                    }

                }
            }
            catch (EndOfStreamException)
            { }

            //try
            //{
            //    StreamReader freader;
            //    freader = new StreamReader("ClassInput.txt");
            //    string line = "Yes";
            //    string cName;
            //    string itle;
            //    string cInst;
            //    string cSeat;
            //    string cCred;
            //    string cNumTimes;
            //    line = freader.ReadLine();

            //    while (line != null)
            //    {
            //        if (line != null)
            //        {
            //            cName = line.Substring(0, 11).Trim();
            //            itle = line.Substring(11, 16).Trim();
            //            cInst = line.Substring(27, 11).Trim();
            //            cCred = line.Substring(38, 5).Trim();
            //            cSeat = line.Substring(43, 4).Trim();
            //            cNumTimes = line.Substring(47, 2).Trim();
            //            string timeline = line.Substring(49).Trim();
            //            int numTimes = Convert.ToInt16(cNumTimes);

            //            for (int i = 0; i < numTimes; i++)
            //            {
            //                int begin = (0 + (i * 5));
            //                timeblocks.Add(timeline.Substring(begin, 5));
            //            }

            //            Course myCourse = new Course(cName, itle, cInst,
            //                Convert.ToDouble(cCred), Convert.ToInt16(cSeat), timeblocks);
            //            Courses.Add(myCourse);

            //            //MessageBox.Show("There are " + Courses.Count + " Courses.");

            //        }

            //        line = freader.ReadLine();
            //    }
            //    freader.Close();
            //    MessageBox.Show("File is now complete.");

            //}
            //catch
            //{
            //    MessageBox.Show("There was an Error");
            //}

            //Application.Run(new Form4(ads, std,fcs));
            Application.Run(new CourseParseForm(Courses, ads, fcs, std));
            //Application.Run(new Sloppyform(ads, std, fcs));
            //Application.Run(new LoginForm(ads,fcs,std,crs));
        }
示例#11
0
 public AdminForm(List <UserFaculty> fl, List <UserStudent> sl, List <Course> cl, UserAdmin adm, UserStudent std)
 {
     InitializeComponent();
     state          = adminstate.asstudent;
     asthisstudent  = std;
     button1.Text   = "Add " + asthisstudent.UserName + " to Course.";
     logoutBtn.Text = "Logout as " + asthisstudent.UserName;
     admin          = adm;
     FacultyList    = fl;
     StudentList    = sl;
     Courses        = cl;
     initdgv();
 }
示例#12
0
 public AdminForm(List <UserFaculty> fl, List <UserStudent> sl, List <Course> cl, UserAdmin adm)
 {
     state = adminstate.asadmin;
     InitializeComponent();
     admin       = adm;
     FacultyList = fl;
     StudentList = sl;
     Courses     = cl;
     initdgv();
 }