public new int Delete(string commentID) { try { DbInstance.BeginTran(); string sql = "select articleID,articleCommentTimes from blog_view_article where articleID=(select articleID from blog_tb_comment where commentID=@commentID)"; DataTable dt = DbInstance.GetDataTable(sql, DbInstance.CreateParameter("@commentID", commentID)); if (dt.Rows.Count > 0) { int articleCommentTimes = Convert.ToInt32(dt.Rows[0]["articleCommentTimes"]); articleCommentTimes = Math.Max(articleCommentTimes - 1, 0); sql = "update blog_tb_article_extend set articleCommentTimes=" + articleCommentTimes + " where articleID=@articleID"; DbInstance.ExecuteSql(sql, DbInstance.CreateParameter("@articleID", dt.Rows[0]["articleID"])); } base.Delete(commentID); DbInstance.Commit(); return(1); } catch { DbInstance.Rollback(); throw; } }
public int CreateCatelog(string ids) { ids = ids.Trim(','); string sql = "select articleTitle,articleID from blog_tb_article where articleID in (" + ids + ") order by ADD_DATE"; DataTable dt = DbInstance.GetDataTable(sql); string str = ""; foreach (DataRow dr in dt.Rows) { str += "<p><a href=\"/artic-" + dr["articleID"] + ".html\">" + dr["articleTitle"] + "</a></p>"; } DbInstance.BeginTran(); int result = DbInstance.ExecuteSql("update blog_tb_article_content set articleContent=@articleContent+articleContent,UPDATE_DATE=@UPDATE_DATE where articleID in (" + ids + ")" , DbInstance.CreateParameter("@articleContent", str) , DbInstance.CreateParameter("@UPDATE_DATE", DateTime.Now)); DbInstance.Commit(); return result; }