public void ProcessRequest(HttpContext context)
 {
     context.Response.ContentType = "text/plain";
     int result = 0;
     int.TryParse(context.Request.Params["id"], out result);
     if (result > 0)
     {
         int num2;
         int num3;
         PointExChangeInfo info = PointExChangeHelper.Get(result);
         string str = context.Request.Params["sort"];
         if (string.IsNullOrWhiteSpace(str))
         {
             str = "ProductId";
         }
         string str2 = context.Request.Params["order"];
         if (string.IsNullOrWhiteSpace(str2))
         {
             str2 = "asc";
         }
         if (!int.TryParse(context.Request.Params["page"], out num2))
         {
             num2 = 1;
         }
         if (!int.TryParse(context.Request.Params["size"], out num3))
         {
             num3 = 10;
         }
         if ((info.BeginDate <= DateTime.Now) && (info.EndDate >= DateTime.Now))
         {
             int num4;
             DataTable table = PointExChangeHelper.GetProducts(result, num2, num3, out num4, str, str2);
             foreach (DataRow row in table.Rows)
             {
                 if (row["ProductNumber"].ToString() == "0")
                 {
                     int num5 = 0;
                     int.TryParse(row["ProductId"].ToString(), out num5);
                     ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), num5);
                     if ((product != null) && (product.SaleStatus == ProductSaleStatus.OnSale))
                     {
                         row["ProductNumber"] = product.Stock.ToString();
                     }
                 }
                 else
                 {
                     int num6 = 0;
                     int.TryParse(row["ProductId"].ToString(), out num6);
                     int num7 = 0;
                     int.TryParse(row["ProductNumber"].ToString(), out num7);
                     int productExchangedCount = PointExChangeHelper.GetProductExchangedCount(result, num6);
                     int num9 = ((num7 - productExchangedCount) >= 0) ? (num7 - productExchangedCount) : 0;
                     row["ProductNumber"] = num9;
                 }
             }
             string s = JsonConvert.SerializeObject(table, Formatting.Indented);
             context.Response.Write(s);
         }
     }
 }
        protected override void AttachChildControls()
        {
            if (!int.TryParse(this.Page.Request.QueryString["productId"], out this.productId) || !int.TryParse(this.Page.Request.QueryString["exchangeId"], out this.exchangeId))
            {
                base.GotoResourceNotFound("");
            }
            this.rptProductImages      = (VshopTemplatedRepeater)this.FindControl("rptProductImages");
            this.litItemParams         = (Literal)this.FindControl("litItemParams");
            this.litProdcutName        = (Literal)this.FindControl("litProdcutName");
            this.litSalePoint          = (Literal)this.FindControl("litSalePoint");
            this.litMarketPrice        = (Literal)this.FindControl("litMarketPrice");
            this.litShortDescription   = (Literal)this.FindControl("litShortDescription");
            this.litSurplusTime        = (Literal)this.FindControl("litSurplusTime");
            this.litDescription        = (Literal)this.FindControl("litDescription");
            this.litStock              = (Literal)this.FindControl("litStock");
            this.litEachCount          = (Literal)this.FindControl("litEachCount");
            this.skuSelector           = (Common_SKUSelector)this.FindControl("skuSelector");
            this.linkDescription       = (HyperLink)this.FindControl("linkDescription");
            this.expandAttr            = (Common_ExpandAttributes)this.FindControl("ExpandAttributes");
            this.litSoldCount          = (Literal)this.FindControl("litSoldCount");
            this.litConsultationsCount = (Literal)this.FindControl("litConsultationsCount");
            this.litReviewsCount       = (Literal)this.FindControl("litReviewsCount");
            this.hdHasCollected        = (HtmlInputHidden)this.FindControl("hdHasCollected");
            this.hdCategoryId          = (HtmlInputHidden)this.FindControl("hdCategoryId");
            this.hdEachCount           = (HtmlInputHidden)this.FindControl("hdEachCount");
            this.hdProductId           = (HtmlInputHidden)this.FindControl("hdProductId");
            this.hdStock         = (HtmlInputHidden)this.FindControl("hdStock");
            this.hdIsActive      = (HtmlInputHidden)this.FindControl("hdIsActive");
            this.hdIsInRange     = (HtmlInputHidden)this.FindControl("hdIsInRange");
            this.hdPoint         = (HtmlInputHidden)this.FindControl("hdPoint");
            this.hdTemplateid    = (HtmlInputHidden)this.FindControl("hdTemplateid");
            this.hdUserExchanged = (HtmlInputHidden)this.FindControl("hdUserExchanged");
            PointExChangeInfo        info        = PointExChangeHelper.Get(this.exchangeId);
            PointExchangeProductInfo productInfo = PointExChangeHelper.GetProductInfo(this.exchangeId, this.productId);
            ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), this.productId);

            if (((info != null) && (product != null)) && (productInfo != null))
            {
                MemberInfo currentMember = MemberProcessor.GetCurrentMember();
                if (currentMember != null)
                {
                    this.hdPoint.Value = currentMember.Points.ToString();
                    if (MemberProcessor.CheckCurrentMemberIsInRange(info.MemberGrades, info.DefualtGroup, info.CustomGroup))
                    {
                        this.hdIsInRange.Value = "true";
                    }
                    else
                    {
                        this.hdIsInRange.Value = "false";
                    }
                }
                if (info.EndDate < DateTime.Now)
                {
                    this.litSurplusTime.Text = "已结束";
                    this.hdIsActive.Value    = "0";
                }
                else if (info.BeginDate > DateTime.Now)
                {
                    this.litSurplusTime.Text = "未开始";
                    this.hdIsActive.Value    = "0";
                }
                else
                {
                    this.hdIsActive.Value = "1";
                    TimeSpan span = (TimeSpan)(info.EndDate - DateTime.Now);
                    if (span.Days > 1)
                    {
                        this.litSurplusTime.Text = string.Concat(new object[] { "还剩", span.Days, "天", span.Hours, "小时" });
                    }
                    else
                    {
                        this.litSurplusTime.Text = "还剩" + span.Hours + "小时";
                    }
                }
                this.hdProductId.Value = this.productId.ToString();
                if (product == null)
                {
                    base.GotoResourceNotFound("此商品已不存在");
                }
                if (product.SaleStatus != ProductSaleStatus.OnSale)
                {
                    base.GotoResourceNotFound(ErrorType.前台商品下架, "此商品已下架");
                }
                if (this.rptProductImages != null)
                {
                    string       locationUrl = "javascript:;";
                    SlideImage[] imageArray  = new SlideImage[] { new SlideImage(product.ImageUrl1, locationUrl), new SlideImage(product.ImageUrl2, locationUrl), new SlideImage(product.ImageUrl3, locationUrl), new SlideImage(product.ImageUrl4, locationUrl), new SlideImage(product.ImageUrl5, locationUrl) };
                    this.rptProductImages.DataSource = from item in imageArray
                                                       where !string.IsNullOrWhiteSpace(item.ImageUrl)
                                                       select item;
                    this.rptProductImages.DataBind();
                }
                string mainCategoryPath = product.MainCategoryPath;
                if (!string.IsNullOrEmpty(mainCategoryPath))
                {
                    this.hdCategoryId.Value = mainCategoryPath.Split(new char[] { '|' })[0];
                }
                else
                {
                    this.hdCategoryId.Value = "0";
                }
                this.litProdcutName.Text = product.ProductName;
                this.hdTemplateid.Value  = product.FreightTemplateId.ToString();
                this.litSalePoint.Text   = productInfo.PointNumber.ToString();
                if (product.MarketPrice.HasValue && (product.MarketPrice > 0M))
                {
                    this.litMarketPrice.Text = "<del class=\"text-muted font-s\">\x00a5" + product.MarketPrice.Value.ToString("F2") + "</del>";
                }
                this.litShortDescription.Text = product.ShortDescription;
                string description = product.Description;
                if (!string.IsNullOrEmpty(description))
                {
                    description = Regex.Replace(description, "<img[^>]*\\bsrc=('|\")([^'\">]*)\\1[^>]*>", "<img alt='" + HttpContext.Current.Server.HtmlEncode(product.ProductName) + "' src='$2' />", RegexOptions.IgnoreCase);
                }
                if (this.litDescription != null)
                {
                    this.litDescription.Text = description;
                }
                this.litSoldCount.SetWhenIsNotNull(product.ShowSaleCounts.ToString());
                int productExchangedCount = PointExChangeHelper.GetProductExchangedCount(this.exchangeId, this.productId);
                int num2 = ((productInfo.ProductNumber - productExchangedCount) >= 0) ? (productInfo.ProductNumber - productExchangedCount) : 0;
                this.litStock.Text         = num2.ToString();
                this.hdStock.Value         = num2.ToString();
                this.litEachCount.Text     = productInfo.EachMaxNumber.ToString();
                this.hdEachCount.Value     = productInfo.EachMaxNumber.ToString();
                this.skuSelector.ProductId = this.productId;
                if (this.expandAttr != null)
                {
                    this.expandAttr.ProductId = this.productId;
                }
                if (this.linkDescription != null)
                {
                    this.linkDescription.NavigateUrl = "/Vshop/ProductDescription.aspx?productId=" + this.productId;
                }
                int productConsultationsCount = ProductBrowser.GetProductConsultationsCount(this.productId, false);
                this.litConsultationsCount.SetWhenIsNotNull(productConsultationsCount.ToString());
                this.litReviewsCount.SetWhenIsNotNull(ProductBrowser.GetProductReviewsCount(this.productId).ToString());
                bool flag = false;
                if (currentMember != null)
                {
                    this.hdUserExchanged.Value = PointExChangeHelper.GetUserProductExchangedCount(this.exchangeId, this.productId, currentMember.UserId).ToString();
                    flag = ProductBrowser.CheckHasCollect(currentMember.UserId, this.productId);
                    this.hdHasCollected.SetWhenIsNotNull(flag ? "1" : "0");
                }
                ProductBrowser.UpdateVisitCounts(this.productId);
                PageTitle.AddSiteNameTitle("积分商品");
                SiteSettings masterSettings = SettingsManager.GetMasterSettings(false);
                string       objStr         = "";
                if (!string.IsNullOrEmpty(masterSettings.GoodsPic))
                {
                    objStr = Globals.HostPath(HttpContext.Current.Request.Url) + masterSettings.GoodsPic;
                }
                this.litItemParams.Text = Globals.GetReplaceStr(objStr, "|", "|") + "|" + Globals.GetReplaceStr(masterSettings.GoodsName, "|", "|") + "|" + Globals.GetReplaceStr(masterSettings.GoodsDescription, "|", "|") + "$" + Globals.HostPath(HttpContext.Current.Request.Url).Replace("|", "|") + Globals.GetReplaceStr(product.ImageUrl1, "|", "|") + "|" + Globals.GetReplaceStr(product.ProductName, "|", "|") + "|" + Globals.GetReplaceStr(product.ShortDescription, "|", "|") + "|" + HttpContext.Current.Request.Url.ToString().Replace("|", "|");
            }
            else
            {
                HttpContext.Current.Response.Redirect("/default.aspx");
                HttpContext.Current.Response.End();
            }
        }
