예제 #1
0
        /// <summary>
        /// 添加一条记录
        /// </summary>
        public int Add(Product entity, IDbTransaction tran)
        {
            string sql = @"insert into [Product]
                               ([productName], [productNo], [marketPrice], [oemPrice], [tradeprice], [collects], [hits], [smallThumPic], [bigThumPic], [addTime], [status], [productTypeId], [creater], [keyword], [articleId], [taobaolink], [sale],[videourl],[Source],[Linepayment],[IsFree])
                               values
                               (@productName, @productNo, @marketPrice, @oemPrice, @tradeprice, @collects, @hits, @smallThumPic, @bigThumPic, @addTime, @status, @productTypeId, @creater, @keyword, @articleId, @taobaolink, @sale,@videourl,@Source,@Linepayment,@IsFree)";

            object param = new
            {
                productName = entity.ProductName,
                productNo = entity.ProductNo,
                marketPrice = entity.MarketPrice,
                oemPrice = entity.OemPrice,
                tradeprice = entity.Tradeprice,
                collects = entity.Collects,
                hits = entity.Hits,
                smallThumPic = entity.SmallThumPic,
                bigThumPic = entity.BigThumPic,
                addTime = entity.AddTime,
                status = entity.Status,
                productTypeId = entity.ProductTypeId,
                creater = entity.Creater,
                keyword = entity.Keyword,
                articleId = entity.ArticleId,
                taobaolink = entity.Taobaolink,
                sale = entity.Sale,
                videourl=entity.VideoUrl,
                Source = entity.Source,
                Linepayment = entity.Linepayment,
                IsFree = entity.IsFree

            };
            int count = tran.Connection.Execute(sql, param, tran);
            return count;
        }
 /// <summary>
 /// 绑定产品基本信息
 /// </summary>
 public void getProductDetail()
 {
     p = pbll.GetByPrimaryKey(pro_id).Entity;
     if (p.VideoUrl.Trim2() != "")
     {
         Isnotvideo = true;
     }
     //判断是否在限时抢购里
     var list = new Bll.Db.TimeSaleBll().GetAllandProduct(1, 1, " A.classid =(select Top 1 Id from TimeSaleClass where GETDATE() between StartTime and EndTime order by EndTime desc) and A.objectid=" + pro_id, null, " A.orderid desc").Entity;
     if (list.Items != null && list.Items.Count > 0)
         p.OemPrice = list.Items[0].SalePrice;
     if (p != null)
     {
         //淘宝链接
         if (p.Taobaolink != null)
             taobaolink = p.Taobaolink;
     }
     if (p.Linepayment)
     {
         isLinepayment = true;
     }
 }
예제 #3
0
        /// <summary>
        /// 添加一条记录
        /// </summary>
        public ResultSet Add(Product entity)
        {
            Func<Product, ResultStatus> validate = (_entity) =>
            {
                return new ResultStatus();
            };

            Func<Product, ResultStatus> op = (_entity) =>
            {
                int ret = new ProductDal().Add(entity);
                if (ret > 0)
                    return new ResultStatus();
                else
                    return new ResultStatus()
                    {
                        Success = false,
                        Code = StatusCollection.AddFailed.Code,
                        Description = StatusCollection.AddFailed.Description
                    };
            };

            return HandleBusiness(entity, op, validate);
        }
예제 #4
0
 /// <summary>
 /// 添加一条记录 返回自增ID
 /// </summary>
 public int AddAndReturn(Product entity)
 {
     return  new ProductDal().AddAndReturn(entity);
 }
예제 #5
0
        public int Update(Product entity)
        {
            //GetUpdateSql2
            string sql = @"update [Product] set productName=@productName, productNo=@productNo, marketPrice=@marketPrice, oemPrice=@oemPrice, tradeprice=@tradeprice, collects=@collects, hits=@hits, smallThumPic=@smallThumPic, bigThumPic=@bigThumPic, addTime=@addTime, status=@status, productTypeId=@productTypeId, creater=@creater, keyword=@keyword, articleId=@articleId, taobaolink=@taobaolink, sale=@sale,videourl=@videourl,Source=@Source,Linepayment=@Linepayment,IsFree=@IsFree  where id=@id ";
               object param = new
            {
               id = entity.Id,
               productName = entity.ProductName,
               productNo = entity.ProductNo,
               marketPrice = entity.MarketPrice,
               oemPrice = entity.OemPrice,
               tradeprice = entity.Tradeprice,
               collects = entity.Collects,
               hits = entity.Hits,
               smallThumPic = entity.SmallThumPic,
               bigThumPic = entity.BigThumPic,
               addTime = entity.AddTime,
               status = entity.Status,
               productTypeId = entity.ProductTypeId,
               creater = entity.Creater,
               keyword = entity.Keyword,
               articleId = entity.ArticleId,
               taobaolink = entity.Taobaolink,
               sale = entity.Sale,
               videourl = entity.VideoUrl,
               Source = entity.Source,
               Linepayment = entity.Linepayment,
               IsFree = entity.IsFree

            };

            using (IDbConnection conn = OpenConnection())
            {
                int count = conn.Execute(sql, param);
                return count;
            }
        }
예제 #6
0
        /// <summary>
        /// 添加一条记录 返回自增ID
        /// </summary>
        public int AddAndReturn(Product entity)
        {
            string sql = @"insert into [Product]
                               ([productName], [productNo], [marketPrice], [oemPrice], [tradeprice], [collects], [hits], [smallThumPic], [bigThumPic], [addTime], [status], [productTypeId], [creater], [keyword], [articleId], [taobaolink], [sale],[videourl],[Source],[Linepayment],[IsFree])
                               values
                               (@productName, @productNo, @marketPrice, @oemPrice, @tradeprice, @collects, @hits, @smallThumPic, @bigThumPic, @addTime, @status, @productTypeId, @creater, @keyword, @articleId, @taobaolink, @sale,@videourl,@Source,@Linepayment,@IsFree)";

            object param = new
            {
                productName = entity.ProductName,
                productNo = entity.ProductNo,
                marketPrice = entity.MarketPrice,
                oemPrice = entity.OemPrice,
                tradeprice = entity.Tradeprice,
                collects = entity.Collects,
                hits = entity.Hits,
                smallThumPic = entity.SmallThumPic,
                bigThumPic = entity.BigThumPic,
                addTime = entity.AddTime,
                status = entity.Status,
                productTypeId = entity.ProductTypeId,
                creater = entity.Creater,
                keyword = entity.Keyword,
                articleId = entity.ArticleId,
                taobaolink = entity.Taobaolink,
                sale = entity.Sale,
                videourl=entity.VideoUrl,
                Source = entity.Source,
                Linepayment = entity.Linepayment,
                IsFree = entity.IsFree

            };

            using (IDbConnection conn = OpenConnection())
            {
                 int row = conn.Execute(sql, entity);
                    if (row > 0)
                        return conn.Query<Product>("SELECT @@IDENTITY AS Id").Single<Product>().Id;
                    else
                        return -1;
            }
        }