/// <summary> /// Function to add a new Director to the Director Array. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void BTN_addDirector_Click(object sender, EventArgs e) { bool valid = true; //Check Director LastName if (TXTBX_directorLastName.TextLength == 0) { LBL_DirectorLastName.ForeColor = Color.Red; MessageBox.Show("Le Nom du Directeur n'est pas entré."); valid = false; } else { LBL_DirectorLastName.ForeColor = Color.White; } //Check Director Name if (TXTBX_directorName.TextLength == 0) { LBL_DirectorName.ForeColor = Color.Red; MessageBox.Show("Le Prenom du Directeur n'est pas entré."); valid = false; } else { LBL_DirectorName.ForeColor = Color.White; } //Check Salary if (NUM_DirectorSalary.Value < 0) { LBL_DirectorSalary.ForeColor = Color.Red; MessageBox.Show("Le Revenu du Directeur ne peut pas etre négatif."); valid = false; } else { LBL_BankAdress.ForeColor = Color.White; } //Create new Director in Dictionnary if all info is valid. if (valid) { //Add the New Director to the DataSource Director newDirector = new Director(TXTBX_directorName.Text, TXTBX_directorLastName.Text, NUM_DirectorSalary.Value); Program.DirectorData.Add(newDirector.DIRECTORID, newDirector); //Empty all the fields TXTBX_directorName.Clear(); TXTBX_directorLastName.Clear(); NUM_DirectorSalary.Value = 0; UpdateDirectorTab(); BTN_ExportData.Enabled = true; } }
/// <summary> /// Function to import all the Director data from the XML File /// </summary> private static void importDirectorData() { DataSet DirectorDB = new DataSet(); DirectorDB.ReadXml("myDirectors.xml"); if (DirectorDB.Tables.Count != 0) { foreach (DataRow row in DirectorDB.Tables["Director Database"].Rows) { Director tempDirector = new Director(row["DirectorID"].ToString(), row["Prenom"].ToString(), row["Nom"].ToString(), decimal.Parse(row["Salaire"].ToString()), row["Bank"].ToString()); Program.DirectorData.Add(tempDirector.DIRECTORID, tempDirector); } } }