Cours-Gratuit
  • Cours
  • Blog
home icon Cours gratuits » Cours informatique » Cours programmation » Cours JAVA » Applications JAVA

Gestion de restaurant avec JAVA code source

Gestion de restaurant avec JAVA code source
Participez au vote ☆☆☆☆☆★★★★★
Aller au Téléchargement

Gestion de restaurant avec JAVA code source

Cet article propose en détaille une application Java pour la gestion des commandes dans une restaurant

Vous pourrez télécharger le fichier au format zip il contient le code sources les classes, les images, …

Cette application contient deux parties :

- Partie Serveur : une interface Swing pour lancer et arrêter le serveur d’écoute, ce dernier est connecté en background avec un serveur de Base de Données MySQL, intégration d'un moniteur de log pour afficher les clients connectés et leur adresses IP/port.

- Partie Client: on trouve ici deux types de clients, une serveuse ordinaire qui va demander une commande faite par un client, et une partie réservée au aux cuisiniers du restaurant, ces derniers vont pouvoir modifier le menu du restau, visualiser les commandes reçues, commencer ou annuler les commandes des serveuses.

Fonctionnement :

  1. Le Serveur doit être lancé avant le Client(Serveuse/Cuisinier)
  2. Les images sont stockées sous forme binaire (Blob)
  3. Compte Client: client/client
  4. Compte Cuisinier : cuisinier/cuisinier

Les fonctionnalités principale qu'une serveuse (Client) peut faire sont :

  • parcourir le Menu
  • Commander des Plats
  • visualiser les commandes en cours de traitement
  • visualiser les commandes reçues
  • générer une facture des commandes consommés

Les fonctionnalités principale qu'un cuisinier peut faire sont :

  • Ajout/Modif/Suppression des Plats du Menu
  • afficher les commandes demandés, pour commencer/annuler leur traitement
  • afficher les commandes en cours de traitement (avec progressBar), et quand la commande est prête une notification est envoyé au serveuse (Client).
  • afficher les commandes déjà servies

Extrait du code source :

package Form;

import java.awt.Graphics;

import java.awt.Image;

import java.awt.image.BufferedImage;

import java.io.ByteArrayInputStream;

import java.io.File;

import java.io.FileOutputStream;

import java.io.IOException;

import java.sql.Blob;

import java.sql.SQLException;

import java.util.ArrayList;

import javax.imageio.ImageIO;

import javax.swing.ImageIcon;

import javax.swing.table.DefaultTableModel;

import org.apache.commons.io.IOUtils;

import shared.Commande;

import shared.Message;

public class CommandeEnCours_Client extends javax.swing.JInternalFrame {

   public MainApp parentMainApp;

   static public DefaultTableModel   table = null;

   public static ArrayList<Commande> listeCommandeEnCours_Client = new ArrayList<Commande>();

   public static javax.swing.JTable CommandesEnCoursClient_jTable = new javax.swing.JTable();

   public CommandeEnCours_Client(MainApp parent) {

initComponents();

       parentMainApp = parent;

       parentMainApp.client.send(new Message("ListCommandesEnCours_Client", parentMainApp.client.getUsername(), "SendMeTheListOfCommandesEnCours_Client", "SERVER"));      

   }

