private void search_Button_Click(object sender, EventArgs e) { TeachingAssistantSQL sql = new TeachingAssistantSQL(); TeachingAssistant teachingAssistant = null; if (select_comboBox.Text == "First Name") { teachingAssistant = sql.SearchTeachingAssistant("firstName", textBox.Text); } else if (select_comboBox.Text == "Last Name") { teachingAssistant = sql.SearchTeachingAssistant("lastName", textBox.Text); } else if (select_comboBox.Text == "ID") { teachingAssistant = sql.SearchTeachingAssistant("ID", textBox.Text); } if (teachingAssistant != null) { String message = "Search Results:\n"; message += "First Name: " + teachingAssistant.FirstName + "\n"; message += "Last Name: " + teachingAssistant.LastName + "\n"; message += "ID: " + teachingAssistant.Id + "\n"; message += "Age: " + teachingAssistant.Age + "\n"; message += "Username: "******"\n"; MessageBox.Show(message); } else { MessageBox.Show("No results were found."); } }
public TimeBetweenClasses_Form(ref TeachingAssistant teachingAssist) { InitializeComponent(); this.teachingAssist = teachingAssist; textBox.Text = hScrollBar1.Value.ToString(); textBox.Enabled = false; }
public void UpdateTeachingAssistantOnClosing(TeachingAssistant teachingAssistant) { if (teachingAssistant == null) { return; } // Add update of first name, last name, id, username and password // add insert courses to teach Insert_DaysToTeach(teachingAssistant.DaysToTeach, teachingAssistant.Id, "TeachingAssistantTable"); Insert_HoursToTeach(teachingAssistant.HoursToTeach, teachingAssistant.Id, "TeachingAssistantTable"); Insert_MinTimeBetweenClasses(teachingAssistant.MinTimeBetweenClasses, teachingAssistant.Id, "TeachingAssistantTable"); Insert_NumOfDaysToTeach(teachingAssistant.NumOfDaysToTeach, teachingAssistant.Id, "TeachingAssistantTable"); Insert_SemestersToTeach(teachingAssistant.SemestersToTeach, teachingAssistant.Id, "TeachingAssistantTable"); Insert_OfficeHours(teachingAssistant.OfficeHoursFrom, teachingAssistant.OfficeHoursTo, teachingAssistant.Id, "TeachingAssistantTable"); Insert_CoursesToTeach(teachingAssistant.CoursesToTeach, teachingAssistant.Id, "TeachingAssistantTable"); }
public ActionResult DeleteConfirmed(string id) { TeachingAssistant teachingAssistant = db.TeachingAssistants.Find(id); db.TeachingAssistants.Remove(teachingAssistant); db.SaveChanges(); return(RedirectToAction("Index")); }
public void TeachingAssistantCanTeachASingleClass() { var underTest = new TeachingAssistant(3); underTest.AddClassTitle("Biology 101"); Assert.Equal("Biology 101", underTest.ClassTitles.Single()); }
public MinTimeBetweenClasses_Form(ref TeachingAssistant user) { if (user == null) { user = new TeachingAssistant(); } this.assistant = user; InitializeComponent(); }
public void TeachingAssistant_WithId() { var ta = new TeachingAssistant(1); Assert.Equal(1, ta.Id); Assert.Null(ta.FirstName); Assert.Null(ta.LastName); Assert.Empty(ta.ClassTitles); Assert.Equal(Subject.None, ta.SubjectArea); }
public ActionResult Edit([Bind(Include = "id,FirstNameTA,LastNameTA")] TeachingAssistant teachingAssistant) { if (ModelState.IsValid) { db.Entry(teachingAssistant).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } return(View(teachingAssistant)); }
public void TeachingAssistant_WithIdAndName() { var ta = new TeachingAssistant(1, "Wahab", "Syed"); Assert.Equal(1, ta.Id); Assert.Equal("Wahab", ta.FirstName); Assert.Equal("Syed", ta.LastName); Assert.Empty(ta.ClassTitles); Assert.Equal(Subject.None, ta.SubjectArea); }
public ActionResult Create([Bind(Include = "id,FirstNameTA,LastNameTA")] TeachingAssistant teachingAssistant) { if (ModelState.IsValid) { db.TeachingAssistants.Add(teachingAssistant); db.SaveChanges(); return(RedirectToAction("Index")); } return(View(teachingAssistant)); }
public TeachingAssistant SearchTeachingAssistant(string searchBy, string value) { TeachingAssistant teachingAssistant = new TeachingAssistant(); String command = "SELECT * FROM TeachingAssistantTable WHERE " + searchBy + " = '" + value + "'"; DataSet dataSet = new DataSet(); SqlDataAdapter adapter = new SqlDataAdapter(); try { adapter.SelectCommand = new SqlCommand(command, sqlConnection); adapter.Fill(dataSet); if (dataSet.Tables.Count == 0) { return(null); } teachingAssistant.FirstName = dataSet.Tables[0].Rows[0].ItemArray[0].ToString(); teachingAssistant.LastName = dataSet.Tables[0].Rows[0].ItemArray[1].ToString(); teachingAssistant.Id = dataSet.Tables[0].Rows[0].ItemArray[2].ToString(); teachingAssistant.Age = Convert.ToInt32(dataSet.Tables[0].Rows[0].ItemArray[3].ToString()); teachingAssistant.Username = dataSet.Tables[0].Rows[0].ItemArray[4].ToString(); teachingAssistant.Password = dataSet.Tables[0].Rows[0].ItemArray[5].ToString(); teachingAssistant.CoursesToTeach = LoginSQL.ParseCoursesToTeachFromSql( dataSet.Tables[0].Rows[0].ItemArray[6].ToString()); teachingAssistant.DaysToTeach = LoginSQL.ParseDaysToTeachFromSql( dataSet.Tables[0].Rows[0].ItemArray[7].ToString()); // ------------------------------------------------------------------- try { DateTime[] tempHoursToTeach = LoginSQL.ParseHoursToTeachFromSql( dataSet.Tables[0].Rows[0].ItemArray[8].ToString()); try { teachingAssistant.HoursToTeach = new DateTime[2]; } catch (Exception e) { e.ToString(); } teachingAssistant.HoursToTeach[0] = new DateTime(2000, 1, 1, tempHoursToTeach[0].Hour, tempHoursToTeach[0].Minute, 0); teachingAssistant.HoursToTeach[1] = new DateTime(2000, 1, 1, tempHoursToTeach[1].Hour, tempHoursToTeach[1].Minute, 0); } catch (Exception e) { e.ToString(); } // ------------------------------------------------------------------- } catch (Exception e) { e.ToString(); return(null); } return(teachingAssistant); }
public void TeachingAssistant_SubjectArea() { var ta = new TeachingAssistant(1, "Wahab", "Syed"); Assert.Throws <ArgumentException>(() => { ta.SubjectArea = Subject.None; }); ta.SubjectArea = Subject.History; Assert.Equal(Subject.History, ta.SubjectArea); }
public void TeachingAssistantCanTeachTwoClasses() { var underTest = new TeachingAssistant(3); underTest.AddClassTitle("Biology 101"); underTest.AddClassTitle("Physics 206"); Assert.Equal("Biology 101", underTest.ClassTitles.First()); Assert.Equal("Physics 206", underTest.ClassTitles.Last()); Assert.Equal(2, underTest.ClassTitles.Count()); }
public void TeachingAssistantHasProperDefault() { var underTest = new TeachingAssistant(42) { FirstName = "An", LastName = "Assistant", SubjectArea = "Science" }; Assert.Equal(42, underTest.Id); Assert.Equal("Science", underTest.SubjectArea); Assert.False(underTest.ClassTitles.Any()); }
public void TeachingAssistantCanTeachNoMoreThanTwoClasses() { var underTest = new TeachingAssistant(3); underTest.AddClassTitle("Biology 101"); underTest.AddClassTitle("Physics 206"); Assert.Throws <InvalidOperationException>(() => underTest.AddClassTitle("Chemistry 112")); Assert.Equal("Biology 101", underTest.ClassTitles.First()); Assert.Equal("Physics 206", underTest.ClassTitles.Last()); Assert.Equal(2, underTest.ClassTitles.Count()); }
public void TeachingAssistantCanReplaceAClass() { var underTest = new TeachingAssistant(3); underTest.AddClassTitle("Biology 101"); underTest.AddClassTitle("Physics 206"); underTest.RemoveClassTitle("Biology 101"); underTest.AddClassTitle("Chemistry 112"); Assert.Equal("Chemistry 112", underTest.ClassTitles.First()); Assert.Equal("Physics 206", underTest.ClassTitles.Last()); Assert.Equal(2, underTest.ClassTitles.Count()); }
// GET: TeachingAssistants/Delete/5 public ActionResult Delete(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } TeachingAssistant teachingAssistant = db.TeachingAssistants.Find(id); if (teachingAssistant == null) { return(HttpNotFound()); } return(View(teachingAssistant)); }
public void TeachingAssistant_RemoveTitle() { var ta = new TeachingAssistant(1, "Wahab", "Syed"); ta.AddTitle("101 - Introduction to Programming"); Assert.Throws <ArgumentNullException>(() => { ta.RemoveTitle(string.Empty); }); ta.RemoveTitle("101 - Introduction to Programming"); Assert.Empty(ta.ClassTitles); Assert.Throws <InvalidOperationException>(() => { ta.RemoveTitle("101 - Introduction to Programming"); }); }
public TimedMethod[] Summon() { if (Party.enemyCount == 4) { return(Switch()); } System.Random rng = new System.Random(); int seed; Character current; for (int i = 0; i < 2; i++) { seed = rng.Next(6); if (seed == 0) { current = new Instructor(); } else if (seed == 1) { current = new Researcher(); } else if (seed == 2) { current = new Janitor(); } else if (seed == 3) { current = new Cop(); } else if (seed == 4) { current = new TeachingAssistant(); } else { current = new ShuttleDriver(); } current.SetRecruitable(false); Party.AddEnemy(current); } return(new TimedMethod[] { new TimedMethod(0, "Audio", new object[] { "Recruit" }), new TimedMethod(60, "Log", new object[] { ToString() + " called in underlings" }) }); }
private void button1_Click(object sender, EventArgs e) { this.Hide(); TeachingAssistant teachingAssist = new TeachingAssistant(); teachingAssist.FirstName = "empty"; BasicUser temp = (BasicUser)teachingAssist; BasicUser_Registration_Form regForm = new BasicUser_Registration_Form(ref temp, true); regForm.FormClosed += new FormClosedEventHandler(FormClosedHandling); regForm.ShowDialog(); if (temp != null && temp.FirstName != "empty") { String tempt = "The new user details: FirstName:" + temp.FirstName + ", lastname:" + temp.LastName + ",password:"******"TeachingAssistantTable"); } }
public void TeachingAssistant_ClassTitles() { var ta = new TeachingAssistant(1, "Wahab", "Syed"); Assert.Throws <ArgumentNullException>(() => { ta.AddTitle(string.Empty); }); ta.AddTitle("101 - Introduction to Programming"); Assert.NotEmpty(ta.ClassTitles); Assert.Contains("101 - Introduction to Programming", ta.ClassTitles); ta.AddTitle("201 - Introduction to Databases"); Assert.Contains("101 - Introduction to Programming", ta.ClassTitles); Assert.Throws <InvalidOperationException>(() => { ta.AddTitle("301 - Introduction to Data Structures"); }); }
private void choose_Button_Click(object sender, EventArgs e) { if (chooseWorker_listView.SelectedItems.Count == 0) { if (type == "Lecturer") { MessageBox.Show("No Lecturer has been selected, try again please."); } else { MessageBox.Show("No Teaching-Assistant has been selected, try again please."); } return; } currentTabPage = assignCourse_tabPage; tabControl.SelectedTab = currentTabPage; CourseSQL.LoadCoursesToListView(ref this.workerCourses_listView); if (type == "Lecturer") { TeachingAssistantSQL sql = new TeachingAssistantSQL(); this.selectedLecturer = sql.SearchLecturer( "id", chooseWorker_listView.SelectedItems[0].SubItems[2].Text); } else { TeachingAssistantSQL sql = new TeachingAssistantSQL(); this.selectedTeachingAssist = sql.SearchTeachingAssistant( "id", chooseWorker_listView.SelectedItems[0].SubItems[2].Text); } foreach (ListViewItem item in workerCourses_listView.Items) { if (IsCourseInSelfCourses(Convert.ToInt32(item.SubItems[0].Text)) == false) { ListViewItem copy = item; workerCourses_listView.Items.Remove(item); otherCourses_listView.Items.Add(copy); } } }
public SemestersToTeach_Form(ref TeachingAssistant assistant) { this.assistant = assistant; InitializeComponent(); }
public void LoginAsLecturer(DataSet dataSet) { //Lecturer lecturer = new Lecturer(); AbstractFactory employeeFactory = FactoryProducer.getFactory("EmployeeFactory"); Lecturer lecturer = (Lecturer)employeeFactory.getEmployee("Lecturer"); lecturer.FirstName = dataSet.Tables[0].Rows[0].ItemArray[0].ToString(); lecturer.LastName = dataSet.Tables[0].Rows[0].ItemArray[1].ToString(); lecturer.Id = dataSet.Tables[0].Rows[0].ItemArray[2].ToString(); lecturer.Age = Convert.ToInt16(dataSet.Tables[0].Rows[0].ItemArray[3].ToString()); lecturer.Username = dataSet.Tables[0].Rows[0].ItemArray[4].ToString(); lecturer.Password = dataSet.Tables[0].Rows[0].ItemArray[5].ToString(); try { lecturer.CoursesToTeach = ParseCoursesToTeachFromSql(dataSet.Tables[0].Rows[0].ItemArray[6].ToString()); } catch (Exception e) { e.ToString(); } try { lecturer.DaysToTeach = ParseDaysToTeachFromSql(dataSet.Tables[0].Rows[0].ItemArray[7].ToString()); } catch (Exception e) { e.ToString(); } // ------------------------------------------------------------------- try { DateTime[] tempHoursToTeach = ParseHoursToTeachFromSql(dataSet.Tables[0].Rows[0].ItemArray[8].ToString()); try { lecturer.HoursToTeach = new DateTime[2]; } catch (Exception e) { e.ToString(); } lecturer.HoursToTeach[0] = new DateTime(2000, 1, 1, tempHoursToTeach[0].Hour, tempHoursToTeach[0].Minute, 0); lecturer.HoursToTeach[1] = new DateTime(2000, 1, 1, tempHoursToTeach[1].Hour, tempHoursToTeach[1].Minute, 0); } catch (Exception e) { e.ToString(); } // ------------------------------------------------------------------- try { lecturer.MinTimeBetweenClasses = Convert.ToInt16(dataSet.Tables[0].Rows[0].ItemArray[9].ToString()); } catch (Exception e) { e.ToString(); } try { lecturer.NumOfDaysToTeach = Convert.ToInt16(dataSet.Tables[0].Rows[0].ItemArray[10].ToString()); } catch (Exception e) { e.ToString(); } try { lecturer.SemestersToTeach = ParseSemestersToTeachFromSql(dataSet.Tables[0].Rows[0].ItemArray[11].ToString()); } catch (Exception e) { e.ToString(); } try { lecturer.OfficeHoursFrom = ParseDateTimeFromSql(dataSet.Tables[0].Rows[0].ItemArray[12].ToString()); } catch (Exception e) { e.ToString(); } try { lecturer.OfficeHoursTo = ParseDateTimeFromSql(dataSet.Tables[0].Rows[0].ItemArray[13].ToString()); } catch (Exception e) { e.ToString(); } TeachingAssistant temp = new TeachingAssistant(); Lecturer_Form lecturer_form = new Lecturer_Form(ref lecturer, this.loginForm); lecturer_form.ShowDialog(); }
public OfficeHours_Form(ref TeachingAssistant user) { this.assistant = user; InitializeComponent(); }
public NumOfDays_Form(ref TeachingAssistant user) { this.assistant = user; InitializeComponent(); }
public ChooseHoursToWork_Form(ref TeachingAssistant user) { this.assistant = user; InitializeComponent(); }
public void LoginAsTeachingAssistant(DataSet dataSet) { //TeachingAssistant teachingAssist = new TeachingAssistant(); AbstractFactory employeeFactory = FactoryProducer.getFactory("EmployeeFactory"); TeachingAssistant teachingAssist = (TeachingAssistant) employeeFactory.getEmployee("TeachingAssistant"); teachingAssist = new TeachingAssistant(); teachingAssist.FirstName = dataSet.Tables[0].Rows[0].ItemArray[0].ToString(); teachingAssist.LastName = dataSet.Tables[0].Rows[0].ItemArray[1].ToString(); teachingAssist.Id = dataSet.Tables[0].Rows[0].ItemArray[2].ToString(); teachingAssist.Age = Convert.ToInt16(dataSet.Tables[0].Rows[0].ItemArray[3].ToString()); teachingAssist.Username = dataSet.Tables[0].Rows[0].ItemArray[4].ToString(); teachingAssist.Password = dataSet.Tables[0].Rows[0].ItemArray[5].ToString(); try { teachingAssist.CoursesToTeach = ParseCoursesToTeachFromSql(dataSet.Tables[0].Rows[0].ItemArray[6].ToString()); } catch (Exception e) { e.ToString(); } try { teachingAssist.DaysToTeach = ParseDaysToTeachFromSql(dataSet.Tables[0].Rows[0].ItemArray[7].ToString()); } catch (Exception e) { e.ToString(); } // ------------------------------------------------------------------- try { DateTime[] tempHoursToTeach = ParseHoursToTeachFromSql(dataSet.Tables[0].Rows[0].ItemArray[8].ToString()); try { teachingAssist.HoursToTeach = new DateTime[2]; } catch (Exception e) { e.ToString(); } teachingAssist.HoursToTeach[0] = new DateTime(2000, 1, 1, tempHoursToTeach[0].Hour, tempHoursToTeach[0].Minute, 0); teachingAssist.HoursToTeach[1] = new DateTime(2000, 1, 1, tempHoursToTeach[1].Hour, tempHoursToTeach[1].Minute, 0); } catch (Exception e) { e.ToString(); } // ------------------------------------------------------------------- try { teachingAssist.MinTimeBetweenClasses = Convert.ToInt16(dataSet.Tables[0].Rows[0].ItemArray[9].ToString()); } catch (Exception e) { e.ToString(); } try { teachingAssist.NumOfDaysToTeach = Convert.ToInt16(dataSet.Tables[0].Rows[0].ItemArray[10].ToString()); } catch (Exception e) { e.ToString(); } try { teachingAssist.SemestersToTeach = ParseSemestersToTeachFromSql(dataSet.Tables[0].Rows[0].ItemArray[11].ToString()); } catch (Exception e) { e.ToString(); } try { teachingAssist.OfficeHoursFrom = ParseDateTimeFromSql(dataSet.Tables[0].Rows[0].ItemArray[12].ToString()); } catch (Exception e) { e.ToString(); } try { teachingAssist.OfficeHoursTo = ParseDateTimeFromSql(dataSet.Tables[0].Rows[0].ItemArray[13].ToString()); } catch (Exception e) { e.ToString(); } TeachingAssist_Form teachingAssistant_form = new TeachingAssist_Form(ref teachingAssist, this.loginForm); teachingAssistant_form.ShowDialog(); //this.loginForm.Hide(); }