Esempio n. 1
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // Get the navigation settings
                _nav = new CatalogNavigation(Request.QueryString);

                if (_nav.ProductID != Null.NullInteger)
                {
                    ProductEdit productEdit = (ProductEdit)LoadControl(ModulePath + "ProductEdit.ascx");
                    productEdit.DataSource = _nav.ProductID;
                    productEdit.EditComplete += new EventHandler(editControl_EditComplete);

                    plhControls.Controls.Add(productEdit);
                }
                else if (_nav.CategoryID != Null.NullInteger)
                {
                    CategoryEdit categoryEdit = (CategoryEdit)LoadControl(ModulePath + "CategoryEdit.ascx");
                    categoryEdit.DataSource = _nav.CategoryID;
                    categoryEdit.EditComplete += new EventHandler(editControl_EditComplete);

                    plhControls.Controls.Add(categoryEdit);
                }
            }
            catch(Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Esempio n. 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Get the navigation settings
                _nav = new CatalogNavigation(Request.QueryString);

                if (_nav.Edit.ToLower() == "product")
                {
                    ProductEdit productEdit = (ProductEdit)LoadControl(ControlPath + "ProductEdit.ascx");
                    productEdit.ID            = "ProductEdit";
                    productEdit.DataSource    = _nav.ProductID;
                    productEdit.EditComplete += editControl_EditComplete;

                    plhControls.Controls.Add(productEdit);
                }
                else if (_nav.Edit.ToLower() == "category")
                {
                    CategoryEdit categoryEdit = (CategoryEdit)LoadControl(ControlPath + "CategoryEdit.ascx");
                    categoryEdit.ID            = "CategoryEdit";
                    categoryEdit.DataSource    = _nav.CategoryID;
                    categoryEdit.EditComplete += editControl_EditComplete;

                    plhControls.Controls.Add(categoryEdit);
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Esempio n. 3
0
 override protected void OnInit(EventArgs e)
 {
     if (StoreSettings != null)
     {
         _settings     = new ModuleSettings(ModuleId, TabId);
         _catalogTabID = _settings.CategoryMenu.CatalogPage;
         if (_catalogTabID <= 0)
         {
             _catalogTabID = StoreSettings.StorePageID;
         }
         _categoryNav = new CatalogNavigation
         {
             TabID = _catalogTabID
         };
         _categoryController = new CategoryController();
         _parentCategories   = new List <CategoryInfo>();
         if (_settings.CategoryMenu.DisplayMode == "T")
         {
             MyList.Visible        = true;
             MyList.ItemDataBound += MyList_ItemDataBound;
             MyList.ItemCommand   += MyList_ItemCommand;
         }
         else
         {
             MyList.Visible = false;
         }
     }
     base.OnInit(e);
 }
Esempio n. 4
0
        private void EditCategory(string categoryID)
        {
            CatalogNavigation editNav = new CatalogNavigation
            {
                Edit       = "Category",
                CategoryID = int.Parse(categoryID)
            };

            Response.Redirect(editNav.GetEditUrl(ModuleId));
        }
Esempio n. 5
0
        //*******************************************************
        //
        // The Page_Load event on this user control is used to obtain
        // from a database a list of reviews about a specified
        // product and then databind it to an asp:datalist control.
        //
        //*******************************************************
        protected void Page_Load(object sender, EventArgs e)
        {
            // Obtain and databind a list of all reviews of a product

            // Obtain ProductID from Page State
            _nav = new CatalogNavigation(Request.QueryString);

            ReviewController controller = new ReviewController();
            lstReviews.DataSource = controller.GetReviewsByProduct(PortalId, _nav.ProductID, ReviewController.StatusFilter.Approved);
            lstReviews.DataBind();
        }
Esempio n. 6
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Obtain and databind a list of all reviews of a product

            // Obtain ProductID from Page State
            _nav = new CatalogNavigation(Request.QueryString);

            ReviewController controller = new ReviewController();

            lstReviews.DataSource = controller.GetReviewsByProduct(PortalId, _nav.ProductID, ReviewController.StatusFilter.Approved);
            lstReviews.DataBind();
        }
Esempio n. 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            _imagesPath = _templatePath + "Images/";

            if (!string.IsNullOrEmpty(StoreSettings.CurrencySymbol))
            {
                _localFormat.CurrencySymbol = StoreSettings.CurrencySymbol;
            }

            _moduleNav = new CatalogNavigation(Request.QueryString);

            //0 indicates that no detail page is being used, so use current tabid
            if (DetailPage == 0)
            {
                DetailPage = TabId;
            }

            if (_moduleNav.PageIndex == Null.NullInteger)
            {
                _moduleNav.PageIndex = 1;
            }

            // Get the product data
            _productList = (DataSource as List <ProductInfo>);

            if (_containerTemplate == string.Empty)
            {
                Controls.Add(TemplateController.ParseTemplate(MapPath(_templatePath), "ListContainer.htm", Localization.GetString("TemplateError", LocalSharedResourceFile), IsLogged, new ProcessTokenDelegate(ProcessToken)));
            }
            else
            {
                Controls.Add(TemplateController.ParseTemplate(MapPath(_templatePath), _containerTemplate, Localization.GetString("TemplateError", LocalSharedResourceFile), IsLogged, new ProcessTokenDelegate(ProcessToken)));
            }

            if (ListType == ProductListTypes.Category || ListType == ProductListTypes.SearchResults)
            {
                BindPagedData();
            }
            else
            {
                if (_lstProducts != null)
                {
                    _lstProducts.DataSource = _productList;
                    _lstProducts.DataBind();
                }
                else
                {
                    _rlProducts.DataSource = _productList;
                    _rlProducts.DataBind();
                }
            }
        }
