//fonction de recuperation des elements d'affichage et affichage dans le dropdownlist void affiche_dropdownListe() { con = new connexion(); SqlDataReader rd = con.selectData("SELECT association_au_region.id_ass, region.nom_region, service.nom_service, poste.nom_poste FROM association_au_region INNER JOIN region ON association_au_region.id_region = region.id_region INNER JOIN service ON association_au_region.id_service = service.id_service INNER JOIN poste ON association_au_region.id_poste = poste.id_poste"); DropDownListAssoc.Items.Clear(); DropDownListAssoc.Items.Add(""); while (rd.Read()) { DropDownListAssoc.Items.Add(rd.GetInt32(0) + " " + rd.GetString(1) + " " + rd.GetString(2) + " " + rd.GetString(3)); } }
//on click pour recuperer la photo d'un employer protected void voir_image_Click(object sender, ImageClickEventArgs e) { string[] matricule_emp = null; try { matricule_emp = DropDownListAssoc.SelectedItem.ToString().Split(' '); if (matricule_emp[0].Length > 0) { con = new connexion(); SqlDataReader rd = con.selectData("select photo_empl from employer where matricule='" + matricule_emp[0] + "'"); if (rd.HasRows) { while (rd.Read()) { byte[] imag = (byte[])rd["photo_empl"]; string myImage = Convert.ToBase64String(imag, 0, imag.Length); Image1.ImageUrl = "data:photo_empl/png;base64," + myImage; Label_valide.Text = "la photo a ete trouve"; label_erreur.Text = ""; } } else { label_erreur.Text = "Image non trouve dans le stockage"; Label_valide.Text = ""; } } else { label_erreur.Text = "selectionnez d'abord un employer dans la liste"; Label_valide.Text = ""; } } catch (Exception ex) { label_erreur.Text = "Image non trouve dans le stockage"; Label_valide.Text = ""; } }
protected void Button2_Click1(object sender, EventArgs e) { con = new connexion(); SqlDataReader rd = con.selectData("select matricule,nom,prenom from employer"); if (rd.HasRows) { DropDownListAssoc.Items.Clear(); DropDownListAssoc.Items.Add(""); while (rd.Read()) { DropDownListAssoc.Items.Add(rd.GetString(0) + " " + rd.GetString(1) + " " + rd.GetString(2)); } voir_image.Enabled = true; detaille.Enabled = true; } else { labsucces.Text = ""; error.Text = "Acun employer trouve"; } }