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 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); } }
protected void btnAddPeopleRoleCatalog_Click(object sender, EventArgs e) { PersonBiz pBiz = new PersonBiz(); lwg_PersonInRole lg = new lwg_PersonInRole(); CatalogBiz cBiz = new CatalogBiz(); if (cBiz.GetByID(ProductId) != null) { if (ddlPeople.Items.Count > 0) { lg.CatalogId = ProductId; lg.PersonId = int.Parse(ddlPeople.SelectedValue); lg.RoleId = int.Parse(ddlRole.SelectedValue); if (pBiz.SavePersonInRole(lg)) { BindingCatalogRole(); } } ltrMessageNote.Visible = false; } else { ltrMessageNote.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); } }
private void BindData() { CatalogBiz cService = new CatalogBiz(); List <lwg_Catalog> lstCatalog = cService.GetRecentCatalog(this.Number); if (lstCatalog.Count > 0) { this.dlRecentProduct.DataSource = lstCatalog; this.dlRecentProduct.DataBind(); } }
protected void btnAddGenre_Click(object sender, EventArgs e) { CatalogBiz pBiz = new CatalogBiz(); if (drpCatalogGenre.Items.Count > 0) { if (pBiz.SaveCatalogGenre(ProductId, int.Parse(drpCatalogGenre.SelectedValue))) { BindingGenre(); } } }
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 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(); } } }
protected void dlGenre_Bound(object sender, DataListItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { lwg_Genre obj = (lwg_Genre)e.Item.DataItem; Label lbl = (Label)e.Item.FindControl("lblNumber"); lbl.Text = (e.Item.ItemIndex + 1).ToString(); lbl = (Label)e.Item.FindControl("lblName"); lbl.Text = obj.Name; CatalogBiz cService = new CatalogBiz(); lbl = (Label)e.Item.FindControl("lblProductNumber"); lbl.Text = cService.GetTotalCatalogOfGenre(obj.GerneId).ToString(); } }
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 string SavePictureIcon(FileUpload fileupload) { Picture pic = null; lwg_Catalog lwg = new CatalogBiz().GetByID(ProductId); if (lwg != null) { if (!string.IsNullOrEmpty(lwg.SoundIcon)) { pic = PictureManager.GetPictureById(int.Parse(lwg.SoundIcon)); } } HttpPostedFile PictureFile = fileupload.PostedFile; if ((PictureFile != null) && (!String.IsNullOrEmpty(PictureFile.FileName))) { byte[] pictureBinary = PictureManager.GetPictureBits(PictureFile.InputStream, PictureFile.ContentLength); if (pic != null) { pic = PictureManager.UpdatePicture(pic.PictureId, pictureBinary, PictureFile.ContentType, true); } else { pic = PictureManager.InsertPicture(pictureBinary, PictureFile.ContentType, true); } } int PictureId = 0; if (pic != null) { PictureId = pic.PictureId; //\ string pictureUrl = PictureManager.GetPictureUrl(pic, 100); imgSoundIcon.Visible = true; imgSoundIcon.ImageUrl = pictureUrl; } return(PictureId.ToString()); }
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 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; } }
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); } }
public static string GetCatalogUrl(int catalogId) { var catalog = new CatalogBiz().GetByID(catalogId); return(GetCatalogUrl(catalog)); }
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 SyncProductCatalog() { // open the file "data.csv" which is a CSV file with headers using (CsvReader csv = new CsvReader(new StreamReader(@"D:\\LudwigMasters04072011.csv"), true)) { int fieldCount = csv.FieldCount; string[] headers = csv.GetFieldHeaders(); CatalogBiz cBiz = new CatalogBiz(); int count = 0; int catalogID = 0; string catNo = string.Empty; while (csv.ReadNextRecord()) { try { catalogID = 0; catNo = string.Empty; for (int i = 0; i < fieldCount; i++) { //Console.Write(string.Format("{0} = {1};", headers[i], csv[i])); if (headers[i].Equals("CategoryID")) { int.TryParse(csv[i], out catalogID); } if (headers[i].Equals("Catno")) { catNo = csv[i]; } } //Console.WriteLine(); List <lwg_Catalog> lst = cBiz.GetListLWGCatalog(catNo); LWGLog.WriteLog("catNo: " + catNo + " product Count: " + lst.Count, " updating ... "); if (lst != null && lst.Count > 0) { foreach (lwg_Catalog item in lst) { if (catalogID > 0) { Product product = ProductManager.GetProductById(item.CatalogId); if (product != null) { ProductCategoryCollection existingProductCategoryCollection = product.ProductCategories; LWGLog.WriteLog("productID: " + product.ProductId + " productCatagoryCollection: " + existingProductCategoryCollection.Count, " updating ... "); if (existingProductCategoryCollection != null && existingProductCategoryCollection.Count > 0) { //CategoryManager.InsertProductCategory(item.CatalogId, catalogID, false, 1); foreach (ProductCategory pc in existingProductCategoryCollection) { if (pc.CategoryId == 74) { CategoryManager.UpdateProductCategory(pc.ProductCategoryId, pc.ProductId, catalogID, pc.IsFeaturedProduct, pc.DisplayOrder); count++; LWGLog.WriteLog("Sync Product to catalog Count: " + count + " productID: " + pc.ProductId + " catagoryID: " + catalogID, " updating ... "); } } } } } } } } catch (Exception ex) { LWGLog.WriteLog("Sync Product to catalog Error: " + catNo + " ", ex.Message); } } LWGLog.WriteLog("Sync Product to catalog Count: " + count + " ", " OK "); } }