protected ArrayList uploadImages() { ArrayList arrImg = new ArrayList(); HttpFileCollection uploads = HttpContext.Current.Request.Files; for (int i = 0; i < uploads.Count; i++) { HttpPostedFile upload = uploads[i]; if (upload.ContentLength == 0) continue; BaseBiz objPic = new BaseBiz(); //Getting actual file name of picture string fileName = System.IO.Path.GetFileName(upload.FileName); // We don't need the path, just the name. string extension = fileName.Substring(fileName.LastIndexOf(".") + 1); //creating new filename before saving string fileSaveName = "Image" + "_" + DateTime.Now.ToString("yyyyMMddHHmmssfff") + "_" + Guid.NewGuid().ToString()+"."+extension; objPic.Name = fileSaveName; arrImg.Add(objPic); try { upload.SaveAs(Server.MapPath("upload\\" + fileSaveName)); } catch (Exception Exp) { throw Exp; } } return arrImg; }
public ProductBiz getProductDetailsById(int pid) { ProductData oProductData = null; ProductBiz oProductBiz = null; try { oProductData = new ProductData(); oProductBiz = new ProductBiz(); DataSet dsProductDetails = oProductData.getProductDetailsById(pid); if (dsProductDetails.Tables.Count > 0 && dsProductDetails.Tables[0].Rows.Count > 0) { foreach (DataRow dr in dsProductDetails.Tables[0].Rows) { oProductBiz.ProductName = dr["productname"].ToString(); oProductBiz.ProductId = Convert.ToInt32(dr["productid"].ToString()); oProductBiz.ProductCode = dr["pcode"].ToString(); oProductBiz.BrandId = Convert.ToInt32(dr["brandid"].ToString()); oProductBiz.ProdShortDesc = dr["productshortdesc"].ToString(); oProductBiz.ProdLongDesc = dr["productlongdesc"].ToString(); oProductBiz.Price = Convert.ToDecimal(dr["price"].ToString()); oProductBiz.MarketPrice = Convert.ToDecimal(dr["price"].ToString()); oProductBiz.IsActive = Convert.ToBoolean(dr["isactive"].ToString()); oProductBiz.IsProductSale = Convert.ToBoolean(dr["isproductsale"].ToString()); oProductBiz.SaleType = dr["saletype"].ToString(); oProductBiz.Priceorpercent = Convert.ToDecimal(dr["priceorpercent"].ToString()); oProductBiz.IsHot = Convert.ToBoolean(dr["ishot"].ToString()); oProductBiz.HotText = dr["hotdealsText"].ToString(); oProductBiz.QtyInCart = Convert.ToInt32(dr["qtyincart"].ToString()); oProductBiz.QtyText = dr["qtytext"].ToString(); } ArrayList arrCategory = new ArrayList(); if (dsProductDetails.Tables[1].Rows.Count > 0) { foreach (DataRow dr in dsProductDetails.Tables[1].Rows) { arrCategory.Add(Convert.ToInt32(dr["categoryid"].ToString())); } oProductBiz.ArrCategories = arrCategory; } ArrayList arrPhotos = new ArrayList(); if (dsProductDetails.Tables[2].Rows.Count > 0) { foreach (DataRow dr in dsProductDetails.Tables[2].Rows) { BaseBiz oBaseBiz = new BaseBiz(); oBaseBiz.Name = dr["photopath"].ToString(); arrPhotos.Add(oBaseBiz); } oProductBiz.ArrImages = arrPhotos; } if (dsProductDetails.Tables[3].Rows.Count > 0) { RatingBiz oRating = new RatingBiz(); oRating.Rating = Convert.ToDecimal(20 * Convert.ToDecimal(dsProductDetails.Tables[3].Rows[0]["rating"].ToString())); oRating.TotalRating = Convert.ToInt32(dsProductDetails.Tables[3].Rows[0]["TotalRating"].ToString()); oProductBiz.Rating = oRating; } } } catch (Exception ex) { throw ex; } return oProductBiz; }