   private void initComponents() {

       Title_jLabel = new javax.swing.JLabel();

       jScrollPane1 = new javax.swing.JScrollPane();

       DetailsPlat_jPanel = new javax.swing.JPanel();

       Nom_jTextField = new javax.swing.JTextField();

       Image_jLabel = new javax.swing.JLabel();

       Image_jTextField = new javax.swing.JTextField();

       Nom_jLabel = new javax.swing.JLabel();

       Categorie_jComboBox = new javax.swing.JComboBox();

       duree_jTextField = new javax.swing.JTextField();

       Categorie_jLabel = new javax.swing.JLabel();

       Prix_jLabel = new javax.swing.JLabel();

       Prix_jTextField = new javax.swing.JTextField();

       duree_jLabel = new javax.swing.JLabel();

       Image_jPanel = new javax.swing.JPanel();

       BX = new javax.swing.JLabel();

       Quantite_jTextField = new javax.swing.JTextField();

       Quantite_jLabel1 = new javax.swing.JLabel();

       TempsEcouleX_jLabel = new javax.swing.JLabel();

       setBackground(java.awt.SystemColor.inactiveCaption);

       setClosable(true);

       setIconifiable(true);

       setMaximizable(true);

       setResizable(true);

       setTitle("Liste des Commandes En Cours");

       Title_jLabel.setFont(new java.awt.Font("Tahoma", 3, 14)); // NOI18N

       Title_jLabel.setText("Liste des Commandes En Cours de Preparation");

       CommandesEnCoursClient_jTable.addMouseListener(new java.awt.event.MouseAdapter() {

           public void mouseClicked(java.awt.event.MouseEvent evt) {

               CommandesEnCoursClient_jTableMouseClicked(evt);

           }

           public void mousePressed(java.awt.event.MouseEvent evt) {

               CommandesEnCoursClient_jTableMousePressed(evt);

           }

       });

       CommandesEnCoursClient_jTable.addKeyListener(new java.awt.event.KeyAdapter() {

           public void keyPressed(java.awt.event.KeyEvent evt) {

               CommandesEnCoursClient_jTableKeyPressed(evt);

           }

       });

       jScrollPane1.setViewportView(CommandesEnCoursClient_jTable);

       DetailsPlat_jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Détails du Plat"));

       Image_jLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

       Image_jLabel.setText("Image du Plat :");

       Nom_jLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

       Nom_jLabel.setText("Nom Plat :");

       Categorie_jComboBox.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Entrée", "Soupe", "Plat principal", "Dessert", "Boisson", "Confiserie" }));

       Categorie_jLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

       Categorie_jLabel.setText("Categorie Plat :");

       Prix_jLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

       Prix_jLabel.setText("Prix du Plat :");

       duree_jLabel.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

       duree_jLabel.setText("Durée Préparation :");

       Image_jPanel.setBorder(javax.swing.BorderFactory.createTitledBorder("Image du Plat"));

       javax.swing.GroupLayout Image_jPanelLayout = new javax.swing.GroupLayout(Image_jPanel);

       Image_jPanel.setLayout(Image_jPanelLayout);

       Image_jPanelLayout.setHorizontalGroup(           Image_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

           .addGroup(Image_jPanelLayout.createSequentialGroup()

               .addContainerGap()

               .addComponent(BX, javax.swing.GroupLayout.PREFERRED_SIZE, 178, javax.swing.GroupLayout.PREFERRED_SIZE)

               .addContainerGap(22, Short.MAX_VALUE))

       );

       Image_jPanelLayout.setVerticalGroup(           Image_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

           .addComponent(BX, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 264, Short.MAX_VALUE)

       );

       Quantite_jLabel1.setFont(new java.awt.Font("Tahoma", 1, 14)); // NOI18N

       Quantite_jLabel1.setText("Quantité demandé");

       javax.swing.GroupLayout DetailsPlat_jPanelLayout = new javax.swing.GroupLayout(DetailsPlat_jPanel);

       DetailsPlat_jPanel.setLayout(DetailsPlat_jPanelLayout);

       DetailsPlat_jPanelLayout.setHorizontalGroup(           DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

           .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, DetailsPlat_jPanelLayout.createSequentialGroup()

               .addContainerGap()               .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                   .addGroup(DetailsPlat_jPanelLayout.createSequentialGroup()                        .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                           .addGroup(DetailsPlat_jPanelLayout.createSequentialGroup()                               .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

                                   .addComponent(Nom_jLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

                                    .addComponent(Categorie_jLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 132, javax.swing.GroupLayout.PREFERRED_SIZE)

                                   .addComponent(Prix_jLabel)

                                   .addComponent(duree_jLabel, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE))

                               .addGap(18, 18, 18))

                           .addGroup(DetailsPlat_jPanelLayout.createSequentialGroup()

                               .addComponent(Quantite_jLabel1, javax.swing.GroupLayout.DEFAULT_SIZE, 154, Short.MAX_VALUE)                               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))                       .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                           .addComponent(Prix_jTextField)

                           .addComponent(duree_jTextField)

                           .addComponent(Image_jTextField)

                           .addComponent(Categorie_jComboBox, 0, 335, Short.MAX_VALUE)

                           .addComponent(Nom_jTextField)

                           .addComponent(Quantite_jTextField)))

                   .addGroup(DetailsPlat_jPanelLayout.createSequentialGroup()                        .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                           .addComponent(Image_jLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 116, javax.swing.GroupLayout.PREFERRED_SIZE)

                          .addGroup(DetailsPlat_jPanelLayout.createSequentialGroup()

                               .addGap(156, 156, 156)

                               .addComponent(TempsEcouleX_jLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 64, javax.swing.GroupLayout.PREFERRED_SIZE)))

