Visual Studio'NET 2005 Using RAD Tools for NTier Development - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Visual Studio'NET 2005 Using RAD Tools for NTier Development

Description:

Data Access Layer. TableAdapter is a new class ideal for creating DAL components ... We will extend the Data Access Layer to provide BLL layer ... – PowerPoint PPT presentation

Number of Views:51
Avg rating:3.0/5.0
Slides: 27
Provided by: cnydeve
Category:

less

Transcript and Presenter's Notes

Title: Visual Studio'NET 2005 Using RAD Tools for NTier Development


1
Visual Studio.NET 2005Using RAD Tools for N-Tier
Development
  • Andy Beaulieu
  • MCT, MCSD.NET

2
Drag/Drop Apps?
  • Demo
  • Using Server Explorer
  • Drag/Drop Table onto Page
  • Use Smart Tag for Formatting
  • No code is generated instead, everything is
    declarative

3
Drag/Drop Apps?
  • Looking at the source view

4
Pros and Cons
  • Pros
  • Very fast
  • Little coding knowledge required
  • Cons
  • Easy to break (no validation)
  • 2Tier Architecture
  • No reusability
  • Limited functionality (at some point, you have to
    code).

5
N-Tier Architecture
  • With a bit more work, we can still use RAD tools
    but get an N-Tier Architecture.
  • N-Tier provides reusability, scalability,
    maintainability.

6
N-Tier Architecture
7
Data Access Layer
  • Provides Programmer Friendly components for
    retrieving and updating data
  • Developer is freed from writing mundane and
    error-prone ADO.NET code
  • Instead can concentrate on Business Logic

8
Data Access Layer
  • TableAdapter is a new class ideal for creating
    DAL components
  • Exists within context of a Typed DataSet
  • Contains DB Connection logic, Select, Insert,
    Update, Delete commands.

9
Data Access Layer
  • DEMO Using VS.NET 2005 Designers to create a DAL
    component (Typed DataSet TableAdapter)

10
Data Access Layer
  • Note on WindowsForms Clients
  • WindowsForms clients can take advantage of
    DataSet events for validation!
  • Provides strongly typed row argument
  • Not usable from ASP.NET client using
    ObjectDataSource

11
Business Logic Layer
  • provides validation and workflow
  • We will extend the Data Access Layer to provide
    BLL layer
  • New ObjectDataSource component allows data
    binding between UI and BLL components

12
Business Logic Layer
  • If we want to use ObjectDataSource component for
    data binding, we must follow some rules

13
Business Logic LayerRules for ObjectDataSource
  • select methods must return a DataSet, Typed
    DataSet, IEnumerable implementation, Collection,
    or Array.
  • Public Function GetCustomers() As DataSet
  • Public Function GetCustomers() As
    CustomerDataSet
  • Public Function GetCustomers() As
    CustomerCollection

14
Business Logic LayerRules for ObjectDataSource
  • Insert, update, delete methods must take each
    field as individual parameters, or a single
    object containing fields as properties
  • Public Sub Update(ByVal CustomerId As String, _
  • ByVal CompanyName As String, _ByVal Address As
    String, ByVal City As String)
  • Public Sub Update(ByVal oCustomersBLL As
    CustomersBLL)

15
Business Logic Layer
  • Good NewsThe TableAdapter conforms to the
    requirements of the ObjectDataSource control!
  • This means we can extend the TableAdapter control
    to add our own customizations such as validation

16
Business Logic Layer
  • DEMO Creating the Business Logic Layer Component

17
Presentation LayerWeb UI
  • User interface
  • Input and validation
  • ObjectDataSource can be used to bind UI Elements
    to Business Logic Layer components

18
Presentation LayerWeb UI
  • DEMO Creating an input page using the GridView,
    ObjectDataSource, and BLL Component

19
Adding ValidationWeb UI
  • GridView class exposes a RowUpdated event which
    is fired whenever a row is updated
  • Protected Sub GridView1_RowUpdated(ByVal sender
    As Object, ByVal e As System.Web.UI.WebControls.Gr
    idViewUpdatedEventArgs) Handles
    GridView1.RowUpdated

20
Adding ValidationWeb UI
  • RowUpdated Event e.Exception argument will
    contain any errors raised from the update
  • Protected Sub GridView1_RowUpdated(ByVal sender
    As Object, ByVal e As System.Web.UI.WebControls.Gr
    idViewUpdatedEventArgs) Handles
    GridView1.RowUpdated
  • If Not e.Exception Is Nothing Then

21
Adding ValidationWeb UI
  • We can create a Custom Exception Class to raise
    Validation errors through the ObjectDataSource
    components Update Event.
  • CExceptionDetail will hold single error
  • CValidationException inherits from
    ApplicationException and holds List of
    CExceptionDetail.

22
Adding ValidationWeb UI
  • DEMO Adding Validation to the Web UI

23
Presentation LayerWinForms UI
  • We can reuse Business Logic Layer in WinForms
    Client
  • Why WinForms?
  • Smart Client
  • WinForms are statefull
  • Better DataBinding support
  • Easy Distribution
  • Web Browsers Suck!!!

24
Presentation LayerWinForms UI
  • DEMO Creating the Windows UI

25
Adding ValidationWinForms UI
  • DEMO Adding Validation to WinForms

26
A Quick word about Transactions
  • For Web UIs, look at Transaction Attribute on
    Page
  • For WinForms UIs, look at new System.Transactions
    .TransactionScope
  • Ideally, should Introduce Business Façade Layer
    for Winforms
Write a Comment
User Comments (0)
About PowerShow.com