博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

Duwamish7.0---(I数据通道 default.aspx篇)

Posted on 2006-03-13 17:29  HH  阅读(324)  评论(0编辑  收藏  举报

1.default.aspx --Banner

web层:

<!-- BEGIN PAGE HEADER MODULE -->
      <Module:Header id="ModuleBanner" runat="server" />
<!-- END PAGE HEADER MODULE -->

调用modules/bannermodule.ascx

<%=PathPrefix + "/images/banner/bannerslice.gif"%> 中的PathPrefix为退到根目录

<%=PageBase.UrlBase + "/default.aspx"%> 中调用PageBase页面的UrlBase方法:

        /// <value>
        ///     Property UrlBase is used to get the prefix for URLs.
        /// </value>
 public static String UrlBase
 {
  get
  {
   return @"http://" + UrlSuffix;
  }
 }

返回根目录的default.aspx页面

        /// <value>
        ///     Property SecureUrlBase is used to get the prefix for URLs in the Secure directory.
        /// </value>
 public static String SecureUrlBase
 {
  get
  {
   return (DuwamishConfiguration.EnableSsl ? @"https://": @"http://") + UrlSuffix;
  }
 }

这个方法是返回Secure directory下面的File




 

2.default.aspx --Search

web层:

                <td style="padding-top:5" align="left">
               
                  <Module:Search id="ModuleSearch" runat="server">
                  </Module:Search>
                 
                </td>

调用modules/searchmodule.ascx

.ascx.cs主要是onclick="SearchButton_Click"事件

SearchResults.aspx.cs代码:resultsSet = (new ProductSystem()).GetSearchItems(searchEnumType, searchText);


Business/Facade 业务外观层:

调用类名称为:ProductSystem.cs的类中的GetSearchItems方法(根据指定的检索字段条件以及书名的关键字查询书的信息)

switch (searchType)
             {
                    case BookData.SearchTypeEnum.Author:
                        retVal = bookDataAccess.GetBooksByAuthor(searchText);
               break;
                    case BookData.SearchTypeEnum.ISBN:
                        retVal = bookDataAccess.GetBooksByISBN(searchText);
               break;
                    case BookData.SearchTypeEnum.Subject:
                        retVal = bookDataAccess.GetBooksBySubject(searchText);
               break;
                    case BookData.SearchTypeEnum.Title:
                        retVal = bookDataAccess.GetBooksByTitle(searchText);
               break;
                    default:
                        ApplicationAssert.Check(false, string.Format("searchType {0} is not valid", searchType.ToString()), ApplicationAssert.LineNumber);
                        break;
             }


DataAccess  数据访问层

调用类名称为:Books.cs的类中的各种方法,例如GetBooksByAuthor:

 public BookData GetBooksByAuthor(String searchText)
        {
            return FillBookData("GetBooksByAuthor", "@Author", searchText );
        }


 private BookData FillBookData(String commandText, String paramName, String paramValue)
        {
            if (dsCommand == null )
            {
                throw new System.ObjectDisposedException( GetType().FullName );
            }           
            BookData   data    = new BookData();
            SqlCommand command = dsCommand.SelectCommand;

            command.CommandText = commandText;
            command.CommandType = CommandType.StoredProcedure;
            SqlParameter param = new SqlParameter(paramName, SqlDbType.NVarChar, 255);
            param.Value = paramValue;
            command.Parameters.Add(param);           

            dsCommand.Fill(data);
            return data;
        }