Beispiel #1
0
        //public IHttpActionResult PostProductImage(Guid ProductId, bool PrimaryImage)
        public IHttpActionResult PostProductImage(Guid ProductId, bool PrimaryImage)
        {
            var file = HttpContext.Current.Request.Files.Count > 0 ?
                       HttpContext.Current.Request.Files[0] : null;

            var productImageDTO = ProductManager.InsertProductImage(ProductId, file, PrimaryImage);

            var propertyList = new JavaScriptSerializer().Deserialize <List <ProductPropertyModel> >(productImageDTO.ProductProperties);

            var productImage = new ProductImageModel
            {
                Id                = productImageDTO.Id,
                PrimaryImage      = productImageDTO.PrimaryImage,
                SelectedForExport = productImageDTO.SelectedForExport,
                Path              = productImageDTO.Path,
                ProductProperties = propertyList,
                Name              = productImageDTO.Name,
                Category          = productImageDTO.Category,
                ErrorMessage      = productImageDTO.ErrorMessage
            };

            //if (PrimaryImage)
            //{
            //    ProductManager.SetPrimaryImage(productImageDTO.Id);
            //}
            return(Ok(productImage));
        }
        public async Task <IActionResult> Edit([FromRoute] Guid Id, [FromBody] ProductImageModel obj)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (Id != obj.Id)
            {
                return(BadRequest());
            }

            var dataModel = _mapper.Map <ProductImageModel>(obj);

            _context.Entry(dataModel).State = EntityState.Modified;

            try
            {
                await _context.SaveChangesAsync();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!Exists(Id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(NoContent());
        }
        /// <summary>
        /// 产品图类型
        /// </summary>
        /// <param name="model"></param>
        /// <remarks>added by jimmy,2015-7-28</remarks>
        private void DrowList(ProductImageModel model)
        {
            //状态
            var states = new Dictionary <int, string>();

            states.Add(1, "Picture");
            states.Add(2, "Video");
            var list = new List <SelectListItem>();

            if (states != null)
            {
                foreach (var item in states)
                {
                    var info = new SelectListItem();
                    if (model != null && model.ImageType != 0)
                    {
                        if (model.ImageType == item.Key)
                        {
                            info.Selected = true;
                        }
                    }
                    info.Value = item.Key.ToString();
                    info.Text  = item.Value;
                    list.Add(info);
                }
            }
            ViewData["ImageType"] = list;
        }
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <ProductImageModel> GetModelList(string strWhere)
        {
            DataSet ds = dal.GetList(strWhere);
            List <ProductImageModel> modelList = new List <ProductImageModel>();
            int rowsCount = ds.Tables[0].Rows.Count;

            if (rowsCount > 0)
            {
                ProductImageModel model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new ProductImageModel();
                    if (ds.Tables[0].Rows[n]["ImageId"].ToString() != "")
                    {
                        model.ImageId = int.Parse(ds.Tables[0].Rows[n]["ImageId"].ToString());
                    }
                    if (ds.Tables[0].Rows[n]["ProductId"].ToString() != "")
                    {
                        model.ProductId = int.Parse(ds.Tables[0].Rows[n]["ProductId"].ToString());
                    }
                    model.SmallImage  = ds.Tables[0].Rows[n]["SmallImage"].ToString();
                    model.LargeImage  = ds.Tables[0].Rows[n]["LargeImage"].ToString();
                    model.OriginImage = ds.Tables[0].Rows[n]["OriginImage"].ToString();
                    model.Title       = ds.Tables[0].Rows[n]["Title"].ToString();
                    modelList.Add(model);
                }
            }
            return(modelList);
        }
        /// <summary>
        /// 添加产品图
        /// </summary>
        /// <param name="model">产品图对象</param>
        /// <returns></returns>
        /// <remarks>added by jimmy,2015-7-27</remarks>
        public ResultModel Add(ProductImageModel model)
        {
            var result = new ResultModel {
                Data = _database.Db.ProductImage.Insert(model)
            };

            return(result);
        }
        public static ProductImageModel GetMultiImageUrl(ProductImageModel MultiImage)
        {
            MultiImage.SmallImage  = config.UrlRoot + MultiImage.SmallImage;
            MultiImage.LargeImage  = config.UrlRoot + MultiImage.LargeImage;
            MultiImage.OriginImage = config.UrlRoot + MultiImage.OriginImage;

            return(MultiImage);
        }
        public static ProductImageModel GetMultiImageUrl(ProductImageModel MultiImage)
        {
            MultiImage.SmallImage = config.UrlRoot + MultiImage.SmallImage;
            MultiImage.LargeImage = config.UrlRoot + MultiImage.LargeImage;
            MultiImage.OriginImage = config.UrlRoot + MultiImage.OriginImage;

            return MultiImage;
        }
 public static ProductImage Map(this ProductImageModel source)
 {
     return(new ProductImage
     {
         Id = source.Id,
         Image = source.Image,
         ProductId = source.ProductId
     });
 }
        private static ProductModel GetProductDetail(Guid id)
        {
            var dbProduct          = ProductManager.GetProduct(id);
            var dbProductImageList = ProductManager.GetProductImages(id);

            var productImageModelList = new List <ProductImageModel>();

            foreach (var dbProductImage in dbProductImageList)
            {
                var productImageModel = new ProductImageModel
                {
                    Id           = dbProductImage.Id,
                    Path         = dbProductImage.Path,
                    PrimaryImage = dbProductImage.PrimaryImage
                };
                productImageModelList.Add(productImageModel);
            }

            List <ProductPropertyModel> propertyList = new List <ProductPropertyModel>();

            if (dbProduct.Properties != null)
            {
                propertyList = new JavaScriptSerializer().Deserialize <List <ProductPropertyModel> >(dbProduct.Properties);
            }

            int tmpCost;

            if (dbProduct.ShippingCost == null)
            {
                tmpCost = 0;
            }
            else
            {
                tmpCost = (int)dbProduct.ShippingCost;
            }

            //Todo: Fixa Category Icon!
            var product = new ProductModel
            {
                Id                = dbProduct.Id,
                Name              = dbProduct.Name,
                Category          = dbProduct.Category,
                Price             = dbProduct.Price,
                ProductImages     = productImageModelList,
                ProductProperties = propertyList,
                CategoryIcon      = "bookmark_border",
                Comment           = dbProduct.Comment,
                Condition         = dbProduct.ProductConditionId,
                Status            = dbProduct.ProductStatusId,
                ProductNumber     = dbProduct.ProductNumber,
                Shipping          = dbProduct.Shipping,
                ShippingCost      = tmpCost
            };

            return(product);
        }
 /// <summary>
 ///  ����һ������
 /// </summary>
 public void Add(ProductImageModel model)
 {
     DbCommand dbCommand = dbw.GetStoredProcCommand("UP_pdProductImage_ADD");
     dbw.AddInParameter(dbCommand, "ImageId", DbType.Int32, model.ImageId);
     dbw.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId);
     dbw.AddInParameter(dbCommand, "SmallImage", DbType.AnsiString, model.SmallImage);
     dbw.AddInParameter(dbCommand, "LargeImage", DbType.AnsiString, model.LargeImage);
     dbw.AddInParameter(dbCommand, "OriginImage", DbType.AnsiString, model.OriginImage);
     dbw.AddInParameter(dbCommand, "Title", DbType.AnsiString, model.Title);
     dbw.ExecuteNonQuery(dbCommand);
 }
        /// <summary>
        ///  更新一条数据
        /// </summary>
        public void Update(ProductImageModel model)
        {
            DbCommand dbCommand = dbw.GetStoredProcCommand("UP_pdProductImage_Update");

            dbw.AddInParameter(dbCommand, "ImageId", DbType.Int32, model.ImageId);
            dbw.AddInParameter(dbCommand, "ProductId", DbType.Int32, model.ProductId);
            dbw.AddInParameter(dbCommand, "SmallImage", DbType.AnsiString, model.SmallImage);
            dbw.AddInParameter(dbCommand, "LargeImage", DbType.AnsiString, model.LargeImage);
            dbw.AddInParameter(dbCommand, "OriginImage", DbType.AnsiString, model.OriginImage);
            dbw.AddInParameter(dbCommand, "Title", DbType.AnsiString, model.Title);
            dbw.ExecuteNonQuery(dbCommand);
        }
