protected void btnLinkDetailImg_Click(object sender, ImageClickEventArgs e) { ImageButton button = (sender as ImageButton); if (button != null) { _catalogNav.TabID = _detailID; _catalogNav.ProductID = int.Parse(button.CommandArgument); Response.Redirect(_catalogNav.GetNavigationUrl()); } }
private void editControl_EditComplete(object sender, EventArgs e) { if (_nav.Edit.ToLower() == "category") { _nav.CategoryID = Null.NullInteger; } _nav.Edit = Null.NullString; _nav.ProductID = Null.NullInteger; Response.Redirect(_nav.GetNavigationUrl(), false); }
protected void ddlSortBy_SelectedIndexChanged(object sender, EventArgs e) { DropDownList ddlSortBy = (sender as DropDownList); if (ddlSortBy != null) { _moduleNav.SortID = int.Parse(ddlSortBy.SelectedValue); _moduleNav.SortDir = "ASC"; _moduleNav.PageIndex = Null.NullInteger; } Response.Redirect(_moduleNav.GetNavigationUrl()); }
private void MyList_ItemDataBound(object sender, DataListItemEventArgs e) { // Do we have the category info? CategoryInfo category = (e.Item.DataItem as CategoryInfo); if (category != null) { // Did we find the hyperlink? HyperLink linkCategory = (e.Item.FindControl("linkCategory") as HyperLink); if (linkCategory != null) { // Build the nav URL for this item _categoryNav.CategoryID = category.CategoryID; if (StoreSettings.SEOFeature) { _categoryNav.Category = category.SEOName; } // Define hyperlink properties linkCategory.NavigateUrl = _categoryNav.GetNavigationUrl(); linkCategory.ToolTip = category.Description; //Set styling... string indentClass = " StoreMenuCategoryItemLevel_0"; if (_selectedCategoryID == category.CategoryID) { linkCategory.CssClass = "StoreMenuCategoryItemSelected" + indentClass; } else { linkCategory.CssClass = "StoreMenuCategoryItem" + indentClass; } if (_parentCategories.Count > 0) { // If equal, this is a root cat that needs to be expanded... if (category.CategoryID == _parentCategories[0].CategoryID) { DisplayChildCategories(_parentCategories[0], e.Item, 1); } } } } }
protected String FixHyperlinkCatalog(CatalogNavigation currentCatalogNav, int categoryLevel) { StringDictionary replaceParams = new StringDictionary(); if (categoryLevel < 3) replaceParams["CategoryID3"] = Null.NullString; if (categoryLevel < 2) replaceParams["CategoryID2"] = Null.NullString; if (categoryLevel < 1) replaceParams["CategoryID"] = Null.NullString; return currentCatalogNav.GetNavigationUrl(replaceParams); }
protected void grdItems_ItemDataBound(object sender, DataGridItemEventArgs e) { if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) { ItemInfo itemInfo = (ItemInfo)e.Item.DataItem; if (_showThumbnail) { Image imgThumbnail = (Image)e.Item.FindControl("imgThumbnail"); if (imgThumbnail != null) { imgThumbnail.ImageUrl = GetImageUrl(itemInfo.ProductImage); imgThumbnail.AlternateText = itemInfo.ProductTitle; imgThumbnail.Width = _thumbnailWidth; } } string productTitle = null; switch (_productColumn) { case "modelnumber": productTitle = itemInfo.ModelNumber; break; case "modelname": productTitle = itemInfo.ModelName; break; case "producttitle": productTitle = itemInfo.ProductTitle; break; } if (_linkToDetail) { HtmlAnchor lnkTitle = (HtmlAnchor)e.Item.FindControl("lnkTitle"); if (lnkTitle != null) { StringDictionary rplcTitle = new StringDictionary { { "ProductID", itemInfo.ProductID.ToString() } }; if (StoreSettings.SEOFeature) { ProductInfo product = _productControler.GetProduct(PortalId, itemInfo.ProductID); rplcTitle.Add("Product", product.SEOName); } CatalogNavigation catalogNav = new CatalogNavigation(); lnkTitle.InnerText = productTitle; lnkTitle.Title = _linkTitle; lnkTitle.HRef = catalogNav.GetNavigationUrl(StoreSettings.StorePageID, rplcTitle); lnkTitle.Visible = true; } } else { Label lblTitle = (Label)e.Item.FindControl("lblTitle"); if (lblTitle != null) { lblTitle.Text = productTitle; lblTitle.Visible = true; } } Label lblPrice = (Label)e.Item.FindControl("lblPrice"); if (lblPrice != null) { decimal unitCost = itemInfo.UnitCost; if (_showTax && _includeVAT) { unitCost = (unitCost + (unitCost * (_defaultTaxRate / 100))); } lblPrice.Text = (unitCost).ToString("C", _localFormat); } Label lblSubtotal = (Label)e.Item.FindControl("lblSubtotal"); if (lblSubtotal != null) { decimal subTotal = itemInfo.SubTotal; if (_showTax && _includeVAT) { subTotal = (subTotal + (subTotal * (_defaultTaxRate / 100))); } lblSubtotal.Text = (subTotal).ToString("C", _localFormat); _cartTotal += subTotal; _itemsCount += itemInfo.Quantity; } TextBox txtQty = (TextBox)e.Item.FindControl("txtQuantity"); if (txtQty != null) { txtQty.Text = itemInfo.Quantity.ToString(); } RequiredFieldValidator valReqQuantity = (RequiredFieldValidator)e.Item.FindControl("valReqQuantity"); if (valReqQuantity != null) { valReqQuantity.ErrorMessage = LocalizeString("valReqQuantity"); } CompareValidator valCompQuantity = (CompareValidator)e.Item.FindControl("valCompQuantity"); if (valCompQuantity != null) { valCompQuantity.ErrorMessage = LocalizeString("valCompQuantity"); } CustomValidator valCustQuantity = (CustomValidator)e.Item.FindControl("valCustQuantity"); if (valCustQuantity != null) { if (StoreSettings.InventoryManagement && StoreSettings.AvoidNegativeStock) { valCustQuantity.Attributes.Add("ItemID", itemInfo.ItemID.ToString()); } else { valCustQuantity.Visible = false; } } ImageButton ibUpdate = (ImageButton)e.Item.FindControl("ibUpdate"); if (ibUpdate != null) { ibUpdate.ImageUrl = _imageUpdate; ibUpdate.CommandArgument = e.Item.ItemIndex.ToString(); ibUpdate.CommandName = "Update"; } if (txtQty != null && ibUpdate != null) { txtQty.Attributes.Add("onkeydown", "javascript:if((event.which && event.which == 13) || (event.keyCode && event.keyCode == 13)){document.getElementById('" + ibUpdate.ClientID + "').click();return false;}else return true;"); } ImageButton ibDelete = (ImageButton)e.Item.FindControl("ibDelete"); if (ibDelete != null) { ibDelete.ImageUrl = _imageDelete; ibDelete.CommandArgument = e.Item.ItemIndex.ToString(); ibDelete.CommandName = "Delete"; } } else if (e.Item.ItemType == ListItemType.Footer) { Label lblCount = (Label)e.Item.FindControl("lblCount"); if (lblCount != null) { lblCount.Text = _itemsCount.ToString(); } Label lblTotal = (Label)e.Item.FindControl("lblTotal"); if (lblTotal != null) { lblTotal.Text = _cartTotal.ToString("C", _localFormat); } } }
protected void btnAddReview_Click(object sender, EventArgs e) { _nav.ReviewID = 0; Response.Redirect(_nav.GetNavigationUrl(), false); }
private Control ProcessToken(string tokenName) { switch (tokenName.ToUpper()) { case "LISTTITLE": Label lblTitle = new Label { CssClass = "StoreListTitle", Text = _title }; return(lblTitle); case "PAGENAV": if ((ListType == ProductListTypes.Category || ListType == ProductListTypes.SearchResults) && _productList.Count > 0) { HyperLink btnPrevious = new HyperLink { Text = Localization.GetString("Previous", LocalResourceFile), CssClass = "StorePagePrevious" }; _buttonsPrevious.Add(btnPrevious); Literal lblSpace = new Literal { Text = " " }; HyperLink btnNext = new HyperLink { Text = Localization.GetString("Next", LocalResourceFile), CssClass = "StorePageNext" }; _buttonsNext.Add(btnNext); PlaceHolder phPageList = new PlaceHolder(); _placeholdersPageList.Add(phPageList); Label lblPageNav = new Label(); lblPageNav.Controls.Add(btnPrevious); lblPageNav.Controls.Add(lblSpace); lblPageNav.Controls.Add(phPageList); lblPageNav.Controls.Add(btnNext); lblPageNav.CssClass = "StorePageNav"; _labelsPageNav.Add(lblPageNav); return(lblPageNav); } return(null); case "PAGEINFO": if (_productList.Count > 0) { Label lblPageInfo = new Label { CssClass = "StorePageInfo", Text = string.Format(Localization.GetString("PageInfo", LocalResourceFile), 1, 1) }; _labelsPageInfo.Add(lblPageInfo); return(lblPageInfo); } return(null); case "PRODUCTS": if (_productList.Count > 0) { _lstProducts = new DataList { ID = "ProductsList", CssClass = _containerCssClass, RepeatLayout = RepeatLayout.Table }; switch (_direction) { case "V": _lstProducts.RepeatDirection = RepeatDirection.Vertical; break; case "H": default: _lstProducts.RepeatDirection = RepeatDirection.Horizontal; break; } _lstProducts.RepeatColumns = _columnCount; _lstProducts.ItemDataBound += lstProducts_ItemDataBound; return(_lstProducts); } Label lblEmpty = new Label { CssClass = "StoreEmptyList" }; if (ListType == ProductListTypes.Category) { lblEmpty.Text = Localization.GetString("CategoryEmpty", LocalResourceFile); } else if (ListType == ProductListTypes.SearchResults) { lblEmpty.Text = Localization.GetString("SearchEmpty", LocalResourceFile); } return(lblEmpty); case "ULISTPRODUCTS": if (_productList.Count > 0) { _rlProducts = new Repeater { ID = "UnorderedProductsList", HeaderTemplate = new ListTemplate("<ul>"), ItemTemplate = new ListTemplate(), FooterTemplate = new ListTemplate("</ul>") }; _rlProducts.ItemDataBound += rlProducts_ItemDataBound; return(_rlProducts); } return(null); case "ITEMSCOUNT": if (_productList != null) { Label lblItems = new Label { CssClass = "StoreItemsCount", Text = string.Format(Localization.GetString("ItemsCount", LocalResourceFile), _productList.Count) }; return(lblItems); } return(null); case "SELECTEDCATEGORY": if (ListType == ProductListTypes.Category) { if (_moduleNav.CategoryID == Null.NullInteger && _moduleSettings.General.DisplayAllProducts) { Label lblProductCategory = new Label { Text = Localization.GetString("FullCatalog", LocalResourceFile), CssClass = "StoreSelectedCategory" }; return(lblProductCategory); } _categoryControler = new CategoryController(); CategoryInfo categoryInfo = _categoryControler.GetCategory(PortalId, CategoryID); if (categoryInfo != null) { Label lblProductCategory = new Label { Text = string.Format(Localization.GetString("SelectedCategory", LocalResourceFile), categoryInfo.Name), CssClass = "StoreSelectedCategory" }; return(lblProductCategory); } } return(null); case "CATEGORIESBREADCRUMB": if (ListType == ProductListTypes.Category && CategoryID != Null.NullInteger) { _categoryControler = new CategoryController(); CategoryInfo categoryInfo = _categoryControler.GetCategory(PortalId, CategoryID); if (categoryInfo != null) { // Create label to contains all other controls Label lblCategoriesBreadcrumb = new Label { CssClass = "StoreCategoriesBreadcrumb" }; // Create "before" label with locale resource Label lblBeforeBreadcrumb = new Label { Text = Localization.GetString("BeforeCategoriesBreadcrumb", LocalResourceFile), CssClass = "StoreBeforeBreadcrumb" }; lblCategoriesBreadcrumb.Controls.Add(lblBeforeBreadcrumb); // Create label to contains categories Label lblBreadcrumb = new Label { CssClass = "StoreBreadcrumb" }; lblCategoriesBreadcrumb.Controls.Add(lblBreadcrumb); // Create literal with selected category name Literal litSelectedCategory = new Literal { Text = categoryInfo.Name }; lblBreadcrumb.Controls.Add(litSelectedCategory); // Create "between" label with locale resource Literal litBetwenBreadcrumb; String betweenBreadcrumb = Localization.GetString("BetweenCategoriesBreadcrumb", LocalResourceFile); // Create catalog navigation object to compute hyperlink URL CatalogNavigation categoryNav = new CatalogNavigation(); // Loop for parent categories (if any) int parentCategoryID = categoryInfo.ParentCategoryID; while (parentCategoryID != Null.NullInteger) { // Get parent category categoryInfo = _categoryControler.GetCategory(PortalId, parentCategoryID); if (categoryInfo != null) { // Insert separator litBetwenBreadcrumb = new Literal { Text = betweenBreadcrumb }; lblBreadcrumb.Controls.AddAt(0, litBetwenBreadcrumb); // Create hyperlink with the parent category HyperLink hlCategory = new HyperLink { Text = categoryInfo.Name }; categoryNav.CategoryID = categoryInfo.CategoryID; if (StoreSettings.SEOFeature) { categoryNav.Category = categoryInfo.SEOName; } hlCategory.NavigateUrl = categoryNav.GetNavigationUrl(); lblBreadcrumb.Controls.AddAt(0, hlCategory); parentCategoryID = categoryInfo.ParentCategoryID; } else { parentCategoryID = Null.NullInteger; } } // Create "after" label with locale resource Label lblAfterBreadcrumb = new Label { Text = Localization.GetString("AfterCategoriesBreadcrumb", LocalResourceFile), CssClass = "StoreAfterBreadcrumb" }; lblCategoriesBreadcrumb.Controls.Add(lblAfterBreadcrumb); return(lblCategoriesBreadcrumb); } } return(null); case "SORTBY": if (_moduleSettings.SortProducts.SortColumns != 0 && (ListType == ProductListTypes.Category || ListType == ProductListTypes.SearchResults)) { // Create label to contains all other controls Label lblSortBy = new Label { CssClass = "StoreSortBy" }; // Create literal text with locale resource Literal litSortBy = new Literal { Text = Localization.GetString("SortBy", LocalResourceFile) }; lblSortBy.Controls.Add(litSortBy); // Create DropDownList with column names DropDownList ddlSortBy = new DropDownList { AutoPostBack = true, CssClass = "StoreSortByColumns" }; int sortColumns = _moduleSettings.SortProducts.SortColumns; if ((sortColumns & (int)SortColumn.Manufacturer) != 0) { ddlSortBy.Items.Add(new ListItem(Localization.GetString("SortManufacturer", LocalResourceFile), "0")); } if ((sortColumns & (int)SortColumn.ModelNumber) != 0) { ddlSortBy.Items.Add(new ListItem(Localization.GetString("SortModelNumber", LocalResourceFile), "1")); } if ((sortColumns & (int)SortColumn.ModelName) != 0) { ddlSortBy.Items.Add(new ListItem(Localization.GetString("SortModelName", LocalResourceFile), "2")); } if ((sortColumns & (int)SortColumn.UnitPrice) != 0) { ddlSortBy.Items.Add(new ListItem(Localization.GetString("SortUnitPrice", LocalResourceFile), "3")); } if ((sortColumns & (int)SortColumn.Date) != 0) { ddlSortBy.Items.Add(new ListItem(Localization.GetString("SortCreatedDate", LocalResourceFile), "4")); } string sortColumn; // Define sort column if (_moduleNav.SortID != Null.NullInteger) { // Currently selected sort column sortColumn = _moduleNav.SortID.ToString(); } else { // Default sort column sortColumn = _moduleSettings.SortProducts.SortBy.ToString(); } ListItem itemSortColumn = ddlSortBy.Items.FindByValue(sortColumn); if (itemSortColumn != null) { itemSortColumn.Selected = true; } ddlSortBy.SelectedIndexChanged += ddlSortBy_SelectedIndexChanged; if (_productList.Count == 0) { ddlSortBy.Enabled = false; } lblSortBy.Controls.Add(ddlSortBy); // Create Sort Order image button ImageButton btnSortDir = new ImageButton { CssClass = "StoreSortByLinkButton" }; string sortDir; if (_moduleNav.SortDir != Null.NullString) { // Currently selected sort direction sortDir = _moduleNav.SortDir; } else { // Default sort direction sortDir = _moduleSettings.SortProducts.SortDir; } string imageName; string altText; if (sortDir.ToUpper() == "ASC") { imageName = "arrow_up.png"; altText = Localization.GetString("SortAscending", LocalResourceFile); } else { imageName = "arrow_down.png"; altText = Localization.GetString("SortDescending", LocalResourceFile); } btnSortDir.CommandArgument = sortDir; btnSortDir.AlternateText = altText; if (StoreSettings.PortalTemplates) { btnSortDir.ImageUrl = PortalSettings.HomeDirectory + "Store/Templates/Images/" + imageName; } else { btnSortDir.ImageUrl = TemplateSourceDirectory + "/Templates/Images/" + imageName; } btnSortDir.Click += btnSortDir_Click; if (_productList.Count == 0) { btnSortDir.Enabled = false; } lblSortBy.Controls.Add(btnSortDir); return(lblSortBy); } return(null); default: LiteralControl litText = new LiteralControl(tokenName); return(litText); } }
protected void Page_Load(object sender, EventArgs e) { _catalogNav = new CatalogNavigation(Request.QueryString); _imagesPath = _templatePath + "Images/"; if (!string.IsNullOrEmpty(StoreSettings.CurrencySymbol)) { _localFormat.CurrencySymbol = StoreSettings.CurrencySymbol; } ITaxProvider taxProvider = StoreController.GetTaxProvider(StoreSettings.TaxName); ITaxInfo taxInfo = taxProvider.GetDefautTaxRates(PortalId); _defaultTaxRate = taxInfo.DefaultTaxRate; _showTax = taxInfo.ShowTax; _product = (DataSource as ProductInfo); if (_product != null) { _category = _categoryControler.GetCategory(PortalId, _product.CategoryID); if (StoreSettings.SEOFeature) { _catalogNav.Category = _category.SEOName; if (InList == false) { BasePage.Title = SEO(Localization.GetString("DetailsSEOTitle", LocalResourceFile), MetaTags.Title); BasePage.Description = SEO(Localization.GetString("DetailsSEODescription", LocalResourceFile), MetaTags.Description); BasePage.KeyWords = SEO(Localization.GetString("DetailsSEOKeywords", LocalResourceFile), MetaTags.Keywords); CatalogNavigation canonical = new CatalogNavigation { CategoryID = _product.CategoryID, ProductID = _product.ProductID }; string domain = Request.Url.GetLeftPart(UriPartial.Authority); string url = canonical.GetNavigationUrl(); if (url.StartsWith(domain, true, CultureInfo.CurrentCulture) == false) { url = domain + url; } HeaderHelper.AddCanonicalLink(Page, url); } } plhDetails.Controls.Add(TemplateController.ParseTemplate(MapPath(_templatePath), _template, Localization.GetString("TemplateError", LocalSharedResourceFile), IsLogged, new ProcessTokenDelegate(ProcessToken))); } // Clear error message divError.Visible = false; // Show review panel ? if (ShowReviews && !InList) { int reviewID = _catalogNav.ReviewID; // Show review list or edit? if (reviewID != Null.NullInteger) { if (reviewID > 0 && !CanManageReviews()) { _catalogNav.ReviewID = Null.NullInteger; Response.Redirect(_catalogNav.GetNavigationUrl()); } else { LoadReviewEditControl(); } } else { LoadReviewListControl(); } pnlReviews.Visible = true; } else { pnlReviews.Visible = false; } // Show Return link? if (InList == false) { if (_catalogNav.SearchID == Null.NullInteger) { if (_catalogNav.CategoryID == Null.NullInteger) { lnkReturn.Text = Localization.GetString("lnkReturnToCatalog", LocalResourceFile); } else { lnkReturn.Text = Localization.GetString("lnkReturn", LocalResourceFile); } } else { lnkReturn.Text = Localization.GetString("lnkReturnToSearch", LocalResourceFile); } lnkReturn.NavigateUrl = GetReturnUrl(ReturnPage); pnlReturn.Visible = true; } else { pnlReturn.Visible = false; } }
void IHttpHandler.ProcessRequest(HttpContext context) { PortalSettings portalSettings = PortalController.Instance.GetCurrentPortalSettings(); UserInfo user = (UserInfo)context.Items["UserInfo"]; if (user != null && user.UserID != Null.NullInteger) { // Init params int currentUserID = user.UserID; int portalID = portalSettings.PortalId; string key = context.Request.QueryString["KEY"]; key = SymmetricHelper.Decrypt(key); string[] values = key.Split(','); int orderDetailID = int.Parse(values[0]); int userID = int.Parse(values[1]); ProductInfo product = null; // Get the requested order detail row OrderController orderControler = new OrderController(); OrderDetailInfo orderDetail = orderControler.GetOrderDetail(orderDetailID); if (orderDetail != null) { // Get the corresponding product ProductController productControler = new ProductController(); product = productControler.GetProduct(portalID, orderDetail.ProductID); } // If user authentication and product are valid if (currentUserID == userID && product != null) { // Is download allowed? if (product.AllowedDownloads == Null.NullInteger || orderDetail.Downloads < product.AllowedDownloads) { // Update download counter then download file int downloads = orderDetail.Downloads; if (downloads == Null.NullInteger) { downloads = 1; } else { downloads += 1; } orderControler.UpdateOrderDetail(orderDetail.OrderDetailID, orderDetail.OrderID, orderDetail.ProductID, orderDetail.Quantity, orderDetail.UnitCost, orderDetail.RoleID, downloads); IFileInfo file = FileManager.Instance.GetFile(product.VirtualFileID); FileManager.Instance.WriteFileToResponse(file, ContentDisposition.Attachment); } // The following code is NEVER reached when download succeed! } // Redirect to the product detail page or the store page StoreInfo storeInfo = StoreController.GetStoreInfo(portalSettings.PortalId); CatalogNavigation catNav = new CatalogNavigation { TabID = storeInfo.StorePageID }; if (product != null) { catNav.CategoryID = product.CategoryID; catNav.ProductID = product.ProductID; } context.Response.Redirect(catNav.GetNavigationUrl()); } else { // Try to authenticate the user then retry download string returnUrl = context.Request.RawUrl; int posReturn = returnUrl.IndexOf("?returnurl="); if (posReturn != Null.NullInteger) { returnUrl = returnUrl.Substring(0, posReturn); } returnUrl = "returnurl=" + context.Server.UrlEncode(returnUrl); if (portalSettings.LoginTabId != Null.NullInteger && context.Request["override"] == null) { context.Response.Redirect(Globals.NavigateURL(portalSettings.LoginTabId, "", returnUrl), true); } else { if (portalSettings.HomeTabId != Null.NullInteger) { context.Response.Redirect(Globals.NavigateURL(portalSettings.HomeTabId, "Login", returnUrl), true); } else { context.Response.Redirect(Globals.NavigateURL(portalSettings.ActiveTab.TabID, "Login", returnUrl), true); } } } }