Exemplo n.º 1
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(ProVsCommentModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into ProVsComment(");
            strSql.Append("ProId,CommentId,VsType");
            strSql.Append(") values (");
            strSql.Append("@ProId,@CommentId,@VsType");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ProId",     SqlDbType.VarChar, 50),
                new SqlParameter("@CommentId", SqlDbType.Decimal,  9),
                new SqlParameter("@VsType",    SqlDbType.VarChar, 10)
            };

            parameters[0].Value = model.ProId;
            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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(ProVsCommentModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("update ProVsComment set ");

            strSql.Append(" ProId = @ProId , ");
            strSql.Append(" CommentId = @CommentId , ");
            strSql.Append(" VsType = @VsType  ");
            strSql.Append(" where ProId=@ProId and CommentId=@CommentId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@ProId",     SqlDbType.VarChar, 50),
                new SqlParameter("@CommentId", SqlDbType.Decimal,  9),
                new SqlParameter("@VsType",    SqlDbType.VarChar, 10)
            };

            parameters[0].Value = model.ProId;
            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);
        }