/// <summary> /// 增加一条数据 /// </summary> public bool Add(InformationVsCommentModel model) { StringBuilder strSql = new StringBuilder(); strSql.Append("insert into InformationVsComment("); strSql.Append("CommentId,InformationId,vsType"); strSql.Append(") values ("); strSql.Append("@CommentId,@InformationId,@vsType"); strSql.Append(") "); SqlParameter[] parameters = { new SqlParameter("@CommentId", SqlDbType.Decimal, 9), new SqlParameter("@InformationId", SqlDbType.Decimal, 9), new SqlParameter("@vsType", SqlDbType.VarChar, 10) }; parameters[0].Value = model.CommentId; parameters[1].Value = model.InformationId; 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 InformationVsCommentModel GetModel(decimal CommentId, decimal InformationId) { StringBuilder strSql = new StringBuilder(); strSql.Append("select CommentId, InformationId, vsType "); strSql.Append(" from InformationVsComment "); strSql.Append(" where CommentId=@CommentId and InformationId=@InformationId "); SqlParameter[] parameters = { new SqlParameter("@CommentId", SqlDbType.Decimal, 9), new SqlParameter("@InformationId", SqlDbType.Decimal, 9) }; parameters[0].Value = CommentId; parameters[1].Value = InformationId; InformationVsCommentModel model = new InformationVsCommentModel(); DataSet ds = helper.ExecSqlReDs(strSql.ToString(), parameters); if (ds.Tables[0].Rows.Count > 0) { if (ds.Tables[0].Rows[0]["CommentId"].ToString() != "") { model.CommentId = decimal.Parse(ds.Tables[0].Rows[0]["CommentId"].ToString()); } if (ds.Tables[0].Rows[0]["InformationId"].ToString() != "") { model.InformationId = decimal.Parse(ds.Tables[0].Rows[0]["InformationId"].ToString()); } model.vsType = ds.Tables[0].Rows[0]["vsType"].ToString(); return(model); } else { return(model); } }
/// <summary> /// 更新一条数据 /// </summary> public bool Update(InformationVsCommentModel model) { bool reValue = true; int reCount = 0; StringBuilder strSql = new StringBuilder(); strSql.Append("update InformationVsComment set "); strSql.Append(" CommentId = @CommentId , "); strSql.Append(" InformationId = @InformationId , "); strSql.Append(" vsType = @vsType "); strSql.Append(" where CommentId=@CommentId and InformationId=@InformationId "); SqlParameter[] parameters = { new SqlParameter("@CommentId", SqlDbType.Decimal, 9), new SqlParameter("@InformationId", SqlDbType.Decimal, 9), new SqlParameter("@vsType", SqlDbType.VarChar, 10) }; parameters[0].Value = model.CommentId; parameters[1].Value = model.InformationId; 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); }