So Right now I'm currently building a POS system using jframe while adding all my necessary functions including functional buttons I'm currently stuck on how to add item stock to my listed items so that it displays how much stocks are left and how to display or show error when an item or product is out of stock.
This is my ItemCost Function
public void ItemCost()
{
double sum = 0;
for (int i = 0; i < jTable1.getRowCount(); i++)
{
sum = sum + Double.parseDouble(jTable1.getValueAt(i, 2).toString());
}
jtxtTotal1.setText(Double.toString(sum));
double cTotal1 = Double.parseDouble(jtxtTotal1.getText());
double cTax = (cTotal1 * 0/100);
String iTotal = String.format("₱ %.2f", cTotal1);
jtxtTotal1.setText(iTotal);
}
Now this is my Change function
public void Change()
{
double sum = 0;
double tax = 0;
double cash = Double.parseDouble(jtxtCash.getText());
for (int i = 0; i < jTable1.getRowCount(); i++)
{
sum = sum + Double.parseDouble(jTable1.getValueAt(i, 2).toString());
}
double cTax = (sum * 0)/100;
double cChange = (cash -(sum + cTax));
String ChangeGiven = String.format("₱ %.2f", cChange);
jtxtChange.setText(ChangeGiven);
}
Now this is one of the example codes of my product
private void jbtnPiatosActionPerformed(java.awt.event.ActionEvent evt) {
double PriceOfItem = 30;
DefaultTableModel model = (DefaultTableModel) jTable1.getModel();
model.addRow(new Object[]{"Piatos Cheese", "1", PriceOfItem });
ItemCost();
}
so currently I have like 8 products and I'm stuck on what function should I use been researching on the internet even on youtube and books for a few days and I'm still stuck to this day. :(