Esempio n. 1
0
        private void BindCountDown()
        {
            CountDownInfo countDownInfo = PromoteHelper.GetCountDownInfo(this.countDownId, 0);

            if (countDownInfo.StartDate <= DateTime.Now && countDownInfo.EndDate > DateTime.Now)
            {
                this.aChoiceProduct.Visible = false;
                this.CPStartTime.Enabled    = false;
            }
            DataTable countDownSkus = PromoteHelper.GetCountDownSkus(this.countDownId, 0, false);

            if (SettingsManager.GetMasterSettings().OpenMultStore)
            {
                List <StoreBase> activityStores = StoreActivityHelper.GetActivityStores(this.countDownId, 2, countDownInfo.StoreType);
                this.hidStoreIds.Value = (from t in activityStores
                                          select t.StoreId.ToString()).Aggregate((string t, string n) => t + "," + n);
            }
            else
            {
                this.hidStoreIds.Value = "";
            }
            int num = 0;

            if (countDownSkus.Rows.Count == 1)
            {
                DataRow dataRow = countDownSkus.Rows[0];
                this.txtPrice.Text      = dataRow["SalePrice"].ToDecimal(0).F2ToString("f2");
                this.txtTotalCount.Text = dataRow["TotalCount"].ToNullString();
                num = dataRow["BoughtCount"].ToInt(0);
            }
            else
            {
                for (int i = 0; i < countDownSkus.Rows.Count; i++)
                {
                    num += countDownSkus.Rows[i]["BoughtCount"].ToInt(0);
                }
            }
            this.txtContent.Text          = Globals.HtmlDecode(countDownInfo.Content);
            this.txtMaxCount.Text         = Convert.ToString(countDownInfo.MaxCount);
            this.ltBoughtCount.Text       = num.ToString();
            this.CPEndDate.SelectedDate   = countDownInfo.EndDate;
            this.CPStartTime.SelectedDate = countDownInfo.StartDate;
            this.txtShareDetails.Text     = countDownInfo.ShareDetails;
            this.txtShareTitle.Text       = countDownInfo.ShareTitle;
            this.hidUploadLogo.Value      = countDownInfo.ShareIcon;
        }
Esempio n. 2
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());
            }
        }