Esempio n. 8
0
        protected void btnEdit_Click(object sender, ImageClickEventArgs e)
        {
            ImageButton button = (sender as ImageButton);

            if (button != null)
            {
                CatalogNavigation editNav = new CatalogNavigation(ModuleId, Request.QueryString)
                {
                    ProductID = int.Parse(button.CommandArgument),
                    Edit      = "Product"
                };
                Response.Redirect(editNav.GetEditUrl());
            }
        }
Esempio n. 9
0
        private void AddToCart(int productID, int quantity, bool buyNow)
        {
            if (StoreSettings.InventoryManagement && StoreSettings.AvoidNegativeStock)
            {
                ProductController controler      = new ProductController();
                ProductInfo       currentProduct = controler.GetProduct(PortalId, productID);

                if (currentProduct.StockQuantity < quantity)
                {
                    lblError.Text    = Localization.GetString("DetaiNotEnoughProductslsSEOTitle", LocalResourceFile);
                    divError.Visible = true;
                    return;
                }
            }
            CurrentCart.AddItem(PortalId, StoreSettings.SecureCookie, productID, quantity);
            if (buyNow)
            {
                _catalogNav = new CatalogNavigation
                {
                    TabID = StoreSettings.ShoppingCartPageID
                };
            }
            Response.Redirect(_catalogNav.GetNavigationUrl());
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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);
                }
            }
        }
