// 添加微博 public bool save(WeiBo WeiBo) { string sql = "insert into t_weibo(authorId, authorName,isOriginal,zanNumber,transmitNumber,favsNumber,reviewNumber," + "content,orAuthorId,orAuthorName,orContent,ortime,createTime) values(" + WeiBo.authorId + ",'" + WeiBo.authorName + "','" + WeiBo.isOriginal + "'," + WeiBo.zanNumber + "," + WeiBo.transmitNumber + "," + WeiBo.favsNumber + "," + WeiBo.reviewNumber + ",'" + WeiBo.content + "'," + WeiBo.orAuthorId + ",'" + WeiBo.orAuthorName + "','" + WeiBo.orContent + "','" + WeiBo.orTime + "','" + WeiBo.createTime + "')"; int flag = DBHelper.ExecuteSQL(sql); if (flag == 1) { return(true); } else { return(false); } }
//根据sql查询微博信息 IList <WeiBo> GetWeiBosBySql(string sql) { SqlDataReader reader = DBHelper.ExecuteReader(sql); IList <WeiBo> WeiBos = new List <WeiBo>(); try { while (reader.Read()) { WeiBo w = new WeiBo(); w.weiboId = (Int32)reader["weiboId"]; w.authorId = (Int32)reader["authorId"]; w.authorName = reader["authorName"].ToString(); w.content = reader["content"].ToString(); w.createTime = (DateTime)reader["createTime"]; w.favsNumber = (Int32)reader["favsNumber"]; w.reviewNumber = (Int32)reader["reviewNumber"]; w.transmitNumber = (Int32)reader["transmitNumber"]; w.zanNumber = (Int32)reader["zanNumber"]; w.isOriginal = reader["isOriginal"].ToString(); if (w.isOriginal.Trim() != "原创") { w.orAuthorId = (Int32)reader["orAuthorId"]; w.orAuthorName = reader["orAuthorName"].ToString(); w.orContent = reader["orContent"].ToString(); w.orTime = (DateTime)reader["orTime"]; } WeiBos.Add(w); } } catch (Exception) { throw; } finally { if (reader != null) { reader.Close(); } } return(WeiBos); }
//根据weiboId更新微博(ZanFavsReviewTrans) public bool updateZanFavsReviewTrans(WeiBo wb) { string sql = "update t_WeiBo " + " set zanNumber=" + wb.zanNumber + "," + "favsNumber=" + wb.favsNumber + "," + "reviewNumber=" + wb.reviewNumber + "," + "transmitNumber=" + wb.transmitNumber + " where weiboid=" + wb.weiboId; int flag = DBHelper.ExecuteSQL(sql); if (flag >= 1) { return(true); } else { return(false); } }