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 partial class MainWindow : Window
{ {
public Manager ListedesInscrits => ((App)Application.Current).AllInscrits; public Manager ListedesInscrits => ((App)Application.Current).AllInscrits;
public MainWindow() public MainWindow()
{ {
InitializeComponent(); InitializeComponent();
@ -32,27 +33,35 @@ namespace IHM
} }
public void test() public void testSelect()
{ {
foreach (Inscrit i in ListedesInscrits.ListedesInscrits) 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( Console.WriteLine(
string.Format( string.Format(
"({0}, {1}, {2}, {3}, {4})", "({0}, {1}, {2}, {3}, {4}",
reader.GetString(0), reader.GetString(0),
reader.GetString(1), reader.GetString(1),
reader.GetString(2), reader.GetString(2),
reader.GetString(3), reader.GetString(3),
reader.GetString(4) reader.GetString(4)
/*reader.GetString(5)*/
/*reader.GetInt32(2).ToString()*/ /*reader.GetInt32(2).ToString()*/
) )
); );
foreach (var EltInscrit in reader) 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(); reader.Close();
return ListeInscrits;
}
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();
}
} }
} }
} }

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

@ -17,9 +17,9 @@ namespace Model
Mail = mail; Mail = mail;
Prenom = prenom; Prenom = prenom;
Mdp = mdp; Mdp = mdp;
} }
public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal) public Inscrit(string id, string nom, string mail, string prenom, string mdp, double soldeTotal)
@ -50,6 +50,8 @@ namespace Model
public Devises Dev { get; private set; } public Devises Dev { get; private set; }
public List<Banque> LesBanques { get; private set; } = new List<Banque>(); public List<Banque> LesBanques { get; private set; } = new List<Banque>();
public void ajouterBanque(Banque banque) public void ajouterBanque(Banque banque)
{ {
LesBanques.Add(banque); LesBanques.Add(banque);

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

Loading…
Cancel
Save