public StringBuilder GetProductDetailsView(int pid, int gradeId, string host, string format, string skuContentFormat) { StringBuilder sbProduct = new StringBuilder(); string existSkuDetials = "false"; string skuList = ""; DataSet productSkuDetials = ProductHelper.GetProductSkuDetials(pid, gradeId); foreach (DataRow skuRow in productSkuDetials.Tables[1].Rows) { existSkuDetials = "true"; string skuContent = MessageInfo.GetSkuContent(skuRow["SkuId"].ToString()); string skuSalePrice = ""; string skuCostPrice = ""; if (skuRow["SalePrice"] != null && skuRow["SalePrice"].ToString() != "") { skuSalePrice = decimal.Parse(skuRow["SalePrice"].ToString()).ToString("F2"); } if (skuRow["CostPrice"] != null && skuRow["CostPrice"].ToString() != "") { skuCostPrice = decimal.Parse(skuRow["CostPrice"].ToString()).ToString("F2"); } skuList = skuList + string.Format(skuContentFormat, new object[] { skuRow["ProductId"].ToString(), skuRow["SKU"].ToString(), skuRow["SkuId"], skuContent, skuRow["Stock"], skuSalePrice, skuCostPrice }) + ","; } if (skuList.Length > 0) { skuList = skuList.Substring(0, skuList.Length - 1); } JsonConvert.SerializeObject(productSkuDetials.Tables[0]); foreach (DataRow productRow in productSkuDetials.Tables[0].Rows) { string productDetailsUrl = host + Globals.GetSiteUrls().UrlData.FormatUrl("productDetails", new object[] { productRow["ProductId"].ToString() }); string[] strimg = new string[] { productRow["ImageUrl1"].ToString(), productRow["ImageUrl2"].ToString(), productRow["ImageUrl3"].ToString(), productRow["ImageUrl4"].ToString(), productRow["ImageUrl5"].ToString() }; string desciption = MessageInfo.GetDesciption(productRow["Description"].ToString(), host); string shortDescription = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(productRow["ShortDescription"].ToString())); string imageUrl = this.ImageUrl(host, strimg); string salePrice = ""; string marketPrice = ""; string costPrice = ""; if (productRow["SalePrice"] != null && productRow["SalePrice"].ToString() != "") { salePrice = decimal.Parse(productRow["SalePrice"].ToString()).ToString("F2"); } if (productRow["CostPrice"] != null && productRow["CostPrice"].ToString() != "") { costPrice = decimal.Parse(productRow["SalePrice"].ToString()).ToString("F2"); } if (productRow["MarketPrice"] != null && productRow["MarketPrice"].ToString() != "") { marketPrice = decimal.Parse(productRow["MarketPrice"].ToString()).ToString("F2"); } format = format.Replace("{{", "").Replace("}}", ""); sbProduct.AppendFormat(format, new object[] { productRow["ProductId"].ToString(), productRow["ProductCode"].ToString(), productRow["ProductName"].ToString(), imageUrl, productDetailsUrl, marketPrice, salePrice, costPrice, productRow["Weight"].ToString(), productRow["SaleStatus"].ToString(), productRow["SaleCounts"].ToString(), shortDescription, productRow["Stock"].ToString(), productRow["AddedDate"].ToString(), desciption, salePrice, existSkuDetials, productRow["BrandId"].ToString(), skuList, productRow["Unit"].ToString() }); } return(sbProduct); }
public StringBuilder GetProductView(ProductQuery query, int gradeId, string host, string strformat, string skuContentFormat, out int recordes) { if (query.CategoryId.HasValue) { query.MaiCategoryPath = CatalogHelper.GetCategory(query.CategoryId.Value).Path; } StringBuilder sbProducts = new StringBuilder(); int recordCount = 0; DataSet productsByQuery = ProductHelper.GetProductsByQuery(query, gradeId, out recordCount); foreach (DataRow rowProduct in productsByQuery.Tables[0].Rows) { StringBuilder sbProductRel = new StringBuilder(); string existRelationProduct = "false"; DataRow[] childRows = rowProduct.GetChildRows("ProductRealation"); DataRow[] array = childRows; for (int i = 0; i < array.Length; i++) { DataRow rowProductRel = array[i]; existRelationProduct = "true"; string skuContent = MessageInfo.GetSkuContent(rowProductRel["SkuId"].ToString()); string salePriceRel = ""; string costPriceRel = ""; if (rowProductRel["SalePrice"] != null && rowProductRel["SalePrice"].ToString() != "") { salePriceRel = decimal.Parse(rowProductRel["SalePrice"].ToString()).ToString("F2"); } if (rowProductRel["CostPrice"] != null && rowProductRel["CostPrice"].ToString() != "") { costPriceRel = decimal.Parse(rowProductRel["CostPrice"].ToString()).ToString("F2"); } sbProductRel.AppendFormat(skuContentFormat, new object[] { rowProductRel["ProductId"].ToString(), rowProductRel["SKU"].ToString(), rowProductRel["SKuId"].ToString(), skuContent, rowProductRel["Stock"].ToString(), salePriceRel, costPriceRel }); sbProductRel.Append(","); } if (sbProductRel.Length > 0) { sbProductRel = sbProductRel.Remove(sbProductRel.Length - 1, 1); } string detailsUrl = host + "/AppShop/ProductDetails.aspx?productId=" + rowProduct["ProductId"]; string imageUrl60 = host + rowProduct["ThumbnailUrl60"]; if (string.IsNullOrEmpty(rowProduct["ThumbnailUrl60"].ToString())) { imageUrl60 = host + this.siteSettings.DefaultProductThumbnail2; } if (rowProduct["ThumbnailUrl60"].ToString().IndexOf("http://image58.kuaidiantong.cn/Storage/master/product/") >= 0) { imageUrl60 = rowProduct["ThumbnailUrl60"].ToString(); } string marketPrice = ""; string salePrice = ""; string rankPrice = ""; string costPrice = ""; string shotDescription = System.Convert.ToBase64String(Encoding.UTF8.GetBytes(rowProduct["ShortDescription"].ToString())); if (rowProduct["MarketPrice"] != null && rowProduct["MarketPrice"].ToString() != "") { marketPrice = decimal.Parse(rowProduct["MarketPrice"].ToString()).ToString("F2"); } if (rowProduct["SalePrice"] != null && rowProduct["SalePrice"].ToString() != "") { salePrice = decimal.Parse(rowProduct["SalePrice"].ToString()).ToString("F2"); } if (rowProduct["CostPrice"] != null && rowProduct["CostPrice"].ToString() != "") { costPrice = decimal.Parse(rowProduct["CostPrice"].ToString()).ToString("F2"); } if (rowProduct["RankPrice"] != null && rowProduct["RankPrice"].ToString() != "") { rankPrice = decimal.Parse(rowProduct["RankPrice"].ToString()).ToString("F2"); } sbProducts.AppendFormat(strformat, new object[] { rowProduct["ProductId"].ToString(), rowProduct["ProductCode"].ToString(), rowProduct["ProductName"].ToString(), imageUrl60, detailsUrl, marketPrice, salePrice, costPrice, rowProduct["Weight"].ToString(), rowProduct["SaleStatus"].ToString(), rowProduct["SaleCounts"].ToString(), shotDescription, rowProduct["Stock"].ToString(), rowProduct["AddedDate"].ToString(), MessageInfo.GetDesciption(rowProduct["Description"].ToString(), host), rankPrice, existRelationProduct, rowProduct["BrandId"].ToString(), sbProductRel, rowProduct["Unit"].ToString() }); sbProducts.Append(","); } recordes = recordCount; if (sbProducts.Length > 0) { sbProducts = sbProducts.Remove(sbProducts.Length - 1, 1); } return(sbProducts); }