Esempio n. 3
0
        protected void grdProducts_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            string commandName = e.CommandName;

            switch (commandName)
            {
            case "Renew":
                if (!string.IsNullOrEmpty(base.Request["id"].ToString()))
                {
                    int    exchangeId = int.Parse(base.Request["id"]);
                    string productIds = e.CommandArgument.ToString();
                    if (PointExChangeHelper.SetProductsStatus(exchangeId, 0, productIds))
                    {
                        this.ShowMsg("恢复商品成功", true);
                        this.BindProducts(this.exchangeId);
                        return;
                    }
                    this.ShowMsg("恢复商品失败", false);
                    return;
                }
                break;

            case "Pause":
                if (!string.IsNullOrEmpty(base.Request["id"].ToString()))
                {
                    int    num2 = int.Parse(base.Request["id"]);
                    string str3 = e.CommandArgument.ToString();
                    if (PointExChangeHelper.SetProductsStatus(num2, 1, str3))
                    {
                        this.ShowMsg("暂停商品成功", true);
                        this.BindProducts(this.exchangeId);
                        return;
                    }
                    this.ShowMsg("暂停商品失败", false);
                    return;
                }
                break;

            default:
                if ((commandName == "Delete") && !string.IsNullOrEmpty(base.Request["id"].ToString()))
                {
                    int    num3 = int.Parse(base.Request["id"]);
                    string str4 = e.CommandArgument.ToString();
                    if (!string.IsNullOrEmpty(str4))
                    {
                        if (PointExChangeHelper.GetProductExchangedCount(num3, int.Parse(str4)) > 0)
                        {
                            this.ShowMsg("该商品已经存在兑换记录,不能移除!", false);
                            return;
                        }
                        if (PointExChangeHelper.DeleteProducts(num3, str4))
                        {
                            this.ShowMsg("删除商品成功", true);
                            this.BindProducts(this.exchangeId);
                            return;
                        }
                        this.ShowMsg("删除商品失败", false);
                    }
                }
                break;
            }
        }
