1.結構概述
Duwamish 7.0 結構分為四個邏輯層:
Web 層
Web 層為用戶端提供對應用程式的訪問。這一層是作為 Duwamish.sln 解決方案檔案中的 Web 項目實現的。Web 層由 ASP.NET Web Form和程式碼後置檔案組成。Web Form只是用 HTML 提供使用者操作,而程式碼後置檔案實現各種控制項的事件處理。
業務外觀層
業務外觀層為 Web 層提供處理帳戶、類別瀏覽和購書的介面。這一層是作為 Duwamish.sln 解決方案檔案中的 BusinessFacade 項目實現的。業務外觀層用作隔離層,它將使用者介面與各種業務功能的實現隔離開來。除了低級系統和支援功能之外,對資料庫伺服器的所有調用都是通過此程式集進行的。
//----------------------------------------------------------------
// Copyright (C) 2000-2001 Microsoft Corporation
// All rights reserved.
//
// This source code is intended only as a supplement to Microsoft
// Development Tools and/or on-line documentation. See these other
// materials for detailed information regarding Microsoft code samples.
//
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR
// FITNESS FOR A PARTICULAR PURPOSE.
//----------------------------------------------------------------
namespace Duwamish7.Common.Data
{
using System;
using System.Data;
using System.Runtime.Serialization;
/// <summary>
/// A custom serializable dataset containing customer information.
/// <remarks>
/// This class is used to define the shape of CustomerData.
/// </remarks>
/// <remarks>
/// The serializale constructor allows objects of type CustomerData to be remoted.
/// </remarks>
/// </summary>
[SerializableAttribute]
public class CustomerData : DataSet
{
//
//Customer constants
//
/// <value>The constant used for Customers table. </value>
public const String CUSTOMERS_TABLE = "Customers";
/// <value>The constant used for Email field in the Customers table. </value>
public const String EMAIL_FIELD = "Email";
/// <value>The constant used for Name field in the Customers table. </value>
public const String NAME_FIELD = "Name";
/// <value>The constant used for Address field in the Customers table. </value>
public const String ADDRESS_FIELD = "Address";
/// <value>The constant used for Country field in the Customers table. </value>
public const String COUNTRY_FIELD = "Country";
/// <value>The constant used for Password field in the Customers table. </value>
public const String PASSWORD_FIELD = "Password";
/// <value>The constant used for PhoneNumber field in the Customers table. </value>
public const String PHONE_FIELD = "PhoneNumber";
/// <value>The constant used for Fax field in the Customers table. </value>
public const String FAX_FIELD = "Fax";
/// <value>The constant used for PKId field in the Customers table. </value>
public const String PKID_FIELD = "PKId";
//
// Error messages
//
/// <value>The constant used for row error when 'Email Not Unique' field in CustomerData. </value>
public const String EMAIL_FIELD_NOT_UNIQUE = "Email Not Unique";
/// <value>The constant used for row error when 'Email Invalid Format' field in CustomerData. </value>
public const String EMAIL_FIELD_INVALID_FORMAT = "Email Invalid Format";
/// <value>The constant used for row error when there is an 'Invalid Field' in CustomerData. </value>
public const String INVALID_FIELD = "Invalid Field";
/// <value>The constant used for error when 'Invalid Fields' exist in CustomerData. </value>
public const String INVALID_FIELDS = "Invalid Fields";
/// <summary>
/// Constructor to support serialization.
/// <remarks>Constructor that supports serialization.</remarks>
/// <param name="info">The SerializationInfo object to read from.</param>
/// <param name="context">Information on who is calling this method.</param>
/// </summary>
public CustomerData(SerializationInfo info, StreamingContext context) : base(info, context)
{
}
/// <summary>
/// Constructor for CustomerData.
/// <remarks>Initialize a CustomerData instance by building the table schema.</remarks>
/// </summary>
public CustomerData()
{
//
// Create the tables in the dataset
//
BuildDataTables();
}
//----------------------------------------------------------------
// Sub BuildDataTables:
// Creates the following datatables: Customers
//----------------------------------------------------------------
private void BuildDataTables()
{
//
// Create the Customers table
//
DataTable table = new DataTable(CUSTOMERS_TABLE);
DataColumnCollection columns = table.Columns;