private async void dgDetalle_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                pedidoActual = (DetallePedidoBLL)dgDetalle.SelectedItem;
                switch (await this.ShowMessageAsync("Atencion", "¿Quiere exportar este detalle del Pedido N°: " + pedidoActual.IdPedido + " ?", MessageDialogStyle.AffirmativeAndNegative))
                {
                case MessageDialogResult.Affirmative:
                    indice   = ListaDetallePedidos.IndexOf(pedidoActual);
                    idPedido = pedidoActual.IdPedido;
                    cboProductos.SelectedValue = pedidoActual.IdProducto;
                    cboEstado.SelectedValue    = pedidoActual.Estado;
                    txtCantidadDetalle.Text    = pedidoActual.Cantidad.ToString();
                    // Comentario irá en el check
                    await this.ShowMessageAsync("Informacion", "Datos Cargados.");

                    break;

                case MessageDialogResult.Negative:
                    await this.ShowMessageAsync("Informacion", "Accion cancelada.");

                    break;
                }
            }
            catch (Exception ex)
            {
                await this.ShowMessageAsync("Error", "Lo sentimos ha ocurrido un error. \n Error: " + ex.Message, style : MessageDialogStyle.Affirmative);
            }
        }
        public ActionResult NuevoPedido(PedidoView pedidoView)
        {
            pedidoView = Session["PedidoView"] as PedidoView;
            var      id            = int.Parse(Request["idcliente"]);
            DateTime dateEjecucion = Convert.ToDateTime(Request["FechaPedido"]);
            string   costo         = Request["Costo"];
            Pedido   pedido        = new Pedido
            {
                fechaEjecucion = dateEjecucion,
                idcliente      = id,
                costo          = Convert.ToDecimal(costo)
            };

            PedidoBLL.Create(pedido);
            int ultimoPedido = PedidoBLL.List().Select(x => x.idpedido).Max();

            foreach (Servicio item in pedidoView.Servicios)
            {
                var detalle = new DetallePedido()
                {
                    idpedido   = ultimoPedido,
                    idservicio = item.idservicio
                };
                DetallePedidoBLL.Create(detalle);
            }
            pedidoView        = Session["PedidoView"] as PedidoView;
            ViewBag.idcliente = new SelectList(ClienteBLL.ListToNames(), "idcliente", "nombre");
            return(RedirectToAction("Index"));
        }