Esempio n. 4
0
        protected override void AttachChildControls()
        {
            if (!int.TryParse(this.Page.Request.QueryString["productId"], out this.productId) || !int.TryParse(this.Page.Request.QueryString["exchangeId"], out this.exchangeId))
            {
                base.GotoResourceNotFound("");
            }
            this.rptProductImages      = (VshopTemplatedRepeater)this.FindControl("rptProductImages");
            this.litItemParams         = (Literal)this.FindControl("litItemParams");
            this.litProdcutName        = (Literal)this.FindControl("litProdcutName");
            this.litActivities         = (Literal)this.FindControl("litActivities");
            this.litSalePoint          = (Literal)this.FindControl("litSalePoint");
            this.litMarketPrice        = (Literal)this.FindControl("litMarketPrice");
            this.litShortDescription   = (Literal)this.FindControl("litShortDescription");
            this.litSurplusTime        = (Literal)this.FindControl("litSurplusTime");
            this.litDescription        = (Literal)this.FindControl("litDescription");
            this.litStock              = (Literal)this.FindControl("litStock");
            this.litEachCount          = (Literal)this.FindControl("litEachCount");
            this.skuSelector           = (Common_SKUSelector)this.FindControl("skuSelector");
            this.linkDescription       = (HyperLink)this.FindControl("linkDescription");
            this.expandAttr            = (Common_ExpandAttributes)this.FindControl("ExpandAttributes");
            this.litSoldCount          = (Literal)this.FindControl("litSoldCount");
            this.litConsultationsCount = (Literal)this.FindControl("litConsultationsCount");
            this.litReviewsCount       = (Literal)this.FindControl("litReviewsCount");
            this.hdHasCollected        = (HtmlInputHidden)this.FindControl("hdHasCollected");
            this.hdCategoryId          = (HtmlInputHidden)this.FindControl("hdCategoryId");
            this.hdEachCount           = (HtmlInputHidden)this.FindControl("hdEachCount");
            this.hdProductId           = (HtmlInputHidden)this.FindControl("hdProductId");
            this.hdStock         = (HtmlInputHidden)this.FindControl("hdStock");
            this.hdIsActive      = (HtmlInputHidden)this.FindControl("hdIsActive");
            this.hdNeedGrade     = (HtmlInputHidden)this.FindControl("hdNeedGrade");
            this.hdGradeId       = (HtmlInputHidden)this.FindControl("hdGradeId");
            this.hdPoint         = (HtmlInputHidden)this.FindControl("hdPoint");
            this.hdTemplateid    = (HtmlInputHidden)this.FindControl("hdTemplateid");
            this.hdUserExchanged = (HtmlInputHidden)this.FindControl("hdUserExchanged");
            PointExChangeInfo        info        = PointExChangeHelper.Get(this.exchangeId);
            PointExchangeProductInfo productInfo = PointExChangeHelper.GetProductInfo(this.exchangeId, this.productId);
            ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), this.productId);

            if (((info != null) && (product != null)) && (productInfo != null))
            {
                MemberInfo currentMember = MemberProcessor.GetCurrentMember();
                if (currentMember != null)
                {
                    this.hdGradeId.Value   = currentMember.GradeId.ToString();
                    this.hdPoint.Value     = currentMember.Points.ToString();
                    this.hdNeedGrade.Value = info.MemberGrades;
                    if (info.EndDate < DateTime.Now)
                    {
                        this.litSurplusTime.Text = "已结束";
                        this.hdIsActive.Value    = "0";
                    }
                    else if (info.BeginDate > DateTime.Now)
                    {
                        this.litSurplusTime.Text = "未开始";
                        this.hdIsActive.Value    = "0";
                    }
                    else
                    {
                        this.hdIsActive.Value = "1";
                        TimeSpan span = (TimeSpan)(info.EndDate - DateTime.Now);
                        if (span.Days > 1)
                        {
                            this.litSurplusTime.Text = string.Concat(new object[] { "还剩", span.Days, "天", span.Hours, "小时" });
                        }
                        else
                        {
                            this.litSurplusTime.Text = "还剩" + span.Hours + "小时";
                        }
                    }
                    this.hdProductId.Value = this.productId.ToString();
                    if (!string.IsNullOrEmpty(product.MainCategoryPath))
                    {
                        DataTable allFull = ProductBrowser.GetAllFull(int.Parse(product.MainCategoryPath.Split(new char[] { '|' })[0].ToString()));
                        this.litActivities.Text = "<div class=\"price clearfix\"><span class=\"title\">促销活动:</span><div class=\"all-action\">";
                        if (allFull.Rows.Count > 0)
                        {
                            for (int i = 0; i < allFull.Rows.Count; i++)
                            {
                                if (i == 0)
                                {
                                    object text = this.litActivities.Text;
                                    this.litActivities.Text = string.Concat(new object[] { text, "<div class=\"action\"><span class=\"purchase\"><a href=\"/Vshop/ActivityDetail.aspx?ActivitiesId=", allFull.Rows[i]["ActivitiesId"], "&CategoryId=", allFull.Rows[i]["ActivitiesType"], "\">", allFull.Rows[i]["ActivitiesName"].ToString(), "满", decimal.Parse(allFull.Rows[i]["MeetMoney"].ToString()).ToString("0"), "减", decimal.Parse(allFull.Rows[i]["ReductionMoney"].ToString()).ToString("0"), "</a>&nbsp;&nbsp;</span></div>" });
                                }
                                else
                                {
                                    object obj3 = this.litActivities.Text;
                                    this.litActivities.Text = string.Concat(new object[] { obj3, "<div class=\"action actionnone\"><span class=\"purchase\"><a href=\"/Vshop/ActivityDetail.aspx?ActivitiesId=", allFull.Rows[i]["ActivitiesId"], "&CategoryId=", allFull.Rows[i]["ActivitiesType"], "\">", allFull.Rows[i]["ActivitiesName"].ToString(), "满", decimal.Parse(allFull.Rows[i]["MeetMoney"].ToString()).ToString("0"), "减", decimal.Parse(allFull.Rows[i]["ReductionMoney"].ToString()).ToString("0"), "</a>&nbsp;&nbsp;</span></div>" });
                                }
                            }
                            this.litActivities.Text = this.litActivities.Text + "</div><em>&nbsp;more</em></div>";
                        }
                        else
                        {
                            this.litActivities.Text = "";
                        }
                    }
                    if (!string.IsNullOrEmpty(this.litActivities.Text) && (product == null))
                    {
                        base.GotoResourceNotFound("此商品已不存在");
                    }
                    if (product.SaleStatus != ProductSaleStatus.OnSale)
                    {
                        base.GotoResourceNotFound("此商品已下架");
                    }
                    if (this.rptProductImages != null)
                    {
                        string       locationUrl = "javascript:;";
                        SlideImage[] imageArray  = new SlideImage[] { new SlideImage(product.ImageUrl1, locationUrl), new SlideImage(product.ImageUrl2, locationUrl), new SlideImage(product.ImageUrl3, locationUrl), new SlideImage(product.ImageUrl4, locationUrl), new SlideImage(product.ImageUrl5, locationUrl) };
                        this.rptProductImages.DataSource = from item in imageArray
                                                           where !string.IsNullOrWhiteSpace(item.ImageUrl)
                                                           select item;
                        this.rptProductImages.DataBind();
                    }
                    string mainCategoryPath = product.MainCategoryPath;
                    if (!string.IsNullOrEmpty(mainCategoryPath))
                    {
                        this.hdCategoryId.Value = mainCategoryPath.Split(new char[] { '|' })[0];
                    }
                    else
                    {
                        this.hdCategoryId.Value = "0";
                    }
                    this.litProdcutName.Text = product.ProductName;
                    this.hdTemplateid.Value  = product.FreightTemplateId.ToString();
                    this.litSalePoint.Text   = productInfo.PointNumber.ToString();
                    if (product.MarketPrice.HasValue)
                    {
                        this.litMarketPrice.SetWhenIsNotNull(product.MarketPrice.GetValueOrDefault(0M).ToString("F2"));
                    }
                    this.litShortDescription.Text = product.ShortDescription;
                    if (this.litDescription != null)
                    {
                        this.litDescription.Text = product.Description;
                    }
                    this.litSoldCount.SetWhenIsNotNull(product.ShowSaleCounts.ToString());
                    int productExchangedCount = PointExChangeHelper.GetProductExchangedCount(this.exchangeId, this.productId);
                    int num3 = ((productInfo.ProductNumber - productExchangedCount) >= 0) ? (productInfo.ProductNumber - productExchangedCount) : 0;
                    this.litStock.Text         = num3.ToString();
                    this.hdStock.Value         = num3.ToString();
                    this.litEachCount.Text     = productInfo.EachMaxNumber.ToString();
                    this.hdEachCount.Value     = productInfo.EachMaxNumber.ToString();
                    this.hdUserExchanged.Value = PointExChangeHelper.GetUserProductExchangedCount(this.exchangeId, this.productId, currentMember.UserId).ToString();
                    this.skuSelector.ProductId = this.productId;
                    if (this.expandAttr != null)
                    {
                        this.expandAttr.ProductId = this.productId;
                    }
                    if (this.linkDescription != null)
                    {
                        this.linkDescription.NavigateUrl = "/Vshop/ProductDescription.aspx?productId=" + this.productId;
                    }

                    int productConsultationsCount = ProductBrowser.GetProductConsultationsCount(this.productId, false, currentMember.UserId);
                    this.litConsultationsCount.SetWhenIsNotNull(productConsultationsCount.ToString());
                    this.litReviewsCount.SetWhenIsNotNull(ProductBrowser.GetProductReviewsCount(this.productId, currentMember.UserId).ToString());
                    bool flag = false;
                    flag = ProductBrowser.CheckHasCollect(currentMember.UserId, this.productId);
                    this.hdHasCollected.SetWhenIsNotNull(flag ? "1" : "0");
                    ProductBrowser.UpdateVisitCounts(this.productId);
                    PageTitle.AddSiteNameTitle("积分商品");
                    SiteSettings masterSettings = SettingsManager.GetMasterSettings(false, wid);
                    string       str3           = "";
                    if (!string.IsNullOrEmpty(masterSettings.GoodsPic))
                    {
                        str3 = Globals.HostPath(HttpContext.Current.Request.Url) + masterSettings.GoodsPic;
                    }
                    this.litItemParams.Text = string.Concat(new object[] { str3, "|", masterSettings.GoodsName, "|", masterSettings.GoodsDescription, "$", Globals.HostPath(HttpContext.Current.Request.Url), product.ImageUrl1, "|", this.litProdcutName.Text, "|", product.ShortDescription, "|", HttpContext.Current.Request.Url });
                }
            }
            else
            {
                HttpContext.Current.Response.Redirect("/vshop/");
                HttpContext.Current.Response.End();
            }
        }
