CodeCharge Studio
search Register Login  

Visual PHP Web Development

Visually Create Internationalized Web Applications, Web Reports, Calendars, and more.
CodeCharge.com

YesSoftware Forums -> CodeCharge Studio -> PHP

 Advice needed re: Editable grid or other options

Print topic Send  topic

Author Message
ckroon

Posts: 869
Posted: 02/16/2008, 6:43 PM

Hello all.
Very proud newbie coder here. I needed to create a page where a school could figure out how much they owed families for ISP reimbursements. They wanted to have it display on a page so their bookkeeper could look up a family and what they are owed. There are two different rates depending upon grade and I had to do some date lookups to see if/when they enrolled or withdrew.

They NOW want this data to be saved to a table, so they can run reports and mail merge the totals to a check writing program.

So... I need to be able to transfer the FamilyID and Total fields to a database table.
My question (finally!) is...What is the most efficient way to do this? I am thinking of making an editable grid and have that save the data in a custom Update/Insert.. but wanted to know if I have other options.

Thanks! :-D

Below is the code from the Before Show Row event of the page...feel free to criticize or copy :)

  
//Explanation: sedate=school enrolled date, osdate=official start date, oedate=official end date, wdate=withdrawal.   
The osdate and oedate are at the top of the grid in the BS event, pulled from a database table.  
   
 //set start date {d1}  
  
 if ($Container->sedate->GetValue() <= $Container->osdate->GetValue())  
   $Container->d1->SetValue( $Container->osdate->GetValue());//if enrolled prior to beg~ of term, set to beg~ of term  
 if ($Container->sedate->GetValue() > $Container->osdate->GetValue())  
   $Container->d1->SetValue( $Container->sedate->GetValue()); //if enrolled later, set to that later date  
   
 //set end date {d2}  
   
 if ($Container->wdate->GetValue() < $Container->oedate->GetValue())  
   $Container->d2->SetValue( $Container->wdate->GetValue()); // if withdrew prior to year end, set as withdrawal date  
   
 if ($Container->wdate->GetValue() >= $Container->oedate->GetValue())  
   $Container->d2->SetValue( $Container->oedate->GetValue()); //if withdrawal date was after the official end date,   
set as official end date  
   
 //calculate difference between the two days  
  
$NewGrid1->days->SetValue( (strtotime($NewGrid1->d2->GetText() ) -  
 strtotime($NewGrid1->d1->GetText() ) ) / (60 * 60 * 24) );  
  
   
 //set {rate} according to {grade}  
   
 $grade=$Container->grade->GetValue();  
 $k8 = 8;  
 $k = "K";  
   
 if ($grade<=$k8)  
 $Container->rate->SetValue (.44);  
 if ($grade>$k8)  
 $Container->rate->SetValue (.99);  
 if ($grade==$k)  
 $Container->rate->SetValue (.44);  
   
 //multiply {rate} times {days} = {total}  
 $NewGrid1->total->SetValue($NewGrid1->rate->GetValue() * $NewGrid1->days->GetValue() );  
  
//set the date fields to display so user can see what dates are being used  
  
  $NewGrid1->startdate->SetValue($NewGrid1->d1->GetValue());  
  $NewGrid1->stopdate->SetValue($NewGrid1->d2->GetValue());  
// -------------------------  
//End Custom Code  



_________________
Walter Kempees...you are dearly missed.
View profile  Send private message
datadoit
Posted: 02/17/2008, 6:53 AM

Important note: If you put in code to update/insert data to another
table via an editable grid's BeforeShowRow event, only the rows that are
'displayed' will be accessed.

This is the perfect place for a database stored procedure.
ckroon

Posts: 869
Posted: 02/17/2008, 11:15 AM

Lol. Ok. Now to find out what a stored procedure is and how to write one :)
Thanks Datadoit.
_________________
Walter Kempees...you are dearly missed.
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.

MS Access to Web

Convert MS Access to Web.
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.