public ActionResult Crear(DetallePedido nuevoDetallePedido, int NroPedido, int CodMedicamento)
 {
     var proxy = new TransaccionClient();
     var nropedido = proxy.ObtenerPedido(NroPedido);
     //nuevoDetallePedido.NroPedido = nropedido;
     var codmedicament = proxy.ObtenerMedicamentos(CodMedicamento);
     //nuevoDetallePedido.CodMedicamento = codmedicament;
     proxy.CrearDetallePedido(nuevoDetallePedido);
     return RedirectToAction("Index");
 }
        public DetallePedido FindById(DetallePedido dp)
        {
            DetallePedido detallePedido = null;

            try
            {
                using (var conexion = new SqlConnection(ConfigurationManager.ConnectionStrings["ALaOrden"].ToString()))
                {
                    conexion.Open();
                    var query = new SqlCommand("select dp.idPedido ,dp.precio as CantidadPrecio,dp.cantidad as CantidadDetalle,p.idProducto,p.nombre as NombreProducto,p.presentacion as PresentacionProducto,p.cantidad as CantidadProducto,p.Magnitud as MagnitudProducto,p.unidad as UnidadProducto,p.descripcion as DescripcionProducto,p.imagen as ImagenProducto,c.idCategoria, c.nombre as NombreCategoria,m.idMarca,m.nombre as NombreMarca from Marca m ,Categoria c, Producto p,DetallePedido dp where p.idMarca = m.idMarca and p.idCategoria = c.idCategoria and dp.idProducto = p.idProducto and dp.idPedido = @idPedido and dp.idProducto = @idProducto", conexion);
                    query.Parameters.AddWithValue("@idPedido", dp.IdPedido);
                    query.Parameters.AddWithValue("@idProducot", dp.Producto.IdProducto);
                    using (var dr = query.ExecuteReader())
                    {
                        while (dr.Read())
                        {
                            detallePedido = new DetallePedido();
                            Producto  producto  = new Producto();
                            Marca     marca     = new Marca();
                            Categoria categoria = new Categoria();

                            producto.IdProducto   = Convert.ToInt32(dr["idProducto"]);
                            producto.Nombre       = dr["NombreProducto"].ToString();
                            producto.Presentacion = dr["PresentacionProducto"].ToString();
                            producto.Descripcion  = dr["DescripcionProducto"].ToString();
                            producto.Cantidad     = Convert.ToInt32(dr["CantidadProducto"]);
                            producto.Unidad       = dr["UnidadProducto"].ToString();
                            producto.Magnitud     = Convert.ToDouble(dr["MagnitudProducto"]);

                            categoria.IdCategoria = Convert.ToInt32(dr["idCategoria"]);
                            categoria.Nombre      = dr["NombreCategoria"].ToString();

                            marca.IdMarca = Convert.ToInt32(dr["idMarca"]);
                            marca.Nombre  = dr["NombreMarca"].ToString();

                            producto.Marca     = marca;
                            producto.Categoria = categoria;

                            detallePedido.IdPedido = Convert.ToInt32(dr["idPedido"]);
                            detallePedido.Precio   = Convert.ToDouble(dr["precio"]);
                            detallePedido.Cantidad = Convert.ToInt32(dr["cantidad"]);

                            detallePedido.Producto = producto;
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }


            return(detallePedido);
        }
示例#3
0
        public IActionResult PostDetallePedido([FromBody] DetallePedido detallePedido)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            detallePedidoService.Save(detallePedido);

            return(CreatedAtAction("GetDetallePedido", new { IdPedido = detallePedido.Pedido.IdPedido, IdProducto = detallePedido.Producto.IdProducto }, detallePedido));
        }
示例#4
0
 public bool Existe(DetallePedido dp)
 {
     foreach (DetallePedido dep in DetallePedidos)
     {
         if (dep.Producto.IdProducto == dp.Producto.IdProducto)
         {
             return(true);
         }
     }
     return(false);
 }
示例#5
0
 public List <DetallePedido> GetDetallePedidos(DetallePedido detallePedido)
 {
     try
     {
     }
     catch (Exception ex)
     {
         throw ex;
     }
     return(null);
 }
        public ActionResult Edit(int p, int pr)
        {
            DetallePedido dp       = new DetallePedido();
            Producto      producto = new Producto();

            dp.IdPedido         = p;
            producto.IdProducto = pr;
            dp.Producto         = producto;
            ViewBag.productos   = servicioProducto.GetAll();
            return(View(servicioDetallePedido.FindById(dp)));
        }
示例#7
0
        void AgregarDetalles()
        {
            if (idDetallePedidoAEditar != null)
            {
                foreach (DetallePedido detalle in listadoDetallesPedido.Where(x => x.Id == idDetallePedidoAEditar))
                {
                    detalle.IdProducto     = producto.Id;
                    detalle.Producto       = producto.Nombre;
                    detalle.Descripcion    = producto.Descripcion;
                    detalle.Cantidad       = ushort.Parse(nudCantidad.Text);
                    detalle.PrecioUnitario = producto.PrecioVenta;
                    detalle.SubTotal       = ushort.Parse(nudCantidad.Text) * producto.PrecioVenta;
                    detalle.Estado         = cmbEstadoDetallePedido.SelectedItem.ToString();
                }
                ActualizarDatagridView();
                LimpiarDetalles();
                btnAgregarDetalle.Text = "Agregar detalle";
            }

            else
            {
                DetallePedido detallePedidoAAgregar = new DetallePedido();
                detallePedidoAAgregar.IdProducto     = producto.Id;
                detallePedidoAAgregar.Producto       = producto.Nombre;
                detallePedidoAAgregar.Descripcion    = producto.Descripcion;
                detallePedidoAAgregar.Cantidad       = ushort.Parse(nudCantidad.Text);
                detallePedidoAAgregar.PrecioUnitario = producto.PrecioVenta;
                detallePedidoAAgregar.SubTotal       = ushort.Parse(nudCantidad.Text) * producto.PrecioVenta;
                detallePedidoAAgregar.Estado         = cmbEstadoDetallePedido.SelectedItem.ToString();
                int idUltimoDetalle;
                if (listadoDetallesPedido.Count >= 1)
                {
                    idUltimoDetalle = listadoDetallesPedido[listadoDetallesPedido.Count - 1].Id;
                }
                else
                {
                    idUltimoDetalle = 0;
                }
                detallePedidoAAgregar.Id = idUltimoDetalle + 1;
                if (listadoDetallesPedido.Exists(x => x.IdProducto == detallePedidoAAgregar.IdProducto))
                {
                    MetroMessageBox.Show(this, "Ya agregó este producto a la lista.", "¡Aviso!", MessageBoxButtons.OK, MessageBoxIcon.Warning,
                                         MessageBoxDefaultButton.Button1);
                    nudCantidad.ResetText();
                    nudCantidad.Focus();
                }
                else
                {
                    listadoDetallesPedido.Add(detallePedidoAAgregar);
                    CargarListadoDetalles();
                    LimpiarDetalles();
                }
            }
        }
        public IHttpActionResult GetDetallePedido(int id)
        {
            DetallePedido detallePedido = db.DetallePedidoes.Find(id);

            if (detallePedido == null)
            {
                return(NotFound());
            }

            return(Ok(detallePedido));
        }
示例#9
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));
 }
