/**
         * Creates a new ProviderInterface.
         */
        public ProviderInterface()
        {
            ui = new UserInterface();

            //Start use case Manage Session
            logon();

            string menuText = "\t1. Verify Member/Submit Claim\n"
                              + "\t2. Request Provider Directory\n"
                              + "\t3. Quit\n";

            int choice;

            do
            {
                //display menu and read choice
                ui.message("\n\t\t\tProvider Subsystem\n");
                choice = ui.menu(menuText);
                switch (choice)
                {
                //Use case Verify Member followed optionally by Submit claim
                case 1: verifyMember(); break;

                //Use case Receive Provider Directory
                case 2: receiveDirectory(); break;

                case 3: break;

                default: ui.errorMessage("Invalid choice.  Please re-enter."); break;
                }
            } while (choice != 3);
        }// default Constructor
Beispiel #2
0
        }//deleteService

        //Utility method to get user input and update attributes of a service
        private void updateService(UserInterface ui, Service aService, Boolean retainOldValue)
        {
            try
            {
                string input;

                //Get value for code if it has not already been set
                if (aService.getCode() == null)  //code may not be changed
                {
                    input = ui.promptForString("Code: ");
                    aService.setCode(input);
                }

                //get value for name
                input = ui.promptForString("Name: ");
                if (input.Length == 0 && retainOldValue)
                {
                    aService.setName(aService.getName());    //ensure valid name
                }
                else
                {
                    aService.setName(input);
                }

                //get value for fee
                double fee;
                if (retainOldValue)
                {
                    fee = ui.promptForDouble("Fee: ", aService.getFee());
                }
                else
                {
                    fee = ui.promptForDouble("Fee: ");
                }
                aService.setFee(fee);
            }
            catch (FormatException ex)
            {
                ui.errorMessage(ex.Message);
                ui.message("Current details:");
                ui.message(aService.toFormattedString());
                ui.message("\nPlease repeat input.  "
                           + "Press Enter for details that are correct.");
                updateService(ui, aService, true);    //Give the user another chance
            }
        }//updateService
        private Providers providers;  //a collection of provider objects

        //********************************************************************

        /**
         * Runs the ProviderMaintainer independently of the rest of the system.
         * @param args not used
         */
        public static void Main(string[] args)
        {
            try
            {
                new ProviderMaintainer();
            }
            catch (Exception ex)
            {
                UserInterface ui = new UserInterface();
                ui.message("\nEnd of test run.\n");
            }
        }//main
Beispiel #4
0
        //********************************************************************

        /**
         * Runs the ServiceMaintainer independently of the rest of the system.
         * @param args not used
         */
        static void Main(String[] args)
        {
            try
            {
                new ServiceMaintainer();
            }
            catch (Exception ex)
            {
                UserInterface ui = new UserInterface();
                ui.message("\nEnd of test run.\n");
            }

            Console.ReadKey();
        }//main
