protected void Page_Load(object sender, EventArgs e) { long id = Convert.ToInt64(Request.QueryString.Get("Id")); string tipo = Request.QueryString.Get("tipo"); //string nome= Request.QueryString["comp"]; //Response.Write("<div style=position:absolute><img src='" + nome + ".jpg' /></div>"); //System.IO.Stream comp = ((System.IO.Stream)Session["comp"]); //byte[] oc = new byte[comp.Length]; //int i = 0; //while (comp.Position < comp.Length){ // oc[i] = (byte)comp.ReadByte(); // i++; //} Response.Clear(); Context.Response.ContentType = "image/GIF"; //bmp.Save(context.Response.OutputStream, ImageFormat.Gif); Lancamento l = FabricaLancamento.fabricarLancamento(tipo, id); //System.Drawing.Image comp = (System.Drawing.Image)Session["comp"]; MemoryStream ms = new MemoryStream(); l.Comprovante.Save(ms, System.Drawing.Imaging.ImageFormat.Gif); // Response.BinaryWrite((byte[])Session["comp"]); //Pode ser isso que está faltando!! //Response.ContentType = "jpg"; // myDataReader.Item("PersonImageType") Response.OutputStream.Write(ms.ToArray(), 0, (int)ms.Length); Response.Flush(); Response.Close(); }
protected void Cadastrar(object sender, EventArgs e) { Lancamento l = FabricaLancamento.fabricarLancamento(this.rbtTipoLancamento.SelectedValue, this.uplComprovante.PostedFile.InputStream); l.descricao = this.txtDescricao.Text; l.valor = Decimal.Parse(this.txtValor.Text); l.data = this.calData.SelectedDate; l.registrar(); this.lblMensagem.Text = "Registrado com sucesso!"; this.CarregarGrid(); }
protected void Cadastrar(object sender, EventArgs e) { long tamanho = this.uplComprovante.PostedFile.InputStream.Length; byte[] comp = new byte[tamanho]; if (this.uplComprovante.HasFile) { try{ this.uplComprovante.PostedFile.InputStream.Read(comp, 0, (int)tamanho); }catch (Exception erro) { this.lblMensagem.Text = erro.Message; } } else { this.lblMensagem.Text = "Nenhum comprovante anexado."; } try { Lancamento l = FabricaLancamento.fabricarLancamento(this.rbtTipoLancamento.SelectedValue, comp); //l.valor = Decimal.Parse(this.txtValor.Text); l.data = this.calData.SelectedDate; if (this.accLancamento.SelectedIndex == 0) { l.descricao = this.txtDescricao.Text; } else { l.produtos.AddRange(this.produtos); } l.valor = this.txtValor.Text != string.Empty ? Decimal.Parse(this.txtValor.Text): 0; this.categoriaSelecionada.incluirLancamento(l); this.LimpaTela(); this.lblMensagem.Text = "Registrado com sucesso!"; ViewState["produtos"] = null; } catch (Exception erro) { this.lblMensagem.Text = erro.Message; } }