private void PrepararTela() { if (aluno == null) { aluno = new Aluno(); } if (aluno.Id == 0) //NOVO { txtNome.Text = string.Empty; txtEmail.Text = string.Empty; txtCartao.Value = 0; txtFoto.Text = string.Empty; picFoto.Image = null; txtUsuario.Text = string.Empty; usuario = new Usuario(); usuario.Tipo = 1; } else //EDICAO { txtNome.Text = aluno.Nome; txtEmail.Text = aluno.Email; txtCartao.Value = aluno.Cartao; //Foto do aluno ImagesDAO imgDao = new ImagesDAO(); aluno.Foto = imgDao.CarregarAlunoFoto(aluno.Id); picFoto.Image = imgDao.ByteArray2Image(aluno.Foto); usuario = new UsuarioDAO().Carregar(aluno.IdUsuario); txtUsuario.Text = usuario.Username; } }
public static HtmlString DrowAvatar(this HtmlHelper helper, int userID) { UsersDAO usersDAO = new UsersDAO(); ImagesDAO imagesDAO = new ImagesDAO(); Users user = usersDAO.GetByID(userID); if (user.Avatar != null) { Images image = imagesDAO.GetImage(user.Avatar); TagBuilder img = new TagBuilder("img"); string attribute = "data:image;base64," + Convert.ToBase64String(image.Image); string height = "300px"; string width = "300px"; img.Attributes.Add("src", attribute); img.Attributes.Add("height", height); img.Attributes.Add("width", width); return(new HtmlString(img.ToString())); } else { TagBuilder label = new TagBuilder("label"); label.SetInnerText("No avatar("); return(new HtmlString(label.ToString())); } }
/// <summary> /// DB에 저장된 이미지를 이미지 폴더 내에 저장하기 위한 메서드. /// </summary> private void DownloadImage() { string downloadImage = string.Empty; foreach (var name in needsToDownload) { try { ImageVO imgVO = new ImagesDAO().SelectImagesByName(name); downloadImage += imgVO.Name + Environment.NewLine; File.WriteAllBytes(Application.StartupPath + "\\images\\" + imgVO.Name, imgVO.Image); } catch (SqlException ex) { MessageBox.Show(ex.StackTrace); } } if (!string.IsNullOrWhiteSpace(downloadImage)) { MessageBox.Show("현재 폴더에없는" + Environment.NewLine + downloadImage + "가 다운로드 되었습니다"); } }