180 likes | 254 Views
IS 8726---Summer 2008. Examples with controls. Using the calendar control to make a very simple appointment book Creating an amortization table. A Few Examples. Display a calendar Click on a date causes display of appointment for that day Only one per day
E N D
IS 8726---Summer 2008 Examples with controls
Using the calendar control to make a very simple appointment book Creating an amortization table IS 8726, Summer 2008, 5/16/2008 A Few Examples
Display a calendar • Click on a date causes display of appointment for that day • Only one per day • User can add an appointment if there is none on that day or change the appointment • Data is saved in a file IS 8726, Summer 2008, 5/16/2008 Appointment Calendar
File structure, loading and saving Internal storage of data Planning event handling The interface IS 8726, Summer 2008, 5/16/2008 Order of ‘Attack’
Use a text file • An appointment will be stored on two lines • The first line is the date • The second line is the text of the appointment • This is not a good structure for processing, but the application won’t process the file other than reading and writing IS 8726, Summer 2008, 5/16/2008 File Structure
The file will be located in the application directory • It will have the name appointments.txt • Saving the file will remove any data in the file • Loading the file will be accomplished by reading a date and an appointment with ReadLine and storing the pair IS 8726, Summer 2008, 5/16/2008 Loading and Saving
The appointments will be stored for use in the program using a HashTable • The date string will be the key • This is possibly a problem due to the different ways dates can be represented • We could, possibly, use a date object • The appointment text will be the value IS 8726, Summer 2008, 5/16/2008 Internal Data Storage
User chooses a date User clicks Add/Change button IS 8726, Summer 2008, 5/16/2008 Event Handling
Display a header identifying the date • States if there is no appointment for that date • Display the text of the appointment if there is one for that date • Display a button with Add or Change • Provide a text box for entering an appointment IS 8726, Summer 2008, 5/16/2008 User Chooses a Date
The appointment is stored in the HashTable The button and text box are hidden The appointment header and message are adjusted The appointment data is saved to disk IS 8726, Summer 2008, 5/16/2008 User Clicks Add/Change Button
A label as a page header • A calendar • Two labels for displaying the appointment data • A label and textbox for entering an appointment • A label displaying the full path name of the appointments file • When stored using a relative path, it was difficult to find it,otherwise IS 8726, Summer 2008, 5/16/2008 The Interface
User enters data for a loan A table of the interest paid and the loan balance is displayed IS 8726, Summer 2008, 5/16/2008 Amortization Table
Balance Interest owed for month Payment for month New balance There are formulas, but we won’t need them IS 8726, Summer 2008, 5/16/2008 Theory of Compound Interest
How to create a table programmatically Using a loop to create the rows of the table Setting class attribute dynamically for negative values IS 8726, Summer 2008, 5/16/2008 Design
Area for data entry • Styling to make it look better? • Header for the table and an empty table element IS 8726, Summer 2008, 5/16/2008 The Web Page
Classes involved • Table • TableRow • TableCell • Collections • table.Rows • row.Cells IS 8726, Summer 2008, 5/16/2008 CREATING A Table Programmatically
Step through each month Compute interest and new balance Create a new row of the table and add to the table IS 8726, Summer 2008, 5/16/2008 Main Processing loop
Using cssclass to note negative cells Using cssclass to note header cells IS 8726, Summer 2008, 5/16/2008 Setting Styles