Beispiel #1
0
    private void UpdateMaxActiveCampaignsLiteralText()
    {
        int activeCampaigns = PtcAdvert.GetUserActiveCampaignsCount(Member.CurrentId);

        MaxActiveCampaignsLiteral.Text = U5007.MAXACTIVEADCAMPAINS + ": " + activeCampaigns
                                         + "/" + Member.CurrentInCache.Membership.MaxActivePtcCampaignLimit;
    }
Beispiel #2
0
    protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //We want to obey OnSort and OnChart events
        string[] commands = new string[5] {
            "start", "stop", "add", "remove", "edit"
        };

        if (commands.Contains(e.CommandName))
        {
            ErrorMessagePanel2.Visible = false;

            int         index = e.GetSelectedRowIndex() % DirectRefsGridView.PageSize;
            GridViewRow row   = DirectRefsGridView.Rows[index];
            string      AdId  = (row.Cells[1].Text.Trim());
            var         Ad    = new PtcAdvert(Convert.ToInt32(AdId));

            if (e.CommandName == "start")
            {
                //Check Max Campaign limit
                int currentCamapigns = PtcAdvert.GetUserActiveCampaignsCount(Member.CurrentId);

                if (currentCamapigns + 1 > Member.CurrentInCache.Membership.MaxActivePtcCampaignLimit)
                {
                    ErrorMessagePanel2.Visible = true;
                    ErrorMessage2.Text         = U5006.CANNOTEXCEED.Replace("%n%", Member.CurrentInCache.Membership.MaxActivePtcCampaignLimit.ToString());
                }
                else
                {
                    Ad.Status = AdvertStatus.Active;
                    Ad.SaveStatus();
                }
            }
            else if (e.CommandName == "stop")
            {
                Ad.Status = AdvertStatus.Paused;
                Ad.SaveStatus();
            }
            else if (e.CommandName == "add")
            {
                Response.Redirect("credits.aspx?id=" + AdId);
            }
            else if (e.CommandName == "remove")
            {
                Ad.Status = AdvertStatus.Deleted;
                Ad.SaveStatus();
            }
            else if (e.CommandName == "edit")
            {
                Response.Redirect("ads.aspx?editid=" + AdId);
            }

            UpdateMaxActiveCampaignsLiteralText();
            DirectRefsGridView.DataBind();
        }
    }