protected void btnEditar_Click(object sender, EventArgs e) { Button button = (Button)sender; Evento evento = new Evento(); evento.id_evento = int.Parse(button.CommandArgument); try { EventoLogic el = new EventoLogic(); evento = el.BuscarEvento(evento); cargarPanelAgregarEvento(evento); btnAgregarEvento.Visible = false; btnEditarEvento.Visible = true; panelAgregarEvento.Visible = true; buscarEventosDelUsuario(); } catch (Exception ex) { Session["error"] = ex; Response.Redirect("~/Errores.aspx", false); Context.ApplicationInstance.CompleteRequest(); } }
private void buscarEventosDelUsuario(DateTime fecha) { lblFecha.Text = fecha.ToString("dddd", new CultureInfo("es-ES")).First().ToString().ToUpper() + fecha.ToString("dddd", new CultureInfo("es-ES")).Substring(1) + ", " + fecha.ToString("dd") + " de " + fecha.ToString("MMMM", new CultureInfo("es-ES")) + " de " + fecha.ToString("yyyy"); try { EventoLogic el = new EventoLogic(); List <Evento> eventos = el.BuscarEventosDelUsuario(userSesion, fecha); if (eventos != null && eventos.Count > 0) { lblEventos.Visible = false; rptEventos.DataSource = eventos; rptEventos.DataBind(); rptEventos.Visible = true; lblZonaHoraria.Text = "Todos los horarios corresponden a la zona horaria " + userSesion.zonaHoraria.descripcion; lblZonaHoraria.Visible = true; } else { rptEventos.Visible = false; lblZonaHoraria.Visible = false; lblEventos.Visible = true; } } catch (Exception ex) { Session["error"] = ex; Response.Redirect("~/Errores.aspx", false); Context.ApplicationInstance.CompleteRequest(); } }
protected void btnEditarEvento_Click(object sender, EventArgs e) { if (nombreTextBox.Text != null && nombreTextBox.Text != "" && descripcionTextArea.Value != null && descripcionTextArea.Value != "" && fechaEventoTextBox.Value != null && fechaEventoTextBox.Value != "" && (todoElDiaCheckBox.Checked == true || (todoElDiaCheckBox.Checked == false && horaEventoTextBox.Value != null && horaEventoTextBox.Value != "")) && (recordatorioCheckBox.Checked == false || (recordatorioCheckBox.Checked == true && fechaRecordatorioTextBox.Value != null && fechaRecordatorioTextBox.Value != "" && horaRecordatorioTextBox.Value != null && horaRecordatorioTextBox.Value != ""))) { Evento evento = new Evento(); evento.id_evento = int.Parse(idEventoTextBox.Value); evento.nombre = nombreTextBox.Text; evento.descripcion = descripcionTextArea.Value; evento.todo_el_dia = todoElDiaCheckBox.Checked; if (evento.todo_el_dia) { evento.fecha_hora_evento = DateTime.ParseExact(fechaEventoTextBox.Value, "dd/MM/yyyy", null); } else { evento.fecha_hora_evento = new DateTime(DateTime.ParseExact(fechaEventoTextBox.Value, "dd/MM/yyyy", null).Year, DateTime.ParseExact(fechaEventoTextBox.Value, "dd/MM/yyyy", null).Month, DateTime.ParseExact(fechaEventoTextBox.Value, "dd/MM/yyyy", null).Day, DateTime.ParseExact(horaEventoTextBox.Value, "HH:mm", null).Hour, DateTime.ParseExact(horaEventoTextBox.Value, "HH:mm", null).Minute, 0).AddHours(-int.Parse(zonaHorariaDropDownList.SelectedValue)); } if (recordatorioCheckBox.Checked) { evento.fecha_hora_recordatorio = new DateTime(DateTime.ParseExact(fechaRecordatorioTextBox.Value, "dd/MM/yyyy", null).Year, DateTime.ParseExact(fechaRecordatorioTextBox.Value, "dd/MM/yyyy", null).Month, DateTime.ParseExact(fechaRecordatorioTextBox.Value, "dd/MM/yyyy", null).Day, DateTime.ParseExact(horaRecordatorioTextBox.Value, "HH:mm", null).Hour, DateTime.ParseExact(horaRecordatorioTextBox.Value, "HH:mm", null).Minute, 0).AddHours(-int.Parse(zonaHorariaDropDownList.SelectedValue)); } else { evento.fecha_hora_recordatorio = null; evento.recordatorio_enviado = null; } evento.id_usuario = userSesion.id_usuario; evento.id_color = int.Parse(colorDropDownList.SelectedValue); try { EventoLogic el = new EventoLogic(); el.ActualizarEvento(evento); buscarEventosDelUsuario(); panelAgregarEvento.Visible = false; limpiarPanelAgregarEvento(); } catch (Exception ex) { Session["error"] = ex; Response.Redirect("~/Errores.aspx", false); Context.ApplicationInstance.CompleteRequest(); } } else { Response.Redirect("~/Errores.aspx", false); Context.ApplicationInstance.CompleteRequest(); } }
protected void btnEliminar_Click(object sender, EventArgs e) { Button button = (Button)sender; Evento evento = new Evento(); evento.id_evento = int.Parse(button.CommandArgument); try { EventoLogic el = new EventoLogic(); el.EliminarEvento(evento); buscarEventosDelUsuario(DateTime.ParseExact(fechaEventosTextBox.Value, "dd/MM/yyyy", null)); } catch (Exception ex) { Session["error"] = ex; Response.Redirect("~/Errores.aspx", false); Context.ApplicationInstance.CompleteRequest(); } }
private void buscarEventosDelUsuario() { try { EventoLogic el = new EventoLogic(); List <Evento> eventos = el.BuscarEventosDelUsuario(userSesion); if (eventos != null && eventos.Count > 0) { lblEventos.Visible = false; int comienzo = 1; if (Request.QueryString["valor"] != null) { comienzo = int.Parse(Request.QueryString["valor"]); } List <Evento> eventosAMostrar = new List <Evento>(); for (int i = (comienzo * 10) - 10; i < comienzo * 10 && i < eventos.Count; i++) { eventosAMostrar.Add(eventos[i]); } rptEventos.DataSource = eventosAMostrar; rptEventos.DataBind(); rptEventos.Visible = true; lblZonaHoraria.Text = "Todos los horarios corresponden a la zona horaria " + userSesion.zonaHoraria.descripcion; lblZonaHoraria.Visible = true; List <NumeroPaginacion> numeros = new List <NumeroPaginacion>(); for (int i = 1; i <= Math.Ceiling((double)eventos.Count / (double)10); i++) { if (i == comienzo) { numeros.Add(new NumeroPaginacion(i, true)); } else { numeros.Add(new NumeroPaginacion(i, false)); } } rptPaginacion1.DataSource = numeros; rptPaginacion1.DataBind(); rptPaginacion2.DataSource = numeros; rptPaginacion2.DataBind(); paginacion1.Visible = true; paginacion2.Visible = true; } else { rptEventos.Visible = false; lblZonaHoraria.Visible = false; paginacion1.Visible = false; paginacion2.Visible = false; lblEventos.Visible = true; } } catch (Exception ex) { Session["error"] = ex; Response.Redirect("~/Errores.aspx", false); Context.ApplicationInstance.CompleteRequest(); } }
public EventosViewModel() { _logic = new EventoLogic(); List(); }
public EventosController() { _logic = new EventoLogic(); }