                       .addGap(0, 0, Short.MAX_VALUE)))

               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)

               .addComponent(Image_jPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

               .addContainerGap())

       );

       DetailsPlat_jPanelLayout.setVerticalGroup(           DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

           .addGroup(DetailsPlat_jPanelLayout.createSequentialGroup()

               .addContainerGap(19, Short.MAX_VALUE)               .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                   .addComponent(Image_jPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                   .addGroup(DetailsPlat_jPanelLayout.createSequentialGroup()

                        .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                           .addComponent(Categorie_jComboBox, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                           .addComponent(Categorie_jLabel))

                       .addGap(7, 7, 7)                       .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                           .addComponent(Nom_jLabel)

                           .addComponent(Nom_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))                      .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                       .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                           .addComponent(Prix_jLabel)

                         .addComponent(Prix_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                       .addGap(18, 18, 18)                       .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)

                           .addComponent(duree_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                           .addGroup(DetailsPlat_jPanelLayout.createSequentialGroup()

                               .addGap(3, 3, 3)

                               .addComponent(duree_jLabel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))

                       .addGap(18, 18, 18)                       .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                           .addComponent(Image_jLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 20, javax.swing.GroupLayout.PREFERRED_SIZE)

                           .addComponent(Image_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))

                       .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)                       .addGroup(DetailsPlat_jPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)

                            .addComponent(Quantite_jTextField, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                           .addComponent(Quantite_jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 27, javax.swing.GroupLayout.PREFERRED_SIZE))

                       .addGap(56, 56, 56)

                       .addComponent(TempsEcouleX_jLabel, javax.swing.GroupLayout.PREFERRED_SIZE, 22, javax.swing.GroupLayout.PREFERRED_SIZE))))

       );

       javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());

       getContentPane().setLayout(layout);

       layout.setHorizontalGroup(

           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

           .addGroup(layout.createSequentialGroup()

               .addContainerGap()               .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

                   .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 753, Short.MAX_VALUE)

                   .addComponent(DetailsPlat_jPanel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

               .addContainerGap())

           .addGroup(layout.createSequentialGroup()

               .addGap(209, 209, 209)

               .addComponent(Title_jLabel)

               .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))

       );

       layout.setVerticalGroup(

           layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)

           .addGroup(layout.createSequentialGroup()

               .addGap(18, 18, 18)

               .addComponent(Title_jLabel)

               .addGap(18, 18, 18)

               .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 209, javax.swing.GroupLayout.PREFERRED_SIZE)

               .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)

               .addComponent(DetailsPlat_jPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)

                .addContainerGap())

       );

       pack();

   }// </editor-fold>                      

   private void CommandesEnCoursClient_jTableMouseClicked(java.awt.event.MouseEvent evt) {                                                          

       SelectAction();

   }                                                        

   private void CommandesEnCoursClient_jTableMousePressed(java.awt.event.MouseEvent evt) {                                                          

       SelectAction();

   }                                                        

   private void CommandesEnCoursClient_jTableKeyPressed(java.awt.event.KeyEvent evt) {                                                        

       SelectAction();

   }                                                        

  

   public void SelectAction()

   {

       try {

           BX.setIcon(null);      

           Selected_Row = CommandesEnCoursClient_jTable.getSelectedRow();

           Temp_Commande = parentMainApp.listeCommandeEnCours_Client.get(Selected_Row);          

           Selected_categorie = Temp_Commande.getCommandePlat().getCategorie();

           Selected_nom = Temp_Commande.getCommandePlat().getNom();

           Selected_prix = Temp_Commande.getCommandePlat().getPrix();

           Selected_duree = Temp_Commande.getCommandePlat().getDuree();

           Selected_nom_image = Temp_Commande.getCommandePlat().getNom_image();

           Selected_image = Temp_Commande.getCommandePlat().getImage();

           Categorie_jComboBox.setSelectedItem(Selected_categorie);

           Nom_jTextField.setText(Selected_nom);

           Prix_jTextField.setText(""+Selected_prix);

           duree_jTextField.setText(""+Selected_duree);

           Image_jTextField.setText("./images/"+Selected_nom_image);

           Quantite_jTextField.setText(String.valueOf(Temp_Commande.getQuantite()));          

           Selected_FilePath = "./images/"+Selected_nom_image;

           if(ArchOS){ Selected_FilePath = Selected_FilePath.replace("\\", "/"); }

           Selected_File = new File(Selected_FilePath);        

           int blobLength = (int) Selected_image.length();

           Selected_bytes = Selected_image.getBytes(1, blobLength);            

     ByteArrayInputStream in = new ByteArrayInputStream(Selected_bytes);

           FileOutputStream out = new FileOutputStream(Selected_File);

           IOUtils.copy(in, out);

           IOUtils.closeQuietly(in);

           IOUtils.closeQuietly(out);

BufferedImage image;

               image = ImageIO.read(Selected_File);

               if(image == null) System.out.println("image null");

               ImageIcon icon;

               icon = new ImageIcon(image);

Image img = icon.getImage();

               BufferedImage bi = new BufferedImage(img.getWidth(null), img.getHeight(null), BufferedImage.TYPE_INT_ARGB);

               Graphics g = bi.createGraphics();

               g.drawImage(img, 0, 0, 250, 215, null);

               ImageIcon newIcon = new ImageIcon(bi);

               BX.setIcon(newIcon);    

              

               } catch (SQLException | IOException ex) {

                   ex.printStackTrace();

               }

   }  

   int Selected_Row=99999;

   String Selected_categorie;

   String Selected_nom;

   double Selected_prix;

   int Selected_duree;

   String Selected_nom_image;

   Blob Selected_image;

   String Selected_FilePath;

   File Selected_File;

   byte[] Selected_bytes;

   public static Commande Temp_Commande = null;  

   boolean ArchOS = System.getProperty("os.name").startsWith("Windows");

