/// <summary> /// Modifica un registro de Tipo de Evento /// </summary> /// <param name="tipoEvento">Objeto TipoEvento</param> public void editarTipoEvento(TipoEventoBEL tipoEvento) { try { Entidades conexion = ConexionBLL.getConexion(); TIPO_EVENTO tipoEventoDALC = (from tmpTipoEvento in conexion.TIPO_EVENTO where tmpTipoEvento.ID_TIPO_EVENTO == tipoEvento.IdTipoEvento select tmpTipoEvento).FirstOrDefault(); tipoEventoDALC.ID_TIPO_EVENTO = tipoEvento.IdTipoEvento; tipoEventoDALC.DESCRIPCION = tipoEvento.DescripcionTipoEvento; conexion.SaveChanges(); } catch { return; } }
/// <summary> /// Agrega un nuevo registro de Tipo de Evento /// </summary> /// <param name="tipoEvento">Objeto TipoEvento</param> public void agregarTipoEvento(TipoEventoBEL tipoEvento) { try { Entidades conexion = ConexionBLL.getConexion(); TIPO_EVENTO tipoEventoDALC = new TIPO_EVENTO(); tipoEventoDALC.DESCRIPCION = tipoEvento.DescripcionTipoEvento; //tipoEventoDALC.ID_TIPO_EVENTO = tipoEvento.IdTipoEvento; conexion.AddToTIPO_EVENTO(tipoEventoDALC); conexion.SaveChanges(); conexion.Dispose(); } catch { return; } }
protected void Page_Load(object sender, EventArgs e) { /// <summary> /// Carga los datos si se requiere actualiar o editar /// </summary> if (!IsPostBack) { if (Request.QueryString["id"] != null) { lblTitulo.Text = "Modificar Tipo Evento"; TipoEventoBLL tipoBLL = new TipoEventoBLL(); TipoEventoBEL tipoBEL = tipoBLL.taerEnventoPorId(Int32.Parse(Request.QueryString["id"])); txtNombre.Text = tipoBEL.DescripcionTipoEvento; idTipoEvento.Text = tipoBEL.IdTipoEvento.ToString(); } } }
/// <summary> /// Guarda los datos entregados por el usuario /// </summary> protected void btnGuardar_Click(object sender, EventArgs e) { TipoEventoBEL tipoEvento = new TipoEventoBEL(); tipoEvento.DescripcionTipoEvento = txtNombre.Text; TipoEventoBLL tipevebll = new TipoEventoBLL(); if (lblTitulo.Text == "Modificar Tipo Evento") { tipoEvento.IdTipoEvento = Int32.Parse(idTipoEvento.Text); tipevebll.editarTipoEvento(tipoEvento); Response.Write("<script>alert('Datos modificados correctamente'); window.location='TiposEventos.aspx';</script>"); } else { tipevebll.agregarTipoEvento(tipoEvento); Response.Write("<script>alert('Se agregó correctamente');window.location='TiposEventos.aspx';</script>"); txtNombre.Text = String.Empty; } }
/// <summary> /// Trae el registro de Tipos de Eventos como LIST /// </summary> /// <param name="id">id del tipo de evento a Filtrar</param> /// <returns></returns> public TipoEventoBEL taerEnventoPorId(int id) { try { TIPO_EVENTO evenDalc = (from tmpevento in ConexionBLL.getConexion().TIPO_EVENTO where tmpevento.ID_TIPO_EVENTO == id select tmpevento).FirstOrDefault(); if (evenDalc != null) { TipoEventoBEL tipo = new TipoEventoBEL(); tipo.IdTipoEvento = (int)evenDalc.ID_TIPO_EVENTO; tipo.DescripcionTipoEvento = evenDalc.DESCRIPCION; return(tipo); } return(null); } catch { return(null); } }