예제 #1
0
 public void Remove(Product p)
 {
     int index = Search(p.ID);
     if (index != -1)
     {
         Products.RemoveAt(index);
     }
 }
예제 #2
0
 public bool Add(Product p)
 {
     int index = Search(p.ID);
     if (index == -1)
     {
         Products.Add(p);
         return true;
     }
     return false;
 }
예제 #3
0
 protected void btnSave_Click(object sender, EventArgs e)
 {
     Product p = new Product();
     p.Name = txtName.Text;
     p.Price = ToSQL.SQLToDecimal(txtPriceNew.Text);
     p.ProductType_ID = ToSQL.SQLToIntNull(ddlProductType.SelectedValue);
     p.Manufacuturer_ID = ToSQL.SQLToIntNull(ddlManufacturer.SelectedValue);
     p.Description = CKEditorControlDescription.Text;
     p.IsActive = true;
     p.IsBestSelling = chkBestSelling.Checked;
     p.IsNew = chkNew.Checked;
     p.IsSpecial = chkSpecial.Checked;
     p.DateCreated = DateTime.Now;
     if (fulImageDefault.HasFile)
     {
         ProductImage image = new ProductImage();
         string url = CheckFileShared.UploadAndRsizeImage(fulImageDefault.PostedFile);
         if (url != "")
         {
             image.Image = url;
             image.IsDefault = true;
             p.ProductImages.Add(image);
         }
     }
     HttpFileCollection uploads = Request.Files;
     //for (int fileCount = 0; fileCount < uploads.Count; fileCount++)
     foreach (HttpPostedFile uploadedFile in FileUploadJquery.PostedFiles)
     {
         ProductImage image = new ProductImage();
         string url = CheckFileShared.UploadAndRsizeImage(uploadedFile);
         if (url != "")
         {
             image.Image = url;
             image.IsDefault = false;
             p.ProductImages.Add(image);
         }
     }
     if (productRepo.CreateProduct(p) > 0)
     {
         ProductPriceHistory productPriceHistory = new ProductPriceHistory();
         productPriceHistory.Product_ID = p.ID;
         productPriceHistory.Price = p.Price;
         productPriceHistory.DateCreated = DateTime.Now;
         new ProductPriceHistoryRepo().CreateProductPriceHistory(productPriceHistory);
         Response.Redirect("~/Admincp/Management-Products.aspx");
     }
     else
     {
         lbMessage.Text = "Please check input data! Try again!";
     }
 }
예제 #4
0
파일: Cart.cs 프로젝트: htphongqn/B2C_EC
 public Cart ConverProductToCart(Product product)
 {
     this.ProductID = product.ID;
     this.ProductName = product.Name;
     this.Price = product.Price;
     return this;
 }