/*public static void ResetCalendrier() * { * _conn.Open(); * SqlCommand cmd = new SqlCommand * { * Connection = _conn, * CommandText = * "DELETE FROM MACHINES_CALENDRIER WHERE NOMACHINE != @nomachine" * }; * cmd.Parameters.AddWithValue("@nomachine", ""); * * cmd.ExecuteNonQuery(); * _conn.Close(); * } */ #endregion #region DeleteElementAAfficher public static void DeleteElementAAfficher(AffichableEnListeBox elemToDelete) { if (elemToDelete is ExceptionUVM) { ExceptionUVM excepts = elemToDelete as ExceptionUVM; if (VerifConnection()) { _conn.Open(); SqlCommand cmd = new SqlCommand { Connection = _conn, CommandText = "DELETE FROM MACHINES_CALENDRIER WHERE NOMACHINE = @nomachine AND DATE = @date AND EQUIPE = @equipe" }; cmd.Parameters.AddWithValue("@nomachine", excepts.NoMachine); cmd.Parameters.AddWithValue("@date", excepts.Date.Date); cmd.Parameters.AddWithValue("@equipe", excepts.Poste); cmd.ExecuteNonQuery(); _conn.Close(); // Close the connection } } if (elemToDelete is IndisponibilitéVM) { IndisponibilitéVM indispo = elemToDelete as IndisponibilitéVM; if (VerifConnection()) { _conn.Open(); SqlCommand cmd = new SqlCommand { Connection = _conn, CommandText = "DELETE FROM MACHINES_INDISPO WHERE NOMACHINE = @nomachine AND DATE_DEBUT = @dateDeb AND DATE_FIN = @dateFin AND COMMENTAIRE = @commentaire AND REQUISE = @requise" }; cmd.Parameters.AddWithValue("@nomachine", indispo.NoMachineIndispo); cmd.Parameters.AddWithValue("@dateDeb", indispo.DateSaisieD); cmd.Parameters.AddWithValue("@dateFin", indispo.DateSaisieF); cmd.Parameters.AddWithValue("@commentaire", indispo.Commentaire); cmd.Parameters.AddWithValue("@requise", indispo.Requise); cmd.ExecuteNonQuery(); _conn.Close(); // Close the connection } } }
public static void SaveIndispo(IndisponibilitéVM indispoToSave) { if (VerifConnection()) { _conn.Open(); SqlCommand cmd = new SqlCommand { Connection = _conn, CommandText = "INSERT INTO MACHINES_INDISPO (NOMACHINE, DATE_DEBUT, DATE_FIN, COMMENTAIRE, REQUISE) VALUES (@nomachine, @dateDeb, @dateFin, @commentaire, @requise)" }; cmd.Parameters.AddWithValue("@nomachine", indispoToSave.NoMachineIndispo); cmd.Parameters.AddWithValue("@dateDeb", indispoToSave.DateSaisieD); cmd.Parameters.AddWithValue("@dateFin", indispoToSave.DateSaisieF); cmd.Parameters.AddWithValue("@commentaire", indispoToSave.Commentaire); cmd.Parameters.AddWithValue("@requise", indispoToSave.Requise); cmd.ExecuteNonQuery(); _conn.Close(); } }