Esempio n. 5
0
        protected void grdProducts_ItemCommand(object source, System.Web.UI.WebControls.RepeaterCommandEventArgs e)
        {
            string commandName = e.CommandName;

            if (commandName == "Renew")
            {
                if (!string.IsNullOrEmpty(base.Request["id"].ToString()))
                {
                    int    num        = int.Parse(base.Request["id"]);
                    string productIds = e.CommandArgument.ToString();
                    bool   flag       = PointExChangeHelper.SetProductsStatus(num, 0, productIds);
                    if (flag)
                    {
                        this.ShowMsg("恢复商品成功", true);
                        this.BindProducts(this.exchangeId);
                        return;
                    }
                    this.ShowMsg("恢复商品失败", false);
                    return;
                }
            }
            else if (commandName == "Pause")
            {
                if (!string.IsNullOrEmpty(base.Request["id"].ToString()))
                {
                    int    num2        = int.Parse(base.Request["id"]);
                    string productIds2 = e.CommandArgument.ToString();
                    bool   flag2       = PointExChangeHelper.SetProductsStatus(num2, 1, productIds2);
                    if (flag2)
                    {
                        this.ShowMsg("暂停商品成功", true);
                        this.BindProducts(this.exchangeId);
                        return;
                    }
                    this.ShowMsg("暂停商品失败", false);
                    return;
                }
            }
            else if (commandName == "Delete" && !string.IsNullOrEmpty(base.Request["id"].ToString()))
            {
                int    num3 = int.Parse(base.Request["id"]);
                string text = e.CommandArgument.ToString();
                if (!string.IsNullOrEmpty(text))
                {
                    int productExchangedCount = PointExChangeHelper.GetProductExchangedCount(num3, int.Parse(text));
                    if (productExchangedCount > 0)
                    {
                        this.ShowMsg("该商品已经存在兑换记录,不能移除!", false);
                        return;
                    }
                    bool flag3 = PointExChangeHelper.DeleteProducts(num3, text);
                    if (flag3)
                    {
                        this.ShowMsg("删除商品成功", true);
                        this.BindProducts(this.exchangeId);
                        return;
                    }
                    this.ShowMsg("删除商品失败", false);
                }
            }
        }
