122 lines
4.4 KiB
C#
122 lines
4.4 KiB
C#
#region Ressources extérieures
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Data.SqlTypes;
|
|
using ProjetTheAlone.Classes;
|
|
#endregion
|
|
|
|
namespace ProjetTheAlone.Acces
|
|
{
|
|
/// <summary>
|
|
/// Couche d'accès aux données (Data Access Layer)
|
|
/// </summary>
|
|
public class A_T_listParticipant : ADBase
|
|
{
|
|
#region Constructeurs
|
|
public A_T_listParticipant(string sChaineConnexion)
|
|
: base(sChaineConnexion)
|
|
{ }
|
|
#endregion
|
|
public int Ajouter(int? ID_equipe, int? ID_benificiaire)
|
|
{
|
|
CreerCommande("AjouterT_listParticipant");
|
|
int res = 0;
|
|
Commande.Parameters.Add("ID_LP", SqlDbType.Int);
|
|
Direction("ID_LP", ParameterDirection.Output);
|
|
if(ID_equipe == null) Commande.Parameters.AddWithValue("@ID_equipe", Convert.DBNull);
|
|
else Commande.Parameters.AddWithValue("@ID_equipe", ID_equipe);
|
|
if(ID_benificiaire == null) Commande.Parameters.AddWithValue("@ID_benificiaire", Convert.DBNull);
|
|
else Commande.Parameters.AddWithValue("@ID_benificiaire", ID_benificiaire);
|
|
Commande.Connection.Open();
|
|
Commande.ExecuteNonQuery();
|
|
res = int.Parse(LireParametre("ID_LP"));
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public int Modifier(int ID_LP, int? ID_equipe, int? ID_benificiaire)
|
|
{
|
|
CreerCommande("ModifierT_listParticipant");
|
|
int res = 0;
|
|
Commande.Parameters.AddWithValue("@ID_LP", ID_LP);
|
|
if(ID_equipe == null) Commande.Parameters.AddWithValue("@ID_equipe", Convert.DBNull);
|
|
else Commande.Parameters.AddWithValue("@ID_equipe", ID_equipe);
|
|
if(ID_benificiaire == null) Commande.Parameters.AddWithValue("@ID_benificiaire", Convert.DBNull);
|
|
else Commande.Parameters.AddWithValue("@ID_benificiaire", ID_benificiaire);
|
|
Commande.Connection.Open();
|
|
Commande.ExecuteNonQuery();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public List<C_T_listParticipant> Lire(string Index)
|
|
{
|
|
CreerCommande("SelectionnerT_listParticipant");
|
|
Commande.Parameters.AddWithValue("@Index", Index);
|
|
Commande.Connection.Open();
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
List<C_T_listParticipant> res = new List<C_T_listParticipant>();
|
|
while (dr.Read())
|
|
{
|
|
C_T_listParticipant tmp = new C_T_listParticipant();
|
|
tmp.ID_LP = int.Parse(dr["ID_LP"].ToString());
|
|
if(dr["ID_equipe"] != DBNull.Value) tmp.ID_equipe = int.Parse(dr["ID_equipe"].ToString());
|
|
if(dr["ID_benificiaire"] != DBNull.Value) tmp.ID_benificiaire = int.Parse(dr["ID_benificiaire"].ToString());
|
|
res.Add(tmp);
|
|
}
|
|
dr.Close();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public List<C_T_beneficiaire> Lire(int ID_Equipe)
|
|
{
|
|
CreerCommande("ListParticipantEquipe");
|
|
Commande.Parameters.AddWithValue("@ID_equipe", ID_Equipe);
|
|
Commande.Connection.Open();
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
List<C_T_beneficiaire> res = new List<C_T_beneficiaire>();
|
|
while (dr.Read())
|
|
{
|
|
C_T_beneficiaire tmp = new C_T_beneficiaire();
|
|
tmp.ID_beneficiaire = int.Parse(dr["ID_beneficiaire"].ToString());
|
|
tmp.B_nom = dr["B_nom"].ToString();
|
|
tmp.B_prenom = dr["B_prenom"].ToString();
|
|
if (dr["B_anniversaire"] != DBNull.Value) tmp.B_anniversaire = DateTime.Parse(dr["B_anniversaire"].ToString());
|
|
if (dr["B_img"] != DBNull.Value) tmp.B_img = Outil.toNullableByteArray.Convert((byte[])dr["B_img"]);
|
|
res.Add(tmp);
|
|
}
|
|
dr.Close();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public C_T_listParticipant Lire_ID(int ID_LP)
|
|
{
|
|
CreerCommande("SelectionnerT_listParticipant_ID");
|
|
Commande.Parameters.AddWithValue("@ID_LP", ID_LP);
|
|
Commande.Connection.Open();
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
C_T_listParticipant res = new C_T_listParticipant();
|
|
while (dr.Read())
|
|
{
|
|
res.ID_LP = int.Parse(dr["ID_LP"].ToString());
|
|
if(dr["ID_equipe"] != DBNull.Value) res.ID_equipe = int.Parse(dr["ID_equipe"].ToString());
|
|
if(dr["ID_benificiaire"] != DBNull.Value) res.ID_benificiaire = int.Parse(dr["ID_benificiaire"].ToString());
|
|
}
|
|
dr.Close();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public int Supprimer(int ID_LP)
|
|
{
|
|
CreerCommande("SupprimerT_listParticipant");
|
|
int res = 0;
|
|
Commande.Parameters.AddWithValue("@ID_LP", ID_LP);
|
|
Commande.Connection.Open();
|
|
res = Commande.ExecuteNonQuery();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
}
|
|
}
|