From 1c53efb234222343459d151c404fcf7ffdfa6407 Mon Sep 17 00:00:00 2001 From: javaaaahell <153199847+javaaaahell@users.noreply.github.com> Date: Sat, 9 Dec 2023 21:54:54 +0800 Subject: [PATCH] Add files via upload --- assignment/AdminPage.form | 186 +++++++++------- assignment/AdminPage.java | 183 ++++++++++------ assignment/CustomerPage.form | 3 + assignment/CustomerPage.java | 14 +- assignment/DDPage.form | 3 + assignment/DDPage.java | 14 +- assignment/JavaGrpAssignment.java | 20 ++ assignment/Login.form | 137 +++++------- assignment/Login.java | 307 ++++++++++++++------------- assignment/OrderApproved_Vendor.form | 127 +++++++++++ assignment/OrderApproved_Vendor.java | 164 ++++++++++++++ assignment/OrderHistory.form | 176 +++++++++++++++ assignment/OrderHistory.java | 220 +++++++++++++++++++ assignment/VendorMenu.form | 78 +++++-- assignment/VendorMenu.java | 166 ++++++++++++--- assignment/VendorOrderDetails.form | 127 +++++++++++ assignment/VendorOrderDetails.java | 196 +++++++++++++++++ assignment/VendorPage.form | 3 + assignment/VendorPage.java | 110 ++++++---- assignment/menu_details.txt | 5 + assignment/password.txt | 5 + 21 files changed, 1771 insertions(+), 473 deletions(-) create mode 100644 assignment/JavaGrpAssignment.java create mode 100644 assignment/OrderApproved_Vendor.form create mode 100644 assignment/OrderApproved_Vendor.java create mode 100644 assignment/OrderHistory.form create mode 100644 assignment/OrderHistory.java create mode 100644 assignment/VendorOrderDetails.form create mode 100644 assignment/VendorOrderDetails.java create mode 100644 assignment/menu_details.txt create mode 100644 assignment/password.txt diff --git a/assignment/AdminPage.form b/assignment/AdminPage.form index f8583b4..58898aa 100644 --- a/assignment/AdminPage.form +++ b/assignment/AdminPage.form @@ -18,73 +18,24 @@ + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + + + + + + - - - - - - - - - - - - - - - - - - - - + @@ -96,26 +47,115 @@ - - - - - - - - - + - + + + - - + + + + + + + + + + + + + + + + + + + + + - + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assignment/AdminPage.java b/assignment/AdminPage.java index e018de4..042487b 100644 --- a/assignment/AdminPage.java +++ b/assignment/AdminPage.java @@ -2,18 +2,20 @@ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template */ -package com.mycompany.registrationpage; +package javagrpassignment; /** * - * @author Yanaal + * @author chiaj */ -public class AdminPage extends javax.swing.JFrame { +public class AdminPage extends javax.swing.JFrame +{ /** * Creates new form AdminPage */ - public AdminPage() { + public AdminPage() + { initComponents(); } @@ -24,112 +26,150 @@ public AdminPage() { */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents - private void initComponents() { + private void initComponents() + { + java.awt.GridBagConstraints gridBagConstraints; - jPanel1 = new javax.swing.JPanel(); + jPanel6 = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); + jPanel7 = new javax.swing.JPanel(); + AdminLogOutbtn = new javax.swing.JButton(); + jPanel5 = new javax.swing.JPanel(); + jPanel2 = new javax.swing.JPanel(); + jPanel4 = new javax.swing.JPanel(); ATopUpbtn = new javax.swing.JButton(); + jPanel3 = new javax.swing.JPanel(); UserRegbtn = new javax.swing.JButton(); - AdminLogOutbtn = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); - jPanel1.setBackground(new java.awt.Color(255, 51, 51)); + jPanel6.setBackground(new java.awt.Color(255, 51, 102)); jLabel1.setFont(new java.awt.Font("Segoe UI", 1, 24)); // NOI18N jLabel1.setForeground(new java.awt.Color(255, 255, 255)); jLabel1.setText("Administrator"); + jPanel6.add(jLabel1); + + getContentPane().add(jPanel6, java.awt.BorderLayout.PAGE_START); + + jPanel7.setBackground(new java.awt.Color(153, 255, 255)); + jPanel7.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.LEFT)); + + AdminLogOutbtn.setText("Log Out"); + AdminLogOutbtn.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + AdminLogOutbtnActionPerformed(evt); + } + }); + jPanel7.add(AdminLogOutbtn); + + getContentPane().add(jPanel7, java.awt.BorderLayout.PAGE_END); - javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); - jPanel1.setLayout(jPanel1Layout); - jPanel1Layout.setHorizontalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(jPanel1Layout.createSequentialGroup() - .addGap(115, 115, 115) - .addComponent(jLabel1) - .addContainerGap(125, Short.MAX_VALUE)) - ); - jPanel1Layout.setVerticalGroup( - jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jLabel1) - .addGap(15, 15, 15)) - ); - - jLabel1.getAccessibleContext().setAccessibleName("Adminlbl"); + jPanel5.setBackground(new java.awt.Color(153, 255, 255)); + jPanel5.setLayout(new java.awt.GridLayout(1, 0)); + + jPanel2.setBackground(new java.awt.Color(153, 255, 255)); + jPanel2.setLayout(new java.awt.GridLayout(2, 0)); + + jPanel4.setBackground(new java.awt.Color(153, 255, 255)); + jPanel4.setLayout(new java.awt.GridBagLayout()); ATopUpbtn.setText("Top-Up Credit"); + ATopUpbtn.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + ATopUpbtnActionPerformed(evt); + } + }); + jPanel4.add(ATopUpbtn, new java.awt.GridBagConstraints()); + + jPanel2.add(jPanel4); + + jPanel3.setBackground(new java.awt.Color(153, 255, 255)); + jPanel3.setLayout(new java.awt.GridBagLayout()); UserRegbtn.setText("User Registration"); + UserRegbtn.addActionListener(new java.awt.event.ActionListener() + { + public void actionPerformed(java.awt.event.ActionEvent evt) + { + UserRegbtnActionPerformed(evt); + } + }); + gridBagConstraints = new java.awt.GridBagConstraints(); + gridBagConstraints.gridx = 0; + gridBagConstraints.gridy = 0; + gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST; + gridBagConstraints.insets = new java.awt.Insets(65, 169, 65, 169); + jPanel3.add(UserRegbtn, gridBagConstraints); - AdminLogOutbtn.setText("Log Out"); + jPanel2.add(jPanel3); - javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); - getContentPane().setLayout(layout); - layout.setHorizontalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addGroup(layout.createSequentialGroup() - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addGap(14, 14, 14) - .addComponent(AdminLogOutbtn)) - .addGroup(layout.createSequentialGroup() - .addGap(121, 121, 121) - .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) - .addComponent(ATopUpbtn, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE) - .addComponent(UserRegbtn, javax.swing.GroupLayout.PREFERRED_SIZE, 142, javax.swing.GroupLayout.PREFERRED_SIZE)))) - .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) - ); - layout.setVerticalGroup( - layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGroup(layout.createSequentialGroup() - .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(32, 32, 32) - .addComponent(UserRegbtn, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(38, 38, 38) - .addComponent(ATopUpbtn, javax.swing.GroupLayout.PREFERRED_SIZE, 48, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(45, 45, 45) - .addComponent(AdminLogOutbtn) - .addContainerGap(13, Short.MAX_VALUE)) - ); + jPanel5.add(jPanel2); + + getContentPane().add(jPanel5, java.awt.BorderLayout.CENTER); pack(); }// //GEN-END:initComponents + private void AdminLogOutbtnActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_AdminLogOutbtnActionPerformed + {//GEN-HEADEREND:event_AdminLogOutbtnActionPerformed + Login a =new Login(); + a.setVisible(true); + this.setVisible(false); + }//GEN-LAST:event_AdminLogOutbtnActionPerformed + + private void UserRegbtnActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_UserRegbtnActionPerformed + {//GEN-HEADEREND:event_UserRegbtnActionPerformed + + }//GEN-LAST:event_UserRegbtnActionPerformed + + private void ATopUpbtnActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_ATopUpbtnActionPerformed + {//GEN-HEADEREND:event_ATopUpbtnActionPerformed + + }//GEN-LAST:event_ATopUpbtnActionPerformed + /** * @param args the command line arguments */ - public static void main(String args[]) { + public static void main(String args[]) + { /* Set the Nimbus look and feel */ // /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { + try + { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) + { + if ("Nimbus".equals(info.getName())) + { javax.swing.UIManager.setLookAndFeel(info.getClassName()); break; } } - } catch (ClassNotFoundException ex) { + } catch (ClassNotFoundException ex) + { java.util.logging.Logger.getLogger(AdminPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { + } catch (InstantiationException ex) + { java.util.logging.Logger.getLogger(AdminPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { + } catch (IllegalAccessException ex) + { java.util.logging.Logger.getLogger(AdminPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { + } catch (javax.swing.UnsupportedLookAndFeelException ex) + { java.util.logging.Logger.getLogger(AdminPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } // /* Create and display the form */ - java.awt.EventQueue.invokeLater(new Runnable() { - public void run() { - new AdminPage().setVisible(true); - } + java.awt.EventQueue.invokeLater(() -> { + new AdminPage().setVisible(true); }); } @@ -138,6 +178,11 @@ public void run() { private javax.swing.JButton AdminLogOutbtn; private javax.swing.JButton UserRegbtn; private javax.swing.JLabel jLabel1; - private javax.swing.JPanel jPanel1; + private javax.swing.JPanel jPanel2; + private javax.swing.JPanel jPanel3; + private javax.swing.JPanel jPanel4; + private javax.swing.JPanel jPanel5; + private javax.swing.JPanel jPanel6; + private javax.swing.JPanel jPanel7; // End of variables declaration//GEN-END:variables } diff --git a/assignment/CustomerPage.form b/assignment/CustomerPage.form index 58b8b63..6f9f2ad 100644 --- a/assignment/CustomerPage.form +++ b/assignment/CustomerPage.form @@ -118,6 +118,9 @@ + + + diff --git a/assignment/CustomerPage.java b/assignment/CustomerPage.java index 485c6e9..7f22989 100644 --- a/assignment/CustomerPage.java +++ b/assignment/CustomerPage.java @@ -2,7 +2,7 @@ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template */ -package com.mycompany.registrationpage; +package javagrpassignment; /** * @@ -64,6 +64,11 @@ private void initComponents() { CustMenubtn.setText("Menu"); CustLogOutbtn.setText("Log Out"); + CustLogOutbtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + CustLogOutbtnActionPerformed(evt); + } + }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); @@ -101,6 +106,13 @@ private void initComponents() { pack(); }// //GEN-END:initComponents + private void CustLogOutbtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CustLogOutbtnActionPerformed + // TODO add your handling code here: + Login a =new Login(); + a.setVisible(true); + this.setVisible(false); + }//GEN-LAST:event_CustLogOutbtnActionPerformed + /** * @param args the command line arguments */ diff --git a/assignment/DDPage.form b/assignment/DDPage.form index 6cdc7e5..8552074 100644 --- a/assignment/DDPage.form +++ b/assignment/DDPage.form @@ -115,6 +115,9 @@ + + + diff --git a/assignment/DDPage.java b/assignment/DDPage.java index fdf5438..f21ec04 100644 --- a/assignment/DDPage.java +++ b/assignment/DDPage.java @@ -2,7 +2,7 @@ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template */ -package com.mycompany.registrationpage; +package javagrpassignment; /** * @@ -63,6 +63,11 @@ private void initComponents() { DDRevenueBtn.setText("Check Revenue"); DDLogOutbtn.setText("Log Out"); + DDLogOutbtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + DDLogOutbtnActionPerformed(evt); + } + }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); @@ -97,6 +102,13 @@ private void initComponents() { pack(); }// //GEN-END:initComponents + private void DDLogOutbtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DDLogOutbtnActionPerformed + // TODO add your handling code here: + Login a =new Login(); + a.setVisible(true); + this.setVisible(false); + }//GEN-LAST:event_DDLogOutbtnActionPerformed + /** * @param args the command line arguments */ diff --git a/assignment/JavaGrpAssignment.java b/assignment/JavaGrpAssignment.java new file mode 100644 index 0000000..aeddf8b --- /dev/null +++ b/assignment/JavaGrpAssignment.java @@ -0,0 +1,20 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template + */ +package javagrpassignment; + +/** + * + * @author baigs + */ +public class JavaGrpAssignment { + + /** + * @param args the command line arguments + */ + public static void main(String[] args) { + // TODO code application logic here + } + +} diff --git a/assignment/Login.form b/assignment/Login.form index 2b2c83b..7efc394 100644 --- a/assignment/Login.form +++ b/assignment/Login.form @@ -21,71 +21,13 @@ - + - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -93,8 +35,8 @@ - - + + @@ -151,7 +93,7 @@ - + @@ -172,8 +114,8 @@ - - + + @@ -181,19 +123,16 @@ - - + + - - - - + - + @@ -221,7 +160,7 @@ - + @@ -263,19 +202,49 @@ - + + + + - + - - + + - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assignment/Login.java b/assignment/Login.java index 3421377..97ed131 100644 --- a/assignment/Login.java +++ b/assignment/Login.java @@ -2,31 +2,39 @@ * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template */ -package assignment; +package javagrpassignment; import java.io.BufferedReader; +import java.io.File; +import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; +import java.util.StringTokenizer; +import java.util.ArrayList; +import java.util.logging.Level; +import java.util.logging.Logger; +import javax.swing.JOptionPane; -public class Login extends javax.swing.JFrame +public class Login extends javax.swing.JFrame { - - /** - * Creates new form Login - */ + + private String loggedInUserID; + private final ArrayList idPasswordList; + private boolean matchFound; + + public static void main(String[] args) { + // This is the entry point of your program + // You can create an instance of your Login class and make it visible + java.awt.EventQueue.invokeLater(() -> { + new Login().setVisible(true); + }); + } public Login() { - initComponents(); - - - - - + initComponents(); + setLocationRelativeTo(null) ; + idPasswordList = new ArrayList<>(); } - - - - /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always @@ -34,12 +42,8 @@ public Login() */ @SuppressWarnings("unchecked") // //GEN-BEGIN:initComponents - private void initComponents() - { + private void initComponents() { - jLabel1 = new javax.swing.JLabel(); - jPanel7 = new javax.swing.JPanel(); - jPanel8 = new javax.swing.JPanel(); jPanel9 = new javax.swing.JPanel(); jPanel10 = new javax.swing.JPanel(); jLabel2 = new javax.swing.JLabel(); @@ -47,50 +51,21 @@ private void initComponents() jPanel2 = new javax.swing.JPanel(); jLabel3 = new javax.swing.JLabel(); jPanel1 = new javax.swing.JPanel(); - jTFUserid = new javax.swing.JTextField(); + JTFUserID = new javax.swing.JTextField(); jPanel5 = new javax.swing.JPanel(); jPanel4 = new javax.swing.JPanel(); jLabel6 = new javax.swing.JLabel(); jPanel3 = new javax.swing.JPanel(); JTfPassword = new javax.swing.JTextField(); jPanel6 = new javax.swing.JPanel(); - jbLogin = new javax.swing.JButton(); + jPanel12 = new javax.swing.JPanel(); + jBLogin = new javax.swing.JButton(); + jPanel13 = new javax.swing.JPanel(); + jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setBackground(new java.awt.Color(153, 255, 255)); - - jLabel1.setText("jLabel1"); - getContentPane().add(jLabel1, java.awt.BorderLayout.CENTER); - - jPanel7.setBackground(new java.awt.Color(153, 255, 255)); - - javax.swing.GroupLayout jPanel7Layout = new javax.swing.GroupLayout(jPanel7); - jPanel7.setLayout(jPanel7Layout); - jPanel7Layout.setHorizontalGroup( - jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 100, Short.MAX_VALUE) - ); - jPanel7Layout.setVerticalGroup( - jPanel7Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 483, Short.MAX_VALUE) - ); - - getContentPane().add(jPanel7, java.awt.BorderLayout.LINE_END); - - jPanel8.setBackground(new java.awt.Color(153, 255, 255)); - - javax.swing.GroupLayout jPanel8Layout = new javax.swing.GroupLayout(jPanel8); - jPanel8.setLayout(jPanel8Layout); - jPanel8Layout.setHorizontalGroup( - jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 100, Short.MAX_VALUE) - ); - jPanel8Layout.setVerticalGroup( - jPanel8Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) - .addGap(0, 483, Short.MAX_VALUE) - ); - - getContentPane().add(jPanel8, java.awt.BorderLayout.LINE_START); + getContentPane().setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); jPanel9.setBackground(new java.awt.Color(153, 255, 255)); jPanel9.setLayout(new java.awt.GridLayout(4, 1)); @@ -110,7 +85,7 @@ private void initComponents() jPanel2.setBackground(new java.awt.Color(153, 255, 255)); jPanel2.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); - jLabel3.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N + jLabel3.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N jLabel3.setForeground(new java.awt.Color(255, 153, 0)); jLabel3.setText("User ID:"); jPanel2.add(jLabel3); @@ -119,12 +94,9 @@ private void initComponents() jPanel1.setBackground(new java.awt.Color(153, 255, 255)); - jTFUserid.setText(" "); - jTFUserid.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { - jTFUseridActionPerformed(evt); + JTFUserID.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + JTFUserIDActionPerformed(evt); } }); @@ -133,15 +105,15 @@ public void actionPerformed(java.awt.event.ActionEvent evt) jPanel1Layout.setHorizontalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() - .addComponent(jTFUserid, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 155, Short.MAX_VALUE)) + .addComponent(JTFUserID, javax.swing.GroupLayout.PREFERRED_SIZE, 104, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(0, 178, Short.MAX_VALUE)) ); jPanel1Layout.setVerticalGroup( jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanel1Layout.createSequentialGroup() .addContainerGap() - .addComponent(jTFUserid, javax.swing.GroupLayout.PREFERRED_SIZE, 18, javax.swing.GroupLayout.PREFERRED_SIZE) - .addContainerGap(96, Short.MAX_VALUE)) + .addComponent(JTFUserID, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(68, Short.MAX_VALUE)) ); jPanel11.add(jPanel1); @@ -153,7 +125,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) jPanel4.setBackground(new java.awt.Color(153, 255, 255)); jPanel4.setLayout(new java.awt.FlowLayout(java.awt.FlowLayout.RIGHT)); - jLabel6.setFont(new java.awt.Font("sansserif", 0, 18)); // NOI18N + jLabel6.setFont(new java.awt.Font("Segoe UI", 1, 18)); // NOI18N jLabel6.setForeground(new java.awt.Color(255, 153, 51)); jLabel6.setText("Password:"); jPanel4.add(jLabel6); @@ -163,10 +135,8 @@ public void actionPerformed(java.awt.event.ActionEvent evt) jPanel3.setBackground(new java.awt.Color(153, 255, 255)); jPanel3.setLayout(new org.netbeans.lib.awtextra.AbsoluteLayout()); - JTfPassword.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { + JTfPassword.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { JTfPasswordActionPerformed(evt); } }); @@ -177,113 +147,158 @@ public void actionPerformed(java.awt.event.ActionEvent evt) jPanel9.add(jPanel5); jPanel6.setBackground(new java.awt.Color(153, 255, 255)); + jPanel6.setLayout(new java.awt.GridLayout(2, 1)); + + jPanel12.setBackground(new java.awt.Color(153, 255, 255)); + + jBLogin.setText("Login"); + jBLogin.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jBLoginActionPerformed(evt); + } + }); + jPanel12.add(jBLogin); - jbLogin.setFont(new java.awt.Font("Arial", 0, 24)); // NOI18N - jbLogin.setText("Login"); - jbLogin.addActionListener(new java.awt.event.ActionListener() - { - public void actionPerformed(java.awt.event.ActionEvent evt) - { - jbLoginActionPerformed(evt); + jPanel6.add(jPanel12); + + jPanel13.setBackground(new java.awt.Color(153, 255, 255)); + + jButton2.setText("Forgot Password"); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); } }); - jPanel6.add(jbLogin); + jPanel13.add(jButton2); + + jPanel6.add(jPanel13); jPanel9.add(jPanel6); - getContentPane().add(jPanel9, java.awt.BorderLayout.CENTER); + getContentPane().add(jPanel9, new org.netbeans.lib.awtextra.AbsoluteConstraints(0, 0, 565, 411)); pack(); }// //GEN-END:initComponents - private void jbLoginActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jbLoginActionPerformed - {//GEN-HEADEREND:event_jbLoginActionPerformed - String id = JTfPassword.getText(); - - String password = jTFUserid.getText(); - - String idpassword = id+","+password; - - System.out.println(idpassword); - - - }//GEN-LAST:event_jbLoginActionPerformed - private void JTfPasswordActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_JTfPasswordActionPerformed {//GEN-HEADEREND:event_JTfPasswordActionPerformed // TODO add your handling code here: }//GEN-LAST:event_JTfPasswordActionPerformed - private void jTFUseridActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jTFUseridActionPerformed - {//GEN-HEADEREND:event_jTFUseridActionPerformed + private void JTFUserIDActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_JTFUserIDActionPerformed + {//GEN-HEADEREND:event_JTFUserIDActionPerformed // TODO add your handling code here: - }//GEN-LAST:event_jTFUseridActionPerformed - - - - /** - * @param args the command line arguments - */ - public static void main(String args[]) - { - /* Set the Nimbus look and feel */ - // - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try - { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) - { - if ("Nimbus".equals(info.getName())) - { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } + }//GEN-LAST:event_JTFUserIDActionPerformed + + private void jBLoginActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jBLoginActionPerformed + {//GEN-HEADEREND:event_jBLoginActionPerformed + String userType = ""; + String userID = ""; + String Passkey = JTFUserID.getText() + "," + JTfPassword.getText(); + + File f = new File("C:\\Users\\baigs\\OneDrive\\Documents\\NetBeansProjects\\JavaGrpAssignment\\src\\javagrpassignment\\password.txt"); + + try (BufferedReader br = new BufferedReader(new FileReader(f))) { + String line; + + while ((line = br.readLine()) != null) { + // Split the line using commas as the separator + String[] data = line.split(", "); + + // Ensure that there are at least two elements (id and password) + if (data.length >= 3) { // Modified to check for at least three elements + String id = data[1].trim(); // Assuming id is the second element + String password = data[2].trim(); // Assuming password is the third element + + idPasswordList.add(new String[]{id, password}); } - } catch (ClassNotFoundException ex) - { - java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) - { - java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) - { - java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) - { - java.util.logging.Logger.getLogger(Login.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } - // - - /* Create and display the form */ - java.awt.EventQueue.invokeLater(new Runnable() - { - public void run() - { - new Login().setVisible(true); - } - }); + } catch (IOException e) { + e.printStackTrace(); + } + + for (String[] pair : idPasswordList) { + if (Passkey.equals(pair[0] + "," + pair[1])) { + matchFound = true; + userType = pair[0].substring(0, 2); + if ("vd".equals(userType)) { + userID = pair[0]; + } else { + userID = pair[0]; + } + loggedInUserID = userID; + break; + } } + // ... After the loop + if (!matchFound) { + JOptionPane.showMessageDialog(this, "Invalid login credentials", "Error", JOptionPane.ERROR_MESSAGE); + // Display an error message or handle invalid credentials as needed + } else { + switch (userType) { + case "cu": + // Open customer page + CustomerPage customerPage = new CustomerPage(); + customerPage.setVisible(true); + break; + case "ad": + // Open admin page + AdminPage adminPage = new AdminPage(); + adminPage.setVisible(true); + break; + case "dm": + // Open delivery driver page + DDPage deliveryDriverPage = new DDPage(); + deliveryDriverPage.setVisible(true); + break; + case "vd": + // Open vendor page with the user ID + VendorPage vendorPage = new VendorPage(userID); + vendorPage.setVisible(true); + break; + default: + // Handle unknown user type + System.out.println("Unknown user type"); + break; + } + // Close the current login page + this.setVisible(false); + } + + }//GEN-LAST:event_jBLoginActionPerformed + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt)//GEN-FIRST:event_jButton2ActionPerformed + {//GEN-HEADEREND:event_jButton2ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jButton2ActionPerformed + + public String getLoggedInUserID() { + return loggedInUserID; + } + + /** + * @param args the command line arguments + */ + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JTextField JTFUserID; private javax.swing.JTextField JTfPassword; - private javax.swing.JLabel jLabel1; + private javax.swing.JButton jBLogin; + private javax.swing.JButton jButton2; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel6; private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel10; private javax.swing.JPanel jPanel11; + private javax.swing.JPanel jPanel12; + private javax.swing.JPanel jPanel13; private javax.swing.JPanel jPanel2; private javax.swing.JPanel jPanel3; private javax.swing.JPanel jPanel4; private javax.swing.JPanel jPanel5; private javax.swing.JPanel jPanel6; - private javax.swing.JPanel jPanel7; - private javax.swing.JPanel jPanel8; private javax.swing.JPanel jPanel9; - private javax.swing.JTextField jTFUserid; - private javax.swing.JButton jbLogin; // End of variables declaration//GEN-END:variables } diff --git a/assignment/OrderApproved_Vendor.form b/assignment/OrderApproved_Vendor.form new file mode 100644 index 0000000..89f7819 --- /dev/null +++ b/assignment/OrderApproved_Vendor.form @@ -0,0 +1,127 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/assignment/OrderApproved_Vendor.java b/assignment/OrderApproved_Vendor.java new file mode 100644 index 0000000..abe2867 --- /dev/null +++ b/assignment/OrderApproved_Vendor.java @@ -0,0 +1,164 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package javagrpassignment; + +/** + * + * @author baigs + */ +public class OrderApproved_Vendor extends javax.swing.JFrame { + + /** + * Creates new form OrderApproved_Vendor + */ + public OrderApproved_Vendor() { + initComponents(); + this.setTitle("Order Management"); + setLocationRelativeTo(null); + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + jScrollPane1 = new javax.swing.JScrollPane(); + jList1 = new javax.swing.JList<>(); + jLabel1 = new javax.swing.JLabel(); + jButton3 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jButton1.setText("Reject"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jButton2.setText("Approve"); + + jList1.setModel(new javax.swing.AbstractListModel() { + String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" }; + public int getSize() { return strings.length; } + public String getElementAt(int i) { return strings[i]; } + }); + jScrollPane1.setViewportView(jList1); + + jLabel1.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N + jLabel1.setText("Approve/Reject Order"); + + jButton3.setText("Back"); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(42, 42, 42) + .addComponent(jButton1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jButton2) + .addGap(50, 50, 50)) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jButton3)) + .addGroup(layout.createSequentialGroup() + .addGap(101, 101, 101) + .addComponent(jLabel1)) + .addGroup(layout.createSequentialGroup() + .addGap(115, 115, 115) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 155, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addContainerGap(120, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addGap(11, 11, 11) + .addComponent(jButton3) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 224, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(12, 12, 12) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton2) + .addComponent(jButton1)) + .addGap(43, 43, 43)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jButton1ActionPerformed + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + // TODO add your handling code here: + VendorOrderDetails page8 = new VendorOrderDetails(); + + page8.setVisible(true); + + this.setVisible(false); + }//GEN-LAST:event_jButton3ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(OrderApproved_Vendor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(OrderApproved_Vendor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(OrderApproved_Vendor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(OrderApproved_Vendor.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new OrderApproved_Vendor().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JLabel jLabel1; + private javax.swing.JList jList1; + private javax.swing.JScrollPane jScrollPane1; + // End of variables declaration//GEN-END:variables +} diff --git a/assignment/OrderHistory.form b/assignment/OrderHistory.form new file mode 100644 index 0000000..8bc7c75 --- /dev/null +++ b/assignment/OrderHistory.form @@ -0,0 +1,176 @@ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + +
+
+
+
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
diff --git a/assignment/OrderHistory.java b/assignment/OrderHistory.java new file mode 100644 index 0000000..69df10d --- /dev/null +++ b/assignment/OrderHistory.java @@ -0,0 +1,220 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package javagrpassignment; + +/** + * + * @author baigs + */ +public class OrderHistory extends javax.swing.JFrame { + + /** + * Creates new form OrderHistory + */ + public OrderHistory() { + initComponents(); + this.setTitle("Order History"); + setLocationRelativeTo(null); + } + + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // //GEN-BEGIN:initComponents + private void initComponents() { + + jScrollPane1 = new javax.swing.JScrollPane(); + jTable1 = new javax.swing.JTable(); + jScrollPane2 = new javax.swing.JScrollPane(); + jTable2 = new javax.swing.JTable(); + jLabel1 = new javax.swing.JLabel(); + jLabel2 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + jButton3 = new javax.swing.JButton(); + jLabel3 = new javax.swing.JLabel(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + + jTable1.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" + } + )); + jScrollPane1.setViewportView(jTable1); + + jTable2.setModel(new javax.swing.table.DefaultTableModel( + new Object [][] { + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null}, + {null, null, null, null} + }, + new String [] { + "Title 1", "Title 2", "Title 3", "Title 4" + } + )); + jScrollPane2.setViewportView(jTable2); + + jLabel1.setText("Approved Order "); + + jLabel2.setText("Rejected Order"); + + jButton1.setText("Refresh approved table"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jButton2.setText("Refresh rejected table"); + jButton2.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton2ActionPerformed(evt); + } + }); + + jButton3.setText("Back"); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + + jLabel3.setText("Order History"); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(34, 34, 34) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGroup(layout.createSequentialGroup() + .addGap(50, 50, 50) + .addComponent(jButton1))) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 192, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 216, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(56, 56, 56)) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addComponent(jButton2) + .addGap(90, 90, 90)))) + .addGroup(layout.createSequentialGroup() + .addGap(93, 93, 93) + .addComponent(jLabel1) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) + .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE) + .addGap(102, 102, 102)) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jButton3) + .addGap(229, 229, 229) + .addComponent(jLabel3, javax.swing.GroupLayout.PREFERRED_SIZE, 85, javax.swing.GroupLayout.PREFERRED_SIZE) + .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() + .addContainerGap(10, Short.MAX_VALUE) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton3) + .addComponent(jLabel3)) + .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jLabel1) + .addComponent(jLabel2)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) + .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 209, Short.MAX_VALUE) + .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton1) + .addComponent(jButton2)) + .addGap(22, 22, 22)) + ); + + pack(); + }// //GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jButton1ActionPerformed + + private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jButton2ActionPerformed + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + // TODO add your handling code here: + VendorOrderDetails page9 = new VendorOrderDetails(); + + page9.setVisible(true); + + this.setVisible(false); + }//GEN-LAST:event_jButton3ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + // + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(OrderHistory.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(OrderHistory.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(OrderHistory.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(OrderHistory.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + // + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new OrderHistory().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JLabel jLabel1; + private javax.swing.JLabel jLabel2; + private javax.swing.JLabel jLabel3; + private javax.swing.JScrollPane jScrollPane1; + private javax.swing.JScrollPane jScrollPane2; + private javax.swing.JTable jTable1; + private javax.swing.JTable jTable2; + // End of variables declaration//GEN-END:variables +} diff --git a/assignment/VendorMenu.form b/assignment/VendorMenu.form index 52d2185..7c86802 100644 --- a/assignment/VendorMenu.form +++ b/assignment/VendorMenu.form @@ -28,26 +28,26 @@ - + - + - + - + - + @@ -73,25 +73,25 @@ - + - + - + - + - + @@ -108,9 +108,15 @@ - + + + + - + + + + @@ -120,39 +126,69 @@ - + - + - + - + - - - - + + + +
+ + + + + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + <Column maxWidth="-1" minWidth="-1" prefWidth="-1" resizable="true"> + <Title/> + <Editor/> + <Renderer/> + </Column> + </TableColumnModel> + </Property> + <Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor"> + <TableHeader reorderingAllowed="true" resizingAllowed="true"/> + </Property> </Properties> </Component> </SubComponents> </Container> - <Component class="javax.swing.JButton" name="jButton1"> + <Component class="javax.swing.JButton" name="VendorViewMenubtn"> <Properties> <Property name="text" type="java.lang.String" value="View menu"/> </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="VendorViewMenubtnActionPerformed"/> + </Events> </Component> <Component class="javax.swing.JButton" name="jButton2"> <Properties> diff --git a/assignment/VendorMenu.java b/assignment/VendorMenu.java index 2c74e30..95acf54 100644 --- a/assignment/VendorMenu.java +++ b/assignment/VendorMenu.java @@ -4,19 +4,29 @@ */ package javagrpassignment; +import java.io.BufferedReader; +import java.io.FileReader; +import java.io.IOException; +import javax.swing.JOptionPane; +import javax.swing.table.DefaultTableModel; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardOpenOption; /** * * @author baigs */ public class VendorMenu extends javax.swing.JFrame { - + + private String userID; /** * Creates new form VendorMenu */ - public VendorMenu() { + public VendorMenu(String userID) { initComponents(); this.setTitle("Vendor Menu"); setLocationRelativeTo(null); + this.userID = userID; } /** @@ -30,13 +40,13 @@ private void initComponents() { jLabel1 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel(); - jTextField1 = new javax.swing.JTextField(); - jTextField2 = new javax.swing.JTextField(); + VFoodNametxtFld = new javax.swing.JTextField(); + VFoodPricetxtFld = new javax.swing.JTextField(); jLabel3 = new javax.swing.JLabel(); - jButton3 = new javax.swing.JButton(); - jScrollPane1 = new javax.swing.JScrollPane(); - jTable1 = new javax.swing.JTable(); - jButton1 = new javax.swing.JButton(); + VendorAddMenubtn = new javax.swing.JButton(); + VendorMenuTable = new javax.swing.JScrollPane(); + VendorMenuEditTable = new javax.swing.JTable(); + VendorViewMenubtn = new javax.swing.JButton(); jButton2 = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); @@ -45,17 +55,29 @@ private void initComponents() { jLabel2.setText("Prices"); + VFoodNametxtFld.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + VFoodNametxtFldActionPerformed(evt); + } + }); + + VFoodPricetxtFld.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + VFoodPricetxtFldActionPerformed(evt); + } + }); + jLabel3.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N jLabel3.setText("Add item to Menu"); - jButton3.setText("Add menu"); - jButton3.addActionListener(new java.awt.event.ActionListener() { + VendorAddMenubtn.setText("Add menu"); + VendorAddMenubtn.addActionListener(new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { - jButton3ActionPerformed(evt); + VendorAddMenubtnActionPerformed(evt); } }); - jTable1.setModel(new javax.swing.table.DefaultTableModel( + VendorMenuEditTable.setModel(new javax.swing.table.DefaultTableModel( new Object [][] { {null, null, null, null}, {null, null, null, null}, @@ -63,12 +85,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { {null, null, null, null} }, new String [] { - "Title 1", "Title 2", "Title 3", "Title 4" + "Vendor ID", "Vendor Name", "Food Name", "Price" } )); - jScrollPane1.setViewportView(jTable1); + VendorMenuTable.setViewportView(VendorMenuEditTable); - jButton1.setText("View menu"); + VendorViewMenubtn.setText("View menu"); + VendorViewMenubtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + VendorViewMenubtnActionPerformed(evt); + } + }); jButton2.setText("Back"); jButton2.addActionListener(new java.awt.event.ActionListener() { @@ -86,22 +113,22 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGap(123, 123, 123) - .addComponent(jButton1) + .addComponent(VendorViewMenubtn) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup() - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(VendorMenuTable, javax.swing.GroupLayout.PREFERRED_SIZE, 362, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 44, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(layout.createSequentialGroup() .addComponent(jLabel2, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) - .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(VFoodPricetxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(50, 50, 50) - .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))) - .addComponent(jButton3)) + .addComponent(VFoodNametxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, 71, javax.swing.GroupLayout.PREFERRED_SIZE))) + .addComponent(VendorAddMenubtn)) .addGap(39, 39, 39)))) .addGroup(layout.createSequentialGroup() .addContainerGap() @@ -120,38 +147,107 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addComponent(jLabel3) .addComponent(jButton2)) .addGap(38, 38, 38) - .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 323, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addComponent(VendorMenuTable, javax.swing.GroupLayout.PREFERRED_SIZE, 323, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(layout.createSequentialGroup() .addGap(110, 110, 110) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jTextField1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(VFoodNametxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)) .addGap(28, 28, 28) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) - .addComponent(jTextField2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(VFoodPricetxtFld, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel2)) .addGap(55, 55, 55) - .addComponent(jButton3))) + .addComponent(VendorAddMenubtn))) .addGap(18, 18, 18) - .addComponent(jButton1) + .addComponent(VendorViewMenubtn) .addContainerGap(56, Short.MAX_VALUE)) ); pack(); }// </editor-fold>//GEN-END:initComponents - private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + private void VendorAddMenubtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VendorAddMenubtnActionPerformed // TODO add your handling code here: - }//GEN-LAST:event_jButton3ActionPerformed + // Get the data from text fields + String vendorName = VFoodNametxtFld.getText().trim(); + String price = VFoodPricetxtFld.getText().trim(); + + // Validate that both fields are not empty + if (vendorName.isEmpty() || price.isEmpty()) { + JOptionPane.showMessageDialog(this, "Please enter both Name and Prices.", "Error", JOptionPane.ERROR_MESSAGE); + return; + } + + try { + // Specify the path to your text file containing the food menu + String filePath = "C:\\Users\\baigs\\OneDrive\\Documents\\NetBeansProjects\\JavaGrpAssignment\\src\\javagrpassignment/menu_details.txt"; + + // Append the new data to the file + Files.write(Path.of(filePath), (vendorName + "\tYourStringValue\t" + price + "\n").getBytes(), StandardOpenOption.APPEND); + + // Display success message + JOptionPane.showMessageDialog(this, "Menu Updated"); + + // Clear text fields + VFoodNametxtFld.setText(""); + VFoodNametxtFld.setText(""); + + } catch (IOException ex) { + // Handle any exceptions that may occur during file writing + JOptionPane.showMessageDialog(this, "Error updating menu: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + }//GEN-LAST:event_VendorAddMenubtnActionPerformed private void jButton2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton2ActionPerformed // TODO add your handling code here: - VendorPage page6 = new VendorPage (); + VendorPage page6 = new VendorPage (userID); page6.setVisible(true); this.setVisible(false); }//GEN-LAST:event_jButton2ActionPerformed + private void VendorViewMenubtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VendorViewMenubtnActionPerformed + // TODO add your handling code here: + try { + // Specify the path to your text file containing the food menu + String filePath = "C:\\Users\\baigs\\OneDrive\\Documents\\NetBeansProjects\\JavaGrpAssignment\\src\\javagrpassignment/menu_details.txt"; + + // Read the contents of the file + BufferedReader reader = new BufferedReader(new FileReader(filePath)); + + // Clear existing table data + DefaultTableModel model = (DefaultTableModel) VendorMenuEditTable.getModel(); + model.setColumnIdentifiers(new String[]{"Vendor ID", "Vendor Name", "Food Name", "Price"}); + model.setRowCount(0); + + // Populate the table with file content + String line; + while ((line = reader.readLine()) != null) { + String[] data = line.split("\t"); + if (data.length >= 2 && userID.equals(data[0])) + model.addRow(data); + } + + reader.close(); + + JOptionPane.showMessageDialog(this, "Menu Loaded"); + + } catch (IOException ex) { +// Handle any exceptions that may occur during file reading + JOptionPane.showMessageDialog(this, "Error loading menu: " + ex.getMessage(), "Error", JOptionPane.ERROR_MESSAGE); + } + + }//GEN-LAST:event_VendorViewMenubtnActionPerformed + + private void VFoodNametxtFldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VFoodNametxtFldActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_VFoodNametxtFldActionPerformed + + private void VFoodPricetxtFldActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VFoodPricetxtFldActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_VFoodPricetxtFldActionPerformed + /** * @param args the command line arguments */ @@ -182,21 +278,21 @@ public static void main(String args[]) { /* Create and display the form */ java.awt.EventQueue.invokeLater(new Runnable() { public void run() { - new VendorMenu().setVisible(true); + new VendorMenu(userID).setVisible(true); } }); } // Variables declaration - do not modify//GEN-BEGIN:variables - private javax.swing.JButton jButton1; + private javax.swing.JTextField VFoodNametxtFld; + private javax.swing.JTextField VFoodPricetxtFld; + private javax.swing.JButton VendorAddMenubtn; + private javax.swing.JTable VendorMenuEditTable; + private javax.swing.JScrollPane VendorMenuTable; + private javax.swing.JButton VendorViewMenubtn; private javax.swing.JButton jButton2; - private javax.swing.JButton jButton3; private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel3; - private javax.swing.JScrollPane jScrollPane1; - private javax.swing.JTable jTable1; - private javax.swing.JTextField jTextField1; - private javax.swing.JTextField jTextField2; // End of variables declaration//GEN-END:variables } diff --git a/assignment/VendorOrderDetails.form b/assignment/VendorOrderDetails.form new file mode 100644 index 0000000..635d6a9 --- /dev/null +++ b/assignment/VendorOrderDetails.form @@ -0,0 +1,127 @@ +<?xml version="1.0" encoding="UTF-8" ?> + +<Form version="1.3" maxVersion="1.9" type="org.netbeans.modules.form.forminfo.JFrameFormInfo"> + <Properties> + <Property name="defaultCloseOperation" type="int" value="3"/> + <Property name="resizable" type="boolean" value="false"/> + </Properties> + <SyntheticProperties> + <SyntheticProperty name="formSizePolicy" type="int" value="1"/> + <SyntheticProperty name="generateCenter" type="boolean" value="false"/> + </SyntheticProperties> + <AuxValues> + <AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/> + <AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/> + <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> + <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> + <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> + </AuxValues> + + <Layout> + <DimensionLayout dim="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace max="-2" attributes="0"/> + <Component id="jButton5" min="-2" max="-2" attributes="0"/> + <EmptySpace min="-2" pref="146" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="79" max="-2" attributes="0"/> + <Group type="103" groupAlignment="1" attributes="0"> + <Component id="jButton4" min="-2" pref="161" max="-2" attributes="0"/> + <Component id="jButton2" min="-2" max="-2" attributes="0"/> + </Group> + <EmptySpace type="separate" max="-2" attributes="0"/> + <Group type="103" groupAlignment="0" attributes="0"> + <Component id="jButton3" min="-2" max="-2" attributes="0"/> + <Component id="jButton1" min="-2" pref="161" max="-2" attributes="0"/> + </Group> + </Group> + </Group> + <EmptySpace pref="93" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + <DimensionLayout dim="1"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" alignment="0" attributes="0"> + <Group type="103" groupAlignment="0" attributes="0"> + <Group type="102" attributes="0"> + <EmptySpace min="-2" pref="24" max="-2" attributes="0"/> + <Component id="jButton5" min="-2" max="-2" attributes="0"/> + </Group> + <Group type="102" alignment="0" attributes="0"> + <EmptySpace min="-2" pref="38" max="-2" attributes="0"/> + <Component id="jLabel1" min="-2" max="-2" attributes="0"/> + </Group> + </Group> + <EmptySpace min="-2" pref="46" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jButton4" alignment="3" min="-2" pref="38" max="-2" attributes="0"/> + <Component id="jButton1" alignment="3" min="-2" pref="40" max="-2" attributes="0"/> + </Group> + <EmptySpace min="-2" pref="25" max="-2" attributes="0"/> + <Group type="103" groupAlignment="3" attributes="0"> + <Component id="jButton3" alignment="3" min="-2" pref="40" max="-2" attributes="0"/> + <Component id="jButton2" alignment="3" min="-2" pref="43" max="-2" attributes="0"/> + </Group> + <EmptySpace pref="125" max="32767" attributes="0"/> + </Group> + </Group> + </DimensionLayout> + </Layout> + <SubComponents> + <Component class="javax.swing.JLabel" name="jLabel1"> + <Properties> + <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> + <Font name="Segoe UI" size="18" style="0"/> + </Property> + <Property name="text" type="java.lang.String" value="Menu"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jButton1"> + <Properties> + <Property name="text" type="java.lang.String" value="Check Order Details"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton1ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jButton2"> + <Properties> + <Property name="text" type="java.lang.String" value="Update Customer Order"/> + </Properties> + </Component> + <Component class="javax.swing.JButton" name="jButton3"> + <Properties> + <Property name="text" type="java.lang.String" value="Send Notification(driver)"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton3ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jButton4"> + <Properties> + <Property name="text" type="java.lang.String" value="Order History"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton4ActionPerformed"/> + </Events> + </Component> + <Component class="javax.swing.JButton" name="jButton5"> + <Properties> + <Property name="text" type="java.lang.String" value="Back"/> + </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="jButton5ActionPerformed"/> + </Events> + </Component> + </SubComponents> +</Form> diff --git a/assignment/VendorOrderDetails.java b/assignment/VendorOrderDetails.java new file mode 100644 index 0000000..bb7249b --- /dev/null +++ b/assignment/VendorOrderDetails.java @@ -0,0 +1,196 @@ +/* + * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license + * Click nbfs://nbhost/SystemFileSystem/Templates/GUIForms/JFrame.java to edit this template + */ +package javagrpassignment; + +/** + * + * @author baigs + */ +public class VendorOrderDetails extends javax.swing.JFrame { + private String userID; + /** + * Creates new form Menu_Vendor + * @param userID + */ + public VendorOrderDetails(String userID) { + initComponents(); + this.setTitle("Vendor Menu Management"); + setLocationRelativeTo(null); + this.userID = userID; + } + + /** + * This method is called from within the constructor to initialize the form. + * WARNING: Do NOT modify this code. The content of this method is always + * regenerated by the Form Editor. + */ + @SuppressWarnings("unchecked") + // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents + private void initComponents() { + + jLabel1 = new javax.swing.JLabel(); + jButton1 = new javax.swing.JButton(); + jButton2 = new javax.swing.JButton(); + jButton3 = new javax.swing.JButton(); + jButton4 = new javax.swing.JButton(); + jButton5 = new javax.swing.JButton(); + + setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); + setResizable(false); + + jLabel1.setFont(new java.awt.Font("Segoe UI", 0, 18)); // NOI18N + jLabel1.setText("Menu"); + + jButton1.setText("Check Order Details"); + jButton1.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton1ActionPerformed(evt); + } + }); + + jButton2.setText("Update Customer Order"); + + jButton3.setText("Send Notification(driver)"); + jButton3.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton3ActionPerformed(evt); + } + }); + + jButton4.setText("Order History"); + jButton4.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton4ActionPerformed(evt); + } + }); + + jButton5.setText("Back"); + jButton5.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + jButton5ActionPerformed(evt); + } + }); + + javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); + getContentPane().setLayout(layout); + layout.setHorizontalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addContainerGap() + .addComponent(jButton5) + .addGap(146, 146, 146) + .addComponent(jLabel1)) + .addGroup(layout.createSequentialGroup() + .addGap(79, 79, 79) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) + .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton2)) + .addGap(18, 18, 18) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addComponent(jButton3) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)))) + .addContainerGap(93, Short.MAX_VALUE)) + ); + layout.setVerticalGroup( + layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) + .addGroup(layout.createSequentialGroup() + .addGap(24, 24, 24) + .addComponent(jButton5)) + .addGroup(layout.createSequentialGroup() + .addGap(38, 38, 38) + .addComponent(jLabel1))) + .addGap(46, 46, 46) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton4, javax.swing.GroupLayout.PREFERRED_SIZE, 38, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton1, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addGap(25, 25, 25) + .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) + .addComponent(jButton3, javax.swing.GroupLayout.PREFERRED_SIZE, 40, javax.swing.GroupLayout.PREFERRED_SIZE) + .addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 43, javax.swing.GroupLayout.PREFERRED_SIZE)) + .addContainerGap(125, Short.MAX_VALUE)) + ); + + pack(); + }// </editor-fold>//GEN-END:initComponents + + private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed + // TODO add your handling code here: + OrderApproved_Vendor page4 = new OrderApproved_Vendor(); + page4.setVisible(true); + + this.setVisible(false); + }//GEN-LAST:event_jButton1ActionPerformed + + private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed + // TODO add your handling code here: + }//GEN-LAST:event_jButton3ActionPerformed + + private void jButton4ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton4ActionPerformed + // TODO add your handling code here: + OrderHistory page5 = new OrderHistory(); + page5.setVisible(true); + + this.setVisible(false); + + + }//GEN-LAST:event_jButton4ActionPerformed + + private void jButton5ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton5ActionPerformed + // TODO add your handling code here: + VendorPage page7 = new VendorPage(userID); + page7.setVisible(true); + + this.setVisible(false); + }//GEN-LAST:event_jButton5ActionPerformed + + /** + * @param args the command line arguments + */ + public static void main(String args[]) { + /* Set the Nimbus look and feel */ + //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; + } + } + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(VendorOrderDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(VendorOrderDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(VendorOrderDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(VendorOrderDetails.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } + //</editor-fold> + //</editor-fold> + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(new Runnable() { + public void run() { + new VendorOrderDetails().setVisible(true); + } + }); + } + + // Variables declaration - do not modify//GEN-BEGIN:variables + private javax.swing.JButton jButton1; + private javax.swing.JButton jButton2; + private javax.swing.JButton jButton3; + private javax.swing.JButton jButton4; + private javax.swing.JButton jButton5; + private javax.swing.JLabel jLabel1; + // End of variables declaration//GEN-END:variables +} diff --git a/assignment/VendorPage.form b/assignment/VendorPage.form index 5ef38fc..8348872 100644 --- a/assignment/VendorPage.form +++ b/assignment/VendorPage.form @@ -114,6 +114,9 @@ <Properties> <Property name="text" type="java.lang.String" value="Log Out"/> </Properties> + <Events> + <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="VLogOutbtnActionPerformed"/> + </Events> </Component> </SubComponents> </Form> diff --git a/assignment/VendorPage.java b/assignment/VendorPage.java index 16142df..094322f 100644 --- a/assignment/VendorPage.java +++ b/assignment/VendorPage.java @@ -5,27 +5,22 @@ package javagrpassignment; import java.io.*; +import javax.swing.JLabel; /** * * @author Yanaal */ public class VendorPage extends javax.swing.JFrame { - - /** - * Creates new form VendorPage - */ - public VendorPage() { + private String userID; + + public VendorPage(String userID) { initComponents(); this.setTitle("Home Page"); setLocationRelativeTo(null); + this.userID = userID; } - - - - - /** * This method is called from within the constructor to initialize the form. * WARNING: Do NOT modify this code. The content of this method is always @@ -81,6 +76,11 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { }); VLogOutbtn.setText("Log Out"); + VLogOutbtn.addActionListener(new java.awt.event.ActionListener() { + public void actionPerformed(java.awt.event.ActionEvent evt) { + VLogOutbtnActionPerformed(evt); + } + }); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); getContentPane().setLayout(layout); @@ -116,18 +116,17 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { private void VOrderbtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VOrderbtnActionPerformed // Open VendorOrerDetails - VendorOrderDetails page2 = new VendorOrderDetails(); - //VendorOrderDetails.setLocationRelativeTo(null); // Center Page2 on screen + VendorOrderDetails page2 = new VendorOrderDetails(userID); page2.setVisible(true); - this.setVisible(false); + }//GEN-LAST:event_VOrderbtnActionPerformed private void VMenubtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VMenubtnActionPerformed // TODO add your handling code here: createMenuFile(); - VendorMenu page3 = new VendorMenu(); + VendorMenu page3 = new VendorMenu(userID); page3.setVisible(true); this.setVisible(false); @@ -144,7 +143,7 @@ private void createMenuFile() { } // Assuming vendor details are stored in another file - File vendorDetailsFile = new File("C:\\Path\\To\\VendorDetails.txt"); + File vendorDetailsFile = new File("C:\\Users\\baigs\\OneDrive\\Documents\\NetBeansProjects\\JavaGrpAssignment\\src\\javagrpassignment\\password.txt"); try (FileReader fr = new FileReader(vendorDetailsFile); BufferedReader br = new BufferedReader(fr); @@ -154,11 +153,11 @@ private void createMenuFile() { // and vendor name is in the second column String line; while ((line = br.readLine()) != null) { - String[] vendorDetails = line.split("\t"); // Assuming tab-separated values + String[] vendorDetails = line.split(", "); // Assuming tab-separated values // Writing to the menu file: Vendor ID, Vendor Name, String Variable, Int Variable - writer.write(vendorDetails[0] + "\t"); // Vendor ID - writer.write(vendorDetails[1] + "\t"); // Vendor Name + writer.write(vendorDetails[1] + "\t"); // Vendor ID + writer.write(vendorDetails[0] + "\t"); // Vendor Name // Add your string variable here writer.write("YourStringValue" + "\t"); @@ -172,38 +171,63 @@ private void createMenuFile() { } }//GEN-LAST:event_VMenubtnActionPerformed + private void VLogOutbtnActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_VLogOutbtnActionPerformed + // TODO add your handling code here: + Login a =new Login(); + a.setVisible(true); + this.setVisible(false); + }//GEN-LAST:event_VLogOutbtnActionPerformed + /** * @param args the command line arguments */ public static void main(String args[]) { - /* Set the Nimbus look and feel */ - //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> - /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. - * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html - */ - try { - for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { - if ("Nimbus".equals(info.getName())) { - javax.swing.UIManager.setLookAndFeel(info.getClassName()); - break; - } + /* Set the Nimbus look and feel */ + //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) "> + /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel. + * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html + */ + try { + for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) { + if ("Nimbus".equals(info.getName())) { + javax.swing.UIManager.setLookAndFeel(info.getClassName()); + break; } - } catch (ClassNotFoundException ex) { - java.util.logging.Logger.getLogger(VendorPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - java.util.logging.Logger.getLogger(VendorPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { - java.util.logging.Logger.getLogger(VendorPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); - } catch (javax.swing.UnsupportedLookAndFeelException ex) { - java.util.logging.Logger.getLogger(VendorPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } - //</editor-fold> - - /* Create and display the form */ - java.awt.EventQueue.invokeLater(() -> { - new VendorPage().setVisible(true); - }); + } catch (ClassNotFoundException ex) { + java.util.logging.Logger.getLogger(VendorPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (InstantiationException ex) { + java.util.logging.Logger.getLogger(VendorPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (IllegalAccessException ex) { + java.util.logging.Logger.getLogger(VendorPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); + } catch (javax.swing.UnsupportedLookAndFeelException ex) { + java.util.logging.Logger.getLogger(VendorPage.class.getName()).log(java.util.logging.Level.SEVERE, null, ex); } + //</editor-fold> + + /* Create and display the form */ + java.awt.EventQueue.invokeLater(() -> { + // Create an instance of Login to obtain the user ID + Login login = new Login(); + login.setVisible(true); + + // Wait for the login to be completed + while (!login.isLoginComplete()) { + try { + Thread.sleep(100); // Sleep for 100 milliseconds + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + + // Get the logged-in user ID from the login page + String loggedInUserID = login.getLoggedInUserID(); + + // Create an instance of VendorPage with the obtained user ID + VendorPage vendorPage = new VendorPage(loggedInUserID); + vendorPage.setVisible(true); + }); +} // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JButton VLogOutbtn; diff --git a/assignment/menu_details.txt b/assignment/menu_details.txt new file mode 100644 index 0000000..5bd6ccf --- /dev/null +++ b/assignment/menu_details.txt @@ -0,0 +1,5 @@ +cu123456 Yang YourStringValue 123 +cu123456 Yang YourStringValue 123 +ad123456 Jas YourStringValue 123 +dm123456 Ken YourStringValue 123 +vd178345 Smitch YourStringValue 123 diff --git a/assignment/password.txt b/assignment/password.txt new file mode 100644 index 0000000..85105ca --- /dev/null +++ b/assignment/password.txt @@ -0,0 +1,5 @@ +Yang, cu123456, 1323rn3nkdmx, +Yang, cu123456, 1323rn3nkdmx, +Jas, ad123456, ewfmlksmf vj, +Ken, dm123456, dskjfncskd, +Smitch, vd178345, jzncksdjj,