Exemplo n.º 1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(UserVsMerModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("update UserVsMer set ");

            strSql.Append(" AutoId = @AutoId , ");
            strSql.Append(" UserId = @UserId , ");
            strSql.Append(" MerchantId = @MerchantId , ");
            strSql.Append(" PostId = @PostId  ");
            strSql.Append(" where AutoId=@AutoId  ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@AutoId",     SqlDbType.Decimal,  9),
                new SqlParameter("@UserId",     SqlDbType.VarChar, 50),
                new SqlParameter("@MerchantId", SqlDbType.Decimal,  9),
                new SqlParameter("@PostId",     SqlDbType.Decimal, 9)
            };

            parameters[0].Value = model.AutoId;
            parameters[1].Value = model.UserId;
            parameters[2].Value = model.MerchantId;
            parameters[3].Value = model.PostId; try
            {//异常处理
                reCount = this.helper.ExecSqlReInt(strSql.ToString(), parameters);
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            if (reCount <= 0)
            {
                reValue = false;
            }
            return(reValue);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public bool Add(UserVsMerModel model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into UserVsMer(");
            strSql.Append("AutoId,UserId,MerchantId,PostId");
            strSql.Append(") values (");
            strSql.Append("@AutoId,@UserId,@MerchantId,@PostId");
            strSql.Append(") ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@AutoId",     SqlDbType.Decimal,  9),
                new SqlParameter("@UserId",     SqlDbType.VarChar, 50),
                new SqlParameter("@MerchantId", SqlDbType.Decimal,  9),
                new SqlParameter("@PostId",     SqlDbType.Decimal, 9)
            };

            parameters[0].Value = model.AutoId;
            parameters[1].Value = model.UserId;
            parameters[2].Value = model.MerchantId;
            parameters[3].Value = model.PostId;

            bool result = false;

            try
            {
                helper.ExecSqlReInt(strSql.ToString(), parameters);
                result = true;
            }
            catch (Exception ex)
            {
                this.helper.Close();
                throw ex;
            }
            finally
            {
            }
            return(result);
        }