public Boolean addProduct(ProductBiz oProductObj) { try { ProductData oProductData = new ProductData(); return oProductData.addProduct(oProductObj); } catch (Exception ex) { throw ex; } }
public Boolean addProduct(ProductBiz oProductBiz) { CDL.CoreDataLayer objCoreDataLayer = new CDL.CoreDataLayer(); Boolean flag = false; try { ArrayList arrImages = new ArrayList(); arrImages = oProductBiz.ArrImages; StringBuilder strBuildImg = new StringBuilder(); ArrayList arrCat = new ArrayList(); arrCat = oProductBiz.ArrCategories; StringBuilder strBuildCat = new StringBuilder(); string strRetValue = string.Empty; foreach (BaseBiz arr in arrImages) { strBuildImg.Append(arr.Name); strBuildImg.Append(","); } foreach (string cat in arrCat) { strBuildCat.Append(cat); strBuildCat.Append(","); } if (oProductBiz.UserAction != "") { strRetValue = objCoreDataLayer.ExecuteScalar("pr_updProduct", new object[] {oProductBiz.ProductId, oProductBiz.ProductName,oProductBiz.ProductCode,oProductBiz.ProdShortDesc,oProductBiz.ProdLongDesc, oProductBiz.Price,oProductBiz.BrandId,oProductBiz.IsActive,oProductBiz.IsProductSale,oProductBiz.SaleType,oProductBiz.Priceorpercent,oProductBiz.IsHot,oProductBiz.HotText,strBuildImg.ToString(),strBuildCat.ToString(),oProductBiz.QtyInCart,oProductBiz.QtyText }, true); } else { strRetValue = objCoreDataLayer.ExecuteScalar("pr_insProduct", new object[] { oProductBiz.ProductName,oProductBiz.ProductCode,oProductBiz.ProdShortDesc,oProductBiz.ProdLongDesc, oProductBiz.Price,oProductBiz.BrandId,oProductBiz.IsActive,oProductBiz.IsProductSale,oProductBiz.SaleType,oProductBiz.Priceorpercent,oProductBiz.IsHot,oProductBiz.HotText,strBuildImg.ToString(),strBuildCat.ToString(),oProductBiz.QtyInCart,oProductBiz.QtyText }, true); } if (strRetValue == "0") flag = true; } catch (Exception ex) { throw ex; } return flag; }
protected void btnSave_Click(object sender, EventArgs e) { if (Page.IsValid) { ProductBiz oProductBiz = new ProductBiz(); oProductBiz.ProductName = txtProdName.Value.Trim(); oProductBiz.ProductCode = txtProdCode.Value.Trim(); oProductBiz.ProdShortDesc = txtShortDesc.Content; oProductBiz.ProdLongDesc = txtLongDesc.Content; if (txtPrice.Value != "") { oProductBiz.Price = Convert.ToDecimal(txtPrice.Value.Trim()); } else oProductBiz.Price = 0.0m; if (txtMarketPrice.Value != "") { oProductBiz.MarketPrice = Convert.ToDecimal(txtMarketPrice.Value.Trim()); } else oProductBiz.MarketPrice = 0.0m; oProductBiz.IsProductSale = chkSale.Checked; if (oProductBiz.IsProductSale) { oProductBiz.SaleType = radSale.SelectedItem.Value; oProductBiz.Priceorpercent = Convert.ToDecimal(txtOffer.Value); } // String effDate = HelperFunction.FormatDate(txtEffective.Value, "dd-MMM-yyyy"); //String expDate = HelperFunction.FormatDate(txtExpiry.Value, "dd-MMM-yyyy"); oProductBiz.BrandId = Convert.ToInt32(ddlBrand.SelectedItem.Value); oProductBiz.StatusId = Convert.ToInt32(ddlStatus.SelectedItem.Value); oProductBiz.IsHot = chkHot.Checked; oProductBiz.HotText = txtHotText.Value; ArrayList arrCategory = new ArrayList(); foreach (ListItem li in lstCategory.Items) { if (li.Selected) { arrCategory.Add(li.Value); } } oProductBiz.ArrCategories = arrCategory; if (hdnUpdate.Value != "") { oProductBiz.UserAction = "update"; oProductBiz.ProductId = Convert.ToInt32(hdnUpdate.Value); string[] strArr = hdnFileName.Value.Split(','); if (strArr.Length > 0) { for (int j = 0; j < strArr.Length; j++) { File.Delete(Server.MapPath("upload\\" + strArr[j])); } } } oProductBiz.ArrImages = uploadImages(); oProductBiz.QtyInCart = Int32.Parse(txtQty.Value); oProductBiz.QtyText = txtDisplayText.Value; bool isStatus = oProducts.addProduct(oProductBiz); if (isStatus) { if(oProductBiz.UserAction!="") Response.Write("<script>alert('Product updated successfully');</script>"); else Response.Write("<script>alert('Product added successfully');</script>"); Response.Redirect("ManageProducts.aspx"); } } }
private void setProductDetails(ProductBiz oProductBiz,object sender, EventArgs e) { hdnUpdate.Value = oProductBiz.ProductId.ToString(); txtProdName.Value = oProductBiz.ProductName; txtProdCode.Value = oProductBiz.ProductCode; txtShortDesc.Content = oProductBiz.ProdShortDesc; txtLongDesc.Content = oProductBiz.ProdLongDesc; txtPrice.Value = Convert.ToString(oProductBiz.Price); txtMarketPrice.Value = Convert.ToString(oProductBiz.MarketPrice); txtQty.Value = Convert.ToString(oProductBiz.QtyInCart); txtDisplayText.Value = oProductBiz.QtyText; ddlBrand.Items.FindByValue(oProductBiz.BrandId.ToString()).Selected = true; if (oProductBiz.IsHot) chkHot.Checked = true; txtHotText.Value = oProductBiz.HotText; if (oProductBiz.IsProductSale) { chkSale.Checked = true; radSale.Items.FindByValue(oProductBiz.SaleType.ToString()).Selected = true; txtOffer.Value = Convert.ToString(oProductBiz.Priceorpercent); } //Category for(int i=0;i<oProductBiz.ArrCategories.Count;i++) { lstCategory.Items.FindByValue(oProductBiz.ArrCategories[i].ToString()).Selected = true; } ddlStatus.Items.FindByValue(oProductBiz.StatusId.ToString()).Selected = true; //Displaying images StringBuilder strBuild = new StringBuilder(); StringBuilder strImg = new StringBuilder(); if (oProductBiz.ArrImages != null) { for (int j = 0; j < oProductBiz.ArrImages.Count; j++) { BaseBiz opic = (BaseBiz)oProductBiz.ArrImages[j]; string imgPath = "/admin/upload/" + opic.Name; strImg.Append(opic.Name); strImg.Append(","); strBuild.Append("<input type='file' size='20' name='dynamic" + j + "'> <img src='" + imgPath + "' border='0' width='25' height='25'> <a id='lnkRemove' runat='server' href='javascript:fnRemoveImg();'>Remove</a>"); strBuild.Append("<br/>"); } hdnFileName.Value = strImg.ToString().Substring(0, strImg.Length - 1); } if(oProductBiz.IsProductSale) strBuild.Append("<script>document.getElementById('divSale').style.display='block'</script>"); divImgView.InnerHtml = strBuild.ToString(); }
public ArrayList getAllProducts() { ArrayList arrProducts = null; ProductData oProductData = null; try { arrProducts = new ArrayList(); oProductData = new ProductData(); DataSet dsProducts = oProductData.getAllProducts(); if (dsProducts.Tables.Count > 0 && dsProducts.Tables[0].Rows.Count > 0) { foreach (DataRow dr in dsProducts.Tables[0].Rows) { ProductBiz oProductBiz = new ProductBiz(); oProductBiz.ProductName = dr["productname"].ToString(); oProductBiz.ProductId = Convert.ToInt32(dr["productid"].ToString()); oProductBiz.ProductCode = dr["pcode"].ToString(); oProductBiz.Price = Convert.ToDecimal(dr["price"].ToString()); oProductBiz.StatusName = dr["isactive"].ToString(); arrProducts.Add(oProductBiz); } } } catch (Exception ex) { throw ex; } return arrProducts; }
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; }
public ArrayList getListAllProducts(ProductBiz objProductBiz) { ArrayList arrProducts = null; ProductData oProductData = null; try { arrProducts = new ArrayList(); oProductData = new ProductData(); DataSet dsProducts = oProductData.getListAllProducts(objProductBiz); if (dsProducts.Tables.Count > 0 && dsProducts.Tables[0].Rows.Count > 0) { foreach (DataRow dr in dsProducts.Tables[0].Rows) { ProductBiz oProductBiz = new ProductBiz(); oProductBiz.ProductName = dr["productname"].ToString(); oProductBiz.ProductId = Convert.ToInt32(dr["productid"].ToString()); oProductBiz.ImagePath = dr["photopath"].ToString(); //oProductBiz.ProdShortDesc = dr["productshortdesc"].ToString(); //oProductBiz.ProdLongDesc = dr["productlongdesc"].ToString(); oProductBiz.SaleType = dr["saletype"].ToString(); oProductBiz.Priceorpercent = Convert.ToDecimal(dr["priceorpercent"].ToString()); oProductBiz.Price = Convert.ToDecimal(dr["price"].ToString()); oProductBiz.IsHot = Convert.ToBoolean(dr["ishot"].ToString()); oProductBiz.HotText = dr["hotdealsText"].ToString(); arrProducts.Add(oProductBiz); } } } catch (Exception ex) { throw ex; } return arrProducts; }
public void DisplayProducts() { Products oProducts = new Products(); ProductBiz objProductBiz = new ProductBiz(); objProductBiz.StatusId = StatusId; objProductBiz.CategoryId = CategoryId; objProductBiz.SearchText = SearchText; ArrayList arrProducts = oProducts.getListAllProducts(objProductBiz); StringBuilder strBuild = new StringBuilder(); strBuild.Append("<table cellpadding='2' cellspacing='2' border='0' width='100%'><tr>"); for (int i = 0; i < arrProducts.Count; i++) { if (i % 3 == 0) strBuild.Append("</tr><tr>"); strBuild.Append("<td>"); ProductBiz oProductBiz = (ProductBiz)arrProducts[i]; int pid = oProductBiz.ProductId; using (StreamReader sr = new StreamReader(Server.MapPath(@"~\admin\Templates\products.htm"))) { string fullText = sr.ReadToEnd(); fullText = fullText.Replace("{#PRODUCTNAME#}", "<a id='easyView' href='/control/products/" + pid + "/details'>"+oProductBiz.ProductName+"</a><br/>"); string prodImage = oProductBiz.ImagePath; if (prodImage != "") { string imgPath = "/admin/upload/" + prodImage; prodImage = "<a href='javascript:void(0)'><img src='" + imgPath + "' border='0' width='125px' height='125px'><span class='qkview'><input type='button' data_id=" + pid + " name='btnQuickView' onClick='javascript:fnQuickView(this);' value='Quick View' /></span></a>"; } else prodImage = "No Image"; fullText = fullText.Replace("{#IMAGE#}", prodImage); decimal price = oProductBiz.Price; decimal offerPrice = 0.0m; decimal offer = 0.0m; String saleType = ""; if (oProductBiz.SaleType != "") { saleType = oProductBiz.SaleType; if (saleType == "S") { offerPrice = price - oProductBiz.Priceorpercent; offer = oProductBiz.Priceorpercent; saleType = " OFF"; } else { offerPrice = price - (price * (oProductBiz.Priceorpercent / 100)); offer = oProductBiz.Priceorpercent; saleType = " % OFF"; } } fullText = fullText.Replace("{#PRICE#}", String.Format("{0:0,0}", price)); fullText = fullText.Replace("{#PRICEORPERCENT#}", offer > 0 ? String.Format("{0:0}", offer) + " " + saleType : ""); fullText = fullText.Replace("{#OFFERPRICE#}", offerPrice > 0 ? String.Format("{0:0,0}", offerPrice) : ""); string strHot = string.Empty; if (oProductBiz.IsHot) { strHot = "<img src='/admin/includes/images/hoticon.gif' border='0' width='30' height='30' />"; } string hotText = string.Empty; if (oProductBiz.HotText != null && oProductBiz.HotText != "") { hotText = oProductBiz.HotText; strHot += "<font size='1'>" + hotText + "</font>"; } // fullText = fullText.Replace("{#ISHOT#}", strHot); strBuild.Append(fullText); strBuild.Append("</td>"); //sr.Close(); } } strBuild.Append("</tr></table>"); divList.InnerHtml = strBuild.ToString(); }
public DataSet getListAllProducts(ProductBiz oProductBiz) { DataSet dsProducts = null; CDL.CoreDataLayer objCoreDataLayer = new CDL.CoreDataLayer(); try { dsProducts = new DataSet(); dsProducts = objCoreDataLayer.ExecuteDataSet("pr_getallproducts", new object[] { oProductBiz.CategoryId ,oProductBiz.SearchText}); } catch (Exception ex) { throw ex; } return dsProducts; }