Example #1
0
        private void Main_Load(object sender, EventArgs e)
        {
            Student stu1 = new Student("Kai Zhou", Gender.male, 26);
            Student stu2 = new Student("Shiyang Liu", Gender.femal, 25);
            Student stu3 = new Student("Yaqiao Liu", Gender.femal, 25);

            Students stuList = new Students();
            stuList.Add(stu1);
            stuList.Add(stu2);
            stuList.Add(stu3);

            bindingSourceStudents.DataSource = stuList;
            bindingSourceStudents.ResetBindings(false);
        }
Example #2
0
    static void Main()
    {
        Students students = new Students();
        students.Add(new Student() { Roll = 10, Name = "Raj" });
        students.Add(new Student() { Roll = 20, Name = "Man" });

        Student search = new Student() { Roll = 10, Name = "Raj" };

        Console.WriteLine(students.Contains(search,new StudentCompareByRoll()));
        students.Remove(search);
        foreach (var t in students)
        {
            Console.WriteLine(t.Roll + " " + t.Name);
        }
    }
 public void AddStudent(Student student)
 {
     if (string.IsNullOrEmpty(student.Name))
     {
         throw new ArgumentException("A Name is required to add a student to a gradebook.");
     }
     Students.Add(student);
 }
Example #4
0
 public void Add(Student student)
 {
     if (!Students.Contains(student))
     {
         Students.Add(student);
         DataService.InsertNewStudent(student);
     }
 }
Example #5
0
 public void AddToGroup(Student student)
 {
     Students.Add(student);
     foreach (Student s in Students)
     {
         Console.WriteLine(student.FirstName + " " + student.LastName + " " + student.PersonalCode);
     }
 }
Example #6
0
 public void AddStudent(Student student)
 {
     if (!Students.Contains(student))
     {
         Students.Add(student);
         student.setId(this.ShortName + $"{_studentId++:0000}");
     }
 }
Example #7
0
        public void AddNewStudent(Student newStudent)
        {
            if (newStudent == null)
            {
                throw new ArgumentException("Student cannot be empty", nameof(newStudent));
            }

            Students.Add(newStudent);
        }
 public void AddStudent(string name)
 {
     Students.Add(new Student()
     {
         Name = name, Tests = new List <Test>()
     });
     ///I want to notify that a user was added
     OnProcessCompleted(EventArgs.Empty);
 }
 private void AddStudentClick()
 {
     if (Students.Count != 0)
     {
         var newStudent = new Student(_index++, "LastName", "FirstName", 16, "");
         _repo.AddStudent(newStudent);
         Students.Add(new StudentsViewModel(newStudent));
     }
 }
Example #10
0
 /// <summary>
 /// 在班级中增加学生
 /// </summary>
 /// <param name="pobj">学生对象</param>
 /// <return>增加成功,则返回ture;不成功,返回false,说明此ID已存在</return>
 internal bool AddStudent(Student pobj)
 {
     if (FindStudentByID(pobj.ID) == null)//此ID号不存在
     {
         Students.Add(pobj);
         return(true);
     }
     return(false);
 }
Example #11
0
 public void AddStudent(Student student)
 {
     // student.Name == null || ""
     if (string.IsNullOrEmpty(student.Name))
     {
         throw new ArgumentException("A name is required to add a Student to the List");
     }
     Students.Add(student);
 }