Esempio n. 12
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // Load utility objects
                _nav = new CatalogNavigation(Request.QueryString);
                _nav.ProductID = Null.NullInteger;	//Product should not be displayed!
                if (_nav.CategoryID == 0)
                {
                    _nav.CategoryID = Null.NullInteger;
                }

                //Get category and parent category data
                CategoryController categoryController = new CategoryController();
                selectedCategoryID = _nav.CategoryID;
                if (selectedCategoryID != Null.NullInteger)
                {
                    CategoryInfo category = categoryController.GetCategory(selectedCategoryID);
                    parentCategories.Add(category);
                    if (category.CategoryID != category.ParentCategoryID)
                    {
                        while (category.ParentCategoryID != Null.NullInteger)
                        {
                            category = categoryController.GetCategory(category.ParentCategoryID);
                            parentCategories.Add(category);
                            foreach (CategoryInfo cat in parentCategories)
                            {
                                if (cat.CategoryID == category.CategoryID)
                                {
                                    //Cyclical categories found
                                    break;
                                }
                            }
                        }
                    }
                }
                if (parentCategories.Count > 0)
                {
                    parentCategories.Reverse();
                }

                if (storeInfo == null)
                {
                    StoreController storeController = new StoreController();
                    storeInfo = storeController.GetStoreInfo(PortalId);
                    if (storeInfo.PortalTemplates)
                    {
                        CssTools.AddCss(this.Page, PortalSettings.HomeDirectory + "Store", PortalId);
                    }
                    else
                    {
                        CssTools.AddCss(this.Page, this.TemplateSourceDirectory, PortalId);
                    }
                }

                _settings = new ModuleSettings(this.ModuleId, this.TabId);
                // Databind to list of categories
                CategoryController controller = new CategoryController();
                ArrayList categoryList = controller.GetCategories(this.PortalId, false, -2);
                MyList.RepeatColumns = int.Parse(_settings.CategoryMenu.ColumnCount);
                MyList.DataSource = categoryList;
                MyList.DataBind();

                //MyList.SelectedIndex = GetSelectedIndex();
            }
            catch(Exception ex)
            {
                if (ex.InnerException != null)
                {
                    Exceptions.ProcessModuleLoadException(this, ex.InnerException);
                }
                else
                {
                    string ErrorSettings = Localization.GetString("ErrorSettings", this.LocalResourceFile);
                    Exceptions.ProcessModuleLoadException(ErrorSettings, this, ex, true);
                }
            }
        }
Esempio n. 13
0
        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 = "&nbsp;&nbsp;"
                    };

                    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);
            }
        }
Esempio n. 14
0
        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;
            }
        }
Esempio n. 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (storeInfo == null)
            {
                StoreController storeController = new StoreController();
                storeInfo = storeController.GetStoreInfo(PortalId);
                if (storeInfo.PortalTemplates)
                {
                    templatesPath = PortalSettings.HomeDirectoryMapPath + "Store\\";
                    imagesPath = PortalSettings.HomeDirectory + "Store/Templates/Images/";
                }
                else
                {
                    //templatesPath = MapPath(ModulePath) + "\\";
                    templatesPath = MapPath(ModulePath);
                    imagesPath = parentControl.ModulePath + "Templates/Images/";
                }
            }

            if (storeInfo.CurrencySymbol != string.Empty)
            {
                LocalFormat.CurrencySymbol = storeInfo.CurrencySymbol;
            }

            moduleNav = new CatalogNavigation(Request.QueryString);

            //0 indicates that no detail page is being used, so use current tabid
            if (this.DetailPage == 0)
            {
                this.DetailPage = this.TabId;
            }
            moduleNav.TabId = this.DetailPage;

            if (moduleNav.PageIndex == Null.NullInteger)
            {
                moduleNav.PageIndex = 1;
            }

            if (containerTemplate == string.Empty)
            {
                this.Controls.Add(TemplateController.ParseTemplate(templatesPath, "ListContainer.htm", new ProcessTokenDelegate(processToken)));
            }
            else
            {
                this.Controls.Add(TemplateController.ParseTemplate(templatesPath, containerTemplate, new ProcessTokenDelegate(processToken)));
            }
            if (lstProducts != null) BindData();
        }
