void AddShopPic(GanJiWebInfoEntity entity, int shopId) { List<string> shopPic = new ShopAnalyse().GetShopPic(entity.HouseImage, entity.ComeFrom); foreach (string picUrl in shopPic) { ShopPicEntity entityPic = new ShopPicEntity(); entityPic.PicUrl = picUrl; entityPic.ShopID = shopId; entityPic.IsActive = 1; entityPic.CreateTime = DateTime.Now; ShopPicBLL.GetInstance().Insert(entityPic); } }
/// <summary> /// 向数据表ShopPic更新一条记录。带事务 /// </summary> /// <param name="sp">事务对象</param> /// <param name="_ShopPicModel">_ShopPicModel</param> /// <returns>影响的行数</returns> public int Update(SqlTransaction sp, ShopPicEntity _ShopPicModel) { string sqlStr = "update ShopPic set [ShopID]=@ShopID,[PicUrl]=@PicUrl,[CreateTime]=@CreateTime,[IsActive]=@IsActive where PicID=@PicID"; SqlParameter[] _param ={ new SqlParameter("@PicID",SqlDbType.Int), new SqlParameter("@ShopID",SqlDbType.Int), new SqlParameter("@PicUrl",SqlDbType.VarChar), new SqlParameter("@CreateTime",SqlDbType.DateTime), new SqlParameter("@IsActive",SqlDbType.SmallInt) }; _param[0].Value = _ShopPicModel.PicID; _param[1].Value = _ShopPicModel.ShopID; _param[2].Value = _ShopPicModel.PicUrl; _param[3].Value = _ShopPicModel.CreateTime; _param[4].Value = _ShopPicModel.IsActive; return SqlHelper.ExecuteNonQuery(sp, CommandType.Text, sqlStr, _param); }
/// <summary> /// 得到 shoppic 数据实体 /// </summary> /// <param name="row">row</param> /// <returns>shoppic 数据实体</returns> public ShopPicEntity Populate_ShopPicEntity_FromDr(DataRow row) { ShopPicEntity Obj = new ShopPicEntity(); if (row != null) { Obj.PicID = ((row["PicID"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["PicID"]); Obj.ShopID = ((row["ShopID"]) == DBNull.Value) ? 0 : Convert.ToInt32(row["ShopID"]); Obj.PicUrl = row["PicUrl"].ToString(); Obj.CreateTime = ((row["CreateTime"]) == DBNull.Value) ? Convert.ToDateTime("1900-1-1") : Convert.ToDateTime(row["CreateTime"]); Obj.IsActive = ((row["IsActive"]) == DBNull.Value) ? (short)0 : (short)row["IsActive"]; } else { return null; } return Obj; }
/// <summary> /// 得到 shoppic 数据实体 /// </summary> /// <param name="dr">dr</param> /// <returns>shoppic 数据实体</returns> public ShopPicEntity Populate_ShopPicEntity_FromDr(IDataReader dr) { ShopPicEntity Obj = new ShopPicEntity(); Obj.PicID = ((dr["PicID"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["PicID"]); Obj.ShopID = ((dr["ShopID"]) == DBNull.Value) ? 0 : Convert.ToInt32(dr["ShopID"]); Obj.PicUrl = dr["PicUrl"].ToString(); Obj.CreateTime = ((dr["CreateTime"]) == DBNull.Value) ? Convert.ToDateTime("1900-1-1") : Convert.ToDateTime(dr["CreateTime"]); Obj.IsActive = ((dr["IsActive"]) == DBNull.Value) ? (short)0 : (short)dr["IsActive"]; return Obj; }
/// <summary> /// 向数据库中插入一条新记录。带事务 /// </summary> /// <param name="sp">事务对象</param> /// <param name="_ShopPicModel">ShopPic实体</param> /// <returns>新插入记录的编号</returns> public int Insert(SqlTransaction sp, ShopPicEntity _ShopPicModel) { string sqlStr = "insert into ShopPic([ShopID],[PicUrl],[CreateTime],[IsActive]) values(@ShopID,@PicUrl,@CreateTime,@IsActive) select @@identity"; int res; SqlParameter[] _param ={ new SqlParameter("@ShopID",SqlDbType.Int), new SqlParameter("@PicUrl",SqlDbType.VarChar), new SqlParameter("@CreateTime",SqlDbType.DateTime), new SqlParameter("@IsActive",SqlDbType.SmallInt) }; _param[0].Value = _ShopPicModel.ShopID; _param[1].Value = _ShopPicModel.PicUrl; _param[2].Value = _ShopPicModel.CreateTime; _param[3].Value = _ShopPicModel.IsActive; res = Convert.ToInt32(SqlHelper.ExecuteScalar(sp, CommandType.Text, sqlStr, _param)); return res; }