Example #12
0
        private void InitCommands()
        {
            AddNewStudent = new RelayCommand(
                canExecute: () => true,
                execute: () => Students.Add(new Student("First", "Last", "000000000")));

            ClearStudents = new RelayCommand(
                canExecute: () => 0 < Students.Count,
                execute: () => Students.Clear());

            DeleteSelectedStudent = new RelayCommand(
                canExecute: () => SelectedStudent != null,
                execute: () =>
            {
                if (SelectedStudent != null)
                {
                    Students.Remove(SelectedStudent);
                }
            });

            ReadFromFile = new RelayCommand(
                canExecute: () => true,
                execute: () =>
            {
                var openDialog = new OpenFileDialog();
                var result     = openDialog.ShowDialog();

                if (result == true)
                {
                    //Paramater is not used so pass in null
                    if (ClearStudents.CanExecute(null))
                    {
                        ClearStudents.Execute(null);
                    }

                    var students = FileIo.ReadStudentsFromCsv(openDialog.FileName);
                    foreach (var s in students)
                    {
                        Students.Add(s);
                    }
                }
            });

            SaveToFile = new RelayCommand(
                canExecute: () => 0 < Students.Count,
                execute: () =>
            {
                var saveDialog = new SaveFileDialog();
                var result     = saveDialog.ShowDialog();

                if (result == true)
                {
                    FileIo.WriteStudentsToCsv(Students, saveDialog.FileName);
                }
            });
        }
Example #13
0
        public void CreateStudent(string firstName, string lastName, string birthday, List <string> classes)
        {
            Student student = new Student(lastName, firstName, DateTime.Parse(birthday));

            Students.Add(student);
            foreach (var item in classes)
            {
                GetClass(item).AddStudent(student);
            }
        }
Example #14
0
        private void AddStudent()
        {
            var newStudent = new Student {
                Name = "Viktor", Birthday = DateTime.Now
            };

            Students.Add(newStudent);
            _repository.Add(newStudent);
            _repository.Commit();
        }
Example #15
0
        public static bool AddStudent(Student aStudent)
        {
            var success = false;

            aStudent.ID = Guid.NewGuid();
            Students.Add(aStudent.ID, aStudent);
            StudentsByDni.Add(aStudent.DNI, aStudent);
            success = true;
            return(success);
        }
        private void ReloadStudents()
        {
            Students.Clear();
            var students = _studentsXmlProvider.GetAll();

            foreach (var student in students)
            {
                Students.Add(student);
            }
        }
Example #17
0
        private Student NewStudent()
        {
            Student student = new Student
            {
                StudentIndex = Students.Count + 1
            };

            Students.Add(student);
            return(student);
        }
        public async void PopulateStudentRoster()
        {
            List <Student> students = await App.DB.ShowStudents();

            Students.Clear();
            foreach (Student student in students)
            {
                Students.Add(student);
            }
        }
Example #19
0
        private void AddStudent()
        {
            Student NewStudent = new Student
            {
                name   = name,
                zachet = zachet,
            };

            Students.Add(NewStudent);
        }
 public void AddStudent(params Student[] students)
 {
     foreach (Student student in students)
     {
         if (!Students.Contains(student))
         {
             Students.Add(student);
         }
     }
 }
        async Task ExecuteLoadStudentsCommand()
        {
            Students.Clear();
            var students = await App.DB.ShowStudents();

            foreach (var student in students)
            {
                Students.Add(student);
            }
        }
Example #22
0
 public Repository(DbContextOptions <Repository> options) : base(options)
 {
     if (Database.EnsureCreated())
     {
         Students.Add(new StudentEntity {
             LogId = "1234qwer"
         });
         SaveChanges();
     }
 }
Example #23
0
        private void GetStudentList()
        {
            Students.Clear();
            SelectedStudent = null;

            foreach (var student in context.GetStudents())
            {
                Students.Add(student);
            }
        }
Example #24
0
        private async Task AddStudents()
        {
            var viewModel = new StudentDetailViewModel(new StudentTableViewModel(), _studentStore, _pageService);

            viewModel.StudentAdded += (source, student) =>
            {
                Students.Add(new StudentTableViewModel(student));
            };

            await _pageService.PushModalAsync(new StudentDetailPage(viewModel));
        }
Example #25
0
 public void AddStudent(Student student)
 {
     if (VerifyStudent(student))
     {
         Students.Add(student);
     }
     else
     {
         throw new ArgumentException($"Wrong student parameters.");
     }
 }
Example #26
0
 public void EnrollSchool(Student student)
 {
     if (IsStudentEnrolled(student.StudentId))
     {
         throw new Exception();
     }
     else
     {
         Students.Add(student);
     }
 }
