How to Check Old Record Before Add?

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
alivepro
User
Posts: 6

How to Check Old Record Before Add?

Post by alivepro »

Hi,

Check old records fields for before add.
If there is the same date and user record, it will give a warning, and it will give a yes or no warning to save.


arbei
User
Posts: 9384

Post by arbei »

You may use Row_Inserting server to event to execute a query to check, e.g. you may use ExecuteScalar().


alivepro
User
Posts: 6

Post by alivepro »

Can you explain this with an example code?


arbei
User
Posts: 9384

Post by arbei »

You may click above links, read the examples and try to put them together. If your code does not work, you may post it here for discussion.


alivepro
User
Posts: 6

Post by alivepro »

My code:

function Row_Inserting($rsold, &$rsnew) {

	$skontrol  = ExecuteScalar("SELECT count(*) FROM e_egitim_plani_detay where salon = '".$rsnew["salon"]."' and tarih = '".$rsnew["tarih"]."'");
	$etkontrol  = ExecuteScalar("SELECT count(*) FROM e_egitim_plani_detay where egitmen = '".$rsnew["egitmen"]."' and tarih = '".$rsnew["tarih"]."'");
	$tarih = date("d/m/Y", strtotime($rsnew["tarih"]));
	if($etkontrol > 0){
	$this->CancelMessage = "".$rsnew["egitmen"]." , $tarih tarihinde eğitimi bulunmaktadır, lütfen farklı bir eğitmen seçiniz.";
	return false;
	}elseif($skontrol > 0){
	$this->CancelMessage = "".$rsnew["salon"]." , $tarih tarihinde eğitimi bulunmaktadır, lütfen farklı bir salon seçiniz.";
	return false;
	}else{
	return TRUE;	  
	}}

I want a popup to open instead of CancelMessage, and I want it to return true when you click yes, and return false when you click no.


arbei
User
Posts: 9384

Post by arbei »

As explained and replied:
viewtopic.php?t=41668


Post Reply