so something like :
SavePerson()
- Person p = new
p. ??
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
VulpesPosted May 24, 2013, 11:04 AM
If the code calls any methods post the code for those methods too.
ICE QUEENPosted May 24, 2013, 10:56 AM
ICE QUEENPosted May 24, 2013, 10:55 AM
VulpesPosted May 24, 2013, 10:41 AM
So the GetAllSalesman method should be defined and coded like this:
private List
{
List
foreach(Salesman s in salesmanList)
{
names.Add(s.LastName + " " + s.FirstName);
}
return names;
}
If this method is or could be accessed from a different form, then replace 'private' with internal static.
If 'NamesListed' is the class name of the form that it's in, you can call the method from the main form like this:
private void aLLToolStripMenuItem_Click(object sender, EventArgs e)
{
List
// do something with names
}
ICE QUEENPosted May 24, 2013, 10:33 AM
ICE QUEENPosted May 24, 2013, 10:23 AM
VulpesPosted May 24, 2013, 10:08 AM
using System.IO;
I'm surprised you don't have that one already.
ICE QUEENPosted May 24, 2013, 9:46 AM
VulpesPosted May 24, 2013, 9:41 AM
There should be a semi-colon at the end of this line:
string line;
and the brackets in this line should be as follows:
if(File.Exists(dataPath)) LoadSalesman();
ICE QUEENPosted May 24, 2013, 9:09 AM
ICE QUEENPosted May 24, 2013, 9:07 AM
ICE QUEENPosted May 24, 2013, 9:05 AM
VulpesPosted May 24, 2013, 8:56 AM
All you have to remember is to declare them 'internal static' if they're going to be accessed from another form. You then just precede them with the name of the form, when you want to call them from some other form.
What errors are you getting?
ICE QUEENPosted May 24, 2013, 8:50 AM
ICE QUEENPosted May 24, 2013, 8:38 AM
VulpesPosted May 24, 2013, 8:29 AM
Similarly, if you need to access any methods on the main form make them 'internal static' rather than 'private'. They can then be called like this:
Form1.GetPersonNames();
ICE QUEENPosted May 24, 2013, 8:24 AM
ICE QUEENPosted May 24, 2013, 8:17 AM
VulpesPosted May 24, 2013, 8:11 AM
ICE QUEENPosted May 24, 2013, 7:57 AM
ICE QUEENPosted May 24, 2013, 7:47 AM
Person, u do mean user input right or are u referring to changes in the method itself?
ICE QUEENPosted May 24, 2013, 7:45 AM
VulpesPosted May 24, 2013, 7:39 AM
Now in your 'create', 'edit' or 'replace' person methods, start off by making the appropriate changes to the List
SavePersons();