Hi People, im new here.
I have a app to register CandidatesForJob.. i have a datagridview and i load data from xml file. I Have a object with data. But my boss sad me to associate each row to my object. Who can help me?
That button , open my AddCandidateForm.
private void newToolStripMenuItem_Click(object sender, EventArgs e)
{
AddCandidate MyForm = new AddCandidate();
if (MyForm.ShowDialog() == System.Windows.Forms.DialogResult.OK) {
CandidatesForJob _c = MyForm.resultado;
XElement xmlNode = new XElement("Candidate",
new XElement("FullName", _c.FullName ),
new XElement("YearsOfExperience", _c.YearsOfExperience ),
new XElement("Job", _c.Job ),
new XElement("Certification", _c.Certification ),
new XElement("Email", _c.Email ));
XElement xmlFile;
try
{
xmlFile = XElement.Load("diogomonteiro.xml");
xmlFile.Add(xmlNode);
}
catch (XmlException)
{
xmlFile = new XElement("CandidatesForJob", xmlNode);
}
xmlFile.Save("diogomonteiro.xml");
And my addButton on AddCandidate form have that code:
private void btnAddList_Click(object sender, EventArgs e)
{
_c = new CandidatesForJob();
_c.FullName = txtFullName.Text;
_c.YearsOfExperience = txtYearsExperience.Text;
_c.Job = txtPreviousJob.Text;
_c.Certification = txtCertification.Text;
_c.Email = txtEmail.Text;
if (!File.Exists("diogomonteiro.xml"))
{
using (File.Create("diogomonteiro.xml"))
{ }
}
if (String.IsNullOrEmpty(txtFullName.Text))
{
MessageBox.Show("Enter your Full Name please.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (String.IsNullOrEmpty(txtYearsExperience.Text))
{
MessageBox.Show("Enter a number in Years Of Experience please.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (String.IsNullOrEmpty(txtPreviousJob.Text))
{
MessageBox.Show("Enter your previous job please.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (String.IsNullOrEmpty(txtCertification.Text))
{
MessageBox.Show("Enter your certification please.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
if (String.IsNullOrEmpty(txtEmail.Text))
{
MessageBox.Show("Enter your email please.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning);
return;
}
this.DialogResult = System.Windows.Forms.DialogResult.OK;
this.Close();
}
Sorry my english :s