Skip to content
This repository has been archived by the owner on Dec 15, 2022. It is now read-only.

Commit

Permalink
fix missing cid in operations
Browse files Browse the repository at this point in the history
  • Loading branch information
jhdcruz committed Dec 12, 2022
1 parent 7bec8ca commit 17298e2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/com/pharmacy/Views/CustomerPage.form
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
<Component id="jSeparator2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="entryPanel" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
Expand Down Expand Up @@ -237,7 +236,8 @@
<Column editable="false" title="Title 4" type="java.lang.Object"/>
</Table>
</Property>
<Property name="autoResizeMode" type="int" value="0"/>
<Property name="autoResizeMode" type="int" value="4"/>
<Property name="rowHeight" type="int" value="35"/>
<Property name="showGrid" type="boolean" value="true"/>
<Property name="tableHeader" type="javax.swing.table.JTableHeader" editor="org.netbeans.modules.form.editors2.JTableHeaderEditor">
<TableHeader reorderingAllowed="false" resizingAllowed="true"/>
Expand Down
25 changes: 15 additions & 10 deletions src/main/java/com/pharmacy/Views/CustomerPage.java
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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())
);

Expand Down Expand Up @@ -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
Expand All @@ -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);
Expand All @@ -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();
}
Expand All @@ -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();
}
Expand Down

0 comments on commit 17298e2

Please sign in to comment.