protected void Clear_Click(object sender, EventArgs e) { PlayerID.Text = ""; FirstName.Text = ""; LastName.Text = ""; Age.Text = ""; Gender.SelectedValue = "M"; AlbertaHealthCareNumber.Text = ""; MedicalAlertDetails.Text = ""; PlayerList.ClearSelection(); GuardianList.ClearSelection(); TeamList.ClearSelection(); }
protected void DeletePlayer_Click(object sender, EventArgs e) { int playerid = 0; if (string.IsNullOrEmpty(PlayerID.Text)) { errormsgs.Add("Search for a player to delete"); } else if (!int.TryParse(PlayerID.Text, out playerid)) { errormsgs.Add("Player ID is invalid"); } else if (playerid < 1) { errormsgs.Add("Product ID is invalid"); } if (errormsgs.Count > 0) { LoadMessageDisplay(errormsgs, "alert alert-danger"); } else { try { PlayerController sysmgr = new PlayerController(); int rowsaffected = sysmgr.Player_Delete(playerid); if (rowsaffected > 0) { errormsgs.Add("Player has been deleted"); LoadMessageDisplay(errormsgs, "alert alert-success"); BindPlayerList(); PlayerID.Text = ""; GuardianList.ClearSelection(); TeamList.ClearSelection(); FirstName.Text = ""; LastName.Text = ""; Age.Text = ""; Gender.ClearSelection(); AlbertaHealthCareNumber.Text = ""; MedicalAlertDetails.Text = ""; PlayerList.ClearSelection(); } else { errormsgs.Add("Player has not been deleted. Player was not found."); LoadMessageDisplay(errormsgs, "alert alert-info"); BindPlayerList(); } } catch (DbUpdateException ex) { UpdateException updateException = (UpdateException)ex.InnerException; if (updateException.InnerException != null) { errormsgs.Add(updateException.InnerException.Message.ToString()); } else { errormsgs.Add(updateException.Message); } LoadMessageDisplay(errormsgs, "alert alert-danger"); } catch (DbEntityValidationException ex) { foreach (var entityValidationErrors in ex.EntityValidationErrors) { foreach (var validationError in entityValidationErrors.ValidationErrors) { errormsgs.Add(validationError.ErrorMessage); } } LoadMessageDisplay(errormsgs, "alert alert-danger"); } catch (Exception ex) { errormsgs.Add(GetInnerException(ex).ToString()); LoadMessageDisplay(errormsgs, "alert alert-danger"); } } }