95 lines
2.7 KiB
C#
95 lines
2.7 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_typePlat : ADBase
|
|
{
|
|
#region Constructeurs
|
|
public A_T_typePlat(string sChaineConnexion)
|
|
: base(sChaineConnexion)
|
|
{ }
|
|
#endregion
|
|
public int Ajouter(string TP_nom)
|
|
{
|
|
CreerCommande("AjouterT_typePlat");
|
|
int res = 0;
|
|
Commande.Parameters.Add("ID_typePlat", SqlDbType.Int);
|
|
Direction("ID_typePlat", ParameterDirection.Output);
|
|
if(TP_nom == null) Commande.Parameters.AddWithValue("@TP_nom", Convert.DBNull);
|
|
else Commande.Parameters.AddWithValue("@TP_nom", TP_nom);
|
|
Commande.Connection.Open();
|
|
Commande.ExecuteNonQuery();
|
|
res = int.Parse(LireParametre("ID_typePlat"));
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public int Modifier(int ID_typePlat, string TP_nom)
|
|
{
|
|
CreerCommande("ModifierT_typePlat");
|
|
int res = 0;
|
|
Commande.Parameters.AddWithValue("@ID_typePlat", ID_typePlat);
|
|
if(TP_nom == null) Commande.Parameters.AddWithValue("@TP_nom", Convert.DBNull);
|
|
else Commande.Parameters.AddWithValue("@TP_nom", TP_nom);
|
|
Commande.Connection.Open();
|
|
Commande.ExecuteNonQuery();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public List<C_T_typePlat> Lire(string Index)
|
|
{
|
|
CreerCommande("SelectionnerT_typePlat");
|
|
Commande.Parameters.AddWithValue("@Index", Index);
|
|
Commande.Connection.Open();
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
List<C_T_typePlat> res = new List<C_T_typePlat>();
|
|
while (dr.Read())
|
|
{
|
|
C_T_typePlat tmp = new C_T_typePlat();
|
|
tmp.ID_typePlat = int.Parse(dr["ID_typePlat"].ToString());
|
|
tmp.TP_nom = dr["TP_nom"].ToString();
|
|
res.Add(tmp);
|
|
}
|
|
dr.Close();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public C_T_typePlat Lire_ID(int ID_typePlat)
|
|
{
|
|
CreerCommande("SelectionnerT_typePlat_ID");
|
|
Commande.Parameters.AddWithValue("@ID_typePlat", ID_typePlat);
|
|
Commande.Connection.Open();
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
C_T_typePlat res = new C_T_typePlat();
|
|
while (dr.Read())
|
|
{
|
|
res.ID_typePlat = int.Parse(dr["ID_typePlat"].ToString());
|
|
res.TP_nom = dr["TP_nom"].ToString();
|
|
}
|
|
dr.Close();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
public int Supprimer(int ID_typePlat)
|
|
{
|
|
CreerCommande("SupprimerT_typePlat");
|
|
int res = 0;
|
|
Commande.Parameters.AddWithValue("@ID_typePlat", ID_typePlat);
|
|
Commande.Connection.Open();
|
|
res = Commande.ExecuteNonQuery();
|
|
Commande.Connection.Close();
|
|
return res;
|
|
}
|
|
}
|
|
}
|