namespace SysCommon.RealtyModel.Hotel { /// <summary> /// 酒店的接口 /// </summary> public interface IHotelManage { string HotelManage(string str); } } namespace SysCommon.RealtyExt.Hotel { public class AddHotelInfo : SysCommon.RealtyModel.Hotel.IHotelManage { #region IHotelManage 成员-新增酒店基础信息 string SysCommon.RealtyModel.Hotel.IHotelManage.HotelManage(string str) { try { return SysCommon.DbSql.ExecuteSql(str).ToString(); } catch { return "0"; } } #endregion } public class AddHotelAreaConn : SysCommon.RealtyModel.Hotel.IHotelManage { #region IHotelManage 成员--新增 地区和酒店关联记录 public string HotelManage(string str) { try { return SysCommon.DbSql.ExecuteSql(str).ToString(); } catch { return "0"; } } #endregion } public class AddHotel_RoomStyleInfo : SysCommon.RealtyModel.Hotel.IHotelManage { #region IHotelManage 成员 public string HotelManage(string str) { try { return SysCommon.DbSql.ExecuteSql(str).ToString(); } catch { return "0"; } } #endregion } } namespace SysCommon.RealtyBll.Hotel { public class HotelInfoFactory { public HotelInfoFactory() { } public SysCommon.RealtyModel.Hotel.IHotelManage CreateHotelInfo(string styleID) {//1新增酒店基础信息 2新增酒店地区关联表 3新增酒店房型信息 SysCommon.RealtyModel.Hotel.IHotelManage hm = null; switch (styleID) { case "1": hm = new SysCommon.RealtyExt.Hotel.AddHotelInfo(); break; case "2": hm = new SysCommon.RealtyExt.Hotel.AddHotelAreaConn(); break; case "3": hm = new SysCommon.RealtyExt.Hotel.AddHotel_RoomStyleInfo(); break; default : hm = new SysCommon.RealtyExt.Hotel.AddHotelInfo(); break; } return hm; } } } string sql1 = " //利用工厂创建新增方法 SysCommon.RealtyModel.Hotel.IHotelManage h = hFactory.CreateHotelInfo("1");//1新增 //执行新增 返回值 string Flag=h.HotelManage(sql1); if (Flag != "0") { return Flag; } return "0"; 工厂看着简单,自己试了下,有点不知所措,不知道怎么套用自己的项目! ⊙﹏⊙b汗