/// <summary>
        /// 产品信息提交
        /// </summary>
        /// <returns></returns>
        public int ProductDetailEdit()
        {
            int     _productId       = FormString.IntSafeQ("productId");
            int     _productDetailId = FormString.IntSafeQ("productDetailId");
            int     _productType     = FormString.IntSafeQ("productType");
            int     _status          = FormString.IntSafeQ("status");
            int     _saleNum         = FormString.IntSafeQ("saleNum");
            decimal _tradePrice      = FormString.DecimalSafeQ("tradePrice");
            decimal _price           = FormString.DecimalSafeQ("price");

            int _stockNum = FormString.IntSafeQ("stockNum");

            ProductDetailEntity entity = new ProductDetailEntity();

            entity.ProductId   = _productId;
            entity.Id          = _productDetailId;
            entity.ProductType = _productType;
            entity.Status      = _status;
            entity.SaleNum     = _saleNum;
            entity.TradePrice  = _tradePrice;
            entity.Price       = _price;

            entity.StockNum = _stockNum;
            //if (_productType == (int)ProductType.SpecialPrice)
            //{
            //    entity.StockNum = _stockNum;
            //}
            //else if (_productType == (int)ProductType.Normal)
            //{
            //    entity.StockNum = 999999;
            //}
            int _result = ProductDetailBLL.Instance.AddProductDetail(entity);

            return(_result);
        }
示例#2
0
        public bool Post(ProductDetailModel model)
        {
            var entity = new ProductDetailEntity
            {
                Detail = model.Detail,

                ImgUrl1 = model.ImgUrl1,

                ImgUrl2 = model.ImgUrl2,

                ImgUrl3 = model.ImgUrl3,

                ImgUrl4 = model.ImgUrl4,

                ImgUrl5 = model.ImgUrl5,

//				Product = model.Product,
            };

            if (_ProductDetailService.Create(entity).Id > 0)
            {
                return(true);
            }
            return(false);
        }
示例#3
0
        /// <summary>
        /// 插入一条记录到表ProductDetail,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="productDetail">待插入的实体对象</param>
        public int AddProductDetail(ProductDetailEntity entity)
        {
            string    sql = @"insert into ProductDetail( [ProductId],[Price],[TradePrice],[StockNum],[SaleNum],[ProductType],[Status],IsBP,Sort)VALUES
			            ( @ProductId,@Price,@TradePrice,@StockNum,@SaleNum,@ProductType,@Status,@IsBP,@Sort);
			SELECT SCOPE_IDENTITY();"            ;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@ProductId", DbType.Int32, entity.ProductId);
            db.AddInParameter(cmd, "@Price", DbType.Decimal, entity.Price);
            db.AddInParameter(cmd, "@TradePrice", DbType.Decimal, entity.TradePrice);
            db.AddInParameter(cmd, "@StockNum", DbType.Int32, entity.StockNum);
            db.AddInParameter(cmd, "@SaleNum", DbType.Int32, entity.SaleNum);
            db.AddInParameter(cmd, "@ProductType", DbType.Int32, entity.ProductType);
            db.AddInParameter(cmd, "@Status", DbType.Int32, entity.Status);
            db.AddInParameter(cmd, "@IsBP", DbType.Int32, entity.IsBP);
            db.AddInParameter(cmd, "@Sort", DbType.Int32, entity.Sort);

            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
        public bool Post(ProductDetailModel model)
        {
            var entity = new ProductDetailEntity
            {
                Name              = model.Name,
                Detail            = model.Detail,
                Img               = model.Img,
                Img1              = model.Img1,
                Img2              = model.Img2,
                Img3              = model.Img3,
                Img4              = model.Img4,
                SericeInstruction = model.SericeInstruction,
                AddUser           = model.AddUser,
                AddTime           = model.AddTime,
                UpdUser           = model.UpdUser,
                UpdTime           = model.UpdTime,
                Ad1               = model.Ad1,
                Ad2               = model.Ad2,
                Ad3               = model.Ad3,
            };

            if (_productDetailService.Create(entity).Id > 0)
            {
                return(true);
            }
            return(false);
        }
