<! version 2.24July46 by burin rujjanapan from yonok.ac.th>
<%
dim connect, rs, sql, tots, i, j, k, l, nextl, max
set connect = server.createobject("ADODB.Connection")
%><!--#include file="connectinfo.asp"--><%
u = "lampang"
'
if request.form("process") = "SignOut" then
session("owner") = ""
session("password") = ""
end if
'
if request.form("process") = "SignIn" _
and request.form("user") = u then
sql = "select * from tb where tbid = '"& request.form("owner") &"' and tbpassword = '"&request.form("password") &"'"
set rs = server.createobject("ADODB.recordset")
rs.open sql,connect,1,3
tots = rs.recordcount
if tots > 0 then
session("owner") = request.form("owner")
session("password") = request.form("password")
end if
end if
connect.close
%><!--#include file="connectnews.asp"--><!--#include file="header.asp"--><%
if len(session("owner")) = 0 or request.querystring("action") = "all" then
if request.querystring("action") = "all" then
sql = "select * from news order by nid desc"
set rs = server.createobject("ADODB.recordset")
rs.open sql,connect,1,3
tots = rs.recordcount
if tots > 0 then
i = 1
response.write("<b>Intranet news :: </b><ol>")
do while not rs.eof
response.write("<li>nid=<font color=red>"& rs("nid") &"</font> by <font color=blue>"& rs("owner") &"</font> - "&rs("ndate")&" - <a href=displaynews.asp?niddtl="& rs("nid") & ">"&rs("nshort")&"</a><br>")
rs.movenext
i = i + 1
loop
response.write("</ol>")
end if
else
response.write("<form action=addnews.asp method=post><center><table width=300 bgcolor=#808080><td align=right bgcolor=#dddddd>")
response.write("รหัสตำบล (tbid) : <input name=owner value="& session("owner") &"><input type=hidden name=user value=lampang><br>")
response.write("รหัสผ่าน (tbpassword) : <input name=password type=password><br>")
response.write("<center><input type=submit name=process value=SignIn></center>")
response.write("</td></table></form>")
end if
else
response.write("<form action=addnews.asp method=post><center>Now usertb : <font color=red size=4>"&session("owner") & "</font> is signin<br>")
response.write("<input type=submit name=process value=SignOut></form>")
end if
'
if request.form("process") = "AddNews" _
and len(session("owner")) > 0 then
dim sd
if len(request.form("fshowdate")) > 0 then
sd = request.form("fshowdate")
else
sd = " "
end if
sql = "insert into news(ndate,nshort,showdate,ndetail,owner) values ('"
sql = sql & Now &"','"& request.form("fnshort") &"','" & sd & "','"& request.form("fndetail") &"','"& session("owner") &"')"
connect.execute(sql)
response.write("<br>AddNews : ok")
end if
'
if request.form("process") = "DelNews" _
and len(session("owner")) > 0 then
sql = "delete from news where nid = "& cint(request.form("fnid"))
connect.execute(sql)
response.write("<br>DelNews : ok")
end if
'
if len(session("owner")) > 0 then
response.write("<table width=95% border=0 cellpadding=1 cellspacing=1 bgcolor=blue><td bgcolor=#dddddd>")
response.write("<form action=addnews.asp method=post><b>ลบข่าวตามรหัสข่าว</b><br>")
response.write("News id : <input name=fnid value=999>")
response.write("<input type=submit name=process value=DelNews>")
response.write("</form>")
response.write("</td></table><br>")
response.write("<table width=95% border=0 cellpadding=1 cellspacing=1 bgcolor=blue><td bgcolor=#dddddd>")
response.write("<form action=addnews.asp method=post><b>เพิ่มข่าวใหม่</b><br>")
response.write("วันที่แสดงพร้อมหัวข้อ <input name=fshowdate size=30 value='13/01/45'><br>")
response.write("หัวข้อ <input name=fnshort size=60 value='เปิดงานบริจาคโลหิตครั้งที่ 68'><br>")
response.write("รายละเอียด :<br><textarea name=fndetail rows=15 cols=120>"& chr(10))
response.write("เป็นงานที่ยิ่งใหม่มาก มีผู้เข้าร่วมงานกว่า 500 คน ประกอบด้วย" & chr(10))
response.write("พร้อมถ่ายภาพ ที่ระลึก และการแสดงต่าง ๆ มากมาย" & chr(10))
response.write("มอบเข็ม และประกวดผู้หญิงแข็งแรง" & chr(10))
response.write("</textarea>")
response.write("<br><input name=process type=submit value=AddNews>")
response.write("</form>")
response.write("</td></table><br>")
response.write("<table width=95% border=0 cellpadding=1 cellspacing=1 bgcolor=blue><td bgcolor=#dddddd>")
response.write("<b>แสดง 15 ข่าวล่าสุด</b> ::")
sql = "select * from news where owner = '"& session("owner") &"'order by nid desc"
set rs = server.createobject("ADODB.recordset")
rs.open sql,connect,1,3
tots = rs.recordcount
if tots > 0 then
i = 1
response.write("<form action=addnews.asp method=post><input type=submit name=process value=DelNews><pre>")
do while not rs.eof and i < 16
response.write("<input type=radio name=fnid value="&rs("nid")&"> "& i & ". nid=<font color=red>"& rs("nid") &"</font> by <font color=blue>"& rs("owner") &"</font> - "&rs("ndate")&" - "&rs("nshort")&" - "&rs("ndetail")&"<br>")
rs.movenext
i = i + 1
loop
else
response.write("<br>ยังไม่มีข้อมูลในฐานข้อมูล")
end if
response.write("</form>")
response.write("</td></table>")
else
response.write("<br>Invalid account")
end if
' ====================
if request.form("process") = "DelNews" and len(session("owner")) > 0 then
sql = "delete from news where nid = "& cint(request.form("fnid"))
connect.execute(sql)
end if
connect.close
set rs = nothing
set connect = nothing
%>
</pre>
<!--#include file="footer.asp"-->
</body></html>
จำนวน : 127 บรรทัด