Пример #1
0
        private void btnbtnAddCountDown_Click(object sender, EventArgs e)
        {
            CountDownInfo countDownInfo = new CountDownInfo();
            string        str           = string.Empty;

            if (dropGroupBuyProduct.SelectedValue > 0)
            {
                if (PromoteHelper.ProductCountDownExist(dropGroupBuyProduct.SelectedValue.Value))
                {
                    ShowMsg("已经存在此商品的限时抢购活动", false);
                    return;
                }
                countDownInfo.ProductId = dropGroupBuyProduct.SelectedValue.Value;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("请选择限时抢购商品");
            }
            if (!calendarEndDate.SelectedDate.HasValue)
            {
                str = str + Formatter.FormatErrorMessage("请选择结束日期");
            }
            else
            {
                countDownInfo.EndDate = calendarEndDate.SelectedDate.Value;
            }
            if (!string.IsNullOrEmpty(txtPrice.Text))
            {
                decimal num;
                if (decimal.TryParse(txtPrice.Text.Trim(), out num))
                {
                    countDownInfo.CountDownPrice = num;
                }
                else
                {
                    str = str + Formatter.FormatErrorMessage("价格填写格式不正确");
                }
            }
            if (!string.IsNullOrEmpty(str))
            {
                ShowMsg(str, false);
            }
            else
            {
                countDownInfo.Content = Globals.HtmlEncode(txtContent.Text);
                if (PromoteHelper.AddCountDown(countDownInfo))
                {
                    ShowMsg("添加限时抢购活动成功", true);
                }
                else
                {
                    ShowMsg("添加限时抢购活动失败", true);
                }
            }
        }
