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