示例#10
0
 public ActionResult Edit([Bind(Include = "iddetalle,idpedido,idservicio")] DetallePedido detallePedido)
 {
     if (ModelState.IsValid)
     {
         db.Entry(detallePedido).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.idpedido   = new SelectList(db.Pedidoes, "idpedido", "estado", detallePedido.idpedido);
     ViewBag.idservicio = new SelectList(db.Servicios, "idservicio", "nombre", detallePedido.idservicio);
     return(View(detallePedido));
 }
示例#11
0
        private void ActualizarStockFarmacia(Pedido pedido, DetallePedido item)
        {
            StockFarmacia insumo = db.StockFarmacias.Where(p => p.hospitalId == pedido.hospitalId &&
                                                           p.insumoId == item.insumoId).First();

            if (insumo != null)
            {
                insumo.stockFarmacia   = insumo.stockFarmacia + item.cantidadAutorizada;
                db.Entry(insumo).State = EntityState.Modified;
            }
            //TODO: Si el insumo no existe se deberia insertar en la BD
        }
示例#12
0
 public ActionResult Edit([Bind(Include = "IdDetalle,IdMenu,IdPedido")] DetallePedido detallePedido)
 {
     if (ModelState.IsValid)
     {
         db.Entry(detallePedido).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdMenu   = new SelectList(db.Menus, "IdMenu", "Nombre", detallePedido.IdMenu);
     ViewBag.IdPedido = new SelectList(db.Pedido, "IdPedido", "Cliente", detallePedido.IdPedido);
     return(View(detallePedido));
 }
 public async Task<IActionResult> Create([Bind("CodDetalle,CantidadDetalle,PrecioTotalDetalle,DetallePedidoFinalizado,PedidoFk,ModeloProductoFk,Digitador,FechaDigitador")] DetallePedido detallePedido)
 {
     if (ModelState.IsValid)
     {
         _context.Add(detallePedido);
         await _context.SaveChangesAsync();
         return RedirectToAction(nameof(Index));
     }
     ViewData["ModeloProductoFk"] = new SelectList(_context.ModeloProducto, "CodEstructuraMateria", "CodEstructuraMateria", detallePedido.ModeloProductoFk);
     ViewData["PedidoFk"] = new SelectList(_context.Pedido, "NumeroOrdenCompra", "NumeroOrdenCompra", detallePedido.PedidoFk);
     return View(detallePedido);
 }
        public async Task <IActionResult> Create([Bind("idDetallePedido,idOrdenPedido,idInventario,cantidad")] DetallePedido detallePedido)
        {
            if (ModelState.IsValid)
            {
                _context.Add(detallePedido);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["idInventario"] = new SelectList(_context.Inventario, "IdInventario", "IdInventario", detallePedido.idInventario);
            return(View(detallePedido));
        }
示例#15
0
 public IActionResult Editar(int id, [FromBody] DetallePedido datos)
 {
     if (repositorio.PorId(id) is DetallePedido)
     {
         datos.Id = id;
         if (repositorio.Editar(datos))
         {
             return(Accepted());
         }
     }
     return(BadRequest());
 }
示例#16
0
 public IHttpActionResult Put(DetallePedido detalle)
 {
     try
     {
         DetallePedidoBLL.Update(detalle);
         return(Content(HttpStatusCode.OK, "DetallePedido actualizado correctamente"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#17
0
 public IHttpActionResult Post(DetallePedido detalle)
 {
     try
     {
         DetallePedidoBLL.Create(detalle);
         return(Content(HttpStatusCode.Created, "Detalle creado correctamente"));
     }
     catch (Exception ex)
     {
         return(BadRequest(ex.Message));
     }
 }
示例#18
0
 public ActionResult Edit([Bind(Include = "id_dped,id_ped,id_art,cantidad_dped")] DetallePedido detallePedido)
 {
     if (ModelState.IsValid)
     {
         db.Entry(detallePedido).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.id_art = new SelectList(db.Articulo, "id_art", "nombre_art", detallePedido.id_art);
     ViewBag.id_ped = new SelectList(db.Pedido, "id_ped", "id_ped", detallePedido.id_ped);
     return(View(detallePedido));
 }
 public ActionResult Edit(DetallePedido detallepedido)
 {
     if (ModelState.IsValid)
     {
         db.Entry(detallepedido).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.IdPedido   = new SelectList(db.Pedidos, "Id", "Id", detallepedido.IdPedido);
     ViewBag.IdProducto = new SelectList(db.Productos, "Id", "Nombre", detallepedido.IdProducto);
     return(View(detallepedido));
 }
示例#20
0
        public ActionResult delete_Detalle(int id)
        {
            DetallePedido detalle = db.DetallePedido.ToList().Find(p => p.Id == id);

            if (detalle != null)
            {
                db.DetallePedido.Remove(detalle);
                db.SaveChanges();
            }

            return(Json(detalle, JsonRequestBehavior.AllowGet));
        }
        //
        // GET: /DetallesPedidos/Edit/5

        public ActionResult Edit(int id = 0)
        {
            DetallePedido detallepedido = db.DetallePedido.Find(id);

            if (detallepedido == null)
            {
                return(HttpNotFound());
            }
            ViewBag.IdPedido   = new SelectList(db.Pedidos, "Id", "Id", detallepedido.IdPedido);
            ViewBag.IdProducto = new SelectList(db.Productos, "Id", "Nombre", detallepedido.IdProducto);
            return(View(detallepedido));
        }
示例#22
0
        public static DetallePedido MapToEntity(DtoDetallePedido dto)
        {
            DetallePedido entity = new DetallePedido();

            entity.CantidadPreparar = dto.CantidadPreparar;
            entity.idPedido         = dto.idPedido;
            entity.idProducto       = dto.idProducto;
            entity.PrecioU          = dto.PrecioU;
            entity.UbicacionPro     = dto.UbicacionPro;

            return(entity);
        }
示例#23
0
        public static DtoDetallePedido MapToDto(DetallePedido entity)
        {
            DtoDetallePedido dto = new DtoDetallePedido();

            dto.CantidadPreparar = entity.CantidadPreparar;
            dto.idPedido         = entity.idPedido;
            dto.idProducto       = entity.idProducto;
            dto.PrecioU          = entity.PrecioU;
            dto.UbicacionPro     = entity.UbicacionPro;

            return(dto);
        }
示例#24
0
        public IHttpActionResult PutMesas(Mesas mesas)

        {
            /* if (!ModelState.IsValid)
             * {
             *   return BadRequest(ModelState);
             * }*/

            if (mesas == null)
            {
                return(NotFound());
            }

            Pedido pd = (from p in db.Pedidoes where p.IdMesa == mesas.IdMesa select p).FirstOrDefault();
            //pd.FirstOrDefault();
            DetallePedido pd2 = (from pp in db.DetallePedidoes where pp.IdPedido == pd.IdPedido select pp).FirstOrDefault();

            var mesaId = from m in db.Mesas
                         where m.IdMesa == mesas.IdMesa
                         select m;

            if (pd2 != null)
            {
                return(NotFound());
            }

            if (mesaId.FirstOrDefault().IdMesa != mesas.IdMesa)
            {
                return(BadRequest());
            }
            mesas.NumMesa = mesas.NumMesa.Replace("Mesa ", "");
            db.Set <Mesas>().AddOrUpdate(mesas);
            //db.Entry(mesas).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!MesasExists(mesaId.FirstOrDefault().IdMesa))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
示例#25
0
        public ActionResult EliminarCarrito(int id)
        {
            DetallePedido dp = new DetallePedido
            {
                Producto = new Producto
                {
                    IdProducto = id
                }
            };

            carrito.DeleteDetalle(dp);
            return(RedirectToAction("Carrito"));
        }
        public async Task <IActionResult> Create([Bind("DetallePedidoID,ProductoID,PedidoID,Cantidad,Precio,Total,Estado")] DetallePedido detallePedido)
        {
            if (ModelState.IsValid)
            {
                _context.Add(detallePedido);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["PedidoID"]   = new SelectList(_context.Pedido, "PedidoID", "PedidoID", detallePedido.PedidoID);
            ViewData["ProductoID"] = new SelectList(_context.Producto, "ProductoID", "NombreProducto", detallePedido.ProductoID);
            return(View(detallePedido));
        }
        public ActionResult Delete(int p, int pr)
        {
            if (p != 0 && pr != 0)
            {
                DetallePedido dp = new DetallePedido();
                dp.IdPedido            = p;
                dp.Producto.IdProducto = pr;
                servicioDetallePedido.Delete(dp);
                return(RedirectToAction("Index", new { id = p }));
            }

            return(RedirectToAction("Index"));
        }
示例#28
0
        public ICollection <DetallePedido> getPlatosSeleccionado()
        {
            List <DetallePedido> details = new List <DetallePedido>();

            foreach (Platos platos in managerPlatos.getPlatosSeleccionado())
            {
                DetallePedido detail = new DetallePedido();
                detail.Cantidad = 1;
                detail.Platos   = platos;
                details.Add(detail);
            }
            return(details);
        }
示例#29
0
        public IActionResult Delete(int id)
        {
            DetallePedido detalle = repositorio.PorId(id);

            if (detalle is DetallePedido)
            {
                if (repositorio.Eliminar(detalle))
                {
                    return(Accepted());
                }
            }
            return(BadRequest());
        }
示例#30
0
        private void agregarHistoricoSIAH(DetallePedido detalle, DateTime fechaAutorizacion, Pedido pedido, int saldoStock)
        {
            HistoricoSIAH historicoSIAH = new HistoricoSIAH();

            historicoSIAH.insumoId        = detalle.insumoId;
            historicoSIAH.fechaMovimiento = fechaAutorizacion;
            historicoSIAH.descripcion     = "Autorización realizada al Pedido número: " + pedido.id;
            historicoSIAH.cantidad        = detalle.cantidadAutorizada * (-1);
            historicoSIAH.saldo           = saldoStock;
            historicoSIAH.isNegative      = true;

            db.HistoricoSIAH.Add(historicoSIAH);
        }
示例#31
0
        public override void save <T>(T entity)
        {
            try
            {
                DetallePedido detalle = entity as DetallePedido;

                dao.DetallePedidos.InsertOnSubmit(detalle);
            }
            catch (Exception ex)
            {
                throw new Exception("Error al guardar" + ex.Message);
            }
        }
示例#32
0
        public static void actualizarStock(DetallePedido detPedido, SqlConnection con, SqlTransaction trans, Pedido pedido, List<Producto> productosConPocaMP)
        {
            DataTable ProductosIntermedio;
            DataTable MateriaPrima;
            DataTable DetallePlan;
            int idProductoFinal = 0;
            int idProductoIntermedio = 0;
            double cantidad = 0;

            idProductoFinal = detPedido.producto.idProducto;//OBTENEMOS EL ID DEL PRODUCTO FINAL
            cantidad = detPedido.cantidad;//OBTENEMOS LA CANTIDAD DE PRODUCTOS
            if (ProductoDAO.verificarProductoPlanificado(pedido.fechaNecesidad.Date, idProductoFinal, con,trans) == true)//PREGUNTAMOS SI PARA ESE PRODUCTO YA HAY UN DETALLE DEL PLAN PARA ESA FECHA Y ES TRUE
            {
                DetallePlan = DetallePlanProduccionDAO.GetDetallePlanXProducto(idProductoFinal, pedido.fechaNecesidad.Date,con, trans);//OBTENEMOS LOS DATOS DEL DETALLE DEL PLAN

                actualizarDetallePlanYPedidoXPlan(DetallePlan, pedido.idPedido, con, trans, cantidad);

                MateriaPrima = ProductoDAO.GetMateriaPrima(idProductoFinal,trans,con);//CARGAMOS EN LA TABLA LOS DATOS DE LAS MATERIAS PRIMAS
                DataTable MateriaPrimaXIntermedio = new DataTable();
                ProductosIntermedio = ProductoDAO.GetProductoIntermedio(idProductoFinal,con,trans);//CARGAMOS EN LA TABLA LOS DATOS DE LOS PRODUCTOS INTERMEDIO

                obtenerMateriasPrimas(MateriaPrima, MateriaPrimaXIntermedio, ProductosIntermedio, cantidad, idProductoFinal, con, trans, productosConPocaMP);
            }
            else
            {
                if (ProductoDAO.verificarPlanSinProducto(pedido.fechaNecesidad.Date, idProductoFinal, con, trans) == true)//PREGUNTAMOS SI PARA ESE PRODUCTO YA HAY UN DETALLE DEL PLAN PARA ESA FECHA Y ES TRUE
                {
                    Producto prodNuevo = new Producto();
                    prodNuevo.idProducto = idProductoFinal;
                    DetallePlanProduccion detallePlanProduccion = new DetallePlanProduccion()
                    {
                        fechaProduccion = pedido.fechaNecesidad,
                        idPlan = PlanMaestroProduccionDAO.obtenerIdPlan(pedido.fechaNecesidad.Date),
                        cantidadPLan = 0,
                        producto = prodNuevo,
                        cantidadPedido = double.Parse(cantidad.ToString())
                    };

                    cargarNuevoDetallePlanYPedidoXPlan(detallePlanProduccion, con, trans, pedido);

                    MateriaPrima = ProductoDAO.GetMateriaPrima(idProductoFinal,trans,con);//CARGAMOS EN LA TABLA LOS DATOS DE LAS MATERIAS PRIMAS
                    DataTable MateriaPrimaXIntermedio = new DataTable();
                    ProductosIntermedio = ProductoDAO.GetProductoIntermedio(idProductoFinal,con,trans);//CARGAMOS EN LA TABLA LOS DATOS DE LOS PRODUCTOS INTERMEDIO

                    obtenerMateriasPrimas(MateriaPrima, MateriaPrimaXIntermedio, ProductosIntermedio, cantidad, idProductoFinal, con, trans, productosConPocaMP);
                }
            }
        }
        private void dgv_pedidos_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (dgv_pedidos.CurrentCell is DataGridViewButtonCell)
            {
                int idPedido = Convert.ToInt32(dgv_pedidos.Rows[dgv_pedidos.CurrentRow.Index].Cells["idPedido"].Value);
                int estadoDesde = Convert.ToInt32(dgv_pedidos.Rows[dgv_pedidos.CurrentRow.Index].Cells["idestado"].Value);
                int estadoHasta = estadoDesde;

                switch (estadoDesde)
                {
                    case 2:
                        estadoHasta = 5;
                        if (tieneProductosFinalizados())
                        {
                            try
                            {
                                PedidoDAO.UpdateEstados(idPedido, estadoHasta);
                                MessageBox.Show("Fin Preparación ", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                cargarGrilla();
                            }
                            catch (ApplicationException ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Faltan Productos Por Preparar ", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }
                        break;
                    case 5:
                        estadoHasta = 6;

                        //Abrir Interface de Factura

                        int idPed = (int)dgv_pedidos.CurrentRow.Cells["idPedido"].Value;
                        RegistrarFactura factura = new RegistrarFactura();
                        factura._idPedido = idPed;
                        factura.ShowDialog();
                        //Si se registro la factura hacer
                        if (factura._estado==estados.guardado)
                        {
                            try
                            {
                                //PedidoDAO.UpdateEstados(idPedido, estadoHasta);
                                MessageBox.Show("Factura Registrada", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                cargarGrilla();
                            }
                            catch (ApplicationException ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                            }

                            Emitir_Factura fact = new Emitir_Factura();

                            fact.ShowDialog();
                        }

                        break;
                    case 6:
                        estadoHasta = 7;

                        if (pagaronLaFactura(idPedido))
                        {
                            try
                            {

                                for (int i = 0; i < dgv_detalle_pedido.Rows.Count; i++)
                                {
                                    DetallePedido det = new DetallePedido();
                                    det.producto = new Producto() { idProducto = (int)dgv_detalle_pedido.Rows[i].Cells["idProd"].Value };
                                    det.cantidad = (double)dgv_detalle_pedido.Rows[i].Cells["cant"].Value;

                                    ProductoDAO.UpdateStockReservadoYActualdePedidoEntregado(det, idPedido, estadoHasta);
                                }

                                MessageBox.Show("Registro de Entrega Completado ", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                cargarGrilla();
                            }
                            catch (ApplicationException ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                            }
                        }
                        else
                        {
                            MessageBox.Show("Falta el Pago de la Factura ", "Atención", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);
                        }

                        break;

                }
            }
        }
        private void btn_guardar_Click(object sender, EventArgs e)
        {
            int idPedido=0;

            if (dtp_fecha_necesidad.Value.Date >= DateTime.Now.Date)
            {
                if (dgv_detalle.Rows.Count >= 1)
                {
                    List<DetallePedido> detalle = new List<DetallePedido>();

                    for (int c = 0; c < dgv_detalle.RowCount; c++)
                    {
                        DetallePedido de = new DetallePedido();
                        Producto p = new Producto();
                        Estado est = new Estado();

                        p.idProducto = (int)dgv_detalle.Rows[c].Cells["idProductodetalle"].Value;
                        p.precio = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;

                        de.cantidad = Convert.ToDouble(dgv_detalle.Rows[c].Cells["cantidad"].Value);
                        de.precio = (double)dgv_detalle.Rows[c].Cells["preciodetalle"].Value;
                        if (dgv_detalle.Rows[c].Cells["reservado"].Value.ToString() == "NO")
                        {
                            de.reservado = false;
                            de.cantidadReservada = 0;
                            est.idEstado = 26;
                            if (estadoFormulario == estados.modificar && dgv_detalle.Rows[c].Cells["idestado"].Value!=null)
                            {
                                est.idEstado = (int)dgv_detalle.Rows[c].Cells["idestado"].Value;
                            }
                            de.Estado = est;

                        }
                        else {
                            de.reservado = true;
                            de.cantidadReservada = de.cantidad;
                            est.idEstado = 25;
                            de.Estado = est ;
                        }

                        de.producto = p;

                        detalle.Add(de);
                    }
                    if (estadoFormulario == estados.nuevo)
                    {
                        gestor.clienteSeleccionado(resultado);
                        gestor.tomarProductosSeleccionados(detalle);
                        gestor.fechaDeNecesidadTomada(dtp_fecha_necesidad.Value.Date);
                        gestor.dirEntregaTomada(txt_dir_entrega.Text);

                        if(!estanTodosReservados())
                        {
                            gestor.estado(1);
                        }
                        else{
                            gestor.estado(5);
                        }

                        try
                        {
                            List<Producto> productosConPocaMP = new List<Producto>();
                            idPedido = gestor.confirmacionTomada(productosConPocaMP);
                            ////////////// MOSTRAR LOS PRODUCTOS CON BAJO STOCK
                            if (productosConPocaMP.Count > 0)
                            {
                                string mensaje = "";
                                List<Producto> prodConPocoStock = new List<Producto>();
                                Boolean MPRepetida = false;
                                foreach (Producto Prod in productosConPocaMP)
                                {
                                    foreach (Producto P in prodConPocoStock)
                                    {
                                        if (P.idProducto == Prod.idProducto)
                                        {
                                            MPRepetida = true;
                                            break;
                                        }
                                    }
                                    if (MPRepetida == false)
                                    {
                                        mensaje += Environment.NewLine + Prod.Nombre.ToString();
                                        prodConPocoStock.Add(Prod);
                                    }

                                }
                                MessageBox.Show("Los siguientes productos estan con bajo stock: " + mensaje, "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                            }
                            /////////////////////////////////////////////////////////////
                            MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                            limpiarCampos();
                        }
                        catch (ApplicationException ex)
                        {
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                        }
                    }
                    else
                    {
                        if (estadoFormulario == estados.modificar)
                        {
                            //foreach (Producto  pro in productosEliminados )
                            //{

                            //    ProductoDAO.UpdateStockReservadoYDisponibleEliminado(pro.idProducto,pro.cantidadProductos );

                            //}

                            gestor.tomarProductosSeleccionados(detalle);
                            gestor.fechaDeNecesidadTomada(dtp_fecha_necesidad.Value.Date);
                            gestor.dirEntregaTomada(txt_dir_entrega.Text);

                            if (!estanTodosReservados())
                            {
                                gestor.estado(1);
                            }
                            else
                            {
                                gestor.estado(5);
                            }

                            try
                            {

                                List<Producto> productosConPocaMP = new List<Producto>();
                                gestor.modificacionConfirmada(tablaAModificar, productosConPocaMP);
                                ////////////// MOSTRAR LOS PRODUCTOS CON BAJO STOCK
                                if (productosConPocaMP.Count > 0)
                                {
                                    string mensaje = "";
                                    List<Producto> prodConPocoStock = new List<Producto>();
                                    Boolean MPRepetida = false;
                                    foreach (Producto Prod in productosConPocaMP)
                                    {
                                        foreach (Producto P in prodConPocoStock)
                                        {
                                            if (P.idProducto == Prod.idProducto)
                                            {
                                                MPRepetida = true;
                                                break;
                                            }
                                        }
                                        if (MPRepetida == false)
                                        {
                                            mensaje += Environment.NewLine + Prod.Nombre.ToString();
                                            prodConPocoStock.Add(Prod);
                                        }

                                    }
                                    MessageBox.Show("Los siguientes productos estan con bajo stock: " + mensaje, "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                                }
                                /////////////////////////////////////////////////////////////
                                MessageBox.Show("Registrado con Exito", "Exito", MessageBoxButtons.OK, MessageBoxIcon.Information, MessageBoxDefaultButton.Button1);
                                limpiarCampos();
                            }
                            catch (ApplicationException ex)
                            {
                                MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1);
                            }

                        }
                    }
                    cargarGrillaProductos();

                }
                else
                {
                    MessageBox.Show("Agrege productos al pedido", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

                }
            }
            else
            {
                MessageBox.Show("La fecha de necesidad no puede ser anterior a la actual", "Atencion", MessageBoxButtons.OK, MessageBoxIcon.Exclamation, MessageBoxDefaultButton.Button1);

            }
        }
示例#35
0
 public DetallePedido CrearDetallePedido(DetallePedido detallePedido)
 {
     return ObjDetallePedido.Crear(detallePedido);
 }
示例#36
0
 public DetallePedido ModificarDetallePedido(DetallePedido detallePedido)
 {
     return ObjDetallePedido.Modificar(detallePedido);
 }