diff --git a/src/main/java/com/pharmacy/Controllers/CustomerController.java b/src/main/java/com/pharmacy/Controllers/CustomerController.java index 1d85a69..87fbb52 100644 --- a/src/main/java/com/pharmacy/Controllers/CustomerController.java +++ b/src/main/java/com/pharmacy/Controllers/CustomerController.java @@ -102,7 +102,7 @@ public void deleteCustomer(String customerCode) { */ public ResultSet getCustomers() { try { - String query = "SELECT customer_code, full_name, location, phone, last_updated FROM customers"; + String query = "SELECT cid, customer_code, full_name, location, phone, last_updated FROM customers"; resultSet = statement.executeQuery(query); } catch (SQLException e) { e.printStackTrace(); diff --git a/src/main/java/com/pharmacy/Views/CustomerPage.form b/src/main/java/com/pharmacy/Views/CustomerPage.form index 528aeff..1358dd3 100644 --- a/src/main/java/com/pharmacy/Views/CustomerPage.form +++ b/src/main/java/com/pharmacy/Views/CustomerPage.form @@ -64,7 +64,6 @@ - @@ -237,7 +236,8 @@ - + + diff --git a/src/main/java/com/pharmacy/Views/CustomerPage.java b/src/main/java/com/pharmacy/Views/CustomerPage.java index 2dd0a43..1db92c8 100644 --- a/src/main/java/com/pharmacy/Views/CustomerPage.java +++ b/src/main/java/com/pharmacy/Views/CustomerPage.java @@ -159,7 +159,8 @@ public boolean isCellEditable(int rowIndex, int columnIndex) { return canEdit[columnIndex]; } }); - custTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_OFF); + custTable.setAutoResizeMode(javax.swing.JTable.AUTO_RESIZE_ALL_COLUMNS); + custTable.setRowHeight(35); custTable.setShowGrid(true); custTable.getTableHeader().setReorderingAllowed(false); custTable.addMouseListener(new java.awt.event.MouseAdapter() { @@ -248,8 +249,7 @@ public void actionPerformed(java.awt.event.ActionEvent evt) { .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) - .addComponent(entryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) - .addGap(0, 0, 0))) + .addComponent(entryPanel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addContainerGap()) ); @@ -309,10 +309,11 @@ private void custTableMouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:e for (int i = 0; i < col; i++) { data[i] = custTable.getValueAt(row, i); } - codeText.setText((String) data[0]); - nameText.setText((String) data[1]); - locationText.setText((String) data[2]); - phoneText.setText((String) data[3]); + + codeText.setText(data[1].toString()); + nameText.setText(data[2].toString()); + locationText.setText(data[3].toString()); + phoneText.setText(data[4].toString()); }//GEN-LAST:event_custTableMouseClicked private void searchTextKeyReleased(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_searchTextKeyReleased @@ -323,7 +324,11 @@ private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN loadDataSet(); }//GEN-LAST:event_refreshButtonActionPerformed - private void resizeColumnWidths() { + private void processColumns() { + // hide pid + custTable.getColumnModel().getColumn(0).setMinWidth(0); + custTable.getColumnModel().getColumn(0).setMaxWidth(0); + custTable.getColumnModel().getColumn(0).setPreferredWidth(130); custTable.getColumnModel().getColumn(1).setPreferredWidth(180); custTable.getColumnModel().getColumn(2).setPreferredWidth(250); @@ -336,7 +341,7 @@ public void loadDataSet() { try { CustomerController customerController = new CustomerController(); custTable.setModel(new DataTableModel().buildTableModel(customerController.getCustomers())); - resizeColumnWidths(); + processColumns(); } catch (SQLException e) { e.printStackTrace(); } @@ -348,7 +353,7 @@ public void loadSearchData(String text) { try { CustomerController customerController = new CustomerController(); custTable.setModel(new DataTableModel().buildTableModel(customerController.getCustomerSearch(text))); - resizeColumnWidths(); + processColumns(); } catch (SQLException e) { e.printStackTrace(); }