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,43 +12,30 @@ 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
{
conn.Open();
}
catch
{
conn.Close();
Environment.Exit(0);
}
NpgsqlDataReader dbReader = new NpgsqlCommand("SELECT * FROM Inscrit", conn).ExecuteReader();
while (dbReader.Read())
Console.Out.WriteLine("Ouverture de la connection");
conn.Open();
using var cmd = new NpgsqlCommand("SELECT id FROM INSCRIT WHERE (nom=(@p) OR mail=(@p)) AND mdp=@p2",conn)
{
t++;
i=new Inscrit(dbReader.GetString(0), dbReader.GetString(1), dbReader.GetString(2), dbReader.GetString(3), dbReader.GetString(4));
}
dbReader.Close();
return i;
Parameters =
{
new("p", id),
new("p2", mdp)
}
};
return cmd.ExecuteNonQuery().ToString();
}
/*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(connexionBDD);
Console.Out.WriteLine("Ouverture de la connection");
conn.Open();
@ -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,37 +13,25 @@ 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