CodeCharge Studio
search Register Login  

Visual Web Reporting

Visually create Web Reports in PHP, ASP, .NET, Java, Perl and ColdFusion.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 help: if else statement

Print topic Send  topic

Author Message
dzulishak

Posts: 12
Posted: 12/19/2012, 6:26 PM

Hello,
can some one help me using if else statement in codecharge using php?

i want to add if else statement to check if $ bakiasal < jum_tolak ( error message : Baki tidak mencukupi) then if the $bakiasal is greater then jum_tolak then the system wil do the deduction. can someone help me?
--before insert--
$tarif2=CCGetFromGet(id_tarif);
$bakiasal=CCGetFromGet(baki_kuantiti);
$jumtolak= $tolak->jum_keluar->GetValue();
//penolakan
$jumbaru = $bakiasal - $jumtolak;
$tolak->Label3->SetValue($jumbaru);
//update row table tarif
$db= new clsDBkuantiti;
$sql="UPDATE tarif SET baki_kuantiti =$jumbaru WHERE id_tarif=". $tarif2;
$db->query($sql);
$db->close;
View profile  Send private message
saseow

Posts: 744
Posted: 12/19/2012, 8:01 PM

It works something like this:

--before insert--
$tarif2=CCGetFromGet(id_tarif);
$bakiasal=CCGetFromGet(baki_kuantiti);
$jumtolak= $tolak->jum_keluar->GetValue();
//here is the check
if ($bakiasal < $jumtolak)
{
$Container->Errors->addError("Bakiasal is smaller than Jumtoluk!");
}
else
{
//penolakan
$jumbaru = $bakiasal - $jumtolak;
$tolak->Label3->SetValue($jumbaru);
//update row table tarif
$db= new clsDBkuantiti;
$sql="UPDATE tarif SET baki_kuantiti =$jumbaru WHERE id_tarif=". $tarif2;
$db->query($sql);
$db->close;
}
View profile  Send private message
dzulishak

Posts: 12
Posted: 12/19/2012, 8:54 PM

Quote saseow:
It works something like this:

--before insert--
$tarif2=CCGetFromGet(id_tarif);
$bakiasal=CCGetFromGet(baki_kuantiti);
$jumtolak= $tolak->jum_keluar->GetValue();
//here is the check
if ($bakiasal < $jumtolak)
{
$Container->Errors->addError("Bakiasal is smaller than Jumtoluk!");
}
else
{
//penolakan
$jumbaru = $bakiasal - $jumtolak;
$tolak->Label3->SetValue($jumbaru);
//update row table tarif
$db= new clsDBkuantiti;
$sql="UPDATE tarif SET baki_kuantiti =$jumbaru WHERE id_tarif=". $tarif2;
$db->query($sql);
$db->close;
}
thanks saseow it's work ;-)
View profile  Send private message
dzulishak

Posts: 12
Posted: 12/19/2012, 11:31 PM

1 question...how to prevent data to record?
View profile  Send private message
saseow

Posts: 744
Posted: 12/20/2012, 2:36 AM

The $Container->Errors will stop the data from being inserted.
Search the help file for InsertAllowed to see how to do it without adding custom error messages.

e.g.

$items->InsertAllowed = false;
View profile  Send private message
dzulishak

Posts: 12
Posted: 12/20/2012, 5:12 PM

ok.thanks sesow for advice..will try it.. :-P
View profile  Send private message
dzulishak

Posts: 12
Posted: 12/27/2012, 12:13 AM

i just got 1 question:
i have 2 database db A and db B if iuse if else statement :

if ($bakiasal < $jumtolak)
{
$Container->Errors->addError("Bakiasal is smaller than Jumtoluk!");
}
else
{
//penolakan (DATABASE B)
$jumbaru = $bakiasal - $jumtolak;
$tolak->Label3->SetValue($jumbaru);
//update row table tarif
$db= new clsDBkuantiti;
$sql="UPDATE tarif SET baki_kuantiti =$jumbaru WHERE id_tarif=". $tarif2;
$db->query($sql);
$db->close;

what should i do to prevent database A from save data if ($bakiasal < $jumtolak) ?

anyone can help me? :(
View profile  Send private message
Lucius

Posts: 220
Posted: 01/09/2013, 6:49 AM

I don't know if you are looking exactly for this, but check CCS help (F1 in designer) and search this topic: InsertAllowed Run-Time Property (PHP)
View profile  Send private message

Add new topic Subscribe to topic   


These are Community Forums for users to exchange information.
If you would like to obtain technical product help please visit http://support.yessoftware.com.

Web Database

Join thousands of Web developers who build Web applications with minimal coding.
CodeCharge.com

Home   |    Search   |    Members   |    Register   |    Login


Powered by UltraApps Forum created with CodeCharge Studio
Copyright © 2003-2004 by UltraApps.com  and YesSoftware, Inc.