protected void DeleteAlbum_Click(object sender, EventArgs e) { //any other business rules if (string.IsNullOrEmpty(AlbumID.Text)) { MessageUserControl2.ShowInfo("Missing Data", "Missing Album Id. Use Find to locate the album you wish to maintain."); } else { int albumid = 0; if (int.TryParse(AlbumID.Text, out albumid)) { MessageUserControl2.TryRun(() => { AlbumController sysmgr = new AlbumController(); sysmgr.Albums_Delete(albumid); }, "Delete Album", "Album has been successfully delete from the database."); } else { MessageUserControl2.ShowInfo("Invalid Data", "Album Id. Use Find to locate the album you wish to maintain."); } } }
protected void UpdateAlbum_Click(object sender, EventArgs e) { if (IsValid) { //any other business rules if (string.IsNullOrEmpty(AlbumID.Text)) { MessageUserControl2.ShowInfo("Missing Data", "Missing Album Id. Use Find to locate the album you wish to maintain."); } else { int albumid = 0; if (int.TryParse(AlbumID.Text, out albumid)) { MessageUserControl2.TryRun(() => { AlbumController sysmgr = new AlbumController(); Album newalbum = new Album(); newalbum.AlbumId = albumid; newalbum.Title = AlbumTitle.Text; newalbum.ArtistId = int.Parse(ArtistList.SelectedValue); newalbum.ReleaseYear = int.Parse(AlbumReleaseYear.Text); newalbum.ReleaseLabel = string.IsNullOrEmpty(AlbumReleaseLabel.Text) ? null : AlbumReleaseYear.Text; sysmgr.Albums_Update(newalbum); }, "Update Album", "Album has been successfully update on the database."); } else { MessageUserControl2.ShowInfo("Invalid Data", "Album Id. Use Find to locate the album you wish to maintain."); } } } }
protected void DeleteAlbum_Click(object sender, EventArgs e) { //retest the validation of the incoming data via the Validation controls //any other business rules if (string.IsNullOrEmpty(AlbumID.Text)) { MessageUserControl2.ShowInfo("Missing Data", "Missing Album Id, Use find to lcation the album you wish to update"); } else { int albumid = 0; if (int.TryParse(AlbumID.Text, out albumid)) { MessageUserControl2.TryRun(() => { AlbumController sysmgr = new AlbumController(); sysmgr.Album_Delete(albumid); }, "Add Album", "Album has been sucessfully updated to the database"); } else { MessageUserControl2.ShowInfo("Invalid Data", "Album Id, Use find to lcation the album you wish to update"); } } }
protected void UpdateResults_Command(object sender, CommandEventArgs e) { var raceID = ScheduleGridView.SelectedValue; string error = string.Empty; List <ResultsViewModel> results = new List <ResultsViewModel>(); ResultsViewModel singleResult = null; foreach (GridViewRow row in ResultsGridView.Rows) { DropDownList penalties = (DropDownList)row.FindControl("PenaltyDropDownList"); TextBox runTimeText = (TextBox)row.FindControl("RunTimeTextBox"); Label name = (Label)row.FindControl("NameLabel"); if (runTimeText.Text.Trim().Length < 1 && int.Parse(penalties.SelectedValue) != 4) { error = error + $"Cannot enter null values for race times unless vehicle has been scratched - {name.Text}"; } TimeSpan?runTime = null; if (runTimeText.Text == "") { runTime = null; } else { runTime = TimeSpan.Parse(runTimeText.Text); } HiddenField raceDetailID = (HiddenField)row.FindControl("RaceDetailID"); singleResult = new ResultsViewModel() { Name = name.Text, RaceDetailID = int.Parse(raceDetailID.Value), RaceID = Convert.ToInt32(raceID), RunTime = runTime, PenaltyID = int.Parse(penalties.SelectedValue) }; results.Add(singleResult); } var controller = new RacingController(); if (error.Trim().Length > 0) { MessageUserControl2.ShowInfo("Error", error); } else { controller.Edit_Results(results); LoadRaceTime(); } }
protected void DeleteAlbum_Click(object sender, EventArgs e) { MessageUserControl2.ShowInfo("inside Delete"); }