Beispiel #12
0
        public ActionResult UploadProductImage(ProductImageModel model)
        {
            HttpPostedFileBase file = Request.Files["ImageData"];
            var result = UploadImageInDataBase(file, model);

            if (returnMessages.Count > 0)
            {
                ViewBag.MyErrorMessage     = returnMessages;
                ViewData["MyErrorMessage"] = returnMessages;
            }
            return(View("Index"));
        }
        public static ProductImageModel GetProductImage(ProductImage productImage)
        {
            var model = new ProductImageModel
            {
                Id                 = productImage.Id,
                ImagePath          = productImage.ImagePath,
                ProducVariation_Id = productImage.ProductVariation_Id,
                CreateDate         = productImage.CreatedDate,
                UpdateDate         = productImage.UpdatedDate,
                IsActive           = productImage.IsActive
            };

            return(model);
        }
        public ActionResult ProductImageIndex()
        {
            var model = new ProductImageModel
            {
                Id         = GetParams <int>("id"),
                ProductId  = GetParams <string>("productid"),
                ImageId    = GetParams <string>("imageid"),
                Status     = GetParams <int>("status"),
                Createtime = GetParams <DateTime>("createtime"),
                Updatetime = GetParams <DateTime>("updatetime"),
            };

            return(View(model));
        }
