public SiteManagerUI(String UserName) { initComponents(); // Setting window to center Dimension dim = Toolkit.getDefaultToolkit().getScreenSize(); this.setLocation( dim.width / 2 - this.getSize().width / 2, dim.height / 2 - this.getSize().height / 2); userService = new UserService(); itemService = new ItemService(); orderService = new RequisitionOrderService(); siteService = new SiteService(); // Deserializing try { userList = this.userService.Deserialize(UserFile); itemList = this.itemService.Deserialize(ItemFile); siteList = this.siteService.Deserialize(SiteFile); orderList = this.orderService.Deserialize(RequisitionOrderFile); } catch (IOException ex) { Logger.getLogger(RegisterUserUI.class.getName()).log(Level.SEVERE, null, ex); } catch (ClassNotFoundException ex) { Logger.getLogger(RegisterUserUI.class.getName()).log(Level.SEVERE, null, ex); } // Creating a jTable model DefaultTableModel model = new DefaultTableModel(); model.addColumn("Item"); model.addColumn("Quantity"); model.addColumn("Cost"); jTable1.setModel(model); // Creating jTable2 model DefaultTableModel model1 = new DefaultTableModel(); model1.addColumn("Order ID"); model1.addColumn("Number of Items Ordered"); model1.addColumn("Total Price of Items"); model1.addColumn("Required Date"); model1.addColumn("Status of Approval"); jTable2.setModel(model1); // Setting the username and sitename Username = UserName; // Temp variable to see if user has a site boolean found = false; for (Site site : siteList) { if (site.getSiteManagersUsername().equals(Username)) { SiteName = site.getSiteName(); found = true; break; } else { found = false; } } if (found == false) { SiteName = ""; // disabling the components because the sitemanager doesnt have a site Component[] list1 = PlaceRequisitionOrderPanel.getComponents(); Component[] list2 = SearchRequisitionOrderPanel.getComponents(); for (int i = 0; i < list1.length; i++) { list1[i].setEnabled(false); } for (int i = 0; i < list2.length; i++) { list2[i].setEnabled(false); } JOptionPane.showMessageDialog( null, "You are not assigned to a Site, please register your site with the system to continue"); } jDateRequired.setDateFormatString("dd/MM/yyyy"); jDateSet.setDateFormatString("dd/MM/yyyy"); // Setting todays date to the date chooser Date today = new Date(); jDateRequired.setDate(today); jDateSet.setDate(today); }
/** * 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() { jTabbedPane2 = new javax.swing.JTabbedPane(); PlaceRequisitionOrderPanel = new javax.swing.JPanel(); jLabel1 = new javax.swing.JLabel(); btnViewItems = new javax.swing.JButton(); cmbItems = new javax.swing.JComboBox(); jLabel2 = new javax.swing.JLabel(); txtQuantity = new javax.swing.JTextField(); btnAddItem = new javax.swing.JButton(); btnDeleteItem = new javax.swing.JButton(); jScrollPane1 = new javax.swing.JScrollPane(); jTable1 = new javax.swing.JTable(); jLabel3 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel(); jScrollPane2 = new javax.swing.JScrollPane(); txtComments = new javax.swing.JTextArea(); btnPlaceOrder = new javax.swing.JButton(); btnCheckTotal = new javax.swing.JButton(); jDateRequired = new com.toedter.calendar.JDateChooser(); SearchRequisitionOrderPanel = new javax.swing.JPanel(); jLabel7 = new javax.swing.JLabel(); jScrollPane3 = new javax.swing.JScrollPane(); jTable2 = new javax.swing.JTable(); btnViewOrders = new javax.swing.JButton(); btnViewOrderInDetail = new javax.swing.JButton(); btnDeleteOrder = new javax.swing.JButton(); btnViewAllOrders = new javax.swing.JButton(); jDateSet = new com.toedter.calendar.JDateChooser(); LogoutPanel = new javax.swing.JPanel(); jLabel5 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel(); btnLogin = new javax.swing.JButton(); setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); setTitle("Main Menu"); jLabel1.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N jLabel1.setText("Place Requisition Order"); btnViewItems.setText("View All Items"); btnViewItems.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnViewItemsActionPerformed(evt); } }); jLabel2.setText("Select Quantity"); btnAddItem.setText("Add Item"); btnAddItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnAddItemActionPerformed(evt); } }); btnDeleteItem.setText("Delete Item"); btnDeleteItem.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDeleteItemActionPerformed(evt); } }); 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); jLabel3.setText("When are these Items Required?"); jLabel4.setText("Additional Comments"); txtComments.setColumns(20); txtComments.setLineWrap(true); txtComments.setRows(5); jScrollPane2.setViewportView(txtComments); btnPlaceOrder.setText("Place Order"); btnPlaceOrder.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnPlaceOrderActionPerformed(evt); } }); btnCheckTotal.setText("Check Total"); btnCheckTotal.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnCheckTotalActionPerformed(evt); } }); javax.swing.GroupLayout PlaceRequisitionOrderPanelLayout = new javax.swing.GroupLayout(PlaceRequisitionOrderPanel); PlaceRequisitionOrderPanel.setLayout(PlaceRequisitionOrderPanelLayout); PlaceRequisitionOrderPanelLayout.setHorizontalGroup( PlaceRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( PlaceRequisitionOrderPanelLayout.createSequentialGroup() .addGap(24, 24, 24) .addGroup( PlaceRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( PlaceRequisitionOrderPanelLayout.createSequentialGroup() .addComponent(jLabel1) .addContainerGap( javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup( PlaceRequisitionOrderPanelLayout.createSequentialGroup() .addGroup( PlaceRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( PlaceRequisitionOrderPanelLayout .createSequentialGroup() .addComponent(btnViewItems) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( cmbItems, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( PlaceRequisitionOrderPanelLayout .createSequentialGroup() .addComponent( btnAddItem, javax.swing.GroupLayout.PREFERRED_SIZE, 137, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( btnDeleteItem, javax.swing.GroupLayout.PREFERRED_SIZE, 122, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED) .addComponent( btnCheckTotal, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent( jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addGroup( PlaceRequisitionOrderPanelLayout .createSequentialGroup() .addGap(13, 13, 13) .addComponent(jLabel2) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent( txtQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, 220, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup( PlaceRequisitionOrderPanelLayout .createSequentialGroup() .addGroup( PlaceRequisitionOrderPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment .LEADING) .addComponent(jLabel3) .addComponent(jLabel4)) .addGroup( PlaceRequisitionOrderPanelLayout .createParallelGroup( javax.swing.GroupLayout.Alignment .LEADING) .addGroup( PlaceRequisitionOrderPanelLayout .createSequentialGroup() .addPreferredGap( javax.swing.LayoutStyle .ComponentPlacement .RELATED, javax.swing.GroupLayout .DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(btnPlaceOrder) .addGap(43, 43, 43)) .addGroup( PlaceRequisitionOrderPanelLayout .createSequentialGroup() .addGap(18, 18, 18) .addGroup( PlaceRequisitionOrderPanelLayout .createParallelGroup( javax.swing .GroupLayout .Alignment .LEADING) .addComponent( jScrollPane2, javax.swing .GroupLayout .DEFAULT_SIZE, 199, Short.MAX_VALUE) .addComponent( jDateRequired, javax.swing .GroupLayout .DEFAULT_SIZE, javax.swing .GroupLayout .DEFAULT_SIZE, Short .MAX_VALUE)))))) .addGap(33, 33, 33))))); PlaceRequisitionOrderPanelLayout.setVerticalGroup( PlaceRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( PlaceRequisitionOrderPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(jLabel1) .addGap(18, 18, 18) .addGroup( PlaceRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnViewItems) .addComponent( cmbItems, javax.swing.GroupLayout.PREFERRED_SIZE, 23, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup( PlaceRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel2) .addComponent( txtQuantity, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup( PlaceRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnAddItem) .addComponent(btnDeleteItem) .addComponent(btnCheckTotal)) .addGap(29, 29, 29) .addComponent( jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 119, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(23, 23, 23) .addGroup( PlaceRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent(jLabel3) .addComponent( jDateRequired, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGap(18, 18, 18) .addGroup( PlaceRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( PlaceRequisitionOrderPanelLayout.createSequentialGroup() .addComponent( jScrollPane2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addComponent(btnPlaceOrder)) .addComponent(jLabel4)) .addContainerGap(52, Short.MAX_VALUE))); jTabbedPane2.addTab("Place Order", PlaceRequisitionOrderPanel); jLabel7.setText("Please select the date you set the order:"); 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"})); jScrollPane3.setViewportView(jTable2); btnViewOrders.setText("View Order(s)"); btnViewOrders.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnViewOrdersActionPerformed(evt); } }); btnViewOrderInDetail.setText("View in Detail"); btnViewOrderInDetail.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnViewOrderInDetailActionPerformed(evt); } }); btnDeleteOrder.setText("Delete Order"); btnDeleteOrder.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnDeleteOrderActionPerformed(evt); } }); btnViewAllOrders.setText("View All Orders"); btnViewAllOrders.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnViewAllOrdersActionPerformed(evt); } }); javax.swing.GroupLayout SearchRequisitionOrderPanelLayout = new javax.swing.GroupLayout(SearchRequisitionOrderPanel); SearchRequisitionOrderPanel.setLayout(SearchRequisitionOrderPanelLayout); SearchRequisitionOrderPanelLayout.setHorizontalGroup( SearchRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( SearchRequisitionOrderPanelLayout.createSequentialGroup() .addContainerGap() .addGroup( SearchRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( SearchRequisitionOrderPanelLayout.createSequentialGroup() .addGroup( SearchRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.TRAILING) .addComponent( jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE) .addGroup( SearchRequisitionOrderPanelLayout .createSequentialGroup() .addComponent(jLabel7) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement .UNRELATED) .addComponent( jDateSet, javax.swing.GroupLayout.PREFERRED_SIZE, 205, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, SearchRequisitionOrderPanelLayout.createSequentialGroup() .addGap(0, 0, Short.MAX_VALUE) .addComponent(btnViewOrders) .addGap(53, 53, 53)))) .addGroup( SearchRequisitionOrderPanelLayout.createSequentialGroup() .addGap(44, 44, 44) .addComponent(btnViewAllOrders) .addGap(18, 18, 18) .addComponent(btnDeleteOrder) .addGap(18, 18, 18) .addComponent(btnViewOrderInDetail) .addGap(0, 0, Short.MAX_VALUE))); SearchRequisitionOrderPanelLayout.setVerticalGroup( SearchRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addGroup( SearchRequisitionOrderPanelLayout.createSequentialGroup() .addGap(25, 25, 25) .addGroup( SearchRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel7) .addComponent( jDateSet, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(btnViewOrders) .addGap(18, 18, 18) .addComponent( jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 106, javax.swing.GroupLayout.PREFERRED_SIZE) .addGap(18, 18, 18) .addGroup( SearchRequisitionOrderPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnDeleteOrder) .addComponent(btnViewAllOrders) .addComponent(btnViewOrderInDetail)) .addContainerGap(312, Short.MAX_VALUE))); jTabbedPane2.addTab("Search Orders", SearchRequisitionOrderPanel); jLabel5.setText("System Developed By: Shavin/Ismail/Shivaram/Abhiramy"); jLabel6.setText("Contact: 0771870683/Sri Lanka"); btnLogin.setText("Logout"); btnLogin.addActionListener( new java.awt.event.ActionListener() { public void actionPerformed(java.awt.event.ActionEvent evt) { btnLoginActionPerformed(evt); } }); javax.swing.GroupLayout LogoutPanelLayout = new javax.swing.GroupLayout(LogoutPanel); LogoutPanel.setLayout(LogoutPanelLayout); LogoutPanelLayout.setHorizontalGroup( LogoutPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, LogoutPanelLayout.createSequentialGroup() .addContainerGap(151, Short.MAX_VALUE) .addGroup( LogoutPanelLayout.createParallelGroup( javax.swing.GroupLayout.Alignment.LEADING) .addComponent(jLabel6) .addComponent(jLabel5)) .addContainerGap()) .addGroup( LogoutPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(btnLogin) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); LogoutPanelLayout.setVerticalGroup( LogoutPanelLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( javax.swing.GroupLayout.Alignment.TRAILING, LogoutPanelLayout.createSequentialGroup() .addContainerGap() .addComponent(btnLogin) .addPreferredGap( javax.swing.LayoutStyle.ComponentPlacement.RELATED, 473, Short.MAX_VALUE) .addComponent(jLabel5) .addGap(5, 5, 5) .addComponent(jLabel6) .addContainerGap())); jTabbedPane2.addTab("Logout", LogoutPanel); 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() .addComponent(jTabbedPane2) .addContainerGap())); layout.setVerticalGroup( layout .createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup( layout .createSequentialGroup() .addContainerGap() .addComponent( jTabbedPane2, javax.swing.GroupLayout.PREFERRED_SIZE, 579, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))); pack(); } // </editor-fold>//GEN-END:initComponents