protected void gvAudios_RowDeleting(object sender, GridViewDeleteEventArgs e) { int productAudioId = (int)gvAudios.DataKeys[e.RowIndex]["AudioId"]; AudioBiz audioBiz = new AudioBiz(); lwg_Audio audio = audioBiz.GetAudioById(productAudioId); if (audio != null) { audioBiz.DeleteCatalogAudio(productAudioId); LWGUtils.ClearOldFile(string.Format("{0}{1}", LWGUtils.GetSoundPath(), audio.SoundFile)); BindData(); } }
// update a audio public bool UpdateCatalogAudio(lwg_Audio audio) { lwg_Audio _audio = dbContext.lwg_Audio.Where(v => v.AudioId == audio.AudioId).FirstOrDefault(); if (_audio != null) { _audio.SoundFile = audio.SoundFile; _audio.DisplayOrder = audio.DisplayOrder; _audio.CatalogId = audio.CatalogId; dbContext.SaveChanges(); return(true); } return(false); }
protected void dlListenMusics_ItemDataBound(object sender, DataListItemEventArgs e) { lwg_Audio audio = e.Item.DataItem as lwg_Audio; HyperLink hpListenSampleMusic = e.Item.FindControl("hpListenSampleMusic") as HyperLink; HyperLink hpIconListenSampleMusic = e.Item.FindControl("hpIconListenSampleMusic") as HyperLink; if (audio != null && hpListenSampleMusic != null && hpIconListenSampleMusic != null) { string strCompare = "http://"; if (audio.SoundFile.TrimStart().StartsWith(strCompare)) { hpListenSampleMusic.NavigateUrl = audio.SoundFile; hpIconListenSampleMusic.NavigateUrl = audio.SoundFile; } else { hpListenSampleMusic.NavigateUrl = string.Format("{0}{1}", LWGUtils.GetSoundPath(), audio.SoundFile); hpIconListenSampleMusic.NavigateUrl = string.Format("{0}{1}", LWGUtils.GetSoundPath(), audio.SoundFile); } hpListenSampleMusic.Text = "Listen to the sample " + (e.Item.ItemIndex + 1).ToString(); } }
protected void gvAudios_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "UpdateProductAudio") { int index = Convert.ToInt32(e.CommandArgument); GridViewRow row = gvAudios.Rows[index]; NumericTextBox txtProductVideoDisplayOrder = row.FindControl("txtProductAudioDisplayOrder") as NumericTextBox; HiddenField hfProductAudioId = row.FindControl("hdAudioId") as HiddenField; int displayOrder = txtProductVideoDisplayOrder.Value; int productAudioId = int.Parse(hfProductAudioId.Value); AudioBiz audioBiz = new AudioBiz(); lwg_Audio audio = audioBiz.GetAudioById(productAudioId); if (audio != null) { audio.DisplayOrder = displayOrder; audioBiz.UpdateCatalogAudio(audio); } BindData(); } }
protected void btnUploadProductAudio_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_Audio> audioList = new List <lwg_Audio>(); lwg_Audio audio; string error = string.Empty; string path = SaveSoundFile(fuProductAudio1, ref error); if (string.IsNullOrEmpty(error)) { audio = new lwg_Audio(); audio.CatalogId = this.ProductId; audio.DisplayOrder = txtProductAudioDisplayOrder1.Value; audio.SoundFile = path; audioList.Add(audio); } 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 = SaveSoundFile(fuProductAudio2, ref error); if (string.IsNullOrEmpty(error)) { audio = new lwg_Audio(); audio.CatalogId = this.ProductId; audio.DisplayOrder = txtProductAudioDisplayOrder2.Value; audio.SoundFile = path; audioList.Add(audio); } 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 = SaveSoundFile(fuProductAudio3, ref error); if (string.IsNullOrEmpty(error)) { audio = new lwg_Audio(); audio.CatalogId = this.ProductId; audio.DisplayOrder = txtProductAudioDisplayOrder3.Value; audio.SoundFile = path; audioList.Add(audio); } 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 (audioList.Count > 0) { AudioBiz audioBiz = new AudioBiz(); audioBiz.AddCatalogAudio(audioList); BindData(); } } } catch (Exception exc) { ProcessException(exc); } }