finission de la supression de la banque en BDD

Link_to_npgsql
Vincent ASTOLFI 2 years ago
commit 7b4735c6a4

@ -16,5 +16,7 @@ namespace IHM
public partial class App : Application public partial class App : Application
{ {
public Manager AllInscrits { get; private set; } = new Manager(new LinqToPgSQL.PersLinqToPgSQL()); public Manager AllInscrits { get; private set; } = new Manager(new LinqToPgSQL.PersLinqToPgSQL());
//public Manager AllInscrits { get; private set; } = new Manager(new Stub());
} }
} }

@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Controls;
using System.Windows.Data;
namespace IHM.Converters
{
public class Func2WindowPartConverter : IValueConverter
{
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
Func<UserControl>? windowPartCreator = value as Func<UserControl>;
if (windowPartCreator == null)
{
return null;
}
return windowPartCreator();
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

@ -39,7 +39,7 @@ namespace IHM
{ {
MessageBox.Show($"{i.Id} + {i.Nom} + {i.Mdp} + {i.Mail} + {i.Dev}"); MessageBox.Show($"{i.Id} + {i.Nom} + {i.Prenom} + {i.Mail} + {i.Mdp}");
} }
@ -69,5 +69,6 @@ namespace IHM
testSelect(); testSelect();
/* testSuppression();*/ /* testSuppression();*/
} }
} }
} }

@ -6,6 +6,7 @@ using System.Threading.Tasks;
using Npgsql; using Npgsql;
using Model; using Model;
using System.IO; using System.IO;
using System.Diagnostics;
namespace LinqToPgSQL namespace LinqToPgSQL
{ {
@ -32,33 +33,29 @@ namespace LinqToPgSQL
List<Inscrit> ListeInscrits = new List<Inscrit>(); List<Inscrit> ListeInscrits = new List<Inscrit>();
var conn = new NpgsqlConnection(connString); var conn = new NpgsqlConnection(connString);
Console.Out.WriteLine("Ouverture de la connection"); Console.Out.WriteLine("Ouverture de la connection"); try
conn.Open(); {
conn.Open();
var AllInscrit = new NpgsqlCommand("SELECT * FROM Inscrit", conn); }
catch
{
conn.Close();
Environment.Exit(0);
}
NpgsqlDataReader dbReader = new NpgsqlCommand("SELECT * FROM Inscrit", conn).ExecuteReader();
var reader = AllInscrit.ExecuteReader(); while (dbReader.Read())
while (reader.Read())
{ {
Console.WriteLine(
string.Format(
"({0}, {1}, {2}, {3}, {4}",
reader.GetString(0),
reader.GetString(1),
reader.GetString(2),
reader.GetString(3),
reader.GetString(4)
/*reader.GetInt32(2).ToString()*/
)
);
foreach (var EltInscrit in reader)
{
ListeInscrits.Add(new(reader.GetString(0), reader.GetString(1), reader.GetString(3), reader.GetString(2), reader.GetString(4)));
}
ListeInscrits.Add(new Inscrit(dbReader.GetString(0), dbReader.GetString(1), dbReader.GetString(2), dbReader.GetString(3), dbReader.GetString(4)));
} }
reader.Close();
dbReader.Close();
return ListeInscrits; return ListeInscrits;
} }

@ -10,7 +10,7 @@ namespace Model
public class Inscrit public class Inscrit
{ {
public Inscrit(string id, string nom, string mail, string prenom, string mdp) public Inscrit(string id, string nom, string prenom, string mail, string mdp)
{ {
Id = id; Id = id;
Nom = nom; Nom = nom;

@ -12,6 +12,8 @@ namespace Model
public List<Inscrit> Inscrits = new(); public List<Inscrit> Inscrits = new();
public List<Compte> Comptes = new(); public List<Compte> Comptes = new();
// ajouter load all pour tout les inscrits // ajouter load all pour tout les inscrits
public List<Inscrit> LoadInscrit() public List<Inscrit> LoadInscrit()

Loading…
Cancel
Save