Errors In C# windows forms

Aug 20 2013 3:01 PM
Hi there,
I am having some issues regarding some errors on my Windows Form and dont know how to solve them.
Here is my code below. I would be much appreciated if some one could help with these issues.
The error is under
public
static void readFixtures(string theFile, ArrayList allpremiereFixtures,
{
When i try to solve this error i keep ending up with loads of errors.
Please please Help.



using
System;
using
System.Collections;
using
System.Collections.Generic;
using
System.IO;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;


namespace
WindowsFormsApplication3
{
class Utillities
{

public static void readFixtures(string theFile, ArrayList allpremiereFixtures,
{
//local Variables
StreamReader inpremierFixtures = null;
bool anyMorePremierFixtures = false;
string[] fixtureData = new string[frmLoginPage.numFixItems];
string[] teamData = new string[frmLoginPage.numTeamItems];
Fixtures tempFix;
Team tempTeam;
int numTeamsInFix;
//if file is ok then proceed
if (Utillities.fileOpenForReadOK(theFile, ref inpremierFixtures))
{
anyMorePremierFixtures =
Utillities.getNext(frmLoginPage.numFixItems, inpremierFixtures, fixtureData);
//loop for all fixtures
while (anyMorePremierFixtures == true)
{
numTeamsInFix =
Convert.ToInt32(fixtureData[7]);
// order = Location, Date , Time,Information, Home Team ,Away Team, Favourite,
tempFix =
new Fixtures(fixtureData[0], fixtureData[1], fixtureData[2], fixtureData[3], fixtureData[4], fixtureData[5], fixtureData[6], numTeamsInFixtures);
//loop for all of the fixtures
for (int i = 0; i < numTeamsInFix; i++)
{
getNext(
frmLoginPage.numTeamItems, inpremierFixtures, teamData);
// team order= Nickname , logo , Owner, Manager, Name , Position in League
// Points, Games played , Goal Differance.
tempTeam =
new Team(teamData[0], teamData[1], teamData[2], teamData[3], teamData[4],
teamData[5], teamData[6], teamData[7], teamData[8]);
}
}
if (inpremierFixtures != null) inpremierFixtures.Close();
}
}




//write out data
public static void writeAllFixTeams(string theFile, ArrayList allpremierFixtures)
{
//local variables
StreamWriter outputTeams = null;
//create out
if (fileOpenForWtiteOK(theFile, ref outputTeams))
{
//loop through each fixture
foreach (Fixtures currFixtures in allpremierFixtures)
{
writeFixtures(outputTeams, currFixtures);
foreach (Team currTeam in currFixtures.getfixAllTeams()) //loop through each Team
writeTeam(outputTeams, currTeam);
}
outputTeams.Close();
//finish and tidy up
if (outputTeams != null) outputTeams.Close();
}
}
private static bool fileOpenForWtiteOK(string theFile, ref StreamWriter outputTeams)
{
throw new NotImplementedException();
}
public static void writeTeam(StreamWriter writingOutTeam, Team thisTeam)
{
// write out all its details
writingOutTeam.WriteLine(thisTeam.getNickname());
writingOutTeam.WriteLine(thisTeam.getLogo());
writingOutTeam.WriteLine(thisTeam.getOwner());
writingOutTeam.WriteLine(thisTeam.getManager());
writingOutTeam.WriteLine(thisTeam.getName());
writingOutTeam.WriteLine(thisTeam.getPosition());
writingOutTeam.WriteLine(thisTeam.getPoints());
writingOutTeam.WriteLine(thisTeam.getGames_Played());
writingOutTeam.WriteLine(thisTeam.getGoalDiff());
}

//services
public static bool getNext(int numItems, StreamReader inNext, string[] nextTeamData)
{
// locals
string nextLine;
int numDataItems = numItems;
//readFixtures Team Data - based on numDataItems
for (int i = 0; i < numDataItems; i++)
{
try{

nextLine = inNext.ReadLine();
if (nextLine != null)
nextTeamData[i] = nextLine;
else
{
return false; // no more full teams to process
}
}
catch (Exception e)
{
System.Windows.Forms.
MessageBox.Show("ERROR Reading from file. Incomplete Data. \n" + e.Message);
return false; // Problem , could not read the file
}
}
return true; // no issues
}
// services
// fixture order = Location, date, time, Information, Home team , away team , Favourite
public static void writeFixtures(StreamWriter writingOutFixtures, Fixtures thisFixtures)
{
writingOutFixtures.WriteLine(thisFixtures.getfixLocation());
writingOutFixtures.WriteLine(thisFixtures.getfixDate());
writingOutFixtures.WriteLine(thisFixtures.getfixTime());
writingOutFixtures.WriteLine(thisFixtures.getfixInformation());
writingOutFixtures.WriteLine(thisFixtures.getfixHome_Team());
writingOutFixtures.WriteLine(thisFixtures.getfixAway_Team());
writingOutFixtures.WriteLine(thisFixtures.getfixFavourite());
}
// services
public static void showListOfFixtures(TextBox textBoxOutput)
{
// clear TextBox
textBoxOutput.Clear();
string output;
// output data
foreach (Fixtures f in frmLoginPage.frmkeeppremierFixtures)
{

if ((1.getFixItemsAllTeams().Count) > 0)// if there are any teams
{
foreach (Fixtures f in 1.getnumFixtureItems())
{
output = (
" Fixture" + 1.getnumFixtureItems() + f.getfixLocation() + " Location " + f.getfixDate() + " Date " + f.getfixTime()
+
" Time " + f.getfixInformation() + " Information " + f.getfixHome_Team() + " Home team " + f.getfixAway_Team()
+
" Away Team " + f.getfixFavourite() + ".");
textBoxOutput.ControlAdded(output);
}
}
else
// show fix with no teams yet
{
output = (
" fixture " + 1.getfixLocation() + " has no teams yet");
textBoxOutput.Items.Add(output);
}
}
}

// In put validation
public static bool fileOpenForWriteOK(string writeFile, ref StreamWriter dataOut)
{
//open file and check for Errors
try
{
dataOut =
new StreamWriter(writeFile);
return true;
}
catch (FileNotFoundException notFound)
{
System.Windows.Forms.
MessageBox.Show("Error Opening File ( when writing data out)" +
"- File could not be found.\n" + notFound.Message);
return false;
}
catch (Exception e)
{
System.Windows.Forms.
MessageBox.Show("Error Opening File( when writing data out)" +
"- Operation failed.\n" + e.Message);
return false;
}
}
//Input Validation
public static bool fileOpenForReadOK(string readFile, ref StreamReader dataIn)
{
// open files and check for Errors
try
{
dataIn =
new StreamReader(readFile);
return true;
}
catch (FileNotFoundException notFound)
{
System.Windows.Forms.
MessageBox.Show("Error when reading data in )- File could not be found.\n" + notFound.Message);
return false;
}
catch (Exception e)
{
System.Windows.Forms.
MessageBox.Show("ERROR Opening File (when reading data in)- Operation failed.\n" + e.Message);
return false;
}
}
// input validation
public static bool notNullTextBox(TextBox txtCurrent, String userFeedback)
{
if (txtCurrent.Text == "")
{
System.Windows.Forms.
MessageBox.Show("ERROR - The input for " + userFeedback + " cannot be empty!. Please input again ... ");
txtCurrent.Focus();
return false;
}
else return true;
}
// Input Validation
public static bool validNumOfFixtures()
{
return true;
}
//input Validation
public static bool validNumber(TextBox txtBeingTested, string outputString)
{
try
{
Convert.ToInt32(txtBeingTested.Text);
return true;
}
catch (FormatException e)
{
MessageBox.Show("INVALID Input: " + e.Message + "The input for " + outputString + "is not a valid number");
txtBeingTested.Text =
"";
txtBeingTested.Focus();
return false;
}
}
}
}



Answers (2)