2019-01-18 13:08:55 +01:00
|
|
|
#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_repa : ADBase
|
|
|
|
{
|
|
|
|
#region Constructeurs
|
|
|
|
public A_T_repa(string sChaineConnexion)
|
|
|
|
: base(sChaineConnexion)
|
|
|
|
{ }
|
|
|
|
#endregion
|
2019-01-19 22:29:09 +01:00
|
|
|
public int Ajouter(int? ID_listPlat, int? ID_typeRepa, DateTime R_Date)
|
2019-01-18 13:08:55 +01:00
|
|
|
{
|
|
|
|
CreerCommande("AjouterT_repa");
|
|
|
|
int res = 0;
|
|
|
|
Commande.Parameters.Add("ID_repa", SqlDbType.Int);
|
|
|
|
Direction("ID_repa", ParameterDirection.Output);
|
|
|
|
if(ID_listPlat == null) Commande.Parameters.AddWithValue("@ID_listPlat", Convert.DBNull);
|
|
|
|
else Commande.Parameters.AddWithValue("@ID_listPlat", ID_listPlat);
|
|
|
|
if(ID_typeRepa == null) Commande.Parameters.AddWithValue("@ID_typeRepa", Convert.DBNull);
|
|
|
|
else Commande.Parameters.AddWithValue("@ID_typeRepa", ID_typeRepa);
|
2019-01-19 22:29:09 +01:00
|
|
|
Commande.Parameters.AddWithValue("@R_Date", R_Date);
|
2019-01-18 13:08:55 +01:00
|
|
|
Commande.Connection.Open();
|
|
|
|
Commande.ExecuteNonQuery();
|
|
|
|
res = int.Parse(LireParametre("ID_repa"));
|
|
|
|
Commande.Connection.Close();
|
|
|
|
return res;
|
|
|
|
}
|
2019-01-19 22:29:09 +01:00
|
|
|
public int Modifier(int ID_repa, int? ID_listPlat, int? ID_typeRepa , DateTime R_Date)
|
2019-01-18 13:08:55 +01:00
|
|
|
{
|
|
|
|
CreerCommande("ModifierT_repa");
|
|
|
|
int res = 0;
|
|
|
|
Commande.Parameters.AddWithValue("@ID_repa", ID_repa);
|
|
|
|
if(ID_listPlat == null) Commande.Parameters.AddWithValue("@ID_listPlat", Convert.DBNull);
|
|
|
|
else Commande.Parameters.AddWithValue("@ID_listPlat", ID_listPlat);
|
|
|
|
if(ID_typeRepa == null) Commande.Parameters.AddWithValue("@ID_typeRepa", Convert.DBNull);
|
|
|
|
else Commande.Parameters.AddWithValue("@ID_typeRepa", ID_typeRepa);
|
2019-01-19 22:29:09 +01:00
|
|
|
Commande.Parameters.AddWithValue("@R_Date", R_Date);
|
|
|
|
Commande.Connection.Open();
|
2019-01-18 13:08:55 +01:00
|
|
|
Commande.ExecuteNonQuery();
|
|
|
|
Commande.Connection.Close();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
public List<C_T_repa> Lire(string Index)
|
|
|
|
{
|
|
|
|
CreerCommande("SelectionnerT_repa");
|
|
|
|
Commande.Parameters.AddWithValue("@Index", Index);
|
|
|
|
Commande.Connection.Open();
|
|
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
|
|
List<C_T_repa> res = new List<C_T_repa>();
|
|
|
|
while (dr.Read())
|
|
|
|
{
|
|
|
|
C_T_repa tmp = new C_T_repa();
|
|
|
|
tmp.ID_repa = int.Parse(dr["ID_repa"].ToString());
|
2019-01-19 22:29:09 +01:00
|
|
|
tmp.R_Date = DateTime.Parse(dr["R_Date"].ToString());
|
2019-01-18 13:08:55 +01:00
|
|
|
if(dr["ID_listPlat"] != DBNull.Value) tmp.ID_listPlat = int.Parse(dr["ID_listPlat"].ToString());
|
|
|
|
if(dr["ID_typeRepa"] != DBNull.Value) tmp.ID_typeRepa = int.Parse(dr["ID_typeRepa"].ToString());
|
|
|
|
res.Add(tmp);
|
|
|
|
}
|
|
|
|
dr.Close();
|
|
|
|
Commande.Connection.Close();
|
|
|
|
return res;
|
|
|
|
}
|
2019-01-19 22:29:09 +01:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// resume de <c>Lire</c>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="start">Date filtre debut compris</param>
|
|
|
|
/// <param name="end">Date fin non compris</param>
|
|
|
|
|
|
|
|
public List<C_T_repa> Lire(DateTime start, DateTime end)
|
|
|
|
{
|
|
|
|
CreerCommande("SelectEventBetweenTwoDateTime");
|
|
|
|
Commande.Parameters.AddWithValue("@dateStart", start);
|
|
|
|
Commande.Parameters.AddWithValue("@dateEnd", end);
|
|
|
|
Commande.Connection.Open();
|
|
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
|
|
List<C_T_repa> res = new List<C_T_repa>();
|
|
|
|
while (dr.Read())
|
|
|
|
{
|
|
|
|
C_T_repa tmp = new C_T_repa();
|
|
|
|
tmp.ID_repa = int.Parse(dr["ID_repa"].ToString());
|
|
|
|
tmp.R_Date = DateTime.Parse(dr["R_Date"].ToString());
|
|
|
|
if (dr["ID_listPlat"] != DBNull.Value) tmp.ID_listPlat = int.Parse(dr["ID_listPlat"].ToString());
|
|
|
|
if (dr["ID_typeRepa"] != DBNull.Value) tmp.ID_typeRepa = int.Parse(dr["ID_typeRepa"].ToString());
|
|
|
|
res.Add(tmp);
|
|
|
|
}
|
|
|
|
dr.Close();
|
|
|
|
Commande.Connection.Close();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
public List<C_T_repa> Lire(DateTime dateV)
|
|
|
|
{
|
|
|
|
CreerCommande("SelectEventBetweenTwoDateTime");
|
|
|
|
Commande.Parameters.AddWithValue("@dateV", dateV);
|
|
|
|
Commande.Connection.Open();
|
|
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
|
|
List<C_T_repa> res = new List<C_T_repa>();
|
|
|
|
while (dr.Read())
|
|
|
|
{
|
|
|
|
C_T_repa tmp = new C_T_repa();
|
|
|
|
tmp.ID_repa = int.Parse(dr["ID_repa"].ToString());
|
|
|
|
tmp.R_Date = DateTime.Parse(dr["R_Date"].ToString());
|
|
|
|
if (dr["ID_listPlat"] != DBNull.Value) tmp.ID_listPlat = int.Parse(dr["ID_listPlat"].ToString());
|
|
|
|
if (dr["ID_typeRepa"] != DBNull.Value) tmp.ID_typeRepa = int.Parse(dr["ID_typeRepa"].ToString());
|
|
|
|
res.Add(tmp);
|
|
|
|
}
|
|
|
|
dr.Close();
|
|
|
|
Commande.Connection.Close();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
public C_T_repa Lire_ID(int ID_repa)
|
2019-01-18 13:08:55 +01:00
|
|
|
{
|
|
|
|
CreerCommande("SelectionnerT_repa_ID");
|
|
|
|
Commande.Parameters.AddWithValue("@ID_repa", ID_repa);
|
|
|
|
Commande.Connection.Open();
|
|
|
|
SqlDataReader dr = Commande.ExecuteReader();
|
|
|
|
C_T_repa res = new C_T_repa();
|
|
|
|
while (dr.Read())
|
|
|
|
{
|
2019-01-19 22:29:09 +01:00
|
|
|
res.R_Date = DateTime.Parse(dr["R_Date"].ToString());
|
|
|
|
res.ID_repa = int.Parse(dr["ID_repa"].ToString());
|
2019-01-18 13:08:55 +01:00
|
|
|
if(dr["ID_listPlat"] != DBNull.Value) res.ID_listPlat = int.Parse(dr["ID_listPlat"].ToString());
|
|
|
|
if(dr["ID_typeRepa"] != DBNull.Value) res.ID_typeRepa = int.Parse(dr["ID_typeRepa"].ToString());
|
|
|
|
}
|
|
|
|
dr.Close();
|
|
|
|
Commande.Connection.Close();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
public int Supprimer(int ID_repa)
|
|
|
|
{
|
|
|
|
CreerCommande("SupprimerT_repa");
|
|
|
|
int res = 0;
|
|
|
|
Commande.Parameters.AddWithValue("@ID_repa", ID_repa);
|
|
|
|
Commande.Connection.Open();
|
|
|
|
res = Commande.ExecuteNonQuery();
|
|
|
|
Commande.Connection.Close();
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|