private Personne TrouverPlusProche(Personne debut, List <Personne> clients, List <int> dejaVisite) { Personne proche = null; double minDist = double.MaxValue; foreach (Personne cli in clients) { if (!dejaVisite.Contains(cli.Id)) { double dist = Helper.Distance(debut, cli); if (dist < minDist) { minDist = dist; proche = cli; } } } return(proche); }
//Bouton Mettre à jour private void butMaj_Click(object sender, EventArgs e) { //Init d'un objet Peronne() Personne nouvelle = new Personne(); // récupération des informations dans les zones en bas à droite pour envoyer la requête de mise à jour dans la bdd // puis maj de la liste visuel pour l'utilisateur if (textBox1.Text != "") { nouvelle.Nom = textBox1.Text; nouvelle.Date_naissance = dateTimePicker1.Value; test.Update(nouvelle, editer); remplirListe(); } else { MessageBox.Show("rentrer un nom ! "); textBox1.Focus(); } }
private void btnInscrire_Click(object sender, EventArgs e) { if (txtNom.Text != "" && txtPrenom.Text != "" && txtCourriel.Text != "" && cmbCategorie.SelectedIndex != -1 && cmbCegep.SelectedIndex != -1) { foreach (Personne personne in m_listPersonnes) { if (personne.Nom == txtNom.Text && personne.Prenom == txtPrenom.Text) { return; } } sql insertionPersonneSQL = new sql("INSERT INTO [dbo].[Personne] VALUES ('" + txtPrenom.Text + "', '" + txtNom.Text + "', '" + txtCourriel.Text + "', " + "123123" + ")", "A18_Sim_Eq07"); insertionPersonneSQL.executeNonQuery(); //sql insertioInscriptionnSQL = new sql("INSERT INTO [dbo].[Inscription] VALUES ()", "A18_Sim_Eq07"); //insertioInscriptionnSQL.executeNonQuery(); // Ajouter à la liste locale m_objPersonne = new Personne(txtNom.Text, txtPrenom.Text, txtCourriel.Text); if (cmbGroupesExistants.SelectedIndex != -1) { foreach (Participant participant in m_listParticipant) { if (participant.Nom == txtGroupe.Text) { participant.Ajouter(m_objPersonne); } } } else { m_objParticipant = new Participant(txtGroupe.Text); m_listParticipant.Add(m_objParticipant); m_objParticipant.Ajouter(m_objPersonne); } MessageBox.Show("Vous avez bien étés enrigistrés"); } }
/// <summary> /// Ajoute une nouvelle personne à la liste /// </summary> public void Ajouter(Personne pPersonne) { m_colPersonnes.Add(pPersonne); }
private double distTrajet(Personne comercial, Personne c) { pdist = pdist + Helper.dist(comercial, c); return(pdist); }