예제 #1
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            var groups = ProductDataSource.GetGroups((String)navigationParameter);

            //var groups = SampleDataSource.GetGroups((String)navigationParameter);
            this.DefaultViewModel["Groups"] = groups;
        }
예제 #2
0
        protected void GoButton_Click(object sender, EventArgs e)
        {
            bool selectAll = AlwaysConvert.ToBool(SelectAll.Value, false);
            bool link      = AlwaysConvert.ToBool(GridActions.SelectedValue, false);

            if (selectAll)
            {
                BitFieldState   featured = (BitFieldState)Enum.Parse(typeof(BitFieldState), FeaturedFilter.SelectedValue);
                IList <Product> products = ProductDataSource.FindProducts(Name.Text.Trim(), SearchDescriptions.Checked, Sku.Text.Trim(), AlwaysConvert.ToInt(CategoriesList.SelectedValue), AlwaysConvert.ToInt(ManufacturerList.SelectedValue), AlwaysConvert.ToInt(VendorList.SelectedValue), featured, AlwaysConvert.ToInt(TaxCodeList.SelectedValue), AlwaysConvert.ToDecimal(FromPrice.Text), AlwaysConvert.ToDecimal(ToPrice.Text), OnlyDigitalGoods.Checked, OnlyGiftCertificates.Checked, OnlyKits.Checked, OnlySubscriptions.Checked, AlwaysConvert.ToInt(ProductGroups.SelectedValue));
                foreach (var product in products)
                {
                    SetFeatured(product.Id, link);
                }
            }
            else
            {
                int indexPeg = PG.PageSize * PG.PageIndex;

                foreach (GridViewRow row in PG.Rows)
                {
                    CheckBox selected = (CheckBox)PageHelper.RecursiveFindControl(row, "PID");
                    if ((selected != null) && selected.Checked)
                    {
                        int productId = (int)PG.DataKeys[row.DataItemIndex - indexPeg].Values[0];
                        SetFeatured(productId, link);
                    }
                }
            }

            PG.DataBind();
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            foreach (RepeaterItem ri in SelectedProductRepeater.Items)
            {
                HiddenField pid       = (HiddenField)ri.FindControl("PID");
                int         productId = AlwaysConvert.ToInt(pid.Value);
                Product     p         = ProductDataSource.Load(productId);
                if (p != null && p.ProductOptions.Count > 0)
                {
                    Dictionary <int, int> selectedOptions = GetSelectedOptions(ri.ItemIndex);
                    bool              allOptionsSelected  = (selectedOptions.Count == p.ProductOptions.Count);
                    string            optionList          = ProductVariantDataSource.GetOptionList(p.Id, selectedOptions, true);
                    ProductCalculator pcalc        = ProductCalculator.LoadForProduct(p.Id, 1, optionList, string.Empty);
                    Literal           productPrice = (Literal)ri.FindControl("ProductPrice");
                    productPrice.Text = pcalc.Price.LSCurrencyFormat("lc");
                    if (allOptionsSelected)
                    {
                        ProductVariant pv = ProductVariantDataSource.LoadForOptionList(p.Id, optionList);
                        if (pv != null && !pv.Available)
                        {
                            HtmlTableRow trInvalidVariant = (HtmlTableRow)ri.FindControl("trInvalidVariant");
                            if (trInvalidVariant != null)
                            {
                                trInvalidVariant.Visible = true;
                            }
                        }
                    }
                }
            }

            // SAVE THE CUSTOM VIEWSTATE
            SaveCustomViewState();
        }
