ajout fonction de suppression d'identifiant dans la bdd (en attente de modification des tables)
continuous-integration/drone/push Build is passing Details

connexion
Nicolas MAYE 2 years ago
parent 47e8c4dcf9
commit 58e1f540a3

@ -23,6 +23,7 @@ namespace IHM
public partial class MainWindow : Window
{
public Manager ListedesInscrits => ((App)Application.Current).AllInscrits;
public MainWindow()
{
InitializeComponent();
@ -32,27 +33,35 @@ namespace IHM
}
public void test()
public void testSelect()
{
foreach (Inscrit i in ListedesInscrits.ListedesInscrits)
{
if(i.Nom == "YOUVOI")
{
MessageBox.Show($"{i.Id} + {i.Nom} + {i.Mdp} + {i.Mail} + {i.Dev}");
}
MessageBox.Show($"{i.Id} + {i.Nom} + {i.Mdp} + {i.Mail} + {i.Dev}");
}
}
private void test_Click(object sender, RoutedEventArgs e)
public void testSuppression()
{
foreach (Inscrit i in ListedesInscrits.ListedesInscrits)
{
if (i.Nom == "YOUVOI")
{
ListedesInscrits.supprimerInscritBdd(i);
}
test();
}
}
private void test_Click(object sender, RoutedEventArgs e)
{
testSelect();
}
}
}

@ -42,28 +42,55 @@ namespace LinqToPgSQL
{
Console.WriteLine(
string.Format(
"({0}, {1}, {2}, {3}, {4})",
"({0}, {1}, {2}, {3}, {4}",
reader.GetString(0),
reader.GetString(1),
reader.GetString(2),
reader.GetString(3),
reader.GetString(4)
/*reader.GetString(5)*/
/*reader.GetInt32(2).ToString()*/
)
);
foreach (var EltInscrit in reader)
{
ListeInscrits.Add(new(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetString(4)));
ListeInscrits.Add(new(reader.GetString(0), reader.GetString(1), reader.GetString(3), reader.GetString(2), reader.GetString(4)));
}
}
reader.Close();
return ListeInscrits;
}
/*Revoir la BDD, probleme de clé étrangère de devise*/
public async void SupprimerInscritBdd(Inscrit i)
{
/*List<Inscrit> ListeInscrits = new List<Inscrit>(LoadInscrit());*/
var conn = new NpgsqlConnection(connString);
Console.Out.WriteLine("Ouverture de la connection");
conn.Open();
string requete = $"DELETE FROM INSCRIT WHERE id=(@p)";
string requeteFKey = $"DELETE FROM DEVISE WHERE id=(@p2)";
using (var command1 = new NpgsqlCommand(requeteFKey, conn))
{
command1.Parameters.AddWithValue("p2", i.Dev);
await command1.ExecuteNonQueryAsync();
}
using (var command = new NpgsqlCommand(requete, conn))
{
command.Parameters.AddWithValue("p", i.Id);
await command.ExecuteNonQueryAsync();
}
return ListeInscrits;
}
}
}

@ -9,5 +9,6 @@ namespace Model
public interface IPersistanceManager
{
IEnumerable<Inscrit> LoadInscrit();
void SupprimerInscritBdd(Inscrit inscrit);
}
}

@ -50,6 +50,8 @@ namespace Model
public Devises Dev { get; private set; }
public List<Banque> LesBanques { get; private set; } = new List<Banque>();
public void ajouterBanque(Banque banque)
{
LesBanques.Add(banque);

@ -52,6 +52,17 @@ namespace Model
Pers = persistance;
}
public void supprimerInscritBdd(Inscrit i)
{
Pers.SupprimerInscritBdd(i);
}
/* public void supprimerInscritBdd(Inscrit i)
{
}*/
}

Loading…
Cancel
Save