Beispiel #5
0
        /**
         * Creates a new ServiceMaintainer control object
         */
        public ServiceMaintainer()
        {
            try
            {
                //Create and open the service collection
                services = new Services();
                services.open();

                //Create a user interface and set up menu
                ui = new UserInterface();
                string menuText = "1.\tAdd a New Service\n" +
                                  "2.\tEdit a Service\n" +
                                  "3.\tDelete a Service\n" +
                                  "4.\tQuit\n";

                int choice;
                do
                {
                    ui.message("\t\t\tMaintain Services\n\n");
                    choice = ui.menu(menuText);  //display menu and get choice
                    switch (choice)
                    {
                    case 1: addService(); break;

                    case 2: editService(); break;

                    case 3: deleteService(); break;

                    case 4: break;

                    default: ui.errorMessage("Invalid choice.  Please re-enter."); break;
                    }
                } while (choice != 4);

                //close the service collection
                services.close();
            }
            catch (FormatException ex)  //Error in file format
            {
                ui.errorMessage(ex.Message);
                return;
            }
            catch (FileNotFoundException ex)
            {
                //occurs if the file cannot be created
                ui.errorMessage(ex.Message);
            }
        }//default constructor
        /**
         * Creates a new ProviderMaintainer control object
         */
        public ProviderMaintainer()
        {
            try
            {
                //create and open the provider collection
                providers = new Providers();
                providers.open();

                //set up menu for user interface
                ui = new UserInterface();
                string menuText = "1.\tAdd a New Provider\n" +
                                  "2.\tEdit a Provider\n" +
                                  "3.\tDelete a Provider\n" +
                                  "4.\tQuit\n";

                int choice;
                do
                {
                    ui.message("\t\t\tMaintain Providers\n\n");
                    //display menu and read choice
                    choice = ui.menu(menuText);
                    switch (choice)
                    {
                    case 1: addProvider(); break;

                    case 2: editProvider(); break;

                    case 3: deleteProvider(); break;

                    case 4: break;

                    default: ui.errorMessage("Invalid choice.  Please re-enter."); break;
                    }
                } while (choice != 4);

                //close provider collection
                providers.close();
            }
            catch (FileNotFoundException ex)
            {
                //occurs if the file cannot be created
                ui.errorMessage(ex.Message);
            }
        }//default constructor
