Example #1
0
    public void MenuButton_Click(object sender, EventArgs e)
    {
        ErrorMessagePanel.Visible = false;
        SuccMessagePanel.Visible  = false;

        var TheButton = (Button)sender;
        int viewIndex = Int32.Parse(TheButton.CommandArgument);

        if (viewIndex == 0)
        {
            Response.Redirect("bannersb.aspx");
        }
        else
        {
            DimensionsPlaceHolder.Controls.Clear();
        }

        MenuMultiView.ActiveViewIndex = viewIndex;

        //Change button style
        foreach (Button b in MenuButtonPlaceHolder.Controls)
        {
            b.CssClass = "";
        }
        TheButton.CssClass = "ViewSelected";

        if (viewIndex == 1)
        {
            DirectRefsGridView.DataBind();
        }

        Session["YourCampaigns_NewBannerAdvert"]       = null;
        createBannerAdvertisement_BannerImage.ImageUrl = "";
        URL.Text = "http://";
    }
Example #2
0
    protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "comSend")
        {
            try
            {
                AppSettings.DemoCheck();

                int index = e.GetSelectedRowIndex() % DirectRefsGridView.PageSize;

                GridViewRow row = DirectRefsGridView.Rows[index];

                var declaration = new RefBackDeclarations();
                declaration.Username      = Member.CurrentName;
                declaration.RefbackSiteId = Int32.Parse(row.Cells[0].Text);
                declaration.Save();

                var site = new RefBackSites(declaration.RefbackSiteId);
                site.UsersDeclared++;
                site.Save();

                DirectRefsGridView.DataBind();
            }
            catch (MsgException ex)
            { }
        }
    }
Example #3
0
    protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //We want to obey OnSort and OnChart events
        string[] commands = new string[3] {
            "start", "stop", "remove"
        };

        if (commands.Contains(e.CommandName))
        {
            int         index = e.GetSelectedRowIndex() % DirectRefsGridView.PageSize;
            GridViewRow row   = DirectRefsGridView.Rows[index];
            var         Ad    = new FacebookAdvert(Convert.ToInt32(row.Cells[1].Text.Trim()));

            if (e.CommandName == "start")
            {
                Ad.Status = AdvertStatus.Active;
                Ad.SaveStatus();
                DirectRefsGridView.DataBind();
            }
            else if (e.CommandName == "stop")
            {
                Ad.Status = AdvertStatus.Paused;
                Ad.SaveStatus();
                DirectRefsGridView.DataBind();
            }
            else if (e.CommandName == "remove")
            {
                Ad.Status = AdvertStatus.Deleted;
                Ad.SaveStatus();
                DirectRefsGridView.DataBind();
            }
        }
    }
Example #4
0
    protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //We want to obey OnSort and OnChart events
        string[] commands = new string[3] {
            "start", "stop", "remove"
        };

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

            switch (e.CommandName)
            {
            case "start":
                Ad.Status = AdvertStatus.Active;
                break;

            case "stop":
                Ad.Status = AdvertStatus.Paused;
                break;

            case "remove":
                Ad.Status = AdvertStatus.Deleted;
                break;
            }
            Ad.SaveStatus();
            ShowSuccPanel();
            DirectRefsGridView.DataBind();
            Response.Redirect("~/user/advert/banners.aspx");
        }
    }
Example #5
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();
        }
    }
Example #6
0
    protected void RenewButton_Click(object sender, EventArgs e)
    {
        ClearPanels();
        //Renew
        try
        {
            Member user = Member.Current;

            int referralsDone = 0;
            for (int i = 0; i < DirectRefsGridView.Rows.Count; i++)
            {
                if (((HtmlInputCheckBox)DirectRefsGridView.Rows[i].FindControl("chkSelect")).Checked)
                {
                    RentedReferralRenewalDiscount discount;
                    var discountId = Convert.ToInt32(RenewDropDownList.SelectedValue);

                    if (discountId == -1)
                    {
                        discount = RentedReferralRenewalDiscount.GetDefaultObject();
                    }
                    else
                    {
                        discount = new RentedReferralRenewalDiscount(discountId);
                    }

                    var price = RentedReferralRenewalDiscount.GetRenewalPrice(user.Membership, discount);
                    if (price > user.PurchaseBalance)
                    {
                        throw new MsgException(L1.OPPREFPARTIAL.ToString().Replace("%n%", referralsDone.ToString()));
                    }

                    user.SubtractFromPurchaseBalance(price, "Ref: renew");
                    user.SaveBalances();
                    referralsDone++;
                    string refId = (DirectRefsGridView.Rows[i].Cells[1].Text.Trim());
                    RentReferralsSystem.RenewReferral(Int32.Parse(refId), discount.Days);
                }
            }
            SuccMessagePanel2.Visible = true;
            SuccMessage2.Text         = U3501.REFACTIONSUCC;
        }
        catch (MsgException ex)
        {
            ErrorMessagePanel2.Visible = true;
            ErrorMessage2.Text         = ex.Message;
        }

        DirectRefsGridView.DataBind();
    }
