protected void DirectRefsGridView_RowCommand(object sender, GridViewCommandEventArgs e) { //We want to obey OnSort and OnChart events string[] commands = new string[5] { "start", "stop", "add", "addsubpage", "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 TrafficExchangeAdvert(Convert.ToInt32(AdId)); if (e.CommandName == "start") { Ad.Status = AdvertStatus.Active; Ad.SaveStatus(); Response.Redirect("trafficexchange.aspx"); } else if (e.CommandName == "stop") { Ad.Status = AdvertStatus.Paused; Ad.SaveStatus(); Response.Redirect("trafficexchange.aspx"); } else if (e.CommandName == "add") { Response.Redirect("trafficexchangecredits.aspx?id=" + AdId); } else if (e.CommandName == "addsubpage") { Response.Redirect("trafficexchangesubpages.aspx?id=" + AdId); } else if (e.CommandName == "remove") { Ad.Status = AdvertStatus.Deleted; Ad.SaveStatus(); Response.Redirect("trafficexchange.aspx"); } } }
protected void CreateAdButton_Click(object sender, EventArgs e) { ErrorMessagePanel.Visible = false; if (Page.IsValid) { try { AppSettings.DemoCheck(); if (Ad.Status == AdvertStatus.Finished) { Member User = Member.Current; TrafficExchangeAdvertPack Pack = new TrafficExchangeAdvertPack(Int32.Parse(ddlOptions.SelectedValue)); PurchaseOption.ChargeBalance(User, Pack.Price, PurchaseBalances.Traffic, U6012.TECREDITS); //Modify Ad.Prolong(Pack); Ad.Status = AdvertStatus.Paused; Ad.SaveStatus(); Ad.Save(); //Add history entry string entryText = ""; if (Pack.Ends.EndMode == End.Mode.Clicks) { entryText = (Convert.ToInt32(Pack.Ends.Value)).ToString() + " ad clicks"; } else if (Pack.Ends.EndMode == End.Mode.Days) { entryText = (Convert.ToInt32(Pack.Ends.Value)).ToString() + " ad days"; } History.AddPurchase(User.Name, Pack.Price, entryText); Response.Redirect("trafficexchange.aspx"); } } catch (MsgException ex) { ErrorMessagePanel.Visible = true; ErrorMessage.Text = ex.Message; } catch (Exception ex) { ErrorLogger.Log(ex); throw ex; } } }