public FormAluno(Aluno a) { InitializeComponent(); this.aluno = a; dao = new DAO(); //carregar foto foto = dao.CarregarFotoAluno(a.Id); }
private void SalvarFoto() { try { if (txtFoto.Text.Length < 1) //SEM FOTO { return; } try { if (Convert.ToInt32(txtFoto.Text) == foto.IdFoto) //SEM ALTERACAO DA FOTO { return; } } catch (Exception) { } //se deu pau é que está correto, vai ser nova foto if (foto == null) { foto = new FotoAlunoDTO(); foto.IdAluno = aluno.Id; foto.IdFoto = 0; } string FileName = txtFoto.Text; FileStream fs = new FileStream(FileName, FileMode.Open, FileAccess.Read); BinaryReader br = new BinaryReader(fs); foto.Imagem = br.ReadBytes((int)fs.Length); br.Close(); fs.Close(); dao.PersistirFotoAluno(foto); } catch (Exception ex) { Program.Erro(ex.Message); } }