/// <summary> /// 增加一条数据 /// </summary> public int Add(HotelPictureInfo model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into wx_hotel_pic("); strSql.Append("hotelid,title,sortid,picUrl,picTiaozhuan,createDate)"); strSql.Append(" values ("); strSql.Append("@hotelid,@title,@sortid,@picUrl,@picTiaozhuan,@createDate)"); strSql.Append(";select @@IDENTITY"); SqlParameter[] parameters = { new SqlParameter("@hotelid", SqlDbType.Int, 4), new SqlParameter("@title", SqlDbType.VarChar, 200), new SqlParameter("@sortid", SqlDbType.Int, 4), new SqlParameter("@picUrl", SqlDbType.VarChar, 200), new SqlParameter("@picTiaozhuan", SqlDbType.VarChar, 200), new SqlParameter("@createDate", SqlDbType.DateTime) }; parameters[0].Value = model.hotelid; parameters[1].Value = model.title; parameters[2].Value = model.sortid; parameters[3].Value = model.picUrl; parameters[4].Value = model.picTiaozhuan; parameters[5].Value = model.createDate; object obj = DbHelperSQL.GetSingle(strSql.ToString(), parameters); if (obj == null) { return 0; } else { return Convert.ToInt32(obj); } }
/// <summary> /// 得到一个对象实体 /// </summary> public HotelPictureInfo DataRowToModel(DataRow row) { var model = new HotelPictureInfo(); 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["title"] != null) { model.title = row["title"].ToString(); } if (row["sortid"] != null && row["sortid"].ToString() != "") { model.sortid = int.Parse(row["sortid"].ToString()); } if (row["picUrl"] != null) { model.picUrl = row["picUrl"].ToString(); } if (row["picTiaozhuan"] != null) { model.picTiaozhuan = row["picTiaozhuan"].ToString(); } if (row["createDate"] != null && row["createDate"].ToString() != "") { model.createDate = DateTime.Parse(row["createDate"].ToString()); } } return model; }
/// <summary> /// 增加一条数据 /// </summary> public int Add(HotelPictureInfo model) { return this._repository.Add(model); }