예제 #1
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            if (!string.IsNullOrEmpty(Request.QueryString["Delete"]))
            {
                var list = TranslateUtils.StringCollectionToIntList(Request.QueryString["IDCollection"]);
                if (list.Count > 0)
                {
                    try
                    {
                        DataProviderWx.CouponDao.Delete(list);
                        SuccessMessage("优惠劵删除成功!");
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "优惠劵删除失败!");
                    }
                }
            }

            SpContents.ControlToPaginate = RptContents;
            SpContents.ItemsPerPage      = 30;
            SpContents.SelectCommand     = DataProviderWx.CouponDao.GetSelectString(PublishmentSystemId);
            SpContents.SortField         = CouponAttribute.Id;
            SpContents.SortMode          = SortMode.ASC;
            RptContents.ItemDataBound   += rptContents_ItemDataBound;

            if (!IsPostBack)
            {
                BreadCrumb(AppManager.WeiXin.LeftMenu.IdFunction, AppManager.WeiXin.LeftMenu.Function.IdCoupon, "优惠劵管理", AppManager.WeiXin.Permission.WebSite.Coupon);

                SpContents.DataBind();

                BtnAdd.Attributes.Add("onclick", ModalCouponAdd.GetOpenWindowStringToAdd(PublishmentSystemId));

                var urlDelete = PageUtils.AddQueryString(GetRedirectUrl(PublishmentSystemId), "Delete", "True");
                BtnDelete.Attributes.Add("onclick", PageUtils.GetRedirectStringWithCheckBoxValueAndAlert(urlDelete, "IDCollection", "IDCollection", "请选择需要删除的优惠劵", "此操作将删除所选优惠劵,确认吗?"));

                BtnReturn.Attributes.Add("onclick",
                                         $@"location.href=""{PageCouponAct.GetRedirectUrl(PublishmentSystemId)}"";return false");
            }
        }
예제 #2
0
        public void Page_Load(object sender, EventArgs e)
        {
            if (IsForbidden)
            {
                return;
            }

            PageUtils.CheckRequestParameter("PublishmentSystemId");
            _actId = Body.GetQueryInt("actID");

            if (!IsPostBack)
            {
                var pageTitle = _actId > 0 ? "编辑优惠劵活动" : "添加优惠劵活动";
                BreadCrumb(AppManager.WeiXin.LeftMenu.IdFunction, AppManager.WeiXin.LeftMenu.Function.IdCoupon, pageTitle, AppManager.WeiXin.Permission.WebSite.Coupon);
                LtlPageTitle.Text = pageTitle;

                LtlImageUrl.Text =
                    $@"<img id=""preview_imageUrl"" src=""{CouponManager.GetImageUrl(PublishmentSystemInfo,
                        string.Empty)}"" width=""370"" align=""middle"" />";
                LtlContentImageUrl.Text =
                    $@"<img id=""preview_contentImageUrl"" src=""{CouponManager.GetContentImageUrl(
                        PublishmentSystemInfo, string.Empty)}"" width=""370"" align=""middle"" />";
                LtlEndImageUrl.Text =
                    $@"<img id=""preview_endImageUrl"" src=""{CouponManager.GetEndImageUrl(PublishmentSystemInfo,
                        string.Empty)}"" width=""370"" align=""middle"" />";

                if (_actId > 0)
                {
                    var actInfo = DataProviderWx.CouponActDao.GetActInfo(_actId);

                    TbKeywords.Text       = DataProviderWx.KeywordDao.GetKeywords(actInfo.KeywordId);
                    CbIsEnabled.Checked   = !actInfo.IsDisabled;
                    DtbStartDate.DateTime = actInfo.StartDate;
                    DtbEndDate.DateTime   = actInfo.EndDate;
                    TbTitle.Text          = actInfo.Title;
                    if (!string.IsNullOrEmpty(actInfo.ImageUrl))
                    {
                        LtlImageUrl.Text =
                            $@"<img id=""preview_imageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                PublishmentSystemInfo, actInfo.ImageUrl)}"" width=""370"" align=""middle"" />";
                    }
                    TbSummary.Text = actInfo.Summary;
                    if (!string.IsNullOrEmpty(actInfo.ContentImageUrl))
                    {
                        LtlContentImageUrl.Text =
                            $@"<img id=""preview_contentImageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                PublishmentSystemInfo, actInfo.ContentImageUrl)}"" width=""370"" align=""middle"" />";
                    }
                    TbContentUsage.Text       = actInfo.ContentUsage;
                    TbContentDescription.Text = actInfo.ContentDescription;
                    TbAwardCode.Text          = actInfo.AwardCode;

                    TbEndTitle.Text   = actInfo.EndTitle;
                    TbEndSummary.Text = actInfo.EndSummary;
                    if (!string.IsNullOrEmpty(actInfo.EndImageUrl))
                    {
                        LtlEndImageUrl.Text =
                            $@"<img id=""preview_endImageUrl"" src=""{PageUtility.ParseNavigationUrl(
                                PublishmentSystemInfo, actInfo.EndImageUrl)}"" width=""370"" align=""middle"" />";
                    }

                    ImageUrl.Value        = actInfo.ImageUrl;
                    ContentImageUrl.Value = actInfo.ContentImageUrl;
                    EndImageUrl.Value     = actInfo.EndImageUrl;

                    CbIsFormRealName.Checked = actInfo.IsFormRealName;
                    TbFormRealNameTitle.Text = actInfo.FormRealNameTitle;
                    CbIsFormMobile.Checked   = actInfo.IsFormMobile;
                    TbFormMobileTitle.Text   = actInfo.FormMobileTitle;
                    CbIsFormEmail.Checked    = actInfo.IsFormEmail;
                    TbFormEmailTitle.Text    = actInfo.FormEmailTitle;
                    CbIsFormAddress.Checked  = actInfo.IsFormAddress;
                    TbFormAddressTitle.Text  = actInfo.FormAddressTitle;
                }
                else
                {
                    DtbEndDate.DateTime = DateTime.Now.AddMonths(1);
                }

                BtnReturn.Attributes.Add("onclick",
                                         $@"location.href=""{PageCouponAct.GetRedirectUrl(PublishmentSystemId)}"";return false");
            }
        }
