コード例 #1
0
        protected void InitializeProductFile(ProductFile file, bool updateFileName)
        {
            if (updateFileName)
            {
                ProductFile otherFile = null;
                if (_currentMode == Mode.DropDownList)
                {
                    otherFile = MyPage.MTApp.CatalogServices.ProductFiles.Find(FilesDropDownList.SelectedValue);
                    file.Bvin = otherFile.Bvin;
                    file.FileName = otherFile.FileName;
                }
                else if (_currentMode == Mode.FileBrowsed)
                {
                    otherFile = MyPage.MTApp.CatalogServices.ProductFiles.Find(FileIdHiddenField.Value);
                    file.Bvin = otherFile.Bvin;
                    file.FileName = otherFile.FileName;
                }
                else if (_currentMode == Mode.NewUpload)
                {
                    file.FileName = System.IO.Path.GetFileName(NewFileUpload.FileName);
                }
            }
            else
            {
                if (_currentMode == Mode.NewUpload)
                {
                    file.FileName = System.IO.Path.GetFileName(NewFileUpload.FileName);
                }
            }

            if (this.DisplayShortDescription)
            {
                file.ShortDescription = ShortDescriptionTextBox.Text.Trim();
            }

            if (this.ProductId != string.Empty)
            {
                file.ProductId = this.ProductId;
                file.SetMinutes(AvailableForTimespanPicker.Months, AvailableForTimespanPicker.Days, AvailableForTimespanPicker.Hours, AvailableForTimespanPicker.Minutes);
                if (NumberOfDownloadsTextBox.Text.Trim() != string.Empty)
                {
                    file.MaxDownloads = int.Parse(NumberOfDownloadsTextBox.Text);
                }
                else
                {
                    file.MaxDownloads = 0;
                }
            }
        }