예제 #4
0
        protected void Page_Init(object sender, EventArgs e)
        {
            _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
            _Product   = ProductDataSource.Load(_ProductId);
            if (_Product != null)
            {
                if (_Product.VolumeDiscounts.Count > 0)
                {
                    _VolumeDiscountId = _Product.VolumeDiscounts[0].Id;
                    _VolumeDiscount   = _Product.VolumeDiscounts[0];
                    _IsAdd            = false;
                }
                else
                {
                    _IsAdd               = true;
                    _VolumeDiscount      = new VolumeDiscount();
                    _VolumeDiscount.Name = _Product.Name;
                    _VolumeDiscount.Products.Add(_Product);
                    _VolumeDiscount.Save();
                    _VolumeDiscountId = _VolumeDiscount.Id;
                    VolumeDiscountLevel newDiscountLevel = new VolumeDiscountLevel();
                    _VolumeDiscount.Levels.Add(newDiscountLevel);
                }

                DiscountLevelGrid.DataSource = _VolumeDiscount.Levels;
                DiscountLevelGrid.DataBind();
            }
        }
        public static bool UnAssignAllProducts(ProductFilter filter, int groupId)
        {
            int totalCount   = ProductDataSource.FindProductsCount(filter.Name, filter.SearchDescriptions, filter.Sku, filter.CategoryId, filter.ManufacturerId, filter.VendorId, filter.Featured, 0, filter.FromPrice, filter.ToPrice, filter.DigitalGoodsOnly, filter.GiftCertificatesOnly, filter.KitsOnly, filter.SubscriptionsOnly);
            int currentIndex = 0;
            IDatabaseSessionManager database = AbleContext.Current.Database;

            database.BeginTransaction();
            while (currentIndex < totalCount)
            {
                IList <Product> currentBatch = ProductDataSource.FindProducts(filter.Name, filter.SearchDescriptions, filter.Sku, filter.CategoryId, filter.ManufacturerId, filter.VendorId, filter.Featured, 0, filter.FromPrice, filter.ToPrice, filter.DigitalGoodsOnly, filter.GiftCertificatesOnly, filter.KitsOnly, filter.SubscriptionsOnly, 100, currentIndex);
                foreach (Product p in currentBatch)
                {
                    ProductGroup pg = ProductGroupDataSource.Load(p.Id, groupId);
                    if (pg != null)
                    {
                        p.ProductGroups.Remove(pg);
                        p.Save();
                        pg.Delete();
                    }
                }
                currentIndex += 100;
            }

            database.CommitTransaction();
            return(true);
        }
예제 #6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _ProductId = AbleCommerce.Code.PageHelper.GetProductId();
            _Product   = ProductDataSource.Load(_ProductId);
            _settings  = AbleContext.Current.Store.Settings;
            _user      = AbleContext.Current.User;
            if (_Product != null)
            {
                ProductName.Text = _Product.Name;

                CategoryBreadCrumbs1.Visible = DisplayBreadCrumbs;

                //if (_Product.Manufacturer != null)
                //{
                //    Manufacturer manufacturer = _Product.Manufacturer;
                //    ManufacturerDetails.Controls.Add(new LiteralControl("Other products by "));
                //    ManufacturerDetails.Controls.Add(new LiteralControl(string.Format("<a href='{0}?m={1}' itemprop='manufacturer'>{2}</a><br />", Page.ResolveUrl("~/Search.aspx"), manufacturer.Id, manufacturer.Name)));
                //}

                // update moreitems tab text with category name
                int      categoryId = PageHelper.GetCategoryId();
                Category category   = CategoryDataSource.Load(categoryId);
                if (category != null)
                {
                    MoreItemsTabText.Text = string.Format(MoreItemsTabText.Text, category.Name);
                }
            }
        }
