不使用数据绑定,分层显得更加清晰

ASPX文件

<table id="list">
        <thead>
            <tr>
                <td>
                    ID
                </td>
                <td>
                    用户名
                </td>
                <td>
                    建立日期
                </td>
            </tr>
        </thead>
        <tbody>
            <%foreach (var userbase in ModeluserBase)
              { %>
            <tr>
                <td>
                    <%=userbase.UserID %>
                </td>
                <td>
                    <%=userbase.UserName %>
                </td>
                <td>
                    <%=userbase.CreateDate %>
                </td>
            </tr>
            <%} %>
        </tbody>
    </table>

WEB层CS文件

public partial class About : System.Web.UI.Page
    {
        Service.IUserService iUserService = null;
        public List<Entity.OA.UserBase> ModeluserBase = null; //用户模型
        public About()
        {
            this.iUserService = new Service.UserService();
        }
 
        protected void Page_Load(object sender, EventArgs e)
        {
            this.ModeluserBase = this.iUserService.GetUserBases();
        }
    }

Service层CS文件

 public class UserService : IUserService
    {
        Data.OA.IUserBasesRepository iUserBasesRepository = null;
        public UserService()
        {
            this.iUserBasesRepository = new Data.OA.UserBasesRepository();
        }
 
        #region IUserService Members
 
        public List<Entity.OA.UserBase> GetUserBases()
        {
            return this.iUserBasesRepository.GetUserBases().ToList();
        }
 
        #endregion
    }

Entity层CS文件

 public partial class UserBase : IDataEntity,ISimpleUserInfo
    {
        //初始字段
        #region original field
        
        /// <summary>
        /// 
        /// </summary>
        public string UserID { get;  set; }
        
        /// <summary>
        /// 
        /// </summary>
        public string UserName { get;  set; }
        
        /// <summary>
        /// 
        /// </summary>
        public string Email { get;  set; }
        
        /// <summary>
        /// 
        /// </summary>
        public string Password { get;  set; }
        
        /// <summary>
        /// 
        /// </summary>
        public object CreateDate { get;  set; }
        
        /// <summary>
        /// 
        /// </summary>
        public object UpdateDate { get;  set; }
        
        /// <summary>
        /// 
        /// </summary>
        public Entity.CommonEnum.Status Status { get; set; }
        
        #endregion
 
        //外延字段
        #region extensional field
        #endregion
 
        //构造函数
        #region constructed function
        
        /// <summary>
        /// 新建立的时候构造函数
        /// </summary>
        public UserBase()
        {
        
        }
        
        /// <summary>
        /// 新建立的时候构造函数
        /// </summary>
        /// <param name="_UserID"></param>
        public UserBase(String _UserID )
        {
            this.UserID = _UserID ;
            
        }
 
        #endregion
 
        //方法
        #region function
 
        #endregion
 
        //重写方法
        #region object overrides
 
        #endregion
    }

Data层使用LINQTOSQL做数据的持久化更安全,方便,开发效率更高

posted @ 2011-06-21 13:37  张占岭  阅读(628)  评论(0编辑  收藏  举报