Example #27
0
 public void AddStudentToGroup(Student student)
 {
     if (Capacity > Students.Count)
     {
         Students.Add(student);
     }
     else
     {
         throw new InvalidCapacityException("Imposible add student, capacity overflow");
     }
 }
        public Student AddStudent(string name)
        {
            var student = new Student()
            {
                Id = Guid.NewGuid().ToString(), Name = name
            };

            Students.Add(student);

            return(student);
        }
        void LogStudent(string data)
        {
            string UID = data;
            string matric;

            matric = TableQuery(data);

            mainWindow.AddMatricToListBox(matric);

            Students.Add(new Student(matric, UID));
        }
Example #30
0
        //Students Class Extens List<Student>
        static void Main()
        {
            #region Students List<Student>

            Students stud = new Students();
            stud.Add(new Student {
                RollNo = 1, Name = "Roshan", Subject1 = 80, Subject2 = 75
            });
            stud.Add(new Student {
                RollNo = 2, Name = "Palak", Subject1 = 70, Subject2 = 67
            });
            stud.Add(new Student {
                RollNo = 3, Name = "Piyu", Subject1 = 85, Subject2 = 56
            });
            stud.Add(new Student {
                RollNo = 4, Name = "Shlok", Subject1 = 84, Subject2 = 73
            });
            stud.Add(new Student {
                RollNo = 5, Name = "Pratiksha", Subject1 = 60, Subject2 = 59
            });

            Console.WriteLine();

            foreach (Student aStudent in stud)
            {
                aStudent.Display();
                Console.WriteLine();
            }

            stud.RemoveAt(4);

            foreach (Student aStudent in stud)
            {
                aStudent.Display();
                Console.WriteLine();
            }

            #endregion

            Console.ReadLine();
        }
Example #31
0
        public void Fetch(string filepath1, string filepath2, string filepath3)
        {
            FetchStudent(filepath1);
            FetchCourse(filepath2);
            FetchStudentCourse(filepath3);


            foreach (string line in StudentList)
            {
                if (line == StudentList[0])
                {
                    continue;
                }
                else
                {
                    string[] properties = line.Split(',');

                    Students.Add(new Student {
                        StudentID = Int32.Parse(properties[0]), StudentName = properties[1], StudentAddress = properties[2], PhoneNumber = properties[3]
                    });
                }
            }
            foreach (string line in CourseList)
            {
                if (line == CourseList[0])
                {
                    continue;
                }
                else
                {
                    string[] properties = line.Split(',');

                    Courses.Add(new Course {
                        CourseID = Int32.Parse(properties[0]), CourseName = properties[1]
                    });
                }
            }
            foreach (string line in StudentCourseList)
            {
                if (line == StudentCourseList[0])
                {
                    continue;
                }
                else
                {
                    string[] properties = line.Split(',');

                    StudentCourses.Add(new StudentCourse {
                        id = Int32.Parse(properties[0]), StudentID = Int32.Parse(properties[1]), CourseID = Int32.Parse(properties[2])
                    });
                }
            }
        }
Example #32
0
 static void AddAlumno()
 {
     while (true)
     {
         Console.WriteLine($"Entra alumno <dni*nombre*nota> {Students.Count + 1} / q - exit");
         string notaText = Console.ReadLine();
         if (notaText == "q")
         {
             Console.Clear();
             break;
         }
         char[]   c1   = { '*' };
         string[] info = notaText.Split(c1);
         if (info.Length < 3)
         {
             Console.WriteLine("Entered data is incorrect. Try again!");
             continue;
         }
         var    result = Students.Where(x => x.Dni == info[0]);
         double nota;
         if (double.TryParse(info[2].Replace(".", ","), out nota))
         {
             if (result.Count() == 0)
             {
                 Student NewStudent = new Student()
                 {
                     Dni = info[0], Name = info[1]
                 };
                 NewStudent.Marks = new List <double>();
                 NewStudent.Marks.Add(nota);
                 Students.Add(NewStudent);
             }
             else if (result.Count() == 1)
             {
                 Console.WriteLine($"Este alumno existe ya!");
                 foreach (var item in result) //or result.First() or result.ElementAt(0)
                 {
                     item.Marks.Add(nota);
                 }
             }
             else
             {
                 Console.WriteLine("Error! Dos alumnos tienen el mismo DNI!");
             }
         }
         else
         {
             Console.WriteLine($"valor introducidio [{notaText}] no válido");
             Console.WriteLine("Entered data is incorrect. Try again!");
             continue;
         }
     }
 }
