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()
{
MessageBox.Show($"{Manager.SelectedInscrits.Id} + {Manager.SelectedInscrits.Nom} + {Manager.SelectedInscrits.Prenom} + {Manager.SelectedInscrits.Mail} + {Manager.SelectedInscrits.Mdp}");
MessageBox.Show($"{Manager.SelectedInscrits}");
}
public void testSuppression()

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

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

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

Loading…
Cancel
Save