Você está na página 1de 3

function Row_Inserting($rsold, &$rsnew) {

// Enter your code here


// To cancel, set return value to FALSE

$MyCount = ew_ExecuteScalar("SELECT COUNT(*) from AME_LMCP where UID=(" .


$rsnew["UID"] . ")");
if ($MyCount !=0){

$this->setFailureMessage("Failed to add the record");


return FALSE;
}
else
return True;
}
-----------------------------------------------------------------------------------
-------------------------
// Row Inserted event
function Row_Inserted($rsold, &$rsnew) {

//echo "Row Inserted"


if ($rsnew["final_cat"] == "RME")
{
$MyResult = ew_Execute(" insert into AME_RMEM (UID,Year) values
('" . $rsnew["UID"] . "','" . $rsnew["AME_YR"] . "')");
$MyResult = ew_Execute(" insert into AME_RMED (UID,Year) values
('" . $rsnew["UID"] . "','" . $rsnew["AME_YR"] . "')");
}
}

--------------other-----------
$sql = "select LMC_Permanent from AME_LMCP where uid=('" . $rsnew["UID"] .
"')";
$stmt = $conn->prepare($sql);
$stmt->bindParam(':id_var', $id_var);
$stmt->execute();
if($stmt->fetch()) {
// row found
} else {
// row not found
}
$stmt->closeCursor();

global $conn;
// Get component based on ID_Products
$rs = $conn->Execute("select LMC_Permanent from AME_LMCP where uid=('" .
$rsnew["UID"] . "')");
if ($rs->RecordCount() > 0)
{
$MyResult = ew_Execute("insert into AME_LMCT (UID,Year,Remarks,Shape) values
('" . $rsnew["UID"] . "','" . $rsnew["AME_YR"] . "','" . $rsnew["Remarks"] .
"','" . $rsnew["final_cat"] . "')");
}
}

$query = "SELECT username from my_table where username='bob'";


$result = mysql_query($query);
if(mysql_num_rows($result) > 0)
{
// row exists. do whatever you would like to do.
}

$Shape= '" . $rsnew["final_cat"] . "';


if ( $Shape!="SHAPE1")
{
$MyResult = ew_Execute("IF NOT EXISTS (select * from AME_LMCP
where uid=('" . $rsnew["UID"] . "')) BEGIN insert into AME_LMCT
(UID,Year,Remarks,Shape) values ('" . $rsnew["UID"] . "','" . $rsnew["AME_YR"] .
"','" . $rsnew["Remarks"] . "','" . $rsnew["final_cat"] . "') END");
}

("
IF NOT EXISTS (select * from AME_LMCP where uid=('" .
$rsnew["UID"] . "'))
BEGIN
insert into AME_LMCT (UID,Year,Remarks,Shape) values ('" .
$rsnew["UID"] . "','" . $rsnew["AME_YR"] . "','" . $rsnew["Remarks"] . "','" .
$rsnew["final_cat"] . "')
");

("
IF NOT EXISTS (select * from AME_LMCP where uid=16010543)
BEGIN
insert into AME_LMCT (UID,Year,Remarks,Shape) values ('" .
$rsnew["UID"] . "','" . $rsnew["AME_YR"] . "','" . $rsnew["Remarks"] . "','" .
$rsnew["final_cat"] . "')
");

$Shape= ($rsnew["final_cat"]);
if ( $Shape=="RME")
{
$MyResult = ew_Execute(" insert into AME_RMEM (UID,Year) values ('" .
$rsnew["UID"] . "','" . $rsnew["AME_YR"] . "','" . $rsnew["ame_dT"] . "','" .
$rsnew["Remarks"] . "','" . $rsnew["final_cat"] . "')");
$MyResult = ew_Execute(" insert into AME_RMED (UID,Year) values ('" .
$rsnew["UID"] . "','" . $rsnew["AME_YR"] . "','" . $rsnew["ame_dT"] . "','" .
$rsnew["Remarks"] . "','" . $rsnew["final_cat"] . "')");

}
$MyResult = ew_Execute(" insert into AME_SHP (UID,Year) values ('" . $rsnew["UID"]
. "','" . $rsnew["AME_YR"] . "','" . $rsnew["ame_dT"] . "','" . $rsnew["Remarks"] .
"','" . $rsnew["final_cat"] . "')");

// Get a field value


// NOTE: Modify your SQL here, replace the table name, field name and the condition
$MyField = ew_ExecuteScalar("SELECT MyField FROM MyTable WHERE XXX");
$limit = ew_ExecuteScalar("SELECT products FROM yourtable WHERE pkg = " .
$rsnew["pkg"]); // assume pkg is your selection
$ri = ew_ExecuteScalar("SELECT COUNT(*) FROm YourTable WHERE ID = " .
$rsnew["ID"]); // assume ID is your ID
if ($ri > $limit) {
$this->CancelMessage = "Exceeded the record";
return FALSE; // cancel the insert/update
} else {
return TRUE;
}

Você também pode gostar