示例#1
0
 // upload product's second image
 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
             ProductDetails pd = CatalogBLO.GetProductDetails(currentProductId);
             CatalogBLO.UpdateProduct(currentProductId, pd.Name, pd.Description, pd.Price.ToString(), pd.Image1FileName, fileName, pd.OnDepartmentPromotion.ToString(), pd.OnCatalogPromotion.ToString());
             // reload the page
             Response.Redirect(Request.ApplicationPath + "/CatalogAdmin.aspx" +
                               "?DepartmentID=" + currentDepartmentId +
                               "&CategoryID=" + currentCategoryId +
                               "&ProductID=" + currentProductId);
         }
         catch
         {
             statusLabel.Text = "Uploading image 2 failed";
         }
     }
 }
示例#2
0
    // Fill the control with data
    private void PopulateControls()
    {
        // Retrieve ProductID from the query string
        string productId = Request.QueryString["ProductID"];
        // stores product details
        ProductDetails pd;

        // Retrieve product details
        pd = CatalogBLO.GetProductDetails(productId);
        // Display product details
        titleLabel.Text       = pd.Name;
        descriptionLabel.Text = pd.Description;
        priceLabel.Text       = String.Format("{0:c}", pd.Price);
        productImage.ImageUrl = "ProductImages/" + pd.Image2FileName;
        // Set the title of the page
        this.Title = ShopConfiguration.SiteName +
                     " : Product : " + pd.Name;
    }
示例#3
0
    // Populate the controls
    private void PopulateControls()
    {
        // Set the "go back to products" link
        goBackLink.NavigateUrl = Request.ApplicationPath +
                                 String.Format("/CatalogAdmin.aspx?DepartmentID={0}&CategoryID={1}",
                                               currentDepartmentId, currentCategoryId);
        // Retrieve product details and category details from database
        ProductDetails  productDetails  = CatalogBLO.GetProductDetails(currentProductId);
        CategoryDetails categoryDetails = CatalogBLO.GetCategoryDetails(currentCategoryId);

        // Set up labels and images
        productNameLabel.Text = productDetails.Name;
        moveLabel.Text        = "Move product from category <b>" + categoryDetails.Name + "</b> to this category: ";
        image1.ImageUrl       = Request.ApplicationPath + "/ProductImages/" + productDetails.Image1FileName;
        image2.ImageUrl       = Request.ApplicationPath + "/ProductImages/" + productDetails.Image2FileName;
        // Clear form
        categoriesLabel.Text = "";
        categoriesListAssign.Items.Clear();
        categoriesListMove.Items.Clear();
        categoriesListRemove.Items.Clear();
        // Fill categoriesLabel and categoriesListRemove with data
        string    categoryId, categoryName;
        DataTable productCategories = CatalogBLO.GetCategoriesWithProduct(currentProductId);

        for (int i = 0; i < productCategories.Rows.Count; i++)
        {
            // obtain category id and name
            categoryId   = productCategories.Rows[i]["CategoryId"].ToString();
            categoryName = productCategories.Rows[i]["Name"].ToString();
            // add a link to the category admin page
            categoriesLabel.Text += (categoriesLabel.Text == "" ? "" : ", ") +
                                    "<a href=\"" + Request.ApplicationPath + "/CatalogAdmin.aspx" +
                                    "?DepartmentID=" + CatalogBLO.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 = CatalogBLO.GetCategoriesWithoutProduct(currentProductId);
        for (int i = 0; i < productCategories.Rows.Count; i++)
        {
            // obtain category id and name
            categoryId   = productCategories.Rows[i]["CategoryId"].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));
        }
    }