protected void Update_Page(object sender, EventArgs e) { seasondb db = new seasondb(); bool valid = true; string season_id = Request.QueryString["seasonid"]; if (String.IsNullOrEmpty(season_id)) { valid = false; } if (valid) { http_page new_season = new http_page(); new_season.SetStitle(s_title.Text); new_season.SetSbody(s_body.Text); try { db.UpdatePage(Int32.Parse(season_id), new_season); Response.Redirect("listpages.aspx?seasonid=" + season_id); } catch { valid = false; } } }
public http_page FindPage(int seasonId) { MySqlConnection Connect = new MySqlConnection(ConnectionString); http_page result_season = new http_page(); try { //finding a particular season based on seasonid information string query = "select * from season where seasonid = " + seasonId; Debug.WriteLine("Connection Initialized..."); Connect.Open(); MySqlCommand cmd = new MySqlCommand(query, Connect); MySqlDataReader resultset = cmd.ExecuteReader(); List <http_page> seasons = new List <http_page>(); while (resultset.Read()) { http_page currentseason = new http_page(); for (int i = 0; i < resultset.FieldCount; i++) { string key = resultset.GetName(i); string value = resultset.GetString(i); Debug.WriteLine("Attempting to transfer " + key + " data of " + value); switch (key) { case "seasontitle": currentseason.SetStitle(value); break; case "seasonbody": currentseason.SetSbody(value); break; } } seasons.Add(currentseason); } result_season = seasons[0]; } catch (Exception ex) { Debug.WriteLine("Something went wrong in the find season method!"); Debug.WriteLine(ex.ToString()); } Connect.Close(); Debug.WriteLine("Database Connection Terminated."); return(result_season); }
protected void Add_Page(object sender, EventArgs e) { seasondb db = new seasondb(); http_page new_season = new http_page(); new_season.SetStitle(season_title.Text); new_season.SetSbody(season_body.Text); db.AddPage(new_season); Response.Redirect("listpages.aspx"); }