<?php
//--Class base_DocSecretLevel--------------------------
//--PK of base_DocSecretLevel ::
//    1. DclID
include_once "../link/keyThai.php";
class 
DocSecretLevel extends clsDB{

var 
$result;

var 
$DclID;
var 
$DclName;

function 
DocSecretLevel(&$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 DocSecretLevel values('".th2a($this->DclID)."', '".th2a($this->DclName)."')";
    }else {
        
$sql "update DocSecretLevel set DclName='".th2a($this->DclName)."' where DclID='".th2a($this->DclID)."'";
    }
    return 
$this->Dml($sql);
}

function 
Delete(){
    return 
$this->Dml("delete from DocSecretLevel where DclID='$this->DclID'");
}

function 
GetNextCode(){
    
$this->SetQuery("select max(DclID) as num from DocSecretLevel");
    if (
$result=$this->GetResult()) {
        return 
$result['num']+1;
    }
}

function 
RSDocSecretLevel(){
    
$this->SetQuery("select * from DocSecretLevel order by DclID");
}

function 
GetRecord(){
    
$numFields $this->NumField();
    
$row $this->GetResult();
    if (
$row){
        for (
$i=0$i<$numFields$i++){
            eval(
"\$this->".mysql_field_name($this->rs$i)."=\$row['".mysql_field_name($this->rs$i)."'];");
            
$this->DclName=a2th($this->DclName);
        }
        return 
true;
    }else{    
// clear value of Member;
        
for ($i=0$i<$numFields$i++){
            eval(
"\$this->".mysql_field_name($this->rs$i)."='';");
        }
        return 
false;
    }
}

function 
SearchByKey($xKey){
    if (
$this->SetQuery("select * from DocSecretLevel where DclID= '$xKey'")){ 
        return 
1;
    }else {
        return 
0;
    }
}
//****************** You can add new functions below **********************//
function SearchName($xKey){
    
$this->SetQuery("select DclName as num from DocSecretLevel where DclID= '$xKey'");
    if (
$result=$this->GetResult()) {
        return 
$result['num'];
    }
}

//--End class base_DocSecretLevel--

?>