Viewing file: 2552-05-19-1.0.03-clsHoldCourse.php (9.33 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//--Class HoldCourse--------------------------
//--PK of HoldCourse ::
// 1. holdid
class HoldCourse extends clsDB{
var $result;
var $holdid;
var $defineid;
var $classId;
var $ttId;
var $officerId;
function HoldCourse(&$c){
$this->c=$c->c;
$this->DB=$c->db;
}
function Save(){
//--ข้อมูลในอ๊อบเจ๊กเป็นข้อมูลใหม่หรือข้อมูลเดิม --1:ข้อมูลใหม่ 2:ข้อมูลเดิม
if ($this->status==1){
//uncomment a line below if your table use ID as running number
$this->holdid=$this->GetNextCode();
$sql = "insert into HoldCourse values(
'$this->holdid',
'$this->defineid',
'$this->classId',
'$this->ttId',
'$this->officerId'
)";
}else {
$sql = "update HoldCourse set
defineid='$this->defineid',
classId='$this->classId',
ttId='$this->ttId' ,
officerId='$this->officerId'
where holdid='$this->holdid'";
}
return $this->Dml($sql);
}
function Delete(){
//--ลบข้อมูลเดิมในอ๊อบเจ๊ก, เป็นการลบข้อมูลทีละ 1 เรคอร์ด
//--ต้องเรียกเมธอดตามลำดับดังนี้ SearchByKey()-->GetRecord()-->Delete()
return $this->Dml("delete from HoldCourse where holdid='$this->holdid'");
}
function GetNextCode(){
//--หาค่าสูงสุดของฟิลด์ที่ใช้เป็นคีย์ของตาราง ในลักษณะ auto increment
//--ต้องเป็นฟิลด์ชนิดตัวเลขจำนวนเต็มเท่านั้น และไม่ได้กำหนดรหัสเองทางจอภาพ
$this->SetQuery("select max(holdid) as num from HoldCourse");
if ($result=$this->GetResult()) {
return $result['num']+1;
}
}
function RSHoldCourse(){
//--เมธอดที่ขึ้นต้นด้วย RS (ResultSet) มีความหมายว่าจะได้รับข้อมูลกลับมาจากการ select มากกว่า 1 เรคอร์ด
//--จะต้องเรียกเมธอด GetRecord() ด้วยเสมอ นำข้อมูลจาก ResultSet เข้าอ๊อบเจ๊ก
//--โดยสามารถเพิ่มเมธอดได้ตามต้องการ แต่ต้องขึ้นต้นด้วย RS
$this->SetQuery("select * from HoldCourse order by holdid");
}
function GetRecord(){
//--นำข้อมูลจาก ResultSet มากำหนดให้กับแอตทริบิวต์ของอ๊อบเจ็ก
//--เรียก GetRecord() หนึ่งครั้ง จะเลื่อนตัวชี้เรคอร์ดไปอีกหนึ่งเรคอร์ด
if ($this->result = $this->GetResult()) {
$this->holdid = $this->result['holdid'];
$this->defineid = $this->result['defineid'];
$this->classId = $this->result['classId'];
$this->ttId = $this->result['ttId'];
$this->officerId = $this->result['officerId'];
return 1;
}else {
return 0;
}
}
function GetRecordJoinClass(){
//--นำข้อมูลจาก ResultSet มากำหนดให้กับแอตทริบิวต์ของอ๊อบเจ็ก
//--เรียก GetRecord() หนึ่งครั้ง จะเลื่อนตัวชี้เรคอร์ดไปอีกหนึ่งเรคอร์ด
if ($this->result = $this->GetResult()) {
$this->holdid = $this->result['holdid'];
$this->defineid = $this->result['defineid'];
$this->ttId = $this->result['ttId'];
$this->officerId = $this->result['officerId'];
return 1;
}else {
return 0;
}
}
function SearchByKey($xKey){
//--ค้นหาข้อมูลตาม PK ต้องระบุพารามิเตอร์ด้วย และต้องตามด้วยเมธอด GetRecord() เสมอ
if ($this->SetQuery("select * from HoldCourse where holdid= '$xKey'")){
return 1;
}else {
return 0;
}
}
//****************** You can add new functions below **********************//
function SearchByDefineid($xKey1){
if ($this->SetQuery("select * from HoldCourse where defineid='$xKey1' order by holdid")){
return 1;
}else {
return 0;
}
}
function SearchDistinctClassIdByDefineid($xKey1){
if ($this->SetQuery("select distinct classId from HoldCourse where defineid='$xKey1' order by classId")){
return 1;
}else {
return 0;
}
}
function SearchByDefineidClassId($xKey1,$xKey2){
if ($this->SetQuery("select * from HoldCourse where defineid='$xKey1' and classId = '$xKey2'")){
return 1;
}else {
return 0;
}
}
function DeleteByDefineid(){
return $this->Dml("delete from HoldCourse where defineid='$this->defineid'");
}
function CountClassIdByDefineid($xdefineid){
$this->SetQuery("select count(*) as num from HoldCourse where defineid = '$xdefineid'");
$result = $this->GetResult();
return $result['num'];
}
function JoinClassIdByDefineIdOfficerId($xKey,$yKey){
if ($this->SetQuery("select * from HoldCourse A, ClassInStructorAssess B where A.classId = B.classId and A.defineid = '$xKey' and B.officerId = '$yKey'")){
return 1;
}else {
return 0;
}
}
//12/11/2549
function JoinClassIdByDefineIdOfficerIdClassId($xKey,$yKey,$zKey){
if ($this->SetQuery("select * from HoldCourse A, ClassInStructorAssess B where A.classId = B.classId and A.defineid = '$xKey' and B.officerId = '$yKey' and B.classId = '$zKey' group by B.classId")){
return 1;
}else {
return 0;
}
}
function JoinClassIdByDefineIdOfficerIdClassIdGpOfficer($xKey,$yKey,$zKey){
if ($this->SetQuery("select * from HoldCourse A, ClassInStructorAssess B where A.classId = B.classId and A.defineid = '$xKey' and B.officerId = '$yKey' and B.classId = '$zKey' group by B.classId, B.officerId")){
return 1;
}else {
return 0;
}
}
function CountClassId(){
//$this->SetQuery("select count(*) as num from HoldCourseTmp");
$this->SetQuery("select count(*) as num
from (select distinct tt.ttClId
from TimeTableAssess tt
join ( select *
from HoldCourse
where 1
)A
on tt.ttId=A.ttId)B
");
$result = $this->GetResult();
return $result['num'];
}
function SearchByClassId($xKey){
if ($this->SetQuery("select * from HoldCourse hc
join TimeTableAssess tt on hc.ttId=tt.ttId
where tt.ttClId= '$xKey'")){
return 1;
}else {
return 0;
}
}
function SearchByttId($xKey){
if ($this->SetQuery("select * from HoldCourse
where ttId= '$xKey'")){
return 1;
}else {
return 0;
}
}
function DeleteByClassId($xKey){
return $this->Dml("delete hc.* from HoldCourse hc
join TimeTableAssess tt on hc.ttId=tt.ttId
where tt.ttClId= '$xKey'");
}
function DeleteByDefineidClassId($xKey1,$xKey2){
return $this->Dml("delete hc.* from HoldCourse hc
join TimeTableAssess tt on hc.ttId=tt.ttId
where tt.ttClId= '$xKey1'
and defineid='$xKey2' ");
}
function SearchByDefineidClassId2($xKey1,$xKey2){
if ($this->SetQuery("select * from HoldCourse hc
join TimeTableAssess tt on hc.ttId=tt.ttId
where tt.ttClId= '$xKey1'
and hc.defineid='$xKey2'")){
return 1;
}else {
return 0;
}
}
function SearchByDefineIdttId($xKey1,$xKey2){
if ($this->SetQuery("select * from HoldCourse
where defineid = '$xKey1'
and ttId= '$xKey2'")){
return 1;
}else {
return 0;
}
}
function RSAssessFlag7ByAssid($assid,$scDate,$clId){
return $this->SetQuery("select A.holdid,A.defineid,A.classId,A.ttId
from DefineAssessment df
join (select tt.*,holdid,defineid,classId
from TimeTableAssess tt
join HoldCourse hc
on tt.ttId=hc.ttId
where hc.classId='$clId'
order by tt.ttWdAcYWeekNo,tt.ttDyId
)A
on df.defineid = A.defineid
where df.flag = 7
and df.startDate <= '$scDate'
and df.closeDate >= '$scDate'
and df.assid = '$assid'
order by df.assid ,df.startDate,A.ttWdAcYWeekNo,df.isPreAssess desc,A.ttDyId");
}
function RSAssessFlag8ByAssidSCDateClId($assid,$scDate,$clId){
if ($this->SetQuery("select hc.* from HoldCourse hc
join DefineAssessment da
on hc.defineid=da.defineid
where assid = '$assid'
and da.flag = 8
and classId = '$clId'
and '$scDate' between da.startDate
and da.closeDate
order by hc.officerId,da.startDate,da.closeDate ")){
return 1;
}else {
return 0;
}
}
function SearchByDefineidClassIdOfficerId($xKey1,$xKey2,$xKey3){
if ($this->SetQuery("select * from HoldCourse where defineid='$xKey1' and classId LIKE '$xKey2' and officerId LIKE '$xKey3' ")){
return 1;
}else {
return 0;
}
}
function RSDistinctOfficerIdByDefineid($xKey){
if ($this->SetQuery("select distinct officerId from HoldCourse where defineid='$xKey' order by officerId")){
return 1;
}else {
return 0;
}
}
function JoinCISDistinctOfficerIdByDefineid($xKey){
if ($this->SetQuery("select distinct cis.officerId from HoldCourse hc
join ClassInStructorAssess cis on hc.classId = cis.classId
where hc.defineid='$xKey' order by officerId")){
return 1;
}else {
return 0;
}
}
function JoinTimeTableDistinctOfficerIdByDefineid($xKey){
if ($this->SetQuery("select distinct tt.ttOfId AS officerId from HoldCourse hc
join TimeTableAssess tt on hc.classId = tt.ttClId
where hc.defineid='$xKey'
and hc.ttId = tt.ttId
order by tt.ttOfId")){
return 1;
}else {
return 0;
}
}
function RSDistinctOfficerIdByAcYSe($xKey1,$xKey2){
if($this->SetQuery("select distinct cis.officerId from ClassAssess ca
join ClassInStructorAssess cis on ca.classId = cis.classId
where acadYear = '$xKey1'
and semester = '$xKey2'
order by cis.officerId")){
return 1;
}else{
return 0;
}
}
function SearchByDefineidClassIdOfficerIdttId($xKey1,$xKey2,$xKey3,$xKey4){
if ($this->SetQuery("select * from HoldCourse
where defineid='$xKey1' and classId LIKE '$xKey2' and officerId LIKE '$xKey3' and ttId LIKE '$xKey4' ")){
return 1;
}else {
return 0;
}
}
function RSByDefineidCourseIdOfficerId($xKey1,$xKey2,$xKey3){
if($this->SetQuery("SELECT * FROM HoldCourse hc
join ClassAssess ca on hc.classId = ca.classId
WHERE hc.defineid = $xKey1 and ca.courseId = $xKey2 and hc.officerId = $xKey3
")){
return 1;
}else{
return 0;
}
}
} //--End class HoldCourse--
?>
|