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);
         }
     }
 }
Esempio n. 2
0
        protected override void AttachChildControls()
        {
            if (!int.TryParse(this.Page.Request.QueryString["id"], out this.id))
            {
                base.GotoResourceNotFound("");
            }
            PointExChangeInfo info = PointExChangeHelper.Get(this.id);

            if (info != null)
            {
                PageTitle.AddSiteNameTitle("积分兑换");
                MemberInfo currentMember = MemberProcessor.GetCurrentMember();
                if (currentMember != null)
                {
                    this.imgCover          = (Image)this.FindControl("imgCover");
                    this.litPoints         = (Literal)this.FindControl("litPoints");
                    this.litPoints.Text    = currentMember.Points.ToString();
                    this.gradeId           = currentMember.GradeId;
                    this.imgCover.ImageUrl = !string.IsNullOrEmpty(info.ImgUrl) ? info.ImgUrl : "http://fpoimg.com/640x220";
                }
            }
            else
            {
                HttpContext.Current.Response.Redirect("/vshop/");
                HttpContext.Current.Response.End();
            }
        }
Esempio n. 3
0
 protected void Page_Load(object sender, System.EventArgs e)
 {
     this.saveBtn.Click += new System.EventHandler(this.saveBtn_Click);
     string[] allKeys = base.Request.Params.AllKeys;
     if (allKeys.Contains("id") && base.Request["id"].ToString().bInt(ref this.eId) && !this.Page.IsPostBack)
     {
         PointExChangeInfo pointExChangeInfo = PointExChangeHelper.Get(this.eId);
         this.txt_name.Text = pointExChangeInfo.Name;
         this.calendarStartDate.SelectedDate = new System.DateTime?(pointExChangeInfo.BeginDate);
         this.calendarEndDate.SelectedDate   = new System.DateTime?(pointExChangeInfo.EndDate);
         this.txt_img.Text = pointExChangeInfo.ImgUrl;
         this.hidpic.Value = pointExChangeInfo.ImgUrl;
         System.Web.UI.WebControls.HiddenField hiddenField  = this.SetMemberRange.FindControl("txt_Grades") as System.Web.UI.WebControls.HiddenField;
         System.Web.UI.WebControls.HiddenField hiddenField2 = this.SetMemberRange.FindControl("txt_DefualtGroup") as System.Web.UI.WebControls.HiddenField;
         System.Web.UI.WebControls.HiddenField hiddenField3 = this.SetMemberRange.FindControl("txt_CustomGroup") as System.Web.UI.WebControls.HiddenField;
         this.SetMemberRange.Grade        = pointExChangeInfo.MemberGrades;
         this.SetMemberRange.DefualtGroup = pointExChangeInfo.DefualtGroup;
         this.SetMemberRange.CustomGroup  = pointExChangeInfo.CustomGroup;
         hiddenField.Value  = pointExChangeInfo.MemberGrades;
         hiddenField2.Value = pointExChangeInfo.DefualtGroup;
         hiddenField3.Value = pointExChangeInfo.CustomGroup;
         if (pointExChangeInfo.EndDate < System.DateTime.Now)
         {
             this.bFinished = true;
             return;
         }
         this.bFinished = false;
     }
 }
Esempio n. 4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.saveBtn.Click += new EventHandler(this.saveBtn_Click);
     if ((base.Request.Params.AllKeys.Contains <string>("id") && base.Request["id"].ToString().bInt(ref this.eId)) && !this.Page.IsPostBack)
     {
         PointExChangeInfo info = PointExChangeHelper.Get(this.eId);
         this.txt_name.Text = info.Name;
         this.calendarStartDate.SelectedDate = new DateTime?(info.BeginDate);
         this.calendarEndDate.SelectedDate   = new DateTime?(info.EndDate);
         this.txt_img.Text = info.ImgUrl;
         this.hidpic.Value = info.ImgUrl;
         HiddenField field  = this.SetMemberRange.FindControl("txt_Grades") as HiddenField;
         HiddenField field2 = this.SetMemberRange.FindControl("txt_DefualtGroup") as HiddenField;
         HiddenField field3 = this.SetMemberRange.FindControl("txt_CustomGroup") as HiddenField;
         this.SetMemberRange.Grade        = info.MemberGrades;
         this.SetMemberRange.DefualtGroup = info.DefualtGroup;
         this.SetMemberRange.CustomGroup  = info.CustomGroup;
         field.Value  = info.MemberGrades;
         field2.Value = info.DefualtGroup;
         field3.Value = info.CustomGroup;
         if (info.EndDate < DateTime.Now)
         {
             this.bFinished = true;
         }
         else
         {
             this.bFinished = false;
         }
     }
 }
