コード例 #1
0
        //runs the payment history
        private static void RunPaymentHistory()
        {
            long student_id;

            if (_studentViewer == null)
            {
                _studentViewer = new StudentViewer();
            }
            if (_paymentHistoryViewer == null)
            {
                _paymentHistoryViewer = new PaymentHistoryViewer();
            }

            IList <StudentViewModel> student;


            WriteHeader();

            Console.WriteLine("Enter student ID: ");
            string str_student_id = (Console.ReadLine());

            student_id = Convert.ToInt64(str_student_id);


            //display student name and ask for confirmation

            string student_name = _studentViewer.GetStudent(student_id);

            Console.WriteLine("Student name: {0}", student_name);

            CommandPrompt("Is this correct? (Y/N)");
            string str_response = Console.ReadLine();

            if (str_response.ToLower() == "y")
            {
                IList <PaymentViewModel> histories = _paymentHistoryViewer.GetPaymentHistory(student_id);

                //display payment history


                Console.Clear();
                Console.WriteLine("Payment History for " + student_name);
                Console.WriteLine("###############################################################################################");
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();

                //get data
                Console.WriteLine("{0,-30} {1,9}", "Payment Date", "Payment Amount");
                foreach (PaymentViewModel history in histories)
                {
                    PrintOutSummaryLine(history);
                }
                Console.WriteLine("Press any key...");
                Console.ReadKey();
                return;
            }
            //}
        }
コード例 #2
0
        //create student

        private static void CreateStudent()
        {
            int    room_number;
            long   student_id;
            string first_name, last_name, building_name;

            if (_buildingViewer == null)
            {
                _buildingViewer = new BuildingViewer();
            }
            if (_roomViewer == null)
            {
                _roomViewer = new RoomViewer();
            }

            UWHousing.Entities.ViewModels.IList <BuildingViewModel> building = _buildingViewer.GetAllBuildingname();
            UWHousing.Entities.ViewModels.IList <RoomViewModel>     rooms;
            UWHousing.Entities.ViewModels.IList <StudentViewModel>  students;
            //TODO ILists

            WriteHeader();
            WriteCreateStudentHeader();

            //get student ID
            Console.WriteLine("Enter Student ID: ");
            string str_student_id = (Console.ReadLine());

            //validate student ID
            if (!Int64.TryParse(str_student_id, out student_id) || student_id > 9079999999 || student_id < 9070000000)
            {
                Console.WriteLine("Invalid student ID.  Press any key...");
                Console.ReadKey();
                return;
            }

            //TODO check if student id is already in use
            students = _studentViewer.GetStudent(student_id);
            if (students != null)
            {
                Console.WriteLine("Student ID already exists.Press any key...");
                Console.ReadKey();
                return;
            }

            //input first and last name
            Console.WriteLine("Enter student first name: ");
            first_name = Console.ReadLine();
            Console.WriteLine("Enter student last name: ");
            last_name = Console.ReadLine();

            //write building names on screen
            for (var i = 0; i < building.Count; i++)
            {
                Console.WriteLine("{0}. {1} {2}", building[i]);
            }
            CommandPrompt("Type building name: ");
            building_name = Console.ReadLine();

            //validate building name
            if (!building.Contains(building_name))
            {
                Console.WriteLine("Invalid building entry.  Press any key...");
                Console.ReadKey();
                return;
            }

            //building is valid - grab open rooms
            rooms = _roomViewer.GetOpenRoomsByBuilding(building_name);

            //TODO room
            for (var i = 0; i < rooms.Count; i++)
            {
                Console.WriteLine("Open rooms in " + building_name);
                Console.WriteLine("{0}. {1} {2}", rooms[i]);
            }
            CommandPrompt("Select open room: ");
            string str_room_number = Console.ReadLine();

            //validate room
            if (!Int32.TryParse(str_room_number, out room_number) || !rooms.Contains(room_number))
            {
                Console.WriteLine("Invalid room number.  Press any key...");
                Console.ReadKey();
                return;
            }

            //TODO summary screen
            WriteHeader();
            WriteCreateStudentHeader();
            Console.WriteLine("Student Details:");
            Console.WriteLine("Student Id: " + student_id);
            Console.WriteLine("Name: " + first_name + " " + last_name);
            Console.WriteLine("Building: " + building_name);
            Console.WriteLine("Room number: " + room_number);
            //TODO meal plan
            CommandPrompt("Is this correct? (Y/N)");
            string str_response = Console.ReadLine();

            //pass to DTO
            if (str_response.ToLower() == "y")
            {
                NewStudentDTO newStudent = new NewStudentDTO()
                {
                    first_name    = first_name,
                    last_name     = last_name,
                    building_name = building_name,
                    room_number   = room_number
                                    //TODO meal_plan = meal_plan
                };
                Console.WriteLine("Student created successfully.");
                Console.WriteLine("Press any key...");
                return;
            }
        }
コード例 #3
0
        //runs the payment history
        private static void RunPaymentHistory()
        {
            long student_id;

            if (_studentViewer == null)
            {
                _studentViewer = new StudentViewer();
            }
            if (_paymentHistoryViewer == null)
            {
                _paymentHistoryViewer = new PaymentHistoryViewer();
            }

            IList <StudentViewModel> student;

            //IList<PaymentHistoryViewModel> history;

            WriteHeader();

            Console.WriteLine("Enter student ID: ");
            string str_student_id = (Console.ReadLine());

            student_id = Convert.ToInt64(str_student_id);

            ////validate student ID
            //if (!Int64.TryParse(str_student_id, out student_id) || !student.Contains(student_id))
            //{
            //    Console.WriteLine("Invalid student ID.  Press any key...");
            //    Console.ReadKey();
            //    return;
            //}
            //else
            //{
            //display student name and ask for confirmation

            string student_name = _studentViewer.GetStudent(student_id)[0].FirstName + " " + _studentViewer.GetStudent(student_id)[0].LastName;

            Console.WriteLine("Student name: {0}", student_name);

            CommandPrompt("Is this correct? (Y/N)");
            string str_response = Console.ReadLine();

            if (str_response.ToLower() == "y")
            {
                IList <PaymentViewModel> histories = _paymentHistoryViewer.GetPaymentHistory(student_id);

                //display payment history
                //history = _paymentHistoryViewer.GetPaymentHistory(student_id);

                Console.Clear();
                Console.WriteLine("Payment History for " + student_name);
                Console.WriteLine("###############################################################################################");
                Console.WriteLine();
                Console.WriteLine();
                Console.WriteLine();

                //get data
                Console.WriteLine("{0,-30} {1,9}", "Payment Date", "Payment Amount");
                //TODO
                foreach (PaymentViewModel history in histories)
                {
                    PrintOutSummaryLine(history);
                }
                Console.ReadKey();
            }
            //}
        }