Beispiel #7
0
        }//default constructor

        /** Prompts the user for the new values with which to update a person.
         *  @param ui the user interface with which to communicate with the user
         *  @param aPerson the person object to update
         *  @param retainOldValue if true, the current value of an attribute is
         *								  retained if the user does not specify a new value.
         *                        If false, and a value is required for the
         *                        attribute, the user will be prompted repeatedly
         *                        to enter a value until the value is valid.
         */
        public void updatePerson(UserInterface ui, Person aPerson
                                 , bool retainOldValue)
        {
            try
            {
                if (retainOldValue)
                {
                    ui.message("\nEnter new values.  "
                               + "Press Enter for values that are correct.");
                }
                string input = ui.promptForString("\nName: ");
                if (input.Length == 0 && retainOldValue)
                {
                    aPerson.setName(aPerson.getName());     //ensure valid name
                }
                else
                {
                    aPerson.setName(input);
                }
                input = ui.promptForString("Street Address: ");
                if (input.Length == 0 && retainOldValue)
                {
                    ;                                      //retain old value
                }
                else
                {
                    aPerson.setStreet(input);
                }
                input = ui.promptForString("City: ");
                if (input.Length == 0 && retainOldValue)
                {
                    ;                                      //retain old value
                }
                else
                {
                    aPerson.setCity(input);
                }
                input = ui.promptForString("State: ");
                if (input.Length == 0 && retainOldValue)
                {
                    ;                                      //retain old value
                }
                else
                {
                    aPerson.setState(input);
                }
                input = ui.promptForString("Zip Code: ");
                if (input.Length == 0 && retainOldValue)
                {
                    ;                                      //retain old value
                }
                else
                {
                    aPerson.setZip(input);
                }
                input = ui.promptForString("Email: ");
                if (input.Length == 0 && retainOldValue)
                {
                    ;                                      //retain old value
                }
                else
                {
                    aPerson.setEmail(input);
                }
            }
            catch (ArgumentOutOfRangeException ex)
            {
                ui.errorMessage(ex.Message);
                ui.message("Current details:\n");
                ui.message(aPerson.toFormattedString());
                ui.message("\nPlease repeat input.\n");
                updatePerson(ui, aPerson, true);    //Give the user another chance
            }
        }//updatePerson
        /**
         * Creates a new SchedulerInterface which then runs the accounting procedure.
         */
        public SchedulerInterface()
        {
            //for communciation with the tester
            UserInterface ui = new UserInterface();

            ui.message("\nRunning the accounting procedure ...\n");

            //Use today's date for all reports
            DateTime now = new DateTime();

            try
            {
                //Generate provider reports
                ui.message("Generating the providers' reports ...");
                Providers providers = new Providers();
                providers.open();
                List <Person> allProviders = providers.getAll();
                foreach (Person person in allProviders)
                {
                    Provider provider = (Provider)person;
                    ProviderReportGenerator generator
                        = new ProviderReportGenerator(provider, now);
                    ProviderReport theReport = generator.getReport();
                    if (theReport.getDetailCount() > 0)
                    {
                        theReport.sendByEmail(provider.getName());
                    }
                }
                providers.close();

                //Generate member reports
                ui.message("Generating the members' reports ...");
                Members members = new Members();
                members.open();
                List <Person> allMembers = members.getAll();
                foreach (Person person in allMembers)
                {
                    Member member = (Member)person;
                    MemberReportGenerator generator
                        = new MemberReportGenerator(member, now);
                    MemberReport theReport = generator.getReport();
                    if (theReport.getDetailCount() > 0)
                    {
                        theReport.sendByEmail(member.getName());
                    }
                }
                members.close();

                //Generate accounts payable report
                ui.message("Generating the accounts payable report ...");
                AccountsPayableReportGenerator generator
                    = new AccountsPayableReportGenerator(now);
                generator.getReport().sendByEmail("Accounts Payable");

                //Generate EFT data
                ui.message("Generating the EFT data ...");
                EFTReportGenerator eftGenerator = new EFTReportGenerator(now);
                eftGenerator.getReport().print("EFT Data");

                ui.message("\nAccounting procedure completed successfully.\n\n");
            }
            catch (FileNotFoundException ex)
            {
                //occurs if a file cannot be created
                ui.errorMessage(ex.Message);
            }
        }//default constructor
        /** Creates a new Claim Submitter object
         *  @param theProvider the provider submitting the claim
         *  @param theMember the member to whom the service was provided
         */
        public ClaimSubmitter(Provider theProvider, Member theMember)
        {
            try
            {
                ui = new UserInterface();

                services = new Services();
                claims   = new Claims();
                services.open();
                claims.open();

                //get the service date
                DateTime serviceDate = ui.promptForDate
                                           ("Service Date (" + UserInterface.DATE_FORMAT + "): ");

                //get the correct service
                Service theService  = null;
                bool    correctCode = false;
                do
                {
                    //get the service code
                    string serviceCode = ui.promptForString("Service Code: ");
                    theService = services.find(serviceCode);
                    if (theService == null)
                    {
                        ui.errorMessage("Invalid code.  Please re-enter.");
                    }
                    else
                    {
                        //confirm the service
                        string answer = ui.promptForString("Service: "
                                                           + theService.getName()
                                                           + "  \nIs this correct? (Y)es or (N)o: ");
                        if (answer != null && answer.Length >= 1 &&
                            char.ToUpper(answer[0]) == 'Y')
                        {
                            correctCode = true;
                        }
                    }
                } while (!correctCode);


                //Create new claim.  The constructor initializes
                //the submission date and time with the system time.
                Claim aClaim = new Claim(theService.getCode(),
                                         theProvider.getNumber(), theMember.getNumber(),
                                         serviceDate);
                claims.add(aClaim);
                //Display success confirmation and service fee
                ui.message("Your claim has been submitted successfully.");
                ui.message("Service fee due to you: "
                           + ui.formatAsCurrency(theService.getFee()));

                services.close();
                claims.close();
            }
            catch (ArgumentException ex)
            {
                //File format is incorrect
                ui.errorMessage(ex.Message);
            }
            catch (IndexOutOfRangeException ex)
            {
                //Thrown by the constructor for the claim object.
                //This should only happen if the comments entered are too long.
                ui.errorMessage(ex.Message);
            }
            catch (FileNotFoundException ex)
            {
                //occurs if the file cannot be created
                ui.errorMessage(ex.Message);
            }
        }//default constructor
Beispiel #10
0
        }//sendByEmail

        /** Displays the report on the given user interface
         *  @param ui the user interface
         */
        public void display(UserInterface ui)
        {
            ui.message(sb.ToString());
        }//display