예제 #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(RoomInfo model)
        {
            StringBuilder query = new StringBuilder();
            query.Append("Update[dbo].[wx_hotel_room]");
            query.Append("     Set[hotelid] = @hotelid");
            query.Append("       ,[roomType] = @roomType");
            query.Append("       ,[indroduce] = @indroduce");
            query.Append("       ,[roomPrice] = @roomPrice");
            query.Append("       ,[salePrice] = @salePrice");
            query.Append("       ,[facilities] = @facilities");
            query.Append("       ,[createDate] = @createDate");
            query.Append("       ,[sortid] = @sortid");
            query.Append("       ,[RoomCode] = @RoomCode");
            query.Append("       ,[UseInstruction] = @UseInstruction");
            query.Append("       ,[RefundRule] = @RefundRule");
            query.Append("       ,[Status] = @Status");
            query.Append("       ,[ExpiryDate_Begin] = @ExpiryDate_Begin");
            query.Append("       ,[ExpiryDate_End] = @ExpiryDate_End");
            query.Append(" Where id=@Id");

            using (IDbConnection db = DbFactory.GetOpenedConnection())
            {
                return db.Execute(query.ToString(), model) > 0;
            }
        }
예제 #2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(RoomInfo model)
        {
            StringBuilder query = new StringBuilder();
            query.Append("Insert Into[dbo].[wx_hotel_room]");
            query.Append("([hotelid],[roomType],[indroduce],[roomPrice],[salePrice],[facilities],[createDate],[sortid],[RoomCode],[UseInstruction],[RefundRule],[Status],[ExpiryDate_Begin],[ExpiryDate_End])");
            query.Append("Values");
            query.Append("(@hotelid, @roomType, @indroduce, @roomPrice, @salePrice, @facilities, @createDate, @sortid, @RoomCode, @UseInstruction, @RefundRule, @Status,@ExpiryDate_Begin,@ExpiryDate_End);");
            query.Append("Select @Id = Scope_Identity()");
            //query.Append("Update dbo.wx_hotel_room Set RoomCode=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");
            }
        }
예제 #3
0
 public bool Update(RoomInfo model)
 {
     return _roomRepository.Update(model);
 }
예제 #4
0
 public int Add(RoomInfo model)
 {
     return _roomRepository.Add(model);
 }