示例#5
0
        /// <summary>
        /// 判断当前节点是否已存在相同的
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        public int  ExistNum(ProductDetailEntity entity)
        {
            ///id=0,判断总数,ID>0判断除自己之外的总数
            string sql = @"Select count(1) from dbo.[ProductDetail] WITH(NOLOCK) ";

            string where = "where ";
            if (entity.Id == 0)
            {
                where += " ProductId=@ProductId AND ProductType=@ProductType";
            }
            else
            {
                where += " Id<>@Id AND ProductId=@ProductId AND ProductType=@ProductType";
            }
            sql = sql + where;
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@ProductId", DbType.Int32, entity.ProductId);
            db.AddInParameter(cmd, "@ProductType", DbType.Int32, entity.ProductType);

            if (entity.Id > 0)
            {
                db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            }
            object identity = db.ExecuteScalar(cmd);

            if (identity == null || identity == DBNull.Value)
            {
                return(0);
            }
            return(Convert.ToInt32(identity));
        }
示例#6
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <ProductDetailEntity> GetProductDetailAll()
        {
            string sql = @"SELECT    [Id],[ProductId],[Price],[TradePrice],[StockNum],[SaleNum],[ProductType],[Status],[TimeStampCode] from dbo.[ProductDetail] WITH(NOLOCK)	";
            IList <ProductDetailEntity> entityList = new List <ProductDetailEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    ProductDetailEntity entity = new ProductDetailEntity();
                    entity.Id            = StringUtils.GetDbInt(reader["Id"]);
                    entity.ProductId     = StringUtils.GetDbInt(reader["ProductId"]);
                    entity.Price         = StringUtils.GetDbDecimal(reader["Price"]);
                    entity.TradePrice    = StringUtils.GetDbDecimal(reader["TradePrice"]);
                    entity.StockNum      = StringUtils.GetDbInt(reader["StockNum"]);
                    entity.SaleNum       = StringUtils.GetDbInt(reader["SaleNum"]);
                    entity.ProductType   = StringUtils.GetDbInt(reader["ProductType"]);
                    entity.Status        = StringUtils.GetDbInt(reader["Status"]);
                    entity.TimeStampCode = StringUtils.GetDbString(reader["TimeStampCode"]);
                    entityList.Add(entity);
                }
            }
            return(entityList);
        }
示例#7
0
        /// <summary>
        /// 添加商品
        /// </summary>
        /// <param name="model">商品model</param>
        /// <returns>提示信息</returns>
        public HttpResponseMessage Post(ProductModel model)
        {
            var category = _categoryService.GetCategoryById(model.CategoryId);
            var entity   = new ProductEntity
            {
                Category     = category,
                BussnessId   = model.BussnessId,
                BussnessName = model.BussnessName,
                Price        = model.Price,
                Name         = model.Name,
                Status       = model.Status,
                MainImg      = model.MainImg,
                IsRecommend  = model.IsRecommend,
                Sort         = model.Sort,
                Stock        = model.Stock,
                AddUser      = _workContext.CurrentUser.Id,
                AddTime      = DateTime.Now,
                UpdUser      = _workContext.CurrentUser.Id,
                UpdTime      = DateTime.Now,
                Subtitte     = model.Subtitte,
                Contactphone = model.Contactphone,
                Type         = model.Type,
                OldPrice     = model.OldPrice,
                Owner        = model.Owner
                               // Detail = model.Detail,
                               //Comments = model.Comments,
//				Parameters = model.Parameters,
            };
            int id = _productService.Create(entity).Id;

            if (id > 0)
            {
                var productDetail = new ProductDetailEntity
                {
                    Id                = id,
                    Name              = model.Name,
                    Detail            = model.Detail,
                    Img               = model.Img,
                    Img1              = model.Img1,
                    Img2              = model.Img2,
                    Img3              = model.Img3,
                    Img4              = model.Img4,
                    SericeInstruction = model.SericeInstruction,
                    AddUser           = _workContext.CurrentUser.Id,
                    AddTime           = DateTime.Now,
                    UpdUser           = _workContext.CurrentUser.Id,
                    UpdTime           = DateTime.Now,
                    Ad1               = model.Ad1,
                    Ad2               = model.Ad2,
                    Ad3               = model.Ad3,
                };
                if (_productDetailService.Create(productDetail).Id > 0)
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功")));
                }
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "商品详细添加失败")));
            }
            return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败")));
        }
 public ProductDetailEntity Update(ProductDetailEntity entity)
 {
     try
     {
         _productdetailRepository.Update(entity);
         return(entity);
     }
     catch (Exception e)
     {
         _log.Error(e, "数据库操作出错");
         return(null);
     }
 }
 public bool Delete(ProductDetailEntity entity)
 {
     try
     {
         _productdetailRepository.Delete(entity);
         return(true);
     }
     catch (Exception e)
     {
         _log.Error(e, "数据库操作出错");
         return(false);
     }
 }
