Jump to content

  • Log In with Google      Sign In   
  • Create Account

problem with updating item count based on customer amount ordered.


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 Enerjak   Members   -  Reputation: 235

Like
0Likes
Like

Posted 08 November 2012 - 02:40 PM

so, uh sorry for once again bothering this great forum with my silly questions........but having a bit of an arithimetic problem....(seems easy in theory at least...). anyways, my problem is that i can't get the item to update properly once the customer orders the amount items: case in point:

(i can't paste a picture........I've lost the control panel on top.....anyways, i'll try my best to explain it.

private void purchase()
{
  HardwareItem Item = null;
  Customer customer = null;
 
  Item = store.getStock().elementAt(this.itemSelection.getSelectedIndex() - 1);
 
  if(Item != null)
  {
   for(int cust = 0; cust < custList.getLength(); cust++)
   {
    customer = custList.elementAt(cust);
   
    String order = this.customerAmount.getText();
   
    int amount = Integer.parseInt(order);
   
    int itemAmount = Item.getNumOfPartsLeft();
   
    int old = 0;
    amount++;
    old = amount;
    itemAmount -= old;
   
   
    if(itemAmount <= 0)
    {
	 itemAmount = 0;
	
	 if(itemAmount == 0)
	 {
	  JOptionPane.showMessageDialog(null, "the item with name: " + Item.getItemName() + " is out of stock");
	 }
    }
    customer.setOrdered(amount);
    Item.setNumOfPartsLeft(itemAmount);
    this.partsL.setText(" " + Item.getNumOfPartsLeft());
   }
  }
}

ok, i can post links now....

http://puu.sh/1nWw0

that's one

now another:

http://puu.sh/1nWwT

hopefully this is better.

Sponsor:

#2 Enerjak   Members   -  Reputation: 235

Like
0Likes
Like

Posted 08 November 2012 - 06:53 PM

please ignore this thread.........




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS