private void btnEffacer_Click(object sender, RoutedEventArgs e) { if (grilleDonnees.SelectedIndex >= 0) { Personne_Administration aEffacer = grilleDonnees.SelectedItem as Personne_Administration; ocAdministration.Remove(aEffacer); } }
private void btnValidation_Click(object sender, RoutedEventArgs e) { try { aAjouter = new Personne_Administration(txtBoxNom.Text, txtBoxPrenom.Text, txtBoxSexe.Text, txtBoxAdresse.Text, txtBoxVille.Text, Convert.ToDateTime(txtBoxNaissance.Text), txtBoxTel.Text, Convert.ToDateTime(txtBoxEntree.Text), Convert.ToDouble(txtBoxSalaire.Text), txtBoxBancaire.Text); MessageBox.Show("Ajout Reussi"); this.DialogResult = true; } catch { MessageBox.Show("Echec de l'ajout"); } }
bool chargerListeAdministration(string nom_club) { Excel.Application appExcel = null; Excel._Workbook workBook = null; Excel._Worksheet workSheet = null; bool chargementReussi = false; int nbAdministration = 0; Personne_Administration personneAdd; string nom_membre; string prenom_membre; string sexe_membre; string adresse_membre; string ville_membre; DateTime naissance_membre; string numero_telephone; DateTime date_Entree; double salaire; string coordoneesBancaire; try { appExcel = new Excel.Application(); appExcel.Visible = false; //Get a new workbook. workBook = (Excel._Workbook)(appExcel.Workbooks.Open(Environment.CurrentDirectory.ToString() + "/" + nom_club + "/FichierAdministration" + nom_club + ".xlsx")); workSheet = (Excel._Worksheet)workBook.ActiveSheet; nbAdministration = Convert.ToInt32(Convert.ToString(workSheet.Cells[1, 1].Value)); if (nbAdministration != 0) { for (int i = 0; i < nbAdministration; i++) { nom_membre = Convert.ToString(workSheet.Cells[i + 2, 1].Value); prenom_membre = Convert.ToString(workSheet.Cells[i + 2, 2].Value); sexe_membre = Convert.ToString(workSheet.Cells[i + 2, 3].Value); adresse_membre = Convert.ToString(workSheet.Cells[i + 2, 4].Value); ville_membre = Convert.ToString(workSheet.Cells[i + 2, 5].Value); naissance_membre = Convert.ToDateTime(workSheet.Cells[i + 2, 6].Value); numero_telephone = "0" + Convert.ToString(workSheet.Cells[i + 2, 7].Value); date_Entree = Convert.ToDateTime(workSheet.Cells[i + 2, 8].Value); salaire = Convert.ToDouble(workSheet.Cells[i + 2, 9].Value); coordoneesBancaire = Convert.ToString((workSheet.Cells[i + 2, 10].Value)); personneAdd = new Personne_Administration(nom_membre, prenom_membre, sexe_membre, adresse_membre, ville_membre, naissance_membre, numero_telephone, date_Entree, salaire, coordoneesBancaire); this.liste_administration.Add(personneAdd); } } chargementReussi = true; } catch { chargementReussi = false; msgAReturn = "Echec chargement Administration " + nom_club; } System.Runtime.InteropServices.Marshal.ReleaseComObject(workSheet); workBook.Close(true); System.Runtime.InteropServices.Marshal.ReleaseComObject(workBook); appExcel.Quit(); System.Runtime.InteropServices.Marshal.ReleaseComObject(appExcel); return(chargementReussi); }