Viewing file:      clsprogramalumni.php (3.36 KB)      -rwxr-xr-x Select action/file-type:    (+) |   (+) |   (+) | Code (+) | Session (+) |   (+) | SDB (+) |   (+) |   (+) |   (+) |   (+) |   (+) |
 
<?php
 //--Class base_ProgramAlumni--------------------------
 //--PK of base_ProgramAlumni ::
 //    1. programalumniId
 
 class ProgramAlumni extends clsDB{
 
 var $result;
 
 var $programalumniId;
 var $programalumniName;
 var $pbriId;
 
 function ProgramAlumni(&$c){
     $this->c=$c->c;
     $this->DB=$c->db;
 }
 
 function AddNew(){
     $this->status = 1;
 }
 
 function Edit(){
     $this->status = 2;
 }
 
 function Save(){
 if ($this->status==1){
         $sql = "insert into ProgramAlumni values('$this->programalumniId', '$this->programalumniName', '$this->pbriId')";
     }else {
         $sql = "update ProgramAlumni set programalumniName='$this->programalumniName', pbriId='$this->pbriId' where programalumniId='$this->programalumniId'";
     }
     return $this->Dml($sql);
 }
 
 function Delete(){
     return $this->Dml("delete from ProgramAlumni where programalumniId='$this->programalumniId'");
 }
 
 function GetNextCode(){
     $this->SetQuery("select max(programalumniId) as num from ProgramAlumni");
     if ($result=$this->GetResult()) {
         return $result['num']+1;
     }
 }
 
 function RSProgramAlumni(){
     $this->SetQuery("select * from ProgramAlumni order by programalumniId");
 }
 
 function GetRecord(){
     if ($this->result = $this->GetResult()) {
         $this->programalumniId = $this->result['programalumniId'];
         $this->programalumniName = $this->result['programalumniName'];
         $this->pbriId = $this->result['pbriId'];
         return 1;
     }else {
         return 0;
     }
 }
 
 function SearchByKey($xKey){
     if ($this->SetQuery("select * from ProgramAlumni where programalumniId= '$xKey'")){ 
         return 1;
     }else {
         return 0;
     }
 }
 //****************** You can add new functions below **********************//
 function selectHTML($name, $ID=""){
     $s="<select name=\"$name\">\n";
     $s.="<option value=\"0\">---เลือกหลักสูตร---\n";
     $this->RSProgramAlumni();
     while($this->GetRecord()){
         $s.="<option value=\"$this->programalumniId\" ";
         $s.=($this->programalumniId==$ID) ? "Selected" : "" ;
         $s.=">$this->programalumniName\n";    
     }
     return $s.="</select>\n";
 }
 
 function selectHTML2($name, $ID=""){
     $s="<select name=\"$name\">\n";
     $s.="<option value=\"0\">---เลือกหลักสูตร---\n";
     $this->RSprogramalumniAt();
     while($this->GetRecord()){
         $s.="<option value=\"$this->programalumniId\" ";
         $s.=($this->programalumniId==$ID) ? "Selected" : "" ;
         $s.=">$this->programalumniName\n";    
     }
     return $s.="</select>\n";
 }
 
 function RSProgramAlumniName($xKey){
     $this->SetQuery("select * from ProgramAlumni where programalumniName like '%$xKey%'order by programalumniName ");
 }
 function RSProgramAlumniNameId($xKey){
     $this->SetQuery("select * from ProgramAlumni where programalumniName like '%$xKey%'order by programalumniName ");
 }
 
 function RSProgramAlumniLimit($xKey,$yKey,$zKey){
     $this->SetQuery("select * from ProgramAlumni where programalumniName LIKE '$zKey%' limit $xKey,$yKey");
 }
 
 function RSprogramalumniAt(){
     $this->SetQuery("select * from ProgramAlumni INNER JOIN AlumniMain ON ProgramAlumni.programalumniId = AlumniMain.programId  group by AlumniMain.programId ");
 }
 
 function NextPage($pg=1){
         if ($this->lastSql<>""){
             $this->frRowNum=($pg-1)*$GLOBALS["rowPerPage"];
             $sql = $this->lastSql." limit $this->frRowNum,".$GLOBALS["rowPerPage"];
             $this->SetQueryPage($sql);
         }
 }
 
 function NumPage() {
         return ceil($this->numRows/$GLOBALS["rowPerPage"]);
 }
 
 } //--End class base_ProgramAlumni--
 ?>
  |