예제 #7
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            if (this.Visible)
            {
                int     _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
                Product _Product   = ProductDataSource.Load(_ProductId);
                if (_Product != null)
                {
                    List <ProductTemplateField> templateFields = (from tf in _Product.TemplateFields
                                                                  where !string.IsNullOrEmpty(tf.InputValue) && tf.InputField.IsMerchantField
                                                                  select tf).OrderBy(x => x.InputField.OrderBy).ToList();

                    ProductTemplateFieldsList.DataSource = templateFields;
                    ProductTemplateFieldsList.DataBind();

                    //List<ProductCustomField> customFields = (from cf in _Product.CustomFields
                    //                                         where !string.IsNullOrEmpty(cf.FieldValue)
                    //                                         select cf).ToList();

                    //ProductCustomFieldsList.DataSource = customFields;
                    //ProductCustomFieldsList.DataBind();

                    this.Visible = (templateFields.Count > 0 /*|| customFields.Count > 0*/);
                }
            }
        }
        protected void CGrid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            if (e.CommandName == "DeleteItem")
            {
                if (CGrid.DataSourceID == "ProductsDs")
                {
                    int     productId = AlwaysConvert.ToInt(e.CommandArgument);
                    Product product   = ProductDataSource.Load(productId);
                    if (product != null)
                    {
                        product.Delete();
                    }
                }
                else if (CGrid.DataSourceID == "LinkDs")
                {
                    int  linkId = AlwaysConvert.ToInt(e.CommandArgument);
                    Link link   = LinkDataSource.Load(linkId);
                    if (link != null)
                    {
                        link.Delete();
                    }
                }
                else if (CGrid.DataSourceID == "CategoryDs")
                {
                    int      cId = AlwaysConvert.ToInt(e.CommandArgument);
                    Category cat = CategoryDataSource.Load(cId);
                    if (cat != null)
                    {
                        cat.Delete();
                    }
                }

                CGrid.DataBind();
            }
        }
