protected void updateSoundIcon_Click(object sender, EventArgs e) { Product product = ProductManager.GetProductById(this.ProductId); if (product != null) { CatalogBiz catalogBiz = new CatalogBiz(); lwg_Catalog catalog = catalogBiz.GetByID(ProductId); if (catalog == null) { catalog = new lwg_Catalog(); catalog.CatalogId = product.ProductId; catalog.CatalogNumber = string.Empty; catalog.Subtitle = string.Empty; catalog.TextLang = string.Empty; catalog.PTSprodcode = string.Empty; catalog.KaldbNumber = string.Empty; catalog.SoundIcon = string.Empty; catalog.PDF = string.Empty; catalog.pages = string.Empty; catalogBiz.SaveCatalog(catalog); } string strSoundIcon = SavePictureIcon(uploadSoundIcon); catalog.SoundIcon = strSoundIcon.Equals("0") == true ? catalog.SoundIcon : strSoundIcon; // txtSoundIcon.Text;// "soundIcon"; //TODO: change uploadfile control catalog.SoundIcon = catalog.SoundIcon == null ? string.Empty : catalog.SoundIcon; catalogBiz.SaveCatalog(catalog); } }
private void BindData() { Product product = ProductManager.GetProductById(ProductId); if (product != null) { CatalogBiz catalogBiz = new CatalogBiz(); lwg_Catalog catalog = catalogBiz.GetByID(this.ProductId); pnlData.Visible = true; pnlMessage.Visible = false; if (catalog != null) { if (catalog.lwg_Video.Count > 0) { gvVideos.Visible = true; gvVideos.DataSource = catalog.lwg_Video; gvVideos.DataBind(); } else { gvVideos.Visible = false; } } } else { pnlData.Visible = false; pnlMessage.Visible = true; } }
protected void btnDelete_Click(object sender, EventArgs e) { try { foreach (GridViewRow row in gvProducts.Rows) { var cbProduct = row.FindControl("cbProduct") as CheckBox; var hfProductId = row.FindControl("hfProductId") as HiddenField; bool isChecked = cbProduct.Checked; int productId = int.Parse(hfProductId.Value); if (isChecked) { ProductManager.MarkProductAsDeleted(productId); //\ Delete lwg_catalog CatalogBiz cBiz = new CatalogBiz(); lwg_Catalog lwgCatalog = cBiz.GetByID(productId); if (lwgCatalog != null) { cBiz.DeleteCatalog(lwgCatalog); } //\ } } BindGrid(); } catch (Exception ex) { ProcessException(ex); } }
public static string GetCatalogUrl(lwg_Catalog catalog) { if (catalog == null) { throw new ArgumentNullException("catalog"); } string seName = GetSEName(catalog.TitleDisplay); string url = string.Format(SettingManager.GetSettingValue("SEO.Product.UrlRewriteFormat"), CommonHelper.GetStoreLocation(), catalog.CatalogId, seName); return(url.ToLowerInvariant()); }
public bool DeleteCatalog(lwg_Catalog h) { if (h != null) { if (h.CatalogId > 0) { //Delete catalogTitle List <lwg_CatalogTitle> lstTitle = dbContext.lwg_CatalogTitle.Where(t => t.CatalogId == h.CatalogId).ToList(); dbContext.lwg_CatalogTitle.RemoveRange(lstTitle); //Delete CatalogInstrumentSearch List <lwg_CatalogInstrumentSearch> lstInstrumentSearch = dbContext.lwg_CatalogInstrumentSearch.Where(s => s.CatalogId == h.CatalogId).ToList(); dbContext.lwg_CatalogInstrumentSearch.RemoveRange(lstInstrumentSearch); // Delete CatalogPublisher List <lwg_CatalogPublisher> lstCP = dbContext.lwg_CatalogPublisher.Where(cp => cp.CatalogId == h.CatalogId).ToList(); dbContext.lwg_CatalogPublisher.RemoveRange(lstCP); //Delete CatalogCategory //List<lwg_CatalogCategory> lstCC = dbContext.CatalogCategories.Where(cc => cc.CatalogId == h.CatalogId).ToList(); //dbContext.lwg_CatalogCategories.DeleteAllOnSubmit(lstCC); //Delete CatalogNameSearch List <lwg_CatalogNameSearch> lstNameSearch = dbContext.lwg_CatalogNameSearch.Where(cn => cn.CatalogId == h.CatalogId).ToList(); dbContext.lwg_CatalogNameSearch.RemoveRange(lstNameSearch); //Delete CatalogTitleSearch List <lwg_CatalogTitleSearch> lstTitleSearch = dbContext.lwg_CatalogTitleSearch.Where(cts => cts.CatalogId == h.CatalogId).ToList(); dbContext.lwg_CatalogTitleSearch.RemoveRange(lstTitleSearch); //Delete CatalogGenre List <lwg_CatalogGenre> lstGenre = dbContext.lwg_CatalogGenre.Where(cg => cg.CatalogId == h.CatalogId).ToList(); dbContext.lwg_CatalogGenre.RemoveRange(lstGenre); //Delete catalogPeople List <lwg_PersonInRole> lstPersonInRole = dbContext.lwg_PersonInRole.Where(cp => cp.CatalogId == h.CatalogId).ToList(); dbContext.lwg_PersonInRole.RemoveRange(lstPersonInRole); //Delete CatalogComposer //List<lwg_CatalogComposer> lstComposer = dbContext.lwg_CatalogComposers.Where(cp => cp.CatalogId == h.CatalogId).ToList(); //dbContext.lwg_CatalogComposers.DeleteAllOnSubmit(lstComposer); //Delete Catalog // delete period new PeriodBiz().DeletePeriodMappingBuyID(h.CatalogId); // delete ReprintSource new ReprintSourceBiz().DeleteReprintSourceMappingByID(h.CatalogId); // delete Series new SeriesBiz().DeleteSeriesMappingByID(h.CatalogId); // delete audio new AudioBiz().DeleteAudiosById(h.CatalogId); // delete video new VideoBiz().DeleteVideosById(h.CatalogId); dbContext.lwg_Catalog.Remove(h); dbContext.SaveChanges(); return(true); } } return(false); }
private void FillData(lwg_Catalog p) { if (p != null) { // insert data txtCatalogNumber.Text = p.CatalogNumber; txtDuration.Text = p.Duration; // "Duration1"; txtGrade.Text = p.Grade == null ? string.Empty : p.Grade; if (drpInstrumental.Items.Count > 0) { drpInstrumental.SelectedValue = p.InstrumentalId == null ? "-1" : p.InstrumentalId.ToString(); } txtKaldbNumber.Text = p.KaldbNumber;// "Kalddbnumber1"; txtPages.Text = p.pages; txtSubTitle.Text = p.Subtitle == null ? string.Empty : p.Subtitle; txtTextLang.Text = p.TextLang == null ? string.Empty : p.TextLang; // replace YearTo, YearFrom by Year txtYear.Text = p.Year; if (!string.IsNullOrEmpty(p.PDF)) { ltrPDFFile.Text = p.PDF; btnDeletePDFFile.Visible = true; } else { ltrPDFFile.Text = string.Empty; btnDeletePDFFile.Visible = false; } CatalogBiz cBiz = new CatalogBiz(); txtCatalogInstrSearch.Text = cBiz.GetInstrSearchByCatalogID(p.CatalogId); txtCatalogNameSearch.Text = cBiz.GetNameSearchByCatalogID(p.CatalogId); int iPublisherID = cBiz.GetPublisherIDByCatalogID(p.CatalogId); if (iPublisherID > 0) { drpCatalogPublisher.SelectedValue = iPublisherID.ToString(); } txtInstrDetail.Text = p.InstrDetail == null ? string.Empty : p.InstrDetail; chkVocAccomp.Checked = p.VocAccomp == null ? false : p.VocAccomp.Value; txtTableofContents.Content = p.TableofContents; txtCopyrightYear.Text = p.CopyrightYear; } }
protected void SaveButton_Click(object sender, EventArgs e) { if (Page.IsValid) { try { Product product = null; //uncomment this line to support transactions //using (var scope = new System.Transactions.TransactionScope()) { product = ctrlProductInfoAdd.SaveInfo(); ctrlProductSEO.SaveInfo(product.ProductId); ctrlProductCategory.SaveInfo(product.ProductId); ctrlProductManufacturer.SaveInfo(product.ProductId); // add catalog CatalogBiz catalogBiz = new CatalogBiz(); lwg_Catalog catalog = new lwg_Catalog(); catalog.CatalogId = product.ProductId; catalog.CatalogNumber = string.Empty; catalog.Subtitle = string.Empty; catalog.TextLang = string.Empty; catalog.PTSprodcode = string.Empty; catalog.KaldbNumber = string.Empty; catalog.SoundIcon = string.Empty; catalog.PDF = string.Empty; catalog.pages = string.Empty; catalog.TitleDisplay = product.Name; //added to fix empty TitleDisplay issue for new product (LDWG-194) catalogBiz.SaveCatalog(catalog); CustomerActivityManager.InsertActivity( "AddNewProduct", GetLocaleResourceString("ActivityLog.AddNewProduct"), product.Name); //uncomment this line to support transactions //scope.Complete(); } if (product != null) { Response.Redirect("ProductDetails.aspx?ProductID=" + product.ProductId); } } catch (Exception exc) { ProcessException(exc); } } }
public Product SaveInfo() { Product product = ProductManager.GetProductById(this.ProductId, 0); if (product != null) { product = ProductManager.UpdateProduct(product.ProductId, txtName.Text, txtShortDescription.Text, txtFullDescription.Content, txtAdminComment.Text, int.Parse(this.ddlProductType.SelectedItem.Value), int.Parse(this.ddlTemplate.SelectedItem.Value), cbShowOnHomePage.Checked, product.MetaKeywords, product.MetaDescription, product.MetaTitle, product.SEName, cbAllowCustomerReviews.Checked, cbAllowCustomerRatings.Checked, product.RatingSum, product.TotalRatingVotes, cbPublished.Checked, product.Deleted, product.CreatedOn, DateTime.Now); SaveLocalizableContent(product); //Update catalog's TitleDisplay CatalogBiz catalogBiz = new CatalogBiz(); lwg_Catalog catalog = catalogBiz.GetByID(product.ProductId); if (catalog != null) { catalog.TitleDisplay = txtName.Text; catalogBiz.SaveCatalog(catalog); } //product tags var productTags1 = ProductManager.GetAllProductTags(product.ProductId, string.Empty); foreach (var productTag in productTags1) { ProductManager.RemoveProductTagMapping(product.ProductId, productTag.ProductTagId); } string[] productTagNames = ParseProductTags(txtProductTags.Text); foreach (string productTagName in productTagNames) { ProductTag productTag = null; var productTags2 = ProductManager.GetAllProductTags(0, productTagName); if (productTags2.Count == 0) { productTag = ProductManager.InsertProductTag(productTagName, 0); } else { productTag = productTags2[0]; } ProductManager.AddProductTagMapping(product.ProductId, productTag.ProductTagId); } } return(product); }
protected void dlRecentProduct_Bound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { lwg_Catalog obj = (lwg_Catalog)e.Item.DataItem; string catalogURL = SEOHelper.GetCatalogUrl(obj); Label lbl = (Label)e.Item.FindControl("lblNumber"); lbl.Text = (e.Item.ItemIndex + 1).ToString(); HyperLink hpl = (HyperLink)e.Item.FindControl("hplName"); hpl.Text = obj.TitleDisplay; hpl.NavigateUrl = catalogURL; } }
protected void btnDeletePDFFile_Click(object sender, EventArgs e) { CatalogBiz catalogBiz = new CatalogBiz(); lwg_Catalog catalog = catalogBiz.GetByID(this.ProductId); if (catalog != null) { if (!string.IsNullOrEmpty(catalog.PDF)) { LWGUtils.ClearOldFile(string.Format("{0}{1}", LWGUtils.GetPDFPath(), catalog.PDF)); catalog.PDF = string.Empty; catalogBiz.SaveCatalog(catalog); BindingCatalog(); } } }
private void BindData() { Product product = ProductManager.GetProductById(ProductId); if (product != null) { pnlData.Visible = true; pnlMessage.Visible = false; CatalogBiz catalogBiz = new CatalogBiz(); lwg_Catalog catalog = catalogBiz.GetByID(this.ProductId); if (catalog != null) { if (catalog.lwg_Audio.Count > 0) { gvAudios.Visible = true; gvAudios.DataSource = catalog.lwg_Audio; gvAudios.DataBind(); } else { gvAudios.Visible = false; } if (!string.IsNullOrEmpty(catalog.SoundIcon)) { int temp = 0; if (int.TryParse(catalog.SoundIcon, out temp) && temp > 0) { Picture Picture = PictureManager.GetPictureById(temp); string pictureUrl = PictureManager.GetPictureUrl(Picture, 100); imgSoundIcon.Visible = true; imgSoundIcon.ImageUrl = pictureUrl; } } } } else { pnlData.Visible = false; pnlMessage.Visible = true; } }
private void BindingCatalog() { if (ProductId == 0) { pnlMessage.Visible = true; updatepnCatalog.Visible = false; return; } else { Product product = ProductManager.GetProductById(this.ProductId); if (product != null) { ltBlurb.Text = product.FullDescription; //load product variants ProductVariantCollection productVariants = product.ProductVariants; gvProductVariants.DataSource = productVariants; gvProductVariants.DataBind(); if (productVariants.Count > 1) { lblFScprodcode.Text = productVariants[1].SKU.ToString();// FSCprodcode1 mapped from SKU of second variant } CatalogBiz cBiz = new CatalogBiz(); lwg_Catalog c = cBiz.GetByID(ProductId); if (c != null) { FillData(c); btnAdd.Text = "Update"; } else { ClearData(); btnAdd.Text = "Add"; } } } }
protected void DeleteButton_Click(object sender, EventArgs e) { try { Product product = ProductManager.GetProductById(this.ProductId); if (product != null) { ProductManager.MarkProductAsDeleted(this.ProductId); CustomerActivityManager.InsertActivity( "DeleteProduct", GetLocaleResourceString("ActivityLog.DeleteProduct"), product.Name); //\ delete catalog CatalogBiz cBiz = new CatalogBiz(); lwg_Catalog lwg = cBiz.GetByID(this.ProductId); if (lwg != null) { foreach (lwg_Audio audio in lwg.lwg_Audio) { LWGUtils.ClearOldFile(string.Format("{0}{1}", LWGUtils.GetSoundPath(), audio.SoundFile)); } foreach (lwg_Video video in lwg.lwg_Video) { LWGUtils.ClearOldFile(string.Format("{0}{1}", LWGUtils.GetVideoPath(), video.QTFile)); } cBiz.DeleteCatalog(lwg); } //\ } Response.Redirect("Products.aspx"); } catch (Exception exc) { ProcessException(exc); } }
public bool SaveCatalog(lwg_Catalog c) { try { if (c != null) { if (dbContext.lwg_Catalog.Any(ct => ct.CatalogId == c.CatalogId)) { lwg_Catalog h = dbContext.lwg_Catalog.SingleOrDefault(ht => ht.CatalogId == c.CatalogId); if (h != null) { //TODO: all file catalog c.ArrangerGroupId = h.ArrangerGroupId; // allow null c.Blurb = h.Blurb; //p.CatalogId // increase by code c.CatalogNumber = h.CatalogNumber; c.Duration = h.Duration; c.Format1 = h.Format1; c.Format10 = h.Format10; c.Format2 = h.Format2; c.Format3 = h.Format3; c.Format4 = h.Format4; c.Format5 = h.Format5; c.Format6 = h.Format6; c.Format7 = h.Format7; c.Format8 = h.Format8; c.Format9 = h.Format9; c.FSCprodcode = h.FSCprodcode; c.Grade = h.Grade; // type : byte ? c.InstrumentalId = h.InstrumentalId; c.KaldbNumber = h.KaldbNumber; c.pages = h.pages; c.PDF = h.PDF; c.PeriodId = h.PeriodId; c.Price1 = h.Price1; // allow null c.Price2 = h.Price2; // allow null c.Price3 = h.Price3; // allow null c.Price4 = h.Price4; // allow null c.Price5 = h.Price5; // allow null c.Price6 = h.Price6; // allow null c.Price7 = h.Price7; // allow null c.Price8 = h.Price8; // allow null c.Price9 = h.Price9; // allow null c.Price10 = h.Price10; // allow null c.PTSprodcode = h.PTSprodcode; c.QTFile1 = h.QTFile1; c.QTFile2 = h.QTFile2; c.QTFile3 = h.QTFile3; c.QTFile4 = h.QTFile4; c.QTFile5 = h.QTFile5; c.QTFile6 = h.QTFile6; c.QTFile7 = h.QTFile7; c.QTFile8 = h.QTFile8; c.QTFile9 = h.QTFile9; c.QTFile10 = h.QTFile10; c.QTFile11 = h.QTFile11; c.recid = h.recid; // what's recid ? c.ReprintSourceId = h.ReprintSourceId; c.S4MasterSeries = h.S4MasterSeries; c.S5MasterCategories = h.S5MasterCategories; c.SeriesId = h.SeriesId; c.SoundFile1 = h.SoundFile1; c.SoundFile2 = h.SoundFile2; c.SoundFile3 = h.SoundFile3; c.SoundFile4 = h.SoundFile4; c.SoundFile5 = h.SoundFile5; c.SoundFile6 = h.SoundFile6; c.SoundFile7 = h.SoundFile7; c.SoundFile8 = h.SoundFile8; c.SoundFile9 = h.SoundFile9; c.SoundFile10 = h.SoundFile10; c.SoundFile11 = h.SoundFile11; c.SoundFile12 = h.SoundFile12; c.SoundFile13 = h.SoundFile13; c.SoundFile14 = h.SoundFile14; c.SoundFile15 = h.SoundFile15; c.SoundIcon = h.SoundIcon; c.Subtitle = h.Subtitle; c.TextLang = h.TextLang; c.TitleDisplay = h.TitleDisplay; c.TitleList = h.TitleList; c.TitleSort = h.TitleSort; c.Track01 = h.Track01; c.Track02 = h.Track02; c.Track03 = h.Track03; c.Track04 = h.Track04; c.Track05 = h.Track05; c.Track06 = h.Track06; c.Track07 = h.Track07; c.Track08 = h.Track08; c.Track09 = h.Track09; c.Track10 = h.Track10; c.Xform1 = h.Xform1; c.Xform2 = h.Xform2; c.Xform3 = h.Xform3; c.Xform4 = h.Xform4; c.Xform5 = h.Xform5; c.InstrDetail = h.InstrDetail; c.VocAccomp = h.VocAccomp; c.Year = h.Year; c.CopyrightYear = h.CopyrightYear; c.TableofContents = h.TableofContents; } else { return(false); } } else { dbContext.lwg_Catalog.Add(c); } dbContext.SaveChanges(); return(true); } return(false); } catch (Exception ex) { throw ex; } }
protected void btnUploadProductVideo_Click(object sender, EventArgs e) { try { Product product = ProductManager.GetProductById(this.ProductId); if (product != null) { CatalogBiz catalogBiz = new CatalogBiz(); lwg_Catalog catalog = catalogBiz.GetByID(product.ProductId); if (catalog == null) { catalog = new lwg_Catalog(); catalog.CatalogId = product.ProductId; catalog.CatalogNumber = string.Empty; catalog.Subtitle = string.Empty; catalog.TextLang = string.Empty; catalog.PTSprodcode = string.Empty; catalog.KaldbNumber = string.Empty; catalog.SoundIcon = string.Empty; catalog.PDF = string.Empty; catalog.pages = string.Empty; catalogBiz.SaveCatalog(catalog); } List <lwg_Video> videoList = new List <lwg_Video>(); lwg_Video video; string error = string.Empty; string path = SaveVideoFile(fuProductVideo1, ref error); if (string.IsNullOrEmpty(error)) { video = new lwg_Video(); video.CatalogId = this.ProductId; video.DisplayOrder = txtProductVideoDisplayOrder1.Value; video.QTFile = path; videoList.Add(video); } else { if (error == LWG.Business.LWGUtils.INVALID_FILE_EXTENSION) { throw new Exception("Invalid file extension."); } else if (error == LWG.Business.LWGUtils.INVALID_FILE_SIZE) { throw new Exception("Invalid file size"); } } path = SaveVideoFile(fuProductVideo2, ref error); if (string.IsNullOrEmpty(error)) { video = new lwg_Video(); video.CatalogId = this.ProductId; video.DisplayOrder = txtProductVideoDisplayOrder2.Value; video.QTFile = path; videoList.Add(video); } else { if (error == LWG.Business.LWGUtils.INVALID_FILE_EXTENSION) { throw new Exception("Invalid file extension."); } else if (error == LWG.Business.LWGUtils.INVALID_FILE_SIZE) { throw new Exception("Invalid file size"); } } path = SaveVideoFile(fuProductVideo3, ref error); if (string.IsNullOrEmpty(error)) { video = new lwg_Video(); video.CatalogId = this.ProductId; video.DisplayOrder = txtProductVideoDisplayOrder3.Value; video.QTFile = path; videoList.Add(video); } else { if (error == LWG.Business.LWGUtils.INVALID_FILE_EXTENSION) { throw new Exception("Invalid file extension."); } else if (error == LWG.Business.LWGUtils.INVALID_FILE_SIZE) { throw new Exception("Invalid file size"); } } // add videos if (videoList.Count > 0) { VideoBiz videoBiz = new VideoBiz(); videoBiz.AddCatalogVideo(videoList); BindData(); } } } catch (Exception exc) { ProcessException(exc); } }
private void BindData() { if (product != null) { string productURL = SEOHelper.GetProductUrl(product); LWG.Business.CatalogBiz catalogBiz = new LWG.Business.CatalogBiz(); lwg_Catalog catalog = catalogBiz.GetByID(product.ProductId); hlCatalogNo.Text = Server.HtmlEncode(catalog.CatalogNumber); hlProduct.NavigateUrl = hlCatalogNo.NavigateUrl = productURL; hlProduct.Text = Server.HtmlEncode(product.Name); ProductPicture productPicture = product.DefaultProductPicture; if (productPicture != null) { hlImageLink.ImageUrl = PictureManager.GetPictureUrl(productPicture.Picture, this.ProductImageSize, true); hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); } else { hlImageLink.ImageUrl = PictureManager.GetDefaultPictureUrl(this.ProductImageSize); hlImageLink.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageLinkTitleFormat"), product.Name); hlImageLink.Text = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); } hlImageLink.NavigateUrl = productURL; lShortDescription.Text = product.ShortDescription; var productVariantCollection = product.ProductVariants; if (productVariantCollection.Count > 0) { if (!product.HasMultipleVariants) { var productVariant = productVariantCollection[0]; btnAddToCart.Visible = (!productVariant.DisableBuyButton); if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || (NopContext.Current.User != null && !NopContext.Current.User.IsGuest)) { if (productVariant.CustomerEntersPrice) { lblOldPrice.Visible = false; lblPrice.Visible = false; } else { decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice); decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false)); decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase != decimal.Zero) { lblOldPrice.Text = PriceHelper.FormatPrice(oldPrice); lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount); } else { lblOldPrice.Visible = false; lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount); } } } else { lblOldPrice.Visible = false; lblPrice.Visible = false; btnAddToCart.Visible = false; } ddlVariantPrice.Visible = false; } else { lblOldPrice.Visible = false; lblPrice.Visible = false; btnAddToCart.Visible = false; ddlVariantPrice.Visible = true; ddlVariantPrice.DataSource = productVariantCollection.OrderBy(pv => pv.Price); ddlVariantPrice.DataBind(); #region comment built-in code //var productVariant = product.MinimalPriceProductVariant; //if (productVariant != null) //{ // if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || // (NopContext.Current.User != null && // !NopContext.Current.User.IsGuest)) // { // if (productVariant.CustomerEntersPrice) // { // lblOldPrice.Visible = false; // lblPrice.Visible = false; // } // else // { // decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false)); // decimal fromPrice = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); // lblOldPrice.Visible = false; // lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice)); // } // } // else // { // lblOldPrice.Visible = false; // lblPrice.Visible = false; // btnAddToCart.Visible = false; // } //} //btnAddToCart.Visible = false; #endregion } } else { lblOldPrice.Visible = false; lblPrice.Visible = false; btnAddToCart.Visible = false; } } }
private void BindData() { if (product != null) { string productURL = SEOHelper.GetProductUrl(product.ProductId); // product name hpProductName.Text = product.Name; hpProductName.NavigateUrl = productURL; // view more hlViewMore.NavigateUrl = productURL; #region product price var productVariantCollection = ProductManager.GetProductVariantsByProductId(product.ProductId); if (productVariantCollection.Count > 0) { if (!(productVariantCollection.Count > 1)) { var productVariant = productVariantCollection[0]; if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || (NopContext.Current.User != null && !NopContext.Current.User.IsGuest)) { if (productVariant.CustomerEntersPrice) { lblPrice.Visible = false; } else { decimal oldPriceBase = TaxManager.GetPrice(productVariant, productVariant.OldPrice); decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false)); decimal oldPrice = CurrencyManager.ConvertCurrency(oldPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); decimal finalPriceWithoutDiscount = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (finalPriceWithoutDiscountBase != oldPriceBase && oldPriceBase != decimal.Zero) { lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount, false, false); } else { lblPrice.Text = PriceHelper.FormatPrice(finalPriceWithoutDiscount, false, false); } } } else { lblPrice.Visible = false; } } else { var productVariant = GetVariant(productVariantCollection); if (productVariant != null) { if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") || (NopContext.Current.User != null && !NopContext.Current.User.IsGuest)) { if (productVariant.CustomerEntersPrice) { lblPrice.Visible = false; } else { decimal fromPriceBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false)); decimal fromPrice = CurrencyManager.ConvertCurrency(fromPriceBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice, false, false)); } } else { lblPrice.Visible = false; } } } } else { lblPrice.Visible = false; } #endregion // category var productCategories = CategoryManager.GetProductCategoriesByProductId(product.ProductId); if (productCategories.Count > 0) { var breadCrumb = CategoryManager.GetBreadCrumb(productCategories[0].CategoryId); if (breadCrumb.Count > 0) { rptrCategoryBreadcrumb.DataSource = breadCrumb; rptrCategoryBreadcrumb.DataBind(); } } lblCategory.Text = "";// ProductManager.GetProductReviewByProductId(Product.ProductId); // catalog number LWG.Business.CatalogBiz catalogBiz = new LWG.Business.CatalogBiz(); lwg_Catalog catalog = catalogBiz.GetByID(product.ProductId); hlCatalogNo.Text = Server.HtmlEncode("# - " + catalog.CatalogNumber); hlCatalogNo.NavigateUrl = productURL; } }
protected void BindData() { var product = ProductManager.GetProductById(this.ProductId); if (product != null) { ctrlProductRating.Visible = product.AllowCustomerRatings; //Get product extend information CatalogBiz cService = new CatalogBiz(); lwg_Catalog catalog = cService.GetByID(product.ProductId); lProductName.Text = Server.HtmlEncode(product.Name); lProductName1.Text = Server.HtmlEncode(product.Name); lShortDescription.Text = product.ShortDescription; lFullDescription.Text = product.FullDescription; lTableofContents.Text = catalog.TableofContents; ltrSubtitle.Text = catalog.Subtitle; var productPictures = product.ProductPictures; if (productPictures.Count > 1) { defaultImage.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].PictureId, SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300)); defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); lvProductPictures.DataSource = productPictures; lvProductPictures.DataBind(); } else if (productPictures.Count == 1) { defaultImage.ImageUrl = PictureManager.GetPictureUrl(productPictures[0].PictureId, SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300)); defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); lvProductPictures.Visible = false; } else { defaultImage.ImageUrl = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300)); defaultImage.ToolTip = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.Name); lvProductPictures.Visible = false; } if (catalog != null) { lProductName.Text = catalog.CatalogNumber + " - " + lProductName.Text; //lProductName1.Text = catalog.TitleDisplay; string strCompare = "http://"; AudioBiz audioBiz = new AudioBiz(); //lwg_Audio audio = audioBiz.GetSoundFile(catalog.CatalogId); //if (audio != null) //{ // if (audio.SoundFile.TrimStart().StartsWith(strCompare)) // { // hplListenToTheSample.NavigateUrl = audio.SoundFile; // } // else // { // hplListenToTheSample.NavigateUrl = string.Format("{0}{1}", LWGUtils.GetSoundPath(), audio.SoundFile); // } //} List <lwg_Audio> audioList = audioBiz.GetAllSoundFiles(catalog.CatalogId); if (audioList.Count > 0) { dlListenMusics.DataSource = audioList; dlListenMusics.DataBind(); divListenToTheSample.Attributes.Add("style", "display:block;"); } if (!string.IsNullOrEmpty(catalog.PDF)) { hplPreviewMusic.NavigateUrl = string.Format("{0}{1}", LWGUtils.GetPDFPath(), catalog.PDF); divPreviewMusic.Attributes.Add("style", "display:block;"); } if (catalog.lwg_PersonInRole != null && catalog.lwg_PersonInRole.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (lwg_PersonInRole catComposer in catalog.lwg_PersonInRole.OrderBy(p => p.RoleId)) { if (catComposer.RoleId == LWGUtils.COMPOSER_ROLE_ID) { sb.Insert(0, string.Format("{0} ({1}), ", catComposer.lwg_Person.NameDisplay, catComposer.lwg_Role.Name)); } else { sb.Append(catComposer.lwg_Person.NameDisplay).Append(" (" + catComposer.lwg_Role.Name).Append("), "); } } string composer = sb.ToString(); if (composer.Length > 0) { try { composer = composer.Substring(0, composer.Length - 2); } catch { ; } } ltrComposer.Text = "by " + composer; } else { ltrComposer.Text = string.Empty; } if (product.ProductVariants.Count > 0) { this.ltrPrice.Text = string.Format("{0:c}", product.ProductVariants[0].Price); productVariantRepeater.DataSource = product.ProductVariants.OrderBy(pv => pv.Price); productVariantRepeater.DataBind(); } else { this.ltrPrice.Text = string.Format("{0:c}", "0"); } this.ltrDuration.Text = catalog.Duration; if (catalog.lwg_Instrumental != null) { this.ltrInstrumention.Text = catalog.lwg_Instrumental.LongName; } this.ltrYear.Text = catalog.Year; this.ltrPeriod.Text = string.Empty; List <lwg_PeriodMapping> lstPeriod = new PeriodBiz().GetListPeriodMappingByCatalogID(ProductId); if (lstPeriod != null && lstPeriod.Count > 0) { foreach (lwg_PeriodMapping lwg in lstPeriod) { this.ltrPeriod.Text += lwg.lwg_Period.Name + ", "; } this.ltrPeriod.Text = this.ltrPeriod.Text.Substring(0, this.ltrPeriod.Text.Length - 2); } if (catalog.lwg_CatalogGenre != null && catalog.lwg_CatalogGenre.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (lwg_CatalogGenre catalogGenre in catalog.lwg_CatalogGenre) { sb.Append(catalogGenre.lwg_Genre.Name).Append(", "); } string genre = sb.ToString(); if (genre.Length > 0) { try { genre = genre.Substring(0, genre.Length - 2); } catch { ; } } this.ltrGenre.Text = genre; this.lblGenre.Visible = (genre != ""); // hide when blank field } this.ltrOrigPrint.Text = string.Empty; List <lwg_ReprintSourceMapping> lstReprintSourceMapping = new ReprintSourceBiz().GetListReprintSourceMappingByCatalogID(ProductId); if (lstReprintSourceMapping != null && lstReprintSourceMapping.Count > 0) { foreach (lwg_ReprintSourceMapping lwg in lstReprintSourceMapping) { this.ltrOrigPrint.Text += lwg.lwg_ReprintSource.Name + ", "; } this.ltrOrigPrint.Text = this.ltrOrigPrint.Text.Substring(0, this.ltrOrigPrint.Text.Length - 2); } if (product.ProductCategories != null && product.ProductCategories.Count > 0) { StringBuilder sb = new StringBuilder(); foreach (ProductCategory productCat in product.ProductCategories) { sb.Append(productCat.Category.Name).Append(", "); } string category = sb.ToString(); if (category.Length > 0) { try { category = category.Substring(0, category.Length - 3); } catch { ; } } this.ltrCategory.Text = category; } this.ltrSeries.Text = string.Empty; List <lwg_SeriesMapping> lstSeriesMapping = new SeriesBiz().GetListSeriesMappingByCatalogID(ProductId); if (lstSeriesMapping != null && lstSeriesMapping.Count > 0) { foreach (lwg_SeriesMapping lwg in lstSeriesMapping) { this.ltrSeries.Text += lwg.lwg_Series.Name + ", "; } this.ltrSeries.Text = this.ltrSeries.Text.Substring(0, this.ltrSeries.Text.Length - 2); } this.ltrText.Text = catalog.TextLang; this.lGrade.Text = catalog.Grade; this.ltrCopyrightYear.Text = catalog.CopyrightYear; InitLabels(); // hide if blank field // add Grade Product Info } else { } } else { this.Visible = false; } }
public void SaveCatalogLWG() { Page.Validate("AddEdit"); if (Page.IsValid) { CatalogBiz pBiz = new CatalogBiz(); Product product = ProductManager.GetProductById(ProductId); lwg_Catalog p = pBiz.GetByID(ProductId); if (p == null) { p = new lwg_Catalog(); p.CatalogId = ProductId; lblNote.Text = "Insert error, please try again"; } else { lblNote.Text = "Update error, please try again"; } if (p != null) { // insert data p.CatalogNumber = txtCatalogNumber.Text; p.Duration = txtDuration.Text.TrimStart().TrimEnd(); // "Duration1"; if (!string.IsNullOrEmpty(txtGrade.Text)) { p.Grade = txtGrade.Text; } if (drpInstrumental.Items.Count > 0 && !drpInstrumental.SelectedValue.Equals("-1")) { p.InstrumentalId = int.Parse(drpInstrumental.SelectedValue); } p.KaldbNumber = txtKaldbNumber.Text;// "Kalddbnumber1"; p.pages = txtPages.Text; string tempPDF = string.Empty; string strPDF = SavePDFFile(uploadPDF, ref tempPDF); if (string.IsNullOrEmpty(tempPDF)) { LWGUtils.ClearOldFile(string.Format("{0}{1}", LWGUtils.GetPDFPath(), p.PDF)); p.PDF = strPDF; //TODO: change to uploadfile control } p.PDF = p.PDF == null ? string.Empty : p.PDF; p.Subtitle = txtSubTitle.Text; p.TextLang = txtTextLang.Text; // replace YearTo, YearFrom by Year p.Year = txtYear.Text.Trim(); p.CopyrightYear = txtCopyrightYear.Text.Trim(); p.InstrDetail = txtInstrDetail.Text.TrimStart().TrimEnd(); p.VocAccomp = chkVocAccomp.Checked; p.TableofContents = txtTableofContents.Content; if (string.IsNullOrEmpty(p.SoundIcon)) { p.SoundIcon = string.Empty; } //Save Catalog if (pBiz.SaveCatalog(p)) { // save publisher, genre,... pBiz.SaveCatalogPublisher(p.CatalogId, int.Parse(drpCatalogPublisher.SelectedValue)); if (!string.IsNullOrEmpty(txtCatalogInstrSearch.Text)) { lwg_CatalogInstrumentSearch lwg = new lwg_CatalogInstrumentSearch(); lwg.CatalogId = p.CatalogId; lwg.IntrText = txtCatalogInstrSearch.Text; pBiz.SaveCatalogInstrumentalSearch(lwg); } if (!string.IsNullOrEmpty(txtCatalogNameSearch.Text)) { lwg_CatalogNameSearch lwg = new lwg_CatalogNameSearch(); lwg.CatalogId = p.CatalogId; lwg.Name = txtCatalogNameSearch.Text; pBiz.SaveCatalogNameSearch(lwg); } lblNote.Text = "Save success!"; //ClearData(); } } lblNote.Visible = true; } }