/// <summary> /// A method used to retrieve the data which stores the fitness classes /// </summary> protected void Load_Data() { XmlDocument doc = new XmlDocument(); string[] dets = new string[10]; doc.Load(Server.MapPath("~/App_Data/report_all.xml")); XmlNode root = doc.DocumentElement; IEnumerator ienum = root.GetEnumerator(); XmlNodeList fitnessClass = doc.GetElementsByTagName("class"); int i = 0; foreach (XmlNode node in fitnessClass) { foreach (XmlNode childNode in node.ChildNodes) { dets[i] = childNode.InnerText; i++; if (i == 10) { if (dets[7] == "No" || dets[7] == "no") { dets[7] = "false"; } else { dets[7] = "true"; } FitnessClassManager.FitnessClassOpportunity fcp = new FitnessClassManager.FitnessClassOpportunity(Int32.Parse(dets[0]), dets[1], dets[2], Int32.Parse(dets[3]), dets[4], Convert.ToDateTime(dets[5]), Int32.Parse(dets[6]), Convert.ToBoolean(dets[7]), Convert.ToDateTime(dets[8]), dets[9]); i = 0; fitnessClassList.addFitnessClass(fcp); } } } fitnessClassList.Sort(); FitnessClassManager.TextReportGenerator trg = new FitnessClassManager.TextReportGenerator(fitnessClassList); trg.GenerateAllReport(Server.MapPath("~/App_Data/report_all.xml")); if (filterDropDownList.SelectedValue == "Show All") { DataSet ds = new DataSet(); ds.ReadXml(Server.MapPath("~/App_Data/report_all.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } trg.GenerateDayReport(Server.MapPath("~/App_Data/report_Monday.xml"), "Monday"); trg.GenerateDayReport(Server.MapPath("~/App_Data/report_Tuesday.xml"), "Tuesday"); trg.GenerateDayReport(Server.MapPath("~/App_Data/report_Wednesday.xml"), "Wednesday"); trg.GenerateDayReport(Server.MapPath("~/App_Data/report_Thursday.xml"), "Thursday"); trg.GenerateDayReport(Server.MapPath("~/App_Data/report_Friday.xml"), "Friday"); trg.GenerateDayReport(Server.MapPath("~/App_Data/report_Saturday.xml"), "Saturday"); trg.GenerateDayReport(Server.MapPath("~/App_Data/report_Sunday.xml"), "Sunday"); trg.GenerateLocationReport(Server.MapPath("~/App_Data/report_CityGym.xml"), "City Gym"); trg.GenerateLocationReport(Server.MapPath("~/App_Data/report_PlazaGym.xml"), "Plaza Gym"); trg.GenerateLocationReport(Server.MapPath("~/App_Data/report_AquaticGym.xml"), "Aquatic Gym"); trg.GenerateLocationReport(Server.MapPath("~/App_Data/report_NewGym.xml"), "New Gym"); trg.GenerateLocationReport(Server.MapPath("~/App_Data/report_QuadrantGym.xml"), "Quadrant Gym"); }
/// <summary> /// If the form details have been filled in correctly then a new class is added to the fitness class list. In the case the user has enter a duplicate ID a /// exception is thrown with the message shown in a message window /// </summary> protected void submitButton_Click(object sender, EventArgs e) { if (Page.IsValid) { try { FitnessClassManager.FitnessClassOpportunity fco = new FitnessClassManager.FitnessClassOpportunity(Int32.Parse(idTextBox.Text), descriptionTextBox.Text, locationDropDownList.SelectedValue, Int32.Parse(spacesTextBox.Text), dowDropDownList.SelectedValue, Convert.ToDateTime(timeTextBox.Text), Int32.Parse(durationTextBox.Text), mw, Convert.ToDateTime(startdateTextBox.Text), nosTextBox.Text); XmlDocument doc = new XmlDocument(); string[] dets = new string[10]; FitnessClassManager.FitnessClassList fitnessClassList = new FitnessClassManager.FitnessClassList(); fitnessClassList.addFitnessClass(fco); doc.Load(Server.MapPath("~/App_Data/report_all.xml")); XmlNode root = doc.DocumentElement; IEnumerator ienum = root.GetEnumerator(); XmlNodeList fitnessClass = doc.GetElementsByTagName("class"); int i = 0; foreach (XmlNode node in fitnessClass) { foreach (XmlNode childNode in node.ChildNodes) { dets[i] = childNode.InnerText; i++; if (i == 10) { if (dets[7] == "No" || dets[7] == "no") { dets[7] = "false"; } else { dets[7] = "true"; } FitnessClassManager.FitnessClassOpportunity fcp = new FitnessClassManager.FitnessClassOpportunity(Int32.Parse(dets[0]), dets[1], dets[2], Int32.Parse(dets[3]), dets[4], Convert.ToDateTime(dets[5]), Int32.Parse(dets[6]), Convert.ToBoolean(dets[7]), Convert.ToDateTime(dets[8]), dets[9]); i = 0; fitnessClassList.addFitnessClass(fcp); } } } FitnessClassManager.TextReportGenerator trg = new FitnessClassManager.TextReportGenerator(fitnessClassList); trg.GenerateAllReport(Server.MapPath("~/App_Data/report_all.xml")); Response.Redirect("Success.aspx"); } catch (FitnessClassManager.DuplicateIdException dIP) { string display = dIP.Message; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else { validationSummary.ShowSummary = true; } }
/// <summary> /// When the user selects to change the report list the dropdown list checks the value and retrieves the value then shows the list /// if the list is not available a message window is shown informing the user of this /// </summary> protected void Change_Output(object sender, EventArgs e) { FitnessClassManager.TextReportGenerator trg = new FitnessClassManager.TextReportGenerator(fitnessClassList); DataSet ds = new DataSet(); if (filterDropDownList.SelectedValue == "Show All") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_all.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "Monday Classes") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_Monday.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on a Monday currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "Tuesday Classes") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_Tuesday.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on a Tuesday currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "Wednesday Classes") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_Wednesday.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on a Wednesday currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "Thursday Classes") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_Thursday.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on a Thursday currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "Friday Classes") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_Friday.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on a Friday currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "Saturday Classes") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_Saturday.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on a Saturday currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "Sunday Classes") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_Sunday.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on a Sunday currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "City Gym") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_CityGym.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on at City Gym currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "Plaza Gym") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_PlazaGym.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on at Plaza Gym currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "New Gym") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_NewGym.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on at New Gym currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "Quadrant Gym") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_QuadrantGym.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on at Quadrant Gym currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } else if (filterDropDownList.SelectedValue == "Aquatic Gym") { try { ds.ReadXml(Server.MapPath("~/App_Data/report_AquaticGym.xml")); Repeater1.DataSource = ds; Repeater1.DataBind(); } catch { string display = "Sorry there are currently no classes held on at Aquatic Gym currently."; ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('" + display + "');", true); } } }