modification loadInsrit
continuous-integration/drone/push Build is passing Details

connexion
Lucas EVARD 2 years ago
parent 8ed4a57ef1
commit 98c88e43bf

@ -32,7 +32,7 @@ namespace IHM
public void testSelect() public void testSelect()
{ {
MessageBox.Show($"{Manager.SelectedInscrits.Id} + {Manager.SelectedInscrits.Nom} + {Manager.SelectedInscrits.Prenom} + {Manager.SelectedInscrits.Mail} + {Manager.SelectedInscrits.Mdp}"); MessageBox.Show($"{Manager.SelectedInscrits}");
} }
public void testSuppression() public void testSuppression()

@ -12,38 +12,25 @@ namespace LinqToPgSQL
{ {
public class PersLinqToPgSQL : IPersistanceManager public class PersLinqToPgSQL : IPersistanceManager
{ {
private static string Host = "90.114.135.116"; string connexionBDD = String.Format("Server=90.114.135.116; Username=postgres; Database=conseco; Port=5432; Password=lulu; SSLMode=Prefer");
private static string User = "postgres"; public string LoadInscrit(string id, string mdp)
private static string DBname = "conseco";
private static string Password = "lulu";
private static string Port = "5432";
string connexionBDD = String.Format("Server={0};Username{1};Database{2};Port{3};Password{4};SSLMode=Prefer",Host,User,DBname,Port,Password);
public Inscrit LoadInscrit()
{ {
int t = 0;
Inscrit i=null;
var conn = new NpgsqlConnection(connexionBDD); var conn = new NpgsqlConnection(connexionBDD);
Console.Out.WriteLine("Ouverture de la connection"); try Console.Out.WriteLine("Ouverture de la connection");
{
conn.Open(); conn.Open();
} using var cmd = new NpgsqlCommand("SELECT id FROM INSCRIT WHERE (nom=(@p) OR mail=(@p)) AND mdp=@p2",conn)
catch
{ {
conn.Close(); Parameters =
Environment.Exit(0);
}
NpgsqlDataReader dbReader = new NpgsqlCommand("SELECT * FROM Inscrit", conn).ExecuteReader();
while (dbReader.Read())
{ {
t++; new("p", id),
i=new Inscrit(dbReader.GetString(0), dbReader.GetString(1), dbReader.GetString(2), dbReader.GetString(3), dbReader.GetString(4)); new("p2", mdp)
} }
dbReader.Close(); };
return i; return cmd.ExecuteNonQuery().ToString();
} }
/*Revoir la BDD, probleme de clé étrangère de devise*/ /*Revoir la BDD, probleme de clé étrangère de devise*/
public async void SupprimerInscritBdd(Inscrit i) public async void SupprimerInscritBdd(Inscrit i)
{ {
@ -65,5 +52,6 @@ namespace LinqToPgSQL
await command.ExecuteNonQueryAsync(); await command.ExecuteNonQueryAsync();
} }
} }
} }
} }

@ -8,7 +8,7 @@ namespace Model
{ {
public interface IPersistanceManager public interface IPersistanceManager
{ {
Inscrit LoadInscrit(); string LoadInscrit(string id,string mdp);
void SupprimerInscritBdd(Inscrit inscrit); void SupprimerInscritBdd(Inscrit inscrit);
} }
} }

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
using System.ComponentModel; using System.ComponentModel;
using System.Linq; using System.Linq;
using Npgsql;
using System.Text; using System.Text;
using System.Threading.Tasks; using System.Threading.Tasks;
@ -12,38 +13,26 @@ namespace Model
{ {
public event PropertyChangedEventHandler? PropertyChanged; public event PropertyChangedEventHandler? PropertyChanged;
public IPersistanceManager Pers { get; private set; } public IPersistanceManager Pers { get; private set; }
public Inscrit SelectedInscrits public string SelectedInscrits;
{
get => selectedInscrits;
set
{
if (selectedInscrits != value)
{
selectedInscrits = value;
OnPropertyChanged(nameof(SelectedInscrits));
}
}
}
private Inscrit selectedInscrits;
void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName)); void OnPropertyChanged(string propertyName) => PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
public Manager(IPersistanceManager persistance) public Manager(IPersistanceManager persistance)
{ {
SelectedInscrits = persistance.LoadInscrit();
Pers = persistance; Pers = persistance;
} }
public void supprimerInscritBdd(Inscrit i) public void SupprimerInscritBdd(Inscrit i)
{ {
Pers.SupprimerInscritBdd(i); Pers.SupprimerInscritBdd(i);
} }
/* public void supprimerInscritBdd(Inscrit i) public void LoadInscrit(string id, string mdp)
{ {
SelectedInscrits = Pers.LoadInscrit(id, mdp);
}
}*/
} }

@ -6,4 +6,8 @@
<Nullable>enable</Nullable> <Nullable>enable</Nullable>
</PropertyGroup> </PropertyGroup>
<ItemGroup>
<PackageReference Include="Npgsql" Version="6.0.7" />
</ItemGroup>
</Project> </Project>

Loading…
Cancel
Save