Object-Oriented Application Development Using VB.NET 1 Chapter 11 Using Multiple Forms with Problem Domain Classes.

Slides:



Advertisements
Similar presentations
Microsoft Visual Basic: Reloaded Chapter Seven More on the Repetition Structure.
Advertisements

Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
Guide to Oracle10G1 Introduction To Forms Builder Chapter 5.
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Automating Tasks With Macros
A Guide to Oracle9i1 Introduction To Forms Builder Chapter 5.
Object-Oriented Application Development Using VB.NET 1 Chapter 13 Introduction to Data Access Classes and Persistence.
Object-Oriented Application Development Using VB.NET 1 Creating a String Array Code to create a String array: ' declare a String array with 4 elements.
A Guide to Oracle9i1 Creating an Integrated Database Application Chapter 8.
Eyad Alshareef 1 Creating Custom Forms Part A. 2Eyad Alshareef Data Block and Custom Forms Data block form Data block form Based on data blocks that are.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 13: Advanced GUI and Graphics
Chapter 13: Object-Oriented Programming
Chapter 14: Advanced Topics: DBMS, SQL, and ASP.NET
Object-Oriented Application Development Using VB.NET 1 Chapter 9 Implementing Association Relationships.
Object-Oriented Application Development Using VB.NET 1 Chapter 8 Understanding Inheritance and Interfaces.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Lesson 8 Creating Forms with JavaScript
CST JavaScript Validating Form Data with JavaScript.
Chapter 9 Collecting Data with Forms. A form on a web page consists of form objects such as text boxes or radio buttons into which users type information.
8 Copyright © 2004, Oracle. All rights reserved. Creating LOVs and Editors.
Chapter 6: Forms JavaScript - Introductory. Previewing the Product Registration Form.
Microsoft Visual Basic 2005: Reloaded Second Edition
XHTML Introductory1 Forms Chapter 7. XHTML Introductory2 Objectives In this chapter, you will: Study elements Learn about input fields Use the element.
Programming with Microsoft Visual Basic 2012 Chapter 12: Web Applications.
Chapter 5 - Writing a Problem Domain Class Definition1 Chapter 5 Writing a Problem Domain Class Definition.
Microsoft Visual Basic 2008 CHAPTER NINE Using Arrays and File Handling.
1 Web-Enabled Decision Support Systems Objects and Procedures Don McLaughlin IE 423 Design of Decision Support Systems (304)
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Chapter 8: Writing Graphical User Interfaces
Java Software Solutions Lewis and Loftus Chapter 10 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Graphical User Interfaces --
Chapter 8: Writing Graphical User Interfaces Visual Basic.NET Programming: From Problem Analysis to Program Design.
Tutorial 111 The Visual Studio.NET Environment The major differences between Visual Basic 6.0 and Visual Basic.NET are the latter’s support for true object-oriented.
An Introduction to Java Chapter 11 Object-Oriented Application Development: Part I.
Visual Basic.NET Comprehensive Concepts and Techniques Chapter 7 Using Menus, Common Dialogs, Procedures, Functions, and Arrays.
JavaScript, Fourth Edition Chapter 5 Validating Form Data with JavaScript.
 Whether using paper forms or forms on the web, forms are used for gathering information. User enter information into designated areas, or fields. Forms.
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
Systems Analysis and Design in a Changing World, 3rd Edition
Chapter 14 - Designing Data Access Classes1 Chapter 14 Designing Data Access Classes.
Chapter 12 - Designing Multiwindow Applications1 Chapter 12 Designing Multiwindow Applications 12.
Chapter 5: More on the Selection Structure Programming with Microsoft Visual Basic 2005, Third Edition.
Object-Oriented Application Development Using VB.NET 1 Chapter 6 Writing a Problem Domain Class Definition.
Object-Oriented Application Development Using VB.NET 1 Chapter 6 Writing a Problem Domain Class Definition.
Creating Graphical User Interfaces (GUI’s) with MATLAB By Jeffrey A. Webb OSU Gateway Coalition Member.
1 Creating Windows GUIs with Visual Studio. 2 Creating the Project New Project Visual C++ Projects Windows Forms Application Give the Project a Name and.
MATLAB for Engineers 4E, by Holly Moore. © 2014 Pearson Education, Inc., Upper Saddle River, NJ. All rights reserved. This material is protected by Copyright.
1.
Chapter Fourteen Access Databases and SQL Programming with Microsoft Visual Basic th Edition.
Object-Oriented Application Development Using VB.NET 1 Chapter 10 VB.NET GUI Components Overview.
Chapter 11 - A GUI Interacting With a Problem Domain Class1 Chapter 11 A GUI Interacting With a Problem Domain Class 11.
Object-Oriented Application Development Using VB.NET 1 Chapter 5 Object-Oriented Analysis and Design.
Chapter 27 Getting “Web-ified” (Web Applications) Clearly Visual Basic: Programming with Visual Basic nd Edition.
Object-Oriented Programming: Inheritance and Polymorphism.
Object-Oriented Application Development Using VB.NET 1 Chapter 13 Introduction to Data Access Classes and Persistence.
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 19 A Ray of Sunshine.
Object-Oriented Application Development Using VB.NET 1 Chapter 15 Assembling a Three-Tier Windows Application.
Programming with Microsoft Visual Basic 2012 Chapter 14: Access Databases and SQL.
IS444: Modern tools for applications development
IS444: Modern tools for applications development
Chap 7. Building Java Graphical User Interfaces
Graphical User Interfaces -- Introduction
Tutorial 19 - Microwave Oven Application Building Your Own Classes and Objects Outline Test-Driving the Microwave Oven Application Designing.
CIS16 Application Development Programming with Visual Basic
Creating More Complex Database Applications
Object-Oriented Programming: Inheritance and Polymorphism
Presentation transcript:

Object-Oriented Application Development Using VB.NET 1 Chapter 11 Using Multiple Forms with Problem Domain Classes

Object-Oriented Application Development Using VB.NET 2 Objectives In this chapter, you will: Develop a GUI class that interacts with a PD class Simulate interaction with a database Develop a GUI class that interacts with multiple PD classes Navigate multiple forms in an integrated system Develop a GUI class that navigates a PD association relationship

Object-Oriented Application Development Using VB.NET 3 Developing a GUI Class that Interacts with a PD Class AddCustomer –A GUI class –Used to Input customer attribute values Create instances of the Customer class

Object-Oriented Application Development Using VB.NET 4 Developing a GUI Class that Interacts with a PD Class GUI form for adding a new customer contains: –A label For the Bradshaw Marina logo –Three text boxes txtName: to input customer name txtAddress: to input customer address txtPhone : to input customer phone number –Three labels To identify the text boxes

Object-Oriented Application Development Using VB.NET 5 Developing a GUI Class that Interacts with a PD Class GUI form for adding a new customer contains (Continued) –Three buttons btnAdd: adds a new customer after the data has been entered btnClear: clears the text boxes btnClose: closes the form and terminates processing

Object-Oriented Application Development Using VB.NET 6 Adding Variables to the Generated Code Variables needed to respond to events –Not generated by the visual programming process –Must be added to the source code through the Code Editor window –Often declared with class scope

Object-Oriented Application Development Using VB.NET 7 Adding Variables to the Generated Code Variables needed for this example –A Customer reference To create a new Customer instance from the data entered by the user –Three String variables To contain the customer data that is retrieved from the text boxes

Object-Oriented Application Development Using VB.NET 8 Handling Events Push buttons on the form –btnAdd_Click Event: add a customer –btnClear_Click Event: clear the form –btnClose_Click Event: close the form Event handling methods –btnAdd.Click –btnClear.Click –btnClose.Click

Object-Oriented Application Development Using VB.NET 9 Handling Events btnClear_Click method –Calls the ClearForm method, which Stores an empty string in each of the text boxes Invokes the Focus method for the txtName control –Focus method »Positions the cursor within the Name text box »Sets the input focus to this control btnClose_Click method –Closes the form

Object-Oriented Application Development Using VB.NET 10 Handling Events btnAdd_Click method –Retrieves the data from the text boxes –Validates values for name, address, and phone If any of the values are missing, a message box prompts the user to enter all of the required data If all three data items are entered –A Customer instance is created –A “Customer Added” message box is displayed –The form is cleared

Object-Oriented Application Development Using VB.NET 11 Simulating Interaction with a Database FindCustomer class –Used to find a customer and then display related information –Simulates interaction with a database

Object-Oriented Application Development Using VB.NET 12 Simulating Interaction with a Database The form to find a customer includes : –A customer list box lstCustomer –Two text boxes txtCustomerAddress txtCustomerPhone –Three buttons btnFind btnUpdate btnClose –A label for the Bradshaw Marina logo lblLogo

