示例#1
0
    public void UpdateProduct(int id, string name, int brandId, string shortDescription, string longDescription, string price, int colorId)
    {
        try
        {
            name             = name.TrimEnd().TrimStart();
            shortDescription = shortDescription.TrimEnd().TrimStart();
        }
        catch (Exception)
        {
            throw new Exception("No es posible actualizar el Producto");
        }

        ProductsDAO dao            = new ProductsDAO();
        Product     updatedProduct = dao.GetProduct(id);

        if (updatedProduct != null)
        {
            updatedProduct.name             = name;
            updatedProduct.brandId          = brandId;
            updatedProduct.shortDescription = shortDescription;
            updatedProduct.longDescription  = longDescription;
            updatedProduct.price            = price;
            updatedProduct.colorId          = colorId;
            int result = dao.UpdateProduct(updatedProduct);
            if (result < 1)
            {
                throw new Exception("No es posible actualizar el Producto");
            }
        }
    }
示例#2
0
    public Product GetProduct(int id)
    {
        Product     product = new Product();
        ProductsDAO dao     = new ProductsDAO();

        product = dao.GetProduct(id);
        return(product);
    }
示例#3
0
    public void DeleteProduct(int id)
    {
        ProductsDAO dao           = new ProductsDAO();
        Product     deleteProduct = dao.GetProduct(id);

        if (deleteProduct != null)
        {
            int result = dao.DeleteProduct(deleteProduct);
            if (result < 1)
            {
                throw new Exception("No es posible eliminar el Producto");
            }
        }
        else
        {
            throw new Exception("El id del Producto a eliminar no es válido");
        }
    }
示例#4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         try
         {
             productId = Convert.ToInt32(Request.QueryString["productId"]);
             ProductsDAO productsDAO = new ProductsDAO();
             Product     product     = productsDAO.GetProduct(productId);
             lblNombreProducto.Text = product.name;
             lblDescripcion.Text    = product.shortDescription;
             Session["sku"]         = product.sku;
         }
         catch (Exception)
         {
             Response.Redirect("Products.aspx");
         }
     }
 }
示例#5
0
    protected void btnBuyProduct_Click(object sender, EventArgs e)
    {
        productId = Convert.ToInt32(Request.QueryString["productId"]);
        ProductsDAO productsDAO = new ProductsDAO();
        Product     product     = productsDAO.GetProduct(productId);

        if (product != null)
        {
            List <ShoppingCartProduct> listProductsShoppingCard;
            if (Session["ssSHOPPINGCARD"] == null)
            {
                listProductsShoppingCard = new List <ShoppingCartProduct>();
                ShoppingCartProduct shoppingCartProduct = new ShoppingCartProduct();
                shoppingCartProduct.product = product;
                shoppingCartProduct.total   = 1;
                listProductsShoppingCard.Add(shoppingCartProduct);
                Session["ssSHOPPINGCARD"] = listProductsShoppingCard;
            }
            else
            {
                listProductsShoppingCard = (List <ShoppingCartProduct>)Session["ssSHOPPINGCARD"];
                ShoppingCartProduct shoppingCartProductOld = listProductsShoppingCard.Find(p => p.product.id.Equals(product.id));
                if (shoppingCartProductOld != null)
                {
                    shoppingCartProductOld.total++;
                }
                else
                {
                    ShoppingCartProduct shoppingCartProduct = new ShoppingCartProduct();
                    shoppingCartProduct.product = product;
                    shoppingCartProduct.total   = 1;
                    listProductsShoppingCard.Add(shoppingCartProduct);
                }
            }

            ClientScript.RegisterStartupScript(this.GetType(), "Respuesta"
                                               , string.Format("alert('{0}');"
                                                               , "¡Agregado correctamente!"), true);
        }
    }
示例#6
0
    private void LoadProduct(int productId)
    {
        try
        {
            ProductsDAO productsDAO = new ProductsDAO();
            Product     product     = productsDAO.GetProduct(productId);

            lblProductName.Focus();

            lblProductName.InnerText       = product.name;
            lblProductPrice.InnerText      = string.Concat("$", " ", product.price);
            lblProductDescrition.InnerText = product.shortDescription;
            lblColors.InnerText            = product.colors;

            ProductImagesDAO    productImagesDAO = new ProductImagesDAO();
            List <ProductImage> ProductImageList = productImagesDAO.GetAllProductImages();
            ProductImageList = ProductImageList.FindAll(pi => pi.productId.Equals(product.id));
            ProductImage productImage = ProductImageList.FirstOrDefault();
            string       url          = "http://localhost:6742/Images/";
            imgProductMain.Src = url + productImage.image;

            hlProductZoom.HRef = imgProductMain.Src;

            string[] sizes = product.sizes.Split(',');
            foreach (string size in sizes)
            {
                ddlProductSizes.Items.Add(size);
            }

            imgProduct1.Src = url + ProductImageList[0].image;
            imgProduct2.Src = url + ProductImageList[1].image;
            imgProduct3.Src = url + ProductImageList[2].image;
            imgProduct4.Src = url + ProductImageList[3].image;
        }
        catch (Exception)
        { }
    }