Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool Recherche(string Champ)
- {
- MySqlConnection maConnexion = new MySqlConnection("Server=192.168.1.11;Database=bdlycee;Uid=jeremy;Pwd=iris2;");
- string maRequeteRecherche;
- MySqlCommand maCommandeRecherche;
- maRequeteRecherche = "SELECT @Champ FROM tbladmin WHERE fldIdentifiant = @Id";
- maCommandeRecherche = new MySqlCommand(maRequeteRecherche, maConnexion);
- maCommandeRecherche.Parameters.Add(new MySqlParameter("@Id", MySqlDbType.String, 11));
- try { maCommandeRecherche.Parameters["@Id"].Value = Convert.ToInt32(mainForm.textBoxResultatAdm.Text); }
- catch { mainForm.labelErreurCodeAdm.Text = "Code barre ou QR code invalide"; return false;}
- maCommandeRecherche.Parameters.Add(new MySqlParameter("@Champ", MySqlDbType.String, 14));
- try { maCommandeRecherche.Parameters["@Champ"].Value = Champ; }
- catch { mainForm.labelErreurCodeAdm.Text = "Erreur au niveau du champ"; return false;}
- try
- {
- maCommandeRecherche.Connection.Open();
- if (maCommandeRecherche.ExecuteScalar() == null)
- {
- maCommandeRecherche.Connection.Close();
- return false;
- }
- else
- {
- if (Admin == true)
- {
- maCommandeRecherche.ExecuteNonQuery();
- MdpBD = Convert.ToString(maCommandeRecherche.ExecuteScalar());
- if (MdpBD == MdpChiffre)
- return true;
- else
- return false;
- }
- else
- {
- maCommandeRecherche.Connection.Close();
- return true;
- }
- }
- }
- catch { MessageBox.Show("Erreur au niveau de la requête de recherche"); return false; }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement