예제 #1
0
        public Entity Add(Entity entity)
        {
            HoursePrice  hoursePrice      = entity as HoursePrice;
            string       sql              = "insert into HoursePrice(AreaId,Price,Year,Month)values(@AreaId,@Price,@Year,@Month);select @HoursePriceId = @@IDENTITY";
            SqlParameter prmHoursePriceId = new SqlParameter("@HoursePriceId", SqlDbType.Int)
            {
                Direction = ParameterDirection.Output
            };
            SqlParameter prmCityId = new SqlParameter("@AreaId", SqlDbType.Int)
            {
                Value = hoursePrice.AreaId
            };
            SqlParameter prmPrice = new SqlParameter("@Price", SqlDbType.Int)
            {
                Value = hoursePrice.Price
            };
            SqlParameter prmYear = new SqlParameter("@Year", SqlDbType.Int)
            {
                Value = hoursePrice.Year
            };
            SqlParameter prmMonth = new SqlParameter("@Month", SqlDbType.Int)
            {
                Value = hoursePrice.Month
            };

            ExecuteNoQuery(sql, prmHoursePriceId, prmCityId, prmPrice, prmYear, prmMonth);
            hoursePrice.HoursePriceId = (int)prmHoursePriceId.Value;
            return(hoursePrice);
        }
예제 #2
0
        public Entity Update(Entity entity)
        {
            HoursePrice  hoursePrice      = entity as HoursePrice;
            string       sql              = "update hoursePrice set Price = @Price,Year = @Year,Month=@Month,AreaId = @AreaId where HoursePriceId = @HoursePriceId";
            SqlParameter prmHoursePriceId = new SqlParameter("@HoursePriceId", SqlDbType.Int)
            {
                Value = hoursePrice.HoursePriceId
            };
            SqlParameter prmPrice = new SqlParameter("@Price", SqlDbType.Int)
            {
                Value = hoursePrice.Price
            };
            SqlParameter prmYear = new SqlParameter("@Year", SqlDbType.Int)
            {
                Value = hoursePrice.Year
            };
            SqlParameter prmMonth = new SqlParameter("@Month", SqlDbType.Int)
            {
                Value = hoursePrice.Month
            };
            SqlParameter prmAreaId = new SqlParameter("@AreaId", SqlDbType.Int)
            {
                Value = hoursePrice.AreaId
            };

            ExecuteNoQuery(sql, prmHoursePriceId, prmPrice, prmYear, prmMonth, prmAreaId);
            return(entity);
        }
예제 #3
0
        private Entity GetOne(SqlDataReader reader)
        {
            if (!reader.HasRows)
            {
                SetError("房价记录不存在");
                return(null);
            }
            reader.Read();
            HoursePrice hoursePrice = new HoursePrice();

            hoursePrice.HoursePriceId = reader.GetInt32(0);
            hoursePrice.AreaId        = reader.GetInt32(1);
            hoursePrice.Year          = reader.GetInt32(2);
            hoursePrice.Month         = reader.GetInt32(3);
            hoursePrice.Price         = reader.GetInt32(4);
            return(hoursePrice);
        }
예제 #4
0
        private void GetOne()
        {
            int         hoursePriceId = int.Parse(Helper.GetParameterFromRequest("hoursePriceId"));
            HoursePrice hoursePrice   = new HoursePrice();

            hoursePrice.HoursePriceId = hoursePriceId;
            HoursePriceRepo Repo = new HoursePriceRepo(hoursePrice);

            if (Repo.Query())
            {
                Helper.Response(hoursePrice.Serialize());
            }
            else
            {
                Helper.ResponseError(Repo.ErrorMessage);
            }
        }
예제 #5
0
        private Entities GetList(SqlDataReader reader)
        {
            Entities    entities = new Entities();
            HoursePrice hoursePrice;

            while (reader.Read())
            {
                hoursePrice = new HoursePrice()
                {
                    HoursePriceId = reader.GetInt32(1),
                    AreaId        = reader.GetInt32(2),
                    Year          = reader.GetInt32(3),
                    Month         = reader.GetInt32(4),
                    Price         = reader.GetInt32(5)
                };
                entities.Add(hoursePrice);
            }
            return(entities);
        }