Exemplo n.º 1
0
function updateItem()
{
    $itemNumber = $_POST['itemNumber'];
    $itemNum = $_POST['itemNum'];
    $description = $_POST['itemDescription'];
    $category = $_POST['category'];
    $deptName = $_POST['departmentName'];
    $purchaseCost = $_POST['purchaseCost'];
    $retailPrice = $_POST['retailPrice'];
    $updateStatement = "Update Item SET ItemNumber = '" . $itemNum . "', ItemDescription = '" . $description . "', Category = '" . $category . "', DepartmentName = '" . $deptName . "', PurchaseCost = '" . $purchaseCost . "', FullRetailPrice = '" . $retailPrice . "' WHERE ItemNumber = '" . $itemNumber . "'";
    // Execute the query--it will return either true or false
    $result = mysql_query($updateStatement);
    $message = "";
    if (!$result) {
        $message = "Error in updating Item: {$itemNum}, {$description}";
    } else {
        $message = "Data for Item: {$itemNum} updated successfully";
    }
    recalculateSalePrice($itemNum);
    showItemUpdateResult($message, $itemNum, $description, $category, $deptName, $purchaseCost, $retailPrice);
}
Exemplo n.º 2
0
function updatePromotion()
{
    $promoCode = $_POST['promoCode'];
    $promoName = $_POST['promoName'];
    $description = $_POST['promoDescription'];
    $amountOff = $_POST['amountOff'];
    $promoType = $_POST['promoType'];
    if ($promoType == 'Percent' && $amountOff >= 1) {
        $amountOff = str_replace("%", "", $amountOff);
        $amountOff = $amountOff / 100;
    }
    $updateStatement = "Update Promotion SET Name = '" . $promoName . "', Description = '" . $description . "', AmountOff = '" . $amountOff . "', PromoType = '" . $promoType . "' WHERE PromoCode = '" . $promoCode . "'";
    // Execute the query--it will return either true or false
    $result = mysql_query($updateStatement);
    $message = "";
    if (!$result) {
        $message = "Error in updating Promotion: {$promoCode}, {$description}";
    } else {
        $message = "Data for Promotion: {$promoCode} updated successfully";
    }
    recalculateSalePrice($promoCode);
    showItemUpdateResult($message, $promoCode, $description, $promoName, $amountOff, $promoType);
}