Beispiel #15
0
        public bool UploadImageInDataBase(HttpPostedFileBase file, ProductImageModel model)
        {
            var productToEdit = _unitOfWork.ProductRepository.Get().Where(p => p.ID == model.ID).FirstOrDefault();

            if (productToEdit != null)
            {
                productToEdit.ProductImage = ConvertToBytes(file);

                _unitOfWork.ProductRepository.Update(productToEdit);
                _unitOfWork.Save();
                returnMessages.Add("Image Added to the Product Name " + productToEdit.Name);
                return(true);
            }
            return(false);
        }
        public async Task <BaseResult> CreateOrUpdate(ProductImageModel model)
        {
            var result       = new BaseResult();
            var ProductImage = model.ToProductImage();

            //Cập nhật thông tin chung của thực thể
            ProductImage = ProductImage.UpdateCommonInt();

            // kiểm tra trùng lặp trong dtb
            var query = _ProductImageRepository.Query().FirstOrDefault(
                x => (x.ProductId == ProductImage.ProductId && x.ImageId == ProductImage.ImageId));

            if (query != null)
            {
                result.Result  = Result.Failed;
                result.Message = "Ảnh đã được thêm trước đó!";
                return(result);
            }
            // Kiểm tra xem sp và hình ảnh có tồn tại hay không
            var isProductExist = _productRepository.Query().FirstOrDefault(
                x => x.Id == ProductImage.ProductId);
            var isImageExist = _productRepository.Query().FirstOrDefault(
                x => x.Id == ProductImage.ImageId);

            if (isProductExist == null)
            {
                result.Result  = Result.Failed;
                result.Message = "Sản phẩm không tồn tại!";
                return(result);
            }
            if (isImageExist == null)
            {
                result.Result  = Result.Failed;
                result.Message = "Hình ảnh không tồn tại!";
                return(result);
            }

            if (ProductImage.Id > 0)
            {
                //Cập nhật
                return(await Update(ProductImage));
            }
            else
            {
                //Thêm mới
                return(await Create(ProductImage));
            }
        }