示例#10
0
 /// <summary>
 /// 插入一条记录到表ProductDetail,如果表中存在自增字段,则返回值为新记录的自增字段值,否则返回0。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="productDetail">要添加的ProductDetail数据实体对象</param>
 public int AddProductDetail(ProductDetailEntity productDetail)
 {
     if (productDetail.Id > 0)
     {
         return(UpdateProductDetail(productDetail));
     }
     else if (ProductDetailBLL.Instance.IsExist(productDetail))
     {
         return((int)CommonStatus.ADD_Fail_Exist);
     }
     else
     {
         return(ProductDetailDA.Instance.AddProductDetail(productDetail));
     }
 }
示例#11
0
        /// <summary>
        /// 读取记录列表。
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="columns">需要返回的列,不提供任何列名时默认将返回所有列</param>
        public IList <ProductDetailEntity> GetProductDetailList(int pagesize, int pageindex, ref int recordCount)
        {
            string sql = @"SELECT   [Id],[ProductId],[Price],[TradePrice],[StockNum],[SaleNum],[ProductType],[Status],[TimeStampCode]
						FROM
						(SELECT ROW_NUMBER() OVER (ORDER BY Id desc) AS ROWNUMBER,
						 [Id],[ProductId],[Price],[TradePrice],[StockNum],[SaleNum],[ProductType],[Status],[TimeStampCode] from dbo.[ProductDetail] WITH(NOLOCK)	
						WHERE  1=1 ) as temp 
						where rownumber BETWEEN ((@PageIndex - 1) * @PageSize + 1) AND @PageIndex * @PageSize"                        ;

            string sql2 = @"Select count(1) from dbo.[ProductDetail] with (nolock) ";
            IList <ProductDetailEntity> entityList = new List <ProductDetailEntity>();
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@PageIndex", DbType.Int32, pageindex);
            db.AddInParameter(cmd, "@PageSize", DbType.Int32, pagesize);

            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                while (reader.Read())
                {
                    ProductDetailEntity entity = new ProductDetailEntity();
                    entity.Id            = StringUtils.GetDbInt(reader["Id"]);
                    entity.ProductId     = StringUtils.GetDbInt(reader["ProductId"]);
                    entity.Price         = StringUtils.GetDbDecimal(reader["Price"]);
                    entity.TradePrice    = StringUtils.GetDbDecimal(reader["TradePrice"]);
                    entity.StockNum      = StringUtils.GetDbInt(reader["StockNum"]);
                    entity.SaleNum       = StringUtils.GetDbInt(reader["SaleNum"]);
                    entity.ProductType   = StringUtils.GetDbInt(reader["ProductType"]);
                    entity.Status        = StringUtils.GetDbInt(reader["Status"]);
                    entity.TimeStampCode = StringUtils.GetDbString(reader["TimeStampCode"]);
                    entityList.Add(entity);
                }
            }
            cmd = db.GetSqlStringCommand(sql2);
            using (IDataReader reader = db.ExecuteReader(cmd))
            {
                if (reader.Read())
                {
                    recordCount = StringUtils.GetDbInt(reader[0]);
                }
                else
                {
                    recordCount = 0;
                }
            }
            return(entityList);
        }
示例#12
0
        /// <summary>
        /// 根据主键值更新记录的全部字段(注意:该方法不会对自增字段、timestamp类型字段以及主键字段更新!如果要更新主键字段,请使用Update方法)。
        /// 如果数据库有数据被更新了则返回True,否则返回False
        /// </summary>
        /// <param name="db">数据库操作对象</param>
        /// <param name="productDetail">待更新的实体对象</param>
        public int UpdateProductDetail(ProductDetailEntity entity)
        {
            string    sql = @" UPDATE dbo.[ProductDetail] SET
                       [ProductId]=@ProductId,[Price]=@Price,IsBP=@IsBP,[TradePrice]=@TradePrice,[DealerPrice]=@DealerPrice,[StockNum]=@StockNum,[SaleNum]=@SaleNum,[ProductType]=@ProductType,[Status]=@Status
                       WHERE [Id]=@id";
            DbCommand cmd = db.GetSqlStringCommand(sql);

            db.AddInParameter(cmd, "@Id", DbType.Int32, entity.Id);
            db.AddInParameter(cmd, "@ProductId", DbType.Int32, entity.ProductId);
            db.AddInParameter(cmd, "@Price", DbType.Decimal, entity.Price);
            db.AddInParameter(cmd, "@TradePrice", DbType.Decimal, entity.TradePrice);
            db.AddInParameter(cmd, "@DealerPrice", DbType.Decimal, entity.DealerPrice);
            db.AddInParameter(cmd, "@StockNum", DbType.Int32, entity.StockNum);
            db.AddInParameter(cmd, "@SaleNum", DbType.Int32, entity.SaleNum);
            db.AddInParameter(cmd, "@ProductType", DbType.Int32, entity.ProductType);
            db.AddInParameter(cmd, "@Status", DbType.Int32, entity.Status);
            db.AddInParameter(cmd, "@IsBP", DbType.Int32, entity.IsBP);
            return(db.ExecuteNonQuery(cmd));
        }