Object-Oriented Application Development Using VB.NET 13 Simulating Interaction with a Database

Object-Oriented Application Development Using VB.NET 14 Creating an Array List of Customers FindCustomer simulates interaction with a database by –Creating six Customer instances –Populating an array list with Customer references ArrayList class –A member of the System.Collections namespace –Creates an array list, which Works like an array Is dynamic rather than fixed in size –Add method: appends an element to the end of an array list

Object-Oriented Application Development Using VB.NET 15 Creating an Array List of Customers CreateCustomers method –Adds Customer instances to the array list –Invoked by the PopulateListBox method PopulateListBox method –Uses Customer instances to add customer names to the list box –Invoked from within the constructor of the FindCustomer class

Object-Oriented Application Development Using VB.NET 16 Handling Events btnFind_Click method –Invoked when the user clicks the Find button –Purpose Determine which customer name is selected on the list box Retrieve and display that customer’s address and phone number

Object-Oriented Application Development Using VB.NET 17 Handling Events btnUpdate_Click method –Invoked when the user clicks the Update button –Purpose: Allow the user to change a customer’s address and phone number btnClose_Click method –Invoked when the user clicks the Close button –Purpose Closes the form

Object-Oriented Application Development Using VB.NET 18 Developing a GUI Class That Interacts with Multiple PD Classes AddBoat class –A GUI class used to add a new boat to the Bradshaw system –Interact with the Boat, Sailboat, and Powerboat classes to create instances of each type of boat

Object-Oriented Application Development Using VB.NET 19 Developing a GUI Class That Interacts with Multiple PD Classes

Object-Oriented Application Development Using VB.NET 20 Developing a GUI Class That Interacts with Multiple PD Classes

Object-Oriented Application Development Using VB.NET 21 Developing a GUI Class That Interacts with Multiple PD Classes AddBoat GUI form –Upper portion Labels and text boxes to input the four attribute values for Boat

Object-Oriented Application Development Using VB.NET 22 Developing a GUI Class That Interacts with Multiple PD Classes AddBoat GUI form –Middle portion Two radio buttons (radSailboat and radPowerboat) Two panel instances (pnlSailboat and pnlPowerboat) User must select either the Sailboat or the Powerboat radio button –If the Sailboat button is selected, pnlSailboat displays (shown in Figure 11-4) –If the Powerboat button is selected, pnlPowerboat displays (shown in Figure 11-5)

Object-Oriented Application Development Using VB.NET 23 Developing a GUI Class That Interacts with Multiple PD Classes

Object-Oriented Application Development Using VB.NET 24 Handling Events radSailboat_CheckedChanged method –Determines whether the radSailboat button is checked; if so Powerboat panel is hidden Sailboat panel is displayed radPowerboat_CheckedChanged method –Determines whether the radPowerboat button is checked; if so Sailboat panel is hidden Powerboat panel is displayed

Object-Oriented Application Development Using VB.NET 25 Writing the ClearForm Method btnClear_Click event handling method –Invokes the ClearForm method ClearForm method –Blanks out all of the text boxes by storing empty string in them –Sets the checked status of radio buttons used within the form back to their default values –Sets the focus to the Manufacturer text box

Object-Oriented Application Development Using VB.NET 26 Writing the btnAdd_Click Method btnAdd_Click method –Retrieves the manufacturer, length, year, and registration information from text boxes –Performs simple data validation of the information –Invokes either AddSailboat or AddPowerboat, depending on which radio button is selected

Object-Oriented Application Development Using VB.NET 27 Writing the btnAdd_Click Method AddSailboat method –Receives the registration, length, manufacturer, and year into parameter variables –Retrieves the number of sails and keel depth from the text boxes –Displays an error message box if the data is not valid –Converts the values for sails and keel depth to numeric data

Object-Oriented Application Development Using VB.NET 28 Writing the btnAdd_Click Method AddSailboat method (Continued) –Determines which of the three motor type radio buttons is selected The appropriate value is placed into motorType –A new Sailboat instance is created –A “Sailboat Added” message is displayed in a message box

Object-Oriented Application Development Using VB.NET 29 Writing the btnAdd_Click Method AddPowerboat method –Similar to AddSailboat, except: Number of engines is retrieved There are only two radio buttons to test: –radGasoline –radDiesel

Object-Oriented Application Development Using VB.NET 30 Navigating Multiple Forms in an Integrated System: Simulating a Data Access Class OO systems –Employ a three-tier design consisting of GUI classes: provide a graphical interface for the input and display of data PD classes: model the business entities and processes DA classes: provide data storage and retrieval services –Advantage of three-tier design Classes in each tier can be independent of those in another