Beispiel #17
0
        public ProductSaleModel GetDefaultModel()
        {
            var productInfo = _unitOfWork.ProductRepository.Get();
            List <ProductImageModel> prodList  = new List <ProductImageModel>();
            ProductSaleModel         modelInfo = new ProductSaleModel();

            foreach (var product in productInfo)
            {
                ProductImageModel modelinfo = new ProductImageModel();
                modelinfo.ID   = product.ID;
                modelinfo.Name = product.Name;
                prodList.Add(modelinfo);
            }
            modelInfo.ProductOptions = prodList.ToList();
            return(modelInfo);
        }
 public static ProductImagePO ToPO(this ProductImageModel item)
 {
     if (item == null)
     {
         return(null);
     }
     return(new ProductImagePO
     {
         Id = item.Id,
         ProductId = item.ProductId,
         ImageId = item.ImageId,
         Status = item.Status,
         Createtime = item.Createtime,
         Updatetime = item.Updatetime,
     });
 }
Beispiel #19
0
        public ActionResult UploadProductImage()
        {
            List <ProductImageModel> prodList  = new List <ProductImageModel>();
            ProductImageModel        modelInfo = new ProductImageModel();
            var productInfo = _unitOfWork.ProductRepository.Get();

            foreach (var product in productInfo)
            {
                ProductImageModel model = new ProductImageModel();
                model.ID   = product.ID;
                model.Name = product.Name;
                prodList.Add(model);
            }
            modelInfo.ProductOptions = prodList.ToList();
            return(View(modelInfo));
        }
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public ProductImageModel GetModel(int ImageId)
        {
            DbCommand dbCommand = dbr.GetStoredProcCommand("UP_pdProductImage_GetModel");

            dbr.AddInParameter(dbCommand, "ImageId", DbType.Int32, ImageId);

            ProductImageModel model = null;

            using (IDataReader dataReader = dbr.ExecuteReader(dbCommand))
            {
                if (dataReader.Read())
                {
                    model = ReaderBind(dataReader);
                }
            }
            return(model);
        }
        /// <summary>
        /// 更新产品图
        /// </summary>
        /// <param name="model">产品图对象</param>
        /// <returns>返回true时,表示更新成功;反之,表示更新失败</returns>
        /// <remarks>added by jimmy,2015-7-27</remarks>
        public ResultModel Update(ProductImageModel model)
        {
            dynamic record = new SimpleRecord();

            record.ProductImageId = model.ProductImageId;
            record.ProductName    = model.ProductName;
            record.ImageUrl       = model.ImageUrl;
            record.ImageType      = model.ImageType;
            record.linkUrl        = model.linkUrl;
            record.UpdateBy       = model.UpdateBy;
            record.UpdateDT       = model.UpdateDT;
            var result = new ResultModel()
            {
                Data = this._database.Db.ProductImage.UpdateByProductImageId(record)
            };

            return(result);
        }
