// Populate the controls
    private void PopulateControls()
    {
        // Retrieve product details and category details from database
        ECommerce.CdShop.Entity.Product productDetails = CatalogAccess.GetProductDetails(currentProductId);
        Category categoryDetails = categoryDao.Find(currentCategoryId);

        // Set up labels and images
        productNameLabel.Text = productDetails.Name;
        image1.ImageUrl       = Link.ToProductImage(productDetails.Thumbnail);
        image2.ImageUrl       = Link.ToProductImage(productDetails.Image);
        // Link to department
        catLink.Text        = categoryDetails.Name;
        catLink.NavigateUrl = "AdminCategories.aspx?DepartmentID=" + currentDepartmentId;
        // Clear form
        categoriesLabel.Text = "";
        categoriesListAssign.Items.Clear();
        categoriesListMove.Items.Clear();
        categoriesListRemove.Items.Clear();
        // Fill categoriesLabel and categoriesListRemove with data
        string    categoryId, categoryName;
        DataTable productCategories = CatalogAccess.GetCategoriesWithProduct(currentProductId);

        for (int i = 0; i < productCategories.Rows.Count; i++)
        {
            // obtain category id and name
            categoryId   = productCategories.Rows[i]["Id"].ToString();
            categoryName = productCategories.Rows[i]["Name"].ToString();
            // add a link to the category admin page
            categoriesLabel.Text +=
                (categoriesLabel.Text == "" ? "" : ", ") +
                "<a href='AdminProducts.aspx?DepartmentID=" +
                CatalogAccess.GetCategoryDetails(currentCategoryId).DepartmentId +
                "&CategoryID=" + categoryId + "'>" +
                categoryName + "</a>";
            // populate the categoriesListRemove combo box
            categoriesListRemove.Items.Add(new ListItem(categoryName, categoryId));
        }
        // Delete from catalog or remove from category?
        if (productCategories.Rows.Count > 1)
        {
            deleteButton.Visible = false;
            removeButton.Enabled = true;
        }
        else
        {
            deleteButton.Visible = true;
            removeButton.Enabled = false;
        }
        // Fill categoriesListMove and categoriesListAssign with data
        productCategories = CatalogAccess.GetCategoriesWithoutProduct(currentProductId);
        for (int i = 0; i < productCategories.Rows.Count; i++)
        {
            // obtain category id and name
            categoryId   = productCategories.Rows[i]["Id"].ToString();
            categoryName = productCategories.Rows[i]["Name"].ToString();
            // populate the list boxes
            categoriesListAssign.Items.Add(new ListItem(categoryName, categoryId));
            categoriesListMove.Items.Add(new ListItem(categoryName, categoryId));
        }
    }
 protected void upload2Button_Click(object sender, EventArgs e)
 {
     // proceed with uploading only if the user selected a file
     if (image2FileUpload.HasFile)
     {
         try
         {
             string fileName = image2FileUpload.FileName;
             string location = Server.MapPath("./ProductImages/") + fileName;
             // save image to server
             image2FileUpload.SaveAs(location);
             // update database with new product details
             ECommerce.CdShop.Entity.Product pd = CatalogAccess.GetProductDetails(currentProductId);
             CatalogAccess.UpdateProduct(currentProductId, pd.Name,
                                         pd.Description, pd.Price.ToString(), pd.Thumbnail, fileName,
                                         pd.PromoDept.ToString(), pd.PromoFront.ToString());
             // reload the page
             Response.Redirect("AdminProductDetails.aspx" +
                               "?DepartmentID=" + currentDepartmentId +
                               "&CategoryID=" + currentCategoryId +
                               "&ProductID=" + currentProductId);
         }
         catch
         {
             statusLabel.Text = "Неуспешно качване на изображение 2";
         }
     }
 }
Example #3
0
    // Fill the control with data
    private void PopulateControls(ECommerce.CdShop.Entity.Product pd)
    {
        // Display product recommendations
        string productId = pd.Id.ToString();

        recommendations.LoadProductRecommendations(productId);

        // Display product details
        titleLabel.Text       = pd.Name;
        descriptionLabel.Text = pd.Description;
        priceLabel.Text       = String.Format("{0:c}", pd.Price);
        productImage.ImageUrl = "ProductImages/" + pd.Image;
        // Set the title of the page
        this.Title = CdShopConfiguration.SiteName + pd.Name;

        // obtain the attributes of the product
        DataTable attrTable = CatalogAccess.GetProductAttributes(pd.Id.ToString());
        // temp variables
        string prevAttributeName = "";
        string attributeName, attributeValue, attributeValueId;
        // current DropDown for attribute values
        Label        attributeNameLabel;
        DropDownList attributeValuesDropDown = new DropDownList();

        // read the list of attributes
        foreach (DataRow r in attrTable.Rows)
        {
            // get attribute data
            attributeName    = r["AttributeName"].ToString();
            attributeValue   = r["AttributeValue"].ToString();
            attributeValueId = r["AttributeValueID"].ToString();
            // if starting a new attribute (e.g. Color, Size)
            if (attributeName != prevAttributeName)
            {
                prevAttributeName       = attributeName;
                attributeNameLabel      = new Label();
                attributeNameLabel.Text = attributeName + ": ";
                attributeValuesDropDown = new DropDownList();
                attrPlaceHolder.Controls.Add(attributeNameLabel);
                attrPlaceHolder.Controls.Add(attributeValuesDropDown);
            }
            // add a new attribute value to the DropDownList
            attributeValuesDropDown.Items.Add(new ListItem(attributeValue, attributeValueId));
        }

        SongDao songDao        = new SongDao();
        int     productIdAsInt = int.Parse(productId);

        grid.DataSource = songDao.GetAllByProductId(productIdAsInt);
        grid.DataBind();
    }
Example #4
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Retrieve ProductID from the query string
        string productId = Request.QueryString["ProductID"];

        // Retrieves product details
        ECommerce.CdShop.Entity.Product pd = CatalogAccess.GetProductDetails(productId);
        // Does the product exist?
        if (pd.Name != null)
        {
            PopulateControls(pd);
        }
        else
        {
            Server.Transfer("~/NotFound.aspx");
        }
        // 301 redirect to the proper URL if necessary
        //Link.CheckProductUrl(Request.QueryString["ProductID"]);
    }