public static void RemoveStudentfromCourse(UserStudent S, Course C) { MessageBox.Show("Removing " + S.UserName + " from " + C.CourseName + " ."); C.RemoveStudent(S); S.MyCourses.Remove(C.CourseName); MessageBox.Show("You are no longer registered for " + C.CourseName + " ."); }
public Form3(List <UserStudent> S, UserStudent s, UserFaculty F, List <Course> C, int number) { Me = F; Stud = S; Crs = C; state = number; little = s; if (state == 3) { //dataGridView1.Hide(); foreach (Course C0 in Crs) { if (little.MyCourses.Contains(C0.CourseName)) { stdCourses.Add(C0); } } dataGridView1.DataSource = stdCourses; //dataGridView1.Refresh(); //dataGridView1.Show(); } }
public void RemoveStudent(UserStudent S) { if (studentNames.Contains(S.UserName)) { studentNames.Remove(S.UserName); } }
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); }
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(); }
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(); }
public static void AddStudenttoCourse(UserStudent S, Course C) { if (C.AddStudent(S)) { S.MyCourses.Add(C.CourseName); MessageBox.Show("You've successfully registered for " + C.CourseName + " ."); } else { if (C.Students >= C.Seats) MessageBox.Show("Class is Full!"); if (S.MyCourses.Contains(C.CourseName)) MessageBox.Show("You've Already Registered for this Course!"); } }
public Form3(List<UserStudent> S, UserStudent s, UserFaculty F, List<Course> C, int i) { Me = F; Stud = S; Crs = C; little = s; if (i == 0) FormState = FacFormState.studentsched; if (i == 1) FormState = FacFormState.studentcurrent; InitializeComponent(); RareButton.Hide(); //dataGridView1.Hide(); if (FormState == FacFormState.studentsched) { foreach (Course C0 in Crs) if (little.MyCourses.Contains(C0.CourseName)) stdCourses.Add(C0); Sbutton.Text = "Show Conflicts."; AButton.Text = "Back"; dataGridView1.DataSource = stdCourses; if (!little.hasConflicts) Sbutton.Hide(); } if (FormState == FacFormState.studentcurrent) { Sbutton.Hide(); List<PastCourse> relevant = new List<PastCourse>(); foreach (PastCourse P in little.MyPastCourses) { if (P.Term == "F12") { relevant.Add(P); } } dataGridView1.DataSource = relevant; } //dataGridView1.Refresh(); //dataGridView1.Show(); }
public Form2(List <Course> C, UserStudent S1, int number) { InitializeComponent(); Courses = C; StudentUser = S1; state = number; if (state == 0) { Text = "Course List"; CourseViewer(); } if (state == 1) { Text = "Schedule"; RegisterButton.Text = "Un-Register from Selected Course"; LogoutButton.Text = "Return to Course List"; ScheduleButton.Text = "View Course History"; SchedViewer(); } if (state == 2) { Text = "Course History"; HistViewer(); LogoutButton.Text = "Return to Schedule"; ScheduleButton.Hide(); if (StudentUser.GPA().ToString().Length > 4) { GPAtxtbox.Text = StudentUser.GPA().ToString().Substring(0, 4); } else { GPAtxtbox.Text = StudentUser.GPA().ToString(); } CreditTxtBox.Text = StudentUser.EarnedCredits().ToString(); GPAtxtbox.Show(); CreditTxtBox.Show(); label1.Show(); Credits.Show(); RegisterButton.Hide(); } }
public bool AddStudent(UserStudent S) { if (Students > Seats) { return(false); } if (studentNames.Contains(S.UserName)) { return(false); } if (S.MyCourses.Contains(CourseName)) { return(false); } studentNames.Add(S.UserName); return(true); }
public Form2(List<Course> C, UserStudent S1, int number) { InitializeComponent(); Courses = C; StudentUser = S1; state = number; CButton.Hide(); if (state == 0) { Text = "Course List"; CourseViewer(); } if (state == 1) { Text = "Schedule"; RegisterButton.Text = "Un-Register from Selected Course"; LogoutButton.Text = "Return to Course List"; ScheduleButton.Text = "View Course History"; CButton.Show(); SchedViewer(); } if (state == 2) { Text = "Course History"; HistViewer(); LogoutButton.Text = "Return to Schedule"; ScheduleButton.Hide(); if (StudentUser.GPA().ToString().Length > 4) GPAtxtbox.Text = StudentUser.GPA().ToString().Substring(0, 4); else GPAtxtbox.Text = StudentUser.GPA().ToString(); CreditTxtBox.Text = StudentUser.EarnedCredits().ToString(); GPAtxtbox.Show(); CreditTxtBox.Show(); label1.Show(); Credits.Show(); RegisterButton.Hide(); } }
public static void AddStudenttoCourse(UserStudent S, Course C) { if (C.AddStudent(S)) { S.MyCourses.Add(C.CourseName); MessageBox.Show("You've successfully registered for " + C.CourseName + " ."); } else { if (C.Students >= C.Seats) { MessageBox.Show("Class is Full!"); } if (S.MyCourses.Contains(C.CourseName)) { MessageBox.Show("You've Already Registered for this Course!"); } } }
public Form3(List<UserStudent> S, UserStudent s, UserFaculty F, List<Course> C, int number) { Me = F; Stud = S; Crs = C; state = number; little = s; if (state == 3) { //dataGridView1.Hide(); foreach (Course C0 in Crs) if (little.MyCourses.Contains(C0.CourseName)) stdCourses.Add(C0); dataGridView1.DataSource = stdCourses; //dataGridView1.Refresh(); //dataGridView1.Show(); } }
private void button1_Click(object sender, EventArgs e) { switch (state) { case adminstate.dflt: { } break; //Do nothing. case adminstate.student: if (studstate == studentstate.sviewall) { asthisstudent = StudentList[dataGridView1.SelectedRows[0].Index]; //MessageBox.Show("Student : " + asthisstudent.FirstName + " " + asthisstudent.LastName); studstate = studentstate.ssched; this.Text = "View/Change " + asthisstudent.UserName + "'s course schedule."; List<Course> StdCrs = new List<Course>(); foreach (Course C in Courses) { if (asthisstudent.MyCourses.Contains(C.CourseName)) { StdCrs.Add(C); } } dataGridView1.DataSource = StdCrs; AdvisorButton.Hide(); button1.Text = "Student List"; FastRegButton.Text = "View all courses"; FastRegButton.Show(); } else { //state = adminstate.dflt; //AdvisorButton.Show(); //MessageBox.Show("State 2b"); IVS(); } break; case adminstate.faculty: { asthisfaculty = FacultyList[dataGridView1.SelectedRows[0].Index]; List<String> myCrsStringList = asthisfaculty.MyClasses; foreach (Course c in Courses) { if (c.Instructor == asthisfaculty.UserName) { facCourse.Add(c); } } dataGridView2.DataSource = facCourse; dataGridView2.Show(); } break; case adminstate.crs: { newNames = new List<String>(); //This prevents a hilarious error. cadst = courseadminstate.name; thisCourse = Courses[dataGridView1.SelectedRows[0].Index]; DetailBox.Text = "Course Name = " + thisCourse.CourseName + "."; YesButton.Text = "Change?"; NoButton.Text = "Cancel Changes"; TrueNo.Show(); showDetail(); } break; default: //MessageBox.Show("CASE 3"); break; } }
public UserStudent(UserStudent A) { UserName = A.UserName; password = A.password; }
public static void AddStudenttoCourse(UserStudent S, Course C, UserAdmin Me) { C.AddStudent(S, Me); }
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(); }
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; }
public void RemoveStudent(UserStudent S) { if (studentNames.Contains(S.UserName)) studentNames.Remove(S.UserName); }
public bool AddStudent(UserStudent S) { if (Students > Seats) return false; if (studentNames.Contains(S.UserName)) return false; if (S.MyCourses.Contains(CourseName)) return false; studentNames.Add(S.UserName); return true; }
public CourseParseForm(List <Course> C, List <UserAdmin> ad, List <UserFaculty> fac, List <UserStudent> std) { InitializeComponent(); Courses = C; A = ad; F = fac; S = std; try { filereader = new StreamReader("ClassInput.txt"); line = filereader.ReadLine(); while (line != null) { 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 * 5)); timeblocks.Add(timeline.Substring(begin, 5)); } 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> 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(); }
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)); }
private void AdvisorButton_Click(object sender, EventArgs e) { studstate = studentstate.sadvisor; asthisstudent = StudentList[dataGridView1.SelectedRows[0].Index]; this.Text = "View/Change " + asthisstudent.UserName + "'s advisor."; StringBuilder OutString = new StringBuilder(); OutString.Append(asthisstudent.UserName); OutString.Append("'s advisor is "); OutString.Append(asthisstudent.Advisor); OutString.Append(". Change?"); DetailBox.Text = OutString.ToString(); showDetail(); }