예제 #1
0
 public static void Nuevo(string id, ComandaDetalle comandaDetalle)
 {
     if (!DetalleExiste(id, comandaDetalle.producto.producto_id))
     {
         ComandaDetalleDato.Insertar(id, comandaDetalle);
     }
 }
예제 #2
0
        public void printComanda()
        {
            var            listaComanda   = lstView_Comanda;
            Comanda        comanda        = new Comanda();
            ComandaDetalle comandaDetalle = new ComandaDetalle();

            //test
            comanda.Fecha      = DateTime.Now;
            comanda.Mesa       = int.Parse(txtNumMesa.Text);
            comanda.Comentario = txtComentarios.Text;

            foreach (var item in lstView_Comanda.Items)
            {
                if (item is ProductGridViewModel product)
                {
                    comanda.ComandaDetalles.Add(new ComandaDetalle
                    {
                        Cantidad   = product.Quantity,
                        ProductoID = product.Id,
                        Precio     = db.Productos.FirstOrDefault(x => x.Id == product.Id).Precio *product.Quantity
                    });
                }
            }

            addComanda(comanda);
        }
예제 #3
0
        public static void Modificar(string comanda_id, ComandaDetalle detalle)
        {
            Database   db      = DatabaseFactory.CreateDatabase("Default");
            SqlCommand comando = new SqlCommand("sp_modificar_comanda_detalle");

            comando.CommandType = CommandType.StoredProcedure;

            comando.Parameters.AddWithValue("@comanda_id", comanda_id);
            comando.Parameters.AddWithValue("@producto_id", detalle.producto.producto_id);
            comando.Parameters.AddWithValue("@cantidad", detalle.cantidad);
            comando.Parameters.AddWithValue("@notas", detalle.notas);

            db.ExecuteNonQuery(comando);
        }
예제 #4
0
        public static List <ComandaDetalle> ObtenerTodos(string comanda_id)
        {
            List <ComandaDetalle> lista = new List <ComandaDetalle>();
            DataSet ds = ComandaDetalleDato.SeleccionarTodos(comanda_id);

            foreach (DataRow fila in ds.Tables[0].Rows)
            {
                ComandaDetalle registro = new ComandaDetalle();

                registro.producto = ProductoLN.SeleccionarProducto(fila["producto_id"].ToString());
                registro.cantidad = Convert.ToInt32(fila["cantidad"]);
                registro.notas    = fila["notas"].ToString();

                lista.Add(registro);
            }
            return(lista);
        }
예제 #5
0
 public static void Modificar(string id, ComandaDetalle comandaDetalle)
 {
     ComandaDetalleDato.Modificar(id, comandaDetalle);
 }
예제 #6
0
 public void addDetalleComanda(ComandaDetalle comandaDetalle)
 {
     db.ComandaDetalles.Add(comandaDetalle);
     db.SaveChanges();
 }