Example #7
0
    protected void AutopayOffButton_Click(object sender, EventArgs e)
    {
        ClearPanels();
        bool hasErrors = false;

        //AutoPay
        using (var bridge = ParserPool.Acquire(Database.Client))
        {
            int referralsDone = 0;
            for (int i = 0; i < DirectRefsGridView.Rows.Count; i++)
            {
                if (((HtmlInputCheckBox)DirectRefsGridView.Rows[i].FindControl("chkSelect")).Checked)
                {
                    int    ExpireDays = Int32.Parse(DirectRefsGridView.Rows[i].Cells[4].Text.Replace(" " + L1.DAYS, ""));
                    string refId      = (DirectRefsGridView.Rows[i].Cells[1].Text.Trim());
                    int    RefId      = Int32.Parse(refId);

                    //Should we turn on or off

                    if (ExpireDays < AppSettings.RentedReferrals.MinDaysToStartAutoPay)
                    {
                        hasErrors = true;
                    }
                    else
                    {
                        referralsDone++;
                        RentReferralsSystem.SetAutopayOffReferral(RefId, bridge.Instance);
                    }
                }
            }
            if (!hasErrors) //so bad, exceptions [*]
            {
                SuccMessagePanel2.Visible = true;
                SuccMessage2.Text         = U3501.REFACTIONSUCC2;
            }
            else
            {
                ErrorMessagePanel2.Visible = true;
                ErrorMessage2.Text         = L1.OPPREFAPARTIAL + " " + L1.OPREFAP;
                ErrorMessage2.Text         = ErrorMessage2.Text.Replace("%n%", referralsDone.ToString());
                ErrorMessage2.Text         = ErrorMessage2.Text.Replace("%n2%", AppSettings.RentedReferrals.MinDaysToStartAutoPay.ToString());
            }
            DirectRefsGridView.DataBind();
        }
    }
Example #8
0
    protected void RecycleButton_Click(object sender, EventArgs e)
    {
        ClearPanels();
        //Recycle
        try
        {
            using (var bridge = ParserPool.Acquire(Database.Client))
            {
                Member User = Member.Current;
                Money  SingleOperationCost = User.Membership.RentedReferralRecycleCost;
                int    referralsDone       = 0;
                for (int i = 0; i < DirectRefsGridView.Rows.Count; i++)
                {
                    if (((HtmlInputCheckBox)DirectRefsGridView.Rows[i].FindControl("chkSelect")).Checked)
                    {
                        if (SingleOperationCost > User.PurchaseBalance)
                        {
                            throw new MsgException(L1.OPPREFPARTIAL.ToString().Replace("%n%", referralsDone.ToString()));
                        }

                        string refId = (DirectRefsGridView.Rows[i].Cells[1].Text.Trim());
                        RentReferralsSystem.RecycleReferral(Int32.Parse(refId), bridge.Instance);
                        User.SubtractFromPurchaseBalance(SingleOperationCost, "Ref: recycle");
                        User.SaveBalances();
                        referralsDone++;
                    }
                }

                RentReferralsSystem.TryForceAutopay(User.Name);

                SuccMessagePanel2.Visible = true;
                SuccMessage2.Text         = U3501.REFACTIONSUCC;
            }
        }
        catch (MsgException ex)
        {
            ErrorMessagePanel2.Visible = true;
            ErrorMessage2.Text         = ex.Message;
        }

        DirectRefsGridView.DataBind();
    }
Example #9
0
    protected void AutopayAllOffButton_Click(object sender, EventArgs e)
    {
        ClearPanels();
        //AutoPay
        using (var bridge = ParserPool.Acquire(Database.Client))
        {
            int referralsDone = 0;
            for (int i = 0; i < DirectRefsGridView.Rows.Count; i++)
            {
                int    ExpireDays = Int32.Parse(DirectRefsGridView.Rows[i].Cells[4].Text.Replace(" " + L1.DAYS, ""));
                string refId      = (DirectRefsGridView.Rows[i].Cells[1].Text.Trim());
                int    RefId      = Int32.Parse(refId);

                referralsDone++;
                RentReferralsSystem.SetAutopayOffReferral(RefId, bridge.Instance);
            }
            SuccMessagePanel2.Visible = true;
            SuccMessage2.Text         = U6011.REFACTIONSUCC;

            DirectRefsGridView.DataBind();
        }
    }
