protected void DeleteBtn_Click(object sender, EventArgs e) { CSS RequestDirector = new CSS(); CustomPrincipal cp = HttpContext.Current.User as CustomPrincipal; bool confirmation; Facilitator activeFac = new Facilitator(); activeFac.FacilitatorID = Convert.ToInt32(cp.Identity.Name); //delete event data List <Event> events = RequestDirector.GetFacilitatorEvents(activeFac.FacilitatorID); List <Question> eventQs; foreach (Event ev in events) { eventQs = new List <Question>(); eventQs = RequestDirector.GetQuestions(ev.EventID); foreach (Question q in eventQs) { confirmation = RequestDirector.DeleteQuestion(q); } confirmation = RequestDirector.DeleteEventData(ev); confirmation = RequestDirector.DeleteEvent(ev); } //delete account confirmation = RequestDirector.DeleteFacilitator(activeFac); //sign out FormsAuthentication.SignOut(); Response.Redirect("Default.aspx", true); }
protected void Page_Load(object sender, EventArgs e) { CustomPrincipal cp = HttpContext.Current.User as CustomPrincipal; CSS Director = new CSS(); Facilitator activeFac = new Facilitator(); activeFac.FacilitatorID = Convert.ToInt32(cp.Identity.Name); activeFac = Director.GetFacilitator(activeFac.FacilitatorID); List <Event> EventList; EventList = Director.GetFacilitatorEvents(activeFac.FacilitatorID); // Displays Rows in the table foreach (Event eve in EventList) { // Display the Row for each event TableRow tRow = new TableRow(); TableCell tCell = new TableCell(); tCell.Text = eve.Date.ToLongDateString(); tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.Text = eve.Location; tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.Text = eve.Performer; tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.Text = eve.Description; tRow.Cells.Add(tCell); tCell = new TableCell(); if (eve.EventStart != defaultTime) { if (eve.EventEnd != defaultTime) { tCell.Text = "Completed"; } else { tCell.Text = "Running"; } } else { tCell.Text = "Waiting to start"; } tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.Text = eve.Evaluators.Count.ToString(); tRow.Cells.Add(tCell); tCell = new TableCell(); tCell.CssClass = "btn-group"; Button btn = new Button(); btn.Text = "View Event"; btn.ID = String.Format("EventView{0}", eve.EventID.ToString()); btn.Click += new EventHandler(ViewEvent_Click); btn.CssClass = "btn btn-default"; tCell.Controls.Add(btn); tRow.Cells.Add(tCell); btn = new Button(); btn.Text = "Delete"; btn.ID = String.Format("EventDelete{0}", eve.EventID.ToString()); btn.Click += new EventHandler(DeleteEvent_Click); btn.OnClientClick = "return confirm('Are you sure you want to delete this event and all associated data?');"; btn.CssClass = "btn btn-default"; tCell.Controls.Add(btn); tRow.Cells.Add(tCell); tRow.Cells.Add(tCell); tblEventList.Rows.Add(tRow); } }