so something like :
SavePerson()
- Person p = new
p. ??
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
VulpesRank #55 · 29.2K reputationPosted May 24, 2013, 3:39 AM EDT
Now in your 'create', 'edit' or 'replace' person methods, start off by making the appropriate changes to the List
SavePersons();
ICE QUEEN100 reputationPosted May 24, 2013, 3:45 AM EDT
ICE QUEEN100 reputationPosted May 24, 2013, 3:47 AM EDT
Person, u do mean user input right or are u referring to changes in the method itself?
ICE QUEEN100 reputationPosted May 24, 2013, 3:57 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 24, 2013, 4:11 AM EDT
ICE QUEEN100 reputationPosted May 24, 2013, 4:17 AM EDT
ICE QUEEN100 reputationPosted May 24, 2013, 4:24 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 24, 2013, 4:29 AM EDT
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 QUEEN100 reputationPosted May 24, 2013, 4:38 AM EDT
ICE QUEEN100 reputationPosted May 24, 2013, 4:50 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 24, 2013, 4:56 AM EDT
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 QUEEN100 reputationPosted May 24, 2013, 5:05 AM EDT
ICE QUEEN100 reputationPosted May 24, 2013, 5:07 AM EDT
ICE QUEEN100 reputationPosted May 24, 2013, 5:09 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 24, 2013, 5:41 AM EDT
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 QUEEN100 reputationPosted May 24, 2013, 5:46 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 24, 2013, 6:08 AM EDT
using System.IO;
I'm surprised you don't have that one already.
ICE QUEEN100 reputationPosted May 24, 2013, 6:23 AM EDT
ICE QUEEN100 reputationPosted May 24, 2013, 6:33 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 24, 2013, 6:41 AM EDT
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 QUEEN100 reputationPosted May 24, 2013, 6:55 AM EDT
ICE QUEEN100 reputationPosted May 24, 2013, 6:56 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 24, 2013, 7:04 AM EDT
If the code calls any methods post the code for those methods too.