* @param pQuantity Type: int
* @param pPrice Type: float
*/
public void incrementHolding(String pCustomerName, String pStockName, int pQuantity, float pPrice) {
Customer oneCustomer = null;
Holding custHolding = null;
float costOfStock = pQuantity*pPrice;
oneCustomer = this.getCustomer(pCustomerName);
if (oneCustomer.getCashBalance() > costOfStock) {
try {
oneCustomer.setCashBalance(oneCustomer.getCashBalance()-costOfStock);
// custHolding = self.GetHolding(pCustomer=oneCustomer,pGetHoldStockName=pStockName);
custHolding = customerDAO.SQLSelectHolding(pCustomerName, pStockName);
custHolding.setQuantity(custHolding.getQuantity()+pQuantity);
customerDAO.SQLUpdateHolding(custHolding);
customerDAO.SQLUpdateCashBal(oneCustomer.getCustomerName(), oneCustomer.getCashBalance());
}
catch (NoSuchHoldingException noHolding) {
Holding newHolding = new Holding();
newHolding.setCustomerName(pCustomerName);
newHolding.setPrice(pPrice);
newHolding.setQuantity(pQuantity);
newHolding.setStockName(pStockName);
customerDAO.SQLInsertHolding(newHolding);
customerDAO.SQLUpdateCashBal(oneCustomer.getCustomerName(), oneCustomer.getCashBalance());
// oneCustomer.HoldingList.AppendRow(object=newHolding);