protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { ProductVideoService.DeleteProductVideo(SQLDataHelper.GetInt(e.CommandArgument)); } }
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "Delete") { ProductVideoService.DeleteProductVideo(Convert.ToInt32(e.CommandArgument)); } }
protected void Page_PreRender(object sender, EventArgs e) { if (ProductID == 0) { return; } if (grid_video.UpdatedRow != null) { int sortOrder = 0; if (int.TryParse(grid_video.UpdatedRow["VideoSortOrder"], out sortOrder)) { ProductVideoService.UpdateProductVideo(SQLDataHelper.GetInt(grid_video.UpdatedRow["ProductVideoID"]), grid_video.UpdatedRow["Name"], sortOrder); } } DataTable data = _paging.PageItems; while (data.Rows.Count < 1 && _paging.CurrentPageIndex > 1) { _paging.CurrentPageIndex--; data = _paging.PageItems; } var clmn = new DataColumn("IsSelected", typeof(bool)) { DefaultValue = _inverseSelection }; data.Columns.Add(clmn); if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { for (int i = 0; i <= data.Rows.Count - 1; i++) { int intIndex = i; if (Array.Exists(_selectionFilter.Values, c => c == data.Rows[intIndex]["ProductVideoID"].ToString())) { data.Rows[i]["IsSelected"] = !_inverseSelection; } } } if (data.Rows.Count < 1) { goToPage.Visible = false; } grid_video.DataSource = data; grid_video.DataBind(); pageNumberer.PageCount = _paging.PageCount; //lblFound.Text = _paging.TotalRowsCount.ToString(); }
private void CreateVideo() { // // Validation // MsgErr(true); //if (String.IsNullOrEmpty(txtName.Text.Trim())) //{ // MsgErr(Resource.Admin_m_ProductVideos_NoName); // return; //} string playercode = txtPlayerCode.Text.Trim(); if (string.IsNullOrEmpty(playercode)) { string error; playercode = ProductVideoService.GetPlayerCodeFromLink(txtVideoLink.Text.Trim(), out error); if (!string.IsNullOrEmpty(error)) { MsgErr(error); return; } } int sortOrder = 0; if (!String.IsNullOrEmpty(txtSortOrder.Text)) { int.TryParse(txtSortOrder.Text, out sortOrder); } try { ProductVideoService.AddProductVideo(new ProductVideo { ProductId = ProductId, Name = txtName.Text.Trim(), PlayerCode = playercode, Description = txtDescription.Text.Trim(), VideoSortOrder = sortOrder }); } catch (Exception ex) { MsgErr(ex.Message + " CreateVideo"); Debug.LogError(ex); } }
private void SaveVideo() { // // Validation // MsgErr(true); if (VideoId == 0) { MsgErr(Resource.Admin_m_News_WrongPageParameters); return; } //if (String.IsNullOrEmpty(txtName.Text.Trim())) //{ // MsgErr(Resource.Admin_m_ProductVideos_NoName); // return; //} if (String.IsNullOrEmpty(txtPlayerCode.Text.Trim())) { MsgErr(Resource.Admin_m_ProductVideos_NoPlayerCode); return; } int sortOrder = 0; if (!String.IsNullOrEmpty(txtSortOrder.Text)) { int.TryParse(txtSortOrder.Text, out sortOrder); } try { ProductVideoService.UpdateProductVideo(new ProductVideo { ProductVideoId = VideoId, Name = txtName.Text.Trim(), PlayerCode = txtPlayerCode.Text.Trim(), Description = txtDescription.Text.Trim(), VideoSortOrder = sortOrder }); } catch (Exception ex) { MsgErr(ex.Message + " SaveProductVideos"); Debug.LogError(ex); } }
private void LoadVideoById(int videoId) { ProductVideo pv = ProductVideoService.GetProductVideo(videoId); if (pv == null) { MsgErr("Video with this ID not exist"); return; } preview.InnerHtml = pv.PlayerCode; preview.Visible = true; txtName.Text = pv.Name; txtPlayerCode.Text = pv.PlayerCode; txtDescription.Text = pv.Description; txtSortOrder.Text = pv.VideoSortOrder.ToString(CultureInfo.InvariantCulture); }
private static void OtherFields(IDictionary <ProductFields, object> fields, int productId, string columSeparator, string propertySeparator) { //Category if (fields.ContainsKey(ProductFields.Category)) { string sorting = string.Empty; if (fields.ContainsKey(ProductFields.Sorting)) { sorting = fields[ProductFields.Sorting].AsString(); } var parentCategory = fields[ProductFields.Category].AsString(); CategoryService.SubParseAndCreateCategory(parentCategory, productId, columSeparator, sorting); } //photo if (fields.ContainsKey(ProductFields.Photos)) { string photos = fields[ProductFields.Photos].AsString(); if (!string.IsNullOrEmpty(photos)) { PhotoService.PhotoFromString(productId, photos, columSeparator, propertySeparator, _skipOriginalPhoto); } } //video if (fields.ContainsKey(ProductFields.Videos)) { string videos = fields[ProductFields.Videos].AsString(); ProductVideoService.VideoFromString(productId, videos, columSeparator); } //Properties if (fields.ContainsKey(ProductFields.Properties)) { string properties = fields[ProductFields.Properties].AsString(); PropertyService.PropertiesFromString(productId, properties, columSeparator, propertySeparator); } if (fields.ContainsKey(ProductFields.CustomOption)) { string customOption = fields[ProductFields.CustomOption].AsString(); CustomOptionsService.CustomOptionsFromString(productId, customOption); } }
protected void lbDeleteSelected_Click(object sender, EventArgs e) { if ((_selectionFilter != null) && (_selectionFilter.Values != null)) { if (!_inverseSelection) { foreach (string id in _selectionFilter.Values) { ProductVideoService.DeleteProductVideo(Convert.ToInt32(id)); } } else { IEnumerable <ProductVideo> videos = ProductVideoService.GetProductVideos(ProductID); foreach (ProductVideo pv in videos.Where(pv => !_selectionFilter.Values.Contains(pv.ProductVideoId.ToString()))) { ProductVideoService.DeleteProductVideo(pv.ProductVideoId); } } } }
private void CreateVideo() { // // Validation // MsgErr(true); if (String.IsNullOrEmpty(txtName.Text.Trim())) { MsgErr(Resource.Admin_m_ProductVideos_NoName); return; } string playercode = txtPlayerCode.Text.Trim(); if (string.IsNullOrEmpty(playercode)) { try { string videoLink = txtVideoLink.Text.Trim(); if (!String.IsNullOrEmpty(videoLink)) { if (videoLink.Contains("youtu.be")) { playercode = String.Format("<iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/{0}\" frameborder=\"0\" allowfullscreen></iframe>", videoLink.Split(new[] { "youtu.be/" }, StringSplitOptions.None).Last()); } else if (videoLink.Contains("youtube.com")) { videoLink = videoLink.StartsWith("http://") ? videoLink : "http://" + videoLink; if (!Uri.IsWellFormedUriString(videoLink, UriKind.Absolute)) { MsgErr(Resource.Admin_m_ProductVideos_WrongLink); return; } var url = new Uri(videoLink); string param = HttpUtility.ParseQueryString(url.Query).Get("v"); playercode = String.Format("<iframe width=\"560\" height=\"315\" src=\"http://www.youtube.com/embed/{0}\" frameborder=\"0\" allowfullscreen></iframe>", param); } else if (videoLink.Contains("vimeo.com")) { playercode = String.Format("<iframe src=\"http://player.vimeo.com/video/{0}?title=0&byline=0&portrait=0\" width=\"560\" height=\"315\" frameborder=\"0\" webkitAllowFullScreen mozallowfullscreen allowFullScreen></iframe>", videoLink.Split(new[] { "vimeo.com/" }, StringSplitOptions.None).Last()); } else { MsgErr(Resource.Admin_m_ProductVideos_WrongLink); return; } } else { MsgErr(Resource.Admin_m_ProductVideos_NoPlayerCode); return; } } catch (Exception ex) { MsgErr(Resource.Admin_m_ProductVideos_WrongLink); Debug.LogError(ex); return; } } int sortOrder = 0; if (!String.IsNullOrEmpty(txtSortOrder.Text)) { int.TryParse(txtSortOrder.Text, out sortOrder); } try { ProductVideoService.AddProductVideo(new ProductVideo { ProductId = ProductId, Name = txtName.Text.Trim(), PlayerCode = playercode, Description = txtDescription.Text.Trim(), VideoSortOrder = sortOrder }); } catch (Exception ex) { MsgErr(ex.Message + " CreateVideo"); Debug.LogError(ex); } }
private void WriteItem(ICsvWriter writer, Product product) { var meta = MetaInfoService.GetMetaInfo(product.ID, MetaType.Product) ?? new MetaInfo(0, 0, MetaType.Product, string.Empty, string.Empty, string.Empty, string.Empty); foreach (var item in _fieldMapping) { if (item == ProductFields.Sku) { writer.WriteField(product.ArtNo); } if (item == ProductFields.Name) { writer.WriteField(product.Name); } if (item == ProductFields.ParamSynonym) { writer.WriteField(product.UrlPath); } if (item == ProductFields.Category) { writer.WriteField((CategoryService.GetCategoryStringByProductId(product.ProductId, _columSeparator))); } if (item == ProductFields.Sorting) { writer.WriteField((CategoryService.GetCategoryStringByProductId(product.ProductId, _columSeparator, true))); } if (item == ProductFields.Enabled) { writer.WriteField(product.Enabled ? "+" : "-"); } if (!product.HasMultiOffer) { var offer = product.Offers.FirstOrDefault() ?? new Offer(); if (item == ProductFields.Price) { writer.WriteField(offer.Price.ToString("F2")); } if (item == ProductFields.PurchasePrice) { writer.WriteField(offer.SupplyPrice.ToString("F2")); } if (item == ProductFields.Amount) { writer.WriteField(offer.Amount.ToString(CultureInfo.InvariantCulture)); } if (item == ProductFields.MultiOffer) { writer.WriteField(string.Empty); } } else { if (item == ProductFields.Price) { writer.WriteField(string.Empty); } if (item == ProductFields.PurchasePrice) { writer.WriteField(string.Empty); } if (item == ProductFields.Amount) { writer.WriteField(string.Empty); } if (item == ProductFields.MultiOffer) { writer.WriteField(OfferService.OffersToString(product.Offers, _columSeparator, _propertySeparator)); } } if (item == ProductFields.Unit) { writer.WriteField(product.Unit); } if (item == ProductFields.ShippingPrice) { writer.WriteField(product.ShippingPrice.ToString("F2")); } if (item == ProductFields.Discount) { writer.WriteField(product.Discount.ToString("F2")); } if (item == ProductFields.Weight) { writer.WriteField(product.Weight.ToString("F2")); } if (item == ProductFields.Size) { writer.WriteField(product.Size.Replace("|", " x ")); } if (item == ProductFields.BriefDescription) { writer.WriteField(product.BriefDescription); } if (item == ProductFields.Description) { writer.WriteField(product.Description); } if (item == ProductFields.Title) { writer.WriteField(meta.Title); } if (item == ProductFields.H1) { writer.WriteField(meta.H1); } if (item == ProductFields.MetaKeywords) { writer.WriteField(meta.MetaKeywords); } if (item == ProductFields.MetaDescription) { writer.WriteField(meta.MetaDescription); } if (item == ProductFields.Markers) { writer.WriteField(ProductService.MarkersToString(product, _columSeparator)); } if (item == ProductFields.Photos) { writer.WriteField(PhotoService.PhotoToString(product.ProductPhotos, _columSeparator, _propertySeparator)); } if (item == ProductFields.Videos) { writer.WriteField(ProductVideoService.VideoToString(product.ProductVideos, _columSeparator)); } if (item == ProductFields.Properties) { writer.WriteField(PropertyService.PropertiesToString(product.ProductPropertyValues, _columSeparator, _propertySeparator)); } if (item == ProductFields.Producer) { writer.WriteField(BrandService.BrandToString(product.BrandId)); } if (item == ProductFields.OrderByRequest) { writer.WriteField(product.AllowPreOrder ? "+" : "-"); } if (item == ProductFields.SalesNotes) { writer.WriteField(product.SalesNote); } if (item == ProductFields.Related) { writer.WriteField(ProductService.LinkedProductToString(product.ProductId, RelatedType.Related, _columSeparator)); } if (item == ProductFields.Alternative) { writer.WriteField(ProductService.LinkedProductToString(product.ProductId, RelatedType.Alternative, _columSeparator)); } if (item == ProductFields.CustomOption) { writer.WriteField(CustomOptionsService.CustomOptionsToString(CustomOptionsService.GetCustomOptionsByProductId(product.ProductId))); } if (item == ProductFields.Gtin) { writer.WriteField(product.Gtin); } if (item == ProductFields.GoogleProductCategory) { writer.WriteField(product.GoogleProductCategory); } if (item == ProductFields.Adult) { writer.WriteField(product.Adult ? "+" : "-"); } if (item == ProductFields.ManufacturerWarranty) { writer.WriteField(product.ManufacturerWarranty ? "+" : "-"); } } writer.NextRecord(); }
protected void Page_Load(object sender, EventArgs e) { hasVideos = ProductVideoService.HasVideo(ProductID); }
private void LoadFirstProduct() { var columSeparator = txtColumSeparator.Text; var propertySeparator = txtPropertySeparator.Text; var product = ProductService.GetFirstProduct(); if (product == null) { return; } foreach (var item in Enum.GetValues(typeof(ProductFields))) { if ((ProductFields)item == ProductFields.None) { ddlProduct.Items.Add(new ListItem { Text = @"-", Value = ProductFields.None.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Sku) { ddlProduct.Items.Add(new ListItem { Text = product.ArtNo, Value = ProductFields.Sku.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Name) { ddlProduct.Items.Add(new ListItem { Text = product.Name.HtmlEncode(), Value = ProductFields.Name.ConvertIntString() }); } if ((ProductFields)item == ProductFields.ParamSynonym) { ddlProduct.Items.Add(new ListItem { Text = product.UrlPath, Value = ProductFields.ParamSynonym.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Category) { ddlProduct.Items.Add(new ListItem { Text = CategoryService.GetCategoryStringByProductId(product.ProductId, columSeparator), Value = ProductFields.Category.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Sorting) { ddlProduct.Items.Add(new ListItem { Text = CategoryService.GetCategoryStringByProductId(product.ProductId, columSeparator, true), Value = ProductFields.Sorting.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Enabled) { ddlProduct.Items.Add(new ListItem { Text = product.Enabled ? "+" : "-", Value = ProductFields.Enabled.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Price) { ddlProduct.Items.Add(new ListItem { Text = product.Offers.Select(x => x.Price).FirstOrDefault().ToString("F2"), Value = ProductFields.Price.ConvertIntString() }); } if ((ProductFields)item == ProductFields.PurchasePrice) { ddlProduct.Items.Add(new ListItem { Text = product.Offers.Select(x => x.SupplyPrice).FirstOrDefault().ToString("F2"), Value = ProductFields.PurchasePrice.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Amount) { ddlProduct.Items.Add(new ListItem { Text = product.Offers.Select(x => x.Amount).FirstOrDefault().ToString("F2"), Value = ProductFields.Amount.ConvertIntString() }); } if ((ProductFields)item == ProductFields.MultiOffer) { ddlProduct.Items.Add(new ListItem { Text = OfferService.OffersToString(product.Offers, columSeparator, propertySeparator), Value = ProductFields.MultiOffer.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Unit) { ddlProduct.Items.Add(new ListItem { Text = product.Unit, Value = ProductFields.Unit.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Discount) { ddlProduct.Items.Add(new ListItem { Text = product.Discount.ToString("F2"), Value = ProductFields.Discount.ConvertIntString() }); } if ((ProductFields)item == ProductFields.ShippingPrice) { ddlProduct.Items.Add(new ListItem { Text = product.ShippingPrice.ToString("F2"), Value = ProductFields.ShippingPrice.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Weight) { ddlProduct.Items.Add(new ListItem { Text = product.Weight.ToString("F2"), Value = ProductFields.Weight.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Size) { ddlProduct.Items.Add(new ListItem { Text = product.Size.Replace("|", " x "), Value = ProductFields.Size.ConvertIntString() }); } if ((ProductFields)item == ProductFields.BriefDescription) { ddlProduct.Items.Add(new ListItem { Text = product.BriefDescription.Reduce(20).HtmlEncode(), Value = ProductFields.BriefDescription.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Description) { ddlProduct.Items.Add(new ListItem { Text = product.Description.Reduce(20).HtmlEncode(), Value = ProductFields.Description.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Title) { ddlProduct.Items.Add(new ListItem { Text = product.Meta.Title.Reduce(20), Value = ProductFields.Title.ConvertIntString() }); } if ((ProductFields)item == ProductFields.H1) { ddlProduct.Items.Add(new ListItem { Text = product.Meta.H1.Reduce(20), Value = ProductFields.H1.ConvertIntString() }); } if ((ProductFields)item == ProductFields.MetaKeywords) { ddlProduct.Items.Add(new ListItem { Text = product.Meta.MetaKeywords.Reduce(20), Value = ProductFields.MetaKeywords.ConvertIntString() }); } if ((ProductFields)item == ProductFields.MetaDescription) { ddlProduct.Items.Add(new ListItem { Text = product.Meta.MetaDescription.Reduce(20), Value = ProductFields.MetaDescription.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Photos) { ddlProduct.Items.Add(new ListItem { Text = PhotoService.PhotoToString(product.ProductPhotos, columSeparator, propertySeparator), Value = ProductFields.Photos.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Videos) { ddlProduct.Items.Add(new ListItem { Text = ProductVideoService.VideoToString(product.ProductVideos, columSeparator).Reduce(20).HtmlEncode(), Value = ProductFields.Videos.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Markers) { ddlProduct.Items.Add(new ListItem { Text = ProductService.MarkersToString(product, columSeparator), Value = ProductFields.Markers.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Properties) { ddlProduct.Items.Add(new ListItem { Text = PropertyService.PropertiesToString(product.ProductPropertyValues, columSeparator, propertySeparator).HtmlEncode(), Value = ProductFields.Properties.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Producer) { ddlProduct.Items.Add(new ListItem { Text = BrandService.BrandToString(product.BrandId), Value = ProductFields.Producer.ConvertIntString() }); } if ((ProductFields)item == ProductFields.OrderByRequest) { ddlProduct.Items.Add(new ListItem { Text = product.AllowPreOrder ? "+" : "-", Value = ProductFields.OrderByRequest.ConvertIntString() }); } if ((ProductFields)item == ProductFields.SalesNotes) { ddlProduct.Items.Add(new ListItem { Text = product.SalesNote, Value = ProductFields.SalesNotes.ConvertIntString() }); } if ((ProductFields)item == ProductFields.Related) { ddlProduct.Items.Add(new ListItem(ProductService.LinkedProductToString(product.ProductId, RelatedType.Related, columSeparator), ProductFields.Related.ConvertIntString())); } if ((ProductFields)item == ProductFields.Alternative) { ddlProduct.Items.Add(new ListItem(ProductService.LinkedProductToString(product.ProductId, RelatedType.Alternative, columSeparator), ProductFields.Alternative.ConvertIntString())); } if ((ProductFields)item == ProductFields.CustomOption) { ddlProduct.Items.Add(new ListItem(CustomOptionsService.CustomOptionsToString(CustomOptionsService.GetCustomOptionsByProductId(product.ProductId)), ProductFields.CustomOption.ConvertIntString())); } if ((ProductFields)item == ProductFields.Gtin) { ddlProduct.Items.Add(new ListItem(product.Gtin, ProductFields.Gtin.ConvertIntString())); } if ((ProductFields)item == ProductFields.GoogleProductCategory) { ddlProduct.Items.Add(new ListItem(product.GoogleProductCategory, ProductFields.GoogleProductCategory.ConvertIntString())); } if ((ProductFields)item == ProductFields.Adult) { ddlProduct.Items.Add(new ListItem { Text = product.Adult ? "+" : "-", Value = ProductFields.Adult.ConvertIntString() }); } if ((ProductFields)item == ProductFields.ManufacturerWarranty) { ddlProduct.Items.Add(new ListItem { Text = product.ManufacturerWarranty ? "+" : "-", Value = ProductFields.ManufacturerWarranty.ConvertIntString() }); } } }