1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32
| private void checkedListBoxProduit_SelectedIndexChanged(object sender, EventArgs e)
{
string reference = ((Location)(checkedListBoxProduit.SelectedItem)).Reference.ToString();
int idProduit = ((Location)(checkedListBoxProduit.SelectedItem)).ID;
DateTime dateD = dateDebutLocation.Value;
DateTime dateF = dateFinLocation.Value;
factory = DbProviderFactories.GetFactory(leProvider);
string strConnect = ConfigurationManager.ConnectionStrings["aplvlecs"].ConnectionString;
maConnexion = factory.CreateConnection();
maConnexion.ConnectionString = strConnect;
maConnexion.Open();
//Création de l'objet responsable de l'exécution des requêtes
maCommand = factory.CreateCommand();
maCommand.CommandText = "SELECT numProduit from jos_mleweb_louer WHERE numProduit NOT IN(SELECT numProduit from jos_mleweb_louer WHERE '"+dateD+"' between dateDeSortieProduitLouer and dateEntreeProduitLouer OR '"+dateF+"' between dateDeSortieProduitLouer and dateEntreeProduitLouer OR ('"+dateD+"' <= dateDeSortieProduitLouer AND '"+dateF+"' >= dateEntreeProduitLouer))AND numProduit = " + idProduit;
//MessageBox.Show("SELECT numProduit from jos_mleweb_louer WHERE numProduit NOT IN(SELECT numProduit from jos_mleweb WHERE '" + dateD + "' between dateDeSortieProduitLouer and dateEntreeProduitLouer OR '" + dateF + "' between dateDeSortieProduitLouer and dateEntreeProduitLouer OR ('" + dateD + "' <= dateDeSortieProduitLouer AND '" + dateF + "' >= dateEntreeProduitLouer))AND numProduit = " + idProduit);
maCommand.Connection = maConnexion;
//Méthode qui ExecuteReader
monLecteur = maCommand.ExecuteReader();
if (monLecteur.HasRows == true)
{
MessageBox.Show("non");
}
else
{
monLecteur.Read();
MessageBox.Show("ok");
}
} |
Partager