Esempio n. 16
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (StoreSettings != null)
            {
                try
                {
                    // Load utility objects
                    _nav = new CatalogNavigation(Request.QueryString)
                    {
                        ProductID = Null.NullInteger    //Product should not be displayed!
                    };
                    if (_nav.CategoryID == 0)
                    {
                        _nav.CategoryID = Null.NullInteger;
                    }

                    // Get selected category and parent categories (if any)
                    _selectedCategoryID = _nav.CategoryID;
                    if (_selectedCategoryID != Null.NullInteger && _settings.CategoryMenu.DisplayMode == "T")
                    {
                        CategoryInfo category = _categoryController.GetCategory(PortalId, _selectedCategoryID);
                        _parentCategories.Add(category);
                        if (category.CategoryID != category.ParentCategoryID)
                        {
                            while (category.ParentCategoryID != Null.NullInteger)
                            {
                                category = _categoryController.GetCategory(PortalId, category.ParentCategoryID);
                                _parentCategories.Add(category);
                                foreach (CategoryInfo cat in _parentCategories)
                                {
                                    if (cat.CategoryID == category.CategoryID)
                                    {
                                        //Cyclical categories found
                                        break;
                                    }
                                }
                            }
                        }
                    }

                    if (_parentCategories.Count > 0)
                    {
                        _parentCategories.Reverse();
                    }

                    string templatePath = CssTools.GetTemplatePath(this, StoreSettings.PortalTemplates);
                    CssTools.AddCss(Page, templatePath, StoreSettings.StyleSheet);

                    if (_settings.CategoryMenu.DisplayMode == "T")
                    {
                        // Databind to list of categories
                        List <CategoryInfo> categoryList = _categoryController.GetCategories(PortalId, false, -2);
                        MyList.RepeatColumns = _settings.CategoryMenu.ColumnCount;
                        MyList.DataSource    = categoryList;
                        MyList.DataBind();
                    }
                    else
                    {
                        Control ulMenu = CreateULMenu(-2, 0);
                        if (ulMenu != null)
                        {
                            divStoreMenu.Controls.Add(ulMenu);
                        }
                    }
                }
                catch (Exception ex)
                {
                    if (ex.InnerException != null)
                    {
                        Exceptions.ProcessModuleLoadException(this, ex.InnerException);
                    }
                    else
                    {
                        Exceptions.ProcessModuleLoadException(this, ex);
                    }
                }
            }
            else
            {
                if (UserInfo.IsSuperUser)
                {
                    string errorSettings        = Localization.GetString("ErrorSettings", LocalResourceFile);
                    string errorSettingsHeading = Localization.GetString("ErrorSettingsHeading", LocalResourceFile);
                    UI.Skins.Skin.AddModuleMessage(this, errorSettingsHeading, errorSettings, UI.Skins.Controls.ModuleMessage.ModuleMessageType.YellowWarning);
                }
                else
                {
                    MyList.Visible = false;
                }
            }
        }