Esempio n. 6
0
        public void ProcessRequest(System.Web.HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            int num = 0;

            int.TryParse(context.Request.Params["id"], out num);
            if (num > 0)
            {
                PointExChangeInfo pointExChangeInfo = PointExChangeHelper.Get(num);
                string            text = context.Request.Params["sort"];
                if (string.IsNullOrWhiteSpace(text))
                {
                    text = "ProductId";
                }
                string text2 = context.Request.Params["order"];
                if (string.IsNullOrWhiteSpace(text2))
                {
                    text2 = "asc";
                }
                int pageNumber;
                if (!int.TryParse(context.Request.Params["page"], out pageNumber))
                {
                    pageNumber = 1;
                }
                int maxNum;
                if (!int.TryParse(context.Request.Params["size"], out maxNum))
                {
                    maxNum = 10;
                }
                if (pointExChangeInfo.BeginDate <= System.DateTime.Now && pointExChangeInfo.EndDate >= System.DateTime.Now)
                {
                    int num2;
                    System.Data.DataTable products = PointExChangeHelper.GetProducts(num, pageNumber, maxNum, out num2, text, text2);
                    foreach (System.Data.DataRow dataRow in products.Rows)
                    {
                        if (dataRow["ProductNumber"].ToString() == "0")
                        {
                            int productId = 0;
                            int.TryParse(dataRow["ProductId"].ToString(), out productId);
                            ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), productId);
                            if (product != null && product.SaleStatus == ProductSaleStatus.OnSale)
                            {
                                dataRow["ProductNumber"] = product.Stock.ToString();
                            }
                        }
                        else
                        {
                            int productId2 = 0;
                            int.TryParse(dataRow["ProductId"].ToString(), out productId2);
                            int num3 = 0;
                            int.TryParse(dataRow["ProductNumber"].ToString(), out num3);
                            int productExchangedCount = PointExChangeHelper.GetProductExchangedCount(num, productId2);
                            int num4 = (num3 - productExchangedCount >= 0) ? (num3 - productExchangedCount) : 0;
                            dataRow["ProductNumber"] = num4;
                        }
                    }
                    string s = JsonConvert.SerializeObject(products, Formatting.Indented);
                    context.Response.Write(s);
                }
            }
        }