Exemple #3
0
        private async void btnRechazar_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                switch (await this.ShowMessageAsync("Informacion", "¿Esta seguro de los cambios?", MessageDialogStyle.AffirmativeAndNegative))
                {
                case MessageDialogResult.Affirmative:
                    detalleActual.Estado = EstadoPedido.Rechazado;
                    detalleActual.modificar();
                    await this.ShowMessageAsync("Informacion", "Cambios guardados");

                    break;

                case MessageDialogResult.Negative:
                    await this.ShowMessageAsync("Informacion", "Cambios cancelados");

                    break;
                }

                ListarDatos();

                detalleActual = null;
            }
            catch (Exception ex)
            {
                await this.ShowMessageAsync("Error", ex.Message);
            }
        }
        private async void btnAddRow_Click(object sender, RoutedEventArgs e)
        {
            DetallePedidoBLL detalleNuevo = new DetallePedidoBLL();

            try
            {
                if (string.IsNullOrEmpty(rutEmpleado))
                {
                    // si esta vacio es porque es un nuevo pedido
                    detalleNuevo.IdPedido    = idPedido;
                    detalleNuevo.IdProducto  = long.Parse(cboProductos.SelectedValue.ToString());
                    detalleNuevo.RutEmpleado = cboEmpleado.SelectedValue.ToString();
                    detalleNuevo.Cantidad    = int.Parse(txtCantidadDetalle.Text);
                    detalleNuevo.Estado      = (EstadoPedido)cboEstado.SelectedValue;
                    detalleNuevo.Comentario  = " ";
                    totalPedido         = totalPedido + int.Parse(txtPrecio.Text);
                    txtTotalPedido.Text = totalPedido.ToString();
                    ListaDetallePedidos.Add(detalleNuevo);
                }
                else
                {
                    if (rutEmpleado == cboEmpleado.SelectedValue.ToString())
                    {
                        detalleNuevo.IdPedido    = idPedido;
                        detalleNuevo.IdProducto  = long.Parse(cboProductos.SelectedValue.ToString());
                        detalleNuevo.RutEmpleado = cboEmpleado.SelectedValue.ToString();
                        detalleNuevo.Cantidad    = int.Parse(txtCantidadDetalle.Text);
                        detalleNuevo.Estado      = (EstadoPedido)cboEstado.SelectedValue;
                        detalleNuevo.Comentario  = " ";
                        totalPedido         = totalPedido + int.Parse(txtPrecio.Text);
                        txtTotalPedido.Text = totalPedido.ToString();
                        ListaDetallePedidos.Add(detalleNuevo);
                    }
                    else
                    {
                        string comentario = " ";
                        detalleNuevo.IdPedido    = idPedido;
                        detalleNuevo.IdProducto  = long.Parse(cboProductos.SelectedValue.ToString());
                        detalleNuevo.RutEmpleado = pedidoActual.RutEmpleado;
                        detalleNuevo.Cantidad    = int.Parse(txtCantidadDetalle.Text);
                        detalleNuevo.Estado      = (EstadoPedido)cboEstado.SelectedValue;
                        detalleNuevo.Comentario  = comentario;
                        totalPedido         = totalPedido + int.Parse(txtPrecio.Text);
                        txtTotalPedido.Text = totalPedido.ToString();
                        ListaDetallePedidos.Add(detalleNuevo);
                    }
                }



                await this.ShowMessageAsync("Información", "El detalle ha sido registrado");
            }
            catch (Exception ex)
            {
                await this.ShowMessageAsync("Información", "Error: " + ex.Message);
            }
            limpiarDetalle();
            dgDetalle.ItemsSource = null;
            dgDetalle.ItemsSource = ListaDetallePedidos;
        }
        private void ListarDetalleProducto(int idpedidofk, string rutEmpleado)
        {
            List <DetallePedidoBLL> listaDetallepedido = new DetallePedidoBLL().listar();
            var listaDetalle = (from dt in listaDetallepedido
                                where dt.IdPedido == idpedidofk
                                select dt).ToList();

            ListaDetallePedidos   = listaDetalle;
            dgDetalle.ItemsSource = listaDetalle;
        }
Exemple #6
0
 public ActionResult Edit([Bind(Include = "idDetPedido,cantidad,subtotal,recargaentrega,iva,total,idPedido,idProducto")] DetallePedido detallePedido)
 {
     if (ModelState.IsValid)
     {
         DetallePedidoBLL.Update(detallePedido);
         return(RedirectToAction("Index"));
     }
     ViewBag.idPedido   = new SelectList(PedidoBLL.List(), "idPedido", "estadopedido", detallePedido.idPedido);
     ViewBag.idProducto = new SelectList(ProductoBLL.List(), "idProducto", "nombre", detallePedido.idProducto);
     return(View(detallePedido));
 }