Beispiel #22
0
        public ActionResult Create([Bind(Include = "Id,Name,DataInHttpPostedFileBase")]  ProductImageModel productImageModel)
        {
            if (ModelState.IsValid)
            {
                //mapping
                ProductImage image = new ProductImage()
                {
                    Name = productImageModel.Name,
                    //Using own method to convert the posted file to a bytearray
                    Data = ConvertHttpPostedFileBaseToByteArray(productImageModel.DataInHttpPostedFileBase)
                };

                db.ProductImage.Add(image);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(productImageModel));
        }
        public ActionResult Create(ProductImageModel model)
        {
            var admin = UserInfo.CurrentUserName;

            if (ModelState.IsValid)
            {
                var resultModel = new ResultModel();
                if (model.ProductImageId != 0)
                {
                    model.UpdateBy = admin;
                    model.UpdateDT = DateTime.Now;
                    model.linkUrl  = !string.IsNullOrEmpty(model.linkUrl) && model.linkUrl.Length > 7 && model.linkUrl.Contains("http://") ? model.linkUrl : string.Empty;
                    var result = _productImageService.Update(model);
                    resultModel.Messages = new List <string>
                    {
                        result.Data > 0 ? "Modify product picture success" : "Modify product picture failed"
                    };
                    var opera = string.Format("修改产品图:{0},操作结果:{1}", JsonConverts.ToJson(model), result.Data > 0 ? "成功" : "失败");
                    LogPackage.InserAC_OperateLog(opera, "企业信息--产品图");
                }
                else
                {
                    model.ProductImageId = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    model.CreateBy       = admin;
                    model.CreateDT       = DateTime.Now;
                    model.UpdateBy       = admin;
                    model.UpdateDT       = DateTime.Now;
                    model.linkUrl        = !string.IsNullOrEmpty(model.linkUrl) && model.linkUrl.Length > 7 && model.linkUrl.Contains("http://") ? model.linkUrl : string.Empty;
                    model.place          = MemCacheFactory.GetCurrentMemCache().Increment("commonId");
                    resultModel.Messages = new List <string>
                    {
                        _productImageService.Add(model).Messages.Count == 0 ? "Add product picture success" : "Add product picture failed"
                    };
                }
                return(Json(resultModel, JsonRequestBehavior.AllowGet));
            }
            else
            {
                DrowList(null);
            }
            return(PartialView(model));
        }
        private static void AddProductMultiImage(int ProductID, string CatePath, string ImageRelativeURL)
        {
            string ImageFullURL = UrlPrefix + ImageRelativeURL;
            FileInfo ImageFile = DownloadImage(ImageFullURL);
            if (!ImageFile.Directory.Exists) Directory.CreateDirectory(ImageFile.Directory.FullName);
            string[] MultiImages;

            ProductMultiImageRule.SaveProductMultiImage(ProductID, CatePath, ImageFile, out MultiImages);

            ProductImageModel model = new ProductImageModel();

            model.ImageId = CommDataHelper.GetNewSerialNum("pd");
            model.ProductId = ProductID;
            model.LargeImage = MultiImages[1];
            model.OriginImage = MultiImages[2];
            model.SmallImage = MultiImages[0];
            model.Title = String.Empty;

            imgBll.Add(model);
        }
        /// <summary>
        /// 对象实体绑定数据
        /// </summary>
        public ProductImageModel ReaderBind(IDataReader dataReader)
        {
            ProductImageModel model = new ProductImageModel();
            object            ojb;

            ojb = dataReader["ImageId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ImageId = (int)ojb;
            }
            ojb = dataReader["ProductId"];
            if (ojb != null && ojb != DBNull.Value)
            {
                model.ProductId = (int)ojb;
            }
            model.SmallImage  = dataReader["SmallImage"].ToString();
            model.LargeImage  = dataReader["LargeImage"].ToString();
            model.OriginImage = dataReader["OriginImage"].ToString();
            model.Title       = dataReader["Title"].ToString();
            return(model);
        }
Beispiel #26
0
        // GET: ProductImages/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductImage      productImage      = db.ProductImage.Find(id);
            ProductImageModel productImageModel = new ProductImageModel();

            if (productImage == null)
            {
                return(HttpNotFound());
            }
            else
            {
                productImageModel.Id           = productImage.Id;
                productImageModel.Name         = productImage.Name;
                productImageModel.SourceString = ConvertImageDataToSourceString(productImage.Data);
            }
            return(View(productImageModel));
        }
        /// <summary>
        ///     加载数据
        /// </summary>
        /// <param name="id">对象系统Id</param>
        /// <returns></returns>
        public ActionResult Create(long?id)
        {
            ProductImageModel model = null;

            if (id.HasValue)
            {
                var result = _productImageService.GetProductImageById(id.Value);
                if (result.Data != null)
                {
                    model              = result.Data;
                    model.linkUrl      = !string.IsNullOrEmpty(model.linkUrl) ? model.linkUrl : "http://";
                    ViewBag.ImgUrl     = model.ImageUrl;
                    ViewBag.ShowImgUrl = imagePath + model.ImageUrl;
                }
            }
            else
            {
                model = new ProductImageModel();
            }
            DrowList(model);
            return(PartialView(model));
        }
Beispiel #28
0
        // GET: ProductImages/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ProductImage image = db.ProductImage.Find(id);

            ProductImageModel productImageModel = new ProductImageModel();

            if (image == null)
            {
                return(HttpNotFound());
            }
            else //mapping
            {
                productImageModel.Name = image.Name;
                productImageModel.Id   = image.Id;
            }


            return(View(productImageModel));
        }
