Ejemplo n.º 1
0
        /// <summary>
        /// 增加一条数据 返回是否成功
        /// </summary>
        public bool Add(DSWebService.Model.Data_Centre.Link_Mid model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into Link_Mid(");
            strSql.Append("id,iden,sum,StockType,PriceType)");

            strSql.Append(" values (");
            strSql.Append("@id,@iden,@sum,@StockType,@PriceType)");
            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "id", DbType.Int32, model.id);
            db.AddInParameter(dbCommand, "iden", DbType.Int32, model.iden);
            db.AddInParameter(dbCommand, "Sum", DbType.Decimal, model.Sum);
            db.AddInParameter(dbCommand, "StockType", DbType.Decimal, model.StockType);
            db.AddInParameter(dbCommand, "PriceType", DbType.Decimal, model.PriceType);
            int x = db.ExecuteNonQuery(dbCommand);

            return(x > 0 ? true : false);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(DSWebService.Model.Data_Centre.Link_Mid model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update Link_Mid set ");
            strSql.Append("iden=@iden,");
            strSql.Append("Sum=@Sum,");
            strSql.Append("StockType=@StockType,");
            strSql.Append("PriceType=@PriceType,");
            strSql.Append("updated=@updated");
            strSql.Append(" where id=@id and iden=@iden ");

            DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());

            db.AddInParameter(dbCommand, "id", DbType.Int32, model.id);
            db.AddInParameter(dbCommand, "iden", DbType.Int32, model.iden);
            db.AddInParameter(dbCommand, "Sum", DbType.Decimal, model.Sum);
            db.AddInParameter(dbCommand, "StockType", DbType.Decimal, model.StockType);
            db.AddInParameter(dbCommand, "PriceType", DbType.Decimal, model.PriceType);
            db.AddInParameter(dbCommand, "updated", DbType.DateTime, model.Updated);
            int rows = db.ExecuteNonQuery(dbCommand);

            return(rows > 0 ? true : false);
        }