107 lines
3.6 KiB
C#
107 lines
3.6 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_equipe : ADBase
|
||
|
{
|
||
|
#region Constructeurs
|
||
|
public A_T_equipe(string sChaineConnexion)
|
||
|
: base(sChaineConnexion)
|
||
|
{ }
|
||
|
#endregion
|
||
|
public int Ajouter(string E_nom, string E_point, int? ID_evenement)
|
||
|
{
|
||
|
CreerCommande("AjouterT_equipe");
|
||
|
int res = 0;
|
||
|
Commande.Parameters.Add("ID_equipe", SqlDbType.Int);
|
||
|
Direction("ID_equipe", ParameterDirection.Output);
|
||
|
if(E_nom == null) Commande.Parameters.AddWithValue("@E_nom", Convert.DBNull);
|
||
|
else Commande.Parameters.AddWithValue("@E_nom", E_nom);
|
||
|
if(E_point == null) Commande.Parameters.AddWithValue("@E_point", Convert.DBNull);
|
||
|
else Commande.Parameters.AddWithValue("@E_point", E_point);
|
||
|
if(ID_evenement == null) Commande.Parameters.AddWithValue("@ID_evenement", Convert.DBNull);
|
||
|
else Commande.Parameters.AddWithValue("@ID_evenement", ID_evenement);
|
||
|
Commande.Connection.Open();
|
||
|
Commande.ExecuteNonQuery();
|
||
|
res = int.Parse(LireParametre("ID_equipe"));
|
||
|
Commande.Connection.Close();
|
||
|
return res;
|
||
|
}
|
||
|
public int Modifier(int ID_equipe, string E_nom, string E_point, int? ID_evenement)
|
||
|
{
|
||
|
CreerCommande("ModifierT_equipe");
|
||
|
int res = 0;
|
||
|
Commande.Parameters.AddWithValue("@ID_equipe", ID_equipe);
|
||
|
if(E_nom == null) Commande.Parameters.AddWithValue("@E_nom", Convert.DBNull);
|
||
|
else Commande.Parameters.AddWithValue("@E_nom", E_nom);
|
||
|
if(E_point == null) Commande.Parameters.AddWithValue("@E_point", Convert.DBNull);
|
||
|
else Commande.Parameters.AddWithValue("@E_point", E_point);
|
||
|
if(ID_evenement == null) Commande.Parameters.AddWithValue("@ID_evenement", Convert.DBNull);
|
||
|
else Commande.Parameters.AddWithValue("@ID_evenement", ID_evenement);
|
||
|
Commande.Connection.Open();
|
||
|
Commande.ExecuteNonQuery();
|
||
|
Commande.Connection.Close();
|
||
|
return res;
|
||
|
}
|
||
|
public List<C_T_equipe> Lire(string Index)
|
||
|
{
|
||
|
CreerCommande("SelectionnerT_equipe");
|
||
|
Commande.Parameters.AddWithValue("@Index", Index);
|
||
|
Commande.Connection.Open();
|
||
|
SqlDataReader dr = Commande.ExecuteReader();
|
||
|
List<C_T_equipe> res = new List<C_T_equipe>();
|
||
|
while (dr.Read())
|
||
|
{
|
||
|
C_T_equipe tmp = new C_T_equipe();
|
||
|
tmp.ID_equipe = int.Parse(dr["ID_equipe"].ToString());
|
||
|
tmp.E_nom = dr["E_nom"].ToString();
|
||
|
tmp.E_point = dr["E_point"].ToString();
|
||
|
if(dr["ID_evenement"] != DBNull.Value) tmp.ID_evenement = int.Parse(dr["ID_evenement"].ToString());
|
||
|
res.Add(tmp);
|
||
|
}
|
||
|
dr.Close();
|
||
|
Commande.Connection.Close();
|
||
|
return res;
|
||
|
}
|
||
|
public C_T_equipe Lire_ID(int ID_equipe)
|
||
|
{
|
||
|
CreerCommande("SelectionnerT_equipe_ID");
|
||
|
Commande.Parameters.AddWithValue("@ID_equipe", ID_equipe);
|
||
|
Commande.Connection.Open();
|
||
|
SqlDataReader dr = Commande.ExecuteReader();
|
||
|
C_T_equipe res = new C_T_equipe();
|
||
|
while (dr.Read())
|
||
|
{
|
||
|
res.ID_equipe = int.Parse(dr["ID_equipe"].ToString());
|
||
|
res.E_nom = dr["E_nom"].ToString();
|
||
|
res.E_point = dr["E_point"].ToString();
|
||
|
if(dr["ID_evenement"] != DBNull.Value) res.ID_evenement = int.Parse(dr["ID_evenement"].ToString());
|
||
|
}
|
||
|
dr.Close();
|
||
|
Commande.Connection.Close();
|
||
|
return res;
|
||
|
}
|
||
|
public int Supprimer(int ID_equipe)
|
||
|
{
|
||
|
CreerCommande("SupprimerT_equipe");
|
||
|
int res = 0;
|
||
|
Commande.Parameters.AddWithValue("@ID_equipe", ID_equipe);
|
||
|
Commande.Connection.Open();
|
||
|
res = Commande.ExecuteNonQuery();
|
||
|
Commande.Connection.Close();
|
||
|
return res;
|
||
|
}
|
||
|
}
|
||
|
}
|