Пример #1
0
        // BUTTON EVENT FIRES
        protected void update_button_Click(object sender, EventArgs e)
        {
            notificationSuccess_label.Text = "";
            notificationError_label.Text   = "";
            if (inputUserWatchQuantity_textBox.Text != "" && inputUserWatchPrice_textBox.Text != "" && inputWatchName_textBox.Text != "")
            {
                if (upload.HasFile)
                {
                    Product p = ProductHandler.GetById(ProductId);
                    if (System.IO.File.Exists(Server.MapPath("~/") + p.ProductImage))
                    {
                        System.IO.File.Delete(Server.MapPath("~/") + p.ProductImage);
                    }

                    string image = getImageUploaded();

                    ProductHandler.UpdateWithImage(ProductId, inputWatchName_textBox.Text, image, Convert.ToDecimal(inputUserWatchPrice_textBox.Text), Int32.Parse(inputUserWatchQuantity_textBox.Text));
                }
                else
                {
                    ProductHandler.UpdateWithoutImage(ProductId, inputWatchName_textBox.Text, Convert.ToDecimal(inputUserWatchPrice_textBox.Text), Int32.Parse(inputUserWatchQuantity_textBox.Text));
                }

                notificationSuccess_label.Text = "Update Watch successfuly!";
                notificationError_label.Text  += "";

                Response.Redirect("Home.aspx");
            }
            else
            {
                checkEmptiness();
            }
        }
        protected override ValidationResult IsValid(object number, ValidationContext validationContext)
        {
            int produktId = (int)validationContext.ObjectInstance.GetType().GetProperty("produkteid", BindingFlags.Public | BindingFlags.Instance)
                            .GetValue(validationContext.ObjectInstance);
            Product product = ProductHandler.GetById(produktId);

            if ((int)number <= product.maxOrderCount)
            {
                return(ValidationResult.Success);
            }
            else
            {
                return(new ValidationResult(String.Format("You cannot order more than {0} from {1}", product.maxOrderCount, product.productname)));
            }
        }
        private void setPreview()
        {
            if (Request.QueryString["productId"] != null)
            {
                ProductId = Int32.Parse(Request.QueryString["productId"]);
                Product p = ProductHandler.GetById(ProductId);

                productName.Text  = p.ProductName;
                productPrice.Text = p.ProductPrice.ToString();
                productStock.Text = p.ProductStock.ToString();
                image.ImageUrl    = string.Format("~/{0}", p.ProductImage);

                DataTable reviews = ReviewHandler.GetAllByProductId(ProductId);

                review.DataSource = reviews;
                review.DataBind();
            }
        }
Пример #4
0
        // DELETE BY GETTING PARAMETER FROM URL
        private void deleteValue()
        {
            if (Request.QueryString["productId"] != null)
            {
                ProductId = Int32.Parse(Request.QueryString["productId"]);

                Product p = ProductHandler.GetById(ProductId);
                if (System.IO.File.Exists(Server.MapPath("~/") + p.ProductImage))
                {
                    System.IO.File.Delete(Server.MapPath("~/") + p.ProductImage);
                }

                ReviewHandler.Delete(ProductId);
                ProductHandler.Delete(ProductId);

                Response.Redirect("Home.aspx");
            }
            else if (Request.QueryString["userId"] != null)
            {
                UserId = Int32.Parse(Request.QueryString["userId"]);

                User u = UserHandler.GetById(UserId);
                if (System.IO.File.Exists(Server.MapPath("~/") + u.UserProfilePicture))
                {
                    System.IO.File.Delete(Server.MapPath("~/") + u.UserProfilePicture);
                }

                UserHandler.Delete(UserId);

                Response.Redirect("Member.aspx");
            }
            else if (Request.QueryString["review"] != null)
            {
                ReviewId = Int32.Parse(Request.QueryString["review"]);
                //Review r = ReviewHandler.GetById(ReviewId);
                ReviewHandler.Delete(ReviewId);

                //Response.Redirect("ProductShowCaseDetail.aspx?productId=" + ProductId);
                Response.Redirect("Home.aspx");
            }
        }
Пример #5
0
        private void changeValue()
        {
            if (Request.QueryString["productId"] != null)
            {
                ProductId = Int32.Parse(Request.QueryString["productId"]);
                Product p = ProductHandler.GetById(ProductId);

                //if (!IsPostBack)
                //{
                //    inputWatchName_textBox.Text = p.ProductName;
                //    inputUserWatchPrice_textBox.Text = p.ProductPrice.ToString();
                //    inputUserWatchQuantity_textBox.Text = p.ProductStock.ToString();
                //}

                image.ImageUrl = string.Format("~/{0}", p.ProductImage);
            }
            else if (Request.QueryString["userId"] != null)
            {
                UserId = Int32.Parse(Request.QueryString["userId"]);
                //UserHandler.Update(UserId);

                Response.Redirect("Member.aspx");
            }
        }