Example #33
0
        static void MyIterator()
        {
            #region student
            Students students = new Students();
            Student st = new Student();
            st.Name = "lili";

            students.Add(st);
            st = new Student();
            st.Name = "OK";

            students.Add(st);

            foreach (Student obj in students)
            {
                Console.WriteLine(obj.Name);
            }
            #endregion

            #region teacher
            Teachers ts = new Teachers();
            Teacher t1 = new Teacher(1001, "t1", 33);
            Teacher t2 = new Teacher(1002, "t2", 34);
            ts.Add(t1);
            ts.Add(t2);

            foreach (Teacher t in ts)
            {
                Console.WriteLine("{0}, {1}, {2};", t.Tid.ToString(), t.Name, t.Age.ToString());
            }

            // other methods for the foreach
            {
                IEnumerator enumerator = ts.GetEnumerator();
                Teacher t;

                while (enumerator.MoveNext())
                {
                    t = (Teacher)enumerator.Current;
                    Console.WriteLine("{0}, {1}, {2};", t.Tid.ToString(), t.Name, t.Age.ToString());
                }
            }

            #endregion

            #region doctor
            // using IEnumerable<T> interface
            Doctors ds = new Doctors();
            Doctor d1 = new Doctor("lili", 28);
            Doctor d2 = new Doctor("wang", 30);
            ds.Add(d1);
            ds.Add(d2);

            foreach (Doctor d in ds)
            {
                Console.WriteLine("{0}, {1};", d.Name, d.Age.ToString());
            }
            Console.WriteLine();

            {
                IEnumerator enumerator = ds.GetEnumerator();
                Doctor d;

                while (enumerator.MoveNext())
                {
                    d = (Doctor)enumerator.Current;
                    Console.WriteLine("{0}, {1};", d.Name, d.Age.ToString());
                }
            }

            Console.WriteLine();

            {
                IEnumerator<Doctor> enumerator = ds.GetEnumerator();
                Doctor d;

                while (enumerator.MoveNext())
                {
                    d = enumerator.Current;
                    Console.WriteLine("{0}, {1};", d.Name, d.Age.ToString());
                }
            }
            #endregion

            #region myStack

            MyStack<int> s = new MyStack<int>();
            for (int i = 0; i < 10; i++)
            {
                s.Push(i);
            }

            // Prints: 9 8 7 6 5 4 3 2 1 0
            // Foreach legal since s implements IEnumerable<int>
            foreach (int n in s)
            {
                System.Console.Write("{0} ", n);
            }
            System.Console.WriteLine();

            // Prints: 9 8 7 6 5 4 3 2 1 0
            // Foreach legal since s.TopToBottom returns IEnumerable<int>
            foreach (int n in s.TopToBottom)
            {
                System.Console.Write("{0} ", n);
            }
            System.Console.WriteLine();

            // Prints: 0 1 2 3 4 5 6 7 8 9
            // Foreach legal since s.BottomToTop returns IEnumerable<int>
            foreach (int n in s.BottomToTop)
            {
                System.Console.Write("{0} ", n);
            }
            System.Console.WriteLine();

            // Prints: 9 8 7 6 5 4 3
            // Foreach legal since s.TopN returns IEnumerable<int>
            foreach (int n in s.TopN(7))
            {
                System.Console.Write("{0} ", n);
            }
            System.Console.WriteLine();

            #endregion
        }