private javax.swing.JLabel BX;

   private javax.swing.JComboBox Categorie_jComboBox;

   private javax.swing.JLabel Categorie_jLabel;

   private javax.swing.JPanel DetailsPlat_jPanel;

   private javax.swing.JLabel Image_jLabel;

   private javax.swing.JPanel Image_jPanel;

   private javax.swing.JTextField Image_jTextField;

   private javax.swing.JLabel Nom_jLabel;

   private javax.swing.JTextField Nom_jTextField;

   private javax.swing.JLabel Prix_jLabel;

   private javax.swing.JTextField Prix_jTextField;

   private javax.swing.JLabel Quantite_jLabel1;

   private javax.swing.JTextField Quantite_jTextField;

   private javax.swing.JLabel TempsEcouleX_jLabel;

   private javax.swing.JLabel Title_jLabel;

   private javax.swing.JLabel duree_jLabel;

   private javax.swing.JTextField duree_jTextField;

   private javax.swing.JScrollPane jScrollPane1;              

}

Articles similaires

  • Comment ouvrir un restaurant au Québec?
  • Exercice création des requêtes SQL
  • Comment faire une étude de marché pour ouvrir un restaurant ?
  • Pourquoi WordPress est le CMS le plus flexible du marché
  • Exercice VB: Gestion Stagiaires avec Fichier et Collection
  • Exercice liste chainée générique JAVA - Structures de données abstraites

Documents similaires

  • Code source en Java sur la gestion étudiant

    Code source en Java sur la gestion étudiant

  • Email application JAVA code source

    Email application JAVA code source

  • Application gestion de paie avec JAVA

    Application gestion de paie avec JAVA

  • Application Excel sur la gestion de caisse restaurant

    Application Excel sur la gestion de caisse restaurant

  • Code source mini projet de compilateur basic en langage C

    Code source mini projet de compilateur basic en langage C

  • Gestionnaire de fenêtres avec menu code source en langage C

    Gestionnaire de fenêtres avec menu code source en langage C

  • Contactez-nous
  • A propos de nous
  • On recrute
  • Rechercher dans le site
  • Politique de confidentialité
  • Droit d'auteur/Copyright
  • Conditions générales d'utilisation
  • Plan du site
  • Accueil
  • Blog
  • Finance et compta.
  • Formations Pro.
  • Logiciels & Apps
  • Organisation
  • Cours informatique
  • Aide à la rédaction
  • Etudes et Metiers
  • Cours commerce
  • Cours électricité
  • Cours finance
  • Cours statistique
  • Cours économie
  • Cours Management
  • Cours comptabilité
  • Cours électronique
  • Cours gestion
  • Cours marketing
id 11354 02