public static Ech_Resultat Get(Int32 Identifiant) { Ech_Resultat ech_resultat = new Ech_Resultat(); //Connection SqlConnection connection = DataBase.Connection(); //Requete String requete = select + " WHERE Identifiant = @Identifiant;"; //Commande SqlCommand commande = new SqlCommand(requete, connection); //Parametres commande.Parameters.AddWithValue("Identifiant", Identifiant); //Execution connection.Open(); SqlDataReader dataReader = commande.ExecuteReader(); dataReader.Read(); ech_resultat.Identifiant = dataReader.GetInt32(0); ech_resultat.Resultat = dataReader.GetDouble(1); ech_resultat.ID_Echantillon = dataReader.GetInt32(2); ech_resultat.ID_Test = dataReader.GetInt32(3); ech_resultat.ID_Constructeur = dataReader.GetInt32(4); ech_resultat.ID_Teinte = dataReader.GetInt32(5); ech_resultat.ISconforme = dataReader.GetInt16(6); dataReader.Close(); connection.Close(); return ech_resultat; }
public AjoutEchantillon() { InitializeComponent(); TcT = new Test_Ctor_Teinte(); EchRes = new Ech_Resultat(); CBvehicule.DataSource = VehiculeDB.List(); CBvehicule.DisplayMember = "Nom"; CBvehicule.ValueMember = "Identifiant"; }
public void InsertER() { List<Echantillon> Lechantillon = EchantillonDB.List(-2); foreach (Echantillon echantillon in Lechantillon) { List<Test_Ctor_Piece> Ltcp = Test_Ctor_PieceDB.List(ProduitDB.Get(echantillon.ID_Produit).ID_Piece); foreach (Test_Ctor_Piece tcp in Ltcp) { Ech_Resultat EchRes = new Ech_Resultat(); EchRes.ID_Echantillon = echantillon.Identifiant; EchRes.ID_Constructeur = tcp.ID_Constructeur; EchRes.ID_Teinte = ProduitDB.Get(echantillon.ID_Produit).ID_Teinte; EchRes.ID_Test = tcp.ID_Test; EchRes.ISconforme = -1; Ech_ResultatDB.Insert(EchRes); } echantillon.ISconforme= -1; EchantillonDB.Update(echantillon); } }
public static Boolean Insert(Ech_Resultat ech_resultat) { //Connection SqlConnection connection = DataBase.Connection(); //Requete String requete = @"INSERT INTO Ech_Resultat (" + champs + ") VALUES (@Resultat,@ID_Echantillon,@ID_Test,@ID_Constructeur,@ID_Teinte);"; //Commande SqlCommand commande = new SqlCommand(requete, connection); //Parametres commande.Parameters.AddWithValue("Resultat", ech_resultat.Resultat); commande.Parameters.AddWithValue("ID_Echantillon", ech_resultat.ID_Echantillon); commande.Parameters.AddWithValue("ID_Test", ech_resultat.ID_Test); commande.Parameters.AddWithValue("ID_Constructeur", ech_resultat.ID_Constructeur); commande.Parameters.AddWithValue("ID_Teinte", ech_resultat.ID_Teinte); commande.Parameters.AddWithValue("ISconforme", ech_resultat.ISconforme); //Execution connection.Open(); commande.ExecuteNonQuery(); connection.Close(); return true; }
public static Boolean Update(Ech_Resultat ech_resultat) { //Connection SqlConnection connection = DataBase.Connection(); //Requete String requete = @"UPDATE Ech_Resultat SET Resultat=@Resultat,ID_Echantillon=@ID_Echantillon,ID_Test=@ID_Test,ID_Constructeur=@ID_Constructeur,ID_Teinte=@ID_Teinte,ISconforme=@ISconforme WHERE Identifiant=@Identifiant ;"; //Commande SqlCommand commande = new SqlCommand(requete, connection); //Parametres commande.Parameters.AddWithValue("Identifiant", ech_resultat.Identifiant); commande.Parameters.AddWithValue("Resultat", ech_resultat.Resultat); commande.Parameters.AddWithValue("ID_Echantillon", ech_resultat.ID_Echantillon); commande.Parameters.AddWithValue("ID_Test", ech_resultat.ID_Test); commande.Parameters.AddWithValue("ID_Constructeur", ech_resultat.ID_Constructeur); commande.Parameters.AddWithValue("ID_Teinte", ech_resultat.ID_Teinte); commande.Parameters.AddWithValue("ISconforme", ech_resultat.ISconforme); //Execution try { connection.Open(); commande.ExecuteNonQuery(); return true; } catch (Exception) { return false; } finally { connection.Close(); } }
public static List<Ech_Resultat> List(Int32 ID_Echantillon, Int32 ID_Test) { List<Ech_Resultat> listeEch_Resultat = new List<Ech_Resultat>(); //Connection SqlConnection connection = DataBase.Connection(); //Requete String requete = select + " WHERE ID_Echantillon=@ID_Echantillon AND ID_Test=@ID_Test ;"; //Commande SqlCommand commande = new SqlCommand(requete, connection); //Parametres commande.Parameters.AddWithValue("ID_Echantillon", ID_Echantillon); commande.Parameters.AddWithValue("ID_Test", ID_Test); //Execution try { connection.Open(); SqlDataReader dataReader = commande.ExecuteReader(); while (dataReader.Read()) { Ech_Resultat ech_resultat = new Ech_Resultat(); ech_resultat.Identifiant = dataReader.GetInt32(0); ech_resultat.Resultat = dataReader.GetDouble(1); ech_resultat.ID_Echantillon = dataReader.GetInt32(2); ech_resultat.ID_Test = dataReader.GetInt32(3); ech_resultat.ID_Constructeur = dataReader.GetInt32(4); ech_resultat.ID_Teinte = dataReader.GetInt32(5); ech_resultat.ISconforme = dataReader.GetInt16(6); listeEch_Resultat.Add(ech_resultat); } dataReader.Close(); ; } catch (Exception) { listeEch_Resultat = null; } finally { connection.Close(); } return listeEch_Resultat; }
public static List<Ech_Resultat> List() { List<Ech_Resultat> listeEch_Resultat = new List<Ech_Resultat>(); //Connection SqlConnection connection = DataBase.Connection(); //Requete String requete = select + ";"; //Commande SqlCommand commande = new SqlCommand(requete, connection); //Parametres //Execution connection.Open(); SqlDataReader dataReader = commande.ExecuteReader(); while (dataReader.Read()) { Ech_Resultat ech_resultat = new Ech_Resultat(); ech_resultat.Identifiant = dataReader.GetInt32(0); ech_resultat.Resultat = dataReader.GetDouble(1); ech_resultat.ID_Echantillon = dataReader.GetInt32(2); ech_resultat.ID_Test = dataReader.GetInt32(3); ech_resultat.ID_Constructeur = dataReader.GetInt32(4); ech_resultat.ID_Teinte = dataReader.GetInt32(5); ech_resultat.ISconforme = dataReader.GetInt16(6); listeEch_Resultat.Add(ech_resultat); } dataReader.Close(); connection.Close(); return listeEch_Resultat; }