예제 #3
0
        public override void Submit_OnClick(object sender, EventArgs e)
        {
            if (Page.IsPostBack && Page.IsValid)
            {
                var selectedStep = 0;
                if (PhStep1.Visible)
                {
                    selectedStep = 1;
                }
                else if (PhStep2.Visible)
                {
                    selectedStep = 2;
                }
                else if (PhStep3.Visible)
                {
                    selectedStep = 3;
                }
                else if (PhStep4.Visible)
                {
                    selectedStep = 4;
                }
                PhStep1.Visible = PhStep2.Visible = PhStep3.Visible = PhStep4.Visible = false;

                if (selectedStep == 1)
                {
                    var isConflict       = false;
                    var conflictKeywords = string.Empty;
                    if (!string.IsNullOrEmpty(TbKeywords.Text))
                    {
                        if (_actId > 0)
                        {
                            var actInfo = DataProviderWx.CouponActDao.GetActInfo(_actId);
                            isConflict = KeywordManager.IsKeywordUpdateConflict(PublishmentSystemId, actInfo.KeywordId, TbKeywords.Text, out conflictKeywords);
                        }
                        else
                        {
                            isConflict = KeywordManager.IsKeywordInsertConflict(PublishmentSystemId, TbKeywords.Text, out conflictKeywords);
                        }
                    }

                    if (isConflict)
                    {
                        FailMessage($"触发关键词“{conflictKeywords}”已存在,请设置其他关键词");
                        PhStep1.Visible = true;
                    }
                    else
                    {
                        PhStep2.Visible = true;
                    }
                }
                else if (selectedStep == 2)
                {
                    PhStep3.Visible = true;
                }
                else if (selectedStep == 3)
                {
                    PhStep4.Visible = true;
                    BtnSubmit.Text  = "确 认";
                }
                else if (selectedStep == 4)
                {
                    var actInfo = new CouponActInfo();
                    if (_actId > 0)
                    {
                        actInfo = DataProviderWx.CouponActDao.GetActInfo(_actId);
                    }
                    actInfo.PublishmentSystemId = PublishmentSystemId;

                    actInfo.KeywordId  = DataProviderWx.KeywordDao.GetKeywordId(PublishmentSystemId, _actId > 0, PageUtils.FilterXss(TbKeywords.Text), EKeywordType.Coupon, actInfo.KeywordId);
                    actInfo.IsDisabled = !CbIsEnabled.Checked;

                    actInfo.StartDate          = DtbStartDate.DateTime;
                    actInfo.EndDate            = DtbEndDate.DateTime;
                    actInfo.Title              = TbTitle.Text;
                    actInfo.ImageUrl           = ImageUrl.Value;;
                    actInfo.Summary            = TbSummary.Text;
                    actInfo.ContentImageUrl    = ContentImageUrl.Value;;
                    actInfo.ContentUsage       = TbContentUsage.Text;
                    actInfo.ContentDescription = TbContentDescription.Text;
                    actInfo.AwardCode          = TbAwardCode.Text;

                    actInfo.IsFormRealName    = CbIsFormRealName.Checked;
                    actInfo.FormRealNameTitle = TbFormRealNameTitle.Text;
                    actInfo.IsFormMobile      = CbIsFormMobile.Checked;
                    actInfo.FormMobileTitle   = TbFormMobileTitle.Text;
                    actInfo.IsFormEmail       = CbIsFormEmail.Checked;
                    actInfo.FormEmailTitle    = TbFormEmailTitle.Text;
                    actInfo.IsFormAddress     = CbIsFormAddress.Checked;
                    actInfo.FormAddressTitle  = TbFormAddressTitle.Text;

                    actInfo.EndTitle    = TbEndTitle.Text;
                    actInfo.EndImageUrl = EndImageUrl.Value;
                    actInfo.EndSummary  = TbEndSummary.Text;

                    try
                    {
                        if (_actId > 0)
                        {
                            DataProviderWx.CouponActDao.Update(actInfo);

                            LogUtils.AddAdminLog("修改优惠劵活动",
                                                 $"优惠劵活动:{TbTitle.Text}");
                            SuccessMessage("修改优惠劵活动成功!");
                        }
                        else
                        {
                            _actId = DataProviderWx.CouponActDao.Insert(actInfo);

                            LogUtils.AddAdminLog("添加优惠劵活动",
                                                 $"优惠劵活动:{TbTitle.Text}");
                            SuccessMessage("添加优惠劵活动成功!");
                        }

                        var redirectUrl = PageCouponAct.GetRedirectUrl(PublishmentSystemId);
                        AddWaitAndRedirectScript(redirectUrl);
                    }
                    catch (Exception ex)
                    {
                        FailMessage(ex, "优惠劵活动设置失败!");
                    }

                    BtnSubmit.Visible = false;
                    BtnReturn.Visible = false;
                }
            }
        }