Esempio n. 1
0
        public bool insertarLineaDePedido(LineaDePedido lineaDePedido, int idPedido)
        {
            MySqlCommand comandoMySQL = new MySqlCommand("spInsertarLineaDeVenta");
            bool         inserta      = false;

            try
            {
                comandoMySQL = gestorMySQL.obtenerComandoDeProcedimiento(comandoMySQL);
                comandoMySQL.Parameters.AddWithValue("prmIntIdProducto", lineaDePedido.Producto.IdProducto);
                comandoMySQL.Parameters.AddWithValue("prmDoublePrecio", lineaDePedido.PrecioDeVenta);
                comandoMySQL.Parameters.AddWithValue("prmIntCantidad", lineaDePedido.CantidadVendida);
                comandoMySQL.Parameters.AddWithValue("prmIntIdPedido", idPedido);
                int indiceInsertado = comandoMySQL.ExecuteNonQuery();

                if (indiceInsertado > 0)
                {
                    inserta = true;
                }
                return(inserta);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        public void Test2_VentaSimpleConCantidades()
        {
            /*************  Definición *************/

            var cajero = new Cajero("Santiago Martinez", 20 - 35624321 - 0, 00001, 50);
            var pedido = new Pedido(cajero);

            var rubroSand  = new Rubro("Sandwiches");
            var rubroPizza = new Rubro("Pizzas");

            var pro1 = new Producto("Sandwiche de Milanesa", 30, 35.00);
            var pro2 = new Producto("Sandwiche de Lomito", 30, 30.00);

            rubroSand.AgregarAlRubro(pro1);
            rubroSand.AgregarAlRubro(pro2);

            var pro3 = new Producto("Pizza 4 quesos", 10, 40.00);

            rubroPizza.AgregarAlRubro(pro3);

            var linea1 = new LineaDePedido(rubroSand.ListaProductos[0]);
            var linea2 = new LineaDePedido(rubroSand.ListaProductos[1], 3);

            var linea3 = new LineaDePedido(rubroPizza.ListaProductos[0], 2);

            /*************  Ejecución *************/

            pedido.AgregarLineaDeVenta(linea1);
            pedido.AgregarLineaDeVenta(linea2);
            pedido.AgregarLineaDeVenta(linea3);

            /*************  Comprobación *************/

            Assert.AreEqual(pedido.Total, 205);
        }
        public void Test3_VentaConAgregados()
        {
            /*************  Definición *************/

            var cajero = new Cajero("Santiago Martinez", 20 - 35624321 - 0, 00001, 50);
            var pedido = new Pedido(cajero);

            var rubroAgreg = new Rubro("Agregados");
            var rubroSand  = new Rubro("Sandwiches");
            var rubroPizza = new Rubro("Pizzas");

            var Agreg1 = new Producto("Lechuga", null, 0, true);
            var Agreg2 = new Producto("Tomate", null, 0, true);
            var Agreg3 = new Producto("Huevo Frito", 30, 5, true);
            var Agreg4 = new Producto("Jamon", null, 5, true);
            var Agreg5 = new Producto("Aceituna", null, 10, true);

            rubroAgreg.AgregarAlRubro(Agreg1);
            rubroAgreg.AgregarAlRubro(Agreg2);
            rubroAgreg.AgregarAlRubro(Agreg3);
            rubroAgreg.AgregarAlRubro(Agreg4);
            rubroAgreg.AgregarAlRubro(Agreg5);

            var pro1 = new Producto("Sandwiche de Milanesa", 30, 35.00);

            pro1.AgregarAgregado(rubroAgreg.ListaProductos[0]);
            pro1.AgregarAgregado(rubroAgreg.ListaProductos[1]);

            var pro2 = new Producto("Sandwiche de Lomito", 30, 30.00);

            pro2.AgregarAgregado(rubroAgreg.ListaProductos[0]);
            pro2.AgregarAgregado(rubroAgreg.ListaProductos[1]);
            pro2.AgregarAgregado(rubroAgreg.ListaProductos[2]);

            rubroSand.AgregarAlRubro(pro1);
            rubroSand.AgregarAlRubro(pro2);

            var pro3 = new Producto("Pizza 4 quesos", 10, 40.00);

            pro3.AgregarAgregado(rubroAgreg.ListaProductos[3]);
            pro3.AgregarAgregado(rubroAgreg.ListaProductos[4]);

            rubroPizza.AgregarAlRubro(pro3);

            var linea1 = new LineaDePedido(rubroSand.ListaProductos[0]);
            var linea2 = new LineaDePedido(rubroSand.ListaProductos[1], 3);

            var linea3 = new LineaDePedido(rubroPizza.ListaProductos[0], 2);

            /*************  Ejecución *************/

            pedido.AgregarLineaDeVenta(linea1);
            pedido.AgregarLineaDeVenta(linea2);
            pedido.AgregarLineaDeVenta(linea3);

            /*************  Comprobación *************/

            Assert.AreEqual(pedido.Total, 250);
        }
        public PresentadorLineaDeVenta(Pedido ventAct, ILineaDeVenta vista)
        {
            VentaAct    = ventAct;
            LineaActual = VentaAct.CrearLineaDeVenta();

            _vista = vista;

            CargarRubrosYLineaDeVenta();
        }
Esempio n. 5
0
        public List <Pedido> listarPedidosPorCliente(int idCliente)
        {
            MySqlCommand         comandoMySQL        = new MySqlCommand("spListarPedidoPorCliente");
            List <Pedido>        listaPedidos        = new List <Pedido>();
            List <LineaDePedido> listaLineaDePedidos = new List <LineaDePedido>();

            List <MySqlParameter> parametros = new List <MySqlParameter>()
            {
                new MySqlParameter("id_cliente", idCliente),
            };

            try
            {
                MySqlDataReader resultadoMySQL = gestorMySQL.ejecutarComandoDeProcedimientoConParametros(comandoMySQL, parametros);
                Producto        producto       = null;
                Pedido          pedido         = null;
                LineaDePedido   lineaDePedido  = null;
                while (resultadoMySQL.Read())
                {
                    producto = new Producto()
                    {
                        IdProducto = Convert.ToInt32(resultadoMySQL["id_producto"]),
                        Nombre     = resultadoMySQL["nombre"].ToString(),
                        Imagen     = resultadoMySQL["imagen"].ToString(),
                    };
                    lineaDePedido = new LineaDePedido()
                    {
                        CantidadVendida = Convert.ToInt32(resultadoMySQL["cantidad"]),
                        PrecioDeVenta   = Convert.ToDouble(resultadoMySQL["precio"])
                    };
                    pedido = new Pedido()
                    {
                        IdPedido = Convert.ToInt32(resultadoMySQL["id_pedido"]),
                        Fecha    = Convert.ToDateTime(resultadoMySQL["fecha"]),
                        Numero   = Convert.ToInt32(resultadoMySQL["numero"]),
                        Estado   = resultadoMySQL["estado"].ToString()
                    };
                    lineaDePedido.Producto = producto;
                    listaLineaDePedidos.Add(lineaDePedido);
                    pedido.ListaLineasDePedido = listaLineaDePedidos;
                    listaPedidos.Add(pedido);
                }
                resultadoMySQL.Close();
                return(listaPedidos);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
 public bool insertarDetallePedido(LineaDePedido lineaDePedido, int idPedido)
 {
     try
     {
         bool inserta = pedidoDAO.insertarLineaDePedido(lineaDePedido, idPedido);
         if (!inserta)
         {
             gestorMySQL.cancelarTransaccion();
         }
         return(inserta);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 7
0
        public ActionResult AgregarProductosACarrito(FormCollection formCollection)
        {
            try
            {
                List <LineaDePedido> lista;
                if (Session["carrito"] != null)
                {
                    lista = (List <LineaDePedido>)Session["carrito"];
                }
                else
                {
                    lista = new List <LineaDePedido>();
                }
                LineaDePedido lineaDePedido = new LineaDePedido();
                Producto      producto      = new Producto
                {
                    IdProducto  = Convert.ToInt32(formCollection["IdProducto"]),
                    Nombre      = formCollection["Nombre"].ToString(),
                    Descripcion = formCollection["Descripcion"].ToString(),
                    Imagen      = formCollection["Imagen"].ToString()
                };

                lineaDePedido.CantidadVendida = Convert.ToInt32(formCollection["Cantidad"]);
                lineaDePedido.PrecioDeVenta   = Convert.ToDouble(formCollection["Precio"]);
                lineaDePedido.Producto        = producto;
                lista.Add(lineaDePedido);

                if (lineaDePedido.esCantidadValida())
                {
                    Session["carrito"] = lista;
                }
                else
                {
                    return(RedirectToAction("ListarProductos", "Producto", new { msgError = "Excedió el máximo permitido que es de 20 unidades" }));
                }
                return(RedirectToAction("ListarCarrito"));
            }
            catch (Exception error)
            {
                return(RedirectToAction("Index", "Error", new { msgError = error.Message }));
            }
        }
Esempio n. 8
0
 internal void RemoverLineaDeVenta(LineaDePedido lineaSelec)
 {
     VentaActual.QuitarLineaDeVenta(lineaSelec);
 }
        //--------------------------------------------------
        //Función para agregar los datos al detalles factura
        public static void AgregarEspecificacionProducto(Formulario formulario,
                                                         EspecificacionDeProducto codiProd,
                                                         int cantidadProd,
                                                         NumericUpDown nudCantidadDetallesFAct,
                                                         EspecificacionDeProducto ProdActual,
                                                         List <LineaDePedido> ListaDetallesFact,
                                                         TextBox txtDescripcionProductoFactura,
                                                         DataGridView dgvGrillaFactura,
                                                         TextBox txtCodigoProductoFactura,
                                                         NumericUpDown nudPrecioProducto,
                                                         List <EspecificacionDeProducto> ListaProducto,
                                                         DataGridView dgvListaProducto,
                                                         bool FactA,
                                                         bool FactB,
                                                         bool FactC,
                                                         TextBox txtIvaFact,
                                                         EspecificacionDeProducto factura,
                                                         TextBox txtSubTotalFactura,
                                                         TextBox txtTOTALFactura)
        {
            //Verifica  si existe un producto en la lista de detalles
            if (ExisteProd(factura, ListaDetallesFact, txtDescripcionProductoFactura))
            {
                //Verifica el stock
                if (nudCantidadDetallesFAct.Value <= ProdActual.ProdStock)
                {
                    foreach (var busc in ListaDetallesFact)
                    {
                        //Verifica que cod de la lista es igual al del producto a agregar, le suma la cantidad y calcula nuevamente el subtotal
                        if (busc.Descripcion == txtDescripcionProductoFactura.Text)
                        {
                            busc.Cantidad       += cantidadProd;
                            busc.SubTotal        = busc.Cantidad * busc.Precio;
                            ProdActual.ProdStock = ProdActual.ProdStock - cantidadProd;
                            FacturaABC(FactA, FactB, FactC, txtIvaFact, ListaDetallesFact, txtSubTotalFactura, txtTOTALFactura);
                        }

                        Facturacion.cargarGrillaFact(formulario, ListaDetallesFact, dgvGrillaFactura);
                    }
                }
                else
                {
                    MessageBox.Show("No hay Stock del producto");
                }
            }
            else
            //Si el producto es nuevo en la lista de detalles
            {
                //Verifica el stock
                if (nudCantidadDetallesFAct.Value <= ProdActual.ProdStock)
                {
                    LineaDePedido ObjDetalle = new LineaDePedido();

                    ObjDetalle.Codigo      = txtCodigoProductoFactura.Text;
                    ObjDetalle.Descripcion = txtDescripcionProductoFactura.Text;
                    ObjDetalle.Precio      = nudPrecioProducto.Value;
                    ObjDetalle.Cantidad    = Convert.ToInt32(nudCantidadDetallesFAct.Value);
                    ObjDetalle.SubTotal    = ObjDetalle.Precio * ObjDetalle.Cantidad;
                    ProdActual.ProdStock   = ProdActual.ProdStock - Convert.ToInt32(nudCantidadDetallesFAct.Value);
                    ListaDetallesFact.Add(ObjDetalle);
                    Facturacion.cargarGrillaFact(formulario, ListaDetallesFact, dgvGrillaFactura);
                    Facturacion.cargargrillaproducto(formulario, ListaProducto, dgvListaProducto);
                }
                else
                {
                    MessageBox.Show("No hay Stock del producto");
                }
            }
        }
 public void ColocarLineaDeVenta(LineaDePedido LineaDeVenta)
 {
     bindingSourceLineaDeVenta.DataSource = LineaDeVenta;
     bindingSourceLineaDeVenta.ResetBindings(false);
 }