Esempio n. 17
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            /*
            Response.Write("<br>Page_load2 ");
            if (Page.IsPostBack)
                Response.Write("<br>Postback2 ");
            */

            /*
            if (Page.IsPostBack)
            {
                labelLog.Text = labelLog.Text + "<br>Page load PostBack" + DateTime.Now.ToString();
                int cat1 = -1;
                int.TryParse(DropDownList1.SelectedValue, out cat1);
                int cat2 = -1;
                int.TryParse(DropDownList2.SelectedValue, out cat2);
                labelLog.Text = labelLog.Text + "<br>dd1: " + cat1.ToString() + " dd2: " + cat2.ToString() + DateTime.Now.ToString();
            }
            else
            {
                labelLog.Text = labelLog.Text + "<br>Page load - Not a PostBack" + DateTime.Now.ToString();
            } */
                //Response.Write("Page_PreRender");

                npTitle = Localization.GetString("NPTitle.Text", this.LocalResourceFile);
                fpTitle = Localization.GetString("FPTitle.Text", this.LocalResourceFile);
                ppTitle = Localization.GetString("PPTitle.Text", this.LocalResourceFile);
                cpTitle = Localization.GetString("CPTitle.Text", this.LocalResourceFile);

                try
                {
                    if (storeInfo == null)
                    {
                        StoreController storeController = new StoreController();
                        storeInfo = storeController.GetStoreInfo(PortalId);
                        if (storeInfo.PortalTemplates)
                        {
                            templatesPath = PortalSettings.HomeDirectoryMapPath + "Store\\";
                            CssTools.AddCss(this.Page, PortalSettings.HomeDirectory + "Store", PortalId);
                        }
                        else
                        {
                            templatesPath = MapPath(ModulePath) + "\\";
                            CssTools.AddCss(this.Page, this.TemplateSourceDirectory, PortalId);
                        }
                    }

                    moduleSettings = new ModuleSettings(this.ModuleId, this.TabId);

                    catalogNav = new CatalogNavigation(Request.QueryString);

                    if (catalogNav.CategoryID == Null.NullInteger)
                    {
                        if (bool.Parse(moduleSettings.General.UseDefaultCategory))
                        {
                            catalogNav.CategoryID = int.Parse(moduleSettings.General.DefaultCategoryID);
                        }
                    }

                    if (catalogNav.ProductID != Null.NullInteger)
                    {
                        ProductController productController = new ProductController();
                        productInfo = productController.GetProduct(catalogNav.ProductID);
                        catalogNav.CategoryID = productInfo.CategoryID;
                    }

                    if (catalogNav.CategoryID != Null.NullInteger)
                    {
                        CategoryController categoryController = new CategoryController();
                        categoryInfo = categoryController.GetCategory(catalogNav.CategoryID);
                    }

                    this.Controls.Add(TemplateController.ParseTemplate(templatesPath, moduleSettings.General.Template, new ProcessTokenDelegate(processToken)));

                    // Canadean changed: added current categoryid on a hidden dropdown, to use on the cascade categories
                    /*
                    if (catalogNav.CategoryID != Null.NullInteger)
                    {
                        ddHidden.Items.Add(new ListItem(catalogNav.CategoryID.ToString(), catalogNav.CategoryID.ToString()));
                    }
                    */

                }
                catch (Exception ex)
                {
                    string ErrorSettings = Localization.GetString("ErrorSettings", this.LocalResourceFile);
                    Response.Write("<br>" + ex.Message);
                    Response.Write("<br>" + ex.StackTrace);

                    //Exceptions.ProcessModuleLoadException(ErrorSettings, this, ex, true);
                }
                if (DotNetNuke.Framework.AJAX.IsInstalled())
                {
                    DotNetNuke.Framework.AJAX.RegisterScriptManager();
                }

            //}
        }
