Viewing file: 2551-03-10-1.0.01-clsDefineAssessment.php (9.56 KB) -rw-r--r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
//--Class DefineAssessment--------------------------
//--PK of DefineAssessment ::
// 1. defineid
// 2. acadYear
// 3. semester
// 4. noAss
class DefineAssessment extends clsDB{
var $result;
var $defineid;
var $assid;
var $startDate;
var $endDate;
var $acadYear;
var $semester;
var $noAss;
var $flag;
var $closeDate;
function DefineAssessment(&$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->defineid=$this->GetNextCode();
$sql = "insert into DefineAssessment values(
'$this->defineid',
'$this->assid',
'$this->startDate',
'$this->endDate',
'$this->acadYear',
'$this->semester',
'$this->noAss',
'$this->flag',
'$this->closeDate'
)";
}else {
$sql = "update DefineAssessment set
assid='$this->assid',
startDate='$this->startDate',
endDate='$this->endDate',
flag='$this->flag',
closeDate='$this->closeDate'
where defineid='$this->defineid' and acadYear='$this->acadYear' and semester='$this->semester' and noAss='$this->noAss'";
}
return $this->Dml($sql);
}
function Delete(){
//--ลบข้อมูลเดิมในอ๊อบเจ๊ก, เป็นการลบข้อมูลทีละ 1 เรคอร์ด
//--ต้องเรียกเมธอดตามลำดับดังนี้ SearchByKey()-->GetRecord()-->Delete()
return $this->Dml("delete from DefineAssessment where defineid='$this->defineid' and acadYear='$this->acadYear' and semester='$this->semester' and noAss='$this->noAss'");
}
function GetNextCode(){
//--หาค่าสูงสุดของฟิลด์ที่ใช้เป็นคีย์ของตาราง ในลักษณะ auto increment
//--ต้องเป็นฟิลด์ชนิดตัวเลขจำนวนเต็มเท่านั้น และไม่ได้กำหนดรหัสเองทางจอภาพ
$this->SetQuery("select max(defineid) as num from DefineAssessment");
if ($result=$this->GetResult()) {
return $result['num']+1;
}
}
function RSDefineAssessment(){
//--เมธอดที่ขึ้นต้นด้วย RS (ResultSet) มีความหมายว่าจะได้รับข้อมูลกลับมาจากการ select มากกว่า 1 เรคอร์ด
//--จะต้องเรียกเมธอด GetRecord() ด้วยเสมอ นำข้อมูลจาก ResultSet เข้าอ๊อบเจ๊ก
//--โดยสามารถเพิ่มเมธอดได้ตามต้องการ แต่ต้องขึ้นต้นด้วย RS
$this->SetQuery("select * from DefineAssessment order by acadYear DESC, semester, noAss ");
}
function GetRecord(){
//--นำข้อมูลจาก ResultSet มากำหนดให้กับแอตทริบิวต์ของอ๊อบเจ็ก
//--เรียก GetRecord() หนึ่งครั้ง จะเลื่อนตัวชี้เรคอร์ดไปอีกหนึ่งเรคอร์ด
if ($this->result = $this->GetResult()) {
$this->defineid = $this->result['defineid'];
$this->assid = $this->result['assid'];
$this->startDate = $this->result['startDate'];
$this->endDate = $this->result['endDate'];
$this->acadYear = $this->result['acadYear'];
$this->semester = $this->result['semester'];
$this->noAss = $this->result['noAss'];
$this->flag = $this->result['flag'];
$this->closeDate = $this->result['closeDate'];
return 1;
}else {
return 0;
}
}
function SearchByKey($xKey1, $xKey2, $xKey3, $xKey4){
//--ค้นหาข้อมูลตาม PK ต้องระบุพารามิเตอร์ด้วย และต้องตามด้วยเมธอด GetRecord() เสมอ
if ($this->SetQuery("select * from DefineAssessment where defineid='$xKey1' and acadYear='$xKey2' and semester='$xKey3' and noAss='$xKey4'")){
return 1;
}else {
return 0;
}
}
//****************** You can add new functions below **********************//
function NumRow(){
return $this->GetRowSelected();
}
function SearchByFlag($xKey1){
if ($this->SetQuery("select * from DefineAssessment where flag='$xKey1' order by acadYear , semester, noAss ")){
return 1;
}else {
return 0;
}
}
function getMaxNoAss($xKey1,$xKey2){
$this->SetQuery("select max(noAss) as num from DefineAssessment where acadYear = '$xKey1' and flag = '$xKey2'");
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function getMaxNoAssByAcadSemFlag($xacadYear,$xsemester,$xflag){
$this->SetQuery("select max(noAss) as num from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and flag = '$xflag'");
if ($result=$this->GetResult()) {
return $result['num'];
}
}
function SearchByAcadSemNo($xacadYear,$xsemester,$xnoAss){
if ($this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and noAss = '$xnoAss'")){
return 1;
}else {
return 0;
}
}
function SearchByDefineid($xdefineid){
if ($this->SetQuery("select * from DefineAssessment where defineid = '$xdefineid'")){
return 1;
}else {
return 0;
}
}
function SearchByAcadSemFlag($xacadYear,$xsemester,$xflag){
if ($this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and flag = '$xflag' order by defineid")){
return 1;
}else {
return 0;
}
}
function SearchAssidByShow($xnowDate,$xflag,$xacadYear,$xsemester){
if ($this->SetQuery("select * from DefineAssessment where startDate <= '$xnowDate' and closeDate >= '$xnowDate' and flag = '$xflag' and acadYear = '$xacadYear' and semester = '$xsemester' order by defineid")){
return 1;
}else {
return 0;
}
}
//16/11/2006
function SearchByFlagAcadSem($xflag,$xacadYear,$xsemester){
if ($this->SetQuery("select * from DefineAssessment where flag = '$xflag' and acadYear = '$xacadYear' and semester = '$xsemester' order by defineid")){
return 1;
}else {
return 0;
}
}
function SearchAssidByShowFlag2($xnowDate,$xflag1,$xflag2,$xacadYear,$xsemester){
if ($this->SetQuery("select * from DefineAssessment where startDate <= '$xnowDate' and closeDate >= '$xnowDate' and (flag = '$xflag1' or flag = '$xflag2') and acadYear = '$xacadYear' and semester = '$xsemester' order by assid,flag")){
return 1;
}else {
return 0;
}
}
//16/11/2006
function SearchByFlag2FlagAcadSem($xflag1,$xflag2,$xacadYear,$xsemester){
if ($this->SetQuery("select * from DefineAssessment where (flag = '$xflag1' or flag = '$xflag2') and acadYear = '$xacadYear' and semester = '$xsemester' order by assid,flag")){
return 1;
}else {
return 0;
}
}
function SearchDefineidByAcadSemAssid($xacadYear,$xsemester,$xassid){
$this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and assid = '$xassid'");
}
function RSAssessLimitByFlag($xflag,$xstart, $xpageSize){
$this->SetQuery("select * from DefineAssessment where flag = '$xflag' order by acadYear , semester, noAss limit $xstart, $xpageSize");
}
function RSAssessLimitByAcadSemFlag($xacadYear,$xsemester,$xflag,$xstart, $xpageSize){
$this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and flag = '$xflag' order by acadYear , semester, noAss limit $xstart, $xpageSize");
}
function RSAssessLimitByAcadSemFlag2($xacadYear,$xsemester,$xflag1,$xflag2,$xstart, $xpageSize){
$this->SetQuery("select * from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and (flag = '$xflag1' or flag = '$xflag2') order by acadYear , semester, noAss limit $xstart, $xpageSize");
}
function CountDefineidByAssid($xassid){
$this->SetQuery("select count(defineid) as num from DefineAssessment where assid = '$xassid'");
$result = $this->GetResult();
return $result['num'];
}
function CountDefineidByNowDateFlagAcadSem($xnowDate,$xflag,$xacadYear,$xsemester){
$this->SetQuery("select count(assid) as num from DefineAssessment where startDate <= '$xnowDate' and endDate >= '$xnowDate' and flag = '$xflag' and acadYear = '$xacadYear' and semester = '$xsemester'");
$result = $this->GetResult();
return $result['num'];
}
//16/11/2006
function CountDefineidByFlagAcadSem($xflag,$xacadYear,$xsemester){
$this->SetQuery("select count(assid) as num from DefineAssessment where flag = '$xflag' and acadYear = '$xacadYear' and semester = '$xsemester'");
$result = $this->GetResult();
return $result['num'];
}
function CountDefineidByFlag2AcadSem($xacadYear,$xsemester,$xflag1,$xflag2){
$this->SetQuery("select count(assid) as num from DefineAssessment where acadYear = '$xacadYear' and semester = '$xsemester' and (flag = '$xflag1' or flag = '$xflag2')");
$result = $this->GetResult();
return $result['num'];
}
// closeDate
function RSDefineAssessmentByAcYAndSeAndFlagAndBetweenSCDate($acY, $se, $flg, $scDate){
$this->SetQuery("select * from DefineAssessment
where acadYear='$acY' and semester='$se' and flag='$flg' and '$scDate' between startDate and closeDate
order by defineid");
}
function RSDefineAssessmentByAcYAndSeAndFlagAndECDate($acY, $se, $flg, $ecDate){
$this->SetQuery("select * from DefineAssessment
where acadYear='$acY' and semester='$se' and flag='$flg' and endDate<'$ecDate' and closeDate>='$ecDate'
order by defineid");
}
function RSDefineAssessmentByAcYAndSeAndFlagAndCoId($acY, $se, $flg, $coId){
$this->SetQuery("select distinct(d.defineid), assid from DefineAssessment d, HoldCourse h, ClassAssess cl
where d.acadYear='$acY' and d.semester='$se' and d.flag='$flg'
and d.defineid=h.defineid and h.classId=cl.classId and cl.courseId='$coId'
order by d.defineid");
}
function RSDefineAssessmentByAcYAndSeAndFlagAndCoIdAndOfId($acY, $se, $flg, $coId, $ofId){
$this->SetQuery("select distinct(d.defineid), assid from DefineAssessment d, HoldCourse h, ClassAssess cl, ClassInStructorAssess ci
where d.acadYear='$acY' and d.semester='$se' and d.flag='$flg'
and d.defineid=h.defineid and h.classId=cl.classId and cl.courseId='$coId'
and cl.classId=ci.classId and ci.officerId='$ofId'
order by d.defineid");
}
} //--End class DefineAssessment--
?>
|