Beispiel #29
0
        public ActionResult Edit([Bind(Include = "Id,Name,DataInHttpPostedFileBase")] ProductImageModel productImageModel)
        {
            if (ModelState.IsValid)
            {
                //Finding the image to change
                ProductImage image = db.ProductImage.Find(productImageModel.Id);

                //If the user posted a new picture change the imagedata,
                //else don't do anything with it
                if (productImageModel.DataInHttpPostedFileBase != null)
                {
                    //Using own method to convert the posted file to a bytearray
                    image.Data = ConvertHttpPostedFileBaseToByteArray(productImageModel.DataInHttpPostedFileBase);
                }

                image.Name = productImageModel.Name;

                db.Entry(image).State = EntityState.Modified;
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }
            return(View(productImageModel));
        }
Beispiel #30
0
        public IHttpActionResult PutProductImages(Guid id, ProductImageModel productImageModel)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != productImageModel.Id)
            {
                return(BadRequest());
            }


            var dbProductImage = new ProductImage
            {
                Id                = id,
                PrimaryImage      = productImageModel.PrimaryImage,
                SelectedForExport = productImageModel.SelectedForExport
            };

            ProductManager.UpdateProductImage(dbProductImage);

            return(StatusCode(HttpStatusCode.NoContent));
        }
        private static void AddProductMultiImage(int ProductID, string CatePath, string ImageRelativeURL)
        {
            string   ImageFullURL = UrlPrefix + ImageRelativeURL;
            FileInfo ImageFile    = DownloadImage(ImageFullURL);

            if (!ImageFile.Directory.Exists)
            {
                Directory.CreateDirectory(ImageFile.Directory.FullName);
            }
            string[] MultiImages;

            ProductMultiImageRule.SaveProductMultiImage(ProductID, CatePath, ImageFile, out MultiImages);

            ProductImageModel model = new ProductImageModel();

            model.ImageId     = CommDataHelper.GetNewSerialNum("pd");
            model.ProductId   = ProductID;
            model.LargeImage  = MultiImages[1];
            model.OriginImage = MultiImages[2];
            model.SmallImage  = MultiImages[0];
            model.Title       = String.Empty;

            imgBll.Add(model);
        }
 /// <summary>
 /// ��������б�
 /// </summary>
 public List<ProductImageModel> GetModelList(string strWhere)
 {
     DataSet ds = dal.GetList(strWhere);
     List<ProductImageModel> modelList = new List<ProductImageModel>();
     int rowsCount = ds.Tables[0].Rows.Count;
     if (rowsCount > 0)
     {
         ProductImageModel model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new ProductImageModel();
             if(ds.Tables[0].Rows[n]["ImageId"].ToString()!="")
             {
                 model.ImageId=int.Parse(ds.Tables[0].Rows[n]["ImageId"].ToString());
             }
             if(ds.Tables[0].Rows[n]["ProductId"].ToString()!="")
             {
                 model.ProductId=int.Parse(ds.Tables[0].Rows[n]["ProductId"].ToString());
             }
             model.SmallImage=ds.Tables[0].Rows[n]["SmallImage"].ToString();
             model.LargeImage=ds.Tables[0].Rows[n]["LargeImage"].ToString();
             model.OriginImage=ds.Tables[0].Rows[n]["OriginImage"].ToString();
             model.Title=ds.Tables[0].Rows[n]["Title"].ToString();
             modelList.Add(model);
         }
     }
     return modelList;
 }
