protected void btnSalvar_Click(object sender, EventArgs e) { if (operacao == 1) { bool bObrPreenchidos = validaObrigatorio(); if (bObrPreenchidos != true) { lblAlerta.Text = "Campos obrigatorios não foram preenchidos, para continuar, preencha todos os campos obrigatorios."; lblAlerta.Visible = true; } else { bool bExisteEvento = validaSeExiste(); if (bExisteEvento != true) { bool bDataConsistente = validaConsisData(); if (bDataConsistente == true) { EventoDAO oEvd = new EventoDAO(); bool auxRet = oEvd.inserirEvento(txtNomeEvento.Text, txtDataInicio.Text, txtDataFim.Text, Convert.ToInt32(ddlTipoEvento.Text), txtEndereco.Text); if (auxRet == true) { Response.Write(string.Format("<script>alert('Cadastro Efetuado.');</script>")); string strCmd = string.Format("select COD_EVENTO from EVENTO where NOME_EVENTO = '{0}'", txtNomeEvento.Text); SqlDataReader dr1 = SqlDB.Instancia.FazerSelect(strCmd); if (dr1.HasRows) { Session["evento"] = Convert.ToString(dr1["COD_EVENTO"]); dr1.Close(); } } } else { Response.Write("<script>alert('Cadastro não efetuado, data de fim menor que a data de inicio ou data de inicio anterior a data atual.');</script>"); } } else { Response.Write("<script>alert('Cadastro não efetuado, já existe um evento com o mesmo nome.');</script>"); } } } else { string strCmd = string.Format("UPDATE EVENTO SET DATA_INICIO = '{0}', DATA_FIM = '{1}', ENDERECO = '{2}' WHERE NOME_EVENTO = '{3}'", txtDataInicio.Text, txtDataFim.Text, txtEndereco.Text, txtNomeEvento.Text); int ret = SqlDB.Instancia.FazerUpdate(strCmd); if (ret > 0) { Response.Write(string.Format("<script>alert('Cadastro Efetuado');</script>")); } else { Response.Write("<script>alert('Alteração não Efetuada.');</script>"); } } }