I am doing a project with some other guys and my part is to wright the class for Team.(FOOTBALL TEAMS) I have managed to do this and now I have to edit,delete and save a Team from a text file. I am using windows form with seven text boxes each for their different names,IE: Team League, Team Name , Team Manager, Team Nickname , Team Stadium, Team Logo and No of Players. I am using free buttons, one for Home,Refresh Team and update team.
I would like to know how to read the Team names in the first text box and then the second line to read in the next text box and so on.
Below is the code for my Form that i am having problems with so any help would be most appreciated. I have quite a few red lines but am not sure how to resolve them.
public partial class EditTeam : Form
private void btnHomeAddFixture_Click(object sender, EventArgs e)
frmFA form = new frmFA();
private void btnEditTeamUpdate_Click(object sender, EventArgs e)
bool allInputOK = false;
League whichLeague = (League)frmFA.Leagues[frmFA.leagueSelected];
//get inputs - fixture ORDER = Author Title Year Copies Isbn
string tempname = txtEditTeamName.Text;
string templeague = txtEditTeamLeague.Text;
string tempmanager = txtEditTeamManager.Text;
string tempnickname = txtEditTeamNickname.Text;
string tempstadium = txtEditTeamStadium.Text;
string templogo = txtEditTeamlogo.Text;
string tempnoofplayers = txtEditTeamNoofPlayers.Text;
//final validation check
allInputOK = Utilities.notNullTextBox(txtEditTeamName, "Team name") && Utilities.notNullTextBox(txtEditTeamLeague, "Team league")
&& Utilities.validNumber(txtEditTeamManager, "Team manager")
&& Utilities.validNumber(txtEditTeamStadium, "Team stadium") && Utilities.notNullTextBox(txtEditTeamlogo, "Team logo")
&& Utilities.validNumber(txtEditTeamNoofPlayers, "Team number of players");
//create fixture if all ok
Team temp = new Team(tempname, templeague, tempmanager, tempnickname, tempstadium, tempposition, temppoints, tempgameplayed, tempgoaldifference, templogo, tempnoofplayers);//create fixture
//OR YOU COULD HABVE USED THe LINE: whichLeague.getlibAllfixtures()[frmFA.fixtureSelected] = temp;
whichLeague.replacefixture(whichLeague.getlibAllfixtures(), temp, frmFA.fixtureSelected);
Utilities.writeAllLeaguefixtures(frmFA.inputDataFile, frmFA.Leagues);//update file
MessageBox.Show("Success: fixture " + tempTitle + " edited in " + whichLeague.getLeagueName());//finish up
private void btnRefresh_Click(object sender, EventArgs e)
I sort of know how stream writer and reader works i have created some demos from youtube and they worked fine. I want to be able to read the first line in my list of teams and have it display in the first text box and auto fill the rest of the text boxes with the rest of the Team data.
Here is the list of teams and the rest of the data , I need to be able to edit delete and save these teams. They have to stay in the same order as in the list. I would be most greatfull if you could help me please.
Arsenal Premiership Liz Stuart The Gunners Emirates Stadium 5 47 27 22 arsenal.jpg 19 Aston Villa Premiership Paul Lambert The Lions Villa Park 18 24 27 -26 villa.jpg 22 Chelsea Premiership Rafael Benetiz the blues Stamford Bridge 4 49 27 25 chelsea.jpg 19 Everton Premiership David Moyes The Toffees Goodison Park 6 42 27 7 everton.jpg 19 Fulham Premiership Martin Jol The Cottagers Craven Cottage 11 32 27 -5 fulham.jpg 19 Liverpool Premiership Brendan Rogers The Reds Anfield 8 39 27 15 liverpool.jpg 22 Manchester United Premiership Sir Alex ferguson The Red Devils Old Trafford 1 68 27 33 manu.jpg 25 Queens Park Rangers Premiership Harry Rednapp The Hoops Loftus Road Stadium 20 17 27 -24 queensparkrangers.jpg 17 Swansea City Premiership Michael Laudrup The Jacks Liberty Stadium 9 37 27 4 swansea.jpg 21 Tottenham Hotspur Premiership Andre Villa-Boas The Spurs White Hart Lane 3 51 27 15 tottenham.jpg 20 Newcastle Premiership Alan Pardew The Magpies St. James' Park 13 30 27 -10 newcastle.jpg 21 Manchester City Premiership Roberto Mancini City City of Manchester Stadium 2 56 27 26 mancity.jpg 23 Norwich Premiership Chris Hughton The Canaries Carrow Road 12 32 27 -14 norwich.jpg 18 West Ham United Premiership Sam Allardyce The Hammers The Boleyn Ground 14 30 27 -10 westham.jpg 19 Wigan Athletic Premiership Roberto Martinez The Latics DW Stadium 17 24 27 -18 wigan.jpg 21 West Bromich Albion Premiership Steve Clarke Albion The Hawthorns 7 40 27 2 westbrom.jpg 18 Sunderland Association Premiership Martin O'Neill The Black Cats Stadium of Light 15 29 27 -7 sunderland.jpg 19 Southampton Premiership Mauricio Pochettino The Saints St. Marys Stadium 16 27 27 -11 southampton.jpg 19 Reading Premiership Brian McDermott The Royals Madejski Stadium 19 23 27 -18 reading.jpg 16 Stoke City Premiership Tony Pulis The Potters Brittania Stadium 10 33 27 -6 stoke.jpg 21
Sounds like homework to me.
So you don't delete from the stream, you would read the stream into memory, probably creating a class for each team, and using a List<T> of teams. You'd then bind that to the list box.
When save is clicked you overwrite the stream with the updated list.
Comments have been closed since this content was published more than 30 days ago, but if you'd like to continue the conversation, please create a new thread in our Forums, or Contact Us and let us know.