protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                int id = Convert.ToInt32(Request.QueryString["id"]);

                if( id > 0 ){

                    EventoBLL bll = new EventoBLL();
                    EventoType evento = bll.selectRecord(id);

                    if (evento.idEvento > 0 && evento.idAssociacao == Int32.Parse(Session["AssociacaoID"].ToString()))
                    {
                        bll.delete(evento);
                        Session["FlashMsg"] = "Apagado com sucesso";
                        Session["FlashMsgType"] = "success";
                    }
                    else
                    {
                        throw new Exception("Id invalido");
                    }
                }
            }
            catch (Exception ex)
            {
                Session["FlashMsg"] = ex.Message;
                Session["FlashMsgType"] = "danger";
            }

            Response.Redirect("~/Painel/Eventos.aspx");
        }
        public void loadEvento()
        {
            EventoBLL bll = new EventoBLL();

            if (_idEvento > 0 && !IsPostBack)
            {
                _evento = bll.selectRecord(_idEvento);

                txtTitulo.Text = _evento.Titulo;
                txtLocal.Text = _evento.Local;
                txtDataInicio.Text = _evento.dataIniToInput;
                txtDataFim.Text = _evento.dataEndToInput;
                _Descricao = _evento.Descricao;
            }
            else {
                _evento = new EventoType();
                if(_idEvento > 0){
                    _evento.idEvento = _idEvento;
                }
            }
        }
        protected void btnSalvar_Click(object sender, EventArgs e)
        {
            try{

                EventoBLL bll = new EventoBLL();
                string descricao = Request.Form["descricao"].ToString();

                _evento.idAssociacao = Master.getAssociacaoSession().IdAssociacao;
                _evento.Local = txtLocal.Text;
                _evento.Titulo = txtTitulo.Text;
                _evento.dataIni = txtDataInicio.Text;
                _evento.dataEnd = txtDataFim.Text;
                _evento.Descricao = descricao;

                if (_evento.idEvento > 0)
                {
                    bll.update(_evento);

                    Session["FlashMsg"] = "Evento atualizado com sucesso.";
                    Session["FlashMsgType"] = "success";
                }
                else {
                    bll.inserir(_evento);

                    Session["FlashMsg"] = "Evento cadastro com sucesso.";
                    Session["FlashMsgType"] = "success";
                }

               }catch (Exception ex)
               {
                Session["FlashMsg"] = ex.Message;
                Session["FlashMsgType"] = "danger";
               }
               finally
               {
               Response.Redirect("~/Painel/Eventos.aspx");
               }
        }
Пример #4
0
 protected void Page_Load(object sender, EventArgs e)
 {
     EventoBLL bll = new EventoBLL();
     eventos = bll.select(Master.AssociacaoIdCookie);
 }