97 lines
2.8 KiB
C#
97 lines
2.8 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_listPlat : ADBase
|
|
{
|
|
#region Constructeurs
|
|
public A_T_listPlat(string sChaineConnexion)
|
|
: base(sChaineConnexion)
|
|
{ }
|
|
#endregion
|
|
public int Ajouter(int ID_repa, int ID_plat)
|
|
{
|
|
CreerCommande("AjouterT_listPlat");
|
|
int res = 0;
|
|
Commande.Parameters.Add("ID_listPlat", SqlDbType.Int);
|
|
Direction("ID_listPlat", ParameterDirection.Output);
|
|
Commande.Parameters.AddWithValue("@ID_repa", ID_repa);
|
|
Commande.Parameters.AddWithValue("@ID_plat", ID_plat);
|
|
Commande.Connection.Open();
|
|
Commande.ExecuteNonQuery();
|
|
res = int.Parse(LireParametre("ID_listPlat"));
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public int Modifier(int ID_listPlat, int ID_repa, int ID_plat)
|
|
{
|
|
CreerCommande("ModifierT_listPlat");
|
|
int res = 0;
|
|
Commande.Parameters.AddWithValue("@ID_listPlat", ID_listPlat);
|
|
Commande.Parameters.AddWithValue("@ID_repa", ID_repa);
|
|
Commande.Parameters.AddWithValue("@ID_plat", ID_plat);
|
|
Commande.Connection.Open();
|
|
Commande.ExecuteNonQuery();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public List<C_T_listPlat> Lire(string Index)
|
|
{
|
|
CreerCommande("SelectionnerT_listPlat");
|
|
Commande.Parameters.AddWithValue("@Index", Index);
|
|
Commande.Connection.Open();
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
List<C_T_listPlat> res = new List<C_T_listPlat>();
|
|
while (dr.Read())
|
|
{
|
|
C_T_listPlat tmp = new C_T_listPlat();
|
|
tmp.ID_listPlat = int.Parse(dr["ID_listPlat"].ToString());
|
|
tmp.ID_repa = int.Parse(dr["ID_repa"].ToString());
|
|
tmp.ID_plat = int.Parse(dr["ID_plat"].ToString());
|
|
res.Add(tmp);
|
|
}
|
|
dr.Close();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public C_T_listPlat Lire_ID(int ID_listPlat)
|
|
{
|
|
CreerCommande("SelectionnerT_listPlat_ID");
|
|
Commande.Parameters.AddWithValue("@ID_listPlat", ID_listPlat);
|
|
Commande.Connection.Open();
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
C_T_listPlat res = new C_T_listPlat();
|
|
while (dr.Read())
|
|
{
|
|
res.ID_listPlat = int.Parse(dr["ID_listPlat"].ToString());
|
|
res.ID_repa = int.Parse(dr["ID_repa"].ToString());
|
|
res.ID_plat = int.Parse(dr["ID_plat"].ToString());
|
|
}
|
|
dr.Close();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public int Supprimer(int ID_listPlat)
|
|
{
|
|
CreerCommande("SupprimerT_listPlat");
|
|
int res = 0;
|
|
Commande.Parameters.AddWithValue("@ID_listPlat", ID_listPlat);
|
|
Commande.Connection.Open();
|
|
res = Commande.ExecuteNonQuery();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
}
|
|
}
|