Beispiel #1
0
        private static void ShowStudents()
        {
            //Instantiate the Student Data Mapper class
            StudentDataMapper student_mapper = new StudentDataMapper();
            var students = student_mapper.Select();
            //List<Student> students = student_mapper.Select();

            var output = new StringBuilder();

            output.AppendLine("Student ID\tFirst Name\tLast Name\tEnroll Date\tMajor");
            output.AppendLine("-----------\t----------\t----------\t-----------\t---------");

            //Loop throuth students list and display values
            foreach (var stu in students)
            {
                output.Append(stu.ID.ToString().PadRight(10));
                output.Append("\t");
                output.Append(stu.FirstName.PadRight(10));
                output.Append("\t");
                output.Append(stu.LastName.PadRight(10));
                output.Append("\t");
                output.Append(string.Format("{0:d}", stu.EnrollDate).PadRight(10));
                output.Append("\t");
                output.Append(stu.Major.PadRight(10));
                output.AppendLine();
            }
            Console.WriteLine(output.ToString());
        }
Beispiel #2
0
        private static void ShowStudents()
        {
            //instantiate the student data mapper class
            StudentDataMapper student_mapper = new StudentDataMapper();
            // var students = student_mapper.Select();
            List <Student> students = student_mapper.Select();
            var            output   = new StringBuilder();

            output.AppendLine("Student ID\tFirst Name\tLast Name\tEnroll Date\tMajor");
            output.AppendLine("---------\t---------\t---------\t---------\t---------");

            foreach (var stu in students)
            {
                output.AppendLine(stu.ID.ToString().PadRight(10));
                output.Append("\t");
                output.Append
            }
        }
        private static void FindStudent()
        {
            Console.WriteLine("Enter the student name:");
            string name = Console.ReadLine();

            StudentDataMapper student_mapper = new StudentDataMapper();
            var searchStudents = student_mapper.Find(name);

            Console.WriteLine("------ Search Results ------");
            if (searchStudents.Count() > 0)
            {
                foreach (var s in searchStudents)
                {
                    Console.WriteLine(s.StudentName);
                }
            }
            else
            {
                Console.WriteLine("No records found for " + name);
            }
        }