예제 #9
0
        protected void Page_Init(object sender, EventArgs e)
        {
            if (Request.Browser.IsMobileDevice)
            {
                _largeImageMaxDimension = 300;
            }
            int     productId = AbleCommerce.Code.PageHelper.GetProductId();
            Product product   = ProductDataSource.Load(productId);

            if (product != null)
            {
                this.Page.Title          = "Images of " + product.Name;
                this.GalleryCaption.Text = string.Format(this.GalleryCaption.Text, product.Name);

                List <ProductImage> images = (from i in product.Images select i)
                                             .ToList <ProductImage>();

                if (!string.IsNullOrEmpty(product.ImageUrl))
                {
                    images.Insert(0, new ProductImage()
                    {
                        ImageUrl = product.ImageUrl, ImageAltText = product.ImageAltText
                    });
                }

                MoreImagesList.DataSource = images;
                MoreImagesList.DataBind();
            }
        }
        protected void Page_Init(object sender, EventArgs e)
        {
            _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
            string optionList = EncryptionHelper.DecryptAES(Request.QueryString["Options"]);

            _OptionList = ProductVariantManager.ValidateOptionList(optionList);
            _Product    = ProductDataSource.Load(_ProductId);
            string productName = _Product.Name;

            _VariantManager = new ProductVariantManager(_ProductId);
            ProductVariant v = _VariantManager.GetVariantFromOptions(_OptionList);

            if (v != null)
            {
                productName = _Product.Name + " (" + v.VariantName + ")";
            }
            else
            {
                _OptionList = string.Empty;
            }
            Caption.Text             = string.Format(Caption.Text, productName);
            CancelButton.NavigateUrl = "DigitalGoods.aspx?ProductId=" + _ProductId.ToString();
            if (!Page.IsPostBack)
            {
                SearchResultsGrid.Visible = false;
            }
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            int     _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
            Product _Product   = ProductDataSource.Load(_ProductId);

            if (_Product != null)
            {
                ProductName.Text = _Product.Name;
                if (AbleContext.Current.Store.Settings.MobileStoreProductUseSummary)
                {
                    phDescription.Text = _Product.Description;
                }
                else
                {
                    MainDescription.Visible = false;
                }

                if (string.IsNullOrEmpty(_Product.ExtendedDescription))
                {
                    DetailedDescription.Visible = false;
                }
                else
                {
                    DetailedDescription.Visible = true;
                    extDescription.Text         = _Product.ExtendedDescription;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
            _Product   = ProductDataSource.Load(_ProductId);
            if (_Product == null)
            {
                Response.Redirect(AbleCommerce.Code.NavigationHelper.GetAdminUrl("Catalog/Browse.aspx"));
            }
            Caption.Text     = string.Format(Caption.Text, _Product.Name);
            ProductName.Text = _Product.Name;
            ValidFiles.Text  = AbleContext.Current.Store.Settings.FileExt_Assets;
            if (string.IsNullOrEmpty(ValidFiles.Text))
            {
                ValidFiles.Text = "any";
            }
            trSku.Visible = !string.IsNullOrEmpty(_Product.Sku);
            if (trSku.Visible)
            {
                Sku.Text = _Product.Sku;
            }
            if (!Page.IsPostBack)
            {
                StoreSettingsManager settings = AbleContext.Current.Store.Settings;
                CustomWidth.Text  = settings.StandardImageWidth.ToString();
                CustomHeight.Text = settings.StandardImageHeight.ToString();
            }

            FileDataMaxSize.Text = String.Format(FileDataMaxSize.Text, AbleContext.Current.Store.Settings.MaxRequestLength);
        }
예제 #13
0
        protected void InventoryGrid_RowCommand(object sender, System.Web.UI.WebControls.GridViewCommandEventArgs e)
        {
            if (e.CommandName.StartsWith("Do_"))
            {
                switch (e.CommandName)
                {
                case "Do_Pub":
                    // TOGGLE VISIBILITY
                    int     productId = AlwaysConvert.ToInt(e.CommandArgument);
                    Product product   = ProductDataSource.Load(productId);
                    switch (product.Visibility)
                    {
                    case CatalogVisibility.Public:
                        product.Visibility = CatalogVisibility.Hidden;
                        break;

                    case CatalogVisibility.Hidden:
                        product.Visibility = CatalogVisibility.Private;
                        break;

                    default:
                        product.Visibility = CatalogVisibility.Public;
                        break;
                    }
                    product.Save();
                    InventoryGrid.DataBind();
                    break;
                }
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            int     productId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
            Product product   = ProductDataSource.Load(productId);

            if (product == null)
            {
                Response.Redirect("../../Catalog/Browse.aspx?CategoryId=" + AbleCommerce.Code.PageHelper.GetCategoryId());
            }
            Caption.Text = string.Format(Caption.Text, product.Name);

            // build list of kits
            List <KitMemberInfo> kitMemberships = new List <KitMemberInfo>();
            IList <KitComponent> components     = KitComponentDataSource.LoadForMemberProduct(productId);

            foreach (KitComponent component in components)
            {
                foreach (ProductKitComponent pkc in component.ProductKitComponents)
                {
                    kitMemberships.Add(new KitMemberInfo(pkc.ProductId, pkc.Product.Name, component.Name));
                }
            }
            kitMemberships.Sort(new KitMemberInfoComparer());
            KitMembershipList.DataSource = kitMemberships;
            KitMembershipList.DataBind();
        }
 protected void LinkButtonInsert_Click(object sender, EventArgs e)
 {
     ProductDataSource.InsertParameters["ProductStock"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("Txtpdctstock")).Text;
     ProductDataSource.InsertParameters["ProductName"].DefaultValue  = ((TextBox)GridView1.FooterRow.FindControl("TextBox4")).Text;
     ProductDataSource.InsertParameters["ProductPrice"].DefaultValue = ((TextBox)GridView1.FooterRow.FindControl("TextProductPrice")).Text;
     ProductDataSource.Insert();
 }
예제 #16
0
            private string GetInventoryMessage(string optionlist)
            {
                string message = string.Empty;
                Label  label   = new Label();

                if (!string.IsNullOrEmpty(optionlist) && showInventoryMessage)
                {
                    ProductVariant variant          = ProductVariantDataSource.LoadForOptionList(productId, optionlist);
                    Product        _Product         = ProductDataSource.Load(productId);
                    bool           inventoryEnabled = _Product.InventoryMode == InventoryMode.Variant && !_Product.AllowBackorder;
                    if (inventoryEnabled)
                    {
                        if (variant.InStock > 0)
                        {
                            string inStockformat  = AbleContext.Current.Store.Settings.InventoryInStockMessage;
                            string inStockMessage = string.Format(inStockformat, variant.InStock);
                            message = inStockMessage;
                        }
                        else if (!variant.Available || variant.InStock <= 0)
                        {
                            string outOfStockformat  = AbleContext.Current.Store.Settings.InventoryOutOfStockMessage;
                            string outOfStockMessage = string.Format(outOfStockformat, variant.InStock);
                            message = outOfStockMessage;

                            if (variant != null && variant.AvailabilityDate.HasValue && variant.AvailabilityDate >= LocaleHelper.LocalNow)
                            {
                                string availabilityMessageFormat = AbleContext.Current.Store.Settings.InventoryAvailabilityMessage;
                                string availabilityMessage       = string.Format(availabilityMessageFormat, variant.AvailabilityDate.Value.ToShortDateString());
                                message += availabilityMessage;
                            }
                        }
                    }
                }
                return(string.Format("<span class='errorCondition'>{0}</span>", message));
            }
        protected void BindSubCategories()
        {
            IList <Category>       allCategories       = CategoryDataSource.LoadForParent(this._categoryId, true);
            List <SubCategoryData> populatedCategories = new List <SubCategoryData>();

            foreach (Category category in allCategories)
            {
                // SEARCH ALL CATEGORIES
                int totalProducts = ProductDataSource.AdvancedSearchCount(_keywords, category.Id, _manufacturerId, true, true, true, 0, 0, false, PageHelper.GetShopByChoices());
                if (totalProducts > 0)
                {
                    populatedCategories.Add(new SubCategoryData(category.Id, category.Name, category.NavigateUrl, totalProducts));
                }
            }
            if (populatedCategories.Count > 0)
            {
                SubCategoryPanel.Visible       = true;
                SubCategoryRepeater.DataSource = populatedCategories;
                SubCategoryRepeater.DataBind();
            }
            else
            {
                SubCategoryPanel.Visible = false;
            }
        }
예제 #18
0
 protected void Page_Init(object sender, EventArgs e)
 {
     _ProductId            = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
     _Product              = ProductDataSource.Load(_ProductId);
     HiddenProductId.Value = _ProductId.ToString();
     if (_Product == null)
     {
         ProductCaption.Visible = false;
     }
     else
     {
         ProductCaption.Text = string.Format(ProductCaption.Text, _Product.Name);
     }
     if (!Page.IsPostBack)
     {
         //CHECK FOR SEARCH CACE
         SearchCache.SearchCriteria criteria = SearchCache.GetCriteria();
         if ((criteria != null) && (criteria.Arguments.ContainsKey("ShowApproved")))
         {
             ListItem item = ShowApproved.Items.FindByValue(criteria.Arguments["ShowApproved"].ToString());
             if (item != null)
             {
                 ShowApproved.SelectedIndex = ShowApproved.Items.IndexOf(item);
             }
             ReviewGrid.PageIndex             = criteria.PageIndex;
             ReviewGrid.DefaultSortDirection  = criteria.SortDirection;
             ReviewGrid.DefaultSortExpression = criteria.SortExpression;
         }
     }
 }
        protected void Page_Load(object sender, EventArgs e)
        {
            int      _CategoryId = AbleCommerce.Code.PageHelper.GetCategoryId();
            Category _Category   = CategoryDataSource.Load(_CategoryId);

            if (_Category != null)
            {
                //GET FEATURED PRODUCTS IN CATEGORY
                IList <Product> featured = ProductDataSource.GetFeaturedProducts(_CategoryId, true, IncludeOutOfStockItems, _MaxItems, 0);
                //MAKE SURE WE HAVE SOMETHING TO SHOW
                if (featured.Count > 0)
                {
                    //SET CAPTION
                    phCaption.Text = this.Caption;
                    //BIND THE PRODUCTS
                    ProductList.RepeatColumns = this.Columns;
                    ProductList.DataSource    = featured;
                    ProductList.DataBind();
                }
                else
                {
                    //THERE ARE NOT ANY ITEMS TO DISPLAY
                    phContent.Visible = false;
                }
            }
        }
예제 #20
0
        /// <summary>
        /// Checks stock for given product
        /// </summary>
        /// <param name="productId">Id of the product to check stock for</param>
        /// <param name="optionList">The option list of the product to check stock for</param>
        /// <param name="kitProductIds">If its a kit product the Ids of the kit products to check stock for</param>
        /// <returns>InventoryManagerData object containing stock details for the given product</returns>
        public static InventoryManagerData CheckStock(int productId, string optionList, List <int> kitProductIds)
        {
            Product product = ProductDataSource.Load(productId);

            if (product == null)
            {
                throw new InvalidProductException();
            }
            if (kitProductIds == null)
            {
                kitProductIds = new List <int>();
            }
            ProductVariant variant = null;

            if (!string.IsNullOrEmpty(optionList))
            {
                variant = ProductVariantDataSource.LoadForOptionList(productId, optionList);
            }

            List <KitProduct> kitProducts = new List <KitProduct>();

            foreach (int kpid in kitProductIds)
            {
                KitProduct kp = KitProductDataSource.Load(kpid);
                if (kp != null)
                {
                    kitProducts.Add(kp);
                }
            }
            return(CheckStock(product, variant, kitProducts));
        }
예제 #21
0
        /// <summary>
        /// Load this Kit object from the database for the given primary key.
        /// </summary>
        /// <param name="productId">Value of ProductId of the object to load.</param>
        /// <returns><b>true</b> if load is successful, <b>false</b> otherwise</returns>
        public virtual bool Load(Int32 productId)
        {
            if (productId < 1)
            {
                throw new ArgumentException("productId", "productId must be greater than 0");
            }
            _Product = ProductDataSource.Load(productId);
            if (_Product == null)
            {
                throw new InvalidProductException("The productId specified is invalid.");
            }
            _ProductId = productId;
            //CREATE THE DYNAMIC SQL TO LOAD OBJECT
            StringBuilder selectQuery = new StringBuilder();

            selectQuery.Append("SELECT " + GetColumnNames(string.Empty));
            selectQuery.Append(" FROM ac_Kits");
            selectQuery.Append(" WHERE ProductId = @productId");
            Database  database      = Token.Instance.Database;
            DbCommand selectCommand = database.GetSqlStringCommand(selectQuery.ToString());

            database.AddInParameter(selectCommand, "@productId", System.Data.DbType.Int32, productId);
            //EXECUTE THE COMMAND
            using (IDataReader dr = database.ExecuteReader(selectCommand))
            {
                if (dr.Read())
                {
                    LoadDataReader(this, dr);;
                }
                dr.Close();
            }
            return(true);
        }
예제 #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // LOCATE THE USER THAT THE ORDER IS BEING PLACED FOR
            _UserId = AlwaysConvert.ToInt(Request.QueryString["UID"]);
            _User   = UserDataSource.Load(_UserId);
            if (_User == null)
            {
                Response.Redirect("CreateOrder1.aspx");
            }
            _Basket = _User.Basket;

            // INITIALIZE INVENTORY VARIABLES
            _InventoryManager      = AbleContext.Resolve <IInventoryManager>();
            _StoreInventoryEnabled = AbleContext.Current.Store.Settings.EnableInventory;

            // SHOW QUANTITY AVAILABLE COLUMN IF INVENTORY IS ENABLED
            BasketGrid.Columns[4].Visible = _StoreInventoryEnabled;

            // INITIALIZE THE CAPTION
            string userName = _User.IsAnonymous ? "Unregistered User" : _User.UserName;

            Caption.Text = string.Format(Caption.Text, userName);

            // SEE IF THE ADD PRODUCT FORM SHOULD BE VISIBLE
            int     productId = AlwaysConvert.ToInt(Request.Form[AddProductId.UniqueID]);
            Product product   = ProductDataSource.Load(productId);

            if (product != null)
            {
                ShowProductForm(product);
            }
        }
예제 #23
0
        static void Main(string[] args)
        {
            ProductDataSource productContext = new ProductDataSource();

            var allProducts    = productContext.GetAll();
            var specificPoduct = productContext.GetDataByID(new Guid("BF2299D8-8363-41DC-B706-456163BAFCE4"));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            _ProductReviewId = AlwaysConvert.ToInt(Request.QueryString["ReviewId"]);
            _ProductReview   = ProductReviewDataSource.Load(_ProductReviewId);

            if (_ProductReview != null)
            {
                _ProductId = _ProductReview.Product.Id;
            }
            else
            {
                _ProductId = AlwaysConvert.ToInt(Request.QueryString["ProductId"]);
            }
            _Product = ProductDataSource.Load(_ProductId);

            if (!Page.IsPostBack)
            {
                InitializeForm();
            }

            //INIT ReviewBody COUNTDOWN
            AbleCommerce.Code.PageHelper.SetMaxLengthCountDown(ReviewBody, ReviewMessageCharCount);
            ReviewMessageCharCount.Text = ((int)(ReviewBody.MaxLength - ReviewBody.Text.Length)).ToString();

            if (AbleContext.Current.Store.Settings.ProductReviewTermsAndConditions != string.Empty)
            {
                ReviewTermsLink.Visible     = true;
                ReviewTermsLink.NavigateUrl = NavigationHelper.GetMobileStoreUrl(string.Format("~/ReviewTerms.aspx?ProductId={0}", _Product.Id));
            }
            else
            {
                ReviewTermsLink.Visible   = false;
                reviewInstruction.Visible = false;
            }
        }
        protected void Page_PreRender(object sender, EventArgs e)
        {
            Product product = ProductDataSource.Load(this.ProductId);

            if (product == null)
            {
                AC.Visible = false;
                MD.Visible = false;
            }
            else
            {
                if (AbleContext.Current.Store.Settings.ProductPurchasingDisabled ||
                    product.DisablePurchase ||
                    product.HasChoices ||
                    product.UseVariablePrice ||
                    product.IsSubscription ||
                    (product.InventoryMode == InventoryMode.Product && product.InStock <= 0))
                {
                    // cannot click to add the indicated item to the cart
                    AC.Visible     = false;
                    MD.Visible     = true;
                    MD.NavigateUrl = product.NavigateUrl;
                }
                else
                {
                    AC.ID      = "AddToCart_" + this.ProductId;
                    AC.Visible = true;
                    MD.Visible = false;
                }
            }
        }
예제 #26
0
        protected void Page_PreRender(object sender, EventArgs e)
        {
            // REGISTER WARNING SCRIPTS IF THE PRODUCT HAS CUSTOMIZED VARIANTS
            string  warnScript;
            int     productId = AbleCommerce.Code.PageHelper.GetProductId();
            Product product   = ProductDataSource.Load(productId);

            if (product != null)
            {
                bool hasDigitalGoods = ProductVariantManager.HasDigitalGoodData(productId);
                if (hasDigitalGoods || product.KitStatus == KitStatus.Member)
                {
                    String delMesssage = String.Empty;
                    if (hasDigitalGoods)
                    {
                        delMesssage += "WARNING: If there are digital goods linked to variants with this choice, deleting the choice will unlink these digital goods.\\n\\n";
                    }
                    if (product.KitStatus == KitStatus.Member)
                    {
                        delMesssage += "WARNING: This product is part of one or more kit products.  Deleting this choice will remove any variants with this choice from those kit products.\\n\\n";
                    }

                    warnScript = "function confirmDel(){return confirm('" + delMesssage + "Are you sure you want to delete this choice?');}";
                }
                else
                {
                    warnScript = "function confirmDel(){return confirm('Are you sure you want to delete this choice?');}";
                }
                this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "checkVariant", warnScript, true);
            }
        }
예제 #27
0
 protected void SendEmailButton_Click(object sender, EventArgs e)
 {
     if (Page.IsValid)
     {
         if ((!trCaptchaImage.Visible) || CaptchaImage.Authenticate(CaptchaInput.Text))
         {
             int     productId = AbleCommerce.Code.PageHelper.GetProductId();
             Product product   = ProductDataSource.Load(productId);
             if (product != null)
             {
                 int           categoryId = AbleCommerce.Code.PageHelper.GetCategoryId();
                 Category      category   = CategoryDataSource.Load(categoryId);
                 EmailTemplate template   = EmailTemplateDataSource.Load(AbleContext.Current.Store.Settings.ProductTellAFriendEmailTemplateId);
                 if (template != null)
                 {
                     //STRIP HTML
                     Name.Text        = StringHelper.StripHtml(Name.Text);
                     FromEmail.Text   = StringHelper.StripHtml(FromEmail.Text);
                     FriendEmail.Text = StringHelper.StripHtml(FriendEmail.Text);
                     // ADD PARAMETERS
                     template.Parameters["store"]     = AbleContext.Current.Store;
                     template.Parameters["product"]   = product;
                     template.Parameters["category"]  = category;
                     template.Parameters["fromEmail"] = FromEmail.Text;
                     template.Parameters["fromName"]  = Name.Text;
                     template.FromAddress             = FromEmail.Text;
                     template.ToAddress = FriendEmail.Text;
                     template.Send();
                     FriendEmail.Text           = string.Empty;
                     SentMessage.Visible        = true;
                     CaptchaInput.Text          = "";
                     CaptchaImage.ChallengeText = StringHelper.RandomNumber(6);
                 }
                 else
                 {
                     FailureMessage.Text    = "Email template could not be loaded.";
                     FailureMessage.Visible = true;
                 }
             }
             else
             {
                 FailureMessage.Text    = "Product could not be identified.";
                 FailureMessage.Visible = true;
             }
         }
         else
         {
             //CAPTCHA IS VISIBLE AND DID NOT AUTHENTICATE
             CustomValidator invalidInput = new CustomValidator();
             invalidInput.ValidationGroup = "TellAFriend";
             invalidInput.Text            = "*";
             invalidInput.ErrorMessage    = "You did not input the verification number correctly.";
             invalidInput.IsValid         = false;
             phCaptchaValidators.Controls.Add(invalidInput);
             CaptchaInput.Text          = "";
             CaptchaImage.ChallengeText = StringHelper.RandomNumber(6);
         }
     }
 }
예제 #28
0
 protected bool HasChildProducts(Category cat)
 {
     if (cat == null)
     {
         return(false);
     }
     return(ProductDataSource.CountForCategory(cat.Id, false, true) > 0);
 }
예제 #29
0
        /// <summary>
        /// Populates the page with content passed during navigation.  Any saved state is also
        /// provided when recreating a page from a prior session.
        /// </summary>
        /// <param name="navigationParameter">The parameter value passed to
        /// <see cref="Frame.Navigate(Type, Object)"/> when this page was initially requested.
        /// </param>
        /// <param name="pageState">A dictionary of state preserved by this page during an earlier
        /// session.  This will be null the first time a page is visited.</param>
        protected override void LoadState(Object navigationParameter, Dictionary <String, Object> pageState)
        {
            // TODO: Create an appropriate data model for your problem domain to replace the sample data
            var group = ProductDataSource.GetGroup((String)navigationParameter);

            this.DefaultViewModel["Group"] = group;
            this.DefaultViewModel["Items"] = group.Items;
        }
예제 #30
0
        /// <summary>
        /// Deletes this product from the database
        /// </summary>
        /// <returns><b>true</b> if delete is successful, <b>false</b> otherwise</returns>
        public bool Delete()
        {
            //DELETE ALL CHILD DATA THAT MAY NOT BE HANDLED BY CASCADE DELETES
            ProductDataSource.DeleteChildData(this);

            //CALL THE BASE DELETE METHOD
            return(this.BaseDelete());
        }