Acme Travel Agency Case StudyStep 3

for RuBoard

Acme Travel Agency Case Study”Step 3

The Acme Travel Agency case study was introduced in Chapter 4, where we used arrays as our data structures for storing lists of hotels, customers, and reservations . In Chapter 5 we changed the implementation to use collections in place of arrays. We also specified a number of interfaces, and we passed lists as ArrayList object references. We provided a command-line user interface. In the CaseStudy folder of the present chapter we provide a graphical user interface, implemented by using Windows Forms.

We have already looked at the main window (see Figure 6-22), which is the same as in the simplified HotelAdmin [7] program we used to illustrate dialog boxes. The "Add..." button lets us add a new hotel (Figure 6-21), and the "Change..." button (Figure 6-24) lets us change the number of rooms and the rate of a hotel. The "Delete" button will delete the currently selected hotel.

[7] The HotelAdmin program provides only empty forms as stubs for the "Customers" and "Reservations" buttons .

The "Customers..." button brings up a "Customer Management" form, which shows a list of currently registered customers. You may select a customer by clicking in the listbox. Figure 6-25 shows this form after selecting a customer.

Figure 6-25. Customer Management form.

graphics/06fig25.gif

The Id of the selected customer is shown in a textbox. You may unregister this customer by clicking "Unregister." You may change the email address of this customer by clicking "Change Email," which will bring up a dialog box. You may display the information for just this one customer by clicking "One Customer." The "All Customers" button will again show all the customers in the listbox. The "Register" button lets you add a new customer.

The third major form of our user interface is "Hotel Reservations," which is brought up from the main administration form by clicking "Reservations...." To make a reservation, enter the Customer Id, Checkin Date, and Number of Days. You may specify the City and Hotel Name by selecting a hotel from the listbox. To make the reservation, you then simply click the "Make Reservation" button. To show all the reservations for a customer with a particular Customer Id, [8] click "Show Reservations." Figure 6-26 shows this form after the customer whose Id is 1 has made a reservation and we have shown the reservations for this customer.

[8] A Customer Id of -1 will show the reservations for all customers.

Figure 6-26. Hotel Reservations form.

graphics/06fig26.gif

You may clear the reservations listbox by clicking the "Clear Reservations" button. The "Cancel Reservation" will cancel the reservation with a particular Reservation Id, which may either be typed in or selected by clicking in the Reservations listbox.

The Acme Travel Agency case study is used extensively in the following chapters, so you may wish to experiment with it at this point. The graphical user interface makes exercising the case study much easier than our previous command-line interface. On the other hand, the command-line interface and a simple global try block around the whole command loop made it easy to check for all exceptions. Such an approach is not feasible for a GUI program. In an industrial-strength application you should check for exceptions wherever they may occur. Our case study is simplified for instructional purposes, and we have not attempted to be thorough in catching exceptions. Another simplification we made is not checking that a Customer Id used in making a reservation corresponds to a real, registered customer. The database implementation in Chapter 9 does provide such a check.

for RuBoard


Application Development Using C# and .NET
Application Development Using C# and .NET
ISBN: 013093383X
EAN: 2147483647
Year: 2001
Pages: 158

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net