Sun 11 Jun 2006 17:24:20
อยากรู้ว่าถ้าเราตั้งสถานะไว้ระหว่าง 0 ,1 ใช่เป็น 1 ไม่เป็น 0 เมื่อเราทำงานแล้วเมื่อใช่สถานะก็เป็น 1 แต่พอจะยกเลิกสถานะไม่กลับมาเป็น 0 ให้เราต้องทำยังไง หรือว่าช่วยดูโค้ดและช่วยแก้ให้จะได้ไหมค่ะ
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<%
'on error resume next
Process = request("Process")
TotalItem = request("TotalItem")
ID_Marjor=request("ID_Marjor")
ID_Section=request("ID_Section")
ID_Student=request("ID_Student")
ChkOnline=request("ChkOnline")
Data=request("Data")
Table = "M_MainSubject"
Url = "Default.asp?Page=M_MainSubject"
Order=" Order By IDRef Desc"
'============= use for Function CountRecord and ShowTopic ==============
If Process = "Delete" Then
'Set Rs_Del = Conn.execute("Update M_Student set Statuss = 0 WHERE IDRef In (Select ID_Student From M_MainSubject WHERE IDRef IN ('"&CmdTxt&"'))")
For NumOfData = 1 to TotalItem
StrDel = request("check"&NumOfData)
if StrDel <> "" Then
CmdTxt = CmdTxt&StrDel&","
End if
Next
'CmdTxt = Left(CmdTxt,len(CmdTxt) - 1)
CmdTxt = Left(CmdTxt,len(CmdTxt) - 1)
'Response.Write("Update M_Student set Statuss = 0 WHERE IDRef In (Select ID_Student From M_MainSubject WHERE IDRef IN ('"&CmdTxt&"'))")
'Response.End()
'Set Rs_Del = Conn.execute("Update M_Student set Statuss = 0 WHERE IDRef In (Select ID_Student From M_MainSubject WHERE IDRef IN ('"&CmdTxt&"'))")
'Set Rs_Del = Conn.execute("Delete From M_MainSubject WHERE IDRef IN ('"&CmdTxt&"')")
'X = "Update M_Student set Statuss= 0 where IDRef IN ('"&CmdTxt&"')"
'Set Rs_Del = Conn.execute("Update M_Student set Statuss= 0 where IDRef IN ('"&CmdTxt&"')")
'Set Rs_Del = Conn.execute("Update M_Student set Statuss = 0 WHERE RefID In (Select ID_Student From "&Table&" WHERE IDRef IN ('"&CmdTxt&"'))")
'Set Rs_Del = Conn.execute("Update M_Student set Statuss = 0 WHERE ID_Student In (Select ID_Student From "&Table&" WHERE IDRef IN ('"&CmdTxt&"'))")
'Set Rs_Del = Conn.execute("Update M_Student set Statuss = 0 WHERE IDRef In (Select ID_Student From M_MainSubject WHERE IDRef IN ('"&CmdTxt&"'))")
'Set Rs_Del = Conn.execute("Update M_Student set Statuss = 0 WHERE IDRef In (Select ID_Student From M_MainSubject WHERE IDRef IN ('"&CmdTxt&"'))")
Set Rs_Del = Conn.execute("Delete From "&Table&" WHERE IDRef IN ('"&CmdTxt&"')")
'Response.Write( X )
'Set Rs_Del = Conn.execute("Update M_Student set Statuss = 0 WHERE IDRef In (Select ID_Student From M_MainSubject WHERE IDRef IN ('"&CmdTxt&"'))")
'Response.Write("Update M_Student set Statuss = 0 WHERE IDRef In (Select ID_Student From M_MainSubject WHERE IDRef IN ('"&CmdTxt&"'))")
'Response.End()
response.redirect(Url)
End If
' If Process = "Delete" Then
'Table2 = "M_Student "
' StrSQL2 = "Select * from "&Table2
' Set strRS = Server.CreateObject("Adodb.Recordset")
' strRS.open StrSQL2,Conn,1,3
' strRs.Addnew()
' strRs("ID_Student") = ID_Student
' strRs("statuss ") = 0
' strRs.update()
' strRs.close
' set strRs = nothing
' ID_Student = session("User")
'//Table4 = "M_Student"
' StrSQL2 = "Update M_Student set Statuss = 0 where IDRef = " & ID_Student
' Set strRS = Server.CreateObject("Adodb.Recordset")
' strRS.open StrSQL2,Conn,1,3
' strRs.Update()
'//strRs("ID_Student") = ID_Student
'//strRs("ID_Subject") = ID_Subject
'//strRs.update()
' strRs.close
'set strRs = nothing
'end if
Find_Field1 = "ID_Marjor"
Find_Field2 = "ID_Section"
Find_Field3 = "Name"
Find_Field4 = "Surname"
Find_Field5 = "Email"
Find_Field6 = "Online"
Find_Field7 = "IDRef"
Find_Field8 = "ID_Student"
Find_Field9 = "ID_Year"
Find_Field10 = "ID_Term"
if ID_Marjor <> "" and ID_Section <> ""and ID_Student <> "" and ID_Year <> "" and ID_Term<> "" and ChkOnline <> "" and Data <> "" Then
Data = ClearSingleQuote(Data)
Condition = " where "&_
Find_Field1&"="&ID_Marjor &" and "&_
Find_Field2&"="&ID_Section &" and "&_
Find_Field8&"="&ID_Student &" and "&_
Find_Field9&"="&ID_Year &" and "&_
Find_Field10&"="&ID_Term &" and "&_
Find_Field6&"='"&ChkOnline&"' or "&_
Find_Field3&" like '%"& Data &"%' or "&_
Find_Field4&" like '%"& Data &"%' or "&_
Find_Field5&" like '%"& Data &"%' or "&_
Find_Field7&" like '"& Data &"' "
elseif ID_Marjor <> "" and ID_Section <> ""and ID_Student <> "" and ID_Year <> "" and ID_Term<> "" and ChkOnline <> "" Then
Condition = " where "&_
Find_Field1&"="&ID_Marjor &" and "&_
Find_Field2&"="&ID_Section &" and "&_
Find_Field8&"="&ID_Student &" and "&_
Find_Field9&"="&ID_Year &" and "&_
Find_Field10&"="&ID_Term &" and "&_
Find_Field6&"='"&ChkOnline&"'"
elseif ID_Marjor <> "" and ID_Section <> ""and ID_Student <> ""and ID_Year <> "" and ID_Term<> "" Then
Condition = " where "&_
Find_Field1&"="&ID_Marjor &" and "&_
Find_Field2&"="&ID_Section &"and"&_
Find_Field9&"="&ID_Year &" and "&_
Find_Field10&"="&ID_Term &" and "&_
Find_Field8&"="&ID_Student
elseif ID_Marjor <> ""and ID_Section <> "" and ID_Year <> "" and ID_Term<> "" Then
Condition = " where "&_
Find_Field1&"="&ID_Marjor &"and"&_
Find_Field2&"="&ID_Section&"and"&_
Find_Field9&"="&ID_Year &" and "&_
Find_Field10&"="&ID_Term
elseif ID_Marjor <> ""and ID_Section <> "" and ID_Year <> "" Then
Condition = " where "&_
Find_Field2&"="&ID_Section&"and"&_
Find_Field9&"="&ID_Year &" and "&_
Find_Field1&"="&ID_Marjor
elseif ID_Section <> ""and ID_Marjor <> ""Then
Condition = " where "&_
Find_Field2&"="&ID_Section&"and"&_
Find_Field1&"="&ID_Marjor
elseif ID_Marjor <> "" Then
Condition = " where "&_
Find_Field1&"="&ID_Marjor
elseif ID_Section <> ""Then
Condition = " where "&_
Find_Field2&"="&ID_Section
elseif ID_Student <> "" Then
Condition = " where "&_
Find_Field8&"="&ID_Student
elseif ID_Year <> "" Then
Condition = " where "&_
Find_Field9&"="&ID_Year
elseif ID_Term<> "" Then
Condition = " where "&_
Find_Field9&"="&ID_Term
elseif ChkOnline <> "" Then
Condition = " where "&Find_Field6&"='"& ChkOnline &"'"
elseif Data <> "" Then
Condition = " where "&_
Find_Field3&" like '%"& Data &"%' or "&_
Find_Field4&" like '%"& Data &"%' or "&_
Find_Field5&" like '%"& Data &"%' or "&_
Find_Field7&" like '"& Data &"' "
else
Condition=" "
End if
TotalRecord = CountRecord(Table,Condition)
%>
<script language="JavaScript" >
function chk_adddisable(id)
{
f = document.form;
fa = window;
// f.SubPgTypeId.value="";
sp_id = f.allgroup.value.split(",");
for(i=0;i<sp_id.length;i++){
if(sp_id[i] != ""){eval("f.PgType"+sp_id[i]+".value=''");
if(sp_id[i] == id){eval("f.PgType"+sp_id[i]+".style.display=''");
eval("fa.PgType"+sp_id[i]+".style.display=''");
}
else{eval("fa.PgType"+sp_id[i]+".style.display='none'");}
}
}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
window.open(theURL,winName,features);
}
</script>
<link href="../../_Css/Styles.css" rel="stylesheet" type="text/css">
<form name="form" action="Default.asp?Page=<%=server.URLEncode("M_MainSubject")%>" method="post">
<table width="100%" border="0" align="center" cellpadding="2" cellspacing="0" bordercolor="#888A7D" class="FontMenu">
<tr>
<td>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="<%=bg_table_admin%>" class="detail">
<tr>
<td colspan="3">
<table class="FontNormal" width="100%" align="center" cellpadding="2" cellspacing="0" border="1" bordercolor="#f0f0f0">
<tr>
<td colspan="15">
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="detail" >
<tr>
<td width="52%"> <img src="<%=path_link%>_Images/icon/icon_ftp.gif" align="absmiddle">
<a href="Default.asp?Page=<%=server.URLEncode("M_MainSubject")%>" title="Home Default"><font color="#FF0000">˹éÒáá</font></a>
<%'if Getsinglefield("M_User","ID_Level"," Where ID_Level="&Session("ID_Level")) = 1 then %>
<img src="<%=path_link%>_Images/icon/i_151.gif" align="absmiddle"><a href="Default.asp?Page=<%=server.URLEncode("M_MainSubjectManage")%>&Events=Add" title="Add Data"><font color="#FF0000">
à¾ÔèÁ </font></a>
<%'end if%>
<img src="../_Images/icon/i_141.gif"> <a href="#" onclick="MM_openBrWindow('MainSubject/SetingRegis.asp','SetingRegis','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=300,height=300')"><font color="#FF0000">µÑ駤èÒ¡ÒÃà»Ô´ÃѺÊÁѤÃ</font></a>
<img src="<%=path_link%>_Images/icon/i_151.gif" align="absmiddle"><a href="../admin/MainSubject/NoSetting.asp" ><font color="#FF0000">ÂѧäÁèàÅ×Í¡ÃÒÂÇÔªÒ</font>
</a>
<%'end if%>
</td>
<td width="48%" colspan="2"><div align="center" class="FontTitle"><font color="#0000FF"><strong>=
= = = ¨Ñ´¡ÒâéÍÁÙÅ¡ÒÃàÅ×Í¡ÇÔªÒàÃÕ¹ ? = = = = </strong></font></div></td>
</tr>
<tr>
<td colspan="4">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<!--DWLayoutTable-->
<tr>
<td width="23%" height="22" align="right" valign="top">
<%
Table2= "M_Faculty"
Table2Call= "MD_Marjor"
Condition2= ""
SelectName2= "ID_Faculty"
FieldValue2= "IDRef"
FieldDesc2= "Items"
ValueExp2= ID_Faculty
CJava2= ""
Str_Property2= "class=FontNormal"
'Call ListBox4("== All Faculty ==",Table2,Condition2,SelectName2,FieldValue2,FieldDesc2,ValueExp2,CJava2,Table2Call)
%> </td>
<td width="87"> </td>
<td width="143" align="right" valign="top"> <%
Table2= "MD_Year"
Table2Call= "M_MainSubject"
Condition2= ""
SelectName2= "ID_Year"
FieldValue2= "IDRef"
FieldDesc2= "Items"
ValueExp2= ID_Year
CJava2= ""
Str_Property2= "class=FontNormal"
'Call ListBox4("== àÅ×Í¡»Õ¡ÒÃÈÖ¡ÉÒ==",Table2,Condition2,SelectName2,FieldValue2,FieldDesc2,ValueExp2,CJava2,Table2Call)
%> </td>
<td width="139" align="right" valign="top"> <%
Table2= "MD_Term"
Table2Call= "M_MainSubject"
Condition2= ""
SelectName2= "ID_Term"
FieldValue2= "IDRef"
FieldDesc2= "Items"
ValueExp2= ID_Term
CJava2= ""
Str_Property2= "class=FontNormal"
'Call ListBox4("== àÅ×Í¡ÀÒ¤àÃÕ¹==",Table2,Condition2,SelectName2,FieldValue2,FieldDesc2,ValueExp2,CJava2,Table2Call)
%> </td>
<td width="101" valign="top" > <div align="right">
<input name="Data" type="text" class="FontNormal" value="<%=Data%>" size="15" maxlength="30">
</div></td>
<td width="15%" valign="top" align="center">
<input type="button" class="FontNormal" value=" ¤é¹ËÒ" onclick="chk_Process('1')"></td>
</tr>
</table>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td colspan="15" align="right"> ÃÇÁ <%=TotalRecord%> ÃÒ¡ÒÃ</td>
</tr>
<tr>
<%if Session("M_MainSubject_EX") = 1 then%>
<td width="27" align="center" bgcolor="f7f7f7"><input type="checkbox" name="checkall" onClick="ChkBox(this.name,this.checked)" ></td>
<%end if%>
<td width="35" align="center" bgcolor="f7f7f7"><strong>ÃËÑÊ</strong></td>
<td width="237" align="center" bgcolor="f7f7f7"><strong>¹Ñ¡ÈÖ¡ÉÒ</strong></td>
<td width="218" align="center" bgcolor="f7f7f7"><strong>ÇÔªÒ</strong></td>
<td width="86" align="center" bgcolor="f7f7f7"><strong>»Õ¡ÒÃÈÖ¡ÉÒ</strong></td>
<td width="161" align="center" bgcolor="f7f7f7"><strong>ÀÒ¤àÃÕ¹</strong></td>
<td width="47" align="center" bgcolor="f7f7f7"><strong>à¾ÔèÁ</strong></td>
<td width="56" align="center" bgcolor="f7f7f7"><strong>á¡éä¢</strong></td>
<td width="37" align="center" bgcolor="f7f7f7"><strong>´Ù¢éÍÁÙÅ</strong></td>
<%if Session("M_MainSubject_EX") = 1 then%>
<td width="43" align="center" bgcolor="f7f7f7"><strong>á¡éä¢</strong></td>
<%end if%>
</tr>
<% IF TotalRecord > 0 Then
TotalSizePage = "20"
LinkTopic = ""
LinkFileName = ""
No = 1
Call ShowTopic(Table,Condition,TotalSizePage,LinkTopic,LinkFileName,Order)
%>
<tr>
<td colspan="15" align="right" bgcolor="#f7f7f7">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="14%">
<%'if Getsinglefield("M_User","ID_Level"," Where ID_Level="&Session("ID_Level")) = 1 then %>
<input name="button3" type="button" style="font-family: Ms sans serif; font-size: 8pt;" onClick="chk_Process('2')" value="ź¢éÍÁÙÅ">
<%'end if%>
</td>
<td width="86%"><div align="right">
<% Call PageList(Table,Condition,TotalSizePage,"")%>
</div></td>
</tr>
</table>
</td>
</tr>
<%End if%>
<input type="hidden" name="TotalItem" value="<%=No - 1%>">
<input type="hidden" value="" name="process">
</table>
<br></td>
</tr>
</table>
</td>
</tr>
</table>
</form>

