Esempio n. 5
0
        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 num3;
                int num4;
                PointExChangeInfo info = PointExChangeHelper.Get(result);
                int    gradeId         = MemberProcessor.GetCurrentMember().GradeId;
                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 num3))
                {
                    num3 = 1;
                }
                if (!int.TryParse(context.Request.Params["size"], out num4))
                {
                    num4 = 10;
                }
                bool flag = false;
                foreach (string str3 in info.MemberGrades.Split(new char[] { ',' }))
                {
                    if ((int.Parse(str3) == gradeId) || (str3 == "0"))
                    {
                        flag = true;
                    }
                }
                if ((flag && (info.BeginDate <= DateTime.Now)) && (info.EndDate >= DateTime.Now))
                {
                    int       num5;
                    DataTable table = PointExChangeHelper.GetProducts(result, num3, num4, out num5, str, str2);
                    foreach (DataRow row in table.Rows)
                    {
                        if (row["ProductNumber"].ToString() == "0")
                        {
                            int num6 = 0;
                            int.TryParse(row["ProductId"].ToString(), out num6);
                            ProductInfo product = ProductBrowser.GetProduct(MemberProcessor.GetCurrentMember(), num6);
                            if ((product != null) && (product.SaleStatus == ProductSaleStatus.OnSale))
                            {
                                row["ProductNumber"] = product.Stock.ToString();
                            }
                        }
                    }
                    string s = JsonConvert.SerializeObject(table, Formatting.Indented);
                    context.Response.Write(s);
                }
            }
        }
Esempio n. 6
0
 protected void Page_Load(object sender, EventArgs e)
 {
     this.saveBtn.Click += new EventHandler(this.saveBtn_Click);
     if ((base.Request.Params.AllKeys.Contains <string>("id") && base.Request["id"].ToString().bInt(ref this.eId)) && !this.Page.IsPostBack)
     {
         PointExChangeInfo info = PointExChangeHelper.Get(this.eId);
         this.txt_name.Text    = info.Name;
         this.txt_Grades.Value = info.MemberGrades;
         this.calendarStartDate.SelectedDate = new DateTime?(info.BeginDate);
         this.calendarEndDate.SelectedDate   = new DateTime?(info.EndDate);
         this.txt_img.Text = info.ImgUrl;
         this.hidpic.Value = info.ImgUrl;
         if (info.EndDate < DateTime.Now)
         {
             this.bFinished = true;
         }
         else
         {
             this.bFinished = false;
         }
     }
 }
        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. 8
0
        protected void saveBtn_Click(object sender, EventArgs e)
        {
            string   text  = this.txt_name.Text;
            string   str2  = this.txt_Grades.Value;
            DateTime date  = this.calendarStartDate.SelectedDate.Value.Date;
            DateTime time2 = this.calendarEndDate.SelectedDate.Value.Date.AddDays(1.0).AddSeconds(-1.0);
            string   str3  = this.txt_img.Text;

            if (string.IsNullOrEmpty(text) || (text.Length > 30))
            {
                this.ShowMsg("请输入活动名称,长度不能超过30个字符!", false);
            }
            else if (string.IsNullOrEmpty(str2))
            {
                this.ShowMsg("请选择会员等级!", false);
            }
            else if (time2 < date)
            {
                this.ShowMsg("结束时间不能早于开始时间!", false);
            }
            else if (string.IsNullOrEmpty(str3))
            {
                this.ShowMsg("请上传封面图片!", false);
            }
            else
            {
                PointExChangeInfo exchange = new PointExChangeInfo();
                if (this.eId != 0)
                {
                    exchange = PointExChangeHelper.Get(this.eId);
                }
                exchange.BeginDate    = date;
                exchange.EndDate      = time2;
                exchange.Name         = text;
                exchange.MemberGrades = str2;
                exchange.ImgUrl       = str3;
                int    eId = this.eId;
                string msg = "";
                if (this.eId == 0)
                {
                    exchange.ProductNumber = 0;
                    int num2 = PointExChangeHelper.Create(exchange, ref msg);
                    if (num2 == 0)
                    {
                        this.ShowMsg("保存失败(" + msg + ")", false);
                        return;
                    }
                    eId = num2;
                    this.ShowMsg("保存成功!", true);
                }
                else if (PointExChangeHelper.Update(exchange, ref msg))
                {
                    this.ShowMsg("保存成功!", true);
                }
                else
                {
                    this.ShowMsg("保存失败(" + msg + ")", false);
                    return;
                }
                base.Response.Redirect("AddProductToPointExchange.aspx?id=" + eId.ToString());
            }
        }
