コード例 #1
0
 private string SavePDFFile(FileUpload fileupload, ref string strErr)
 {
     strErr = string.Empty;
     if (fileupload.HasFile)
     {
         try
         {
             string temp = LWGUtils.SavePDFFile(fileupload, LWGUtils.GetPDFPath(), ref strErr);
             if (string.IsNullOrEmpty(strErr))
             {
                 return(temp);
             }
         }
         catch (Exception ex)
         {
             //TODO: uploadfile error
             return(string.Empty);
         }
     }
     else
     {
         strErr = LWGUtils.NO_FILE;
     }
     return(string.Empty);
 }
コード例 #2
0
        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();
                }
            }
        }
コード例 #3
0
        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;
            }
        }
コード例 #4
0
        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;
            }
        }