示例#13
0
        public HttpResponseMessage AddProduct([FromBody] JObject obj)
        {
            dynamic json           = obj;
            JObject JProduct       = json.product;
            JObject JProductDetail = json.productDetail;
            var     product        = JProduct.ToObject <ProductModel>();
            var     productDetail  = JProductDetail.ToObject <ProductDetailModel>();
            Regex   reg            = new Regex(@"^[^%@#!*~&',;=?$\x22]+$");
            var     m = reg.IsMatch(productDetail.Productname);

            if (!m)
            {
                return(PageHelper.toJson(PageHelper.ReturnValue(false, "存在非法字符!")));
            }
            else
            {
                //先创建productDetail,跟据部分productDetail部分重叠信息创建product;
                ProductDetailEntity PDE = new ProductDetailEntity()
                {
                    Id                = 0,
                    Productdetail     = productDetail.Productdetail,
                    Productimg        = productDetail.Productimg,
                    Productimg1       = productDetail.Productimg1,
                    Productimg2       = productDetail.Productimg2,
                    Productimg3       = productDetail.Productimg3,
                    Productimg4       = productDetail.Productimg4,
                    Productname       = productDetail.Productname,
                    Sericeinstruction = productDetail.Sericeinstruction,
                    Ad1               = productDetail.Ad1,
                    Addtime           = DateTime.Now,
                    //Adduser = productDetail.Adduser,
                    Adduser = _workContent.CurrentUser.Id.ToString(),
                    Updtime = DateTime.Now,
                    //Upduser = productDetail.Upduser
                    Upduser = _workContent.CurrentUser.Id.ToString()
                };

                ProductDetailEntity PDE2 = _productDetailService.Create(PDE);
                ClassifyEntity      CE   = _classifyService.GetClassifyById(product.ClassifyId);
                ProductBrandEntity  CBE  = _productBrandService.GetProductBrandById(product.ProductBrandId);
                ProductEntity       PE   = new ProductEntity()
                {
                    Bussnessid     = product.Bussnessid,
                    BussnessName   = "yoopoon",
                    Commission     = product.Commission,
                    RecCommission  = product.RecCommission,
                    Dealcommission = product.Dealcommission,
                    Price          = product.Price,
                    Classify       = CE,
                    ProductBrand   = CBE,
                    ProductDetail  = PDE2,
                    Productimg     = product.Productimg,
                    Productname    = PDE.Productname,
                    Recommend      = product.Recommend,
                    Sort           = product.Sort,
                    Status         = product.Status,
                    Stockrule      = product.Stockrule,
                    SubTitle       = product.SubTitle,
                    ContactPhone   = product.ContactPhone,
                    Updtime        = DateTime.Now,
                    //Upduser = PDE.Upduser,
                    Upduser = _workContent.CurrentUser.Id.ToString(),
                    Addtime = DateTime.Now,
                    //Adduser = PDE.Adduser
                    Adduser = _workContent.CurrentUser.Id.ToString()
                };
                var Product = _productService.Create(PE);
                if (Product != null)
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(true, "数据添加成功!", Product.Id)));
                }
                else
                {
                    return(PageHelper.toJson(PageHelper.ReturnValue(false, "数据添加失败!")));
                }
            }
            //try
            //{
            //    return _productService.Create(PE).Id;
            //}
            //catch (Exception e)
            //{
            //    return -1;
            //}
        }
示例#14
0
 /// <summary>
 /// 更新一条ProductDetail记录。
 /// 该方法提供给界面等UI层调用
 /// </summary>
 /// <param name="productDetail">待更新的实体对象</param>
 /// <param name="columns">要更新的列名,不提供任何列名时默认将更新主键之外的所有列</param>
 public int UpdateProductDetail(ProductDetailEntity productDetail)
 {
     return(ProductDetailDA.Instance.UpdateProductDetail(productDetail));
 }
示例#15
0
 /// <summary>
 /// 判断对象是否存在
 /// </summary>
 /// <param name="dicEnum"></param>
 /// <returns></returns>
 public bool IsExist(ProductDetailEntity productDetail)
 {
     return(ProductDetailDA.Instance.ExistNum(productDetail) > 0);
 }