Exemple #7
0
 public IHttpActionResult Put(DetallePedido detalle)
 {
     try
     {
         DetallePedidoBLL.Update(detalle);
         return(Content(HttpStatusCode.OK, "DetallePedido actualizado correctamente"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemple #8
0
        /*public IHttpActionResult Put(DetallePedido detalle)
         * {
         *  try
         *  {
         *      DetallePedidoBLL.Update(detalle);
         *      return Content(HttpStatusCode.OK, "DetallePedido actualizado correctamente");
         *
         *  }
         *  catch (Exception ex)
         *  {
         *      return BadRequest(ex.Message);
         *  }
         * }*/

        public IHttpActionResult Get()
        {
            try
            {
                List <DetallePedido> todos = DetallePedidoBLL.List();
                return(Content(HttpStatusCode.OK, todos));
            }
            catch (Exception ex)
            {
                return(Content(HttpStatusCode.BadRequest, ex));
            }
        }
Exemple #9
0
 public IHttpActionResult Post(DetallePedido detalle)
 {
     try
     {
         DetallePedidoBLL.Create(detalle);
         return(Content(HttpStatusCode.Created, "Detalle creado correctamente"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
Exemple #10
0
 public IHttpActionResult Delete(int id)
 {
     try
     {
         DetallePedidoBLL.Delete(id);
         return(Ok("DetallePedido eliminado correctamente"));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
Exemple #11
0
        // GET: DetallePedidos/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DetallePedido detallePedido = DetallePedidoBLL.Get(id);

            if (detallePedido == null)
            {
                return(HttpNotFound());
            }
            return(View(detallePedido));
        }
Exemple #12
0
        private async void dgDetalle_MouseDoubleClick(object sender, MouseButtonEventArgs e)
        {
            try
            {
                detalleActual = (DetallePedidoBLL)dgDetalle.SelectedItem;
                await this.ShowMessageAsync("Atencion", "Ha seleccionado el producto N° " + detalleActual.IdProducto + ".");

                //ActivarBotones();
            }
            catch (Exception)
            {
                await this.ShowMessageAsync("Informacion", "No ha seleccionado ningun producto");
            }
        }
Exemple #13
0
 public IHttpActionResult Get(int id)
 {
     try
     {
         DetallePedido result = DetallePedidoBLL.Get(id);
         if (result == null)
         {
             return(NotFound());
         }
         return(Content(HttpStatusCode.OK, result));
     }
     catch (Exception ex)
     {
         return(Content(HttpStatusCode.BadRequest, ex));
     }
 }
Exemple #14
0
 private void cboPedido_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     try
     {
         int id = int.Parse(cboPedido.SelectedItem.ToString());
         // carga la tabla con detalle de pedido segun el combo
         var listaDetalle = new DetallePedidoBLL().listar();
         var segunId      = (from detalle in listaDetalle
                             where detalle.IdPedido == id & detalle.Estado != EstadoPedido.Finalizado
                             select detalle).ToList();
         dgDetalle.ItemsSource = segunId;
     }
     catch (Exception)
     {
     }
 }
Exemple #15
0
        // GET: DetallePedidos/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            DetallePedido detallePedido = DetallePedidoBLL.Get(id);

            if (detallePedido == null)
            {
                return(HttpNotFound());
            }
            ViewBag.idPedido   = new SelectList(PedidoBLL.List(), "idPedido", "estadopedido", detallePedido.idPedido);
            ViewBag.idProducto = new SelectList(ProductoBLL.List(), "idProducto", "nombre", detallePedido.idProducto);
            return(View(detallePedido));
        }
Exemple #16
0
        private void ListarDatos()
        {
            // se carga el combo box segun rut empleado activo
            List <int> listaIdPedido = new List <int>();

            listaIdPedido           = new PedidoBLL().listarid(Data.RutEmpleadoActivo);
            cboPedido.ItemsSource   = listaIdPedido;
            cboPedido.SelectedIndex = 0;

            int id = int.Parse(cboPedido.SelectedItem.ToString());
            // carga la tabla con detalle de pedido segun el combo
            var listaDetalle = new DetallePedidoBLL().listar();
            var segunId      = (from detalle in listaDetalle
                                where detalle.IdPedido == id & detalle.Estado != EstadoPedido.Finalizado
                                select detalle).ToList();

            dgDetalle.ItemsSource = segunId;
        }
Exemple #17
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                if (txtComentario.IsEnabled == false)
                {
                    txtComentario.IsEnabled = true;
                    await this.ShowMessageAsync("Informacion", "Ahora puede agregar un comentario.");
                }
                else
                {
                    switch (await this.ShowMessageAsync("Informacion", "¿Esta seguro de los cambios?", MessageDialogStyle.AffirmativeAndNegative))
                    {
                    case MessageDialogResult.Affirmative:
                        detalleActual.Comentario = txtComentario.Text;
                        detalleActual.Estado     = EstadoPedido.Rechazado;
                        detalleActual.modificar();
                        await this.ShowMessageAsync("Informacion", "Detalle mofidicado.");

                        txtComentario.IsEnabled = false;
                        txtComentario.Text      = string.Empty;
                        ListarDatos();
                        detalleActual = null;
                        break;

                    case MessageDialogResult.Negative:
                        await this.ShowMessageAsync("Informacion", "Cambios cancelados.");

                        txtComentario.Text      = string.Empty;
                        txtComentario.IsEnabled = false;
                        break;
                    }
                }
            }
            catch (Exception)
            {
                await this.ShowMessageAsync("Informacion", "No ha seleccionado ningun producto");
            }
        }
Exemple #18
0
        private async void btnAceptardetalle_Click(object sender, RoutedEventArgs e)
        {
            try
            {
                switch (await this.ShowMessageAsync("Informacion", "¿Esta seguro de los cambios?", MessageDialogStyle.AffirmativeAndNegative))
                {
                case MessageDialogResult.Affirmative:
                    ProductoBLL producto = (from pr in new ProductoBLL().ListarTodo()
                                            where pr.Id_producto == detalleActual.IdProducto
                                            select pr).FirstOrDefault();
                    if (detalleActual.Estado != EstadoPedido.Finalizado)
                    {
                        producto.Stock_produc = producto.Stock_produc + detalleActual.Cantidad;
                        producto.Modificar();
                        detalleActual.Estado = EstadoPedido.Finalizado;
                        detalleActual.modificar();
                        await this.ShowMessageAsync("Informacion", "Cambios guardados");
                    }
                    break;

                case MessageDialogResult.Negative:
                    await this.ShowMessageAsync("Informacion", "Cambios cancelados");

                    break;
                }



                detalleActual = null;
                ListarDatos();
            }
            catch (Exception ex)
            {
                await this.ShowMessageAsync("Error", ex.Message);
            }
        }
Exemple #19
0
        public IHttpActionResult Get()
        {
            List <DetallePedido> todos = DetallePedidoBLL.List();

            return(Json(todos));
        }
        private async void btnEditarDetalle_Click(object sender, RoutedEventArgs e)
        {
            // se puede modificar un pedido una vez hecho?
            DetallePedidoBLL editar = new DetallePedidoBLL();

            try
            {
                if (idPedido.Equals(0))
                {
                    // throw new Exception("Seleccione un pedido antes de agregar un detalle");
                }
                switch (await this.ShowMessageAsync("Información", "¿Está seguro que desea modificar este detalle?", MessageDialogStyle.AffirmativeAndNegative))
                {
                case MessageDialogResult.Negative:
                    await this.ShowMessageAsync("Información", "Acción cancelada.");

                    break;

                case MessageDialogResult.Affirmative:

                    if (rutEmpleado == cboEmpleado.SelectedValue.ToString())
                    {
                        editar.IdPedido    = idPedido;
                        editar.IdProducto  = long.Parse(cboProductos.SelectedValue.ToString());
                        editar.RutEmpleado = cboEmpleado.SelectedValue.ToString();
                        editar.Cantidad    = int.Parse(txtCantidadDetalle.Text);
                        editar.Estado      = (EstadoPedido)cboEstado.SelectedValue;
                        editar.Comentario  = " ";

                        ListaDetallePedidos.RemoveAt(indice);
                        ListaDetallePedidos.Insert(indice, editar);


                        editar.modificar();
                    }
                    else
                    {
                        string comentario = " ";
                        editar.IdPedido    = idPedido;
                        editar.IdProducto  = long.Parse(cboProductos.SelectedValue.ToString());
                        editar.RutEmpleado = rutEmpleado;
                        editar.Cantidad    = int.Parse(txtCantidadDetalle.Text);
                        editar.Estado      = (EstadoPedido)cboEstado.SelectedValue;
                        editar.Comentario  = comentario;

                        ListaDetallePedidos.RemoveAt(indice);
                        ListaDetallePedidos.Insert(indice, editar);

                        totalPedido         = totalPedido - int.Parse(txtPrecio.Text);
                        txtTotalPedido.Text = totalPedido.ToString();
                        // detalle compra
                        editar.modificar();
                    }

                    await this.ShowMessageAsync("Información", "El detalle ha sido modificado");

                    break;
                }
            }

            catch (Exception ex)
            {
                await this.ShowMessageAsync("Información", "Error: " + ex.Message);
            }
            dgDetalle.ItemsSource = null;
            dgDetalle.ItemsSource = ListaDetallePedidos;
            limpiarDetalle();
        }
Exemple #21
0
 public ActionResult DeleteConfirmed(int id)
 {
     DetallePedidoBLL.Delete(id);
     return(RedirectToAction("Index"));
 }
Exemple #22
0
 // GET: DetallePedidos
 public ActionResult Index()
 {
     return(View(DetallePedidoBLL.List()));
 }