Beispiel #1
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(NewVsImgModel model)
        {
            bool          reValue = true;
            int           reCount = 0;
            StringBuilder strSql  = new StringBuilder();

            strSql.Append("update NewVsImg set ");

            strSql.Append(" ImgId = @ImgId , ");
            strSql.Append(" NewId = @NewId , ");
            strSql.Append(" OrderNo = @OrderNo  ");
            strSql.Append(" where AutoId=@AutoId ");

            SqlParameter[] parameters =
            {
                new SqlParameter("@AutoId",  SqlDbType.Decimal,  9),
                new SqlParameter("@ImgId",   SqlDbType.VarChar, 50),
                new SqlParameter("@NewId",   SqlDbType.Decimal,  9),
                new SqlParameter("@OrderNo", SqlDbType.Int, 4)
            };

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

            strSql.Append("insert into NewVsImg(");
            strSql.Append("ImgId,NewId,OrderNo");
            strSql.Append(") values (");
            strSql.Append("@ImgId,@NewId,@OrderNo");
            strSql.Append(") ");
            strSql.Append(";select @@IDENTITY");
            SqlParameter[] parameters =
            {
                new SqlParameter("@ImgId",   SqlDbType.VarChar, 50),
                new SqlParameter("@NewId",   SqlDbType.Decimal,  9),
                new SqlParameter("@OrderNo", SqlDbType.Int, 4)
            };

            parameters[0].Value = model.ImgId;
            parameters[1].Value = model.NewId;
            parameters[2].Value = model.OrderNo;

            bool result = false;

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