Example #10
0
    protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //We want to obey OnSort and OnChart events
        string[] commands = new string[3] {
            "start", "stop", "remove"
        };

        if (commands.Contains(e.CommandName))
        {
            int index = e.GetSelectedRowIndex() % DirectRefsGridView.PageSize;

            GridViewRow row = DirectRefsGridView.Rows[index];
            var         Ad  = new CPAOffer((int)DirectRefsGridView.DataKeys[index].Value);

            if (e.CommandName == "start")
            {
                Ad.Status = AdvertStatus.Active;
                Ad.Save();

                DirectRefsGridView.DataBind();
            }
            else if (e.CommandName == "stop")
            {
                Ad.Status = AdvertStatus.Paused;
                Ad.Save();

                DirectRefsGridView.DataBind();
            }
            else if (e.CommandName == "remove")
            {
                Ad.Status = AdvertStatus.Deleted;
                Ad.Save();

                DirectRefsGridView.DataBind();
            }
        }
    }
Example #11
0
    protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        //We want to obey OnSort and OnChart events
        string[] commands = new string[4] {
            "comDelete", "comRenew", "comRecycle", "comAutopay"
        };

        if (commands.Contains(e.CommandName))
        {
            int index = e.GetSelectedRowIndex();

            GridViewRow row = DirectRefsGridView.Rows[index];
            ClearPanels();

            try
            {
                using (var bridge = ParserPool.Acquire(Database.Client))
                {
                    if (e.CommandName == "comDelete")
                    {
                        string refId = (row.Cells[1].Text.Trim());
                        RentReferralsSystem.DeleteReferral(Int32.Parse(refId), bridge.Instance);
                        Response.Redirect("rented.aspx");
                    }
                    else if (e.CommandName == "comRenew")
                    {
                        Member User = Member.Logged(Context);
                        Money  SingleOperationCost = CalcRenewCost(User.Membership.RenewalDiscount, User.Membership.ReferralRentCost);

                        if (User.PurchaseBalance < SingleOperationCost)
                        {
                            throw new MsgException(L1.NOTENOUGHFUNDS);
                        }

                        User.SubtractFromPurchaseBalance(SingleOperationCost, "Ref: renew");
                        User.SaveBalances();
                        string refId = (row.Cells[1].Text.Trim());
                        RentReferralsSystem.RenewReferral(Int32.Parse(refId), bridge.Instance);
                    }
                    else if (e.CommandName == "comRecycle")
                    {
                        Member User = Member.Logged(Context);
                        Money  SingleOperationCost = User.Membership.RentedReferralRecycleCost;

                        if (User.PurchaseBalance < SingleOperationCost)
                        {
                            throw new MsgException(L1.NOTENOUGHFUNDS);
                        }

                        string refId = (row.Cells[1].Text.Trim());
                        RentReferralsSystem.RecycleReferral(Int32.Parse(refId), bridge.Instance);
                        User.SubtractFromPurchaseBalance(SingleOperationCost, "Ref: recycle");
                        User.SaveBalances();
                    }
                    else if (e.CommandName == "comAutopay")
                    {
                        bool   setOn = true;
                        string refId = (row.Cells[1].Text.Trim());

                        if (row.Cells[7].Text.Contains("img")) // I know its bad, very bad
                        {
                            setOn = false;
                        }

                        if (setOn)
                        {
                            int ExpireDays = Int32.Parse(row.Cells[4].Text.Replace(" " + L1.DAYS, ""));
                            if (ExpireDays < AppSettings.RentedReferrals.MinDaysToStartAutoPay)
                            {
                                throw new MsgException((L1.OPREFAP).ToString().Replace("%n2%", AppSettings.RentedReferrals.MinDaysToStartAutoPay.ToString()));
                            }

                            RentReferralsSystem.SetAutopayOnReferral(Int32.Parse(refId), bridge.Instance);
                        }
                        else
                        {
                            RentReferralsSystem.SetAutopayOffReferral(Int32.Parse(refId), bridge.Instance);
                        }
                    }

                    DirectRefsGridView.DataBind();
                    SuccMessagePanel2.Visible = true;
                    SuccMessage2.Text         = L1.OP_SUCCESS;
                }
            }
            catch (MsgException ex)
            {
                ErrorMessagePanel2.Visible = true;
                ErrorMessage2.Text         = ex.Message;
            }
        }
    }