コード例 #1
0
        protected void grdPedidos_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            //
            // Se obtiene indice de la row seleccionada
            //
            int index = Convert.ToInt32(e.CommandArgument);

            //
            // Obtengo el id de la entidad que se esta editando
            // en este caso de la entidad Person
            //
            int id = Convert.ToInt32(grdPedidos.DataKeys[index].Value);

            if (e.CommandName == "cmdEditar")
            {
                contieneFormUC.Visible = true;
                panelVerPedido.Visible = false;

                var pedidoEditado = PedidoServicio.BuscarPorId(id);

                editarDatosEnForm(pedidoEditado, id);
            }

            if (e.CommandName == "cmdVer")
            {
                contieneFormUC.Visible = false;

                panelVerPedido.Visible = true;

                lblPedido.Text = PedidoServicio.VerPedido(id);
            }

            if (e.CommandName == "cmdEliminar")
            {
                bool okDelete = PedidoServicio.BorrarPedido(id);
                contieneFormUC.Visible = false;
                panelVerPedido.Visible = false;
                CargarGrillaConPedidos(string.Empty, string.Empty, string.Empty);
            }

            if (e.CommandName == "cmdCambiar")
            {
                bool okDelete = PedidoServicio.CambiarEstado(id);
                contieneFormUC.Visible = false;
                panelVerPedido.Visible = false;
                CargarGrillaConPedidos(string.Empty, string.Empty, string.Empty);
            }
        }