日期:2014-05-18 浏览次数:20536 次
namespace SamTest.DALFactory { /// <summary> /// This class is implemented following the Abstract Factory pattern to create the DAL implementation /// specified from the configuration file /// </summary> public sealed class DataAccess { private static readonly string path = ConfigurationManager.AppSettings["WebDAL"]; public DataAccess() { } public static SamTest.IDAL.IBuildingSell CreateBuildingSell() { string CacheKey = path + ".BuildingSell"; //此处返回的就是SamTest.BLL.BuildingSell System.Type type = Type.GetType(CacheKey); return (SamTest.IDAL.IBuildingSell)Activator.CreateInstance(type); //此处标记为 A1 } } } namespace SamTest.BLL { /// <summary> /// 业务逻辑类BuildingSell 的摘要说明。 /// </summary> public class BuildingSell { private static readonly IBuildingSell dal = DataAccess.CreateBuildingSell(); //此处标记为 A2 public BuildingSell() { } #region 成员方法 /// <summary> /// 是否存在该记录 /// </summary> public bool Exists(int BU_ID) { return dal.Exists(BU_ID); } /// <summary> /// 增加一条数据 /// </summary> public void Add(SamTest.Model.BuildingSell model) { dal.Add(model); } /// <summary> /// 更新一条数据 /// </summary> public void Update(SamTest.Model.BuildingSell model) { dal.Update(model); } } namespace SamTest.IDAL { /// <summary> /// 接口层IBuildingSell 的摘要说明。 /// </summary> public interface IBuildingSell { #region 成员方法 /// <summary> /// 是否存在该记录 /// </summary> bool Exists(int BU_ID); /// <summary> /// 增加一条数据 /// </summary> void Add(SamTest.Model.BuildingSell model); /// <summary> /// 更新一条数据 /// </summary> void Update(SamTest.Model.BuildingSell model); /// <summary> /// 删除一条数据 /// </summary> void Delete(int BU_ID); #endregion 成员方法 } } public partial class Member_Member_SellFlats_UpdateBuild : System.Web.UI.Page { private void UpdateInfo() { SamTest.BLL.BuildingSell BLLobj = new SamTest.BLL.BuildingSell(); BLLobj.Update(Modelobj); } }