예제 #1
0
        public void CloseOrderToReduceFightGroup(int fightGroupId, string skuId, int quantity)
        {
            FightGroupInfo fightGroupInfo = this.Get <FightGroupInfo>(fightGroupId);

            if (fightGroupInfo != null)
            {
                FightGroupSkuInfo groupSkuInfoByActivityIdSkuId = this.GetGroupSkuInfoByActivityIdSkuId(fightGroupInfo.FightGroupActivityId, skuId);
                if (groupSkuInfoByActivityIdSkuId != null)
                {
                    groupSkuInfoByActivityIdSkuId.BoughtCount -= quantity;
                    this.Update(groupSkuInfoByActivityIdSkuId, null);
                }
            }
        }
예제 #2
0
        private void CloseOrderToReduceFightGroup(int fightGroupId, string skuId, int quantity)
        {
            BaseDao        baseDao        = new BaseDao();
            FightGroupInfo fightGroupInfo = baseDao.Get <FightGroupInfo>(fightGroupId);

            if (fightGroupInfo != null)
            {
                FightGroupSkuInfo groupSkuInfoByActivityIdSkuId = this.GetGroupSkuInfoByActivityIdSkuId(fightGroupInfo.FightGroupActivityId, skuId);
                if (groupSkuInfoByActivityIdSkuId != null)
                {
                    groupSkuInfoByActivityIdSkuId.BoughtCount -= quantity;
                    baseDao.Update(groupSkuInfoByActivityIdSkuId, null);
                }
            }
        }
