protected override void Render(HtmlTextWriter output) { // Stream stream = null; Bitmap image = null; try { //Return an image in the web reponse byte[] bytes = null; Argix.HR.Badge badge = null; switch (this.mIDType) { case "Drivers": break; case "Employees": badge = new Argix.HR.BadgeGateway().GetEmployeeBadge(this.mIDNumber); bytes = ((Argix.HR.EmployeeBadge)badge).Signature; if (bytes != null) { stream = new MemoryStream(bytes); image = new Bitmap(stream); } break; case "Vendors": break; } //Render as jpeg to browser HttpResponse response = this.Context.Response; response.ContentType = "image/jpeg"; response.BufferOutput = true; response.Clear(); if (image != null) { image.Save(response.OutputStream, ImageFormat.Jpeg); } } catch { } finally { if (stream != null) { stream.Dispose(); } if (image != null) { image.Dispose(); } } }
protected void OnChangePhoto(object sender, CommandEventArgs e) { // if (this.mIDType.Length > 0) { switch (e.CommandName) { case "Back": if (this.mIndex > 0) { this.mIndex--; } else { this.mIndex = this.mBadges.BadgeTable.Rows.Count - 1; } break; case "Next": if (this.mIndex < this.mBadges.BadgeTable.Rows.Count - 1) { this.mIndex++; } else { this.mIndex = 0; } break; } this.ViewState["Index"] = this.mIndex; Argix.HR.Badge badge = null; switch (this.mIDType) { case "Drivers": badge = null; break; case "Employees": badge = new Argix.HR.BadgeGateway().GetEmployeeBadge(this.mBadges.BadgeTable[this.mIndex].IDNumber); break; case "Vendors": badge = new Argix.HR.BadgeGateway().GetVendorBadge(this.mBadges.BadgeTable[this.mIndex].IDNumber); break; } this.lblName.Text = badge.FirstName + " " + badge.LastName; this.imgPhoto.ImageUrl = "~/Photo.aspx?type=" + this.mIDType + "&id=" + badge.IDNumber; } }