Esempio n. 18
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                // Get the navigation settings
                _nav = new CatalogNavigation(Request.QueryString)
                {
                    ProductID = (int)DataSource
                };

                // Handle ProductID=0 as Null.NullInteger
                if (_nav.ProductID == 0)
                {
                    _nav.ProductID = Null.NullInteger;
                }

                if (Page.IsPostBack == false)
                {
                    // Get category list
                    CategoryController  categoryController = new CategoryController();
                    List <CategoryInfo> categories         = categoryController.GetCategoriesPath(PortalId, true, Null.NullInteger);

                    // If no category exists, display a warning message
                    if (categories == null || categories.Count == 0)
                    {
                        pnlCategoriesRequired.Visible = true;
                        tblProductForm.Visible        = false;
                    }
                    else
                    {
                        pnlCategoriesRequired.Visible = false;
                        // Bind categories and add 'select' choice to the dropdown
                        cmbCategory.DataSource = categories;
                        cmbCategory.DataBind();
                        cmbCategory.Items.Insert(0, new ListItem(Localization.GetString("SelectComboValue", LocalResourceFile), "-1"));

                        // Allowed file extentions
                        imgProduct.FileFilter = "bmp,png,jpg,jpeg,gif";

                        // Are we editing or creating new item?
                        if (_nav.ProductID != Null.NullInteger || _copyFrom != Null.NullInteger)
                        {
                            ProductController controller = new ProductController();
                            ProductInfo       product    = controller.GetProduct(PortalId, _nav.ProductID == Null.NullInteger ? _copyFrom : _nav.ProductID);

                            if (product != null)
                            {
                                if (_copyFrom == Null.NullInteger)
                                {
                                    // Set delete confirmation
                                    cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");
                                    cmdDelete.Visible = true;
                                }
                                // Define fields values
                                cmbCategory.SelectedValue = product.CategoryID.ToString();
                                txtManufacturer.Text      = product.Manufacturer;
                                txtModelNumber.Text       = product.ModelNumber;
                                txtModelName.Text         = product.ModelName;
                                if (StoreSettings.SEOFeature)
                                {
                                    txtSEOName.Text  = product.SEOName;
                                    txtKeywords.Text = product.Keywords;
                                }
                                else
                                {
                                    trSEOName.Visible  = false;
                                    trKeywords.Visible = false;
                                }
                                txtSummary.Text      = product.Summary;
                                txtRegularPrice.Text = product.RegularPrice.ToString("0.00");
                                txtUnitPrice.Text    = product.UnitCost.ToString("0.00");
                                if (StoreSettings.CheckoutMode == CheckoutType.Registred && StoreSettings.AllowVirtualProducts)
                                {
                                    chkVirtualProduct.Checked = product.IsVirtual;
                                }
                                else
                                {
                                    trVirtualProduct.Visible = false;
                                }
                                if (chkVirtualProduct.Checked)
                                {
                                    trVirtualProductSection.Visible = true;
                                    trProductDimensions.Visible     = false;
                                    if (product.VirtualFileID == Null.NullInteger)
                                    {
                                        urlProductFile.UrlType = "N";
                                    }
                                    else
                                    {
                                        urlProductFile.Url     = "FileID=" + product.VirtualFileID;
                                        urlProductFile.UrlType = "F";
                                    }
                                    txtAllowedDownloads.Text = product.AllowedDownloads.ToString();
                                }
                                else
                                {
                                    trVirtualProductSection.Visible = false;
                                    trProductDimensions.Visible     = true;
                                    txtUnitWeight.Text = product.ProductWeight == Null.NullDecimal ? string.Empty : product.ProductWeight.ToString("0.00");
                                    txtUnitHeight.Text = product.ProductHeight == Null.NullDecimal ? string.Empty : product.ProductHeight.ToString("0.00");
                                    txtUnitLength.Text = product.ProductLength == Null.NullDecimal ? string.Empty : product.ProductLength.ToString("0.00");
                                    txtUnitWidth.Text  = product.ProductWidth == Null.NullDecimal ? string.Empty : product.ProductWidth.ToString("0.00");
                                }
                                if (StoreSettings.InventoryManagement)
                                {
                                    txtStockQuantity.Text = product.StockQuantity.ToString();
                                    txtLowThreshold.Text  = product.LowThreshold.ToString();
                                    txtHighThreshold.Text = product.HighThreshold.ToString();
                                    txtDeliveryTime.Text  = product.DeliveryTime.ToString();
                                    txtPurchasePrice.Text = product.PurchasePrice.ToString("0.00");
                                }
                                else
                                {
                                    trStockManagement.Visible = false;
                                }
                                chkArchived.Checked = product.Archived;

                                LoadRole(product.RoleID);

                                bool isFeatured = product.Featured;
                                chkFeatured.Checked   = isFeatured;
                                trFeatured.Visible    = isFeatured;
                                txtSalePrice.Text     = product.SalePrice == Null.NullDecimal ? string.Empty : product.SalePrice.ToString("0.00");
                                txtSaleStartDate.Text = product.SaleStartDate != Null.NullDate ? product.SaleStartDate.ToString("d") : "";
                                txtSaleEndDate.Text   = product.SaleEndDate != Null.NullDate ? product.SaleEndDate.ToString("d") : "";
                                if (isFeatured)
                                {
                                    MakeCalendars();
                                }

                                if (string.IsNullOrEmpty(product.ProductImage) == false)
                                {
                                    if (product.ProductImage.StartsWith("http://") || product.ProductImage.StartsWith("https://"))
                                    {
                                        imgProduct.Url     = product.ProductImage;
                                        imgProduct.UrlType = "U";
                                    }
                                    else
                                    {
                                        imgProduct.Url     = FileSystemHelper.GetUrlFileID(product.ProductImage, PortalSettings);
                                        imgProduct.UrlType = "F";
                                    }
                                }
                                txtDescription.Text = product.Description;
                            }
                            else
                            {
                                // Handle as new item
                                PrepareNew();
                            }
                        }
                        else
                        {
                            // Handle as new item
                            PrepareNew();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Esempio n. 19
0
        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);
                    }
                }
            }
        }
Esempio n. 20
0
        protected void Page_Load(object sender, System.EventArgs e)
        {
            try
            {
                // Get the navigation settings
                _nav = new CatalogNavigation(Request.QueryString);
                _nav.ProductID = (int)dataSource;

                // Handle ProductID=0 as Null.NullInteger
                if (_nav.ProductID == 0)
                {
                    _nav.ProductID = Null.NullInteger;
                }

                if (!Page.IsPostBack)
                {
                    // Load category list
                    CategoryController categoryController = new CategoryController();
                    cmbCategory1.DataSource = categoryController.GetCategoriesPath(this.PortalId, true, 4);
                    cmbCategory1.DataBind();
                    cmbCategory2.DataSource = categoryController.GetCategoriesPath(this.PortalId, true, 10);
                    cmbCategory2.DataBind();
                    cmbCategory3.DataSource = categoryController.GetCategoriesPath(this.PortalId, true, 18);
                    cmbCategory3.DataBind();

                    // Set delete confirmation
                    cmdDelete.Attributes.Add("onClick", "javascript:return confirm('" + Localization.GetString("DeleteItem") + "');");

                    // Are we editing or creating new item?
                    if (_nav.ProductID != Null.NullInteger)
                    {
                        ProductController controller = new ProductController();
                        ProductInfo product = controller.GetProduct(_nav.ProductID);

                        if (product != null)
                        {
                            cmdDelete.Visible = true;
                            //txtManufacturer.Text		    = product.Manufacturer;
                            txtModelName.Text			    = product.ModelName;
                            txtModelNumber.Text			    = product.ModelNumber;
                            txtSummary.Text                 = product.Summary;
                            //txtSummary2.Text                = product.Summary;
                            txtUnitPrice.Text			    = product.UnitCost.ToString("0.00");
                            tbPriceStr.Text                 = product.PriceStr;

                            /*
                            image1.FileFilter = "bmp,png,jpg,jpeg,gif";
                            image1.ShowDatabase = true;
                            image1.ShowFiles = true;
                            image1.ShowLog = false;
                            image1.ShowNewWindow = false;
                            image1.ShowNone = true;
                            image1.ShowSecure = true;
                            image1.ShowTabs = false;
                            image1.ShowTrack = false;
                            image1.ShowUpLoad = true;
                            image1.ShowUrls = true;
                            image1.ShowUsers = false;
                            */
                            /*PrepareImage(image1);

                            if (product.ProductImage.StartsWith("http://"))
                            {
                                image1.UrlType = "U";
                            }
                            else
                            {
                                image1.UrlType = "F";
                            }
                            image1.Url = product.ProductImage;
                            */

                            //cmbCategory.SelectedValue       = product.CategoryID.ToString();
                            cmbCategory1.SelectedValue      = product.CategoryID1.ToString();
                            cmbCategory2.SelectedValue      = product.CategoryID2.ToString();
                            cmbCategory3.SelectedValue      = product.CategoryID3.ToString();
                            txtNumPages.Text                = product.NumPages.ToString();

                            //System.Web.UI.WebControls.Calendar calPublishDate;

                            //calPublishDate.SelectedDate     = product.PublishDate == Null.NullDate ? Null.NullDate : product.PublishDate;
                            ///calPublishDate.SelectedDate     = product.PublishDate;
                            ///calPublishDate.VisibleDate      = product.PublishDate;
                            tbPublishDate.Text              = product.PublishDate.ToString("dd/MM/yyyy");
                            //Response.Write(product.PublishDate.ToString());

                            chkArchived.Checked			    = product.Archived;
                            //chkFeatured.Checked			    = product.Featured;
                            txtDescription.Text = product.Description;
                            txtDescriptionTwo.Text = product.DescriptionTwo;
                            txtDescriptionThree.Text = product.DescriptionThree;
                            tbDescriptionTag.Text = product.DescriptionTag;
                            txtTOC_Html.Text = product.TOC_Html;
                            //txtTOC_Html.Text = RemoveHTML( product.Description );

                            //Response.Write("<br>before {" + product.ProductFile + "}{" + file1.Url + "}");
                            file1 = PrepareFile(file1);
                            if (product.ProductFile == Null.NullString) product.ProductFile = "_no_report_file_available.pdf";
                            SetFileUrl(file1, "products654654/", product.ProductFile);
                            //Response.Write("<br>after {" + product.ProductFile + "}{" + file1.Url + "}");

                            //Response.Write("<br>preview before {" + product.ProductPreview + "}{" + preview1.Url + "}");
                            preview1 = PrepareFile(preview1);
                            if (product.ProductPreview == Null.NullString) product.ProductPreview = "_no_report_file_available.pdf";
                            SetFileUrl(preview1, "documents/", product.ProductPreview);
                            //Response.Write("<br>preview after {" + product.ProductPreview + "}{" + preview1.Url + "}");

                            tbFile1.Text = product.ProductFile;
                            tbPreview1.Text = product.ProductPreview;

                            //txtDescription2.Text            = product.Description;
                            //txtUnitWeight.Text              = product.ProductWeight == Null.NullDecimal ? string.Empty : product.ProductWeight.ToString("0.00");
                            //txtUnitHeight.Text              = product.ProductHeight == Null.NullDecimal ? string.Empty : product.ProductHeight.ToString("0.00");
                            //txtUnitLength.Text              = product.ProductLength == Null.NullDecimal ? string.Empty : product.ProductLength.ToString("0.00");
                            //txtUnitWidth.Text               = product.ProductWidth == Null.NullDecimal ? string.Empty : product.ProductWidth.ToString("0.00");
                            calSaleStartDate.SelectedDate   = product.SaleStartDate == Null.NullDate ? Null.NullDate : product.SaleStartDate;
                            calSaleEndDate.SelectedDate     = product.SaleEndDate == Null.NullDate ? Null.NullDate : product.SaleEndDate;
                            txtSalePrice.Text               = product.SalePrice == Null.NullDecimal ? string.Empty : product.SalePrice.ToString("0.00");

                            //Response.Write("AvailableONlie: " + product.AvailableOnline);
                            chkAvailableOnline.Checked = product.AvailableOnline;

                            if (calSaleStartDate.SelectedDate != Null.NullDate)
                            {
                                calSaleStartDate.VisibleDate = calSaleStartDate.SelectedDate;
                            }

                            if (calSaleEndDate.SelectedDate != Null.NullDate)
                            {
                                calSaleEndDate.VisibleDate = calSaleEndDate.SelectedDate;
                            }

                            Session["ok"] = true;
                        }
                        else
                        {
                            // Handle as new item
                            PrepareNew();
                        }
                    }
                    else
                    {
                        // Handle as new item
                        PrepareNew();
                    }
                }

            }
            catch(Exception ex)
            {
                Response.Write(ex.Message);
                Response.Write(ex.StackTrace);
                Response.Write(ex.InnerException);
                Response.Write(ex.GetBaseException().Message);

                // Exceptions.ProcessModuleLoadException(this, ex);
            }
        }