コード例 #1
0
        private void CargarGrillaConPedidos(string fecha, string cliente, string estado)
        {
            var losPedidos = PedidoServicio.ObtenerPedidos(fecha, cliente, estado); /// trae todos los pedidos sin filtros

            grdPedidos.DataSource = losPedidos;
            grdPedidos.DataBind();
        }
コード例 #2
0
        public ActionResult EliminarPedido(int pedidoId)
        {
            PedidoServicio PS     = new PedidoServicio();
            Pedido         pedido = new Pedido();

            PS.EliminarPedido(pedidoId);
            //return View("Pedidos", pedido);
            return(RedirectToAction("Pedidos"));
        }
コード例 #3
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);
            }
        }
コード例 #4
0
        protected void btnRegistrar_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                var menuElegido   = ddlMenues.SelectedItem;
                var bebidaElegida = ddlBebidas.SelectedItem;
                var postreElegido = ddlPostres.SelectedItem;
                int id            = int.Parse(hideID.Value);

                PedidoServicio.PedidoFormulario pedidoForm = new PedidoServicio.PedidoFormulario();
                pedidoForm.id           = id;
                pedidoForm.fecha        = txtFecha.Text;
                pedidoForm.cliente      = txtCliente.Text;
                pedidoForm.menu         = menuElegido.Text;
                pedidoForm.menuPrecio   = txtPrecioMenu.Text;
                pedidoForm.bebida       = bebidaElegida.Text;
                pedidoForm.bebidaprecio = txtPrecioBebida.Text;
                pedidoForm.postre       = postreElegido.Text;
                pedidoForm.postreprecio = txtPrecioPostre.Text;
                pedidoForm.formapago    = rdFormaPago.SelectedValue;

                var accion = PedidoServicio.Actualizar(pedidoForm);
                if (accion)
                {
                    //sets the message and the type of alert, than displays the message
                    labelMessage.Text = "El pedido se ha actualizado correctamente";
                    Message.CssClass  = string.Format("alert alert-{0} alert-dismissable", "success");
                    Message.Attributes.Add("role", "alert");
                    Message.Visible = true;
                    LimpiarFormulario();
                    if (id > 0)
                    {
                        Page.Response.Redirect(Page.Request.Url.ToString(), true);
                    }
                }
                else
                {
                    labelMessage.Text = "Ha ocurrido un error al intentar actualizar el pedido";
                    Message.CssClass  = string.Format("alert alert-{0} alert-dismissable", "danger");
                    Message.Attributes.Add("role", "alert");
                    Message.Visible = true;
                }
            }
        }
コード例 #5
0
 private void CargarFiltros()
 {
     Filtros(ddlEstadoFiltro, PedidoServicio.ObtenerFiltrosEstados());
     Filtros(ddlFechaFiltro, PedidoServicio.ObtenerFiltrosFecha());
     Filtros(ddlClienteFiltro, PedidoServicio.ObtenerFiltrosCliente());
 }
コード例 #6
0
        private void MostrarPedidos()
        {
            PedidoServicio NuevoCA = new PedidoServicio();

            dtPedidos.DataSource = NuevoCA.MostrarPedidos();
        }