private void Form2_Load(object sender, EventArgs e) { label1.Parent = pictureBox1; label1.Location = new Point(10, label1.Location.Y); var course_array = from row in RegistrationDatabase.GetCourses() select new { Id = row.Value.GetCourseID(), Name = row.Value.GetCourseName(), Faculty = row.Value.GetFaculty().GetUserName(), Credits = row.Value.GetCourseCredit(), Seats = row.Value.GetNumSeats(), Dates = String.Join(", ", row.Value.GetDayBlocks()), Times = String.Join(", ", row.Value.GetTimeBlocks()) }; var student_array = from row in RegistrationDatabase.GetUserDatabase() where row.Value is Student select new { First = row.Value.GetFirstName(), Last = row.Value.GetLastName(), Username = row.Value.GetUserName(), CurrentAdvisor = row.Value.GetStatus() }; var faculty_array = from row in RegistrationDatabase.GetUserDatabase() where row.Value is Faculty select new { First = row.Value.GetFirstName(), Last = row.Value.GetLastName(), Username = row.Value.GetUserName(), CurrentAdvisor = row.Value.GetStatus() }; dataGridView1.DataSource = course_array.ToArray(); dataGridView2.DataSource = student_array.ToArray(); dataGridView3.DataSource = faculty_array.ToArray(); ComboBox comboBox3 = new ComboBox(); foreach (User user in RegistrationDatabase.GetUserDatabase().Values) { if (user is Student) { comboBox1.Items.Add(user.GetUserName()); } if (user is Faculty) { comboBox3.Items.Add(user.GetUserName()); comboBox2.Items.Add(user.GetUserName()); } } ((DataGridViewComboBoxColumn)dataGridView2.Columns["Advisor"]).DataSource = comboBox3.Items; foreach (DataGridViewRow d_row in dataGridView2.Rows) { d_row.Cells[0].Value = RegistrationDatabase.GetUser((string)d_row.Cells[3].Value).GetStatus(); } }
/// <summary>Accesses database with string userName and string password. </summary> /// <param name="userName">The user's username.</param> /// <param name="password">The user's password.</param> public static User LogIn(string userName, string password) { try { return(RegistrationDatabase.GetUser(userName, password)); } catch (Exception e) { throw new ArgumentNullException("Invalid Username/Password."); } }
private void button9_Click(object sender, EventArgs e) { foreach (DataGridViewRow d_row in dataGridView2.Rows) { DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell)d_row.Cells[1]; if (cb.Value != null) { RegistrationDatabase.GetUser((string)d_row.Cells[4].Value).SetStatus((string)cb.Value); } } Form2_Load(sender, e); }
private void button6_Click(object sender, EventArgs e) { try { LogInScreen.current_user = RegistrationDatabase.GetUser(comboBox1.Text); StudentDashboard form2 = new StudentDashboard(); form2.Show(); } catch { Console.WriteLine("Oops"); } }
private void button7_Click(object sender, EventArgs e) { try { LogInScreen.current_user = RegistrationDatabase.GetUser(comboBox2.Text); ProfessorDashboard form2 = new ProfessorDashboard(); form2.Show(); comboBox2.SelectedIndex = -1; } catch { Console.WriteLine("Oops"); } }
/// <summary> /// Removes a user from the User Database /// </summary> /// <param name="userName">Username of a Faculty or Student</param> public static void RemoveUser(string userName) { try { if (userDatabase[userName].GetStatus().Equals("faculty")) { Faculty faculty = (Faculty)userDatabase[userName]; foreach (KeyValuePair <string, Course> course in faculty.GetCourses()) { course.Value.SetFaculty((Faculty)RegistrationDatabase.GetUser("Staff")); } foreach (Student student in faculty.GetStudentAdvisees()) { student.ChangeAdvisor("Staff"); } userDatabase.Remove(userName); } else // if (userDatabase[userName].GetStatus().Equals("student")) { Student student = (Student)userDatabase[userName]; foreach (KeyValuePair <string, Course> course in student.GetCourses()) { course.Value.WithdrawStudent(student); student.DropCourse(course.Value.GetCourseID()); } Faculty faculty = (Faculty)userDatabase[student.GetStatus()]; faculty.RemoveStudentAdvisee((Student)RegistrationDatabase.GetUser("PRyan")); userDatabase.Remove(userName); } } catch { Console.WriteLine(String.Format("User \"{0}\" Not Found!", userName)); } }
private void button15_Click(object sender, EventArgs e) { List <string> dayBlocks = new List <string>(); List <string> timeBlocks = new List <string>(); Console.WriteLine(checkedListBox1.CheckedItems.Count); Console.WriteLine(comboBox7.SelectedValue); if (checkedListBox1.CheckedItems.Count > 0 && comboBox7.SelectedIndex != -1) { Console.WriteLine("Here Here"); string days = ""; foreach (object day in checkedListBox1.CheckedItems) { days = days + (string)day; } dayBlocks.Add(days); timeBlocks.Add((string)comboBox7.SelectedItem); foreach (int i in checkedListBox1.CheckedIndices) { checkedListBox1.SetItemCheckState(i, CheckState.Unchecked); } comboBox7.SelectedIndex = -1; } if ((checkedListBox2.CheckedItems).Count > 0 && comboBox6.SelectedIndex != -1) { string days = ""; foreach (object day in checkedListBox2.CheckedItems) { days = days + (string)day; } dayBlocks.Add(days); timeBlocks.Add((string)comboBox6.SelectedItem); foreach (int i in checkedListBox2.CheckedIndices) { checkedListBox2.SetItemCheckState(i, CheckState.Unchecked); } comboBox6.SelectedIndex = -1; } if ((checkedListBox3.CheckedItems).Count > 0 && comboBox3.SelectedIndex != -1) { string days = ""; foreach (object day in checkedListBox3.CheckedItems) { days = days + (string)day; } dayBlocks.Add(days); timeBlocks.Add((string)comboBox3.SelectedItem); foreach (int i in checkedListBox3.CheckedIndices) { checkedListBox3.SetItemCheckState(i, CheckState.Unchecked); } comboBox3.SelectedIndex = -1; } if ((checkedListBox4.CheckedItems).Count > 0 && comboBox4.SelectedIndex != -1) { string days = ""; foreach (object day in checkedListBox4.CheckedItems) { days = days + (string)day; } dayBlocks.Add(days); timeBlocks.Add((string)comboBox4.SelectedItem); foreach (int i in checkedListBox4.CheckedIndices) { checkedListBox4.SetItemCheckState(i, CheckState.Unchecked); } comboBox4.SelectedIndex = -1; } if ((checkedListBox5.CheckedItems).Count > 0 && comboBox5.SelectedIndex != -1) { string days = ""; foreach (object day in checkedListBox5.CheckedItems) { days = days + (string)day; } dayBlocks.Add(days); timeBlocks.Add((string)comboBox5.SelectedItem); foreach (int i in checkedListBox5.CheckedIndices) { checkedListBox5.SetItemCheckState(i, CheckState.Unchecked); } comboBox5.SelectedIndex = -1; } RegistrationDatabase.CreateCourse(new Course(textBox10.Text, textBox9.Text, (Faculty)RegistrationDatabase.GetUser((string)comboBox8.SelectedItem), textBox8.Text, Int32.Parse(textBox7.Text), dayBlocks, timeBlocks), textBox10.Text); textBox7.Text = ""; textBox8.Text = ""; textBox9.Text = ""; textBox10.Text = ""; comboBox8.SelectedIndex = -1; Form2_Load(sender, e); }
private void button13_Click(object sender, EventArgs e) { foreach (DataGridViewRow d_row in dataGridView1.Rows) { DataGridViewComboBoxCell cb = (DataGridViewComboBoxCell)d_row.Cells[1]; if (cb.Value != null) { RegistrationDatabase.GetCourse((string)d_row.Cells[2].Value).SetFaculty((Faculty)RegistrationDatabase.GetUser((string)cb.Value)); } } Form2_Load(sender, e); }
private void Form2_Load(object sender, EventArgs e) { var course_array = from row in RegistrationDatabase.GetCourses() select new { Id = row.Value.GetCourseID(), Name = row.Value.GetCourseName(), Faculty = row.Value.GetFaculty().GetUserName(), Credits = row.Value.GetCourseCredit(), Seats = row.Value.GetNumSeats(), Dates = String.Join(", ", row.Value.GetDayBlocks()), Times = String.Join(", ", row.Value.GetTimeBlocks()) }; var student_array = from row in RegistrationDatabase.GetUserDatabase() where row.Value is Student select new { First = row.Value.GetFirstName(), Last = row.Value.GetLastName(), Username = row.Value.GetUserName(), CurrentAdvisor = row.Value.GetStatus() }; var faculty_array = from row in RegistrationDatabase.GetUserDatabase() where row.Value is Faculty select new { First = row.Value.GetFirstName(), Last = row.Value.GetLastName(), Username = row.Value.GetUserName(), CurrentAdvisor = row.Value.GetStatus() }; dataGridView1.DataSource = course_array.ToArray(); dataGridView2.DataSource = student_array.ToArray(); dataGridView3.DataSource = faculty_array.ToArray(); ComboBox comboBox10 = new ComboBox(); if (comboBox9.Items.Count > 0) { comboBox9.Items.Clear(); } if (comboBox8.Items.Count > 0) { comboBox8.Items.Clear(); } if (comboBox2.Items.Count > 0) { comboBox2.Items.Clear(); } if (comboBox1.Items.Count > 0) { comboBox1.Items.Clear(); } foreach (User user in RegistrationDatabase.GetUserDatabase().Values) { if (user is Student) { comboBox1.Items.Add(user.GetUserName()); } if (user is Faculty) { comboBox10.Items.Add(user.GetUserName()); comboBox9.Items.Add(user.GetUserName()); comboBox8.Items.Add(user.GetUserName()); comboBox2.Items.Add(user.GetUserName()); } } comboBox9.Items.Add("faculty"); comboBox9.Items.Add("admin"); ((DataGridViewComboBoxColumn)dataGridView2.Columns["Advisor"]).DataSource = comboBox10.Items; foreach (DataGridViewRow d_row in dataGridView2.Rows) { d_row.Cells[1].Value = RegistrationDatabase.GetUser((string)d_row.Cells[4].Value).GetStatus(); } ((DataGridViewComboBoxColumn)dataGridView1.Columns["ChangeProfessor"]).DataSource = comboBox10.Items; foreach (DataGridViewRow d_row in dataGridView1.Rows) { d_row.Cells[1].Value = (string)d_row.Cells[4].Value; } }