public admChangeAdvisor(userDatabase usrDB, string advisor) { InitializeComponent(); foreach (faculty fac in usrDB.getFacultyList()) { facDropDown.Items.Add(fac.username); facDropDown.AutoCompleteCustomSource.Add(fac.username); } currentAdvisor.Text += advisor; }
public admCreateUser(userDatabase usrDB) { InitializeComponent(); this.usrDB = usrDB; confirm.FlatAppearance.CheckedBackColor = Color.FromArgb(((int)(((byte)(37)))), ((int)(((byte)(49)))), ((int)(((byte)(63))))); foreach (faculty fac in usrDB.getFacultyList()) { advisor.Items.Add(fac.fname + " " + fac.lname); advisor.AutoCompleteCustomSource.Add(fac.fname + " " + fac.lname); } }
public admCreateCrs(courseDatabase crsDB, userDatabase usrDB) { InitializeComponent(); this.crsDB = crsDB; this.usrDB = usrDB; foreach (course crs in crsDB.getCourseList()) { crsIDBox.AutoCompleteCustomSource.Add(crs.crsID); } foreach (faculty fac in usrDB.getFacultyList()) { facDropDown.Items.Add(fac.fname + " " + fac.lname); facDropDown.AutoCompleteCustomSource.Add(fac.fname + " " + fac.lname); } }
public admChangeCrs(course crs, userDatabase usrDB) { InitializeComponent(); // Create the schedule table DataTable table = new DataTable(); table.Columns.Add("Schedule"); table.Columns.Add("Code"); foreach (string crsBlock in crs.timeBlocks) { table.Rows.Add(course.Decode(crsBlock), crsBlock); } crsSch.DataSource = table; DataGridViewCheckBoxColumn btn = new DataGridViewCheckBoxColumn(); btn.ValueType = typeof(bool); crsSch.Columns.Insert(0, btn); crsSch.Columns[0].HeaderText = "Remove"; crsSch.Columns[0].Name = "Remove"; foreach (DataGridViewColumn col in crsSch.Columns) { col.ReadOnly = true; } crsSch.Columns[0].ReadOnly = false; crsSch.Columns["Code"].Visible = false; foreach (faculty fac in usrDB.getFacultyList()) { facDropDown.Items.Add(fac.fname + " " + fac.lname); facDropDown.AutoCompleteCustomSource.Add(fac.fname + " " + fac.lname); } this.crs = crs; this.usrDB = usrDB; }
private void confirmClick(object sender, EventArgs e) { // Search for missing fields if (crsIDBox.Text == "" || titleBox.Text == "" || facDropDown.Text == "" || creditBox.Text == "" || seatBox.Text == "") { MessageBox.Show("Required fields missing.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Check if there is any time specified if (!MA.Checked && !MB.Checked && !TA.Checked && !TB.Checked && !WA.Checked && !WB.Checked && !RA.Checked && !RB.Checked && !FA.Checked && !FB.Checked) { MessageBox.Show("Specify a time slot.", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Day duplicate over multiple time blocks if ((MA.Checked && MB.Checked) || (TA.Checked && TB.Checked) || (WA.Checked && WB.Checked) || (RA.Checked && RB.Checked) || (FA.Checked && FB.Checked)) { MessageBox.Show("Cannot have the same day over two slots", "Invalid Input", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Check the presence of starting and ending time. if (MA.Checked || TA.Checked || WA.Checked || RA.Checked || FA.Checked) { if (startingTimeA.Text == "" || endingTimeA.Text == "") { MessageBox.Show("Specify the starting and ending time.", "Invalid input", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } string crsID = crsIDBox.Text; // Search for duplicate course ID foreach (course crs in crsDB.getCourseList()) { if (crsID.Trim() == crs.crsID) { MessageBox.Show("The course ID is already taken.", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } string title = titleBox.Text.Trim(); string instructor = facDropDown.Text.Trim(); faculty inst = usrDB.getFacultyList()[0]; foreach (faculty fac in usrDB.getFacultyList()) { if (fac.fname + " " + fac.lname == instructor) { inst = fac; break; } } string credits = creditBox.Text; try { if (Convert.ToSingle(credits) == 0) { MessageBox.Show("No credits given.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } catch { MessageBox.Show("Credits have to be a number.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } int seats = 0; try { seats = Convert.ToInt32(seatBox.Text); } catch { MessageBox.Show("Seats have to be a number.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Get the course time block int dd = 0; if (MA.Checked) { dd += 1; } if (TA.Checked) { dd += 2; } if (WA.Checked) { dd += 4; } if (RA.Checked) { dd += 8; } if (FA.Checked) { dd += 16; } string day = dd.ToString(); if (day.Length < 2) { day = "0" + day; } string timeBlockA = day + UF.utilities.encodeTime(startingTimeA.Text, endingTimeA.Text); if (MB.Checked || TB.Checked || WB.Checked || RB.Checked || FB.Checked) { // Get the course time block dd = 0; if (MB.Checked) { dd += 1; } if (TB.Checked) { dd += 2; } if (WB.Checked) { dd += 4; } if (RB.Checked) { dd += 8; } if (FB.Checked) { dd += 16; } day = dd.ToString(); if (day.Length < 2) { day = "0" + day; } string timeBlockB = day + UF.utilities.encodeTime(startingTimeB.Text, endingTimeB.Text); List <string> lst = new List <string>(); lst.Add(timeBlockA); lst.Add(timeBlockB); crs = new course(crsID, title, inst.username, credits, seats, 2, lst); } else { List <string> lst = new List <string>(); lst.Add(timeBlockA); crs = new course(crsID, title, inst.username, credits, seats, 1, lst); } string message; message = "Course ID : " + crs.crsID + "\n"; message += "Title : " + crs.title + "\n"; message += "Instructor : " + crs.instructor + "\n"; message += "Credits : " + crs.credit.ToString() + "\n"; message += "Seats : " + crs.seats.ToString() + "\n"; message += crs.getBlocks() + "\n"; message += "Are you sure?"; if (MessageBox.Show(message, "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Warning) == DialogResult.No) { MessageBox.Show("Canceled the creation.", "Cancel", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { this.DialogResult = DialogResult.OK; Close(); } }
private void confirmClick(object sender, EventArgs e) { // Required fields check if (username.Text == "" || password.Text == "" || userType.Text == "" || fname.Text == "" || lname.Text == "") { MessageBox.Show("Required field missing.", "Invalid Form.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // If student, the presence of an advisor if (userType.Text == "Student" && advisor.Text == "") { MessageBox.Show("Specify an advisor.", "Invalid Form.", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } // Duplicate check: same user username is invalid foreach (student std in usrDB.getStudentList()) { if (std.username.Trim() == username.Text.Trim().ToLower()) { MessageBox.Show("The username is already taken.", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } foreach (faculty fac in usrDB.getFacultyList()) { if (fac.username.Trim() == username.Text.Trim().ToLower()) { MessageBox.Show("The username is already taken.", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } foreach (admin adm in usrDB.getAdminList()) { if (adm.username.Trim() == username.Text.Trim().ToLower()) { MessageBox.Show("The username is already taken.", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } foreach (manager man in usrDB.getManagerList()) { if (man.username.Trim() == username.Text.Trim().ToLower()) { MessageBox.Show("The username is already taken.", "Duplicate", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } } this.uname = username.Text.ToLower(); this.pword = password.Text; if (userType.Text == "Student") { foreach (faculty fac in usrDB.getFacultyList()) { if (fac.fname + " " + fac.lname == advisor.Text) { uType = fac.username; break; } } } else { this.uType = userType.Text.ToLower(); } this.fName = fname.Text; if (mname.Text == "Middle Name") { this.mName = ""; } else { this.mName = mname.Text; } this.lName = lname.Text; this.DialogResult = DialogResult.OK; }
private void confirmClick(object sender, EventArgs e) { if (MessageBox.Show("Confirmation : \nMake sure you input the right information.", "Confirmation", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { // Remove specified time slots foreach (string timeslot in timeSlots) { crs.timeBlocks.Remove(timeslot); crs.num_time -= 1; } // Check if time is specified if (MA.Checked || TA.Checked || WA.Checked || RA.Checked || FA.Checked) { if (startingTimeA.Text == "" || endingTimeA.Text == "") { MessageBox.Show("Specify the starting and ending time.", "No time specified", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } else { int dd = 0; if (MA.Checked) { dd += 1; } if (TA.Checked) { dd += 2; } if (WA.Checked) { dd += 4; } if (RA.Checked) { dd += 8; } if (FA.Checked) { dd += 16; } string day; if (dd < 10) { day = "0" + dd.ToString(); } else { day = dd.ToString(); } string timeBlock = day + UF.utilities.encodeTime(startingTimeA.Text, endingTimeA.Text); crs.timeBlocks.Add(timeBlock); } } if (facDropDown.Text != "") { foreach (faculty fac in usrDB.getFacultyList()) { if (fac.fname + " " + fac.lname == facDropDown.Text.Trim()) { crs.setInstructor(fac.username); } } } DialogResult = DialogResult.OK; Close(); } }