Ejemplo n.º 1
0
 public static int AddProductPhoto(ProductPhotoInfo productPhoto)
 {
     productPhoto.ID = dal.AddProductPhoto(productPhoto);
     UploadBLL.UpdateUpload(TableID, productPhoto.ProductID, productPhoto.ID, Cookies.Admin.GetRandomNumber(false));
     ProductBLL.ChangeProductPhotoCount(productPhoto.ProductID, ChangeAction.Plus);
     return(productPhoto.ID);
 }
Ejemplo n.º 2
0
 public int AddProductPhoto(ProductPhotoInfo productPhoto)
 {
     SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@productID", SqlDbType.Int), new SqlParameter("@name", SqlDbType.NVarChar), new SqlParameter("@photo", SqlDbType.NVarChar) };
     pt[0].Value = productPhoto.ProductID;
     pt[1].Value = productPhoto.Name;
     pt[2].Value = productPhoto.Photo;
     return(Convert.ToInt32(ShopMssqlHelper.ExecuteScalar(ShopMssqlHelper.TablePrefix + "AddProductPhoto", pt)));
 }
Ejemplo n.º 3
0
        public void Update(ProductPhotoInfo entity)
        {
            using (var conn = new SqlConnection(connectString))
            {
                string sql = @"UPDATE ProductPhoto SET ProductId = @ProductId, Name = @Name, ImageUrl = @ImageUrl
                            where Id=@Id";

                conn.Execute(sql, entity);
            }
        }
Ejemplo n.º 4
0
        public int Add(ProductPhotoInfo entity)
        {
            using (var conn = new SqlConnection(connectString))
            {
                string sql = @"INSERT INTO ProductPhoto( ProductId,Name,ImageUrl,ProStyle,AddDate,[OrderID]) VALUES(@ProductId,@Name,@ImageUrl,@ProStyle,GetDate(),@OrderId);
                            select SCOPE_IDENTITY()";

                return(conn.Query <int>(sql, entity).Single());
            }
        }
Ejemplo n.º 5
0
 public void PrepareProductPhotoModel(SqlDataReader dr, List <ProductPhotoInfo> productPhotoList)
 {
     while (dr.Read())
     {
         ProductPhotoInfo item = new ProductPhotoInfo();
         item.ID        = dr.GetInt32(0);
         item.ProductID = dr.GetInt32(1);
         item.Name      = dr[2].ToString();
         item.Photo     = dr[3].ToString();
         productPhotoList.Add(item);
     }
 }
Ejemplo n.º 6
0
        protected void AddProductPhoto(int productID)
        {
            string form = RequestHelper.GetForm <string>("ProductPhoto");

            if (form != string.Empty)
            {
                foreach (string str2 in form.Split(new char[] { ',' }))
                {
                    ProductPhotoInfo productPhoto = new ProductPhotoInfo();
                    productPhoto.ProductID = productID;
                    productPhoto.Name      = str2.Split(new char[] { '|' })[0];
                    productPhoto.Photo     = str2.Split(new char[] { '|' })[1];
                    ProductPhotoBLL.AddProductPhoto(productPhoto);
                }
            }
        }
