protected void CarregarNoticia() { if (Request.QueryString["ID"] != null) { int id = int.Parse(Request.QueryString["ID"]); Noticia_Model m = new Noticia_Model(); noticia nt = new noticia(); nt = m.Obter(id); txtTituloNoticia.Text = nt.titulo_postagem; edtNoticia.Value = nt.corpo_noticia; ddPrioridade.SelectedValue = nt.prioridade.ToString(); String url = nt.imagem_caminho + nt.imagem_nome; imgImagemCarregada.ImageUrl = url; btnSalvarNoticia.Text = "Salvar Notícia"; } else { btnSalvarNoticia.Text = "Publicar Notícia"; } }
protected void Listar() { Noticia_Model model = new Noticia_Model(); if (txtDataInicioAtividade.Value != "") { listaNoticias = model.Listar(DateTime.Parse(txtDataInicioAtividade.Value), txtTitulo.Text); } else { listaNoticias = model.Listar(txtTitulo.Text); } }
protected bool CarregarDados(int id) { try { Noticia_Model model = new Noticia_Model(); ntc = model.Obter(id); return(true); } catch (Exception e) { Master.Alerta(e.Message); return(false); } }
protected void Listar() { Noticia_Model model = new Noticia_Model(); listaNoticias = model.ListarSite(); }
protected void SalvarNoticia() { // Validar se esta editando ou postando nova // se estiver editando, alterar somente titulo, texto e imagem, mantendo a data try { if (Validar()) { configuracao c = new configuracao(); Configuracao_Model mc = new Configuracao_Model(); c = mc.Obter("medPortal"); // salva o caminho das imagens no servidor ftp String caminho = c.caminho_images; // pega o nome da imagem carregada na tela String nome = Path.GetFileName(imgImagemCarregada.ImageUrl); // declara objeto noticia noticia n = new noticia(); // declara objeto noticia_model Noticia_Model model = new Noticia_Model(); // pega o mediador logado mediador med = Session["med"] as mediador; n.titulo_postagem = txtTituloNoticia.Text; n.corpo_noticia = edtNoticia.Value; n.imagem_caminho = caminho; n.imagem_nome = nome; n.prioridade = int.Parse(ddPrioridade.SelectedValue); if (Request.QueryString["ID"] != null) { // se tem ID, altera int id = int.Parse(Request.QueryString["ID"]); n.id = id; n.data_edicao = DateTime.Now; n.id_local_edicao = med.id_local; n.id_mediador_edicao = med.id; if (model.Alterar(n)) { Master.Sucesso("Notícia alterada!"); Response.Redirect("noticias.aspx"); } else { Master.Alerta("Erro: " + model.message); } } else { // se não tem ID, insere n.data_postagem = DateTime.Now; n.id_local = med.id_local; n.id_mediador = med.id; if (model.Inserir(n)) { Master.Sucesso("Notícia postada!"); Response.Redirect("noticias.aspx"); } else { Master.Alerta("Erro: " + model.message); } } } } catch (Exception Exc) { Master.Alerta("Erro: " + Exc.Message); } }