public int GetLimitedTimeDiscountUsedNum(int limitedTimeDiscountId, string skuId, int productId, int userid, bool isContainsShippingCart) { int num = 0; if (userid == -1) { userid = Globals.GetCurrentMemberUserId(false); } if (productId <= 0) { SKUItem skuItem = new SkuDao().GetSkuItem(skuId); if (skuItem != null) { productId = skuItem.ProductId; } } if (((productId > 0) && (limitedTimeDiscountId > 0)) && (userid > 0)) { string query = string.Concat(new object[] { "select isnull(sum(Quantity),0) from Hishop_OrderItems a inner join Hishop_Orders b on a.OrderId=b.OrderId where a.LimitedTimeDiscountId=", limitedTimeDiscountId, " and a.ProductId=", productId, " and b.UserID=", userid, " and a.OrderItemsStatus<>4" }); DbCommand sqlStringCommand = this.database.GetSqlStringCommand(query); num = Globals.ToNum(this.database.ExecuteScalar(sqlStringCommand)); if (isContainsShippingCart) { query = string.Concat(new object[] { "select isnull(sum(Quantity),0) from Hishop_ShoppingCarts where UserId=", userid, " and SkuId in(select SkuId from Hishop_SKUs where ProductId=", productId, ") and LimitedTimeDiscountId=", limitedTimeDiscountId }); sqlStringCommand = this.database.GetSqlStringCommand(query); this.database.AddInParameter(sqlStringCommand, "ProductId", DbType.Int32, productId); num += Globals.ToNum(this.database.ExecuteScalar(sqlStringCommand)); } } return(num); }
public static int GetSkuStock(string skuId, bool isCountdownOrGroupbuy = false) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); SKUItem skuItem = new SkuDao().GetSkuItem(skuId, 0); return(skuItem?.Stock ?? 0); }
public static int GetStockBySkuId(string SkuId) { SiteSettings masterSettings = SettingsManager.GetMasterSettings(); SKUItem skuItem = new SkuDao().GetSkuItem(SkuId, 0); return(skuItem.MaxStock); }
public static void AddLineItem(string skuId, int quantity, int categoryid, int Templateid, int type = 0, int exchangeId = 0, int limitedTimeDiscountId = 0) { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (quantity <= 0) { quantity = 1; } int num = 1; int num2 = 0; if (limitedTimeDiscountId == 0) { int productId = 0; SKUItem skuItem = new SkuDao().GetSkuItem(skuId); if (skuItem != null) { productId = skuItem.ProductId; int id = Globals.ToNum(new LimitedTimeDiscountDao().GetLimitedTimeDiscountIdByProductId(currentMember.UserId, skuId, productId)); if (id > 0) { LimitedTimeDiscountInfo discountInfo = new LimitedTimeDiscountDao().GetDiscountInfo(id); if (new MemberDao().CheckCurrentMemberIsInRange(discountInfo.ApplyMembers, discountInfo.DefualtGroup, discountInfo.CustomGroup, currentMember.UserId)) { int num5 = GetLimitedTimeDiscountUsedNum(id, skuId, productId, currentMember.UserId, true); if (discountInfo.LimitNumber == 0) { limitedTimeDiscountId = discountInfo.LimitedTimeDiscountId; } else if ((discountInfo.LimitNumber - num5) >= quantity) { limitedTimeDiscountId = discountInfo.LimitedTimeDiscountId; } else if ((discountInfo.LimitNumber - num5) < quantity) { num = 2; limitedTimeDiscountId = discountInfo.LimitedTimeDiscountId; num2 = quantity - (discountInfo.LimitNumber - num5); quantity = discountInfo.LimitNumber - num5; } } } } } new ShoppingCartDao().AddLineItem(currentMember, skuId, quantity, categoryid, Templateid, type, exchangeId, limitedTimeDiscountId); if (num == 2) { new ShoppingCartDao().AddLineItem(currentMember, skuId, num2, categoryid, Templateid, type, exchangeId, 0); } }
public static int GetSkuStock(string skuId, int type = 0, int exchangeId = 0) { int result = new SkuDao().GetSkuItem(skuId).Stock; if (type > 0) { int productId = int.Parse(skuId.Split(new char[] { '_' })[0]); PointExchangeProductInfo productInfo = new PointExChangeDao().GetProductInfo(exchangeId, productId); if (productInfo != null) { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); int userProductExchangedCount = new PointExChangeDao().GetUserProductExchangedCount(exchangeId, productId, currentMember.UserId); int productExchangedCount = new PointExChangeDao().GetProductExchangedCount(exchangeId, productId); int num = (productInfo.ProductNumber - productExchangedCount >= 0) ? (productInfo.ProductNumber - productExchangedCount) : 0; int num2; if (productInfo.EachMaxNumber > 0) { if (userProductExchangedCount < productInfo.EachMaxNumber) { if (productInfo.EachMaxNumber <= num) { num2 = productInfo.EachMaxNumber; } else { num2 = num; } } else { num2 = 0; } } else { num2 = num; } if (num2 > 0) { result = num2; } } } return(result); }
public static int GetSkuStock(string skuId, int type = 0, int exchangeId = 0) { int stock = new SkuDao().GetSkuItem(skuId).Stock; if (type > 0) { int productId = int.Parse(skuId.Split(new char[] { '_' })[0]); PointExchangeProductInfo productInfo = new PointExChangeDao().GetProductInfo(exchangeId, productId); if (productInfo == null) { return(stock); } MemberInfo currentMember = MemberProcessor.GetCurrentMember(); int eachMaxNumber = 0; int num4 = new PointExChangeDao().GetUserProductExchangedCount(exchangeId, productId, currentMember.UserId); int productExchangedCount = new PointExChangeDao().GetProductExchangedCount(exchangeId, productId); int num6 = ((productInfo.ProductNumber - productExchangedCount) >= 0) ? (productInfo.ProductNumber - productExchangedCount) : 0; if (productInfo.EachMaxNumber > 0) { if (num4 < productInfo.EachMaxNumber) { if (productInfo.EachMaxNumber <= num6) { eachMaxNumber = productInfo.EachMaxNumber; } else { eachMaxNumber = num6; } } else { eachMaxNumber = 0; } } else { eachMaxNumber = num6; } if (eachMaxNumber > 0) { stock = eachMaxNumber; } } return(stock); }
public static IList <ExtendAttributeInfo> GetExpandAttributeList(int productId) { DataTable expandAttributes = new SkuDao().GetExpandAttributes(productId); IList <ExtendAttributeInfo> list = new List <ExtendAttributeInfo>(); if (expandAttributes != null && expandAttributes.Rows.Count > 0) { foreach (DataRow row in expandAttributes.Rows) { list.Add(new ExtendAttributeInfo { ExtAttrName = row["AttributeName"].ToNullString(), ExtAttrValue = row["ValueStr"].ToNullString() }); } } return(list); }
/// <summary> /// 获取skuid最小库存,如果含有组合商品,则组合商品的库存为其中商品数量的库存除以组合系数的最小值 /// </summary> /// <param name="skuId"></param> /// <returns></returns> public static int GetSkuStock(string skuId) { //SKUItem skuItem = new SkuDao().GetSkuItem(skuId); //int result; //if (skuItem != null) //{ // result = skuItem.Stock; //} //else //{ // result = 0; //} //修改获取库存方法,添加组合商品逻辑 int result = new SkuDao().GetMinStockBySku(skuId); return(result); }
public static void AddLineItem(string skuId, int quantity, int categoryid, int Templateid, [Optional, DefaultParameterValue(0)] int type, [Optional, DefaultParameterValue(0)] int exchangeId, [Optional, DefaultParameterValue(0)] int limitedTimeDiscountId) { MemberInfo currentMember = MemberProcessor.GetCurrentMember(); if (quantity <= 0) { quantity = 1; } if (limitedTimeDiscountId == 0) { int productId = 0; SKUItem skuItem = new SkuDao().GetSkuItem(skuId); if (skuItem != null) { productId = skuItem.ProductId; int num2 = Globals.ToNum(new LimitedTimeDiscountDao().GetLimitedTimeDiscountIdByProductId(currentMember.UserId, skuId, productId)); if (num2 > 0) { limitedTimeDiscountId = num2; } } } new ShoppingCartDao().AddLineItem(currentMember, skuId, quantity, categoryid, Templateid, type, exchangeId, limitedTimeDiscountId); }
public static OrderInfo ConvertShoppingCartToOrder(ShoppingCartInfo shoppingCart, bool isCountDown, bool isSignBuy, bool isAgent) { if (shoppingCart.LineItems.Count == 0 && shoppingCart.LineGifts.Count == 0) { return(null); } OrderInfo info = new OrderInfo { Points = shoppingCart.GetPoint(), ReducedPromotionId = shoppingCart.ReducedPromotionId, ReducedPromotionName = shoppingCart.ReducedPromotionName, ReducedPromotionAmount = shoppingCart.ReducedPromotionAmount, IsReduced = shoppingCart.IsReduced, SentTimesPointPromotionId = shoppingCart.SentTimesPointPromotionId, SentTimesPointPromotionName = shoppingCart.SentTimesPointPromotionName, IsSendTimesPoint = shoppingCart.IsSendTimesPoint, TimesPoint = shoppingCart.TimesPoint, FreightFreePromotionId = shoppingCart.FreightFreePromotionId, FreightFreePromotionName = shoppingCart.FreightFreePromotionName, IsFreightFree = shoppingCart.IsFreightFree }; string str = string.Empty; if (shoppingCart.LineItems.Count > 0) { foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems) { str = str + string.Format("'{0}',", info2.SkuId); } } if (shoppingCart.LineItems.Count > 0) { foreach (ShoppingCartItemInfo info2 in shoppingCart.LineItems) { decimal costprice = new SkuDao().GetSkuItem(info2.SkuId).CostPrice; LineItemInfo info3 = new LineItemInfo { SkuId = info2.SkuId, ProductId = info2.ProductId, SKU = info2.SKU, Quantity = info2.Quantity, ShipmentQuantity = info2.ShippQuantity, ItemCostPrice = costprice, ItemListPrice = isAgent ? costprice : info2.MemberPrice, ItemAdjustedPrice = isAgent ? costprice : info2.AdjustedPrice, ItemDescription = info2.Name, ThumbnailsUrl = info2.ThumbnailUrl40, ItemWeight = info2.Weight, SKUContent = info2.SkuContent, PromotionId = info2.PromotionId, PromotionName = info2.PromotionName, MainCategoryPath = info2.MainCategoryPath, GiveQuantity = info2.GiveQuantity, HalfPriceQuantity = info2.HalfPriceQuantity }; info.LineItems.Add(info3.SkuId, info3); } } //如果有礼品在购物车内,增加礼品到订单 if (shoppingCart.LineGifts.Count > 0) { foreach (ShoppingCartGiftInfo info4 in shoppingCart.LineGifts) { OrderGiftInfo item = new OrderGiftInfo { GiftId = info4.GiftId, GiftName = info4.Name, Quantity = info4.Quantity, ThumbnailsUrl = info4.ThumbnailUrl100, CostPrice = info4.CostPrice, costPoint = info4.NeedPoint * info4.Quantity }; info.Gifts.Add(item); } } //如果当前订单内商品数量为零的话,则订单状态为已付款 if ((info.GetTotal() == 0M) && (info.LineItems.Count == 0)) { info.OrderStatus = OrderStatus.BuyerAlreadyPaid; } info.Tax = 0.00M; info.InvoiceTitle = ""; return(info); }
private void ProcessProductSkus(HttpContext context) { context.Response.ContentType = "application/json"; int num = context.Request["sourceId"].ToInt(0); int productId = int.Parse(context.Request["productId"], NumberStyles.None); int attributeId = int.Parse(context.Request["AttributeId"], NumberStyles.None); int valueId = int.Parse(context.Request["ValueId"], NumberStyles.None); int num2 = context.Request["StoreId"].ToInt(0); DataTable skuItems = ShoppingProcessor.GetUnUpUnUpsellingSkus(productId, attributeId, valueId); if (skuItems == null || skuItems.Rows.Count == 0) { context.Response.Write("{\"Status\":\"1\"}"); } else { skuItems.Columns.Add(new DataColumn { ColumnName = "SalePrice", DataType = typeof(decimal) }); bool flag = false; if (context.Request.UrlReferrer.AbsoluteUri.ToLower().Contains("fightgroup".ToLower()) && num > 0) { IList <FightGroupSkuInfo> fightGroupSkus = VShopHelper.GetFightGroupSkus(num); if (fightGroupSkus.Count > 0) { flag = true; for (int j = 0; j < skuItems.Rows.Count; j++) { DataRow row = skuItems.Rows[j]; FightGroupSkuInfo fightGroupSkuInfo = (from c in fightGroupSkus where c.SkuId == row["SkuId"].ToString() select c).FirstOrDefault(); if (fightGroupSkuInfo == null) { string skuId = skuItems.Rows[j]["skuId"].ToString(); DataTable theSku = new SkuDao().GetTheSku(skuId); if (theSku != null && theSku.Rows.Count > 0) { skuItems.Rows[j]["Stock"] = 0; skuItems.Rows[j]["SalePrice"] = theSku.Rows[0]["SalePrice"].ToDecimal(0).F2ToString("f2"); } } else { int totalCount = fightGroupSkuInfo.TotalCount; int boughtCount = fightGroupSkuInfo.BoughtCount; int num3 = totalCount - boughtCount; if (num3 > fightGroupSkuInfo.Stock) { num3 = fightGroupSkuInfo.Stock; } decimal salePrice = fightGroupSkuInfo.SalePrice; skuItems.Rows[j]["Stock"] = ((num3 >= 0) ? num3 : 0); skuItems.Rows[j]["SalePrice"] = salePrice.F2ToString("f2"); } } } } if (context.Request.UrlReferrer.AbsoluteUri.ToLower().Contains("countdown")) { CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(num, num2); if (countDownInfo != null && countDownInfo.CountDownSkuInfo != null && countDownInfo.CountDownSkuInfo.Count > 0) { flag = true; skuItems.Columns.Add(new DataColumn { ColumnName = "OldSalePrice", DataType = typeof(decimal) }); List <CountDownSkuInfo> countDownSkuInfo = countDownInfo.CountDownSkuInfo; int i; for (i = 0; i < skuItems.Rows.Count; i++) { List <CountDownSkuInfo> list = (from s in countDownSkuInfo where s.SkuId == skuItems.Rows[i]["SkuId"].ToNullString() select s).ToList(); if (list == null || list.Count == 0) { string skuId2 = list[0].SkuId.ToString(); DataTable theSku2 = new SkuDao().GetTheSku(skuId2); if (theSku2 != null && theSku2.Rows.Count > 0) { skuItems.Rows[i]["Stock"] = 0; skuItems.Rows[i]["SalePrice"] = theSku2.Rows[0]["SalePrice"].ToDecimal(0).F2ToString("f2"); skuItems.Rows[i]["OldSalePrice"] = theSku2.Rows[0]["MarketPrice"].ToDecimal(0).F2ToString("f2"); } } else { int totalCount2 = list[0].TotalCount; int boughtCount2 = list[0].BoughtCount; int num4 = totalCount2 - boughtCount2; skuItems.Rows[i]["Stock"] = ((num4 >= 0) ? num4 : 0); decimal salePrice2 = list[0].SalePrice; decimal oldSalePrice = list[0].OldSalePrice; skuItems.Rows[i]["SalePrice"] = salePrice2.F2ToString("f2"); skuItems.Rows[i]["OldSalePrice"] = oldSalePrice.F2ToString("f2"); } } } } if (context.Request.UrlReferrer.AbsoluteUri.ToLower().Contains("groupbuy")) { GroupBuyInfo groupBuy = PromoteHelper.GetGroupBuy(num); if (groupBuy != null) { flag = true; skuItems.Columns.Add(new DataColumn { ColumnName = "OldSalePrice", DataType = typeof(decimal) }); Dictionary <string, SKUItem> productSkuSaleInfo = ProductBrowser.GetProductSkuSaleInfo(productId, 0); int soldCount = PromoteHelper.GetSoldCount(groupBuy.GroupBuyId); for (int k = 0; k < skuItems.Rows.Count; k++) { DataRow dataRow = skuItems.Rows[k]; if (productSkuSaleInfo.ContainsKey(dataRow["SkuId"].ToNullString())) { SKUItem sKUItem = productSkuSaleInfo[dataRow["SkuId"].ToNullString()]; int num5 = skuItems.Rows[k]["Stock"].ToInt(0); int num6 = groupBuy.MaxCount - soldCount; if (num5 < num6) { skuItems.Rows[k]["Stock"] = num5; } else { skuItems.Rows[k]["Stock"] = num6; } skuItems.Rows[k]["SalePrice"] = groupBuy.Price.F2ToString("f2"); skuItems.Rows[k]["OldSalePrice"] = sKUItem.SalePrice.F2ToString("f2"); } } } } if (context.Request.UrlReferrer.AbsoluteUri.ToLower().Contains("presaleproductdetails") && num > 0) { ProductPreSaleInfo productPreSaleInfo = ProductPreSaleHelper.GetProductPreSaleInfo(num); if (productPreSaleInfo != null) { flag = true; Dictionary <string, SKUItem> preSaleProductSkuSaleInfo = ProductBrowser.GetPreSaleProductSkuSaleInfo(productId); foreach (DataRow row2 in skuItems.Rows) { if (preSaleProductSkuSaleInfo.ContainsKey(row2["SkuId"].ToString())) { SKUItem sKUItem2 = preSaleProductSkuSaleInfo[row2["SkuId"].ToString()]; row2["SalePrice"] = sKUItem2.SalePrice; row2["Stock"] = sKUItem2.Stock; } } } } if (!flag) { Dictionary <string, SKUItem> productSkuSaleInfo2 = ProductBrowser.GetProductSkuSaleInfo(productId, num2); string text = ""; if (num2 == 0) { text = PromoteHelper.GetPhonePriceByProductId(productId); } foreach (DataRow row3 in skuItems.Rows) { if (productSkuSaleInfo2.ContainsKey(row3["SkuId"].ToString())) { SKUItem sKUItem3 = productSkuSaleInfo2[row3["SkuId"].ToString()]; if (!string.IsNullOrEmpty(text)) { string s2 = text.Split(',')[0]; decimal num7 = (sKUItem3.SalePrice - decimal.Parse(s2) > decimal.Zero) ? (sKUItem3.SalePrice - decimal.Parse(s2)) : decimal.Zero; row3["SalePrice"] = num7.F2ToString("f2"); } else { row3["SalePrice"] = sKUItem3.SalePrice; } row3["Stock"] = sKUItem3.Stock; } else { row3["Stock"] = "0"; row3["SalePrice"] = "0.00"; } } } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{"); stringBuilder.Append("\"Status\":\"OK\","); stringBuilder.Append("\"SkuItems\":["); foreach (DataRow row4 in skuItems.Rows) { stringBuilder.Append("{"); if (skuItems.Columns.Contains("SkuId")) { stringBuilder.AppendFormat("\"SkuId\":\"{0}\",", row4["SkuId"].ToString()); } if (skuItems.Columns.Contains("SalePrice")) { stringBuilder.AppendFormat("\"SalePrice\":\"{0}\",", row4["SalePrice"].ToDecimal(0).F2ToString("f2")); } if (skuItems.Columns.Contains("OldSalePrice")) { stringBuilder.AppendFormat("\"OldSalePrice\":\"{0}\",", row4["OldSalePrice"].ToDecimal(0).F2ToString("f2")); } if (skuItems.Columns.Contains("Stock")) { stringBuilder.AppendFormat("\"Stock\":\"{0}\",", row4["Stock"].ToString()); } stringBuilder.AppendFormat("\"AttributeId\":\"{0}\",", row4["AttributeId"].ToString()); stringBuilder.AppendFormat("\"ValueId\":\"{0}\"", row4["ValueId"].ToString()); stringBuilder.Append("},"); } stringBuilder.Remove(stringBuilder.Length - 1, 1); stringBuilder.Append("]"); stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); } }
private void ProcessUnUpsellingSku(HttpContext context) { context.Response.ContentType = "application/json"; int num = context.Request["sourceId"].ToInt(0); int productId = context.Request["productId"].ToInt(0); int attributeId = context.Request["AttributeId"].ToInt(0); int valueId = context.Request["ValueId"].ToInt(0); DataTable unUpUnUpsellingSkus = ShoppingProcessor.GetUnUpUnUpsellingSkus(productId, attributeId, valueId); if (unUpUnUpsellingSkus == null || unUpUnUpsellingSkus.Rows.Count == 0) { context.Response.Write("{\"Status\":\"1\"}"); } else { if (context.Request.UrlReferrer.AbsoluteUri.ToLower().Contains("fightgroupactivitydetails".ToLower())) { unUpUnUpsellingSkus.Columns.Add(new DataColumn { ColumnName = "SalePrice", DataType = typeof(decimal) }); if (num == 0) { IList <int> list = null; Dictionary <int, IList <int> > dictionary = default(Dictionary <int, IList <int> >); ProductInfo productDetails = ProductHelper.GetProductDetails(productId, out dictionary, out list); foreach (DataRow row2 in unUpUnUpsellingSkus.Rows) { if (productDetails.Skus.ContainsKey(row2["SkuId"].ToString())) { SKUItem sKUItem = productDetails.Skus[row2["SkuId"].ToString()]; row2["SalePrice"] = sKUItem.SalePrice; row2["Stock"] = sKUItem.Stock; } } } if (num > 0) { IList <FightGroupSkuInfo> fightGroupSkus = VShopHelper.GetFightGroupSkus(num); if (fightGroupSkus.Count > 0) { for (int i = 0; i < unUpUnUpsellingSkus.Rows.Count; i++) { DataRow row = unUpUnUpsellingSkus.Rows[i]; FightGroupSkuInfo fightGroupSkuInfo = (from c in fightGroupSkus where c.SkuId == row["SkuId"].ToString() select c).FirstOrDefault(); if (fightGroupSkuInfo == null) { string skuId = unUpUnUpsellingSkus.Rows[i]["skuId"].ToString(); DataTable theSku = new SkuDao().GetTheSku(skuId); if (theSku != null && theSku.Rows.Count > 0) { unUpUnUpsellingSkus.Rows[i]["Stock"] = 0; unUpUnUpsellingSkus.Rows[i]["SalePrice"] = theSku.Rows[0]["SalePrice"].ToDecimal(0).F2ToString("f2"); } } else { int totalCount = fightGroupSkuInfo.TotalCount; int boughtCount = fightGroupSkuInfo.BoughtCount; int num2 = totalCount - boughtCount; decimal salePrice = fightGroupSkuInfo.SalePrice; unUpUnUpsellingSkus.Rows[i]["Stock"] = ((num2 >= 0) ? num2 : 0); unUpUnUpsellingSkus.Rows[i]["SalePrice"] = salePrice.F2ToString("f2"); } } } } } if (context.Request.UrlReferrer.AbsoluteUri.ToLower().Contains("countdown")) { DataTable countDownSkus = PromoteHelper.GetCountDownSkus(num, 0, false); if (countDownSkus.Rows.Count > 0) { unUpUnUpsellingSkus.Columns.Add(new DataColumn { ColumnName = "SalePrice", DataType = typeof(decimal) }); unUpUnUpsellingSkus.Columns.Add(new DataColumn { ColumnName = "OldSalePrice", DataType = typeof(decimal) }); for (int j = 0; j < unUpUnUpsellingSkus.Rows.Count; j++) { DataRow dataRow2 = unUpUnUpsellingSkus.Rows[j]; DataRow[] array = countDownSkus.Select(string.Format(" SkuId='{0}'", dataRow2["SkuId"])); if (array.Length == 0) { string skuId2 = unUpUnUpsellingSkus.Rows[j]["skuId"].ToString(); DataTable theSku2 = new SkuDao().GetTheSku(skuId2); if (theSku2 != null && theSku2.Rows.Count > 0) { unUpUnUpsellingSkus.Rows[j]["Stock"] = 0; unUpUnUpsellingSkus.Rows[j]["SalePrice"] = theSku2.Rows[0]["SalePrice"].ToDecimal(0).F2ToString("f2"); unUpUnUpsellingSkus.Rows[j]["OldSalePrice"] = theSku2.Rows[0]["MarketPrice"].ToDecimal(0).F2ToString("f2"); } } else { int num3 = array[0]["TotalCount"].ToInt(0); int num4 = array[0]["BoughtCount"].ToInt(0); int num5 = num3 - num4; decimal num6 = array[0]["SalePrice"].ToDecimal(0); decimal num7 = array[0]["OldSalePrice"].ToDecimal(0); unUpUnUpsellingSkus.Rows[j]["Stock"] = ((num5 >= 0) ? num5 : 0); unUpUnUpsellingSkus.Rows[j]["SalePrice"] = num6.F2ToString("f2"); unUpUnUpsellingSkus.Rows[j]["OldSalePrice"] = num7.F2ToString("f2"); } } } } StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("{"); stringBuilder.Append("\"Status\":\"OK\","); stringBuilder.Append("\"SkuItems\":["); foreach (DataRow row3 in unUpUnUpsellingSkus.Rows) { stringBuilder.Append("{"); if (unUpUnUpsellingSkus.Columns.Contains("SkuId")) { stringBuilder.AppendFormat("\"SkuId\":\"{0}\",", row3["SkuId"].ToString()); } if (unUpUnUpsellingSkus.Columns.Contains("SalePrice")) { stringBuilder.AppendFormat("\"SalePrice\":\"{0}\",", row3["SalePrice"].ToString()); } if (unUpUnUpsellingSkus.Columns.Contains("OldSalePrice")) { stringBuilder.AppendFormat("\"OldSalePrice\":\"{0}\",", row3["OldSalePrice"].ToString()); } if (unUpUnUpsellingSkus.Columns.Contains("Stock")) { stringBuilder.AppendFormat("\"Stock\":\"{0}\",", row3["Stock"].ToString()); } stringBuilder.AppendFormat("\"AttributeId\":\"{0}\",", row3["AttributeId"].ToString()); stringBuilder.AppendFormat("\"ValueId\":\"{0}\"", row3["ValueId"].ToString()); stringBuilder.Append("},"); } stringBuilder.Remove(stringBuilder.Length - 1, 1); stringBuilder.Append("]"); stringBuilder.Append("}"); context.Response.Write(stringBuilder.ToString()); } }