protected void btnAgendar_Click(object sender, EventArgs e) { AgendamentoDTO agendamentoDTO = new AgendamentoDTO(); AgendamentoCT agendamentoCT = new AgendamentoCT(); try { agendamentoDTO.IdVenda = Convert.ToInt32(idVenda); agendamentoDTO.IdFuncionario = Convert.ToInt32(ddlFuncionario.SelectedValue); agendamentoDTO.IdHorario = Convert.ToInt32(idHorario); if (valida(0, data)) { agendamentoDTO.DataAgendamento = Convert.ToDateTime(data); if (agendamentoCT.Insere(agendamentoDTO)) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alerta", "alert('Agendamento incluído!'); window.location.href='" + PaginaDeAgendamento + "';", true); } } else { ScriptManager.RegisterStartupScript(this, this.GetType(), "alerta", "alert('Erro ao incluir agendamento. Verifique a data informada!'); window.location.href='" + PaginaDeAgendamento + "';", true); } } catch (Exception ex) { ScriptManager.RegisterStartupScript(this, this.GetType(), "alerta", "alert('Erro ao incluir agendamento. Verifique os dados informados!');", true); } }