Пример #1
0
        /// <summary>
        /// 控件行命令事件
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void repInfo_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            if (e.CommandName.Equals("del"))
            {
                int     id   = Convert.ToInt32(e.CommandArgument);
                NavInfo item = NavInfoService.GetModel(id);
                if (item != null)
                {
                    if (System.IO.File.Exists(Server.MapPath(item.indexImg)))
                    {
                        System.IO.File.Delete(Server.MapPath(item.indexImg));
                    }
                }
                IndexProductService.Delete(id);
                LoadData();
            }
            if (e.CommandName.Equals("mod"))
            {
                int          id   = Convert.ToInt32(e.CommandArgument);
                IndexProduct item = IndexProductService.GetModel(id);
                if (item != null)
                {
                    ddlCate.SelectedValue = item.typeId.ToString();
                    txtTitle.Text         = item.proName;

                    txtTitle2.Text = item.proDesc;
                    txtPrice.Text  = item.priceStr;

                    lblURL1.Text    = item.imgUrl;
                    txtLinkUrl.Text = item.remark;

                    txtUnit.Text        = item.unitDesc;
                    lblId.Text          = item.id.ToString();
                    this.pnlAdd.Visible = true;
                    pnlList.Visible     = false;
                }
            }
        }
Пример #2
0
        public async Task CreateProductIndexIfNotExistAsync()
        {
            var indexName = _searchManagementSettings.ProductsIndexName;

            using (var serviceClient = CreateSearchServiceClient())
            {
                // check if index exists
                if (serviceClient.Indexes.Exists(indexName))
                {
                    return;
                }

                var indexDefinition = new Index()
                {
                    Name            = indexName,
                    Fields          = FieldBuilder.BuildForType <IndexProduct>(),
                    Suggesters      = IndexProduct.GetSuggesters(),
                    ScoringProfiles = IndexProduct.GetScoringProfiles(),
                };

                await serviceClient.Indexes.CreateAsync(indexDefinition);
            }
        }
Пример #3
0
        /// <summary>
        /// 添加友情连接
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void Button1_Click(object sender, EventArgs e)
        {
            string title    = txtTitle.Text.Trim();
            string proDesc  = this.txtTitle2.Text.Trim();
            string proPrice = this.txtPrice.Text.Trim();
            string unitDesc = txtUnit.Text.Trim();
            string url      = this.txtLinkUrl.Text.Trim();

            string spic = "";

            if (this.FileUpload1.PostedFile != null && FileUpload1.PostedFile.FileName != "")
            {
                if (!Directory.Exists(Server.MapPath(Global_Upload.FriendImgPath)))         //判断目录是否存在
                {
                    Directory.CreateDirectory(Server.MapPath(Global_Upload.FriendImgPath)); //创建目录
                }
                spic = DoClass.UploadFile(FileUpload1.PostedFile, Global_Upload.Imgsize, Global_Upload.ImgType, Global_Upload.FriendImgPath);

                if (spic == "-1")
                {
                    return;
                }
                else if (spic == "0")
                {
                    return;
                }
                else
                {
                    ViewState["img1Name"] = spic;
                    spic = Global_Upload.FriendImgPath + spic;
                    ViewState["newsImg1"] = spic;
                    lblURL1.Text          = spic;
                }
            }

            IndexProduct item = new IndexProduct();

            item.typeId   = Convert.ToInt32(ddlCate.SelectedValue);
            item.typeName = ddlCate.SelectedItem.Text;
            item.proName  = title;
            item.proDesc  = proDesc;
            item.proPrice = 0;
            item.priceStr = proPrice;
            item.unitDesc = unitDesc;

            if (ViewState["newsImg1"] != null || lblURL1.Text != "")
            {
                item.imgUrl = lblURL1.Text;
            }
            else
            {
                lblError.Text = "请上传图片";
                return;
            }
            item.status   = 0;
            item.remark   = url;
            item.addTime  = DateTime.Now;
            item.infoType = 0;
            item.addUser  = 0;
            AdminUser au = Session["loginUser"] as AdminUser;

            if (au != null)
            {
                item.addUser = au.id;
            }
            if (lblId.Text != "")
            {
                item.id = Convert.ToInt32(lblId.Text.Trim());
                IndexProductService.Update(item);
            }
            else
            {
                int num = IndexProductService.Add(item);
            }
            pnlAdd.Visible  = false;
            pnlList.Visible = true;
            LoadData();
        }
Пример #4
0
        public static EkProduct EkNewIndexProductToProduct(IndexProduct indexProduct)
        {
            Assure.ArgumentNotNull(indexProduct, nameof(indexProduct));

            var photos = string.IsNullOrEmpty(indexProduct.ThumbnailUrl)
                ? null
                : new[]
            {
                new EkProductPhoto()
                {
                    Url = indexProduct.ThumbnailUrl
                },
            };

            var product = new EkProduct()
            {
                Key        = indexProduct.Key,
                PartNumber = indexProduct.PartNumber,
                BrandName  = indexProduct.BrandName,
                Source     = (EkProductSourceEnum)indexProduct.Source,
                SourceId   = indexProduct.SourceId,
                Name       = new MultiLanguageString()
                {
                    [Languages.RussianCode] = indexProduct.Name_ru,
                },
                Description = new MultiLanguageString()
                {
                    [Languages.RussianCode] = indexProduct.Description_ru,
                },
                SpecificationsJson = new MultiLanguageString()
                {
                    [Languages.RussianCode] = indexProduct.SpecificationsJson_ru,
                },
                Photos                = photos,
                BasePrice             = (decimal)(indexProduct.Price ?? 0),
                BasePriceCurrencyCode = "UAH",
                DeliveryPrice         = 0,
                State          = EkProductStateEnum.New,
                ProductionYear = indexProduct.ProductionYear,
            };

            switch (product.Source)
            {
            case EkProductSourceEnum.OmegaAutoBiz:
            case EkProductSourceEnum.ElitUa:
            {
                var A_Price = product.BasePrice;
                // fixed markup
                const decimal C_Markup = 0.17m;     // 17%
                var           price    = A_Price * (1 + C_Markup);
                product.Price = RoundPrice(price);
                product.PriceCalculationInfo = $"Formula=A+C%, A={A_Price}, C={C_Markup:P}, Source={product.Source}";
                break;
            }

            default:
            {
                product.Price = 0;
                product.PriceCalculationInfo = $"Forbidden (source '{product.Source}' is not supported)";
                break;
            }
            }

            product.PriceCurrencyCode = product.BasePriceCurrencyCode;

            return(product);
        }