protected void tabla_ItemCommand(object source, RepeaterCommandEventArgs e)
        {
            TextBox t = e.Item.FindControl("txtCantidad") as TextBox;

            int cantidad = int.Parse(t.Text);
            int id       = int.Parse((string)e.CommandArgument);

            Dictionary <int, Entidades.Invitacion> invitaciones =
                (Dictionary <int, Entidades.Invitacion>)Session["invitaciones"];

            if (invitaciones.ContainsKey(id))
            {
                invitaciones[id].CantidadInvitaciones = cantidad;
            }
            else
            {
                IDaoDepartamento daoDepartamento = (IDaoDepartamento)Application["daoDepartamentos"];

                Entidades.Empleado empleado = dao.ObtenerPorId(id);

                empleado.DepartamentoAsignado = daoDepartamento.ObtenerPorId(empleado.IdDepartamento);

                invitaciones.Add(id, new Entidades.Invitacion()
                {
                    IdEmpleado           = id,
                    CantidadInvitaciones = cantidad,
                    EmpleadoInvitado     = empleado
                }
                                 );
            }
        }
Exemplo n.º 2
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["usuario"] == null)
            {
                Response.Redirect("~");
                return;
            }

            if (!IsPostBack)
            {
                IDaoDepartamento daoDepartamentos =
                    (IDaoDepartamento)Application["daoDepartamentos"];

                List <Entidades.Departamento> departamentos = daoDepartamentos.ObtenerTodos();

                foreach (Entidades.Departamento departamento in departamentos)
                {
                    ddlDepartamento.Items.Add(
                        new ListItem(departamento.Nombre, departamento.Id.ToString()));
                }

                if (Request["id"] != null)
                {
                    IDaoEmpleado dao =
                        (IDaoEmpleado)Application["daoEmpleados"];

                    int id = int.Parse(Request["id"]);

                    Entidades.Empleado empleado = dao.ObtenerPorId(id);

                    txtId.Text = empleado.Id.ToString();

                    ddlDepartamento.SelectedValue = empleado.IdDepartamento.ToString();

                    txtNombre.Text = empleado.Nombre;
                    txtFecha.Text  = empleado.FechaDeNacimiento.ToString("yyyy-MM-dd");
                    txtSueldo.Text = empleado.Sueldo.ToString("0");
                    txtDni.Text    = empleado.Dni;
                }

                switch (Request["opcion"])
                {
                case "alta":
                    btnAceptar.Text      = "Alta";
                    btnAceptar.CssClass += " btn-primary";
                    break;

                case "borrar":
                    btnAceptar.Text      = "Borrar";
                    btnAceptar.CssClass += " btn-danger";

                    txtNombre.Enabled       = false;
                    txtFecha.Enabled        = false;
                    txtDni.Enabled          = false;
                    txtSueldo.Enabled       = false;
                    ddlDepartamento.Enabled = false;

                    break;

                case "editar":
                    btnAceptar.Text      = "Cambiar";
                    btnAceptar.CssClass += " btn-warning";
                    break;
                }
            }
        }