예제 #3
0
        public static bool ManageFightGroupOrder(OrderInfo orderInfo, DbTransaction dbTran)
        {
            FightGroupDao fightGroupDao = new FightGroupDao();

            if (orderInfo.FightGroupId == 0)
            {
                FightGroupActivityInfo fightGroupActivityInfo = fightGroupDao.Get <FightGroupActivityInfo>(orderInfo.FightGroupActivityId);
                if (fightGroupActivityInfo == null)
                {
                    return(false);
                }
                DateTime endTime = DateTime.Now.AddHours((double)fightGroupActivityInfo.LimitedHour);
                int      num     = fightGroupDao.CreateFightGroup(orderInfo.FightGroupActivityId, orderInfo.OrderId, endTime, dbTran);
                if (num == 0)
                {
                    return(false);
                }
                orderInfo.FightGroupId     = num;
                orderInfo.IsFightGroupHead = true;
            }
            else
            {
                orderInfo.IsFightGroupHead = false;
            }
            foreach (LineItemInfo value in orderInfo.LineItems.Values)
            {
                FightGroupSkuInfo groupSkuInfoByActivityIdSkuId = fightGroupDao.GetGroupSkuInfoByActivityIdSkuId(orderInfo.FightGroupActivityId, value.SkuId);
                if (groupSkuInfoByActivityIdSkuId != null)
                {
                    groupSkuInfoByActivityIdSkuId.BoughtCount += value.Quantity;
                    if (!fightGroupDao.Update(groupSkuInfoByActivityIdSkuId, dbTran))
                    {
                        return(false);
                    }
                }
            }
            return(true);
        }
        private void btnSaveFightGroupActivitiy_Click(object sender, EventArgs e)
        {
            FightGroupActivityInfo   fightGroupActivitieInfo = VShopHelper.GetFightGroupActivitieInfo(this.fightGroupActivityId);
            List <FightGroupSkuInfo> list = new List <FightGroupSkuInfo>();

            if (fightGroupActivitieInfo == null)
            {
                this.ShowMsg("火拼团不存在", false, "FightGroupActivitiyList.aspx");
                return;
            }
            if (this.productId > 0)
            {
                fightGroupActivitieInfo.ProductId = this.productId;
            }
            else
            {
                this.productId = fightGroupActivitieInfo.ProductId;
            }
            string text  = Globals.StripAllTags(this.txtFightGroupShareTitle.Text.Trim());
            string text2 = Globals.StripAllTags(this.txtFightGroupShareDetails.Text.Trim());
            int    num;

            if ((this.rbtlTitle.SelectedIndex != 1 || (!string.IsNullOrEmpty(text) && text.Length <= 60)) && !string.IsNullOrEmpty(text2))
            {
                num = ((text2.Length > 60) ? 1 : 0);
                goto IL_00c4;
            }
            num = 1;
            goto IL_00c4;
IL_00c4:
            if (num != 0)
            {
                this.ShowMsg("请按要求输入分享标题和详情", false);
            }
            else
            {
                if (this.rbtlTitle.SelectedIndex == 0)
                {
                    fightGroupActivitieInfo.ShareTitle = "";
                }
                else
                {
                    fightGroupActivitieInfo.ShareTitle = text;
                }
                fightGroupActivitieInfo.ShareContent = text2;
                if (this.rptProductSkus.Items.Count > 0)
                {
                    for (int i = 0; i < this.rptProductSkus.Items.Count; i++)
                    {
                        RepeaterItem      repeaterItem = this.rptProductSkus.Items[i];
                        HiddenField       hiddenField  = repeaterItem.FindControl("hfSkuId") as HiddenField;
                        TextBox           textBox      = repeaterItem.FindControl("txtActivityStock") as TextBox;
                        HiddenField       hiddenField2 = repeaterItem.FindControl("hidSalePrice") as HiddenField;
                        FightGroupSkuInfo item         = new FightGroupSkuInfo
                        {
                            SalePrice            = hiddenField2.Value.Trim().ToDecimal(0),
                            TotalCount           = textBox.Text.Trim().ToInt(0),
                            SkuId                = hiddenField.Value,
                            FightGroupActivityId = fightGroupActivitieInfo.FightGroupActivityId
                        };
                        list.Add(item);
                    }
                    if (this.rptProductSkus.Items.Count == 0 && this.txtTotalCount.Text.Trim().ToInt(0) == 0)
                    {
                        this.ShowMsg("请填写活动库存", false);
                        return;
                    }
                }
                if (!this.CPEndDate.SelectedDate.HasValue)
                {
                    this.ShowMsg(Formatter.FormatErrorMessage("请填写结束时间"), false);
                }
                else
                {
                    fightGroupActivitieInfo.EndDate = this.CPEndDate.SelectedDate.Value;
                    if (fightGroupActivitieInfo.StartDate >= fightGroupActivitieInfo.EndDate)
                    {
                        this.ShowMsg(Formatter.FormatErrorMessage("结束时间要大于开始时间"), false);
                    }
                    else if (this.txtMaxCount.Text.Trim().ToInt(0) == 0)
                    {
                        this.ShowMsg("请填写每人限购数量", false);
                    }
                    else
                    {
                        fightGroupActivitieInfo.MaxCount = this.txtMaxCount.Text.ToInt(0);
                        int num2 = 0;
                        num2 = ((this.rptProductSkus.Items.Count == 0) ? this.txtTotalCount.Text.Trim().ToInt(0) : list.Sum((FightGroupSkuInfo c) => c.TotalCount));
                        if (fightGroupActivitieInfo.MaxCount > num2)
                        {
                            this.ShowMsg(Formatter.FormatErrorMessage("每人限购数量不能大于活动库存"), false);
                        }
                        else if (list.Count > 0 && fightGroupActivitieInfo.MaxCount > (from c in list
                                                                                       where c.TotalCount > 0
                                                                                       select c).Min((FightGroupSkuInfo c) => c.TotalCount))
                        {
                            this.ShowMsg(Formatter.FormatErrorMessage("每人限购数量不能大于规格的最小活动库存"), false);
                        }
                        else
                        {
                            fightGroupActivitieInfo.Icon = Globals.SaveFile("GroupActivitie", this.hidUploadLogo.Value, "/Storage/master/", true, false, "");
                            this.hidUploadLogo.Value     = fightGroupActivitieInfo.Icon;
                            IList <int> list2 = null;
                            Dictionary <int, IList <int> > dictionary = default(Dictionary <int, IList <int> >);
                            ProductInfo productDetails = ProductHelper.GetProductDetails(fightGroupActivitieInfo.ProductId, out dictionary, out list2);
                            if (productDetails != null)
                            {
                                fightGroupActivitieInfo.ProductName = productDetails.ProductName;
                                if (productDetails.Stock < fightGroupActivitieInfo.MaxCount)
                                {
                                    this.ShowMsg("库存小于每人限购数量", false);
                                    return;
                                }
                                if (productDetails.Stock < num2)
                                {
                                    this.ShowMsg($"当前活动库存为 {num2},商品库存小于活动库存", false);
                                    return;
                                }
                                if (list.Count > 0)
                                {
                                    foreach (KeyValuePair <string, SKUItem> sku in productDetails.Skus)
                                    {
                                        FightGroupSkuInfo fightGroupSkuInfo = (from s in list
                                                                               where s.SkuId == sku.Value.SkuId
                                                                               select s).FirstOrDefault();
                                        if (fightGroupSkuInfo == null)
                                        {
                                            this.ShowMsg("规格不存在,请重新刷新页面", false);
                                            return;
                                        }
                                        if (fightGroupSkuInfo.TotalCount > sku.Value.Stock)
                                        {
                                            this.ShowMsg($"当前规格活动库存为 {fightGroupSkuInfo.TotalCount},商品库存小于活动库存", false);
                                            return;
                                        }
                                    }
                                }
                            }
                            if (list.Count == 0)
                            {
                                DataTable skusByProductId = ProductHelper.GetSkusByProductId(this.productId);
                                if (skusByProductId.Rows.Count > 0)
                                {
                                    DataRow           dataRow = skusByProductId.Rows[0];
                                    FightGroupSkuInfo item2   = new FightGroupSkuInfo
                                    {
                                        SalePrice            = this.ltPrice.Text.Trim().ToDecimal(0),
                                        TotalCount           = num2,
                                        SkuId                = dataRow["SkuId"].ToNullString(),
                                        FightGroupActivityId = fightGroupActivitieInfo.FightGroupActivityId
                                    };
                                    list.Add(item2);
                                }
                            }
                            if (VShopHelper.CanAddFightGroupActivitiy(fightGroupActivitieInfo.ProductId, productDetails.ProductName, fightGroupActivitieInfo.FightGroupActivityId))
                            {
                                VShopHelper.EditFightGroupActivitie(fightGroupActivitieInfo, list);
                                this.ShowMsg("保存火拼团活动成功", true, "FightGroupActivitiyList.aspx");
                            }
                            else
                            {
                                this.ShowMsg("该商品正在参加其他活动,无法同时参加拼团活动", false);
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
        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());
            }
        }
예제 #6
0
        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());
            }
        }