コード例 #1
0
        /// <summary>
        /// Método que controla el evento de consultar una reservación
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void _btnConsultar_Click(object sender, EventArgs e)
        {
            _controlador = new ControladorActivo();
            _sesion = new Sesion();
            _cookieActual = _sesion.verificarValidez(Request.Cookies["PS"]);
            if (_cookieActual == null) // Si la cookie expira redirecciona a la pantalla de Login
                Response.Redirect("../Autentificacion/Login.aspx");
            else // Volver a crear la cookie en el cliente, con el nuevo tiempo de expiración
                Response.SetCookie(_cookieActual);
            if (_txtCodigo.Text.Equals(""))
            {
                _imgMensaje.ImageUrl = "../Imagenes/Advertencia.png";
                _lblMensaje.Text = "Debe especificar el código del activo";
                _imgMensaje.Visible = true;
                _lblMensaje.Visible = true;
                _lblCMensaje.Visible = false;
                _imgCMensaje.Visible = false;

            }
            else
            {
                activo = _controlador.consultarActivoPorCodigo2(_txtCodigo.Text);
                if (activo == null)
                {
                    _imgMensaje.ImageUrl = "~/Imagenes/Error.png";
                    _lblMensaje.Text = "Ha habido un error al encontrar los activos";
                    _imgMensaje.Visible = true;
                    _lblMensaje.Visible = true;
                    _lblCMensaje.Visible = false;
                    _imgCMensaje.Visible = false;

                }
                else if (activo.Count == 0)
                {
                    _imgMensaje.ImageUrl = "~/Imagenes/Advertencia.png";
                    _lblMensaje.Text = "No existe el activo buscado";
                    _imgMensaje.Visible = true;
                    _lblMensaje.Visible = true;
                    _lblCMensaje.Visible = false;
                    _imgCMensaje.Visible = false;

                }
                else
                {
                    _txtCdescripcion.Text = activo.ElementAt(0).ElementAt(1).ToString();
                    _txtCcodigo.Text = activo.ElementAt(0).ElementAt(0).ToString();
                    _ddlEstado.SelectedValue = activo.ElementAt(0).ElementAt(2).ToString();
                    _txtId.Text = activo.ElementAt(0).ElementAt(7).ToString();
                    if (_ddlEstado.SelectedIndex == 1)
                        _ddlEstado.SelectedIndex = 2;
                    else
                        _ddlEstado.SelectedIndex = 1;
                    _imgMensaje.Visible = false;
                    _lblMensaje.Visible = false;
                    //agregarEstados();
                    _txtClogin.Enabled = true;
                    _txtComentario.Enabled = true;
                    _btnMovimiento.Enabled = true;
                    _btnCancelar.Enabled = true;
                    _btnConsultar.Enabled = false;
                    _txtCodigo.Enabled = false;
                    _lblCMensaje.Visible = false;
                    _imgCMensaje.Visible = false;

                }
            }
        }