public static void ModifierSite(Data_Sites dataSite, string id) { // Fonction permettant la supression d'un site via l'id selectionné var sql = "update site set nom = @nom, adresse = @adresse, cp = @cp, ville = @ville where id_site = @id"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con) { CommandType = CommandType.Text }; cmd.Parameters.Add("@id", MySqlDbType.VarChar).Value = id; cmd.Parameters.Add("@nom", MySqlDbType.Text).Value = dataSite.Nom; cmd.Parameters.Add("@adresse", MySqlDbType.Text).Value = dataSite.Adresse; cmd.Parameters.Add("@cp", MySqlDbType.Text).Value = dataSite.Cp; cmd.Parameters.Add("@ville", MySqlDbType.Text).Value = dataSite.Ville; try { cmd.ExecuteNonQuery(); MessageBox.Show("Le site " + dataSite.Nom + " a bien été modifié.\n", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show("Erreur lors de la modification " + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void ModifInter(Data_Interventions dataInter, string id) { // Fonction permettant la modification d'une intervention var sql = "update intervention set dateInter = @dateInter, com = @com ,id_mat = @id_mat where id_intervention = @id"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con) { CommandType = CommandType.Text }; cmd.Parameters.Add("@id", MySqlDbType.VarChar).Value = id; cmd.Parameters.Add("@dateinter", MySqlDbType.DateTime).Value = dataInter.DateInter; cmd.Parameters.Add("@com", MySqlDbType.VarChar).Value = dataInter.Com; // Conversion du format text en Int cmd.Parameters.Add("@id_mat", MySqlDbType.Int32).Value = dataInter.Id_mat; try { cmd.ExecuteNonQuery(); MessageBox.Show("Modification de l'intervation N° " + id + " terminé"); } catch (MySqlException ex) { MessageBox.Show(ex.Message); } }
public static void AjoutMateriel(Data_Materiels DataMAt) { var sql = "insert into materiel (id_mat, nom, referenece, descr, date_instal, mtbf, perime, id_type, id_site, id_client) values (NULL, @nom, @referenece, @descr, @date_instal, @mtbf, @perime, @id_type, @id_site, @id_client)"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con) { CommandType = CommandType.Text }; cmd.Parameters.Add("@nom", MySqlDbType.VarChar).Value = DataMAt.Nom; cmd.Parameters.Add("@referenece", MySqlDbType.VarChar).Value = DataMAt.Referenece; cmd.Parameters.Add("@descr", MySqlDbType.VarChar).Value = DataMAt.Descr; // Conversion du format Text en Date cmd.Parameters.Add("@date_instal", MySqlDbType.DateTime).Value = DataMAt.Date_instal; // Conversion du format Text en Int32 cmd.Parameters.Add("@mtbf", MySqlDbType.Int32).Value = DataMAt.Mtbf; // Converstion du format Text en Bit cmd.Parameters.Add("@perime", MySqlDbType.VarChar).Value = DataMAt.Perime; cmd.Parameters.Add("@id_type", MySqlDbType.Int32).Value = DataMAt.Id_type; cmd.Parameters.Add("@id_site", MySqlDbType.Int32).Value = DataMAt.Id_site; cmd.Parameters.Add("@id_client", MySqlDbType.Int32).Value = DataMAt.Id_client; // Try / Catch pour savoir si la requete passe ou non try { cmd.ExecuteNonQuery(); MessageBox.Show("Le materiel " + DataMAt.Nom + " a bien été ajouté."); } catch (MySqlException ex) { MessageBox.Show(ex.Message); } }
public static void Intervenu(string id) { var sql = "UPDATE intervention SET finie = 'True' WHERE intervention.id_intervention = @id; "; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con) { CommandType = CommandType.Text }; cmd.Parameters.Add("@id", MySqlDbType.VarChar).Value = id; cmd.ExecuteNonQuery(); }
public static void EstIntervenu(string id) { var sql = "update materiel set perime = 'True' where id_mat = @id"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con) { CommandType = CommandType.Text }; cmd.Parameters.Add("@id", MySqlDbType.VarChar).Value = id; cmd.ExecuteNonQuery(); }
public static void AjouterClient(Data_Clients dataClient) { var sql = "insert into client (id_client, nom, adresse) values (NULL, @nom, @adresse)"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@nom", MySqlDbType.Text).Value = dataClient.Nom; cmd.Parameters.Add("@adresse", MySqlDbType.Text).Value = dataClient.Adresse; try { cmd.ExecuteNonQuery(); MessageBox.Show("Insertion du client : " + dataClient.Nom + " réussie."); } catch (MySqlException ex) { MessageBox.Show("Erreur lors de l'insertion : " + ex.Message, ""); } }
public static void SupprInter(string id) { // Fonction permettant la suppression d'une intervention var sql = "delete from intervention where id_intervention = @Id"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@Id", MySqlDbType.VarChar).Value = id; try { cmd.ExecuteNonQuery(); MessageBox.Show("Intervention N° " + id + " deprogrammée."); } catch (MySqlException ex) { MessageBox.Show(ex.Message); } }
public static void SupprSite(string id) { // Fonction permettant la supression d'un site via l'id selectionné var sql = "delete from site where id_site = @Id"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@Id", MySqlDbType.VarChar).Value = id; try { cmd.ExecuteNonQuery(); MessageBox.Show("Le site N° " + id + " a bien été supprimé.\n", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (MySqlException ex) { MessageBox.Show("Erreur lors la suppression du site N° " + id + "\n" + ex.Message, "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void SupprMateriel(string id) { // Fonction permettant la suppression d'un materiel via l'id. var sql = "delete from materiel where id_mat = @id"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@id", MySqlDbType.VarChar).Value = id; try { cmd.ExecuteNonQuery(); MessageBox.Show("Le materiel N°" + id + " a bien été supprimé.\n", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show( "Erreur lors la suppression du materiel N° " + id + "\n Ce materiel appartient à des interventions", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void AjouterSite(Data_Sites dataSite) { // Fonction permettant l'ajout d'un nouveau site. var sql = "insert into site (id_site, nom, adresse, cp, ville) values (NULL, @nom, @adresse, @cp, @ville)"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@nom", MySqlDbType.Text).Value = dataSite.Nom; cmd.Parameters.Add("@adresse", MySqlDbType.Text).Value = dataSite.Adresse; cmd.Parameters.Add("@cp", MySqlDbType.Text).Value = dataSite.Cp; cmd.Parameters.Add("@ville", MySqlDbType.Text).Value = dataSite.Ville; try { cmd.ExecuteNonQuery(); MessageBox.Show("Insertion du site : " + dataSite.Nom + " réussie."); } catch (MySqlException ex) { MessageBox.Show("Erreur lors de l'insertion : " + ex.Message, ""); } }
public static void SupprClient(string id) { // Fonction permettant la supression d'un client via l'id selectionné var sql = "delete from client where id_client = @Id"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con); cmd.CommandType = CommandType.Text; cmd.Parameters.Add("@Id", MySqlDbType.VarChar).Value = id; try { cmd.ExecuteNonQuery(); MessageBox.Show("Le client N°" + id + " a bien été supprimé.\n", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch { MessageBox.Show( "Le client n° " + id + " est lié à un materiel étant en cours de maintenance.\nVeuillez supprimer les interventions en cours.", "Information", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void AjoutInter(Data_Interventions dataInter) { // Fonction permettant l'insertion d'une nouvelle intervention var sql = "insert into intervention (id_intervention, dateInter, com, id_mat) values (NULL, @dateinter, @com, @id_mat)"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con) { CommandType = CommandType.Text }; cmd.Parameters.Add("@dateinter", MySqlDbType.DateTime).Value = dataInter.DateInter; // Date d'intervention cmd.Parameters.Add("@com", MySqlDbType.VarChar).Value = dataInter.Com; // Commentaire cmd.Parameters.Add("@id_mat", MySqlDbType.Int32).Value = dataInter.Id_mat; // Id du materiel try { cmd.ExecuteNonQuery(); MessageBox.Show("Intervention programmée !"); } catch (MySqlException ex) { MessageBox.Show(ex.Message); } }
public static void ModifMat(Data_Materiels dataMat, string id) { // Fonction permettant la modification d'une intervention var sql = "update materiel set nom = @nom, referenece = @referenece, descr = @descr, date_instal = @date_instal, mtbf = @mtbf, perime = @perime, id_type = @id_type, id_site = @id_site, id_client = @id_client where id_mat = @id"; var con = Fcts_DB.GetConnection(); var cmd = new MySqlCommand(sql, con) { CommandType = CommandType.Text }; cmd.Parameters.Add("@id", MySqlDbType.VarChar).Value = id; cmd.Parameters.Add("@nom", MySqlDbType.VarChar).Value = dataMat.Nom; cmd.Parameters.Add("@referenece", MySqlDbType.VarChar).Value = dataMat.Referenece; cmd.Parameters.Add("@descr", MySqlDbType.VarChar).Value = dataMat.Descr; // Conversion du format Text en Date cmd.Parameters.Add("@date_instal", MySqlDbType.DateTime).Value = dataMat.Date_instal; // Conversion du format Text en Int32 cmd.Parameters.Add("@mtbf", MySqlDbType.Int32).Value = dataMat.Mtbf; // Converstion du format Text en Bit cmd.Parameters.Add("@perime", MySqlDbType.VarChar).Value = dataMat.Perime; cmd.Parameters.Add("@id_type", MySqlDbType.Int32).Value = dataMat.Id_type; cmd.Parameters.Add("@id_site", MySqlDbType.Int32).Value = dataMat.Id_site; cmd.Parameters.Add("@id_client", MySqlDbType.Int32).Value = dataMat.Id_client; // Try / Catch pour savoir si la requete passe ou non try { cmd.ExecuteNonQuery(); MessageBox.Show("Le materiel " + dataMat.Nom + " a bien été modifié \n"); } catch (MySqlException ex) { MessageBox.Show(ex.Message); } }