public void Test_MaxAGP() { StudentCollection sc = new StudentCollection(); Student[] st_add = new Student[5]; //Random rand = new Random(); for (int i = 0; i < 5; i++) { //int grade = rand.Next(1, 6); // 1 is inclusive, 6 is exclusive - grade [1,5] Student tmp_student = new Student(new Person("John " + i, "Smith " + i, new DateTime()), Education.Bachelor, 121); tmp_student.AddExams(new Exam("Some Exam", i, new DateTime())); st_add[i] = tmp_student; //st_add[i] = new Student(new Person("John", "Smith", new DateTime()), Education.Bachelor, 112); } sc.AddStudents(st_add); double test_max_agp = (5.0 + 5.0 + 4.0) / 3.0; Console.WriteLine(sc.ToShortString()); Console.WriteLine(sc.MaxAGP); Assert.AreEqual(test_max_agp, sc.MaxAGP); }
public void Test_AddStudents() { StudentCollection sc = new StudentCollection(); sc.AddStudents(new Student()); Console.WriteLine(sc.ToShortString()); }
public static void Run() { var students = new Student[] { new Student("Pesho", "Petrov", 15), new Student("Pesho", "Kostov", 22), new Student("John", "Smith", 25), new Student("Reny", "Adamescu", 20), new Student("Fred", "Gogov", 23), new Student("Gosho", "Popov", 29) }; Console.BackgroundColor = ConsoleColor.Black; Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("03. First name is before last name"); StudentCollection.Print(StudentCollection.FindFirstBeforeLastName(students)); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("04. Students in age range 18 - 24"); StudentCollection.Print(StudentCollection.FindStudentsInAgeRange(students)); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("05. Sorted decending with Lambda"); StudentCollection.Print(StudentCollection.SortStudentsUsingLambda(students)); Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("05. Sorted decending with LINQ"); StudentCollection.Print(StudentCollection.SortStudentsUsingLinq(students)); }
public static StudentCollection SelectAll() { DataTable dt = database.DBLayer.ExecuteQuery("select * from Student"); StudentCollection result = new StudentCollection(); for (int i = 0; i < dt.Rows.Count; i++) { Department dept = new Department(); Admin adm = new Admin(); int id = Convert.ToInt32(dt.Rows[i]["id"]); string userName = dt.Rows[i]["st_userName"].ToString(); string name = dt.Rows[i]["st_Name"].ToString(); string address = dt.Rows[i]["st_address"].ToString(); string phone = dt.Rows[i]["st_phone"].ToString(); string email = dt.Rows[i]["st_email"].ToString(); int age = Convert.ToInt32(dt.Rows[i]["st_age"]); int flag = Convert.ToInt32(dt.Rows[i]["ins_flag"]); adm.Id = Convert.ToInt32(dt.Rows[i]["FK_AdminID"]); dept.Id = Convert.ToInt32(dt.Rows[i]["FK_DeptID"]); string pass = dt.Rows[i]["st_password"].ToString(); Student session = new Student(id, userName, name, age, address, phone, email, pass, adm, dept); result.Add(session); } return(result); }
static void Main(string[] args) { StudentCollection FirstCollect = new StudentCollection(); //Liste d'eleve Numero 1 StudentCollection SecondCollect = new StudentCollection(); //Liste d'eleve Numero 2 FirstCollect.CollectionName = "Collection numero 1"; //ChangeToRussian SecondCollect.CollectionName = "collection numero 2"; //ChangeToRussian StudentCollection[] FirstArray = { FirstCollect }; StudentCollection[] SecondArray = { FirstCollect, SecondCollect }; Journal FirstJournal = new Journal(FirstArray); //Journal Numero 1 Journal SecondJournal = new Journal(SecondArray); //Journal Numero 2 Console.WriteLine("-------------------------------------------Etape1"); FirstCollect.AddDefaults(); //premiere modification sur une liste SecondCollect.AddDefaults(); Student[] StudentToAdd = { new Student("Developpeur c#", 8977, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)), new Student("Developpeur c++", 8077, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)), new Student("Developpeur c", 18977, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)), new Student("Developpeur Javascript", 89770, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)) }; //ChangeToRussian FirstCollect.AddStudent(StudentToAdd); FirstCollect.Remove(1); FirstCollect.Remove(50); SecondCollect[0] = new Student("Developpeur Python", 2145, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)); //La reference A ete changer //ChangeToRussian SecondCollect.AddStudent(new Student[] { new Student("Developpeur Ruby", 77544, GetVariables.getIntArrayList(5), GetVariables.getIntArrayList(5)) }); //ChangeToRussian Console.WriteLine("--------------------------------------------Etape2"); //ChangeToRussian Console.WriteLine(FirstJournal.ToString()); Console.WriteLine(SecondJournal.ToString()); Console.WriteLine("-----------------------------------Etape 3"); //ChangeToRussian Console.WriteLine("Verifions le resume" + FirstCollect.ToString()); //ChangeToRussian Console.WriteLine("Verifions le court Resume" + FirstCollect.ToShortString()); //ChangeToRussian }
public void Test_AddDefaults() { StudentCollection sc = new StudentCollection(); sc.AddDefaults(); Console.WriteLine(sc.ToString()); }
public ReportGenerator(StudentCollection students, string school_year, string semester) { _students = students; _school_year = school_year; _semester = semester; _workbook = new Workbook(); _workbook.Open(new MemoryStream(Properties.Resources.獎懲人數統計報表), FileFormatType.Excel2003); _workbook.Worksheets.Clear(); _systems = new Dictionary <string, EduSystem>(); foreach (string cate in new string[] { "普通科", "職業科", "綜合高中" }) { _systems.Add(cate, new EduSystem(_workbook, cate)); } ProcessDiscipline(); foreach (EduSystem sys in _systems.Values) { sys.SchoolYear = _school_year; sys.Semester = _semester; sys.FillData(); } }
public void Test_CollectionName() { StudentCollection sc = new StudentCollection(); sc.AddDefaults(); sc.CollectionName = "Some Collection"; Assert.AreEqual("Some Collection", sc.CollectionName); }
public DistributeForm(StudentCollection students, string school_year, string semester) { InitializeComponent(); _students = students; this.Text += " " + school_year + " 學年度 "; this.Text += "第 " + semester + " 學期"; InitialMenuBarItem(); }
/// <summary> /// Sets all comboboxes to their default value /// </summary> public void ClearFilters() { SelectedFirstName = StudentCollection.Where(i => i.StudentFirstName == "None").Single(); SelectedLastName = StudentCollection.Where(i => i.StudentLastName == "None").Single(); SelectedMajor = MajorCollection.Where(i => i.MajorDescription == "None").Single(); SelectedStudentYear = StudentYearCollection.Where(i => i.StudentYearDescription == "None").Single(); AllStudentInformation.Clear(); PopulateResultView_NoFilters(); }
public void TestStudentCountChanged() { StudentCollection sc = new StudentCollection(); Journal journal = new Journal(); sc.StudentsCountChanged += journal.handle_StudentsCountChanged; sc.AddDefaults(); Console.WriteLine(journal.ToString()); }
public void TestRemove() { StudentCollection sc = new StudentCollection(); // Add 5 default student objects sc.AddDefaults(); Assert.AreEqual(true, sc.Remove(3)); Console.WriteLine(sc.ToString()); Assert.AreEqual(false, sc.Remove(4)); }
public StudentCollection getStudent(int studentId, int classId, Pagination pagination) { int totalNoOfRecords = 0; var result = _class.getStudent(studentId, classId, pagination, out totalNoOfRecords); List <StudentDto> studentDto = AutoMapper.Mapper.Map <List <Student>, List <StudentDto> >(result); StudentCollection collection = new StudentCollection(); collection.TotalCount = totalNoOfRecords; collection.StudentList = studentDto; return(collection); }
public static StudentCollection GetStudentCollection() { var toReturn = new StudentCollection(); IPredicateExpression filter = new PredicateExpression(); IRelationCollection relations = new RelationCollection(); var sorter = new SortExpression { }; toReturn.GetMulti(filter, 0, sorter, relations); return(toReturn); }
protected void Page_Load(object sender, EventArgs e) { grdVwStudentResults.DataSource = StudentCollection.Load() .OrderBy(x => x.LastName) .Select(x => new { Name = x.LastName + ", " + x.FirstName, GPA = x.GPA, Email = x.Email, CellPhone = x.PhoneCell, Id = x.StudentID }); grdVwStudentResults.DataBind(); }
public MakeStudentInstructor() { InitializeComponent(); students = StudentDAL.SelectAll(); for (int i = 0; i < students.Count; i++) { ComboboxItem item = new ComboboxItem(); item.Text = students[i].Name; item.Value = students[i].Id; studentsComboBox.Items.Add(item); //studentsComboBox.SelectedIndex = 0; } }
public void TestIndexator() { StudentCollection sc = new StudentCollection(); sc.AddDefaults(); sc[3] = new Student(new Person("Pee-Wee", "Jurker", new DateTime(1985, 12, 3)), Education.Bachelor, 123); Console.WriteLine(sc.ToString()); sc[6] = new Student(); Student stud = sc[0]; Assert.AreEqual(new Student(), stud); stud = sc[7]; Assert.AreEqual(null, stud); }
public MainWindowViewModel(Window window) { this.CurrentWindow = window; this._allStudents = DBHandler.Instance.QueryAll(); this._filteredStudents = new StudentCollection(); this.Students = this._allStudents; IList<SearchConditionEntry> searchConditionList = new List<SearchConditionEntry>(); searchConditionList.Add(new SearchConditionEntry("姓名", SearchCategory.SearchByName)); searchConditionList.Add(new SearchConditionEntry("身份证", SearchCategory.SearchByIdentity)); this._searchConditions = new CollectionView(searchConditionList); this._searchKeyword = ""; }
static void Main(string[] args) { var myCollection = new StudentCollection { new Student( new Student.Parameters { FirstName = "Name2", LastName = "Lsd3", DateBirth = 1994, School = "173", Home = "Home" }), new Student( new Student.Parameters { FirstName = "Name34", LastName = "Lsd3", DateBirth = 1999, School = "173", Home = "Home" }), new Student( new Student.Parameters { FirstName = "Name341", LastName = "Lsd3", DateBirth = 1991, School = "173", Home = "Home" }) }; foreach (var item in myCollection) { Console.WriteLine("{0}{1}", item, Environment.NewLine); } myCollection.Sort(); foreach (var item in myCollection) { Console.WriteLine("{0}{1}", item, Environment.NewLine); } Console.ReadKey(); }
static void Main(string[] args) { StudentCollection students = new StudentCollection(); students.Add(new Student(1, "Артем", "KhAI", 100)); students.Add(new Student(2, "Вас", "KhNURE", 75)); students.Add(new Student(3, "Петя", "KhNURE", 70)); students.Add(new Student(4, "Герман", "Karazina", 30)); students.Add(new Student(5, "Яся", "KhAI", 50)); students.Add(new Student(6, "Артур", "Karazina", 65)); students.Add(new Student(7, "Олег", "Karazina", 45)); //students.Add(new Student(7, "Олег", "Karazina", 45)); //Исключение(описано в комментариях) - существующий студент //students.SortById(); students.SortByName(); //students.SortByUniversity(); Console.WriteLine("Сортировка по имени"); foreach (Student item in students) { Console.WriteLine(item); } Console.WriteLine(); Console.WriteLine("Выбираем студента через ID"); Console.WriteLine(students[1]); Console.WriteLine(); //Console.WriteLine(students[50]); //Исключение(описано в комментариях) - такого студента нет Student studentForRemove = new Student(4, "Герман", "Karazina", 30); students.Remove(studentForRemove); students.SortByAssessment(); Console.WriteLine("Сортировка по оценками"); foreach (Student item in students) { Console.WriteLine(item); } Console.WriteLine(); Console.WriteLine("Выбираем студентов по ВУЗу"); foreach (Student item in students.GetStudentsByUniversity("KhAI")) { Console.WriteLine(item); } Console.WriteLine(); }
public void Test_SortByBirthDate() { StudentCollection sc = new StudentCollection(); Student[] st_add = new Student[5]; Random rand = new Random(); for (int i = 0; i < 5; i++) { int day_int = rand.Next(1, 29); // 1 is inclusive, 29 is exclusive - days st_add[i] = new Student(new Person("John", "Smith", new DateTime(1998, 1, day_int)), Education.Bachelor, 112); } sc.AddStudents(st_add); Console.WriteLine(sc.ToShortString()); sc.SortByBirthDate(); Console.WriteLine(sc.ToShortString()); }
static void Main(string[] args) { Person p1 = new Person("Fyodr", "Uncle", new DateTime(2000, 11, 4)); Person p2 = new Person(); Student s1 = new Student(p1, Education.Bachelor, 1); Student s2 = new Student(); Person p3 = new Person(); Person p4 = new Person(); Student s3 = new Student(p3, Education.Bachelor, 1); Student s4 = new Student(p4, Education.Specialist, 2); StudentCollection <Student> stcl = new StudentCollection <Student>(); StudentCollection <Student> stcl2 = new StudentCollection <Student>(); Journal j1 = new Journal(); Journal j2 = new Journal(); stcl.StudentChanged += j1.handler; stcl2.StudentChanged += j2.handler; Student[] st = new Student[2]; st[0] = s1; st[1] = s2; stcl.AddStudents(st); Student[] st2 = new Student[2]; st2[0] = s3; st2[1] = s4; stcl2.AddStudents(st2); stcl.Remove(0); stcl.Replace(s2, s3); Console.WriteLine(j1); Console.WriteLine(j2); }
private static void Main() { var firstCollection = new StudentCollection<string> {CollectionName = "Atlantes"}; var secondCollection = new StudentCollection<string> {CollectionName = "Titans"}; var firstCollectionJournal = new Journal<string>(); var secondCollectionJournal = new Journal<string>(); firstCollection.StudentsChanged += firstCollectionJournal.OnStudentsChanged; secondCollection.StudentsChanged += secondCollectionJournal.OnStudentsChanged; var student1 = new Student(); var student2 = new Student(); firstCollection.AddStudent(student1, student1.PersonId.ToString()); firstCollection.AddStudent(student2, student2.PersonId.ToString()); student1.Exams = new List<Exam> {new Exam {DisciplineName = "English"}}; Console.WriteLine("Elements added to first collection"); Console.WriteLine(!firstCollection.Remove(student1) ? "Failed to remove element from first collection" : "Element removed from first collection"); firstCollection[student1.PersonId.ToString()] = student1; Console.WriteLine("Element inserted to first collection"); var student3 = new Student(); var student4 = new Student(); secondCollection.AddStudent(student3, student3.PersonId.ToString()); secondCollection.AddStudent(student4, student4.PersonId.ToString()); student3.Tests = new List<Test> {new Test {DisciplineName = "English"}}; Console.WriteLine("Elements added to first collection"); Console.WriteLine(!secondCollection.Remove(student3) ? "Failed to remove element from first collection" : "Element removed from first collection"); secondCollection[student3.PersonId.ToString()] = student3; Console.WriteLine("Element inserted to first collection"); Console.WriteLine(); Console.WriteLine($"The first journal:\n{firstCollectionJournal}\n"); Console.WriteLine($"The second journal:\n{secondCollectionJournal}\n"); }
private void LoadStudents() { loadStudentData = new StudentCollection(); loadStudentData.LoadStudentsFromDb(); gridStd.Rows.Count = 1; foreach (var popStd in loadStudentData.pubStudentCollect) { gridStd.Rows.Count++; gridStd[gridStd.Rows.Count - 1, 1] = popStd.Std_Id; gridStd[gridStd.Rows.Count - 1, 2] = popStd.Std_FName; gridStd[gridStd.Rows.Count - 1, 3] = popStd.Std_LName; gridStd[gridStd.Rows.Count - 1, 4] = popStd.Std_MName; gridStd[gridStd.Rows.Count - 1, 5] = popStd.Std_CourseCode; gridStd[gridStd.Rows.Count - 1, 6] = popStd.Std_CourseTitle; gridStd[gridStd.Rows.Count - 1, 7] = popStd.Std_Year; gridStd[gridStd.Rows.Count - 1, 8] = popStd.Std_Section; } }
public void Test_SortByAGP() { StudentCollection sc = new StudentCollection(); Student[] st_add = new Student[5]; Random rand = new Random(); for (int i = 0; i < 5; i++) { int grade = rand.Next(1, 6); // 1 is inclusive, 6 is exclusive - grade [1,5] Student tmp_student = new Student(); tmp_student.AddExams(new Exam("Some Exam", grade, new DateTime())); st_add[i] = tmp_student; //st_add[i] = new Student(new Person("John", "Smith", new DateTime()), Education.Bachelor, 112); } sc.AddStudents(st_add); Console.WriteLine(sc.ToShortString()); sc.SortByAGP(); Console.WriteLine(sc.ToShortString()); }
public void Test_SortByLastName() { StudentCollection sc = new StudentCollection(); Student[] st_add = new Student[5]; Random rand = new Random(); for (int i = 0; i < 5; i++) { // generate a random integer : int symbol_int = rand.Next(65, 91); // 65 is inclusive, 91 is exclusive - [A - Z] ASCII table interval // get character from randompy generated integer : char symbol = (char)symbol_int; string last_name = "a" + symbol; st_add[i] = new Student(new Person("John", last_name, new DateTime()), Education.Bachelor, 112); } sc.AddStudents(st_add); Console.WriteLine(sc.ToShortString()); sc.SortByLastName(); Console.WriteLine(sc.ToShortString()); }
public AssignStudentToExamSession() { InitializeComponent(); students = StudentDAL.SelectAll(); for (int i = 0; i < students.Count; i++) { ComboboxItem item = new ComboboxItem(); item.Text = students[i].Name; item.Value = students[i].Id; StudentsComboBox.Items.Add(item); StudentsComboBox.SelectedIndex = 0; } sessions = ExamSessionDAL.SelectAll(); for (int i = 0; i < sessions.Count; i++) { ComboboxItem item = new ComboboxItem(); item.Text = sessions[i].Id.ToString(); item.Value = sessions[i].Id; ExamSessionsComboBox.Items.Add(item); ExamSessionsComboBox.SelectedIndex = 0; } }
public JsonResult GetStudents(DataTableAjaxPostModel model) { Pagination paginateModel = model.ToPagination(); int recordsTotal = 0; StudentCollection studentCollection = new StudentCollection(); WCFProxy.Using((delegate(IClassSetupService client) { studentCollection = client.getStudent(1, 1, paginateModel); })); recordsTotal = studentCollection.TotalCount; var data = studentCollection.StudentList.Skip(paginateModel.Skip).Take(paginateModel.PageSize).ToList(); return(Json(new { // this is what datatables wants sending back draw = model.draw, recordsTotal = recordsTotal, recordsFiltered = recordsTotal, data = data }, JsonRequestBehavior.AllowGet)); }
public void Test_AverageMarkGroup() { StudentCollection sc = new StudentCollection(); Student[] st_add = new Student[5]; //Random rand = new Random(); for (int i = 0; i < 5; i++) { //int grade = rand.Next(1, 6); // 1 is inclusive, 6 is exclusive - grade [1,5] Student tmp_student = new Student(new Person("John " + i, "Smith " + i, new DateTime()), Education.Bachelor, 121); tmp_student.AddExams(new Exam("Some Exam", i, new DateTime())); st_add[i] = tmp_student; //st_add[i] = new Student(new Person("John", "Smith", new DateTime()), Education.Bachelor, 112); } sc.AddStudents(st_add); Console.WriteLine(sc.ToShortString()); /* Since we have populated StudentCollection with Students and added exams * to those students with grades == i, the only predictable AGP value is 4. * Thus we are creating a list of Students with AGP == 4. */ List <Student> test_list = sc.AverageMarkGroup(4); if (test_list.Count != 0) { foreach (var item in test_list) { Console.WriteLine(item.ToString()); } } else { Console.WriteLine("Test List contains no Students."); } }
public void Test_Specialists() { StudentCollection sc = new StudentCollection(); Student[] st_add = new Student[5]; //Random rand = new Random(); Student tmp_student = new Student(new Person("John 0", "Smith 0", new DateTime()), Education.Bachelor, 121); st_add[0] = tmp_student; Student tmp_student1 = new Student(new Person("John 1", "Smith 1", new DateTime()), Education.Specialist, 121); st_add[1] = tmp_student1; Student tmp_student2 = new Student(new Person("John 2", "Smith 2", new DateTime()), Education.Specialist, 121); st_add[2] = tmp_student2; Student tmp_student3 = new Student(new Person("John 3", "Smith 3", new DateTime()), Education.Bachelor, 121); st_add[3] = tmp_student3; Student tmp_student4 = new Student(new Person("John 4", "Smith 4", new DateTime()), Education.Bachelor, 121); st_add[4] = tmp_student4; sc.AddStudents(st_add); Console.WriteLine(sc.ToShortString()); IEnumerable <Student> test_list = sc.Specialists; foreach (var item in test_list) { Console.WriteLine(item.ToShortString()); } }
public DisciplineStatistics() { SelectSemesterForm form = new SelectSemesterForm(); if (form.ShowDialog() != System.Windows.Forms.DialogResult.OK) { return; } _disciplines = new DisciplineCollection(); _students = new StudentCollection(); _school_year = form.SchoolYear; _semester = form.Semester; _wait = new ManualResetEvent(false); _disciplineLoader = new BackgroundWorker(); _disciplineLoader.DoWork += new DoWorkEventHandler(_disciplineLoader_DoWork); _disciplineLoader.RunWorkerCompleted += new RunWorkerCompletedEventHandler(_disciplineLoader_RunWorkerCompleted); _disciplineLoader.ProgressChanged += new ProgressChangedEventHandler(_disciplineLoader_ProgressChanged); _disciplineLoader.WorkerReportsProgress = true; _disciplineLoader.RunWorkerAsync(); }
/// <summary> /// Populates the Student combobox /// </summary> public void PopulateStudentsCbo() { try { using (var context = new SchoolU_DBEntities()) { context.Database.Connection.Open(); StudentCollection.Clear(); StudentCollection.Add(new Student { StudentFirstName = "None", StudentLastName = "None" }); IList <Student> allStudentsFN = context.Students.Where(i => i.StudentId != 0).ToList(); foreach (var item in allStudentsFN) { StudentCollection.Add(item); } } } catch (Exception ex) { //MessageBox.Show(ex.Message); return; } }
void RemoveExecute() { string message = String.Format("确认删除当前学员:{0},{1}", this.SelectedItem.Identity, this.SelectedItem.Name); MessageBoxResult confirm = MessageBox.Show(message, "确认", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (confirm == MessageBoxResult.Yes) { Student stu = this.SelectedItem; this._allStudents.Remove(stu); this.Students = this._allStudents; DBHandler.Instance.Delete(stu); } }
void ShowAllExecute() { this.Students = this._allStudents; }
void OnEditComplete(EditStudentWindowViewModel vm) { if (vm.IsSaveClicked) { if (!vm.IsForNew) { this.SelectedItem.CloneFrom(vm.CurrentStudent); ((MainWindow)this.CurrentWindow).ResizeGridViewColumns(); } else { Student stu = vm.CurrentStudent; this._allStudents.Add(stu); DBHandler.Instance.Insert(stu); this.Students = this._allStudents; ((MainWindow)this.CurrentWindow).ResizeGridViewColumns(); } } }
static void Main() { var student = new Student { Birthday = DateTime.Parse("01.03.1994"), Exams = new List<Exam> { new Exam {DisciplineName = "English", Mark = 6, Date = DateTime.Parse("03.12.2015")}, new Exam {DisciplineName = "Math", Mark = 3, Date = DateTime.Parse("03.05.2015")}, new Exam {DisciplineName = "Physics", Mark = 7, Date = DateTime.Parse("03.21.2015")}, new Exam {DisciplineName = "Biology", Mark = 5, Date = DateTime.Parse("03.17.2015")} }, Education = Education.Bachelor }; Console.WriteLine($"Source student:\n{student}\n"); Console.WriteLine("Sorted exams by discipline name:\n"); student.SortExamsByDisciplineName(); Console.WriteLine(student); Console.WriteLine(); Console.WriteLine("Sorted exams by mark:\n"); student.SortExamsByMark(); Console.WriteLine(student); Console.WriteLine(); Console.WriteLine("Sorted exams by date:\n"); student.SortExamsByDate(); Console.WriteLine(student); Console.WriteLine(); var students = new StudentCollection<string>(s => s.PersonId.ToString()); students.AddDefaults(2); var student2 = new Student { Education = Education.Bachelor, Exams = new List<Exam> { new Exam {DisciplineName = "English", Mark = 4, Date = DateTime.Parse("03.12.2015")}, new Exam {DisciplineName = "Math", Mark = 7, Date = DateTime.Parse("03.05.2015")}, new Exam {DisciplineName = "Physics", Mark = 9, Date = DateTime.Parse("03.21.2015")}, new Exam {DisciplineName = "Biology", Mark = 10, Date = DateTime.Parse("03.17.2015")} } }; var student3 = new Student { Education = Education.Bachelor, Exams = new List<Exam> { new Exam {DisciplineName = "English", Mark = 7, Date = DateTime.Parse("03.12.2015")}, new Exam {DisciplineName = "Math", Mark = 4, Date = DateTime.Parse("03.05.2015")}, new Exam {DisciplineName = "Physics", Mark = 8, Date = DateTime.Parse("03.21.2015")}, new Exam {DisciplineName = "Biology", Mark = 6, Date = DateTime.Parse("03.17.2015")} } }; students.AddStudents(student, student2, student3); Console.WriteLine($"StudentCollection<string>:\n{students}"); Console.WriteLine(); Console.WriteLine($"StudentCollection<string>(short):\n{students.ToShortString()}"); Console.WriteLine(); Console.WriteLine($"Max average mark: {students.MaxAverageMark}\n"); Console.WriteLine("The list of Bachelors:"); var bachelors = students.GetWithEducationForm(Education.Bachelor); foreach (var bachelor in bachelors) { Console.WriteLine(bachelor.Value); } Console.WriteLine(); Console.WriteLine("Grouping by education:"); var grouped = students.GroupByEducation; foreach (var group in grouped) { Console.WriteLine($"{group.Key}:"); foreach (var item in group) { Console.WriteLine(item.Value); } Console.WriteLine(); } var testCollections = new TestCollections<Person, Student>(5, count => { var tempStudent = new Student(); return new KeyValuePair<Person, Student>(tempStudent.Key, tempStudent); }); for (var att = 0; att < TestAttemptsCount; att++) { Console.WriteLine($"************************ TEST {att} ************************"); testCollections.PerformSearch(testCollections.Value, tuple => Console.WriteLine($"{tuple.Item1} : {tuple.Item2}")); Console.WriteLine(); } }
public void TestInsert() { Student stu1 = new Student() { Name = "stu''1", Identity = "2202014986146513541", Contact = "1212", StartTime = DateTime.Parse("2012-1-1"), EndTime = DateTime.Parse("2012-2-1") }; Student stu2 = new Student() { Name = "stu2", Identity = "2202014981212113541", Contact = "1212", StartTime = DateTime.Parse("2012-1-1") }; StudentCollection _allStudents = new StudentCollection(); StudentDataContext dc = new StudentDataContext(this.connection); dc.StudentTable.InsertOnSubmit(stu2); dc.SubmitChanges(); }
public StudentCollection QueryAll() { StudentCollection result = new StudentCollection(); IEnumerator<Student> iterator = this.dataContext.StudentTable.GetEnumerator(); while (iterator.MoveNext()) { result.Add(iterator.Current); } return result; }
void SearchExecute() { string keyword=this.SearchKeyword.Trim(); if (this.SelectedSearchCondition.Category==SearchCategory.SearchByName) { this._filteredStudents.Clear(); foreach (Student stu in this._allStudents) { if (stu.Name.Contains(keyword)) { this._filteredStudents.Add(stu); } } this.Students = this._filteredStudents; } else if (this.SelectedSearchCondition.Category == SearchCategory.SearchByIdentity) { this._filteredStudents.Clear(); foreach (Student stu in this._allStudents) { if (stu.Identity.Contains(keyword)) { this._filteredStudents.Add(stu); } } this.Students = this._filteredStudents; } }