Esempio n. 9
0
        protected override void AttachChildControls()
        {
            if (!int.TryParse(this.Page.Request.QueryString["id"], out this.id))
            {
                base.GotoResourceNotFound("");
            }
            PointExChangeInfo pointExChangeInfo = PointExChangeHelper.Get(this.id);

            if (pointExChangeInfo != null)
            {
                this.hideImgUrl      = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hideImgUrl");
                this.hideTitle       = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hideTitle");
                this.hideDesc        = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hideDesc");
                this.hideTitle.Value = pointExChangeInfo.Name;
                this.hideDesc.Value  = "活动时间:" + pointExChangeInfo.BeginDate.ToString("yyyy-MM-dd HH:mm:ss") + "至" + pointExChangeInfo.EndDate.ToString("yyyy-MM-dd HH:mm:ss");
                System.Uri url    = System.Web.HttpContext.Current.Request.Url;
                string     imgUrl = pointExChangeInfo.ImgUrl;
                string     str    = string.Empty;
                if (!string.IsNullOrEmpty(imgUrl))
                {
                    if (!imgUrl.StartsWith("http"))
                    {
                        str = url.Scheme + "://" + url.Host + ((url.Port == 80) ? "" : (":" + url.Port.ToString()));
                    }
                    this.hideImgUrl.Value = str + imgUrl;
                }
                PageTitle.AddSiteNameTitle(pointExChangeInfo.Name);
                this.imgCover = (System.Web.UI.WebControls.Image) this.FindControl("imgCover");
                if (!string.IsNullOrEmpty(pointExChangeInfo.ImgUrl))
                {
                    this.imgCover.ImageUrl = pointExChangeInfo.ImgUrl;
                }
                else
                {
                    this.imgCover.Visible = false;
                }
                MemberInfo currentMember = MemberProcessor.GetCurrentMember();
                this.litPoints = (System.Web.UI.WebControls.Literal) this.FindControl("litPoints");
                if (currentMember != null)
                {
                    this.hiddisInRange    = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddisInRange");
                    this.hiddUserId       = (System.Web.UI.HtmlControls.HtmlInputHidden) this.FindControl("hiddUserId");
                    this.litPoints.Text   = currentMember.Points.ToString();
                    this.hiddUserId.Value = currentMember.UserId.ToString();
                    if (MemberProcessor.CheckCurrentMemberIsInRange(pointExChangeInfo.MemberGrades, pointExChangeInfo.DefualtGroup, pointExChangeInfo.CustomGroup))
                    {
                        this.hiddisInRange.Value = "true";
                    }
                    else
                    {
                        this.hiddisInRange.Value = "false";
                    }
                }
                else
                {
                    this.litPoints.Text = "请先登录";
                }
            }
            else
            {
                System.Web.HttpContext.Current.Response.Redirect("/default.aspx");
                System.Web.HttpContext.Current.Response.End();
            }
        }
Esempio n. 10
0
        protected void saveBtn_Click(object sender, System.EventArgs e)
        {
            System.Web.UI.WebControls.HiddenField hiddenField  = this.SetMemberRange.FindControl("txt_Grades") as System.Web.UI.WebControls.HiddenField;
            System.Web.UI.WebControls.HiddenField hiddenField2 = this.SetMemberRange.FindControl("txt_DefualtGroup") as System.Web.UI.WebControls.HiddenField;
            System.Web.UI.WebControls.HiddenField hiddenField3 = this.SetMemberRange.FindControl("txt_CustomGroup") as System.Web.UI.WebControls.HiddenField;
            string value  = hiddenField.Value;
            string value2 = hiddenField2.Value;
            string value3 = hiddenField3.Value;
            string text   = this.txt_name.Text;

            System.DateTime?selectedDate  = this.calendarStartDate.SelectedDate;
            System.DateTime?selectedDate2 = this.calendarEndDate.SelectedDate;
            string          text2         = this.txt_img.Text;

            if (string.IsNullOrEmpty(text) || text.Length > 30)
            {
                this.ShowMsg("请输入活动名称,长度不能超过30个字符!", false);
                return;
            }
            if (value.Equals("-1") && value2.Equals("-1") && value3.Equals("-1"))
            {
                this.ShowMsg("请选择会员范围!", false);
                return;
            }
            if (selectedDate2 < selectedDate)
            {
                this.ShowMsg("结束时间不能早于开始时间!", false);
                return;
            }
            if (!selectedDate.HasValue || !selectedDate2.HasValue)
            {
                this.ShowMsg("开始时间或者结束时间不能为空!", false);
                return;
            }
            if (string.IsNullOrEmpty(text2))
            {
                this.ShowMsg("请上传封面图片!", false);
                return;
            }
            PointExChangeInfo pointExChangeInfo = new PointExChangeInfo();

            if (this.eId != 0)
            {
                pointExChangeInfo = PointExChangeHelper.Get(this.eId);
            }
            pointExChangeInfo.BeginDate    = selectedDate.Value;
            pointExChangeInfo.EndDate      = selectedDate2.Value;
            pointExChangeInfo.Name         = text;
            pointExChangeInfo.MemberGrades = value;
            pointExChangeInfo.DefualtGroup = value2;
            pointExChangeInfo.CustomGroup  = value3;
            pointExChangeInfo.ImgUrl       = text2;
            int    num = this.eId;
            string str = "";

            if (this.eId == 0)
            {
                pointExChangeInfo.ProductNumber = 0;
                int num2 = PointExChangeHelper.Create(pointExChangeInfo, ref str);
                if (num2 == 0)
                {
                    this.ShowMsg("保存失败(" + str + ")", false);
                    return;
                }
                num = num2;
                this.ShowMsg("保存成功!", true);
            }
            else
            {
                bool flag = PointExChangeHelper.Update(pointExChangeInfo, ref str);
                if (!flag)
                {
                    this.ShowMsg("保存失败(" + str + ")", false);
                    return;
                }
                this.ShowMsg("保存成功!", true);
            }
            base.Response.Redirect("AddProductToPointExchange.aspx?id=" + num.ToString());
        }
