Exemple #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(MxWeiXinPF.Model.wx_hotel_room model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update wx_hotel_room set ");
            strSql.Append("hotelid=@hotelid,");
            strSql.Append("roomType=@roomType,");
            strSql.Append("indroduce=@indroduce,");
            strSql.Append("roomPrice=@roomPrice,");
            strSql.Append("salePrice=@salePrice,");
            strSql.Append("facilities=@facilities,");
            strSql.Append("createDate=@createDate,");
            strSql.Append("sortid=@sortid");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@hotelid",    SqlDbType.Int,         4),
                new SqlParameter("@roomType",   SqlDbType.VarChar,   200),
                new SqlParameter("@indroduce",  SqlDbType.VarChar,   300),
                new SqlParameter("@roomPrice",  SqlDbType.Float,       8),
                new SqlParameter("@salePrice",  SqlDbType.Float,       8),
                new SqlParameter("@facilities", SqlDbType.VarChar,   500),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@sortid",     SqlDbType.Int,         4),
                new SqlParameter("@id",         SqlDbType.Int, 4)
            };
            parameters[0].Value = model.hotelid;
            parameters[1].Value = model.roomType;
            parameters[2].Value = model.indroduce;
            parameters[3].Value = model.roomPrice;
            parameters[4].Value = model.salePrice;
            parameters[5].Value = model.facilities;
            parameters[6].Value = model.createDate;
            parameters[7].Value = model.sortid;
            parameters[8].Value = model.id;

            int rows = DbHelperSQL.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 public MxWeiXinPF.Model.wx_hotel_room DataRowToModel(DataRow row)
 {
     MxWeiXinPF.Model.wx_hotel_room model = new MxWeiXinPF.Model.wx_hotel_room();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.id = int.Parse(row["id"].ToString());
         }
         if (row["hotelid"] != null && row["hotelid"].ToString() != "")
         {
             model.hotelid = int.Parse(row["hotelid"].ToString());
         }
         if (row["roomType"] != null)
         {
             model.roomType = row["roomType"].ToString();
         }
         if (row["indroduce"] != null)
         {
             model.indroduce = row["indroduce"].ToString();
         }
         if (row["roomPrice"] != null && row["roomPrice"].ToString() != "")
         {
             model.roomPrice = decimal.Parse(row["roomPrice"].ToString());
         }
         if (row["salePrice"] != null && row["salePrice"].ToString() != "")
         {
             model.salePrice = decimal.Parse(row["salePrice"].ToString());
         }
         if (row["facilities"] != null)
         {
             model.facilities = row["facilities"].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());
         }
     }
     return(model);
 }
Exemple #3
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(MxWeiXinPF.Model.wx_hotel_room model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into wx_hotel_room(");
            strSql.Append("hotelid,roomType,indroduce,roomPrice,salePrice,facilities,createDate,sortid)");
            strSql.Append(" values (");
            strSql.Append("@hotelid,@roomType,@indroduce,@roomPrice,@salePrice,@facilities,@createDate,@sortid)");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@hotelid",    SqlDbType.Int,         4),
                new SqlParameter("@roomType",   SqlDbType.VarChar,   200),
                new SqlParameter("@indroduce",  SqlDbType.VarChar,   300),
                new SqlParameter("@roomPrice",  SqlDbType.Float,       8),
                new SqlParameter("@salePrice",  SqlDbType.Float,       8),
                new SqlParameter("@facilities", SqlDbType.VarChar,   500),
                new SqlParameter("@createDate", SqlDbType.DateTime),
                new SqlParameter("@sortid",     SqlDbType.Int, 4)
            };
            parameters[0].Value = model.hotelid;
            parameters[1].Value = model.roomType;
            parameters[2].Value = model.indroduce;
            parameters[3].Value = model.roomPrice;
            parameters[4].Value = model.salePrice;
            parameters[5].Value = model.facilities;
            parameters[6].Value = model.createDate;
            parameters[7].Value = model.sortid;

            object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters);

            if (obj == null)
            {
                return(0);
            }
            else
            {
                return(Convert.ToInt32(obj));
            }
        }
Exemple #4
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public MxWeiXinPF.Model.wx_hotel_room GetModel(int id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,hotelid,roomType,indroduce,roomPrice,salePrice,facilities,createDate,sortid from wx_hotel_room ");
            strSql.Append(" where id=@id");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.Int, 4)
            };
            parameters[0].Value = id;

            MxWeiXinPF.Model.wx_hotel_room model = new MxWeiXinPF.Model.wx_hotel_room();
            DataSet ds = DbHelperSQL.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }