Exemplo n.º 1
0
        static void Main(string[] args)
        {
            PictureManager pictureManager = new PictureManager(Config.Load());
            DiashowForm form = new DiashowForm();
            pictureManager.PictureChanged += form.ShowImage;
            form.NextPicture += () => { pictureManager.SwitchToNextPicture(); };
            form.ToggleRunning += pictureManager.ToggleRunning;

            form.ShowDialog();
        }
Exemplo n.º 2
0
        static PassagewayRail()
        {
            Point offset = new Point(0, 16);
            Size  sz     = new Size(32, 32);

            sprites = new ISprite[14];
            Picture bmp = PictureManager.get("{3197A63A-89DC-4237-8C9B-045F41F31CDB}");

            for (int i = 0; i < 4; i++)
            {
                sprites[i * 3]     = new SimpleSprite(bmp, offset, new Point(i * 32, 8), sz);
                sprites[i * 3 + 1] = new SimpleSprite(bmp, offset, new Point((i * 2 + 1) * 32, 40), sz);
                sprites[i * 3 + 2] = new SimpleSprite(bmp, offset, new Point((i * 2 + 2) * 32, 40), sz);
            }
            sprites[12] = new SimpleSprite(bmp, offset, new Point(4 * 32, 8), sz);
            sprites[13] = new SimpleSprite(bmp, offset, new Point(5 * 32, 8), sz);

            stairSprites = new ISprite[32];

            // NORTH
            stairSprites[0] = new SimpleSprite(bmp, new Point(+6, 16), new Point(16 - 6, 80), sz);
            stairSprites[1] = new SimpleSprite(bmp, new Point(+6, 16), new Point(48 - 6, 80), sz);
            stairSprites[2] = stairSprites[0];  // can reuse the same sprites
            stairSprites[3] = stairSprites[1];

            stairSprites[4] = new SimpleSprite(bmp, offset, new Point(0, 120), sz);
            stairSprites[5] = new SimpleSprite(bmp, offset, new Point(32, 120), sz);
            stairSprites[6] = stairSprites[4];  // can reuse the same sprites
            stairSprites[7] = stairSprites[5];

            // EAST
            stairSprites[8]  = new SimpleSprite(bmp, new Point(0, 20), new Point(80, 80 - 4), new Size(32, 36));
            stairSprites[9]  = new SimpleSprite(bmp, new Point(0, 20), new Point(112, 80 - 4), new Size(32, 36));
            stairSprites[10] = new SimpleSprite(bmp, new Point(0, 20), new Point(192, 8 - 4), new Size(32, 36));
            stairSprites[11] = new SimpleSprite(bmp, new Point(0, 20), new Point(224, 8 - 4), new Size(32, 36));

            stairSprites[12] = new SimpleSprite(bmp, new Point(+6, 16), new Point(96 - 6, 120), sz);
            stairSprites[13] = new SimpleSprite(bmp, new Point(+6, 16), new Point(128 - 6, 120), sz);
            stairSprites[14] = stairSprites[12];        // can reuse the same sprites
            stairSprites[15] = stairSprites[13];

            // SOUTH
            stairSprites[16] = new SimpleSprite(bmp, new Point(-6, 16), new Point(160 + 6, 120), sz);
            stairSprites[17] = new SimpleSprite(bmp, new Point(-6, 16), new Point(192 + 6, 120), sz);
            stairSprites[18] = stairSprites[16];        // can reuse the same sprites
            stairSprites[19] = stairSprites[17];

            stairSprites[20] = new SimpleSprite(bmp, new Point(0, 20), new Point(176, 80 - 4), new Size(32, 36));
            stairSprites[21] = new SimpleSprite(bmp, new Point(0, 20), new Point(208, 80 - 4), new Size(32, 36));
            stairSprites[22] = new SimpleSprite(bmp, new Point(0, 20), new Point(256, 8 - 4), new Size(32, 36));
            stairSprites[23] = new SimpleSprite(bmp, new Point(0, 20), new Point(388, 8 - 4), new Size(32, 36));

            // WEST
            stairSprites[24] = new SimpleSprite(bmp, offset, new Point(256, 120), sz);
            stairSprites[25] = new SimpleSprite(bmp, offset, new Point(288, 120), sz);
            stairSprites[26] = stairSprites[24];        // can reuse the same sprites
            stairSprites[27] = stairSprites[25];

            stairSprites[28] = new SimpleSprite(bmp, new Point(-6, 16), new Point(240 + 6, 80), sz);
            stairSprites[29] = new SimpleSprite(bmp, new Point(-6, 16), new Point(272 + 6, 80), sz);
            stairSprites[30] = stairSprites[28];
            stairSprites[31] = stairSprites[29];
        }
Exemplo n.º 3
0
        private void BindData()
        {
            if (product != null)
            {
                string productURL = SEOHelper.GetProductUrl(product);

                hlProduct.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;
                        }
                    }
                    else
                    {
                        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);
                                    lblPrice.Text = String.Format(GetLocaleResourceString("Products.PriceRangeFromText"), PriceHelper.FormatPrice(fromPrice));
                                }
                            }
                            else
                            {
                                lblOldPrice.Visible  = false;
                                lblPrice.Visible     = false;
                                btnAddToCart.Visible = false;
                            }
                        }

                        btnAddToCart.Visible = false;
                    }
                }
                else
                {
                    lblOldPrice.Visible  = false;
                    lblPrice.Visible     = false;
                    btnAddToCart.Visible = false;
                }
            }
        }
Exemplo n.º 4
0
        private void BindData()
        {
            ProductVariant productVariant = ProductManager.GetProductVariantById(this.ProductVariantId, 0);

            if (this.HasLocalizableContent)
            {
                var languages = this.GetLocalizableLanguagesSupported();
                rptrLanguageTabs.DataSource = languages;
                rptrLanguageTabs.DataBind();
                rptrLanguageDivs.DataSource = languages;
                rptrLanguageDivs.DataBind();
            }

            if (productVariant != null)
            {
                this.pnlProductVariantId.Visible = true;
                this.lblProductVariantId.Text    = productVariant.ProductVariantId.ToString();


                this.txtName.Text                   = productVariant.Name;
                this.txtSKU.Text                    = productVariant.SKU;
                this.txtDescription.Content         = productVariant.Description;
                this.txtAdminComment.Text           = productVariant.AdminComment;
                this.txtManufacturerPartNumber.Text = productVariant.ManufacturerPartNumber;

                //gift card
                this.cbIsGiftCard.Checked = productVariant.IsGiftCard;

                //downloable products
                this.cbIsDownload.Checked = productVariant.IsDownload;
                Download productVariantDownload = productVariant.Download;
                if (productVariantDownload != null)
                {
                    this.cbUseDownloadURL.Checked = productVariantDownload.UseDownloadUrl;
                    this.txtDownloadURL.Text      = productVariantDownload.DownloadUrl;

                    if (productVariantDownload.DownloadBinary != null)
                    {
                        btnRemoveProductVariantDownload.Visible = true;
                        hlProductVariantDownload.Visible        = true;
                        string adminDownloadUrl = DownloadManager.GetAdminDownloadUrl(productVariantDownload);
                        hlProductVariantDownload.NavigateUrl = adminDownloadUrl;
                    }
                    else
                    {
                        btnRemoveProductVariantDownload.Visible = false;
                        hlProductVariantDownload.Visible        = false;
                    }
                }
                else
                {
                    btnRemoveProductVariantDownload.Visible = false;
                    hlProductVariantDownload.Visible        = false;
                }

                this.cbUnlimitedDownloads.Checked  = productVariant.UnlimitedDownloads;
                this.txtMaxNumberOfDownloads.Value = productVariant.MaxNumberOfDownloads;
                if (productVariant.DownloadExpirationDays.HasValue)
                {
                    this.txtDownloadExpirationDays.Text = productVariant.DownloadExpirationDays.Value.ToString();
                }
                CommonHelper.SelectListItem(this.ddlDownloadActivationType, productVariant.DownloadActivationType);
                this.cbHasUserAgreement.Checked = productVariant.HasUserAgreement;
                if (productVariant.HasUserAgreement)
                {
                    this.txtUserAgreementText.Content = productVariant.UserAgreementText;
                }

                this.cbHasSampleDownload.Checked = productVariant.HasSampleDownload;
                Download productVariantSampleDownload = productVariant.SampleDownload;
                if (productVariantSampleDownload != null)
                {
                    this.cbUseSampleDownloadURL.Checked = productVariantSampleDownload.UseDownloadUrl;
                    this.txtSampleDownloadURL.Text      = productVariantSampleDownload.DownloadUrl;

                    if (productVariantSampleDownload.DownloadBinary != null)
                    {
                        btnRemoveProductVariantSampleDownload.Visible = true;
                        hlProductVariantSampleDownload.Visible        = true;
                        string adminSampleDownloadUrl = DownloadManager.GetAdminDownloadUrl(productVariantSampleDownload);
                        hlProductVariantSampleDownload.NavigateUrl = adminSampleDownloadUrl;
                    }
                    else
                    {
                        btnRemoveProductVariantSampleDownload.Visible = false;
                        hlProductVariantSampleDownload.Visible        = false;
                    }
                }
                else
                {
                    btnRemoveProductVariantSampleDownload.Visible = false;
                    hlProductVariantSampleDownload.Visible        = false;
                }

                //recurring
                this.cbIsRecurring.Checked = productVariant.IsRecurring;
                this.txtCycleLength.Value  = productVariant.CycleLength;
                CommonHelper.SelectListItem(this.ddlCyclePeriod, productVariant.CyclePeriod);
                this.txtTotalCycles.Value = productVariant.TotalCycles;

                //shipping
                this.cbIsShipEnabled.Checked           = productVariant.IsShipEnabled;
                this.cbIsFreeShipping.Checked          = productVariant.IsFreeShipping;
                this.txtAdditionalShippingCharge.Value = productVariant.AdditionalShippingCharge;

                //tax
                this.cbIsTaxExempt.Checked = productVariant.IsTaxExempt;
                CommonHelper.SelectListItem(this.ddlTaxCategory, productVariant.TaxCategoryId);

                //stock management
                CommonHelper.SelectListItem(this.ddlManageStock, productVariant.ManageInventory);
                this.txtStockQuantity.Value             = productVariant.StockQuantity;
                this.cbDisplayStockAvailability.Checked = productVariant.DisplayStockAvailability;
                this.txtMinStockQuantity.Value          = productVariant.MinStockQuantity;
                CommonHelper.SelectListItem(this.ddlLowStockActivity, productVariant.LowStockActivityId);
                this.txtNotifyForQuantityBelow.Value = productVariant.NotifyAdminForQuantityBelow;
                this.cbAllowOutOfStockOrders.Checked = productVariant.AllowOutOfStockOrders;
                this.txtOrderMinimumQuantity.Value   = productVariant.OrderMinimumQuantity;
                this.txtOrderMaximumQuantity.Value   = productVariant.OrderMaximumQuantity;

                //other settings
                CommonHelper.SelectListItem(this.ddlWarehouse, productVariant.WarehouseId);
                this.cbDisableBuyButton.Checked           = productVariant.DisableBuyButton;
                this.txtPrice.Value                       = productVariant.Price;
                this.txtOldPrice.Value                    = productVariant.OldPrice;
                this.txtProductCost.Value                 = productVariant.ProductCost;
                this.cbCustomerEntersPrice.Checked        = productVariant.CustomerEntersPrice;
                this.txtMinimumCustomerEnteredPrice.Value = (int)productVariant.MinimumCustomerEnteredPrice;
                this.txtMaximumCustomerEnteredPrice.Value = (int)productVariant.MaximumCustomerEnteredPrice;

                this.txtWeight.Value = productVariant.Weight;
                this.txtLength.Value = productVariant.Length;
                this.txtWidth.Value  = productVariant.Width;
                this.txtHeight.Value = productVariant.Height;

                Picture productVariantPicture = productVariant.Picture;
                btnRemoveProductVariantImage.Visible = productVariantPicture != null;
                string pictureUrl = PictureManager.GetPictureUrl(productVariantPicture, 100);
                this.iProductVariantPicture.Visible  = true;
                this.iProductVariantPicture.ImageUrl = pictureUrl;

                if (productVariant.AvailableStartDateTime.HasValue)
                {
                    this.ctrlAvailableStartDateTimePicker.SelectedDate = productVariant.AvailableStartDateTime.Value;
                }
                if (productVariant.AvailableEndDateTime.HasValue)
                {
                    this.ctrlAvailableEndDateTimePicker.SelectedDate = productVariant.AvailableEndDateTime.Value;
                }

                this.cbPublished.Checked   = productVariant.Published;
                this.txtDisplayOrder.Value = productVariant.DisplayOrder;
            }
            else
            {
                this.pnlProductVariantId.Visible = false;

                this.btnRemoveProductVariantImage.Visible = false;
                this.iProductVariantPicture.Visible       = false;

                btnRemoveProductVariantDownload.Visible = false;
                hlProductVariantDownload.Visible        = false;

                btnRemoveProductVariantSampleDownload.Visible = false;
                hlProductVariantSampleDownload.Visible        = false;
            }
        }
Exemplo n.º 5
0
        public ProductVariant SaveInfo()
        {
            DateTime nowDT = DateTime.Now;

            string name                   = txtName.Text.Trim();
            string sku                    = txtSKU.Text.Trim();
            string description            = txtDescription.Content;
            string adminComment           = txtAdminComment.Text.Trim();
            string manufacturerPartNumber = txtManufacturerPartNumber.Text.Trim();
            bool   isGiftCard             = cbIsGiftCard.Checked;
            bool   AllowYandexMarket      = true;
            bool   isDownload             = cbIsDownload.Checked;
            bool   unlimitedDownloads     = cbUnlimitedDownloads.Checked;
            int    maxNumberOfDownloads   = txtMaxNumberOfDownloads.Value;
            int?   downloadExpirationDays = null;

            if (!String.IsNullOrEmpty(txtDownloadExpirationDays.Text.Trim()))
            {
                downloadExpirationDays = int.Parse(txtDownloadExpirationDays.Text.Trim());
            }
            DownloadActivationTypeEnum downloadActivationType = (DownloadActivationTypeEnum)Enum.ToObject(typeof(DownloadActivationTypeEnum), int.Parse(this.ddlDownloadActivationType.SelectedItem.Value));
            bool   hasUserAgreement  = cbHasUserAgreement.Checked;
            string userAgreementText = txtUserAgreementText.Content;
            bool   hasSampleDownload = cbHasSampleDownload.Checked;

            bool isRecurring = cbIsRecurring.Checked;
            int  cycleLength = txtCycleLength.Value;
            RecurringProductCyclePeriodEnum cyclePeriod = (RecurringProductCyclePeriodEnum)Enum.ToObject(typeof(RecurringProductCyclePeriodEnum), int.Parse(this.ddlCyclePeriod.SelectedItem.Value));
            int totalCycles = txtTotalCycles.Value;

            bool    isShipEnabled            = cbIsShipEnabled.Checked;
            bool    isFreeShipping           = cbIsFreeShipping.Checked;
            decimal additionalShippingCharge = txtAdditionalShippingCharge.Value;
            bool    isTaxExempt                   = cbIsTaxExempt.Checked;
            int     taxCategoryId                 = int.Parse(this.ddlTaxCategory.SelectedItem.Value);
            int     manageStock                   = Convert.ToInt32(ddlManageStock.SelectedValue);
            int     stockQuantity                 = txtStockQuantity.Value;
            bool    displayStockAvailability      = cbDisplayStockAvailability.Checked;
            int     minStockQuantity              = txtMinStockQuantity.Value;
            LowStockActivityEnum lowStockActivity = (LowStockActivityEnum)Enum.ToObject(typeof(LowStockActivityEnum), int.Parse(this.ddlLowStockActivity.SelectedItem.Value));
            int      notifyForQuantityBelow       = txtNotifyForQuantityBelow.Value;
            bool     allowOutOfStockOrders        = cbAllowOutOfStockOrders.Checked;
            int      orderMinimumQuantity         = txtOrderMinimumQuantity.Value;
            int      orderMaximumQuantity         = txtOrderMaximumQuantity.Value;
            int      warehouseId                  = int.Parse(this.ddlWarehouse.SelectedItem.Value);
            bool     disableBuyButton             = cbDisableBuyButton.Checked;
            decimal  price                       = txtPrice.Value;
            decimal  oldPrice                    = txtOldPrice.Value;
            decimal  productCost                 = txtProductCost.Value;
            bool     customerEntersPrice         = cbCustomerEntersPrice.Checked;
            decimal  minimumCustomerEnteredPrice = txtMinimumCustomerEnteredPrice.Value;
            decimal  maximumCustomerEnteredPrice = txtMaximumCustomerEnteredPrice.Value;
            decimal  weight                      = txtWeight.Value;
            decimal  length                      = txtLength.Value;
            decimal  width                       = txtWidth.Value;
            decimal  height                      = txtHeight.Value;
            DateTime?availableStartDateTime      = ctrlAvailableStartDateTimePicker.SelectedDate;
            DateTime?availableEndDateTime        = ctrlAvailableEndDateTimePicker.SelectedDate;

            if (availableStartDateTime.HasValue)
            {
                availableStartDateTime = DateTime.SpecifyKind(availableStartDateTime.Value, DateTimeKind.Utc);
            }
            if (availableEndDateTime.HasValue)
            {
                availableEndDateTime = DateTime.SpecifyKind(availableEndDateTime.Value, DateTimeKind.Utc);
            }
            bool published    = cbPublished.Checked;
            int  displayOrder = txtDisplayOrder.Value;

            ProductVariant productVariant = ProductManager.GetProductVariantById(ProductVariantId, 0);

            if (productVariant != null)
            {
                #region Update
                Picture        productVariantPicture     = productVariant.Picture;
                HttpPostedFile productVariantPictureFile = fuProductVariantPicture.PostedFile;
                if ((productVariantPictureFile != null) && (!String.IsNullOrEmpty(productVariantPictureFile.FileName)))
                {
                    byte[] productVariantPictureBinary = PictureManager.GetPictureBits(productVariantPictureFile.InputStream, productVariantPictureFile.ContentLength);
                    if (productVariantPicture != null)
                    {
                        productVariantPicture = PictureManager.UpdatePicture(productVariantPicture.PictureId, productVariantPictureBinary, productVariantPictureFile.ContentType, true);
                    }
                    else
                    {
                        productVariantPicture = PictureManager.InsertPicture(productVariantPictureBinary, productVariantPictureFile.ContentType, true);
                    }
                }
                int productVariantPictureId = 0;
                if (productVariantPicture != null)
                {
                    productVariantPictureId = productVariantPicture.PictureId;
                }

                int productVariantDownloadId = 0;
                if (isDownload)
                {
                    Download productVariantDownload       = productVariant.Download;
                    bool     useDownloadURL               = cbUseDownloadURL.Checked;
                    string   downloadURL                  = txtDownloadURL.Text.Trim();
                    byte[]   productVariantDownloadBinary = null;
                    string   downloadContentType          = string.Empty;
                    string   downloadFilename             = string.Empty;
                    string   downloadExtension            = string.Empty;
                    if (productVariantDownload != null)
                    {
                        productVariantDownloadBinary = productVariantDownload.DownloadBinary;
                        downloadContentType          = productVariantDownload.ContentType;
                        downloadFilename             = productVariantDownload.Filename;
                        downloadExtension            = productVariantDownload.Extension;
                    }

                    HttpPostedFile productVariantDownloadFile = fuProductVariantDownload.PostedFile;
                    if ((productVariantDownloadFile != null) && (!String.IsNullOrEmpty(productVariantDownloadFile.FileName)))
                    {
                        productVariantDownloadBinary = DownloadManager.GetDownloadBits(productVariantDownloadFile.InputStream, productVariantDownloadFile.ContentLength);
                        downloadContentType          = productVariantDownloadFile.ContentType;
                        downloadFilename             = Path.GetFileNameWithoutExtension(productVariantDownloadFile.FileName);
                        downloadExtension            = Path.GetExtension(productVariantDownloadFile.FileName);
                    }

                    if (productVariantDownload != null)
                    {
                        productVariantDownload = DownloadManager.UpdateDownload(productVariantDownload.DownloadId,
                                                                                useDownloadURL, downloadURL, productVariantDownloadBinary,
                                                                                downloadContentType, downloadFilename, downloadExtension, true);
                    }
                    else
                    {
                        productVariantDownload = DownloadManager.InsertDownload(useDownloadURL,
                                                                                downloadURL, productVariantDownloadBinary, downloadContentType,
                                                                                downloadFilename, downloadExtension, true);
                    }

                    productVariantDownloadId = productVariantDownload.DownloadId;
                }

                int productVariantSampleDownloadId = 0;
                if (hasSampleDownload)
                {
                    Download productVariantSampleDownload       = productVariant.SampleDownload;
                    bool     useSampleDownloadURL               = cbUseSampleDownloadURL.Checked;
                    string   sampleDownloadURL                  = txtSampleDownloadURL.Text.Trim();
                    byte[]   productVariantSampleDownloadBinary = null;
                    string   sampleDownloadContentType          = string.Empty;
                    string   sampleDownloadFilename             = string.Empty;
                    string   sampleDownloadExtension            = string.Empty;
                    if (productVariantSampleDownload != null)
                    {
                        productVariantSampleDownloadBinary = productVariantSampleDownload.DownloadBinary;
                        sampleDownloadContentType          = productVariantSampleDownload.ContentType;
                        sampleDownloadFilename             = productVariantSampleDownload.Filename;
                        sampleDownloadExtension            = productVariantSampleDownload.Extension;
                    }

                    HttpPostedFile productVariantSampleDownloadFile = fuProductVariantSampleDownload.PostedFile;
                    if ((productVariantSampleDownloadFile != null) && (!String.IsNullOrEmpty(productVariantSampleDownloadFile.FileName)))
                    {
                        productVariantSampleDownloadBinary = DownloadManager.GetDownloadBits(productVariantSampleDownloadFile.InputStream, productVariantSampleDownloadFile.ContentLength);
                        sampleDownloadContentType          = productVariantSampleDownloadFile.ContentType;
                        sampleDownloadFilename             = Path.GetFileNameWithoutExtension(productVariantSampleDownloadFile.FileName);
                        sampleDownloadExtension            = Path.GetExtension(productVariantSampleDownloadFile.FileName);
                    }

                    if (productVariantSampleDownload != null)
                    {
                        productVariantSampleDownload = DownloadManager.UpdateDownload(productVariantSampleDownload.DownloadId,
                                                                                      useSampleDownloadURL, sampleDownloadURL, productVariantSampleDownloadBinary,
                                                                                      sampleDownloadContentType, sampleDownloadFilename, sampleDownloadExtension, true);
                    }
                    else
                    {
                        productVariantSampleDownload = DownloadManager.InsertDownload(useSampleDownloadURL,
                                                                                      sampleDownloadURL, productVariantSampleDownloadBinary,
                                                                                      sampleDownloadContentType, sampleDownloadFilename, sampleDownloadExtension, true);
                    }

                    productVariantSampleDownloadId = productVariantSampleDownload.DownloadId;
                }

                productVariant = ProductManager.UpdateProductVariant(ProductVariantId,
                                                                     productVariant.ProductId, name, sku, description, adminComment, manufacturerPartNumber,
                                                                     isGiftCard, AllowYandexMarket, isDownload, productVariantDownloadId, unlimitedDownloads,
                                                                     maxNumberOfDownloads, downloadExpirationDays, downloadActivationType,
                                                                     hasSampleDownload, productVariantSampleDownloadId, hasUserAgreement, userAgreementText,
                                                                     isRecurring, cycleLength, (int)cyclePeriod, totalCycles,
                                                                     isShipEnabled, isFreeShipping, additionalShippingCharge,
                                                                     isTaxExempt, taxCategoryId, manageStock, stockQuantity, displayStockAvailability,
                                                                     minStockQuantity, lowStockActivity, notifyForQuantityBelow,
                                                                     allowOutOfStockOrders, orderMinimumQuantity, orderMaximumQuantity,
                                                                     warehouseId, disableBuyButton, price,
                                                                     oldPrice, productCost, customerEntersPrice,
                                                                     minimumCustomerEnteredPrice, maximumCustomerEnteredPrice,
                                                                     weight, length, width, height, productVariantPictureId,
                                                                     availableStartDateTime, availableEndDateTime, published,
                                                                     productVariant.Deleted, displayOrder, productVariant.CreatedOn, nowDT);
                #endregion
            }
            else
            {
                #region Insert
                Product product = ProductManager.GetProductById(this.ProductId);
                if (product != null)
                {
                    Picture        productVariantPicture     = null;
                    HttpPostedFile productVariantPictureFile = fuProductVariantPicture.PostedFile;
                    if ((productVariantPictureFile != null) && (!String.IsNullOrEmpty(productVariantPictureFile.FileName)))
                    {
                        byte[] productVariantPictureBinary = PictureManager.GetPictureBits(productVariantPictureFile.InputStream, productVariantPictureFile.ContentLength);
                        productVariantPicture = PictureManager.InsertPicture(productVariantPictureBinary, productVariantPictureFile.ContentType, true);
                    }
                    int productVariantPictureId = 0;
                    if (productVariantPicture != null)
                    {
                        productVariantPictureId = productVariantPicture.PictureId;
                    }

                    int productVariantDownloadId = 0;
                    if (isDownload)
                    {
                        bool   useDownloadURL = cbUseDownloadURL.Checked;
                        string downloadURL    = txtDownloadURL.Text.Trim();
                        byte[] productVariantDownloadBinary = null;
                        string downloadContentType          = string.Empty;
                        string downloadFilename             = string.Empty;
                        string downloadExtension            = string.Empty;

                        HttpPostedFile productVariantDownloadFile = fuProductVariantDownload.PostedFile;
                        if ((productVariantDownloadFile != null) && (!String.IsNullOrEmpty(productVariantDownloadFile.FileName)))
                        {
                            productVariantDownloadBinary = DownloadManager.GetDownloadBits(productVariantDownloadFile.InputStream, productVariantDownloadFile.ContentLength);
                            downloadContentType          = productVariantDownloadFile.ContentType;
                            downloadFilename             = Path.GetFileNameWithoutExtension(productVariantDownloadFile.FileName);
                            downloadExtension            = Path.GetExtension(productVariantDownloadFile.FileName);
                        }

                        Download productVariantDownload = DownloadManager.InsertDownload(useDownloadURL, downloadURL,
                                                                                         productVariantDownloadBinary, downloadContentType,
                                                                                         downloadFilename, downloadExtension, true);
                        productVariantDownloadId = productVariantDownload.DownloadId;
                    }

                    int productVariantSampleDownloadId = 0;
                    if (hasSampleDownload)
                    {
                        bool   useSampleDownloadURL = cbUseSampleDownloadURL.Checked;
                        string sampleDownloadURL    = txtSampleDownloadURL.Text.Trim();
                        byte[] productVariantSampleDownloadBinary = null;
                        string sampleDownloadContentType          = string.Empty;
                        string sampleDownloadFilename             = string.Empty;
                        string sampleDownloadExtension            = string.Empty;

                        HttpPostedFile productVariantSampleDownloadFile = fuProductVariantSampleDownload.PostedFile;
                        if ((productVariantSampleDownloadFile != null) && (!String.IsNullOrEmpty(productVariantSampleDownloadFile.FileName)))
                        {
                            productVariantSampleDownloadBinary = DownloadManager.GetDownloadBits(productVariantSampleDownloadFile.InputStream, productVariantSampleDownloadFile.ContentLength);
                            sampleDownloadContentType          = productVariantSampleDownloadFile.ContentType;
                            sampleDownloadFilename             = Path.GetFileNameWithoutExtension(productVariantSampleDownloadFile.FileName);
                            sampleDownloadExtension            = Path.GetExtension(productVariantSampleDownloadFile.FileName);
                        }

                        Download productVariantSampleDownload = DownloadManager.InsertDownload(useSampleDownloadURL,
                                                                                               sampleDownloadURL, productVariantSampleDownloadBinary,
                                                                                               sampleDownloadContentType, sampleDownloadFilename, sampleDownloadExtension, true);
                        productVariantSampleDownloadId = productVariantSampleDownload.DownloadId;
                    }

                    productVariant = ProductManager.InsertProductVariant(product.ProductId,
                                                                         name, sku, description, adminComment, manufacturerPartNumber,
                                                                         isGiftCard, AllowYandexMarket, isDownload, productVariantDownloadId, unlimitedDownloads,
                                                                         maxNumberOfDownloads, downloadExpirationDays, downloadActivationType,
                                                                         hasSampleDownload, productVariantSampleDownloadId,
                                                                         hasUserAgreement, userAgreementText,
                                                                         isRecurring, cycleLength, (int)cyclePeriod, totalCycles,
                                                                         isShipEnabled, isFreeShipping, additionalShippingCharge, isTaxExempt, taxCategoryId,
                                                                         manageStock, stockQuantity, displayStockAvailability,
                                                                         minStockQuantity, lowStockActivity, notifyForQuantityBelow,
                                                                         allowOutOfStockOrders, orderMinimumQuantity, orderMaximumQuantity,
                                                                         warehouseId, disableBuyButton, price, oldPrice, productCost,
                                                                         customerEntersPrice, minimumCustomerEnteredPrice, maximumCustomerEnteredPrice,
                                                                         weight, length, width, height, productVariantPictureId,
                                                                         availableStartDateTime, availableEndDateTime, published,
                                                                         false, displayOrder, nowDT, nowDT);
                }
                else
                {
                    Response.Redirect("Products.aspx");
                }
                #endregion
            }

            SaveLocalizableContent(productVariant);

            return(productVariant);
        }
Exemplo n.º 6
0
        public void BindData()
        {
            if (newsComment != null)
            {
                lblCreatedOn.Text     = DateTimeHelper.ConvertToUserTime(newsComment.CreatedOn, DateTimeKind.Utc).ToString("g");
                lblTitle.Text         = Server.HtmlEncode(newsComment.Title);
                lblComment.Text       = NewsManager.FormatCommentText(newsComment.Comment);
                lblNewsCommentId.Text = newsComment.NewsCommentId.ToString();

                var customer = newsComment.Customer;
                if (customer != null)
                {
                    if (CustomerManager.AllowViewingProfiles)
                    {
                        hlUser.Text        = Server.HtmlEncode(CustomerManager.FormatUserName(customer, true));
                        hlUser.NavigateUrl = SEOHelper.GetUserProfileUrl(customer.CustomerId);
                        lblUser.Visible    = false;
                    }
                    else
                    {
                        lblUser.Text   = Server.HtmlEncode(CustomerManager.FormatUserName(customer, true));
                        hlUser.Visible = false;
                    }

                    if (CustomerManager.AllowCustomersToUploadAvatars)
                    {
                        var customerAvatar = customer.Avatar;
                        int avatarSize     = SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85);
                        if (customerAvatar != null)
                        {
                            string pictureUrl = PictureManager.GetPictureUrl(customerAvatar, avatarSize, false);
                            this.imgAvatar.ImageUrl = pictureUrl;
                        }
                        else
                        {
                            if (CustomerManager.DefaultAvatarEnabled)
                            {
                                string pictureUrl = PictureManager.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize);
                                this.imgAvatar.ImageUrl = pictureUrl;
                            }
                            else
                            {
                                imgAvatar.Visible = false;
                            }
                        }
                    }
                    else
                    {
                        imgAvatar.Visible = false;
                    }
                }
                else
                {
                    lblUser.Text   = GetLocaleResourceString("Customer.NotRegistered");
                    hlUser.Visible = false;
                    if (CustomerManager.AllowCustomersToUploadAvatars && CustomerManager.DefaultAvatarEnabled)
                    {
                        int    avatarSize = SettingManager.GetSettingValueInteger("Media.Customer.AvatarSize", 85);
                        string pictureUrl = PictureManager.GetDefaultPictureUrl(PictureTypeEnum.Avatar, avatarSize);
                        this.imgAvatar.ImageUrl = pictureUrl;
                    }
                    else
                    {
                        imgAvatar.Visible = false;
                    }
                }
            }
        }
Exemplo n.º 7
0
        protected void BindProductInfo(Product product)
        {
            lProductName.Text      = Server.HtmlEncode(product.LocalizedName);
            lShortDescription.Text = product.LocalizedShortDescription;
            lFullDescription.Text  = product.LocalizedFullDescription;
            //manufacturers
            List <Manufacturer> manufacturers = new List <Manufacturer>();

            foreach (var pm in product.ProductManufacturers)
            {
                var manufacturer = pm.Manufacturer;
                if (manufacturer != null)
                {
                    manufacturers.Add(manufacturer);
                }
            }
            if (manufacturers.Count > 0)
            {
                if (manufacturers.Count == 1)
                {
                    lManufacturersTitle.Text = GetLocaleResourceString("Products.Manufacturer");
                }
                else
                {
                    lManufacturersTitle.Text = GetLocaleResourceString("Products.Manufacturers");
                }
                rptrManufacturers.DataSource = manufacturers;
                rptrManufacturers.DataBind();
            }
            else
            {
                phManufacturers.Visible = false;
            }

            //pictures
            var pictures = PictureManager.GetPicturesByProductId(product.ProductId);

            if (pictures.Count > 1)
            {
                defaultImage.ImageUrl        = PictureManager.GetPictureUrl(pictures[0], SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                defaultImage.ToolTip         = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                defaultImage.AlternateText   = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                lvProductPictures.DataSource = pictures;
                lvProductPictures.DataBind();
            }
            else if (pictures.Count == 1)
            {
                defaultImage.ImageUrl      = PictureManager.GetPictureUrl(pictures[0], SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                defaultImage.ToolTip       = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                lvProductPictures.Visible  = false;
            }
            else
            {
                defaultImage.ImageUrl      = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.DetailImageSize", 300));
                defaultImage.ToolTip       = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                defaultImage.AlternateText = String.Format(GetLocaleResourceString("Media.Product.ImageAlternateTextFormat"), product.LocalizedName);
                lvProductPictures.Visible  = false;
            }
            if (SettingManager.GetSettingValueBoolean("Media.Product.DefaultPictureZoomEnabled", false))
            {
                var picture = product.DefaultPicture;
                if (picture != null)
                {
                    lnkMainLightbox.Attributes["href"] = PictureManager.GetPictureUrl(picture);
                    lnkMainLightbox.Attributes["rel"]  = "lightbox-pd";
                }
            }
        }
        protected void GenerateCompareTable()
        {
            this.tblCompareProducts.Rows.Clear();
            this.tblCompareProducts.Width = "100%";
            var compareProducts = ProductManager.GetCompareProducts();

            if (compareProducts.Count > 0)
            {
                var headerRow = new HtmlTableRow();
                this.AddCell(headerRow, "&nbsp;");
                var productNameRow = new HtmlTableRow();
                this.AddCell(productNameRow, "&nbsp;");
                var priceRow = new HtmlTableRow();
                var cell     = new HtmlTableCell();
                cell.InnerText = GetLocaleResourceString("Products.CompareProductsPrice");
                cell.Align     = "center";
                priceRow.Cells.Add(cell);

                var specificationAttributeIds = new List <int>();
                foreach (var product in compareProducts)
                {
                    var productSpecificationAttributes = SpecificationAttributeManager.GetProductSpecificationAttributesByProductId(product.ProductId, null, true);
                    foreach (var attribute in productSpecificationAttributes)
                    {
                        if (!specificationAttributeIds.Contains(attribute.SpecificationAttribute.SpecificationAttributeId))
                        {
                            specificationAttributeIds.Add(attribute.SpecificationAttribute.SpecificationAttributeId);
                        }
                    }
                }

                foreach (var product in compareProducts)
                {
                    var headerCell        = new HtmlTableCell();
                    var headerCellDiv     = new HtmlGenericControl("div");
                    var btnRemoveFromList = new Button();
                    btnRemoveFromList.ToolTip          = GetLocaleResourceString("Products.CompareProductsRemoveFromList");
                    btnRemoveFromList.Text             = GetLocaleResourceString("Products.CompareProductsRemoveFromList");
                    btnRemoveFromList.CommandName      = "Remove";
                    btnRemoveFromList.Command         += new CommandEventHandler(this.btnRemoveFromList_Command);
                    btnRemoveFromList.CommandArgument  = product.ProductId.ToString();
                    btnRemoveFromList.CausesValidation = false;
                    btnRemoveFromList.CssClass         = "remove-button";
                    btnRemoveFromList.ID = "btnRemoveFromList" + product.ProductId.ToString();
                    headerCellDiv.Controls.Add(btnRemoveFromList);

                    var productImagePanel = new HtmlGenericControl("p");
                    productImagePanel.Attributes.Add("align", "center");

                    var productImage = new HtmlImage();
                    productImage.Border = 0;
                    //productImage.Align = "center";
                    productImage.Alt = "Product image";
                    ProductPicture productPicture = product.DefaultProductPicture;
                    if (productPicture != null)
                    {
                        productImage.Src = PictureManager.GetPictureUrl(productPicture.Picture, SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125), true);
                    }
                    else
                    {
                        productImage.Src = PictureManager.GetDefaultPictureUrl(SettingManager.GetSettingValueInteger("Media.Product.ThumbnailImageSize", 125));
                    }
                    productImagePanel.Controls.Add(productImage);
                    headerCellDiv.Controls.Add(productImagePanel);

                    headerCell.Controls.Add(headerCellDiv);
                    headerRow.Cells.Add(headerCell);
                    var productNameCell = new HtmlTableCell();
                    var productLink     = new HyperLink();
                    productLink.Text        = Server.HtmlEncode(product.Name);
                    productLink.NavigateUrl = SEOHelper.GetProductUrl(product);
                    productLink.Attributes.Add("class", "link");
                    productNameCell.Align = "center";
                    productNameCell.Controls.Add(productLink);
                    productNameRow.Cells.Add(productNameCell);
                    var priceCell = new HtmlTableCell();
                    priceCell.Align = "center";
                    var productVariantCollection = product.ProductVariants;
                    if (productVariantCollection.Count > 0)
                    {
                        var     productVariant = productVariantCollection[0];
                        decimal finalPriceWithoutDiscountBase = TaxManager.GetPrice(productVariant, PriceHelper.GetFinalPrice(productVariant, false));
                        decimal finalPriceWithoutDiscount     = CurrencyManager.ConvertCurrency(finalPriceWithoutDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency);
                        priceCell.InnerText = PriceHelper.FormatPrice(finalPriceWithoutDiscount);
                    }
                    priceRow.Cells.Add(priceCell);
                }
                productNameRow.Attributes.Add("class", "product-name");
                priceRow.Attributes.Add("class", "productPrice");
                this.tblCompareProducts.Rows.Add(headerRow);
                this.tblCompareProducts.Rows.Add(productNameRow);
                if (!SettingManager.GetSettingValueBoolean("Common.HidePricesForNonRegistered") ||
                    (NopContext.Current.User != null &&
                     !NopContext.Current.User.IsGuest))
                {
                    this.tblCompareProducts.Rows.Add(priceRow);
                }

                foreach (int specificationAttributeId in specificationAttributeIds)
                {
                    var specificationAttribute = SpecificationAttributeManager.GetSpecificationAttributeById(specificationAttributeId);
                    var productRow             = new HtmlTableRow();
                    this.AddCell(productRow, Server.HtmlEncode(specificationAttribute.Name)).Align = "left";

                    foreach (var product2 in compareProducts)
                    {
                        var productCell = new HtmlTableCell();
                        {
                            var productSpecificationAttributes2 = SpecificationAttributeManager.GetProductSpecificationAttributesByProductId(product2.ProductId, null, true);
                            foreach (var psa2 in productSpecificationAttributes2)
                            {
                                if (specificationAttribute.SpecificationAttributeId == psa2.SpecificationAttribute.SpecificationAttributeId)
                                {
                                    productCell.InnerHtml = (!String.IsNullOrEmpty(psa2.SpecificationAttributeOption.Name)) ? Server.HtmlEncode(psa2.SpecificationAttributeOption.Name) : "&nbsp;";
                                }
                            }
                        }
                        productCell.Align  = "center";
                        productCell.VAlign = "top";
                        productRow.Cells.Add(productCell);
                    }
                    this.tblCompareProducts.Rows.Add(productRow);
                }

                string width = Math.Round((decimal)(90M / compareProducts.Count), 0).ToString() + "%";
                for (int i = 0; i < this.tblCompareProducts.Rows.Count; i++)
                {
                    var row = this.tblCompareProducts.Rows[i];
                    for (int j = 1; j < row.Cells.Count; j++)
                    {
                        if (j == (row.Cells.Count - 1))
                        {
                            row.Cells[j].Style.Add("width", width);
                            row.Cells[j].Style.Add("text-align", "center");
                        }
                        else
                        {
                            row.Cells[j].Style.Add("width", width);
                            row.Cells[j].Style.Add("text-align", "center");
                        }
                    }
                }
            }
            else
            {
                btnClearCompareProductsList.Visible = false;
                tblCompareProducts.Visible          = false;
            }
        }