/// <summary> /// 更新一条数据 /// </summary> public bool Update(PinPaiVsImgModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update CORE.dbo.PinPaiVsImg set "); strSql.Append(" PinPaiId = @PinPaiId , "); strSql.Append(" ImgId = @ImgId "); strSql.Append(" where PinPaiId=@PinPaiId and ImgId=@ImgId "); SqlParameter[] parameters = { new SqlParameter("@PinPaiId", SqlDbType.Decimal, 9), new SqlParameter("@ImgId", SqlDbType.VarChar, 50) }; parameters[0].Value = model.PinPaiId; parameters[1].Value = model.ImgId; try {//异常处理 reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters); } catch (Exception ex) { this.helper.Close(); throw ex; } if (reCount <= 0) { reValue = false; } return(reValue); }
/// <summary> /// 得到一个对象实体 /// </summary> public PinPaiVsImgModel GetModel(decimal PinPaiId, string ImgId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select PinPaiId, ImgId "); strSql.Append(" from CORE.dbo.PinPaiVsImg "); strSql.Append(" where PinPaiId=@PinPaiId and ImgId=@ImgId "); SqlParameter[] parameters = { new SqlParameter("@PinPaiId", SqlDbType.Decimal, 9), new SqlParameter("@ImgId", SqlDbType.VarChar, 50) }; parameters[0].Value = PinPaiId; parameters[1].Value = ImgId; PinPaiVsImgModel model = new PinPaiVsImgModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["PinPaiId"].ToString() != "") { model.PinPaiId = decimal.Parse(ds.Tables[0].Rows[0]["PinPaiId"].ToString()); } model.ImgId = ds.Tables[0].Rows[0]["ImgId"].ToString(); return(model); } else { return(model); } }
/// <summary> /// 增加一条数据 /// </summary> public bool Add(PinPaiVsImgModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into CORE.dbo.PinPaiVsImg ("); strSql.Append("PinPaiId,ImgId"); strSql.Append(") values ("); strSql.Append("@PinPaiId,@ImgId"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@PinPaiId", SqlDbType.Decimal, 9), new SqlParameter("@ImgId", SqlDbType.VarChar, 50) }; parameters[0].Value = model.PinPaiId; parameters[1].Value = model.ImgId; bool result = false; try { helper.ExecSqlReInt(strSql.ToString(), parameters); result = true; } catch (Exception ex) { this.helper.Close(); throw ex; } finally { } return(result); }