NetPetshop 研究学习(一)


NetPetshop 研究学习(一)


1  NetPetshop是采用了数据库持久层采用O/RM工具iBatisNet。
  采用了典型的三层结构。分层如下:
  数据访问层:NPetshop.Service,NPetshop.Persistence,NPetshop.Domain
  业务逻辑层:NPetshop.Presentation
  表示层:NPetshop.Web
2 以用户帐户注册页面的为例说明调用关系:
D:/NPetShop/NPetshop/NPetshop.Web/Default.aspx.cs
调用如下类:
D:/NPetShop/NPetshop/NPetshop.Web/UserControls/Accounts/NewAccount.ascx.cs
调用如下类:
D:/NPetShop/NPetshop/NPetshop.Presentation/UserActions/AccountAction.cs
调用如下类:
D:/NPetShop/NPetshop/NPetshop.Service/AccountService.cs
调用如下类:
D:/NPetShop/NPetshop/NPetshop.Persistence/MapperDao/Accounts/AccountSqlMapDao.cs
调用如下类:
D:/NPetShop/NPetshop/NPetshop.Persistence/MapperDao/BaseSqlMapDao.cs 

3 如何读取dao.config,SqlMap.config配置文件

D:/NPetShop/NPetshop/NPetshop.Service/ServiceConfig.cs
如下代码:
        static public ServiceConfig GetInstance()
        {
            if (_instance == null)
            {
                lock (_synRoot)
                {
                    if (_instance == null)
                    {
                        ConfigureHandler handler = new ConfigureHandler(ServiceConfig.Reset);

                        DomDaoManagerBuilder builder = new DomDaoManagerBuilder();
                        builder.ConfigureAndWatch("dao.config", handler);

                        _instance = new ServiceConfig();
                        _instance._daoManager = IBatisNet.DataAccess.DaoManager.GetInstance("SqlMapDao");
                    }
                }
            }
            return _instance;
        }

       
       
5 利用<asp:repeater/>控件绑定数据
<asp:repeater id="RepeaterItems" runat="server">
      <headertemplate>
       <table cellpadding="0" cellspacing="1">
        <tr class="gridHead">
         <td>Line</td>
         <td>Item</td>
         <td>Product</td>
         <td>Price</td>
         <td>Quantity</td>
         <td>Subtotal</td>
        </tr>
      </headertemplate>
      <itemtemplate>
       <tr class="gridItem">
        <td><%# DataBinder.Eval(Container.DataItem, "LineNumber") %></td>
        <td><%# DataBinder.Eval(Container.DataItem, "Item.Id") %></td>
        <td><%# DataBinder.Eval(Container.DataItem, "Item.Product.Id") %></td>
        <td class="num"><%# DataBinder.Eval(Container.DataItem, "Item.ListPrice", "{0:c}") %></td>
        <td class="num"><%# DataBinder.Eval(Container.DataItem, "Quantity") %></td>
        <td class="num"><%# DataBinder.Eval(Container.DataItem, "Total", "{0:c}") %></td>
       </tr>
      </itemtemplate>
      <footertemplate></table></footertemplate>
</asp:repeater>

 

posted @ 2008-09-19 08:47  深潭  阅读(240)  评论(0编辑  收藏  举报