Пример #2
0
        private void btnAddCountDown_Click(object sender, EventArgs e)
        {
            CountDownInfo           countDownInfo = new CountDownInfo();
            List <CountDownSkuInfo> list          = new List <CountDownSkuInfo>();

            if (this.productId == 0)
            {
                this.ShowMsg(Formatter.FormatErrorMessage("请选择商品"), false);
            }
            else
            {
                countDownInfo.ProductId = this.productId;
                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;
                    TextBox      textBox2     = repeaterItem.FindControl("txtActivitySalePrice") as TextBox;
                    if (textBox2.Text.Trim().ToDecimal(0) == decimal.Zero)
                    {
                        this.ShowMsg("请完整填写商品规格", false);
                        return;
                    }
                    CountDownSkuInfo item = new CountDownSkuInfo
                    {
                        SalePrice  = textBox2.Text.Trim().ToDecimal(0),
                        TotalCount = textBox.Text.Trim().ToInt(0),
                        SkuId      = hiddenField.Value
                    };
                    list.Add(item);
                }
                if (this.rptProductSkus.Items.Count == 0)
                {
                    if (this.txtPrice.Text.Trim().ToDecimal(0) == decimal.Zero)
                    {
                        this.ShowMsg("请填写限时抢购价格", false);
                        return;
                    }
                    if (this.txtTotalCount.Text.Trim().ToInt(0) == 0)
                    {
                        this.ShowMsg("请填写商品活动库存", false);
                        return;
                    }
                }
                if (!this.CPStartTime.SelectedDate.HasValue)
                {
                    this.ShowMsg(Formatter.FormatErrorMessage("请填写活动开始时间"), false);
                }
                else
                {
                    countDownInfo.StartDate = this.CPStartTime.SelectedDate.Value;
                    if (!this.CPEndDate.SelectedDate.HasValue)
                    {
                        this.ShowMsg(Formatter.FormatErrorMessage("请填写活动结束时间"), false);
                    }
                    else
                    {
                        countDownInfo.EndDate = this.CPEndDate.SelectedDate.Value;
                        if (countDownInfo.StartDate >= countDownInfo.EndDate)
                        {
                            this.ShowMsg(Formatter.FormatErrorMessage("活动结束时间要大于活动开始时间"), false);
                        }
                        else if (countDownInfo.EndDate <= DateTime.Now)
                        {
                            this.ShowMsg(Formatter.FormatErrorMessage("活动结束时间要大于当前系统时间"), false);
                        }
                        else if (this.txtMaxCount.Text.Trim().ToInt(0) == 0)
                        {
                            this.ShowMsg("请填写每人限购数量", false);
                        }
                        else
                        {
                            countDownInfo.MaxCount = this.txtMaxCount.Text.ToInt(0);
                            if (PromoteHelper.ProductCountDownExist(countDownInfo.ProductId))
                            {
                                this.ShowMsg("已经存在此商品的限时抢购活动", false);
                            }
                            else
                            {
                                int num = 0;
                                num = ((this.rptProductSkus.Items.Count == 0) ? this.txtTotalCount.Text.Trim().ToInt(0) : list.Sum((CountDownSkuInfo c) => c.TotalCount));
                                if (!this.site.OpenMultStore && countDownInfo.MaxCount > num)
                                {
                                    this.ShowMsg(Formatter.FormatErrorMessage("每人限购数量不能大于活动库存"), false);
                                }
                                else if (!this.site.OpenMultStore && list.Count > 0 && countDownInfo.MaxCount > (from c in list
                                                                                                                 where c.TotalCount > 0
                                                                                                                 select c).Min((CountDownSkuInfo c) => c.TotalCount))
                                {
                                    this.ShowMsg(Formatter.FormatErrorMessage("每人限购数量不能大于规格的最小活动库存"), false);
                                }
                                else
                                {
                                    countDownInfo.Content      = Globals.HtmlEncode(this.txtContent.Text);
                                    countDownInfo.ShareTitle   = Globals.HtmlEncode(this.txtShareTitle.Text);
                                    countDownInfo.ShareDetails = Globals.HtmlEncode(this.txtShareDetails.Text);
                                    countDownInfo.ShareIcon    = Globals.SaveFile("countDown", this.hidUploadLogo.Value, "/Storage/master/", true, false, "");
                                    IList <int> list2 = null;
                                    Dictionary <int, IList <int> > dictionary = default(Dictionary <int, IList <int> >);
                                    ProductInfo productDetails = ProductHelper.GetProductDetails(countDownInfo.ProductId, out dictionary, out list2);
                                    if (productDetails != null)
                                    {
                                        if (!this.site.OpenMultStore && productDetails.Stock < countDownInfo.MaxCount)
                                        {
                                            this.ShowMsg("库存小于每人限购数量", false);
                                            return;
                                        }
                                        if (!this.site.OpenMultStore && productDetails.Stock < num)
                                        {
                                            this.ShowMsg("库存小于活动库存", false);
                                            return;
                                        }
                                        if (list.Count > 0)
                                        {
                                            foreach (KeyValuePair <string, SKUItem> sku in productDetails.Skus)
                                            {
                                                CountDownSkuInfo countDownSkuInfo = (from s in list
                                                                                     where s.SkuId == sku.Value.SkuId
                                                                                     select s).FirstOrDefault();
                                                if (countDownSkuInfo == null)
                                                {
                                                    this.ShowMsg("规格不存在,请重新刷新页面", false);
                                                    return;
                                                }
                                                if (!this.site.OpenMultStore && countDownSkuInfo.TotalCount > sku.Value.Stock)
                                                {
                                                    this.ShowMsg("商品规格库存不足", false);
                                                    return;
                                                }
                                            }
                                        }
                                    }
                                    if (list.Count == 0)
                                    {
                                        DataTable skusByProductId = ProductHelper.GetSkusByProductId(this.productId);
                                        if (skusByProductId.Rows.Count > 0)
                                        {
                                            DataRow          dataRow = skusByProductId.Rows[0];
                                            CountDownSkuInfo item2   = new CountDownSkuInfo
                                            {
                                                SalePrice  = this.txtPrice.Text.Trim().ToDecimal(0),
                                                TotalCount = num,
                                                SkuId      = dataRow["SkuId"].ToNullString()
                                            };
                                            list.Add(item2);
                                        }
                                    }
                                    if (this.site.OpenMultStore)
                                    {
                                        if (string.IsNullOrEmpty(this.hidStoreIds.Value))
                                        {
                                            this.ShowMsg("请选择门店范围", false);
                                            return;
                                        }
                                        countDownInfo.StoreType = 2;
                                        countDownInfo.StoreIds  = this.hidStoreIds.Value;
                                    }
                                    else
                                    {
                                        countDownInfo.StoreType = 0;
                                    }
                                    PromoteHelper.AddCountDown(countDownInfo, list);
                                    if (countDownInfo.StartDate < DateTime.Now && countDownInfo.EndDate > DateTime.Now)
                                    {
                                        this.ShowMsg("添加限时抢购活动成功", true, "countdowns.aspx");
                                    }
                                    else
                                    {
                                        this.ShowMsg("添加限时抢购活动成功", true, "countdowns.aspx?State=1");
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Пример #3
0
        private void btnbtnAddCountDown_Click(object sender, System.EventArgs e)
        {
            CountDownInfo countDownInfo = new CountDownInfo();
            string        text          = string.Empty;

            if (this.dropGroupBuyProduct.SelectedValue > 0)
            {
                if (PromoteHelper.ProductCountDownExist(this.dropGroupBuyProduct.SelectedValue.Value))
                {
                    this.ShowMsg("已经存在此商品的限时抢购活动", false);
                    return;
                }
                countDownInfo.ProductId = this.dropGroupBuyProduct.SelectedValue.Value;
            }
            else
            {
                text += Formatter.FormatErrorMessage("请选择限时抢购商品");
            }

            bool timeValidated = false;

            if (!this.calendarEndDate.SelectedDate.HasValue)
            {
                text += Formatter.FormatErrorMessage("请选择结束日期");
            }
            else
            {
                countDownInfo.EndDate = this.calendarEndDate.SelectedDate.Value.AddHours((double)this.HourDropDownList1.SelectedValue.Value);
                if (System.DateTime.Compare(this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value), countDownInfo.EndDate) >= 0)
                {
                    text += Formatter.FormatErrorMessage("开始日期必须要早于结束日期");
                }
                else
                {
                    countDownInfo.StartDate = this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value);

                    timeValidated = true;
                }
            }

            if (timeValidated && PromoteHelper.ProductCountDownExist(this.dropGroupBuyProduct.SelectedValue.Value, countDownInfo.StartDate, countDownInfo.EndDate, 0))
            {
                this.ShowMsg("已经存在此商品该时间段的限时抢购活动", false);
                return;
            }

            int maxCount;

            if (int.TryParse(this.txtMaxCount.Text.Trim(), out maxCount))
            {
                countDownInfo.MaxCount = maxCount;
            }
            else
            {
                text += Formatter.FormatErrorMessage("限购数量不能为空,只能为整数");
            }

            int planCount;

            if (int.TryParse(this.txtPlanCount.Text.Trim(), out planCount))
            {
                countDownInfo.PlanCount = planCount;
            }
            else
            {
                text += Formatter.FormatErrorMessage("活动数量不能为空,只能为整数");
            }

            if (!string.IsNullOrEmpty(this.txtPrice.Text))
            {
                decimal countDownPrice;
                if (decimal.TryParse(this.txtPrice.Text.Trim(), out countDownPrice))
                {
                    countDownInfo.CountDownPrice = countDownPrice;
                }
                else
                {
                    text += Formatter.FormatErrorMessage("价格填写格式不正确");
                }
            }
            if (!string.IsNullOrEmpty(text))
            {
                this.ShowMsg(text, false);
                return;
            }
            countDownInfo.Content    = Globals.HtmlEncode(this.txtContent.Text);
            countDownInfo.PlanCount  = maxCount * 10;  //TODO
            countDownInfo.SupplierId = UserHelper.GetAssociatedSupplierId(HiContext.Current.User.UserId);
            if (PromoteHelper.AddCountDown(countDownInfo))
            {
                this.ShowMsg("添加限时抢购活动成功", true);
                return;
            }
            this.ShowMsg("添加限时抢购活动失败", true);
        }
Пример #4
0
        private void btnbtnAddCountDown_Click(object sender, EventArgs e)
        {
            int           num;
            CountDownInfo countDownInfo = new CountDownInfo();
            string        str           = string.Empty;

            if (this.dropGroupBuyProduct.SelectedValue > 0)
            {
                if (PromoteHelper.ProductCountDownExist(this.dropGroupBuyProduct.SelectedValue.Value))
                {
                    this.ShowMsg("已经存在此商品的限时抢购活动", false);
                    return;
                }
                countDownInfo.ProductId = this.dropGroupBuyProduct.SelectedValue.Value;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("请选择限时抢购商品");
            }
            if (!this.calendarEndDate.SelectedDate.HasValue)
            {
                str = str + Formatter.FormatErrorMessage("请选择结束日期");
            }
            else
            {
                countDownInfo.EndDate = this.calendarEndDate.SelectedDate.Value.AddHours((double)this.HourDropDownList1.SelectedValue.Value);
                if (DateTime.Compare(this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value), countDownInfo.EndDate) >= 0)
                {
                    str = str + Formatter.FormatErrorMessage("开始日期必须要早于结束日期");
                }
                else
                {
                    countDownInfo.StartDate = this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value);
                }
            }
            if (int.TryParse(this.txtMaxCount.Text.Trim(), out num))
            {
                countDownInfo.MaxCount = num;
            }
            else
            {
                str = str + Formatter.FormatErrorMessage("限购数量不能为空,只能为整数");
            }
            if (!string.IsNullOrEmpty(this.txtPrice.Text))
            {
                decimal num2;
                if (decimal.TryParse(this.txtPrice.Text.Trim(), out num2))
                {
                    countDownInfo.CountDownPrice = num2;
                }
                else
                {
                    str = str + Formatter.FormatErrorMessage("价格填写格式不正确");
                }
            }
            if (!string.IsNullOrEmpty(str))
            {
                this.ShowMsg(str, false);
            }
            else
            {
                countDownInfo.Content = Globals.HtmlEncode(this.txtContent.Text);
                if (PromoteHelper.AddCountDown(countDownInfo))
                {
                    this.ShowMsg("添加限时抢购活动成功", true);
                }
                else
                {
                    this.ShowMsg("添加限时抢购活动失败", true);
                }
            }
        }
Пример #5
0
        private void btnbtnAddCountDown_Click(object sender, System.EventArgs e)
        {
            try
            {
                string[] Start_hour = Request.Form["sl_hoursByStart"].Split(',').Where(t => !string.IsNullOrEmpty(t)).ToArray();
                string[] Start_time = Request.Form["StartTimes"].Split(',');
                string[] End_hour   = Request.Form["sl_hoursByEnd"].Split(',');
                string[] End_time   = Request.Form["EndTimes"].Split(',').Where(t => !string.IsNullOrEmpty(t)).ToArray();;
                if (Start_hour.Length != Start_time.Length || Start_hour.Length != End_time.Length || Start_hour.Length != End_time.Length)
                {
                    this.ShowMsg("开始和结束时间参数不能为空!", false);
                    return;
                }
                List <CountDownInfo> cdlist = new List <CountDownInfo>();

                CountDownInfo countDownInfo = null;
                string        text          = string.Empty;

                for (int i = 0; i < Start_time.Length; i++)
                {
                    countDownInfo = new CountDownInfo();

                    #region 请选择限时抢购商品
                    if (this.dropGroupBuyProduct.SelectedValue > 0)
                    {
                        // 移到下面与时间一起判断
                        //if (PromoteHelper.ProductCountDownExist(this.dropGroupBuyProduct.SelectedValue.Value))
                        //{
                        //    this.ShowMsg("已经存在此商品的限时抢购活动", false);
                        //    return;
                        //}
                        countDownInfo.ProductId = this.dropGroupBuyProduct.SelectedValue.Value;
                    }
                    else
                    {
                        text += Formatter.FormatErrorMessage("请选择限时抢购商品");
                    }
                    #endregion

                    bool timeValidated = false;
                    #region 组装日期数据
                    countDownInfo.EndDate   = Convert.ToDateTime(End_time[i]).AddHours(double.Parse(End_hour[i]));     //this.calendarEndDate.SelectedDate.Value.AddHours((double)this.HourDropDownList1.SelectedValue.Value);
                    countDownInfo.StartDate = Convert.ToDateTime(Start_time[i]).AddHours(double.Parse(Start_hour[i])); // this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value);
                    if (System.DateTime.Compare(countDownInfo.StartDate, countDownInfo.EndDate) >= 0)
                    {
                        text += Formatter.FormatErrorMessage("开始日期必须要早于结束日期");
                    }
                    else
                    {
                        //countDownInfo.StartDate = this.calendarStartDate.SelectedDate.Value.AddHours((double)this.drophours.SelectedValue.Value);
                        timeValidated = true;
                    }
                    if (timeValidated && PromoteHelper.ProductCountDownExist(this.dropGroupBuyProduct.SelectedValue.Value, countDownInfo.StartDate, countDownInfo.EndDate, 0))
                    {
                        this.ShowMsg("已经存在此商品该时间段的限时抢购活动", false);
                        return;
                    }
                    #endregion

                    #region 数字验证
                    int maxCount;
                    if (int.TryParse(this.txtMaxCount.Text.Trim(), out maxCount))
                    {
                        countDownInfo.MaxCount = maxCount;
                    }
                    else
                    {
                        text += Formatter.FormatErrorMessage("限购数量不能为空,只能为整数");
                    }

                    int planCount;
                    if (int.TryParse(this.txtPlanCount.Text.Trim(), out planCount))
                    {
                        countDownInfo.PlanCount = planCount;
                    }
                    else
                    {
                        text += Formatter.FormatErrorMessage("活动数量不能为空,只能为整数");
                    }

                    if (maxCount > planCount)
                    {
                        text += Formatter.FormatErrorMessage("抢购数量不能大于活动数量");
                    }

                    if (!string.IsNullOrEmpty(this.txtPrice.Text))
                    {
                        decimal countDownPrice;
                        if (decimal.TryParse(this.txtPrice.Text.Trim(), out countDownPrice))
                        {
                            countDownInfo.CountDownPrice = countDownPrice;
                        }
                        else
                        {
                            text += Formatter.FormatErrorMessage("价格填写格式不正确");
                        }
                    }
                    #endregion

                    countDownInfo.Content = Globals.HtmlEncode(this.txtContent.Text);

                    cdlist.Add(countDownInfo);
                }

                if (!string.IsNullOrEmpty(text))
                {
                    this.ShowMsg(text, false);
                    return;
                }

                string RsStr = string.Empty;
                if (cdlist != null)
                {
                    cdlist.ForEach(t =>
                    {
                        bool rest = PromoteHelper.AddCountDown(t);
                        if (!rest)
                        {
                            RsStr += t.StartDate + "~" + t.EndDate + ";";
                        }
                    });
                }
                if (string.IsNullOrEmpty(RsStr))
                {
                    this.ShowMsg("添加限时抢购活动成功", true);
                    return;
                }
                this.ShowMsg("添加限时抢购活动部分失败:" + RsStr, true);
            }
            catch (Exception ee)
            {
                this.ShowMsg("必填参数为空,或格式错误!", false);
                return;
            }
        }