예제 #1
0
        protected void btnAddFeeFree_Click(object sender, EventArgs e)
        {
            decimal Amount = 0m;

            string str = string.Empty;

            if (ValidateValues(out Amount))
            {
                if (!((chkShipChargeFee.Checked || chkServiceChargeFree.Checked) || chkPackingChargeFree.Checked))
                {
                    str = str + Formatter.FormatErrorMessage("请选择此促销活动要免除的订单费用");
                }
                if (chklMemberGrade.SelectedValue.Count <= 0)
                {
                    str = str + Formatter.FormatErrorMessage("适合的客户必须选择一个");
                }
                if (!addpromoteSales.IsValid)
                {
                    ShowMsg(addpromoteSales.CurrentErrors, false);
                }
                else
                {
                    FullFreeInfo target = new FullFreeInfo();

                    target.Name              = addpromoteSales.Item.Name;
                    target.Description       = addpromoteSales.Item.Description;
                    target.Amount            = Amount;
                    target.ShipChargeFree    = chkShipChargeFee.Checked;
                    target.OptionFeeFree     = chkPackingChargeFree.Checked;
                    target.ServiceChargeFree = chkServiceChargeFree.Checked;
                    target.MemberGradeIds    = chklMemberGrade.SelectedValue;

                    ValidationResults results = Hishop.Components.Validation.Validation.Validate <FullFreeInfo>(target, new string[] { "ValPromotion" });
                    if (!results.IsValid)
                    {
                        foreach (ValidationResult result in (IEnumerable <ValidationResult>)results)
                        {
                            str = str + Formatter.FormatErrorMessage(result.Message);
                        }
                    }
                    if (!string.IsNullOrEmpty(str))
                    {
                        ShowMsg(str, false);
                    }
                    else
                    {
                        switch (SubsitePromoteHelper.AddPromotion(target))
                        {
                        case PromotionActionStatus.Success:
                            txtAmount.Text               = string.Empty;
                            chkShipChargeFee.Checked     = false;
                            chkPackingChargeFree.Checked = false;
                            chkServiceChargeFree.Checked = false;
                            addpromoteSales.Reset();
                            ShowMsg("成功添加了一个满额免费用促销活动", true);
                            return;

                        case PromotionActionStatus.DuplicateName:
                            ShowMsg("添加促销活动失败,存在相同的促销活动名称", false);
                            return;

                        case PromotionActionStatus.SameCondition:
                            ShowMsg("已经存在相同满足条件的优惠活动", false);
                            return;
                        }
                        txtAmount.Text               = string.Empty;
                        chkShipChargeFee.Checked     = false;
                        chkPackingChargeFree.Checked = false;
                        chkServiceChargeFree.Checked = false;
                        addpromoteSales.Reset();
                        ShowMsg("添加促销活动失败", false);
                    }
                }
            }
        }
예제 #2
0
 public abstract PromotionActionStatus CreateFullFree(FullFreeInfo promote);
예제 #3
0
        private void grdPromoteSales_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            SiteSettings siteSettings = SettingsManager.GetSiteSettings(HiContext.Current.User.UserId);

            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                int       num     = int.Parse(grdPromoteSales.DataKeys[e.Row.RowIndex].Value.ToString());
                Label     label   = (Label)e.Row.FindControl("lblPromoteType");
                Label     label2  = (Label)e.Row.FindControl("lblPromoteTypeName");
                Literal   literal = (Literal)e.Row.FindControl("ltrPromotionInfo");
                HyperLink link    = (HyperLink)e.Row.FindControl("hpkPromotionProduct");
                HyperLink link2   = (HyperLink)e.Row.FindControl("hpkPromotion");
                link2.NavigateUrl = "http://" + siteSettings.SiteUrl + Globals.ApplicationPath + string.Format("/FavourableDetails.aspx?activityId={0}", num);
                link2.Target      = "_blank";
                Label          label3 = (Label)e.Row.FindControl("lblmemberGrades");
                IList <string> promoteMemberGrades = SubsitePromoteHelper.GetPromoteMemberGrades(num);
                string         str = string.Empty;
                foreach (string str2 in promoteMemberGrades)
                {
                    str = str + str2 + ",";
                }
                str         = str.Remove(str.Length - 1);
                label3.Text = str;
                if (int.Parse(label.Text, CultureInfo.InvariantCulture) == 2)
                {
                    label2.Text = "满额打折";
                    FullDiscountInfo fullDiscountInfo = SubsitePromoteHelper.GetFullDiscountInfo(num);
                    string           str3             = (fullDiscountInfo.ValueType == DiscountValueType.Amount) ? "折扣金额" : "百分比折扣";
                    literal.Text = string.Concat(new object[] { "满足金额:", Globals.FormatMoney(fullDiscountInfo.Amount), "&nbsp;折扣类型:", str3, "&nbsp;折扣值:", decimal.Round(decimal.Parse(fullDiscountInfo.DiscountValue.ToString()), 2) });
                }
                if (int.Parse(label.Text, CultureInfo.InvariantCulture) == 3)
                {
                    FullFreeInfo fullFreeInfo = SubsitePromoteHelper.GetFullFreeInfo(num);
                    label2.Text = "满额免费用";
                    string str4 = "&nbsp;免费项目:";
                    if (fullFreeInfo.OptionFeeFree)
                    {
                        str4 = str4 + "订单选项费,";
                    }
                    if (fullFreeInfo.ServiceChargeFree)
                    {
                        str4 = str4 + "订单支付手续费,";
                    }
                    if (fullFreeInfo.ShipChargeFree)
                    {
                        str4 = str4 + "订单运费,";
                    }
                    literal.Text = "满足金额:" + Globals.FormatMoney(fullFreeInfo.Amount) + str4.Remove(str4.Length - 1);
                }
                if (int.Parse(label.Text, CultureInfo.InvariantCulture) == 4)
                {
                    label2.Text = "买几送几";
                    PurchaseGiftInfo purchaseGiftInfo = SubsitePromoteHelper.GetPurchaseGiftInfo(num);
                    literal.Text     = string.Concat(new object[] { "购买数量:", purchaseGiftInfo.BuyQuantity, "&nbsp;赠送数量:", purchaseGiftInfo.GiveQuantity });
                    link.Visible     = true;
                    link.NavigateUrl = Globals.ApplicationPath + "/Shopadmin/promotion/MyPromotionProducts.aspx?ActiveId=" + num;
                }
                if (int.Parse(label.Text, CultureInfo.InvariantCulture) == 5)
                {
                    label2.Text = "批发打折";
                    WholesaleDiscountInfo wholesaleDiscountInfo = SubsitePromoteHelper.GetWholesaleDiscountInfo(num);
                    literal.Text     = string.Concat(new object[] { "购买数量:", wholesaleDiscountInfo.Quantity, "&nbsp;折扣值:", wholesaleDiscountInfo.DiscountValue });
                    link.Visible     = true;
                    link.NavigateUrl = Globals.ApplicationPath + "/Shopadmin/promotion/MyPromotionProducts.aspx?ActiveId=" + num;
                }
            }
        }