/// <summary> /// 更新一条数据 /// </summary> public bool Update(HotelInfo model) { StringBuilder query = new StringBuilder(); query.Append(" Update[dbo].[wx_hotels_info]"); query.Append(" Set[wid] = @wid"); query.Append(" ,[hotelName] = @hotelName"); query.Append(" ,[hotelAddress] = @hotelAddress"); query.Append(" ,[hotelPhone] = @hotelPhone"); query.Append(" ,[mobilPhone] = @mobilPhone"); query.Append(" ,[noticeEmail] = @noticeEmail"); query.Append(" ,[emailPws] = @emailPws"); query.Append(" ,[smtp] = @smtp"); query.Append(" ,[coverPic] = @coverPic"); query.Append(" ,[topPic] = @topPic"); query.Append(" ,[orderLimit] = @orderLimit"); query.Append(" ,[listMode] = @listMode"); query.Append(" ,[messageNotice] = @messageNotice"); query.Append(" ,[pwd] = @pwd"); query.Append(" ,[hotelIntroduct] = @hotelIntroduct"); query.Append(" ,[orderRemark] = @orderRemark"); query.Append(" ,[createDate] = @createDate"); query.Append(" ,[sortid] = @sortid"); query.Append(" ,[xplace] = @xplace"); query.Append(" ,[yplace] = @yplace"); query.Append(" ,[HotelCode] = @HotelCode"); query.Append(" ,[Operator] = @Operator"); query.Append(" ,[HotelLevel] = @HotelLevel"); query.Append(" ,[Recommend]=@Recommend"); query.Append(" Where id=@Id"); using (IDbConnection db = DbFactory.GetOpenedConnection()) { return db.Execute(query.ToString(), model) > 0; } }
/// <summary> /// 增加一条数据 /// </summary> public int Add(HotelInfo model) { StringBuilder query = new StringBuilder(); query.Append("Insert Into[dbo].[wx_hotels_info]"); query.Append(" ([wid],[hotelName],[hotelAddress],[hotelPhone],[mobilPhone],[noticeEmail],[emailPws],[smtp],[coverPic],[topPic],[orderLimit],[listMode],[messageNotice],[pwd],[hotelIntroduct],[orderRemark],[createDate],[sortid],[xplace],[yplace],[HotelCode],[Operator],[HotelLevel],[Recommend])"); query.Append(" Values"); query.Append(" (@wid, @hotelName, @hotelAddress, @hotelPhone, @mobilPhone, @noticeEmail, @emailPws, @smtp, @coverPic, @topPic, @orderLimit, @listMode, @messageNotice, @pwd, @hotelIntroduct, @orderRemark, @createDate, @sortid, @xplace, @yplace, @HotelCode, @Operator, @HotelLevel,@Recommend);"); query.Append("Select @Id = Scope_Identity();"); query.Append("Update dbo.wx_hotels_info Set HotelCode=Right('0000'+Cast(@Id As Varchar(10)),4) Where Id=@Id"); using (IDbConnection db = DbFactory.GetOpenedConnection()) { DynamicParameters dynamicParameters = new DynamicParameters(); dynamicParameters.AddDynamicParams(model); dynamicParameters.Add("@Id", dbType: DbType.Int32, direction: ParameterDirection.Output); db.Execute(query.ToString(), dynamicParameters); return dynamicParameters.Get<int>("@Id"); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(HotelInfo model) { return this._repository.Update(model); }
/// <summary> /// 增加一条数据 /// </summary> public int Add(HotelInfo model) { return this._repository.Add(model); }
/// <summary> /// 得到一个对象实体 /// </summary> public HotelInfo DataRowToModel(DataRow row) { HotelInfo model = new HotelInfo(); if (row != null) { if (row["id"] != null && row["id"].ToString() != "") { model.id = int.Parse(row["id"].ToString()); } if (row["wid"] != null && row["wid"].ToString() != "") { model.wid = int.Parse(row["wid"].ToString()); } if (row["hotelName"] != null) { model.hotelName = row["hotelName"].ToString(); } if (row["hotelAddress"] != null) { model.hotelAddress = row["hotelAddress"].ToString(); } if (row["hotelPhone"] != null) { model.hotelPhone = row["hotelPhone"].ToString(); } if (row["mobilPhone"] != null) { model.mobilPhone = row["mobilPhone"].ToString(); } if (row["noticeEmail"] != null) { model.noticeEmail = row["noticeEmail"].ToString(); } if (row["emailPws"] != null) { model.emailPws = row["emailPws"].ToString(); } if (row["smtp"] != null) { model.smtp = row["smtp"].ToString(); } if (row["coverPic"] != null) { model.coverPic = row["coverPic"].ToString(); } if (row["topPic"] != null) { model.topPic = row["topPic"].ToString(); } if (row["orderLimit"] != null && row["orderLimit"].ToString() != "") { model.orderLimit = int.Parse(row["orderLimit"].ToString()); } if (row["listMode"] != null && row["listMode"].ToString() != "") { if ((row["listMode"].ToString() == "1") || (row["listMode"].ToString().ToLower() == "true")) { model.listMode = true; } else { model.listMode = false; } } if (row["messageNotice"] != null && row["messageNotice"].ToString() != "") { model.messageNotice = int.Parse(row["messageNotice"].ToString()); } if (row["pwd"] != null) { model.pwd = row["pwd"].ToString(); } if (row["hotelIntroduct"] != null) { model.hotelIntroduct = row["hotelIntroduct"].ToString(); } if (row["orderRemark"] != null) { model.orderRemark = row["orderRemark"].ToString(); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } if (row["sortid"] != null && row["sortid"].ToString() != "") { model.sortid = int.Parse(row["sortid"].ToString()); } if (row["xplace"] != null && row["xplace"].ToString() != "") { model.xplace = decimal.Parse(row["xplace"].ToString()); } if (row["yplace"] != null && row["yplace"].ToString() != "") { model.yplace = decimal.Parse(row["yplace"].ToString()); } } return model; }