Esempio n. 11
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. 12
0
        protected void saveBtn_Click(object sender, EventArgs e)
        {
            HiddenField field        = this.SetMemberRange.FindControl("txt_Grades") as HiddenField;
            HiddenField field2       = this.SetMemberRange.FindControl("txt_DefualtGroup") as HiddenField;
            HiddenField field3       = this.SetMemberRange.FindControl("txt_CustomGroup") as HiddenField;
            string      str          = field.Value;
            string      str2         = field2.Value;
            string      str3         = field3.Value;
            string      text         = this.txt_name.Text;
            DateTime?   selectedDate = this.calendarStartDate.SelectedDate;
            DateTime?   nullable2    = this.calendarEndDate.SelectedDate;
            string      str5         = this.txt_img.Text;

            if (string.IsNullOrEmpty(text) || (text.Length > 30))
            {
                this.ShowMsg("请输入活动名称,长度不能超过30个字符!", false);
            }
            else if ((str.Equals("-1") && str2.Equals("-1")) && str3.Equals("-1"))
            {
                this.ShowMsg("请选择会员范围!", false);
            }
            else
            {
                DateTime?nullable3 = nullable2;
                DateTime?nullable4 = selectedDate;
                if ((nullable3.HasValue & nullable4.HasValue) ? (nullable3.GetValueOrDefault() < nullable4.GetValueOrDefault()) : false)
                {
                    this.ShowMsg("结束时间不能早于开始时间!", false);
                }
                else if (!selectedDate.HasValue || !nullable2.HasValue)
                {
                    this.ShowMsg("开始时间或者结束时间不能为空!", false);
                }
                else if (string.IsNullOrEmpty(str5))
                {
                    this.ShowMsg("请上传封面图片!", false);
                }
                else
                {
                    PointExChangeInfo exchange = new PointExChangeInfo();
                    if (this.eId != 0)
                    {
                        exchange = PointExChangeHelper.Get(this.eId);
                    }
                    exchange.BeginDate    = selectedDate.Value;
                    exchange.EndDate      = nullable2.Value;
                    exchange.Name         = text;
                    exchange.MemberGrades = str;
                    exchange.DefualtGroup = str2;
                    exchange.CustomGroup  = str3;
                    exchange.ImgUrl       = str5;
                    int    eId = this.eId;
                    string msg = "";
                    if (this.eId == 0)
                    {
                        exchange.ProductNumber = 0;
                        int num2 = PointExChangeHelper.Create(exchange, ref msg);
                        if (num2 == 0)
                        {
                            this.ShowMsg("保存失败(" + msg + ")", false);
                            return;
                        }
                        eId = num2;
                        this.ShowMsg("保存成功!", true);
                    }
                    else if (PointExChangeHelper.Update(exchange, ref msg))
                    {
                        this.ShowMsg("保存成功!", true);
                    }
                    else
                    {
                        this.ShowMsg("保存失败(" + msg + ")", false);
                        return;
                    }
                    base.Response.Redirect("AddProductToPointExchange.aspx?id=" + eId.ToString());
                }
            }
        }
Esempio n. 13
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);
                }
            }
        }