Beispiel #33
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public bool Save(ProductImageModel model)
 {
     return(ProductImageRepository.Save(model.ToPO()));
 }
        private int AddProduct()
        {
            int rtnValue = 0;
            string strErr = "";
            if (this.txtProductName.Text == "")
            {
                strErr += "产品名称不能为空!\\n";
            }
            if (!PageValidate.IsDecimal(txtTradePrice.Text))
            {
                strErr += "市场价输入有误!\\n";
            }
            if (!PageValidate.IsDecimal(txtMerchantPrice.Text))
            {
                strErr += "销售价输入有误!\\n";
            }
            if (!PageValidate.IsDecimal(txtReducePrice.Text))
            {
                strErr += "直降价输入有误!\\n";
            }
            if (!PageValidate.IsNumber(txtScore.Text))
            {
                strErr += "商品积分输入有误!\\n";
            }
            if (!PageValidate.IsDecimal(txtWeight.Text))
            {
                strErr += "商品重量输入有误!\\n";
            }
            if (this.fulImage.FileName == "")
            {
                strErr += "产品图片不能为空!\\n";
            }
            if (this.txtKeywords.Text == "")
            {
                strErr += "关键词不能为空!\\n";
            }
            if (this.TextBox_Description.Text == "")
            {
                strErr += "商品简介不能为空!\\n";
            }
            if (!PageValidate.IsNumber(drpStatus.SelectedValue))
            {
                strErr += "商品状态选择有误!\\n";
            }
            int TempNewsID = 0;
            if (!String.IsNullOrEmpty(txtNewsID.Text) && !int.TryParse(txtNewsID.Text, out TempNewsID))
            {
                strErr += "关联资讯ID输入有误!\\n";
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                rtnValue = 1;
                return rtnValue;
            }

            if (bll.Exists(txtProductName.Text))
            {
                MessageBox.Show(this, "对不起,该商品名称已存在,无法添加同名商品");
                rtnValue = 1;
                return rtnValue;
            }
            CategoryModel cate = new CategoryModelBll().GetModel(Convert.ToInt32(txtCategoryID.Value));

            string[] MainImages;

            if (ProductMainImageRule.SaveProductMainImage(ProductID, cate.CatePath, fulImage.PostedFile, out MainImages))
            {
                ProductModel product = new ProductModel();

                product.ProductId = ProductID;
                product.ProductCode = String.IsNullOrEmpty(txtProductCode.Text) ? ProductID.ToString() : txtProductCode.Text;
                product.ProductName = txtProductName.Text;

                product.CateId = cate.CateId;
                product.CatePath = cate.CatePath;
                product.InsertTime = DateTime.Now;
                product.ChangeTime = DateTime.Now;
                product.Keywords = txtKeywords.Text;
                product.Brief = TextBox_Description.Text;
                product.BrandID = Convert.ToInt32(DropDown_Brand.SelectedValue);

                product.SmallImage = MainImages[0];
                product.MediumImage = MainImages[1];
                product.LargeImage = MainImages[2];

                product.MerchantPrice = Convert.ToDecimal(txtMerchantPrice.Text);
                product.ReducePrice = Convert.ToDecimal(txtReducePrice.Text);
                product.TradePrice = Convert.ToDecimal(txtTradePrice.Text);
                product.PageView = 0;
                product.Score = 0;
                //product.SortValue = "";
                product.Status = Convert.ToInt32(drpStatus.SelectedValue);
                product.Stock = int.MaxValue;

                product.Specifications = TextBox_Specification.Text;
                product.PackingList = TextBox_Packing.Text;
                product.AfterSaleService = TextBox_Service.Text;
                product.OfferSet = TextBox_OfferSet.Text;

                product.Weight = Convert.ToDecimal(txtWeight.Text);

                product.StockTip = GetStockTip();
                product.RelateProducts = txtRelateProduct.Text.Replace(",",",");

                new ProductNewsBll().Add(new ProductNewsModel() { ProdutID = ProductID, NewsID = TempNewsID });

                bll.Add(product);

                //添加产品检索属性
                foreach (GridViewRow row in GridView_Parameter.Rows)
                {
                    RadioButtonList ParameterValueList =((RadioButtonList)row.Cells[0].FindControl("RadioList_ParameterValue"));
                    if (!String.IsNullOrEmpty(ParameterValueList.SelectedValue))
                    {
                        int ParameterID = Convert.ToInt32(((HiddenField)row.Cells[0].FindControl("Hidden_ParameterID")).Value);
                        string ParameterValue = Convert.ToString(ParameterValueList.SelectedItem.Text);
                        ProductParaModel para = new ProductParaModel();

                        para.ParaId = ParameterID;
                        para.ProductId = product.ProductId;
                        para.ParaValue = ParameterValue;

                        pvBll.Add(para);
                    }
                }
                //添加产品基本属性
                foreach (GridViewRow row in GridView_Specification.Rows)
                {
                    RadioButtonList ParameterValueList = ((RadioButtonList)row.Cells[0].FindControl("RadioList_SpecificationValue"));
                    if (!String.IsNullOrEmpty(ParameterValueList.SelectedValue))
                    {
                        int ParameterID = Convert.ToInt32(((HiddenField)row.Cells[0].FindControl("Hidden_SpecificationID")).Value);
                        string ParameterValue = Convert.ToString(ParameterValueList.SelectedItem.Text);
                        ProductParaModel para = new ProductParaModel();

                        para.ParaId = ParameterID;
                        para.ProductId = product.ProductId;
                        para.ParaValue = ParameterValue;

                        pvBll.Add(para);
                    }
                }
                //添加商品多图
                foreach (string s in Request.Files.AllKeys)
                {
                    if (s.StartsWith("multiImageUpload") && Request.Files[s].ContentLength>0)
                    {
                        string[] FileNames;
                        ProductMultiImageRule.SaveProductMultiImage(ProductID,cate.CatePath, Request.Files[s], out FileNames);

                        if (FileNames != null)
                        {
                            ProductImageModel model = new ProductImageModel();
                            model.ImageId = CommDataHelper.GetNewSerialNum("pd");
                            model.ProductId = ProductID;
                            model.LargeImage = FileNames[1];
                            model.OriginImage = FileNames[2];
                            model.SmallImage = FileNames[0];
                            model.Title = String.Empty;

                            new ProductImageModelBll().Add(model);
                        }
                    }
                }

                //创建索引
                try
                {
                    DataIndexerProduct SearchIndexer = new DataIndexerProduct(Config.Searches["product"]);
                    SearchIndexer.CreateSingleIndex(new Search.Entities.ProductModel()
                    {
                        EntityIdentity = product.ProductId,
                        CategoryID = product.CateId,
                        CategoryPath = product.CatePath,
                        CreateTime = product.InsertTime,
                        Description = product.Brief,
                        Keywords = product.Keywords,
                        Price = product.MerchantPrice,
                        ProcessType = NoName.NetShop.Search.Entities.EntityProcessType.insert,
                        ProductImage = product.MediumImage,
                        ProductName = product.ProductName,
                        UpdateTime = product.ChangeTime
                    });
                }
                catch { }

                return rtnValue;
            }
            else
            {
                MessageBox.Show(this, "图片上传失败,请检查!");
                rtnValue = 1;
                return rtnValue;
            }
        }
 /// <summary>
 /// ����ʵ�������
 /// </summary>
 public ProductImageModel ReaderBind(IDataReader dataReader)
 {
     ProductImageModel model=new ProductImageModel();
     object ojb;
     ojb = dataReader["ImageId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.ImageId=(int)ojb;
     }
     ojb = dataReader["ProductId"];
     if(ojb != null && ojb != DBNull.Value)
     {
         model.ProductId=(int)ojb;
     }
     model.SmallImage=dataReader["SmallImage"].ToString();
     model.LargeImage=dataReader["LargeImage"].ToString();
     model.OriginImage=dataReader["OriginImage"].ToString();
     model.Title=dataReader["Title"].ToString();
     return model;
 }
 /// <summary>
 /// ����һ������
 /// </summary>
 public void Add(ProductImageModel model)
 {
     dal.Add(model);
 }
 public bool Save(ProductImageModel model)
 {
     return(new ProductImageService().Save(model));
 }
 /// <summary>
 /// ����һ������
 /// </summary>
 public void Update(ProductImageModel model)
 {
     dal.Update(model);
 }