Object-Oriented Application Development Using VB.NET 31 Simulating a Data Access Class DA methods –Invoked by GUI classes which are unaware of their implementation –Can later be used with a real database management system without changing the GUI classes CustomerData class –Contains DA methods –Uses an array list to simulate the database

Object-Oriented Application Development Using VB.NET 32 Simulating a Data Access Class DA methods of the CustomerData class: –Initialize Performs initialization tasks –GetAll Retrieves references to all instances of the Customer class that are stored in the database –AddNew Stores a reference to a new Customer instance into the database –Update Replaces a reference to a particular Customer instance with a reference to a new Customer instance

Object-Oriented Application Development Using VB.NET 33 Integrating Multiple Forms Forms of the Integrated system –Main menu Appears when the system starts –AddCustomer –FindCustomer Users navigate to other forms by clicking buttons on the main menu

Object-Oriented Application Development Using VB.NET 34 Integrating Multiple Forms

Object-Oriented Application Development Using VB.NET 35 Designing the Main Menu Main menu form –Integrates the forms –Serves as the startup object for the entire project –Contains three buttons btnAdd btnFind btnClose

Object-Oriented Application Development Using VB.NET 36 Designing the Main Menu Main menu methods –btnClose_Click method Closes the form –btnAdd_Click method Hides the main menu form Instantiates the AddCustomer GUI form Displays the AddCustomer GUI form by invoking the ShowDialog method

Object-Oriented Application Development Using VB.NET 37 Designing the Main Menu Main menu methods (Continued) –btnFind_Click method Hides the main menu form Instantiates the FindCustomer GUI form Displays the FindCustomer GUI form by invoking the ShowDialog method –Initialize method Invoked from within the constructor of the MainMenu class

Object-Oriented Application Development Using VB.NET 38 Developing a GUI class that Navigates a PD Association Relationship Customer and Boat have a one-to-one association –Customer has a reference attribute for Boat –Boat has a reference attribute for Customer –The Boat instance method AssignBoatToCustomer populates both attributes

Object-Oriented Application Development Using VB.NET 39 Developing a GUI class that Navigates a PD Association Relationship

Object-Oriented Application Development Using VB.NET 40 Understanding the CustomerAndBoatData Class CustomerAndBoatData class –Simulates a database that contains both customer and boat information –Initialize method invokes two procedures InitializeCustomer –Creates six Customer instances InitializeBoat: –Creates six Boat instances: three sailboats and three powerboats –Invokes the AssignBoatToCustomer method of the Boat class to link each boat to a customer

Object-Oriented Application Development Using VB.NET 41 Understanding the CustomerAndBoatData Class CustomerAndBoatData class (Continued) –GetAll method Returns a reference to an array list containing the Customer references –Update methods Modifies the attributes of a particular customer in the array list

Object-Oriented Application Development Using VB.NET 42 Understanding the CustomerAndBoatData Class CustomerAndBoatData class (Continued) –AddNewBoat method Adds a Customer reference to the customer array list Adds a reference to the customer’s boat to the boat array list

Object-Oriented Application Development Using VB.NET 43 Designing the GUI Sequence

Object-Oriented Application Development Using VB.NET 44 Designing the GUI Sequence GUI sequence to add a new customer and boat –In main menu, click the Add Customer and Boat button –AddCustomer form is displayed –Enter the customer’s name, address, and phone number –Click the Add Boat button –AddBoat form is displayed –Enter the boat information –Click the Add Customer and Boat button –Message “Customer and Boat Added” appears

Object-Oriented Application Development Using VB.NET 45 Finding a Customer and Boat Customers and their boats are linked with an association relationship FindCustomer class –Used to display the customer and boat information together

Object-Oriented Application Development Using VB.NET 46 Summary ArrayList class is similar to an array but is dynamic rather than fixed in size You can simulate interaction with a database by using one or more array lists You can use panels and radio buttons to dynamically change the appearance of a form in response to user-generated events A main menu has push buttons that launch other GUIs to accomplish various tasks

Object-Oriented Application Development Using VB.NET 47 Summary A GUI class can be designed to add customers and their boats together by linking the AddCustomer GUI to the AddBoat GUI A single GUI class can be used to find a customer, display customer data, and display the customer’s boat information using the association relationship between the Customer and Boat classes