protected void Page_Load(object sender, EventArgs e) { NewCo = new MyCo(); if (IsPostBack == false) { NewCo.Select("t_produit p", ref dsGalerie); TraitementBDD(dsGalerie,0); dsGalerie.Reset(); NewCo.Select("DISTINCT id_categorie,libelle_site_categorie","t_produit", "t_categorie on id_categorie = fk_id_categorie",0, ref dsGalerie); TraitementBDD(dsGalerie,1); dsGalerie.Reset(); } }
protected void Page_Load(object sender, EventArgs e) { NewCo = new MyCo(); if (IsPostBack == false) { NewCo.Select("t_produit p", ref dsGalerie); TraitementBDD(dsGalerie, 0); dsGalerie.Reset(); NewCo.Select("DISTINCT id_categorie,libelle_site_categorie", "t_produit", "t_categorie on id_categorie = fk_id_categorie", 0, ref dsGalerie); TraitementBDD(dsGalerie, 1); dsGalerie.Reset(); } }
public void ProcessRequest(HttpContext context) { NewCo = new MyCo(); HttpRequest httpRequest = context.Request; //Dim IMG_sortie As Bitmap MemoryStream ms; //si dans la requête http il y a "LOGO_SITE" if (httpRequest["IMG"] != null) { bool verif = true; string id = ""; string num = ""; foreach (char c in httpRequest["IMG"].ToString()) { if (c == '-') { verif = false; } if (verif) { id += c; } if (c != '-' && verif == false) { num += c; } } if (verif) { NewCo.Select("t_produit", "id_produit = " + Convert.ToInt32(httpRequest["IMG"]), ref dsGalerie); try { byte[] data = (byte[])dsGalerie.Tables[0].Rows[0].ItemArray[3]; ms = new MemoryStream(data); //on instencie un flux de mémoire que l'on paramètre avec le logo du site //IMG = Bitmap.FromStream(ms) //format image en .png context.Response.ContentType = "image/JPG"; //IMG.Save(ms, System.Drawing.Imaging.ImageFormat.Png) //on ajoute dans le flux de mémoire, le flux sortant ms.WriteTo(context.Response.OutputStream); //on ferme le flux de mémoire ms.Dispose(); } catch { IMG = Properties.Resources.SansImageProduit; ms = new MemoryStream(ImageToByteArray(IMG)); context.Response.ContentType = "image/JPG"; ms.WriteTo(context.Response.OutputStream); ms.Dispose(); } } else { try { NewCo.Select("t_images_produit", "fk_id_produit = " + Convert.ToInt32(id), ref dsGalerie); if (dsGalerie != null) { foreach (DataRow dr in dsGalerie.Tables[0].Rows) { if (Convert.ToInt32(num) == Convert.ToInt32(dr.ItemArray[2])) { byte[] data = (byte[])dr.ItemArray[1]; ms = new MemoryStream(data); //on instencie un flux de mémoire que l'on paramètre avec le logo du site //IMG = Bitmap.FromStream(ms) //format image en .png context.Response.ContentType = "image/JPG"; //IMG.Save(ms, System.Drawing.Imaging.ImageFormat.Png) //on ajoute dans le flux de mémoire, le flux sortant ms.WriteTo(context.Response.OutputStream); //on ferme le flux de mémoire ms.Dispose(); } } } else { IMG = Properties.Resources.SansImageProduit; ms = new MemoryStream(ImageToByteArray(IMG)); context.Response.ContentType = "image/JPG"; ms.WriteTo(context.Response.OutputStream); ms.Dispose(); } } catch { IMG = Properties.Resources.SansImageProduit; ms = new MemoryStream(ImageToByteArray(IMG)); context.Response.ContentType = "image/JPG"; ms.WriteTo(context.Response.OutputStream); ms.Dispose(); } } } }