Ejemplo n.º 7
0
        protected void AddProductPhoto(int productId)
        {
            string productPhotoList = RequestHelper.GetForm <string>("ProductPhoto");

            if (!string.IsNullOrEmpty(productPhotoList))
            {
                foreach (string temp in productPhotoList.Split(','))
                {
                    ProductPhotoInfo productPhoto = new ProductPhotoInfo();
                    productPhoto.ProductId = productId;
                    productPhoto.Name      = temp.Split('|')[0];
                    productPhoto.ImageUrl  = temp.Split('|')[1].Replace("75-75", "Original");
                    ProductPhotoBLL.Add(productPhoto);
                }
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 添加产品图片
        /// </summary>
        /// <param name="productID"></param>
        protected void AddProductPhoto(int productID)
        {
            string productPhotoList = RequestHelper.GetForm <string>("ProductPhoto");

            if (productPhotoList != string.Empty)
            {
                foreach (string temp in productPhotoList.Split(','))
                {
                    ProductPhotoInfo productPhoto = new ProductPhotoInfo();
                    productPhoto.ProductId = productID;
                    productPhoto.Name      = temp.Split('|')[0];
                    productPhoto.ImageUrl  = temp.Split('|')[1];
                    ProductPhotoBLL.Add(productPhoto);
                }
            }
        }
Ejemplo n.º 9
0
        public ProductPhotoInfo ReadProductPhoto(int id)
        {
            SqlParameter[] pt = new SqlParameter[] { new SqlParameter("@id", SqlDbType.Int) };
            pt[0].Value = id;
            ProductPhotoInfo info = new ProductPhotoInfo();

            using (SqlDataReader reader = ShopMssqlHelper.ExecuteReader(ShopMssqlHelper.TablePrefix + "ReadProductPhoto", pt))
            {
                if (reader.Read())
                {
                    info.ID        = reader.GetInt32(0);
                    info.ProductID = reader.GetInt32(1);
                    info.Name      = reader[2].ToString();
                    info.Photo     = reader[3].ToString();
                }
            }
            return(info);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected override void PageLoad()
        {
            base.PageLoad();
            int id = RequestHelper.GetQueryString <int>("ID");

            if (id <= 0)
            {
                ScriptHelper.AlertFront("该产品未上市,不能查看");
            }
            product = ProductBLL.Read(id);
            if (product.IsSale == (int)BoolType.False || product.IsDelete == 1)
            {
                ScriptHelper.Alert("该产品未上市,不能查看");
            }
            //产品图片
            ProductPhotoInfo productPhoto = new ProductPhotoInfo();

            productPhoto.Name     = product.Name;
            productPhoto.ImageUrl = product.Photo;
            productPhotoList.Add(productPhoto);
            productPhotoList.AddRange(ProductPhotoBLL.ReadList(id, 0));
        }
Ejemplo n.º 11
0
        protected override void PageLoad()
        {
            base.PageLoad();
            int queryString = RequestHelper.GetQueryString <int>("ID");

            this.product = ProductBLL.ReadProduct(queryString);
            if (this.product.IsSale == 0)
            {
                ScriptHelper.Alert("该产品未上市,不能查看");
            }
            ProductBLL.ChangeProductViewCount(queryString, 1);
            ProductPhotoInfo item = new ProductPhotoInfo();

            item.Name  = this.product.Name;
            item.Photo = this.product.Photo;
            this.productPhotoList.Add(item);
            this.productPhotoList.AddRange(ProductPhotoBLL.ReadProductPhotoByProduct(queryString));

            this.attributeRecordList = AttributeRecordBLL.ReadAttributeRecordByProduct(queryString);

            TeacherSearchInfo teacherSearch = new TeacherSearchInfo();

            teacherSearch.InProductID = product.ID.ToString();
            ITeacherBLL teacherBLL = new TeacherBLL();

            teacherList = teacherBLL.ReadList(teacherSearch);

            if (ShopConfig.ReadConfigInfo().ProductStorageType == 1)
            {
                this.leftStorageCount = this.product.TotalStorageCount - this.product.OrderCount;
            }
            else
            {
                this.leftStorageCount = this.product.ImportVirtualStorageCount;
            }
            base.Title       = this.product.Name;
            base.Keywords    = (this.product.Keywords == string.Empty) ? this.product.Name : this.product.Keywords;
            base.Description = (this.product.Summary == string.Empty) ? StringHelper.Substring(StringHelper.KillHTML(this.product.Introduction), 200) : this.product.Summary;
        }
Ejemplo n.º 12
0
        public ActionResult Detail(int id)
        {
            int userGrade = UserGradeBLL.ReadByMoney(0).Id;
            int uid       = RequestHelper.GetForm <int>("uid");
            var user      = UserBLL.ReadUserMore(uid);

            if (user.Id > 0)
            {
                userGrade     = UserGradeBLL.ReadByMoney(user.MoneyUsed).Id;
                user.UserName = HttpUtility.UrlDecode(user.UserName, System.Text.Encoding.UTF8);
            }

            if (id <= 0)
            {
                return(Json(new { ok = false, error = "该产品未上市" }));
            }
            string      fromwhere = RequestHelper.GetQueryString <string>("fw");
            ProductInfo product   = ProductBLL.Read(id);

            if (product.IsSale == (int)BoolType.False || product.IsDelete == 1)
            {
                return(Json(new { ok = false, error = "该产品未上市" }));
            }
            #region 如果商品没有小程序码 则生成并保存
            if (string.IsNullOrWhiteSpace(product.Qrcode))
            {
                string product_miniProramCode = string.Empty;
                CreateMiniProgramCode(product.Id, ref product_miniProramCode, product.Qrcode);
                if (!string.IsNullOrWhiteSpace(product_miniProramCode))
                {//如果调用接口成功生成小程序码(因为只有发布后才能使用此微信接口)
                    Dictionary <string, object> dict = new Dictionary <string, object>();
                    dict.Add("[Qrcode]", product_miniProramCode);
                    ProductBLL.UpdatePart("[Product]", dict, product.Id);
                    product.Qrcode = product_miniProramCode;
                }
            }
            #endregion
            //更新查看数量
            if (CookiesHelper.ReadCookie("productview" + product.Id + "") == null)
            {
                ProductBLL.ChangeViewCount(id, 1);
                CookiesHelper.AddCookie("productview" + product.Id + "", product.Id.ToString());
            }
            ProductCommentSearchInfo proCommSear = new ProductCommentSearchInfo();
            var proComm = ProductCommentBLL.SearchProductCommentList(proCommSear = new ProductCommentSearchInfo {
                ProductId = product.Id, Status = (int)CommentStatus.Show
            });
            var procomlist = new List <VirtualProductCommend>();
            foreach (var item in proComm)
            {
                VirtualProductCommend vpc = new VirtualProductCommend()
                {
                    id         = item.Id,
                    name       = HttpUtility.UrlDecode(item.UserName, Encoding.UTF8),
                    avator     = ShopCommon.ShowImage(UserBLL.Read(item.UserId).Photo),
                    lv         = item.Rank,
                    date       = item.PostDate,
                    content    = item.Content,
                    imglist    = ProductPhotoBLL.ReadList(item.Id, 3),
                    adminreply = item.AdminReplyContent,
                    replydate  = item.AdminReplyDate
                };
                procomlist.Add(vpc);
            }

            //产品价格
            int hotCount           = 0;
            var currentMemberPrice = ProductBLL.GetCurrentPrice(product.SalePrice, userGrade);
            var prorecommend       = ProductBLL.SearchList(1, 8, new ProductSearchInfo {
                IsSale = (int)BoolType.True, IsTop = (int)BoolType.True, IsDelete = (int)BoolType.False, NotInProductId = product.Id.ToString()
            }, ref hotCount);
            var prorelist = new List <ProductVirtualModel>();
            foreach (var item in prorecommend)
            {
                var vp = new ProductVirtualModel()
                {
                    id          = item.Id,
                    name        = item.Name,
                    img         = ShopCommon.ShowImage(item.Photo.Replace("Original", "150-150")),
                    imgbig      = ShopCommon.ShowImage(item.Photo.Replace("Original", "350-350")),
                    imgorg      = ShopCommon.ShowImage(item.Photo),
                    price       = ProductBLL.GetCurrentPrice(item.SalePrice, userGrade),
                    marketprice = item.MarketPrice,
                    click       = item.ViewCount,
                    like        = item.LikeNum,
                    totalstore  = item.StandardType == (int)ProductStandardType.Single ? ProductTypeStandardRecordBLL.GetSumStorageByProduct(item.Id) : item.TotalStorageCount,
                    //ordercount = item.OrderCount
                    //是否启用不限库存,分别计算销量
                    ordercount = item.UnlimitedStorage == 1 ? OrderBLL.GetProductOrderCountDaily(item.Id, item.StandardType, DateTime.Now) : item.OrderCount
                };
                prorelist.Add(vp);
            }
            //产品图片
            List <ProductPhotoInfo> productPhotoList = new List <ProductPhotoInfo>();
            ProductPhotoInfo        productPhoto     = new ProductPhotoInfo();
            productPhoto.Name     = product.Name;
            productPhoto.ImageUrl = product.Photo;
            productPhotoList.Add(productPhoto);
            productPhotoList.AddRange(ProductPhotoBLL.ReadList(id, 0));
            productPhotoList.ForEach(k => k.ImageUrl = k.ImageUrl.Replace("75-75", "Original"));
            //属性
            var attributeRecordList = ProductTypeAttributeRecordBLL.ReadList(id);

            #region 产品规格
            List <ProductTypeStandardInfo> standardList = new List <ProductTypeStandardInfo>();
            string  standardRecordValueList             = "|";
            var     standardRecordList = ProductTypeStandardRecordBLL.ReadListByProduct(product.Id, product.StandardType);
            decimal maxPrice           = product.SalePrice;
            if (standardRecordList.Count > 0)
            {
                string[] standardIDArray = standardRecordList[0].StandardIdList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < standardIDArray.Length; i++)
                {
                    int standardID = Convert.ToInt32(standardIDArray[i]);
                    ProductTypeStandardInfo standard = ProductTypeStandardBLL.Read(standardID);
                    string[] valueArray = standard.ValueList.Split(';');
                    string   valueList  = string.Empty;
                    for (int k = 0; k < valueArray.Length; k++)
                    {
                        foreach (ProductTypeStandardRecordInfo standardRecord in standardRecordList)
                        {
                            if (standardRecord.MarketPrice > maxPrice)
                            {
                                maxPrice = standardRecord.MarketPrice;
                            }
                            string[] tempValueArray = standardRecord.ValueList.Split(';');
                            if (valueArray[k] == tempValueArray[i])
                            {
                                valueList += valueArray[k] + ";";
                                break;
                            }
                        }
                    }
                    if (valueList != string.Empty)
                    {
                        valueList = valueList.Substring(0, valueList.Length - 1);
                    }
                    standard.ValueList = valueList;
                    standardList.Add(standard);
                }
                //规格值
                foreach (ProductTypeStandardRecordInfo standardRecord in standardRecordList)
                {
                    standardRecordValueList += standardRecord.ProductId + ";" + standardRecord.ValueList + "|";
                }
            }
            #endregion
            #region 正在开的团(进行中,排除本人开的团)
            GroupBuySearchInfo gpsearch = new GroupBuySearchInfo
            {
                ProductId = product.Id,
                //NotLeader = user.Id,
                Status = (int)GroupBuyStatus.Going
            };
            List <GroupBuyInfo> gpList = GroupBuyBLL.SearchList(gpsearch);
            gpList.ForEach(k => k.groupSignList = GroupSignBLL.ReadListByGroupId(k.Id));
            gpList.ForEach(k => k.GroupUserName = System.Web.HttpUtility.UrlDecode(k.GroupUserName, Encoding.UTF8));
            #endregion
            return(Json(new
            {
                ok = true,
                product = new
                {
                    id = product.Id,
                    img = ShopCommon.ShowImage(product.Photo.Replace("Original", "350-350")),
                    imgorg = ShopCommon.ShowImage(product.Photo),
                    title = product.Name,
                    summary = product.Summary,
                    price = currentMemberPrice,
                    marketprice = product.MarketPrice,
                    intro = string.IsNullOrEmpty(product.Introduction1_Mobile) ? product.Introduction1 : product.Introduction1_Mobile,
                    remark = product.Remark,
                    totalstore = product.StandardType == (int)ProductStandardType.Single ? ProductTypeStandardRecordBLL.GetSumStorageByProduct(product.Id) : product.TotalStorageCount,
                    ordercount = product.UnlimitedStorage == 1 ? OrderBLL.GetProductOrderCountDaily(product.Id, product.StandardType, DateTime.Now) : product.OrderCount,
                    unlimitedstorage = product.UnlimitedStorage,
                    virtualordercount = product.VirtualOrderCount,
                    usevirtualorder = product.UseVirtualOrder,
                    opengroup = product.OpenGroup,
                    groupprice = product.GroupPrice,
                    groupquantity = product.GroupQuantity,
                    qrcode = product.Qrcode,
                    groupphoto = string.IsNullOrWhiteSpace(product.GroupPhoto) ? product.Photo : product.GroupPhoto
                },
                standardList = standardList,
                standardRecordValueList = standardRecordValueList,
                attributeRecordList = attributeRecordList,
                productPhotoList = productPhotoList,
                prorecommend = prorelist,
                proComm = procomlist,
                maxPrice = maxPrice,
                groupList = gpList
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 13
0
 public static void Update(ProductPhotoInfo entity)
 {
     dal.Update(entity);
 }
Ejemplo n.º 14
0
 public static int Add(ProductPhotoInfo entity)
 {
     return(dal.Add(entity));
 }
Ejemplo n.º 15
0
        public ActionResult UploadImage()
        {
            string filePath = "/Upload/ProductPhoto/Original/" + RequestHelper.DateNow.ToString("yyyyMM") + "/";

            if (FileHelper.SafeFullDirectoryName(filePath))
            {
                try
                {
                    //上传文件
                    UploadHelper upload = new UploadHelper();
                    upload.Path           = "/Upload/ProductPhoto/Original/" + RequestHelper.DateNow.ToString("yyyyMM") + "/";
                    upload.FileType       = ShopConfig.ReadConfigInfo().UploadFile;
                    upload.FileNameType   = FileNameType.Guid;
                    upload.MaxWidth       = ShopConfig.ReadConfigInfo().AllImageWidth;  //整站图片压缩开启后的压缩宽度
                    upload.AllImageIsNail = ShopConfig.ReadConfigInfo().AllImageIsNail; //整站图片压缩开关
                    int needNail = RequestHelper.GetQueryString <int>("NeedNail");
                    if (needNail <= 0)
                    {
                        upload.AllImageIsNail = 0;                                       //如果页面传值不压缩图片,以页面传值为准;
                    }
                    int curMaxWidth = RequestHelper.GetQueryString <int>("CurMaxWidth"); //页面传值最大宽度
                    if (curMaxWidth > 0)
                    {
                        upload.AllImageIsNail = 1;
                        upload.MaxWidth       = curMaxWidth;//如果有页面传值设置图片最大宽度,以页面传值为准
                    }
                    FileInfo file      = null;
                    int      waterType = ShopConfig.ReadConfigInfo().WaterType;

                    //前台上传图片不打水印直接保存
                    file = upload.SaveAs();

                    //生成处理
                    string originalFile = upload.Path + file.Name;
                    string otherFile    = string.Empty;
                    string makeFile     = string.Empty;

                    Dictionary <int, int> dic = new Dictionary <int, int>();

                    if (!dic.ContainsKey(75))
                    {
                        dic.Add(75, 75);                      //后台商品图集默认使用尺寸(如果不存在则手动添加)
                    }
                    foreach (KeyValuePair <int, int> de in dic)
                    {
                        makeFile   = originalFile.Replace("Original", de.Key + "-" + de.Value);
                        otherFile += makeFile + "|";
                        ImageHelper.MakeThumbnailImage(ServerHelper.MapPath(originalFile), ServerHelper.MapPath(makeFile), Convert.ToInt32(de.Key), Convert.ToInt32(de.Value), ThumbnailType.AllFix);
                    }
                    otherFile = otherFile.Substring(0, otherFile.Length - 1);
                    int proStyle = RequestHelper.GetForm <int>("proStyle");
                    if (proStyle < 0)
                    {
                        proStyle = 0;
                    }

                    int pcid = RequestHelper.GetForm <int>("pcid");
                    ProductPhotoInfo productPhoto = new ProductPhotoInfo();
                    productPhoto.ProductId = pcid;
                    productPhoto.ImageUrl  = originalFile;
                    productPhoto.ProStyle  = proStyle;
                    productPhoto.OrderId   = 0;

                    ProductPhotoBLL.Add(productPhoto);
                    return(Content("ok|" + originalFile.Replace("Original", "75-75")));
                }
                catch (Exception ex)
                {
                    return(Content(ex.Message));
                }
            }
            else
            {
                return(Content(ShopLanguage.ReadLanguage("ErrorPathName")));
            }
        }
Ejemplo n.º 16
0
        protected override void PageLoad()
        {
            base.PageLoad();
            int queryString = RequestHelper.GetQueryString <int>("ID");

            this.product = ProductBLL.ReadProduct(queryString);
            if (this.product.IsSale == 0)
            {
                ScriptHelper.Alert("该产品未上市,不能查看");
            }
            ProductBLL.ChangeProductViewCount(queryString, 1);
            this.userGradeList      = UserGradeBLL.ReadUserGradeCacheList();
            this.memberPriceList    = MemberPriceBLL.ReadMemberPriceByProduct(queryString);
            this.currentMemberPrice = (this.product.MarketPrice * UserGradeBLL.ReadUserGradeCache(base.GradeID).Discount) / 100M;
            foreach (MemberPriceInfo info in this.memberPriceList)
            {
                if (info.GradeID == base.GradeID)
                {
                    this.currentMemberPrice = info.Price;
                    break;
                }
            }
            this.currentMemberPrice = Math.Round(this.currentMemberPrice, 2);
            ProductPhotoInfo item = new ProductPhotoInfo();

            item.Name  = this.product.Name;
            item.Photo = this.product.Photo;
            this.productPhotoList.Add(item);
            this.productPhotoList.AddRange(ProductPhotoBLL.ReadProductPhotoByProduct(queryString));
            this.strHistoryProduct = base.Server.UrlDecode(CookiesHelper.ReadCookieValue("HistoryProduct"));
            string strProductID = (this.product.RelationProduct + "," + this.product.Accessory + "," + this.strHistoryProduct).Replace(",,", ",");

            if (strProductID.StartsWith(","))
            {
                strProductID = strProductID.Substring(1);
            }
            if (strProductID.EndsWith(","))
            {
                strProductID = strProductID.Substring(0, strProductID.Length - 1);
            }
            ProductSearchInfo productSearch = new ProductSearchInfo();

            productSearch.InProductID = strProductID;
            this.tempProductList      = ProductBLL.SearchProductList(productSearch);
            if (strProductID != string.Empty)
            {
                this.tempMemberPriceList = MemberPriceBLL.ReadMemberPriceByProductGrade(strProductID, base.GradeID);
            }
            this.attributeRecordList = AttributeRecordBLL.ReadAttributeRecordByProduct(queryString);
            TagsSearchInfo tags = new TagsSearchInfo();

            tags.ProductID       = queryString;
            this.productTagsList = TagsBLL.SearchTagsList(tags);
            if (this.product.RelationArticle != string.Empty)
            {
                ArticleSearchInfo articleSearch = new ArticleSearchInfo();
                articleSearch.InArticleID = this.product.RelationArticle;
                this.productArticleList   = ArticleBLL.SearchArticleList(articleSearch);
            }
            this.standardRecordList = StandardRecordBLL.ReadStandardRecordByProduct(this.product.ID, this.product.StandardType);
            if ((this.standardRecordList.Count > 0) && (this.product.StandardType == 1))
            {
                string[] strArray = this.standardRecordList[0].StandardIDList.Split(new char[] { ',' });
                for (int i = 0; i < strArray.Length; i++)
                {
                    StandardInfo info6     = StandardBLL.ReadStandardCache(Convert.ToInt32(strArray[i]));
                    string[]     strArray2 = info6.ValueList.Split(new char[] { ',' });
                    string[]     strArray3 = info6.PhotoList.Split(new char[] { ',' });
                    string       str2      = string.Empty;
                    string       str3      = string.Empty;
                    for (int j = 0; j < strArray2.Length; j++)
                    {
                        foreach (StandardRecordInfo info7 in this.standardRecordList)
                        {
                            string[] strArray4 = info7.ValueList.Split(new char[] { ',' });
                            if (strArray2[j] == strArray4[i])
                            {
                                str2 = str2 + strArray2[j] + ",";
                                str3 = str3 + strArray3[j] + ",";
                                goto Label_043B;
                            }
                        }
                        Label_043B :;
                    }
                    if (str2 != string.Empty)
                    {
                        str2 = str2.Substring(0, str2.Length - 1);
                        str3 = str3.Substring(0, str3.Length - 1);
                    }
                    info6.ValueList = str2;
                    info6.PhotoList = str3;
                    this.standardList.Add(info6);
                }
                foreach (StandardRecordInfo info7 in this.standardRecordList)
                {
                    object standardRecordValueList = this.standardRecordValueList;
                    this.standardRecordValueList = string.Concat(new object[] { standardRecordValueList, info7.ProductID, ",", info7.ValueList, "|" });
                }
            }
            if (ShopConfig.ReadConfigInfo().ProductStorageType == 1)
            {
                this.leftStorageCount = this.product.TotalStorageCount - this.product.OrderCount;
            }
            else
            {
                this.leftStorageCount = this.product.ImportVirtualStorageCount;
            }
            base.Title       = this.product.Name;
            base.Keywords    = (this.product.Keywords == string.Empty) ? this.product.Name : this.product.Keywords;
            base.Description = (this.product.Summary == string.Empty) ? StringHelper.Substring(StringHelper.KillHTML(this.product.Introduction), 200) : this.product.Summary;
        }
Ejemplo n.º 17
0
        protected void ImportProducts(object sender, EventArgs e)
        {
            string categoryId    = ProductClass.ClassID;
            int    saleStatus    = Convert.ToInt32(IsSale.SelectedValue);
            string selectedValue = dropFiles.SelectedValue;

            selectedValue = Path.Combine(_dataPath, selectedValue);

            if (!File.Exists(selectedValue))
            {
                ScriptHelper.Alert("选择的数据包文件有问题!");
            }
            else
            {
                PrepareDataFiles(new object[] { selectedValue });
                string    path        = Path.Combine(_dataPath, Path.GetFileNameWithoutExtension(selectedValue));
                DataTable productData = (DataTable)ProductBLL.ParseProductData(new object[] { path })[0];
                if ((productData != null) && (productData.Rows.Count > 0))
                {
                    foreach (DataRow row in productData.Rows)
                    {
                        ProductInfo product = new ProductInfo
                        {
                            ClassId       = categoryId,
                            Name          = (string)row["ProductName"],
                            ProductNumber = (string)row["SKU"],
                            BrandId       = 0
                        };
                        if (row["Description"] != DBNull.Value)
                        {
                            product.Introduction1 = (string)row["Description"];
                        }
                        product.AddDate           = DateTime.Now;
                        product.IsSale            = saleStatus;
                        product.MarketPrice       = (decimal)row["SalePrice"];
                        product.TotalStorageCount = (int)row["Stock"];

                        product.Spelling  = ChineseCharacterHelper.GetFirstLetter((string)row["ProductName"]);
                        product.SendPoint = 0;
                        product.Weight    = 0;
                        product.IsSpecial = 0;
                        product.IsNew     = 0;
                        product.IsHot     = 0;
                        if (row["Has_ShowCase"] != DBNull.Value)
                        {
                            product.IsTop = Convert.ToInt32(row["Has_ShowCase"]);
                        }
                        product.AllowComment = 0;
                        product.LowerCount   = 0;
                        product.UpperCount   = 0;
                        product.StandardType = 0;
                        product.AddDate      = RequestHelper.DateNow;

                        product.OrderId   = 0;
                        product.SalePrice = (decimal)row["SalePrice"];

                        if (row["ImageUrl1"] != DBNull.Value)
                        {
                            product.Photo = (string)row["ImageUrl1"];
                        }

                        int proID = ProductBLL.Add(product);
                        #region 生成缩略图和产品相册图
                        if (!(string.IsNullOrEmpty(product.Photo) || (product.Photo.Length <= 0)))
                        {
                            UploadImage(product.Photo, PhotoType.Product);
                        }

                        if (row["ImageUrl2"] != DBNull.Value)
                        {
                            ProductPhotoInfo tempPhoto = new ProductPhotoInfo()
                            {
                                ProductId = proID,
                                Name      = "ImageUrl2",
                                ImageUrl  = (string)row["ImageUrl2"],
                                AddDate   = DateTime.Now
                            };
                            ProductPhotoBLL.Add(tempPhoto);
                            UploadImage(tempPhoto.ImageUrl, PhotoType.ProductPhoto);
                        }
                        if (row["ImageUrl3"] != DBNull.Value)
                        {
                            ProductPhotoInfo tempPhoto = new ProductPhotoInfo()
                            {
                                ProductId = proID,
                                Name      = "ImageUrl3",
                                ImageUrl  = (string)row["ImageUrl3"],
                                AddDate   = DateTime.Now
                            };
                            ProductPhotoBLL.Add(tempPhoto);
                            UploadImage(tempPhoto.ImageUrl, PhotoType.ProductPhoto);
                        }
                        if (row["ImageUrl4"] != DBNull.Value)
                        {
                            ProductPhotoInfo tempPhoto = new ProductPhotoInfo()
                            {
                                ProductId = proID,
                                Name      = "ImageUrl4",
                                ImageUrl  = (string)row["ImageUrl4"],
                                AddDate   = DateTime.Now
                            };
                            ProductPhotoBLL.Add(tempPhoto);
                            UploadImage(tempPhoto.ImageUrl, PhotoType.ProductPhoto);
                        }
                        if (row["ImageUrl5"] != DBNull.Value)
                        {
                            ProductPhotoInfo tempPhoto = new ProductPhotoInfo()
                            {
                                ProductId = proID,
                                Name      = "ImageUrl5",
                                ImageUrl  = (string)row["ImageUrl5"],
                                AddDate   = DateTime.Now
                            };
                            ProductPhotoBLL.Add(tempPhoto);
                            UploadImage(tempPhoto.ImageUrl, PhotoType.ProductPhoto);
                        }
                        #endregion
                    }

                    File.Delete(selectedValue);
                    Directory.Delete(path, true);
                    BindFiles();
                    ScriptHelper.Alert("此次商品批量导入操作已成功!", RequestHelper.RawUrl);
                }
            }
        }
Ejemplo n.º 18
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected override void PageLoad()
        {
            base.PageLoad();

            int count = int.MinValue;

            int id = RequestHelper.GetQueryString <int>("ID");

            if (id <= 0)
            {
                ScriptHelper.AlertFront("该产品未上市,不能查看");
            }
            string fromwhere = RequestHelper.GetQueryString <string>("fw");

            product = ProductBLL.Read(id);
            if (product.IsSale == (int)BoolType.False || product.IsDelete == 1)
            {
                if (fromwhere.ToLower() != "admin")
                {
                    ScriptHelper.Alert("该产品未上市,不能查看");
                }
                else
                {
                    if (Cookies.Admin.GetAdminID(true) == 0)//用户未登录
                    {
                        ScriptHelper.Alert("该产品未上市,不能查看");
                    }
                }
            }

            navList = ProductClassBLL.ProductClassNameList(product.ClassId);
            //更新查看数量
            ProductBLL.ChangeViewCount(id, 1);
            //会员等级
            userGradeList = UserGradeBLL.ReadList();

            //产品图片
            ProductPhotoInfo productPhoto = new ProductPhotoInfo();

            productPhoto.Name     = product.Name;
            productPhoto.ImageUrl = product.Photo.Replace("Original", "75-75");
            productPhotoList.Add(productPhoto);
            productPhotoList.AddRange(ProductPhotoBLL.ReadList(id, 0));
            // 关联产品,配件,浏览过的商品
            strHistoryProduct = Server.UrlDecode(CookiesHelper.ReadCookieValue("HistoryProduct"));
            string tempStrProductID = product.RelationProduct + "," + product.Accessory + "," + strHistoryProduct;

            tempStrProductID = tempStrProductID.Replace(",,", ",");
            if (tempStrProductID.StartsWith(","))
            {
                tempStrProductID = tempStrProductID.Substring(1);
            }
            if (tempStrProductID.EndsWith(","))
            {
                tempStrProductID = tempStrProductID.Substring(0, tempStrProductID.Length - 1);
            }

            ProductSearchInfo productSearch = new ProductSearchInfo();

            productSearch.InProductId = tempStrProductID;
            productSearch.IsDelete    = (int)BoolType.False;
            tempProductList           = ProductBLL.SearchList(productSearch);
            //产品规格
            standardRecordList = ProductTypeStandardRecordBLL.ReadListByProduct(product.Id, product.StandardType);
            if (standardRecordList.Count > 0)
            {
                string[] standardIDArray = standardRecordList[0].StandardIdList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < standardIDArray.Length; i++)
                {
                    int standardID = Convert.ToInt32(standardIDArray[i]);
                    ProductTypeStandardInfo standard = ProductTypeStandardBLL.Read(standardID);
                    string[] valueArray = standard.ValueList.Split(';');
                    string   valueList  = string.Empty;
                    for (int k = 0; k < valueArray.Length; k++)
                    {
                        foreach (ProductTypeStandardRecordInfo standardRecord in standardRecordList)
                        {
                            string[] tempValueArray = standardRecord.ValueList.Split(';');
                            if (valueArray[k] == tempValueArray[i])
                            {
                                valueList += valueArray[k] + ";";
                                break;
                            }
                        }
                    }
                    if (valueList != string.Empty)
                    {
                        valueList = valueList.Substring(0, valueList.Length - 1);
                    }
                    standard.ValueList = valueList;
                    standardList.Add(standard);
                }
                //规格值
                foreach (ProductTypeStandardRecordInfo standardRecord in standardRecordList)
                {
                    standardRecordValueList += standardRecord.ProductId + ";" + standardRecord.ValueList + "|";
                }
            }
            //计算剩余库存量
            if (ShopConfig.ReadConfigInfo().ProductStorageType == (int)ProductStorageType.SelfStorageSystem)
            {
                leftStorageCount = product.TotalStorageCount - product.OrderCount;
            }
            else
            {
                leftStorageCount = product.ImportVirtualStorageCount;
            }
            //搜索优化
            Title       = product.Name;
            Keywords    = (product.Keywords == string.Empty) ? product.Name : product.Keywords;
            Description = (product.Summary == string.Empty) ? StringHelper.Substring(StringHelper.KillHTML(product.Introduction1), 200) : product.Summary;
        }
Ejemplo n.º 19
0
        ///   <summary>
        ///   从图片中截取部分生成新图
        ///   </summary>
        ///   <param   name="sFromFilePath">原始图片</param>
        ///   <param   name="saveFilePath">生成新图</param>
        ///   <param   name="width">截取图片宽度</param>
        ///   <param   name="height">截取图片高度</param>
        ///   <param   name="spaceX">截图图片X坐标</param>
        ///   <param   name="spaceY">截取图片Y坐标</param>
        public void CaptureImage(string sFromFilePath, string saveFilePath, int width, int height, int spaceX, int spaceY, string tarimg, string targetID)
        {
            //载入底图
            System.Drawing.Image  fromImage = System.Drawing.Image.FromFile(sFromFilePath);
            System.Drawing.Bitmap bitmap    = new System.Drawing.Bitmap(width, height);
            //创建作图区域
            System.Drawing.Graphics graphic = System.Drawing.Graphics.FromImage(bitmap);
            //截取原图相应区域写入作图区
            graphic.DrawImage(fromImage, new System.Drawing.Rectangle(0, 0, width, height), new System.Drawing.Rectangle(spaceX, spaceY, width, height), System.Drawing.GraphicsUnit.Pixel);
            //从作图区生成新图
            System.Drawing.Image saveImage = System.Drawing.Image.FromHbitmap(bitmap.GetHbitmap());
            //保存图象
            saveImage.Save(saveFilePath, ImageFormat.Jpeg);
            bitmap.Dispose();
            graphic.Dispose();
            saveImage.Dispose();
            fromImage.Dispose();

            //string delTarget = tarimg.Replace("nail.", ".");
            //FileHelper.DeleteFile(new List<string> { delTarget });//删除原图
            FileHelper.DeleteFile(new List <string> {
                tarimg
            });                                                //删除原图

            string delTarget = saveFilePath.Replace(Server.MapPath("/"), "");

            //FileInfo fileInfo = new FileInfo(saveFilePath);
            //fileInfo.MoveTo(sFromFilePath);

            if (makeNail == 1)//是否需要生成缩略图
            {
                string makeFile = string.Empty;
                //if (targetType == 0)
                //{
                Dictionary <int, int> dic = new Dictionary <int, int>();
                if (tableID == ProductBLL.TableID)
                {
                    foreach (var phototype in PhotoSizeBLL.SearchList((int)PhotoType.Product))
                    {
                        dic.Add(phototype.Width, phototype.Height);
                    }
                    if (!dic.ContainsKey(90))
                    {
                        dic.Add(90, 90);                          //后台商品列表默认使用尺寸(如果不存在则手动添加)
                    }
                }
                else if (tableID == ProductBrandBLL.TableID)
                {
                    dic.Add(88, 31);
                }
                else if (tableID == ThemeActivityBLL.TableID)
                {
                    dic.Add(300, 150);
                }
                else if (tableID == ArticleBLL.TableID)
                {
                    dic.Add(90, 90);    //后台列表缩略图
                    dic.Add(200, 150);  //前台列表缩略图
                }
                else if (tableID == ProductPhotoBLL.TableID)
                {
                    foreach (var phototype in PhotoSizeBLL.SearchList((int)PhotoType.ProductPhoto))
                    {
                        dic.Add(phototype.Width, phototype.Height);
                    }
                    if (!dic.ContainsKey(75))
                    {
                        dic.Add(75, 75);                          //后台商品图集默认使用尺寸(如果不存在则手动添加)
                    }
                }
                if (dic.Count > 0)
                {
                    foreach (KeyValuePair <int, int> kv in dic)
                    {
                        //string nailStr = delTarget.Replace("Original", kv.Key.ToString() + "-" + kv.Value.ToString());
                        string nailStr = tarimg.Replace("Original", kv.Key.ToString() + "-" + kv.Value.ToString());

                        FileHelper.DeleteFile(new List <string> {
                            nailStr
                        });                                                     //删除原有缩略图
                        //makeFile = nailStr;
                        makeFile = delTarget.Replace("Original", kv.Key.ToString() + "-" + kv.Value.ToString());
                        ImageHelper.MakeThumbnailImage(ServerHelper.MapPath(delTarget), ServerHelper.MapPath(makeFile), kv.Key, kv.Value, ThumbnailType.InBox);
                    }
                }
                //}
                //else
                //{

                //    Hashtable ht = new Hashtable();
                //    if (tableID == ProductPhotoBLL.TableID)
                //    {
                //        foreach (var phototype in PhotoSizeBLL.SearchList((int)PhotoType.ProductPhoto))
                //        {
                //            ht.Add(phototype.Width, phototype.Height);
                //        }
                //        if (!ht.ContainsKey(75)) ht.Add(75, 75);//后台商品图集默认使用尺寸(如果不存在则手动添加)
                //    }
                //    else
                //    {
                //        ht.Add("75", "75");
                //        ht.Add("350", "350");
                //    }
                //    foreach (DictionaryEntry de in ht)
                //    {
                //        string nailStr = delTarget.Replace("Original", de.Key + "-" + de.Value);
                //        FileHelper.DeleteFile(new List<string> { nailStr });//删除原有缩略图
                //        makeFile = nailStr;
                //        ImageHelper.MakeThumbnailImage(ServerHelper.MapPath(delTarget), ServerHelper.MapPath(makeFile), Convert.ToInt32(de.Key), Convert.ToInt32(de.Value), ThumbnailType.InBox);
                //    }
                //}
            }
            //parent.layer.close(index);
            string strp_img2 = saveFilePath.Substring(saveFilePath.LastIndexOf('/'), saveFilePath.Length - saveFilePath.LastIndexOf('/'));

            if (targetType == 1)//产品多图
            {
                if (ProductID <= 0)
                {//添加
                    //Response.Write("<script>alert('裁剪成功');var index = parent.layer.getFrameIndex(window.name); parent.$('#" + targetID + ">img').attr('src','" + delTarget + "'); parent.layer.close(index);</script>");
                    string _str = "<script type='text/javascript' src='/Admin/Js/jquery-1.7.2.min.js'></script><script>alert('裁剪成功');var index = parent.layer.getFrameIndex(window.name);window.parent.editProductPhoto('" + targetID + "', '" + delTarget + "', '" + ProductPhotoID + "');parent.layer.close(index);</script>";
                    //Response.Write("<script>alert('裁剪成功');var index = parent.layer.getFrameIndex(window.name);window.parent.o('" + targetID + "').firstChild.src='" + delTarget + "';window.parent.o('" + targetID + "').getElementsByName('ProductPhoto')[0].value='" + _name + "|" + delTarget + "' ; parent.layer.close(index);</script>");
                    Response.Write("<script type='text/javascript' src='/Admin/Js/jquery-1.7.2.min.js'></script><script>alert('裁剪成功');var index = parent.layer.getFrameIndex(window.name);window.parent.editProductPhoto('" + targetID + "', '" + delTarget + "', '" + ProductPhotoID + "');parent.layer.close(index);</script>");
                }
                else
                {
                    ProductPhotoInfo productPhoto = ProductPhotoBLL.Read(ProductPhotoID, ProStyle);
                    productPhoto.ImageUrl = delTarget;
                    ProductPhotoBLL.Update(productPhoto);
                    string _str = "<script type='text/javascript' src='/Admin/Js/jquery-1.7.2.min.js'></script><script>alert('裁剪成功');var index = parent.layer.getFrameIndex(window.name);window.parent.editProductPhoto('" + targetID + "', '" + delTarget + "', '" + ProductPhotoID + "');parent.layer.close(index);</script>";

                    //Response.Write("<script type='text/javascript' src='/Admin/Js/jquery-1.7.2.min.js'></script><script>alert('裁剪成功');var index = parent.layer.getFrameIndex(window.name);window.parent.o('" + targetID + "').firstChild.src='" + delTarget + "';$('#" + targetID + "').find('.cut').attr('href','javascript:loadCut(\"" + delTarget + "\",\"" + targetID + "\",\"" + ProductPhotoID + "\")');parent.layer.close(index);</script>");
                    Response.Write("<script type='text/javascript' src='/Admin/Js/jquery-1.7.2.min.js'></script><script>alert('裁剪成功');var index = parent.layer.getFrameIndex(window.name);window.parent.editProductPhoto('" + targetID + "', '" + delTarget + "', '" + ProductPhotoID + "');parent.layer.close(index);</script>");
                }
            }
            else
            {
                Response.Write("<script>alert('裁剪成功');var index = parent.layer.getFrameIndex(window.name);window.parent.o('" + targetID + "').value='" + delTarget + "';window.parent.o('firstPhoto').src='" + delTarget + "';parent.layer.close(index); </script>");
            }
        }
Ejemplo n.º 20
0
        /// <summary>
        /// 页面加载
        /// </summary>
        protected override void PageLoad()
        {
            base.PageLoad();

            int count = int.MinValue;

            topNav = 2;
            int id = RequestHelper.GetQueryString <int>("ID");

            if (id <= 0)
            {
                ScriptHelper.AlertFront("该产品未上市,不能查看");
            }
            string fromwhere = RequestHelper.GetQueryString <string>("fw");

            product = ProductBLL.Read(id);
            if (product.IsSale == (int)BoolType.False || product.IsDelete == 1)
            {
                if (fromwhere.ToLower() != "admin")
                {
                    ScriptHelper.AlertFront("该产品未上市,不能查看");
                }
                else
                {
                    if (Cookies.Admin.GetAdminID(true) == 0)//用户未登录
                    {
                        ScriptHelper.AlertFront("该产品未上市,不能查看");
                    }
                }
            }

            navList = ProductClassBLL.ProductClassNameList(product.ClassId);
            //更新查看数量
            if (CookiesHelper.ReadCookie("productview" + product.Id + "") == null)
            {
                ProductBLL.ChangeViewCount(id, 1);
                CookiesHelper.AddCookie("productview" + product.Id + "", product.Id.ToString());
            }
            ProductCommentSearchInfo proCommSear = new ProductCommentSearchInfo();

            proComm = ProductCommentBLL.SearchProductCommentList(proCommSear = new ProductCommentSearchInfo {
                ProductId = product.Id
            });

            //会员等级
            userGradeList = UserGradeBLL.ReadList();
            //产品价格
            int hotCount = 0;

            currentMemberPrice = ProductBLL.GetCurrentPrice(product.SalePrice, base.GradeID);
            hotProductList     = ProductBLL.SearchList(1, 7, new ProductSearchInfo {
                IsHot = (int)BoolType.True, IsSale = (int)BoolType.True, IsDelete = (int)BoolType.False, NotInProductId = product.Id.ToString()
            }, ref hotCount);
            ishot = ProductBLL.SearchList(1, 7, new ProductSearchInfo {
                IsHot = (int)BoolType.True, IsSale = (int)BoolType.True, IsTop = (int)BoolType.True, IsDelete = (int)BoolType.False, NotInProductId = product.Id.ToString()
            }, ref hotCount);
            proishot = ProductBLL.SearchList(1, 3, new ProductSearchInfo {
                IsSale = (int)BoolType.True, IsTop = (int)BoolType.True, IsDelete = (int)BoolType.False, NotInProductId = product.Id.ToString()
            }, ref hotCount);

            //产品图片
            ProductPhotoInfo productPhoto = new ProductPhotoInfo();

            productPhoto.Name     = product.Name;
            productPhoto.ImageUrl = product.Photo;
            productPhotoList.Add(productPhoto);
            productPhotoList.AddRange(ProductPhotoBLL.ReadList(id, 0));
            // 关联产品,配件,浏览过的商品
            strHistoryProduct = Server.UrlDecode(CookiesHelper.ReadCookieValue("HistoryProduct"));
            string tempStrProductID = product.RelationProduct + "," + product.Accessory + "," + strHistoryProduct;

            tempStrProductID = tempStrProductID.Replace(",,", ",");
            if (tempStrProductID.StartsWith(","))
            {
                tempStrProductID = tempStrProductID.Substring(1);
            }
            if (tempStrProductID.EndsWith(","))
            {
                tempStrProductID = tempStrProductID.Substring(0, tempStrProductID.Length - 1);
            }
            ProductSearchInfo productSearch = new ProductSearchInfo();

            productSearch.InProductId = tempStrProductID;
            tempProductList           = ProductBLL.SearchList(productSearch);

            //属性
            attributeRecordList = ProductTypeAttributeRecordBLL.ReadList(id);

            //产品文章
            if (product.RelationArticle != string.Empty)
            {
                ArticleSearchInfo articleSearch = new ArticleSearchInfo();
                articleSearch.InArticleId = product.RelationArticle;
                productArticleList        = ArticleBLL.SearchList(articleSearch);
            }
            //产品规格
            standardRecordList = ProductTypeStandardRecordBLL.ReadListByProduct(product.Id, product.StandardType);
            if (standardRecordList.Count > 0)
            {
                string[] standardIDArray = standardRecordList[0].StandardIdList.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries);
                for (int i = 0; i < standardIDArray.Length; i++)
                {
                    int standardID = Convert.ToInt32(standardIDArray[i]);
                    ProductTypeStandardInfo standard = ProductTypeStandardBLL.Read(standardID);
                    string[] valueArray = standard.ValueList.Split(';');
                    string   valueList  = string.Empty;
                    for (int k = 0; k < valueArray.Length; k++)
                    {
                        foreach (ProductTypeStandardRecordInfo standardRecord in standardRecordList)
                        {
                            string[] tempValueArray = standardRecord.ValueList.Split(';');
                            if (valueArray[k] == tempValueArray[i])
                            {
                                valueList += valueArray[k] + ";";
                                break;
                            }
                        }
                    }
                    if (valueList != string.Empty)
                    {
                        valueList = valueList.Substring(0, valueList.Length - 1);
                    }
                    standard.ValueList = valueList;
                    standardList.Add(standard);
                }
                //规格值
                foreach (ProductTypeStandardRecordInfo standardRecord in standardRecordList)
                {
                    standardRecordValueList += standardRecord.ProductId + ";" + standardRecord.ValueList + "|";
                }
            }
            //计算剩余库存量

            leftStorageCount = product.TotalStorageCount - product.OrderCount;

            //搜索优化
            Title       = (product.SubTitle == string.Empty) ? product.Name : product.SubTitle;
            Keywords    = (product.Keywords == string.Empty) ? product.Name : product.Keywords;
            Description = (product.Summary == string.Empty) ? StringHelper.Substring(StringHelper.KillHTML(product.Introduction1), 200) : product.Summary;
        }