protected void btnAdd_Click(object sender, EventArgs e) { clsJourneyCollection Journey = new clsJourneyCollection(); //validation here Boolean OK = Journey.ThisJourney.Valid(txtStationFrom.Text, txtplatformFrom.Text, txtStationTo.Text, txtPlatformTo.Text, txtPrice.Text, txtDeparture.Text, txtArrvial.Text); //set some vars for the txt elements string StationFrom = txtStationFrom.Text; string PlatformFrom = txtplatformFrom.Text; string StationTo = txtStationTo.Text; string PlatformTo = txtPlatformTo.Text; string Price = txtPrice.Text; string Departure = txtDeparture.Text; string Arrvial = txtArrvial.Text; //if the data is OK add it to the object if (OK == true) { Journey.ThisJourney.StationFrom = StationFrom; Journey.ThisJourney.PlatformFrom = PlatformFrom; Journey.ThisJourney.StationTo = StationTo; Journey.ThisJourney.PlatformTo = PlatformTo; Journey.ThisJourney.Price = Price; Journey.ThisJourney.Departure = Departure; Journey.ThisJourney.Arrival = Arrvial; Journey.Add(); //refresh the page Response.Redirect("Journeys.aspx"); lblValid.Text = "Success"; } else { //report an error lblValid.Text = "Please try again"; } }
private void DisplayRecords() { clsJourneyCollection Record = new clsJourneyCollection(); GVJourney.DataSource = Record.JourneyList; GVJourney.DataBind(); }
protected void btnFind_Click(object sender, EventArgs e) { string station = txtStationFrom.Text; string platform = txtplatformFrom.Text; journeys = new clsJourneyCollection(); journeys.FilterByStation(station, platform); GenerateTable(); }
private void DeleteRecord() { //new instance clsJourneyCollection Record = new clsJourneyCollection(); //get the number of the Journey to be deleted from the session object JourneyID = Convert.ToInt32(Session["JourneyID"]); //find the record Record.ThisJourney.Find(JourneyID); //delete the record Record.Delete(); }
private void DisplayJourney() { clsJourneyCollection JourneyList = new clsJourneyCollection(); Int32 Index = 0; Int32 RecordCount = JourneyList.Count; while (Index < RecordCount) { Response.Write(JourneyList.JourneyList[Index].JourneyID); Response.Write(JourneyList.JourneyList[Index].StationFrom); Response.Write(JourneyList.JourneyList[Index].PlatformFrom); Response.Write(JourneyList.JourneyList[Index].StationTo); Response.Write(JourneyList.JourneyList[Index].PlatformTo); Response.Write(JourneyList.JourneyList[Index].Price); Response.Write(JourneyList.JourneyList[Index].Departure); Response.Write(JourneyList.JourneyList[Index].Arrival); //increment the index Index++; } }
protected void btnRefresh_Click(object sender, EventArgs e) { clsJourneyCollection journey = new clsJourneyCollection(); GenerateTable(); }