Session 08: Architecture Controllers or Managers Graphical User Interface (GUI) FEN 2013-04-141AK - IT Softwarekonstruktion.

Slides:



Advertisements
Similar presentations
CS0004: Introduction to Programming Visual Studio 2010 and Controls.
Advertisements

 2007 Dr. Natheer Khasawneh. Chapter 13. Graphical User Interface Concepts: Part 1.
11 Getting Started with ASP.NET Beginning ASP.NET 4.0 in C# 2010 Chapters 5 and 6.
Object-Oriented Design Patterns Composite Singleton State Observer … Autumn 2012UCN Technology: IT/Computer Science1.
Chapter 18 - Data sources and datasets 1 Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Advanced Object-Oriented Programming Features
Copyright © 2012 Pearson Education, Inc. Chapter 2 Introduction to Visual C#
Creating web service (and client application) with Visual Studio 2008 Create web service project New project->web->ASP.NET web service application (with.
1 Web Services Visual C# 2008 Step by Step Chapter 30.
Programming Paradigms Imperative programming Functional programming Logic programming Event-driven programming Object-oriented programming A programming.
Microsoft Visual Basic 2005 CHAPTER 8 Using Procedures and Exception Handling.
ASP.Net, Web Forms and Web Controls 1 Outline Introduction Simple HTTP Transaction System Architecture Creating and Running a Simple Web Form Example Web.
Visual Basic 2008 Express Edition The IDE. Visual Basic 2008 Express The Start Page Recent Projects Open an existing project Create a New Project.
Tutorial: Introduction to ASP.NET Internet Technologies and Web Application 4 th February 2010.
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College
Introduction to Graphical User Interfaces. Objectives * Students should understand what a procedural program is. * Students should understand what an.
Computer Programming and Basic Software Engineering 9 Building Graphical User Interface Working with Unmanaged Code.
Microsoft Visual Basic 2008 CHAPTER 8 Using Procedures and Exception Handling.
ASP.Net Web Applications. Characteristics of a typical data driven web application Web Server HTML Graphics Active-X Java Applets HTTP Request ADO / JDBC.
Department of Mechanical Engineering, LSUSession VII MATLAB Tutorials Session VIII Graphical User Interface using MATLAB Rajeev Madazhy
Introduction to Visual Basic. Quick Links Windows Application Programming Event-Driven Application Becoming familiar with VB Control Objects Saving and.
CSCI 3328 Object Oriented Programming in C# Chapter 2: Introduction to Visual C# Programming 1 Xiang Lian The University of Texas Rio Grande Valley Edinburg,
Multiple Forms, Container Controls, AddHandler This presentation is based on the Forms and ContainerControls VB Projects 1.
Web Programming: Client/Server Applications Server sends the web pages to the client. –built into Visual Studio for development purposes Client displays.
Web Services Week 2 Aims: Getting started with creating simple C# applications within Visual Studio.NET Objectives: –An introduction to the syntax of C#.NET.
Chapter 3: Using GUI Objects and the Visual Studio IDE.
11 Web Services. 22 Objectives You will be able to Say what a web service is. Write and deploy a simple web service. Test a simple web service. Write.
CSCI 6962: Server-side Design and Programming Introduction to Active Server Pages.
Architectures Classic Client/Server Architecture Classic Web Architecture N-tier (multi-tier) Architecture FEN Databaser og Modellering.
Sample Application Multi Layered Architecture (n-tier): –Graphical User Interface (GUI): Forms, components, controls The Visual Designer in Visual Studio.
1 Chapter Eleven Handling Events. 2 Objectives Learn about delegates How to create composed delegates How to handle events How to use the built-in EventHandler.
An Example of Windows Forms Applications Windows-based application –Win Forms Control structures (selection and repetition) Graphics Read integers from.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
Controls. Adding Controls to Form -You can pick controls from the toolbox. -To add the controls from Toolbox to the Form You have be in design view. -To.
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.
Visual C# 2012 How to Program © by Pearson Education, Inc. All Rights Reserved.
1 Chapter 20 – Data sources and datasets Outline How to create a data source How to use a data source How to use Query Builder to build a simple query.
Session 04: C# OOP 2 OOP in C#: Object-Oriented Design.
CSC 157 (Blum)1 Hello World. CSC 157 (Blum)2 Start/Programs/Microsoft Visual Studio.NET 2003/Microsoft Visual Studio.NET 2003.
Copyright © 2010 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Starting Out with Programming Logic & Design Second Edition by Tony Gaddis.
Session 02 and 03: C# OOP 1 OOP in C#: Classes and Objects in C#. Object-Oriented Design. UML Class Diagram. Object Interaction. FEN AK IT:
Presented by Vishy Grandhi.  Architecture (Week 1) ◦ Development Environments ◦ Model driven architecture ◦ Licensing and configuration  AOT (Week 2)
Module 4: Creating a Web Application with Web Forms
Microsoft Visual Basic 2008: Reloaded Third Edition Chapter One An Introduction to Visual Basic 2008.
Architecture Multi Layered Architecture (n-tier): Application: Model Controllers Database Access Graphical User Interface (GUI): Forms, components, controls.
Using ADO.Net to Build a Login System Dr. Ron Eaglin.
Lecture Set 7 Procedures and Event Handlers Part B - The Structure of an Application Event Handlers.
Graphical User Interface Components Version 1.1. Obectives Students should understand how to use these basic Form components to create a Graphical User.
User Interface Programming in C#: Basics and Events Chris North CS 3724: HCI.
Microsoft Visual C# 2010 Fourth Edition Chapter 3 Using GUI Objects and the Visual Studio IDE.
Microsoft Visual Basic 2012: Reloaded Fifth Edition Chapter One An Introduction to Visual Basic 2012.
111 State Management Beginning ASP.NET in C# and VB Chapter 4 Pages
Computing with C# and the .NET Framework
Computing with C# and the .NET Framework
CSCI 3328 Object Oriented Programming in C# Chapter 2: Introduction to Visual C# Programming UTPA – Fall 2012 This set of slides is revised from lecture.
3.01 Apply Controls Associated With Visual Studio Form
Chapter Eleven Handling Events.
Visual programming Chapter 1: Introduction
3.01 Apply Controls Associated With Visual Studio Form
Using Procedures and Exception Handling
Web Development in Microsoft Visual Studio 2013
Social Media And Global Computing Introduction to Visual Studio
Understanding the Visual IDE
The University of Texas – Pan American
CIS16 Application Development Programming with Visual Basic
Module 10: Creating a Web Application with Web Forms
Chapter 15: GUI Applications & Event-Driven Programming
Overview of the IDE Visual Studio .NET is Microsoft’s Integrated Development Environment (IDE) for creating, running and debugging programs (also.
GUI Programming in Visual Studio .NET
Presentation transcript:

Session 08: Architecture Controllers or Managers Graphical User Interface (GUI) FEN AK - IT Softwarekonstruktion

N-tier (multi-tier) Architecture Web Server Browser Client Internet Dedicated Client Database access layer: All code to access database is here. Makes it possible to change data store. Web server accesses application layer – not the database directly. Easier maintenance: No business logic in the web server (or other clients). Application server: All (almost) business logic is re- used. New client may be added without code duplication. DB Database Server Application Server Database Access Layer Backend Mobile Client Client accessing web services FEN AK - IT Softwarekonstruktion New Dedicated Client

Controller Object So far we have had our business logic and “user interface” in the Main method This obviously not a good design! Normally one will used what is known as a layered ( or n tier) architecture, for instance: –UI –Controller –Model –Database FEN AK - IT Softwarekonstruktion3 Application For now we focus on the application layer

More Banking View Code (Banking4View Code (Banking4) FEN AK - IT Softwarekonstruktion4

Design This design is based on the fact that accounts normally are accessed from Customer. (Hence the complicated and inefficient implementation of GetAllOwners). FEN AK - IT Softwarekonstruktion5

Exercises Exercises 1- 3 on Session08.docx.Session08.docx Extra : 4 – 6 on Session08.docxSession08.docx FEN AK - IT Softwarekonstruktion6

Remember Banking4 ? View Code (Banking4View Code (Banking4) FEN UCN T&B: IT Technology7

Banking4 with GUI (Banking5) View Code (Banking4GUI)Banking4GUI FEN UCN T&B: IT Technology8

How to Create a GUI for an Existing Project Firstly you must have a working project with model and controller, for instance Banking4. First step is to create a new solution in Visual Studio: FEN UCN T&B: IT Technology9 It must be a “Windows Form Application” Give it a good name. And choose a location for it.

How to Create a GUI for an Existing Project FEN UCN T&B: IT Technology10 New Form in VS Toolbox. Here you find GUI components Properties. Here you can edit components. For instance give the form a good name

How to Create a GUI for an Existing Project Right click on the solution. Choose ‘Add’ and ‘Existing Project’. Locate the project you want to add the GUI to: FEN UCN T&B: IT Technology11 Here is the project file for ‘Banking4’ Choose that.

How to Create a GUI for an Existing Project Now ‘Banking4’ shows in the Solution Explorer in Visual Studio: FEN UCN T&B: IT Technology12

How to Create a GUI for an Existing Project Next we want to make the project (‘Banking4’) known to our GUI project: You must use the namespace of Banking4: Right click on the form and choose ‘View Code’ Type this using: FEN UCN T&B: IT Technology13 But the compiler doesn’t recognises it? Right click on ‘References’ for the GUI project in the Solution Explorer and choose ‘Add Reference’

How to Create a GUI for an Existing Project FEN UCN T&B: IT Technology14 Choose the project tab. Choose the project you want – Banking4...and ‘OK’ Now the compiler recognises ‘Banking4’ namespace and we are ready.

Using the Existing Project Right click on the form, choose ‘View Code’, and now we can write code, for instance get an instance of the controller: namespace Bank4WithGUI { public partial class Form1 : Form { private BankCtr myBank = BankCtr.GetInstance(); public Form1() { InitializeComponent(); } FEN UCN T&B: IT Technology15 Now myBank can be used in the form, and we are able to communicate with the Banking4 application.

Adding Components and Controls to the Form Drag- and-drop. FEN UCN T&B: IT Technology16 Label ToolStrip TextBox Button You may change the properties of components

Adding Code Test data is added by the constructor. New method added by me. FEN UCN T&B: IT Technology17 //--- public Form1() //Constructor { CreateTestData();//my method InitializeComponent(); } //--- private void CreateTestData() { Customer c = new Customer(1, "Peter Thomsen"); myBank.AddCustomer(c); myBank.AddCustomer(new Customer(2, "Ib Helmer")); BankAccount acc1 = new BankAccount(1, 8, 100); BankAccount acc2 = new BankAccount(2, 0.25, 0); BankAccount acc3 = new BankAccount(3, 5, 1000); c = myBank.GetCustomer(1); c.AddAccount(acc1); c.AddAccount(acc2); c.AddAccount(acc3); c = myBank.GetCustomer(2); c.AddAccount(acc2); }

Getting some Action Double click on the Find Customer Button and you get an empty event handler method for the button. This method is executed when the button is clicked. Type in the code for the actions that you want. FEN UCN T&B: IT Technology18 //--- private void button1_Click(object sender, EventArgs e) { } { string input = this.textBox1.Text; int custNo = Convert.ToInt32(input); //no error handling Customer c = myBank.GetCustomer(custNo); this.textBox2.Text = c.Name; }

Getting some Action Components are objects and may used like any other objects. FEN UCN T&B: IT Technology19 private void button1_Click(object sender, EventArgs e) { string input = this.textBox1.Text; int custNo = Convert.ToInt32(input); //no error handling Customer c = myBank.GetCustomer(custNo); this.textBox2.Text = c.Name; } Use ‘this’ and the IntelliSense to find variable names of components and properties of components.

Error Handling - Exceptions If, what is entered here, not is a valid and existing customer number; some exception (NumberFormat or NullPointer) will make the program crash. FEN UCN T&B: IT Technology20 private void button1_Click(object sender, EventArgs e) { string input = this.textBox1.Text; int custNo = Convert.ToInt32(input); //no error handling Customer c = myBank.GetCustomer(custNo); this.textBox2.Text = c.Name; }

Error Handling - Exceptions We want to catch and handle that exception. That is done by enclosing the code in a try-block. After that we have a catch-block where we handle the exception. FEN UCN T&B: IT Technology21 private void button1_Click(object sender, EventArgs e) { string inString = textBox1.Text; try { int custNo = Convert.ToInt32(inString); c = bankCtr.GetCustomer(custNo); textBox2.Text = c.Name; } catch (Exception excep) { MessageBox.Show("Customer number must be an integer"); } Investigate Banking4GUIBanking4GUI

Exercises Exercises 7 on Session08.docx.Session08.docx Extra : 8 on Session08.docxSession08.docx FEN AK - IT Softwarekonstruktion22