You are on page 1of 33

Më ®Çu

Trë vÒ qu¸ khø, c¸ch mµ c¸c øng dông phÇn mÒm ®îc ¸p dông vµo thùc tÕ lµ lËp
tr×nh ra nã trong mét ng«n ng÷ lËp tr×nh, sau ®ã ®îc cµi vµo c¸c m¸y kh¸c nhau. ChØ cã
mét phiªn b¶n nh vËy ®îc ch¹y trong cïng mét thêi ®iÓm. §ã lµ m« h×nh mét øng dông
mang tÝnh tËp trung.

Ngµy nay, khi c«ng nghÖ Internet ra ®êi tõ lóc cßn s¬ khai cho ®Õn khi ®ang ë
giai ®o¹n ®Ønh ®iÓm th× c¸c øng dông phÇn mÒm cã mét quan niÖm kh¸c. §Æc biÖt lµ khi
c«ng nghÖ Web ®îc coi lµ “søc sèng” cña m¹ng Internet ra ®êi th× viÖc sö dông c¸c øng
dông ph©n t¸n díi d¹ng øng dông Web ®îc coi lµ phæ biÕn. Nã cho phÐp cïng mét øng
dông cã thÓ ®îc sö dông bëi nhiÒu ngêi trong cïng mét thêi ®iÓm. Vµ do ®ã dÉn tíi mét
xu thÕ hiÖn nay lµ “H·y ngåi ë nhµ, víi chiÕc m¸y tÝnh cña b¹n, ®Ó giao tiÕp víi thÕ giíi
bªn ngoµi qua c¸c trang Web”. Qua ®ã ta thÊy r»ng, Web vµ Internet lµ hai thuËt ng÷ kh¸
phæ biÕn hiÖn nay.

B¾t ®Çu tõ c¸c trang Web tÜnh HTML cho phÐp hiÓn thÞ c¸c th«ng tin cè ®Þnh th×
tiÕp tôc n¶y sinh vÊn ®Ò ph¶i t¹o ra ®îc c¸c trang Web biÓu thÞ c¸c th«ng tin thay ®æi theo
yªu cÇu cña ngêi dïng. §ã lµ c¸c trang Web ®éng.

Bµi viÕt nµy ®îc chia lµm 4 phÇn :

PhÇn 1 : Tæng quan vÒ Web.


PhÇn 2 : ASP.
PhÇn 3 : X©y dùng øng dông Web VTV1.
PhÇn 4 : Listing.
PhÇn 1 : Tæng Quan vÒ Web

I. Web lµ g× ?
Web lµ c«ng nghÖ trªn Internet cho phÐp thÓ hiÖn c¸c th«ng tin mét c¸ch sinh
®éng, gÇn gòi víi con ngêi h¬n trªn 1 trang th«ng tin gäi lµ trang Web. Trang Web ®îc
tr×nh bµy trªn c¸c bé duyÖt Web (Browser) trªn c¸c m¸y Client. Trang Web chÝnh lµ c¸c
file v¨n b¶n d¹ng Text ®îc cÊu tróc ho¸ theo ng«n ng÷ HTML.

II. HTML lµ g× ?
HTML lµ ng«n ng÷ ®¸nh dÊu siªu v¨n b¶n (HyperText Markup Language).
HTML ®îc cÊu t¹o bëi c¸c thÎ gäi lµ c¸c Tab. C¸c thÎ nµy lµ c¸c tõ ®îc ®¸nh trong 2 dÊu
< vµ >.
CÊu tróc chung 1 trang Web HTML :
<HTML>
<HEAD>
<!-- Th«ng tin phÇn header cña trang Web -->
<TITLE>Tiªu ®Ò cña trang Web</TITLE>
</HEAD>

<BODY>
<!-- Th«ng tin phÇn body trang Web -->
</BODY>

</HTML>

III. C¸c lo¹i trang Web :


C¸c trang Web ®îc ph©n thµnh 3 lo¹i nh sau :

· Trang Web tÜnh (trang .HTML) : Lµ trang ®· ®îc lu tr÷ trªn Server tõ tríc.
Khi cã yªu cÇu tõ phÝa Client, trang nµy sÏ ®îc t¶i vÒ Client vµ ®îc hiÓn thÞ
trªn Server .

· Trang Web ®éng (DHTML : Dynamic HTML ): Lµ c¸c file ch¬ng tr×nh ®îc
ch¹y trªn Server. Sau khi ch¹y xong, Server sÏ sinh ra trang Web tÜnh HTML
t¬ng øng víi ch¬ng tr×nh ®ã vµ göi vÒ Client. Nh vËy ®Õn ®©y ta cã thÓ coi
r»ng trang Web ®éng lµ c¸c trang Web HTML kh«ng tån t¹i tõ tríc trªn
Server mµ tr¸i l¹i tuú theo yªu cÇu tõ phÝa Client, trang Web nµy sÏ ®îc t¹o ra
sau khi ch¹y ch¬ng tr×nh trªn Server . C¸c trang Web ®éng cã thÓ t¹o ra b»ng
c¸c c¸ch sau :

+ CGI (Common Gateway Interface) : Lµ chuÈn chung phæ biÕn nhÊt ®Ó c¸c
browser cã thÓ ch¹y 1 ch¬ng tr×nh trªn server, cã thÓ cµi ®Æt trªn mäi hÖ ®iÒu hµnh vµ
Web server. Nã lµ tªn gäi ®Ó chØ c¸c ch¬ng tr×nh ch¹y trªn Server mµ ®Çu vµo lµ c¸c
th«ng tin tõ phÝa Client, ®Çu ra lµ c¸c trang HTML ®Ó göi vÓ phÝa Client.
CGI cho c¸ch t¹o c¸c trang Web ®éng 1 c¸ch “ch¾c ch¾n” nhÊt trong ®ã mäi hÖ
®iÒu hµnh ®Òu hç trî. Tuy nhiªn viÖc dïng CGI lµ kh¸ phøc t¹p.

+ ASP (Active Server Page) : Lµ thµnh phÇn ®îc cµi thªm vµo Web Server ®Ó t¹o
ra c¸c trang Web ®éng. §Çu vµo lµ c¸c file.asp cã cÊu tróc t¬ng tù nh trang .HTML nhng
cã thªm c¸c lÖnh Script ®Ó t¹o ra trang Web. C¸c file .asp nµy ®îc ch¹y trªn Server. §Ó
ch¹y ®îc ASP b¾t buéc ph¶i cµi nã trªn c¸c Web Server cña MicroSoft. Ta sÏ nãi râ thªm
vÒ ASP ë phÇn sau.
+ JSP (Java Server Page) : Lµ c«ng nghÖ míi c«ng bè cña riªng h·ng Sun
MicroSystem. Nã lµ sù tÝch hîp cña c¶ Web Server vµ JSP ®Ó t¹o trang Web ®éng. Nã
kh«ng phô thuéc vµo møc Web Server vµ hÖ ®iÒu hµnh ë díi.

· Trang Web cã nhóng c¸c Applet vµ Script : Lµ c¸c trang HTML cã nhóng c¸c
c©u lÖnh Script vµ Applet ®îc viÕt b»ng ng«n ng÷ JavaScript , VBScript , Perl
...C¸c Applet nµy ®îc ch¹y bªn phÝa Client. §Ó c¸c Applet , Script cã thÓ ch¹y
®îc , c¸c Browser ph¶i hç trî c¸c bé dÞch ng«n ng÷ Script, Applet t¬ng øng.
C¸c lo¹i Applet ch¹y trªn Browser (Client) :

+ Java Applet : X©y dùng dùa trªn ng«n ng÷ Java.


+ ActiveX : Lµ c¸c ®èi tîng díi d¹ng modul cã s½n. ChØ ch¹y trªn hÖ ®iÒu
hµnh Window.
+ Plug-In : C¸c thµnh phÇn bæ trî cho c¸c chøc n¨ng míi cña Browser.

IV. M« h×nh giao t¸c Client/Server :


Tríc hÕt ta cÇn hiÓu c¸c kh¸i niÖm vÒ Client, Server :
Server :
+ §îi c¸c yªu cÇu (Request) tõ c¸c m¸y Client. Ph©n tÝch c¸c yªu cÇu ®ã
®Ó xö lý. Göi kÕt qu¶ tr¶ lêi (Response)vÒ Client.
+ Chøa c¸c phÇn mÒm Web Server, Database Server...
+ Lu«n trong tr¹ng th¸i On-Line.
Client :
+ T¹o c¸c kÕt nèi. Göi c¸c yªu cÇu ®Õn m¸y Server vµ chê nhËn kÕt qu¶ tõ
Server.
+ Chøa c¸c phÇn mÒm Web Browser nh IE, Nestcape...
+ Cã thÓ ë tr¹ng th¸i BËt/T¾t bÊt cø lóc nµo.

Nh vËy m« h×nh mét giao t¸c gi÷a Client vµ Server nh sau :

§Çu tiªn, Client göi mét yªu cÇu kÕt nèi ®Õn Server theo ®Þa chØ URL mµ nã cÇn
kÕt nèi. Server t¬ng øng sÏ “nghe” vµ kiÓm tra xem c¸c kªnh kÕt nèi dµnh cho nã cã kªnh
nµo rçi kh«ng. NÕu cã kªnh rçi nã sÏ thiÕt lËp liªn kÕt vµ göi kÕt qu¶ tr¶ vÒ Client t¬ng
øng. §èi víi c¸c yªu cÇu kh¸c hoÆc d÷ liÖu mµ Client göi tíi, Server sÏ lµm t¬ng tù.

M« h×nh Client/Server trong ASP :


PhÇn 2 : ASP (Active Server Page)

I.ASP lµ g× ?
ASP lµ mét thµnh phÇn ®îc cµi t¹i Web Server ®Ó hç trî viÖc dïng c¸c trang Web
®éng .asp. øng dông ASP lµ tËp hîp c¸c trang ASP vµ c¸c thµnh phÇn ActiveX.

C¸c file ASP (.asp) gåm phÇn v¨n b¶n (text), HTML vµ c¸c lÖnh script.
Mçi khi browser göi yªu cÇu vÒ mét file .asp cho Web Server, ASP xö lý phÇn lÖnh script
råi tr¶ l¹i cho browser kÕt qu¶ lµ mét trang HTML.

C¸c script lµ c¸c c©u lÖnh cã nghÜa b»ng bÊt cø ng«n ng÷ scripting nµo, ®îc ng¨n c¸ch víi
phÇn HTML b»ng cÆp dÊu <% vµ %>.

Ng«n ng÷ t¹o kÞch b¶n (scripting language)


Scripting lµ ng«n ng÷ kÕt hîp gi÷a HTML vµ c¸c ng«n ng÷ lËp tr×nh nh J, C++, VB..
Trong ®ã:
+ HTML t¹o v¨n b¶n vµ kÕt nèi c¸c trang.
+ C¸c ng«n ng÷ lËp tr×nh t¹o ra nh÷ng lÖnh phøc t¹p cho m¸y tÝnh.

- Ng«n ng÷ scripting chñ yÕu t¹o ra c¸c v¨n b¶n d¹ng text vµ gäi ®Õn c¸c component ®·
®îc biªn dÞch s½n viÕt b»ng c¸c ng«n ng÷ lËp tr×nh trªn.
- Server míi lµ bªn ®äc vµ xö lý c¸c script trong ASP, v× thÕ chØ c¸c Web server míi cÇn
hç trî cho ng«n ng÷ nµy.
- Client browser chØ cÇn ®a ra yªu cÇu vÒ c¸c trang .asp vµ chê ®îc ®¸p øng, nã kh«ng
cÇn hç trî c¸c ng«n ng÷ scripting.
- Scripting engine: lµ ch¬ng tr×nh xö lý c¸c lÖnh viÕt b»ng ng«n ng÷ scripting nµo ®ã. ASP
cã hai scripting engine lµ VBScript vµJScript.
- Ng«n ng÷ scripting c¬ së: lµ ng«n ng÷ ®îc mÆc ®Þnh ®Ó xö lý c¸c lÖnh trong cÆp dÊu
<% vµ %>. §iÒu nµy phô thuéc vµo tõng server cô thÓ. Cã thÓ ®Æt ng«n ng÷ cho mét
trang hoÆc tÊt c¶ c¸c trang cña øng dông. VÝ dô nh
- §Æt ng«n ng÷ cho mét trang: b»ng chØ dÉn <% @ LANGUAGE = tªn ng«n ng÷ %>

II. C¸c ®Æc ®iÓm cña ASP :

· Cã thÓ thùc hiÖn ®îc c¸c Script trªn Web Server mµ kh«ng ph¶i thùc
hiÖn trªn c¸c Browser. Do ®ã Browser kh«ng hç trî c¸c ng«n ng÷ Script vÉn
cã thÓ thùc hiÖn ®îc c¸c Script b»ng c¸ch göi c¸c yªu cÇu cho Server thùc
hiÖn. §iÒu nµy t¹o ra mét ®Æc tÝnh tiÖn lîi mµ Ýt ai nhËn ra lµ cã thÓ thùc hiÖn
®îc c¸c trang Web sinh ®éng mµ cã thÓ dïng c¸c tr×nh duyÖt Web ®¬n gi¶n
kh«ng cã hç trî c¸c Script.
· C¸c file .asp chØ ®îc lu tr÷ trªn Web Server mµ kh«ng tån t¹i ë m¸y
Client.
· C¸c trang Web .asp sÏ ®îc thùc hiÖn (biªn dÞch) bëi thµnh phÇn Script
Engine cµi trong ASP ë Web Server.
· ViÖc sö dông ASP cho phÐp t¹o ra c¸c øng dông Web m¹nh vµ linh
ho¹t, cã giao diÖn th©n thiÖn víi ngêi dïng qua trang HTML.

III. C¸c thµnh phÇn cña ASP :


Thµnh phÇn chñ yÕu trong ASP ®îc gäi lµ ActiveX Server Components
ActiveX lµ mét c«ng cô m¹nh ®Ó x©y dùng c¸c øng dông Web v× nã cung cÊp c¸c ®èi
tîng ®Ó b¹n cã thÓ sö dông trong script cña m×nh. B¹n cã thÓ x©y dùng c¸c øng dông
Web ®éng, cã t¬ng t¸c nhê sö dông c¸c component do server cung cÊp.
C¸c component nµy ®îc sö dông nh lµ nh÷ng khèi c¬ b¶n trong script hoÆc c¸c øng dông
Web, chóng thùc hiÖn nh÷ng c«ng viÖc th«ng thêng ®Ó b¹n kh«ng cÇn ph¶i viÕt l¹i m·
lÖnh n÷a.
Component lµ m· lÖnh ®· ®îc dÞch, s½n sµng ®Ó ch¹y, ®îc ®Æt díi d¹ng c¸c file .dll hoÆc
.exe.
B¹n cã thÓ dïng c¸c component do ASP cung cÊp hoÆc lÊy tõ mét nguån nµo ®ã hay t¹o
ra c¸c component cho m×nh.
ASP cung cÊp 5 thµnh phÇn (components) c¬ b¶n:

Advertisement Rotator T¹o ®èi t


Browser Capabilities T¹o ®èi tîng BrowserType quyÕt ®Þnh kiÓu, kh¶ n¨ng vµ version
cña mçi browser truy nhËp ®Õn Web site cña b¹n
Database Access Cung cÊp c¸c truy nhËp ®Õn c¬ së d÷ liÖu sö dông ActiveX Data
Objects (ADO).
Content Linking T¹o ®èi tîng NextLink ®Ó t¹o ra b¶ng néi dung cña trang Web vµ
nèi chóng l¹i nh lµ c¸c trang trong mét quyÓn s¸ch.
File Access Cung cÊp c¸c truy nhËp ®Õn c¸c file.

IV. B¹n ph¶i lµm g× ®Ó t¹o ®îc trang Web ®éng .asp :
- L¾p ®Æt hÖ thèng phÇn cøng vÒ m¹ng (nèi c¸c m¸y, cµi ®Æt hÖ ®iÒu hµnh..)
· Cµi ®Æt phÇn mÒm Web Server trªn m¸y mµ b¹n ®Þnh chän lµm Server.
C¸c phÇn mÒm phæ biÕn cã thÓ lµ :
+ IIS (Internet Information Server) : Web Server ( cña Microsoft ) dïng ®Ó cµi
trªn Window NT. Thêng ®îc cµi trong thùc tÕ ®Ó lµm Web Server trªn
Internet.
+ PWS (Personal Web Server) : Web Server ( cña Microsoft ) dïng ®Ó cµi trªn
Window 9x. Thêng ®îc cµi trªn m¸y tÝnh c¸ nh©n ®¬n lÎ ®Ó test øng dông
Web .asp. Nã m« pháng m« h×nh Client/Server trªn mét m¸y ®¬n lÎ.
+ FTS (FastTrack Server) : Web Server cña Netscape. Còng thêng ®îc cµi
trong thùc tÕ ®Ó lµm Web Server trªn Internet.
+ Ngoµi ra cßn mét sè c¸c phÇn mÒm Web Server kh¸c.
· Cµi ASP
§Õn ®©y b¹n hoµn toµn cã thÓ t¹o c¸c trang ASP b»ng mét bé so¹n th¶o v¨n b¶n
bÊt kú. Sau ®ã copy file .asp võa so¹n th¶o vµo th môc InetPub hoÆc WebShare
trªn Server. Tuy nhiªn ®Ó cã thÓ t¹o ra c¸c øng dông Web cã trang Web ®éng .asp
mét c¸ch dÔ dµng vµ chuyªn nghiÖp h¬n, b¹n nªn cµi thªm c¸c thµnh phÇn sau :

· FrontPage Server Extensions : Cho phÐp copy c¸c file HTML vµ ASP
tõ th môc project (cña FrontPage hoÆc Visual Interdev) vµo th môc InetPub
hoÆc WebShare cña Web Server mét c¸ch tù ®éng.
· Visual InterDev (trong bé Visual Studio cña MicroSoft): PhÇn mÒm
cho phÐp t¹o øng dông Web ASP mét c¸ch dÔ dµng.
· FrontPage : PhÇn mÒm so¹n th¶o trang HTML.

V. C¬ chÕ Submit mét form trong ASP :

Submit lµ thuËt ng÷ ®Ó chØ mét giai ®o¹n khi Web Browser trªn m¸y Client göi
c¸c th«ng tin mµ ngêi sö dông ®iÒn trong mét form vÒ Web Server. VÝ dô khi ngêi sö
dông ®iÒn th«ng tin trong mét Text Box vµ bÊm Submit. Nh vËy cã thÓ hiÓu theo c¸ch
kh¸c lµ khi Browser göi yªu cÇu (Request) ®Õn Server th× gäi lµ Submit. Cã 2 method
Submit : Get vµ Post.
+ Post Method : Th«ng tin sÏ n»m trong phÇn th©n cña form göi vÒ Server.
Bªn Server dïng Collection Form cña ®èi tîng Request ®Ó lÊy gi¸ trÞ nµy.
+ Get Method : Th«ng tin sÏ ®îc g¾n vµo sau ®Þa chØ URL ®îc ng¨n c¸ch
bëi dÊu ? díi d¹ng mét chuçi Query. D¹ng cña chuçi nµy nh sau :
§Þa_ChØ_URL?Name1=Value1,..
Bªn Server dïng Collection QueryString cña ®èi tîng Request ®Ó lÊy gi¸ trÞ nµy.

Mét qu¸ tr×nh truyÒn th«ng tin vÒ Server (Submit) thêng kÌm theo ®Þa chØ cña
trang ASP sÏ tiÕp nhËn th«ng tin ®ã, xö lý th«ng tin ®ã vµ t¹o ra kÕt qu¶ lµ trang HTML
göi tr¶ vÒ Browser. §Þa chØ cña trang ASP nµy ®îc x¸c ®Þnh bëi thuéc tÝnh Action trong
Tab Form cña trang HTML chøa form. VÝ dô :
Cã mét trang HTML nh sau :
<HTML>

<BODY>
<FORM METHOD =”POST” ACTION =”ReceiveParam.asp” >
<INPUT TYPE=”TEXT” NAME=”NAME1” SIZE=”40”>
<INPUT TYPE=”SUBMIT” VALUE=”SEND TO SERVER”>
</FORM>
</BODY>

</HTML>

Khi form ®îc Submit vÒ Server nã sÏ göi gi¸ trÞ cña NAME1 ®ång thêi link tíi
trang ReceiveParam.asp. Do ®ã ®Ó lÊy ®îc gi¸ trÞ cña NAME1 bªn Server ta ph¶i t¹o mét
file ReceiveParam.asp vµ dïng Collection Form cña ®èi tîng Request nh sau :
<%@ Language = VBScript %>
<% Set ReceivedValue = Request.Form(“NAME1”)
%>
<HTML>
<BODY>
<%=ReceivedValue%>
</BODY>
</HTML>

§Ó Test kÕt qu¶ ë trªn h·y thùc hiÖn c¸c bíc sau trªn m¸y ®· cµi Web Server vµ ASP :
· T¹o mét th môc Test trong InetPub(hoÆc WebShare víi
PWS)\WWWROOT
· T¹o mét file Test.htm trong th môc Test vµ Paste nh÷ng dßng trang
HTML ë trªn vµo file ®ã.
· T¹o mét file ReceiveParam.asp trong th môc Test vµ Paste nh÷ng dßng
trang ASP ë trªn vµo file ®ã.
· Trªn Browser bÊt kú ®¸nh ®Þa chØ URL :
http://Server_Name/Test/test.htm.

VI. Mét vÝ dô ®¬n gi¶n vÒ trang Web ®éng ASP :


H·y trë l¹i víi mét vÝ dô ®¬n gi¶n vÒ trang HTML “Hello World” :

<HTML>
<BODY>
<FONT SIZE = 10 >
Hello World !
</BODY>
</HTML>

NÕu chØ hiÓn thÞ 1 dßng nh vËy th× sÏ kh«ng cã vÊn ®Ò x¶y ra. Tuy nhiªn gi¶ sö ta
ph¶i tr×nh bµy dßng Hello World ! trªn nhiÒu dßng vµ víi cì ch÷ to dÇn. C¸ch lµm ë ®©y
lµ viÕt lÆp l¹i 2 dßng <FONT SIZE = i >, Hello World víi i t¨ng dÇn. §iÒu ®ã sÏ lµm cho
viÖc ®¸nh trë nªn cång kÒnh vµ “con ong ch¨m chØ”, kh«ng tËn dông ®îc c¸c chøc n¨ng
lÆp cña 1 ng«n ng÷ lËp tr×nh b×nh thêng. Gi¶i ph¸p ë ®©y lµ x©y dùng 1 trang Web ®éng
.asp nh sau :

<%@ Language = VBScript %>


<HTML>
<BODY>
<% For i = 10 To 20 %>
<FONT SIZE = <%=i%> >
Hello World !
<%Next%>
</BODY>
</HTML>
ChØ víi 8 dßng ë trªn ta cã thÓ thay cho 24 dßng trong trang Web tÜnh HTML. BÝ quyÕt lµ
giao cho Server thùc hiÖn c¸c lÖnh trªn ®Ó nã t¹o ra 24 dßng HTML vµ göi vÒ Client (yªu
cÇu trang .asp ë trªn).
PhÇn 3 : X©y dùng øng dông Web VTV1.
I.Yªu cÇu vÒ øng dông Web :

· Dùa trªn m« h×nh øng dông Web Client/Server.


· Truy cËp ®îc c¬ së d÷ liÖu tõ xa trªn m¸y Server.
· óng dông Web ®éng dïng c«ng nghÖ ASP.

II.Giíi thiÖu vÒ trang Web VTV01 :


VTV01 lµ trang Web cho phÐp qu¶n lý vµ theo dâi lÞch ph¸t sãng cña kªnh VTV1
§µi TruyÒn H×nh ViÖt Nam.

Nã cã c¸c chøc n¨ng chÝnh sau :


+ Theo dâi lÞch ph¸t sãng.
+ CËp nhËt, söa ®æi c¸c ch¬ng tr×nh ®· lªn kÕ ho¹ch tõ tríc.
+ Lªn kÕ ho¹ch c¸c ch¬ng tr×nh míi.
+ B¸o c¸o ch¬ng tr×nh ®· lªn kÕ ho¹ch theo tõng th¸ng.

VTV01 ®îc x©y dùng trªn nÒn m¹ng LAN cña c«ng ty FPT. PhÇn mÒm lµ IIS cña
MicroSoft vµ hÖ ®iÒu hµnh Window NT.

VTV01 dïng thµnh phÇn Database Access cña ASP ®Ó truy cËp c¬ së d÷ liÖu
VTV.mdb ®îc t¹o trªn Access 97. Ngoµi ra cã 2 ng«n ng÷ Script ®îc dïng trong øng
dông lµ VBScript ®Ó truy vÊn c¬ së d÷ liÖu vµ JavaScript ®Ó thùc hiÖn c¸c kÕt qu¶ b¸o c¸o
in ra...

III. C¬ së d÷ liÖu cña trang Web VTV1 :


VTV01 cã 1 file c¬ së d÷ liÖu duy nhÊt lµ VTV.mdb ®îc t¹o ra trªn Access. Nã
gåm 2 b¶ng cã cÊu tróc nh sau :

· B¶ng LÞch :

Field Name Data Type Description 1 b¶n ghi trong b¶ng


ID AutoNumber 2
Ngay Date/Time Ngay phat song 4/24/99
GioPhut Date/Time Gio phat song 11:30
The_Loai Text The loai chuong trinh Ho¹t h×nh
Ten_Chuong_Trinh Text Ten chuong trinh Phim ho¹t h×nh
WaltDisney
Bien_Tap Text Ten nguoi bien tap Dhh
Bien_Dich Text Ten nguoi bien dich neu co Haidh
Thoi_Luong Number So phut phat song 20
Vung_SX Text Vung san xuat V2
He_So_Qui_Doi Number He so qui doi 2
Thu_Lao_BT Number Thu lao cho BT 0
Thu_Lao_DD Number Thu lao cho DD 0
Thu_Lao_QP Number Thu lao cho QP 0
Thu_Lao_CTV Number Thu lao cho CTV 0

· B¶ng The_Loai :

Field Name Data Type Description BG1 BG2 BG3 BG4 BG5 BG6
ID Auto Number 1 2 3 4 5 6
The_Loai Text The loai chuong trinh TG§V VQTG PKH Phim
Tµi LiÖu Ho¹t H×nh T¹p ChÝ

Quan hÖ gi÷a 2 b¶ng :

IV. C¸c trang Web trong VTV01 :


- Default.htm : Trang Web mÆc ®Þnh t¬ng øng víi ®Þa chØ URL :
Http://Server_Name/VTV01
Lµ trang t¹o ra 3 frame ®Ó hiÓn thÞ cïng 1 lóc 3 trang Web kh¸c nhau.
· Global.asa (File Active Server Application): Lµ file kh«ng bao gåm
nh÷ng néi dung göi vÒ phÝa Client. Nã lµ file lùa chän cho phÐp khai b¸o c¸c
®èi tîng ë møc phiªn vµ møc øng dông ®Ó dïng trong øng dông Web ASP. Nã
lu tr÷ c¸c th«ng tin vÒ c¸c sù kiÖn vµ c¸c ®èi tîng ®îc sö dông mét c¸ch toµn
côc trong øng dông. §îc lu tr÷ trong th môc gèc cña øng dông Web vµ mçi
øng dông chØ cã duy nhÊt mét file Global.asa. Trong øng dông VTV01 c¸c ®èi
tîng møc phiªn dïng Database Access ®îc khai b¸o ë ®©y.
Trong th môc (Folder) Code :
· About.htm : Trang Web giíi thiÖu. §îc hiÓn thÞ lóc ®Çu trong
Default.htm.
· Header.htm : Trang Web ¶nh cña VTV1 vµ FPT. HiÓn thÞ trªn phÇn
®Çu trang.
· LeftBat.htm : Trang Web link ®Õn c¸c trang ®éng .asp kh¸c. HiÓn thÞ
ë khung bªn tr¸i.
· ScheduleInit.asp : Tr×nh bµy form ®Ó User nhËp th«ng tin vÒ th¸ng cÇn
xem lÞch ph¸t sãng.
· Schedule.asp : VÏ lÞch ph¸t sãng t¬ng øng víi th¸ng mµ User yªu cÇu.
· ListOne.asp : HiÓn thÞ néi dung mét ch¬ng tr×nh.
· UpdateElm.asp : Tr×nh bµy form ®Ó söa ®æi néi dung mét ch¬ng tr×nh.
· UpdateAsp.asp : Thùc hiÖn viÖc cËp nhËt c¬ së d÷ liÖu vµ tr×nh bµy kÕt
qu¶ thay ®æi néi dung ch¬ng tr×nh.
· DeleteAsp.asp : Xo¸ mét ch¬ng tr×nh khái c¬ së d÷ liÖu vµ tr×nh bµy
kÕt qu¶ xo¸.
· Input.asp : Tr×nh bµy form ®Ó t¹o mét ch¬ng tr×nh míi.
· InputAsp.asp : Thùc hiÖn viÖc thªm mét ch¬ng tr×nh míi vµo c¬ së d÷
liÖu vµ tr×nh bµy kÕt qu¶ thªm.
· MonthReport.asp : Tr×nh bµy form ®Ó nhËp th«ng tin vÒ th¸ng cÇn b¸o
c¸o.
· BKTTCT.asp : VÏ b¸o c¸o c¸c ch¬ng tr×nh trong mét th¸ng theo mÉu
cña §µi TruyÒn H×nh ViÖt Nam.
Trong th môc (Folder) Inc :
- FieldNull.inc : File include trong BKTTCT.asp. Chøa c¸c hµm chuyÓn ®æi ngµy
giê..

V. S¬ ®å liªn kÕt gi÷a c¸c trang Web trong VTV01 :


VI. NhËn xÐt :

øng dông ®îc cµi ®Æt trªn nÒn Web Server : MicroSoft Internet Information Server
vµ hÖ ®iÒu hµnh Window NT 4.0. Nh×n chung ®· ®¶m b¶o ®îc c¸c yªu cÇu ®Ò ra ë trªn.
Tuy nhiªn cßn mét sè h¹n chÕ lµ cha cã kh¶ n¨ng kiÓm tra lçi th«ng tin nhËp vµ kh¶ n¨ng
t¬ng thÝch víi c¸c Web Server vµ hÖ ®iÒu hµnh kh¸c lµ cha ®îc ®¶m b¶o.
PhÇn 4 : Listing
· Global.asa :
<SCRIPT LANGUAGE=VBScript RUNAT=Server>

'You can add special event handlers in this file that will get run automatically when
'special Active Server Pages events occur. To create these handlers, just create a
'subroutine with a name from the list below that corresponds to the event you want to
'use. For example, to create an event handler for Session_OnStart, you would put the
'following code into this file (without the comments):

'Sub Session_OnStart
'**Put your code here **
'End Sub

'EventName Description
'Session_OnStart Runs the first time a user runs any page in your application
'Session_OnEnd Runs when a user's session times out or quits your application
'Application_OnStart Runs once when the first page of your application is run for the first time
by any user
'Application_OnEnd Runs once when the web server shuts down

</SCRIPT>

<SCRIPT LANGUAGE=VBScript RUNAT=Server>


Sub Application_OnStart
'==Visual InterDev Generated - startspan==
'--Project Data Connection
Application("Connection_ConnectionString") =
"DSN=VTV;DBQ=D:\PROJECTS\vtv\Database\vtv.mdb;DriverId=25;FIL=MS
Access;MaxBufferSize=512;PageTimeout=5;"
Application("Connection_ConnectionTimeout") = 15
Application("Connection_CommandTimeout") = 30
Application("Connection_CursorLocation") = 3
Application("Connection_RuntimeUserName") = ""
Application("Connection_RuntimePassword") = ""
'-- Project Data Environment
'Set DE = Server.CreateObject("DERuntime.DERuntime")
'Application("DE") = DE.Load(Server.MapPath("Global.ASA"),
"_private/DataEnvironment/DataEnvironment.asa")
'==Visual InterDev Generated - endspan==
End Sub
</SCRIPT>

<SCRIPT LANGUAGE=JScript RUNAT=Server>

function Session_OnStart()
{
//Create ADO Object
Session("objConnection") = new ActiveXObject("ADODB.Connection");
Session("objConnection").ConnectionString = "Provider=MSDASQL.1;Persist Security
Info=False;Data Source=VTV;DriverId=25;FIL=MS
Access;MaxBufferSize=512;PageTimeout=5;";
Session("objConnection").ConnectionTimeOut = 30;
Session("objConnection").open();
}
</Script>
· Default.htm :
<html>

<head>
<title>VTV Program</title>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
</head>

<frameset rows="62,*">
<frame name="banner" scrolling="no" marginwidth="0" marginheight="0" noresize
target="contents" src="Code/Header.htm">
<frameset cols="17%,*">
<frame name="contents" target="main" src="Code/LeftBar.htm" marginwidth="0"
marginheight="0" scrolling="no">
<frame name="main" src="Code/about.htm">
</frameset>
<noframes>
<body>
<p>This page uses frames, but your browser doesn't support them.</p>
</body>
</noframes>
</frameset>
</html>

· About.htm :
<html>
<head>
<meta NAME="GENERATOR" Content="Microsoft Developer Studio">

<title>Document Title</title>
</head>
<body background="../images/bgr.gif">

<!-- Insert HTML here -->


<font face=".VnTime">

<p><img src="../images/Point.gif" WIDTH="13" HEIGHT="13">&nbsp;&nbsp;VTV - ver 1.0 B¶n


quyÒn cña C«ng ty <font color="Blue"><u>FPT</u></font>

<p><img src="../images/Point.gif" WIDTH="13" HEIGHT="13">&nbsp;&nbsp;VTV lµ ch¬ng tr×nh


cho phÐp c¸c c¸n bé cña ®µi tryÒn h×nh
qu¶n lý vµ theo dâi lÞch ph¸t sãng cña ®µi. Ch¬ng tr×nh gåm c¸c chøc n¨ng chÝnh sau:

<p><img src="../images/NextArrow.gif" WIDTH="30" HEIGHT="16">&nbsp;<font


color="Blue"><u>Xem lÞch</u></font> : Theo dâi lÞch ph¸t sãng
<br><img src="../images/NextArrow.gif" WIDTH="30" HEIGHT="16">&nbsp;<font
color="Blue"><u>Ch¬ng tr×nh míi</u></font> : NhËp c¸c ch¬ng tr×nh sÏ ph¸t cña ®µi
<br><img src="../images/NextArrow.gif" WIDTH="30" HEIGHT="16">&nbsp;<font
color="Blue"><u>Söa ®æi lÞch</u></font> : Thay ®æi ch¬ng tr×nh ®· lªn kÕ ho¹ch tríc

</font>

</body>
</html>

· Header.htm :
<html>

<head>
<meta NAME="GENERATOR" Content="Microsoft FrontPage 3.0">

<title>Document Title</title>
<base target="contents">
</head>

<body>
<!-- Insert HTML here -->
<table border="0" width="100%" cellspacing="0" height="100%" cellpadding="0">
<tr>
<td width="7%"></td>
<td width="9%"><img src="http://halh/vtv01/images/Fpt.gif " alt="FPT" border="0" width="79"
height="50"
></td>
<td width="78%"><img src="http://halh/vtv01/images/fpt_internet.gif " alt="VTV Program."
border="0" WIDTH="600"
HEIGHT="50"></td>
<td width="6%"></td>
</tr>
</table>

</body>
</html>
· LeftBar.htm :
<html>

<head>
<meta NAME="GENERATOR" Content="Microsoft FrontPage 3.0">

<title>Document Title</title>
<base target="main">
</head>

<body background="../Images/Fptbgr.gif">
<!-- Insert HTML here -->
<font face=".VnTime">

<table border="0" width="100%" height="190" cellpadding="0">


<tr>
<td width="100%" height="40"><strong><font face=".VnTime">
Ch&oslash;c n&uml;ng
ch&Yacute;nh
</font></strong></td>
</tr>
<tr>
<td width="100%" height="17">
<img src="../images/bullet01.gif" alt="bullet01.gif (85 bytes)" WIDTH="10" HEIGHT="10"
><font size="2" face=".VnTime"><a href="ScheduleInit.asp" target="main"> Xem
k&Otilde; ho&sup1;ch ph&cedil;t
s&atilde;ng</a></font><br></td>
</tr>
<tr>
<td width="100%" height="17"><img src="../images/bullet01.gif" alt="bullet01.gif (85 bytes)"
WIDTH="10" HEIGHT="10"><a target="main" href="Input.asp"><font size="2" face=".VnTime">
L&ordf;n k&Otilde; ho&sup1;ch ch&shy;&not;ng tr&times;nh
m&iacute;i</font></a></td>
</tr>
<tr>
<td width="100%" height="13"></td>
</tr>
<tr>
<td width="100%" height="40"><strong><font face=".VnTime">
In b&cedil;o
c&cedil;o</font></strong></td>
</tr>
<tr>
<td width="100%" height="14"><img src="../images/bullet01.gif" alt="bullet01.gif (85 bytes)"
WIDTH="10" HEIGHT="10"><font size="2" face=".VnTime"><a target="main"
href="MonthReport.asp">
B&cedil;o c&cedil;o th&cedil;ng</a></font></td>
</tr>
<tr>
<td width="100%" height="13"></td>
</tr>
<tr>
<td width="100%" height="40"><strong><font face=".VnTime">
Gi&iacute;i
thi&Ouml;u</font></strong></td>
</tr>
<tr>
<td width="100%" height="14"><img src="../images/bullet01.gif" alt="bullet01.gif (85 bytes)"
WIDTH="10" HEIGHT="10"><font size="2" face=".VnTime"><a target="main" href="About.htm">
Ch&shy;&not;ng tr&times;nh VTV</a></font></td>
</tr>
<tr>
<td width="100%" height="13"></td>
</tr>
</table>

</font>
</body>
</html>
· BKTTCT.asp :
<%@ Language=VBScript %>

<!--#include file="../Inc/FieldNull.inc"-->

<%
MyMonth = Request.Form("Month")
MyYear = Request.Form("Year")
'QFromDate = request("QFromDate")
'QToDate = request("QToDate")
'connect to database
'sql = "select * from Lich"' where Ngay>=#"+QFromDate+"# and
Ngay<=#"+QToDate+"#"
MyStartDate = MyMonth + "/1/" + MyYear
MyEndDate = CStr(MyMonth+1) + "/1/" + MyYear

sql = "select * from Lich where Ngay>=#" + MyStartDate + "# and Ngay<#" +
MyEndDate + "#"

'Response.Write(sql)
Set rs = Session("objConnection").Execute (sql)
%>

<Script Language="JScript" RUNAT="Server">


function getNgay()
{
var d=new Date();
return d.getDate();
}
function getThang()
{
var d=new Date();
return d.getMonth()+1;
}
function getNam()
{
var d=new Date();
var s=new String(d.getYear());
if (s.length==2)
return "19"+s;
else return s;
}
</Script>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY background=../images/bgr.gif>
<FONT face=".VnTime" Size="2">
<FONT Face=".VntimeH">
<TABLE Width=720 border="0" cellspacing="0">
<tr align="middle">
<td width ="220" align="middle"><FONT Size="2">&sect;&micro;i
truy&Ograve;n h&times;nh
Vi&Ouml;t Nam</FONT></td>
<td><FONT Size="4">B&para;ng
k&ordf; thanh to&cedil;n ch&shy;&not;ng tr&times;nh</FONT></td>
</tr>
<tr align="middle">
<td><FONT Size="2">Ban Khoa
gi&cedil;o</FONT></td>
<td><FONT Face=".VnTime" Size=4>Ti&Oacute;u ban :. Ngo&sup1;i
ng&divide;. . . . . . . .
.</FONT></td>
</tr>
</TABLE>
</FONT>
<br>
<TABLE Width=720 border="0" cellspacing="0">
<tr>
<td width ="550">&nbsp;</td>
<td>Th&cedil;ng
<%=MyMonth%>
n&uml;m
<%=MyYear%></td>
<!--getThang() , '=getNam()-->
</tr>
</TABLE>

<P>
<table border="1" width="720" cellspacing="0">
<tr align="middle" bgcolor=#eeffff>
<td rowspan="2" Width="30">TT</td>
<td rowspan="2" Width="160">T&ordf;n ch&shy;&not;ng
tr&times;nh</td>
<td rowspan="2" Width="80">Ng&micro;y ph&cedil;t
s&atilde;ng</td>
<td rowspan="2" Width="50">Bi&ordf;n t&Euml;p</td>
<td rowspan="2" Width="60">V&iuml;ng SX</td>
<td rowspan="2" Width="50">Th&Oacute; lo&sup1;i</td>
<td rowspan="2" Width="50">
<P>Th&ecirc;i&nbsp; l&shy;&icirc;ng</P></td>
<td rowspan="2" Width="40">B&Euml;c</td>
<td colspan="4">Th&iuml; lao nhu&Euml;n
b&oacute;t</td>
<td rowspan="2" Width="40">Th&iuml; lao CTV</td>
</tr>
<tr bgcolor=#eeffff>
<td Width="40">BT</td>
<td Width="40">DD</td>
<td Width="40">QP</td>
<td Width="40">C&eacute;ng</td>
</tr>
<%Dim i
i=0
do while not rs.EOF
i=i+1%>
<tr>
<td>
<%=i%></td>
<td>
<%=strNull(rs("Ten_Chuong_Trinh"))%></td>
<td>
<%=strNgay(rs("Ngay"))%></td>
<td>
<%=strNull(rs("Bien_Tap"))%></td>
<td>
<%=strNull(rs("Vung_SX"))%></td>
<td>
<%=strNull(rs("The_Loai"))%></td>
<td>
<%=numNull(rs("Thoi_Luong"))%></td>
<td>
<%=numNull(rs("He_So_Qui_Doi"))%></td>
<td>
<%=numNull(rs("Thu_Lao_BT"))%></td>
<td>
<%=numNull(rs("Thu_Lao_DD"))%></td>
<td>
<%=numNull(rs("Thu_Lao_QP"))%></td>
<td>
<%=numNull(rs("Thu_Lao_BT")+rs("Thu_Lao_DD")+rs("Thu_Lao_QP"))%></td>
<td>
<%=numNull(rs("Thu_Lao_CTV"))%></td>
</tr>
<%rs.MoveNext
loop%>

</table>
<%

set rs=Nothing
%>

</FONT></P>
</BODY>
</HTML>
· DeleteASp.asp :
<%

sql="Delete * from Lich"


sql=sql+" where id="+request("ID")

'Response.Write(sql)
Session("objConnection").Execute (sql)
%>

<Html>
<body>
<Script Language="JScript">
function back()
{
window.history.go(-3);
//document.a.location.reload();
//window.alert(document.url);
}

</Script>

<Font Face=".VnTime" size="3">


B¶n ghi ®· ®îc xo¸.
<p><a href="javascript:back()">TiÕp tôc</a>
</Font>
</Body>
</html>
· InputASp.asp :
<%@ Language=VBScript %>
<%
'connect to database
sql = "select The_Loai from The_Loai"

'Response.Write(sql)
Set rs = Session("objConnection").Execute (sql)
%>

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JScript">
function insert()
{
document.frmInput.submit();
}
</SCRIPT>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">


</HEAD>
<BODY>
<!-- Insert HTML here -->
<Font face='.vnTime'>
<Form action="InputAsp.asp" method="POST" name="frmInput">
<table border="0" width="400" cellpadding="0" cellspacing="0">
<tr>
<td width="100">Ngµy :</td>
<td width="80"><input type="text" name="Ngay" size="12"></td>
<td width="40"></td>
<td width="100">Giê phót :</td>
<td width="80"><input type="text" name="GioPhut" size="12"></td>
</tr>
<tr>
<td width="100">ThÓ lo¹i CT:</td>
<td width="80">
<select name="The_Loai" width= '12' size="1">
<%do while not rs.EOF %>
<font face = ".VnTime">
<option value="<%=rs("The_Loai")%>"><%=rs("The_Loai")%></option>
</font>
<% rs.MoveNext
loop%>

<%
set rs=Nothing
%>
</select></td>
<td width="40"></td>
<td width="100"></td>
<td width="80"></td>
</tr>
<tr>
<td width="100">Tªn CT:</td>
<td width="320" colspan="4"><input type="text" name="Ten_Chuong_Trinh" size='33'
style="FONT-FAMILY:.VnTime"></td>
</tr>
<tr>
<td width="80">Biªn tËp:</td>
<td width="80"><input type="text" name="Bien_Tap" size="12" style="FONT-
FAMILY:.VnTime"></td>
<td width="40"></td>
<td width="100">Biªn dÞch:</td>
<td width="80"><input type="text" name="Bien_Dich" size="12" style="FONT-
FAMILY:.VnTime"></td>
</tr>
<tr>
<td width="100">Thêi lîng:</td>
<td width="80"><input type="text" name="Thoi_Luong" size="12"></td>
<td width="40"></td>
<td width="100">Vïng SX:</td>
<td width="80"><input type="text" name="Vung_SX" size="12" style="FONT-
FAMILY:.VnTime"></td>
</tr>
<tr>
<td width="100">HS qui ®æi:</td>
<td width="80"><input type="text" name="He_So_Qui_Doi" size="12"></td>
<td width="40"></td>
<td width="100">Thï lao BT:</td>
<td width="80"><input type="text" name="Thu_Lao_BT" size="12"></td>
</tr>
<tr>
<td width="100">Thï lao DD:</td>
<td width="80"><input type="text" name="Thu_Lao_DD" size="12"></td>
<td width="40"></td>
<td width="100">Thï lao QP:</td>
<td width="80"><input type="text" name="Thu_Lao_QP" size="12"></td>
</tr>
<tr>
<td colspan="5" width="400" align="Center"><br><a href="javascript:insert()"><img
src="../images/ThucHien.gif" border="0" WIDTH="85" HEIGHT="21"></td>
</tr>
</table>
</form>

</Font>

</BODY>
</HTML>
· InputASp.asp :
<%@ Language=VBScript %>
<%

sql="Insert into Lich (Ngay,GioPhut,The_Loai, Ten_Chuong_Trinh, Bien_Tap, Bien_Dich)"


sql=sql+" Values ("
sql=sql+"'"+request("Ngay")+"'," 'Ngay
sql=sql+"'"+request("GioPhut")+"'," 'GioPhut
sql=sql+"'"+request("The_Loai")+"'," 'TheLoai
sql=sql+"'"+request("Ten_Chuong_Trinh")+"'," 'Ten Chuong trinh
sql=sql+"'"+request("Bien_Tap")+"'," 'Bien Tap
sql=sql+"'"+request("Bien_Dich")+"'" 'Bien Dich
sql=sql+")"

'Response.Write(sql)
Session("objConnection").Execute (sql)
%>

<Html>
<body>
<Font Face=".VnTime" size="3">
Mét b¶n ghi ®· ®îc bæ xung.
<p><a href="Input.asp">TiÕp tôc</a>
</Font>
</Body>
</html>
· ListOne.asp:
<%@ Language=VBScript %>

<%
ID = request("ID")

'connect to database
sql = "select * from Lich where ID="+ID

'Response.Write(sql)
Set rs = Session("objConnection").Execute (sql)
%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY>
<Font Face=".VnTime" color="DarkBlue" Size="3">

<font color="#800080" face=".VnTime" size=5><em><strong>L&THORN;ch ph&cedil;t


s&atilde;ng VTV</strong></em></font>
<br>
<hr width="50%" Color="blue" align="left" Size="3">
<br>

<STRONG>Ng&micro;y :&nbsp;</STRONG>
<%=rs("Ngay")%>
<br><STRONG>Gi&ecirc;
:&nbsp;</STRONG>
<%=rs("GioPhut")%>
<br><STRONG>Th&Oacute; lo&sup1;i
:&nbsp;</STRONG>
<%=rs("The_Loai")%>
<br><STRONG>T&ordf;n ch&shy;&not;ng
tr&times;nh :&nbsp;</STRONG>
<%=rs("Ten_Chuong_Trinh")%>
<br><STRONG>Bi&ordf;n t&Euml;p
:&nbsp;</STRONG>
<%=rs("Bien_Tap")%>
<br><STRONG>Bi&ordf;n d&THORN;ch
:&nbsp;</STRONG>
<%=rs("Bien_Dich")%>
<br><STRONG>Th&ecirc;i
l&shy;&icirc;ng :&nbsp;</STRONG>
<%=rs("Thoi_Luong")%>
<br><STRONG>V&iuml;ng s&para;n
xu&Ecirc;t :&nbsp;</STRONG>
<%=rs("Vung_SX")%>
<br><STRONG>H&Ouml; s&egrave; qui
&reg;&aelig;i :&nbsp;</STRONG>
<%=rs("He_So_Qui_Doi")%>
<br><STRONG>Th&iuml; lao BT
:&nbsp;</STRONG>
<%=rs("Thu_Lao_BT")%>
<br><STRONG>Th&iuml; lao DD
:&nbsp;</STRONG>
<%=rs("Thu_Lao_DD")%>
<br><STRONG>Th&iuml; lao QP
:&nbsp;</STRONG>
<%=rs("Thu_Lao_QP")%>
<br><STRONG>Th&iuml; lao CTV
:&nbsp;</STRONG>
<%=rs("Thu_Lao_CTV")%>

<%
set rs=Nothing
%>

<!-- xoa sua -->


<br><br>
<Table width="50%" border=0>
<tr>
<td width="25%"><a href="UpdateElm.Asp?ID=<%=id%>">Söa</a></td>
<td width="25%"><a href="DeleteAsp.Asp?ID=<%=id%>">Xo¸</a></td>
</tr>
</Table>
</Font>
</BODY>
</HTML>
· MonthReport.asp:
<%@ Language=VBScript %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">


<html>

<head>

<meta name="GENERATOR" content="Microsoft FrontPage 3.0">


<title></title>
</head>

<body background="../images/bgr.gif">

<Script language="JScript">
function getCurrentYear()
{
var d = new Date();
var s = String(d.getYear());
if (s.length<=2) s="19"+s;
document.frm.Year.value=s;
}

</Script>

<script language="JavaScript">
<!--
function thuchien()
{
document.frm.submit();
}
// -->
</script>

<font color="#800080" Size="5" face = ".VnTime"><em><strong>


B¸o c¸o lÞch ph¸t sãng VTV theo th¸ng
</strong></em></font>

<SCRIPT LANGUAGE="JScript">
</SCRIPT>

<form action="BKTTCT.asp" method="post" name="frm">


<div align="left"><table border="0" width="502" cellspacing="0" cellpadding="0">
<tr>
<td width="110" nowrap checked = "false"><font size="3" face=".VnTime">
<strong>Th¸ng:</strong></font></td>
<td width="384" checked = "false"><font face=".VnTime">
<select name="Month" width= '12' size="1">
<%For i=1 to 12%>
<option value="<%=i%>"><%=i%></option>
<%Next%>
</font>
</td>
</tr>
<tr>
<td width="110" nowrap checked = "false"><font size="3" face=".VnTime">
<strong>N¨m :</strong></font></td>
<td width="384" checked = "false"><font face=".VnTime"></font><INPUT name="Year"
style="HEIGHT: 22px; WIDTH: 82px"></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" width="448" nowrap checked =
"false">&nbsp;</td>
</tr>
<tr>
<td colspan="2" width="448" nowrap checked = "false">
<div align="left"><p>
<font size="3" face=".VnTime"><strong>
<a href="javascript:thuchien()"><img src="../images/Thuchien.gif" alt="Xem b¸o c¸o thêi gian
truy cËp INTERNET" border="0" WIDTH="85"
HEIGHT="21"></a></strong></font></p></div></td>
</tr>
</table>
</div>
</form>

<p align="left"><font face=".VnTime"></p></FONT>


<script>
getCurrentYear();
</script>
</body>
</html>
· Schedule.asp:
<%@ Language=JavaScript %>
<%
var month = Request("month");
var year = Request("year");

function drawCalendar(month,year)
{
var startDay=new Date(year,month-1,1);
var endDay=new Date(year,month-1,31);
i=31;
while (endDay.getMonth()>month-1)
{
endDay=new Date(year, month-1,i-1);
i--;
}
startDate=1;
endDate=endDay.getDate();

//mang lu lich
var luoi=new Array(42);
for (i=0;i<42;i++) luoi[i]=0;

//how many week in month


var numWeek;

//ngay dau thang la thu may


n=endDay.getDate();
var Week=new Array(); // So ngay cua tung tuan
if (startDay.getDay()==0) Week[0]=1;
else Week[0]=7-startDay.getDay()+1;
for (j=6;j>6-Week[0];j--) luoi[j]=j-6+Week[0];
n=n-Week[0];
i=0;
while (n>0)
{
i++;
if (n>=7) Week[i]=7;
else Week[i]=n;
for (j=0;j<Week[i];j++) luoi[j+7*i]=(i-1)*7+j+1+Week[0];
n=n-Week[i];
}
//ve bang
Response.Write("<Font color=#800080><h2>LÞch ph¸t sãng th¸ng "+month+"
n¨m "+year+" </h2></Font>");
Response.Write("<Table border=1 cellpadding=0 cellspacing=0 width=840>");
//Tinh chieu rong va cao o
var CellWidth=(840-60)/(Week.length);
// Hang chi so tuan
Response.Write("<tr align=center bgcolor=#808000>");
for (j=-1;j<Week.length;j++)
{
Response.Write("<td>");
switch (j)
{
case -1: Response.Write("TuÇn"); break;
case 0: Response.Write("I"); break;
case 1: Response.Write("II"); break;
case 2: Response.Write("III"); break;
case 3: Response.Write("IV"); break;
case 4: Response.Write("V"); break;
case 5: Response.Write("VI"); break;
}
Response.Write("</td>");
}
Response.Write("</tr>");
// vong lap viet ra ngay
for (i=0;i<7; i++)
{
Response.Write("<tr bgcolor=#C0C0C0 align=center>");
// viet thu
Response.Write("<td width=60 rowspan=2>");
switch (i)
{
case 0: Response.Write("Thø hai"); break;
case 1: Response.Write("Thø ba"); break;
case 2: Response.Write("Thø t"); break;
case 3: Response.Write("Thø n¨m"); break;
case 4: Response.Write("Thø s¸u"); break;
case 5: Response.Write("Thø b¶y"); break;
case 6: Response.Write("Chñ nhËt"); break;

}
Response.Write("</td>");
for (j=0;j<Week.length;j++)
{
Response.Write("<td width="+CellWidth+">");
if (luoi[i+7*j]!=0) Response.Write(luoi[i+7*j]);
else Response.Write("&nbsp;");
Response.Write("</td>");
}
Response.Write("</tr>");
Response.Write("<tr>");
for (j=0;j<Week.length;j++)
{
Response.Write("<td>");
if (luoi[i+7*j]==0) Response.Write("&nbsp;");
else
{

var day=luoi[i+7*j];
sql="Select * from Lich where
Ngay=#"+month+"/"+day+"/"+year+"#";
var rs = Session("objConnection").Execute(sql);
while (!rs.EOF)
{
Response.Write("<a
href=\"ListOne.asp?ID="+rs("id")+"\">&nbsp;"+rs("Ten_Chuong_Trinh")+"</a><br>");
rs.MoveNext();
}
rs.close();
}
Response.Write("</td>");
}
Response.Write("</tr>");
}
Response.Write("</Table>");
}

%>

<HTML>
<HEAD>
<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">
</HEAD>
<BODY background="../Images/bgr.gif">
<Font face=".VnTime" size=3>
<%drawCalendar(month,year);%>
<P>&nbsp;</P>

</Font>
</BODY>
</HTML>
· ScheduleInit.asp:
<%@ Language=VBScript %>

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">


<html>

<head>
<Script language="JScript" RUNAT="SERVER">
function selectMonth(month)
{
var d = new Date();
if (month==(d.getMonth()+1))
return "Selected";
else
return "";
}
</Script>

<Script language="JScript">
function getCurrentYear()
{
var d = new Date();
var s = String(d.getYear());
if (s.length<=2) s="19"+s;
document.frm.year.value=s;
}
</Script>
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title></title>
</head>

<body background="../images/bgr.gif">

<script language="JavaScript">
<!--
function thuchien()
{
document.frm.submit();
}
// -->
</script>

<font color="#800080" Size="5" face=".VnTime"><em><strong>


LÞch ph¸t sãng theo th¸ng
</strong></em></font>

<SCRIPT LANGUAGE="JScript">
</SCRIPT>

<form action="Schedule.asp" method="post" name="frm">


<div align="left"><table border="0" width="502" cellspacing="0" cellpadding="0">
<tr>
<td width="110" nowrap checked = "false"><font size="3" face=".VnTime">
<strong>Th¸ng:</strong></font></td>
<td width="384" checked = "false"><font face=".VnTime">
<select name="month" width= '12' size="1">
<%For i=1 to 12%>
<option value="<%=i%>"
<%=selectMonth(i)%>><%=i%></option>
<%Next%>
</font>
</td>
</tr>
<tr>
<td width="110" nowrap checked = "false"><font size="3" face=".VnTime">
<strong>N¨m :</strong></font></td>
<td width="384" checked = "false"><font face=".VnTime"></font><INPUT name="year"
style="HEIGHT: 22px; WIDTH: 82px"></td>
</tr>
<tr>
<td>&nbsp;</td>
</tr>
<tr>
<td colspan="2" width="448" nowrap checked = "false">
<div align="left"><p>
<font size="3" face=".VnTime"><strong>
<a href="javascript:thuchien()"><img src="../images/Thuchien.gif" alt="Xem lich phat song
theo thang" border="0" WIDTH="85" HEIGHT="21"></a></strong></font></p></div></td>
</tr>
</table>
</div>
</form>
<p align="left"><font face=".VnTime"></p></FONT>
<Script>
getCurrentYear();
</Script>
</body>
</html>
· UpdateAsp.asp:
<%@ Language=VBScript %>
<%

sql="Update Lich set "


sql=sql+"Ngay='"+request("Ngay")+"',"
sql=sql+"GioPhut='"+request("GioPhut")+"',"
sql=sql+"The_Loai='"+request("The_Loai")+"'," 'TheLoai
sql=sql+"Ten_Chuong_Trinh='"+request("Ten_Chuong_Trinh")+"'," 'Ten Chuong trinh
sql=sql+"Bien_Tap='"+request("Bien_Tap")+"'," 'Bien Tap
sql=sql+"Bien_Dich='"+request("Bien_Dich")+"'" 'Bien Dich
sql=sql+" where id="+request("ID")

'Response.Write(sql)
Session("objConnection").Execute (sql)
%>

<Html>
<body>
<Script Language="JScript">
function back()
{
window.history.go(-2);
//document.a.location.reload();
//window.alert(document.url);
}

</Script>

<Font Face=".VnTime" size="3">


B¶n ghi ®· ®îc cÆp nhËt.
<p><a href="javascript:back()">TiÕp tôc</a>
</Font>
</Body>
</html>
· UpdateElm.asp:
<%@ Language=VBScript %>

<%
ID = request("ID")

'connect to database
sql = "select * from Lich where ID="+ID

'Response.Write(sql)
Set rs = Session("objConnection").Execute (sql)

'connect to database
sql = "select The_Loai from The_Loai"
'Response.Write(sql)
Set rsTheLoai = Session("objConnection").Execute (sql)

Function optionCT(s1,s2)
if (s1=s2) then
optionCT="selected"
exit Function
else
optionCT=""
exit Function
end If
End Function

%>

<HTML>
<HEAD>
<SCRIPT LANGUAGE="JScript">
function update()
{
document.frmUpdate.submit();
}

</Script>

<META NAME="GENERATOR" Content="Microsoft Visual Studio 6.0">


</HEAD>
<BODY>
<!-- Insert HTML here -->
<Font face='.vnTime'>
<Form action="UpdateAsp.asp" method="POST" name="frmUpdate">
<input type="Hidden" name="ID" Value="<%=ID%>">
<table border="0" width="400" cellpadding="0" cellspacing="0">
<tr>
<td width="100">Ngµy :</td>
<td width="80"><input type="text" name="Ngay" size="12" Value="<%=rs("Ngay")%>"></td>
<td width="40"></td>
<td width="100">Giê phót :</td>
<td width="80"><input type="text" name="GioPhut" size="12"
Value=<%=rs("GioPhut")%>></td>
</tr>
<tr>
<td width="100">ThÓ lo¹i CT:</td>
<td width="80">
<select name="The_Loai" width= '12' size="1">
<%do while not rsTheLoai.EOF %>
<font face = ".VnTime">
<option face=".VnTime" style="FONT-FAMILY:.VnTime"
value="<%=rsTheLoai("The_Loai")%>"
<%=optionCT(rsTheLoai("The_Loai"),rs("The_Loai"))%>><%=rsTheLoai("The_Loai")%>
</option>
</font>
<% rsTheLoai.MoveNext
loop%>
<%
set rsTheLoai=Nothing
%>

</select></td>
<td width="40"></td>
<td width="100"></td>
<td width="80"></td>
</tr>
<tr>
<td width="100">Tªn CT:</td>
<td width="320" colspan="4"><input type="text" name="Ten_Chuong_Trinh" size='33'
Value="<%=rs("Ten_Chuong_Trinh")%>" style="FONT-FAMILY:.VnTime"></td>
</tr>
<tr>
<td width="80">Biªn tËp:</td>
<td width="80"><input type="text" name="Bien_Tap" size="12"
Value="<%=rs("Bien_Tap")%>" style="FONT-FAMILY:.VnTime"></td>
<td width="40"></td>
<td width="100">Biªn dÞch:</td>
<td width="80"><input type="text" name="Bien_Dich" size="12"
Value="<%=rs("Bien_Dich")%>" style="FONT-FAMILY:.VnTime"></td>
</tr>
<tr>
<td width="100">Thêi lîng:</td>
<td width="80"><input type="text" name="Thoi_Luong" size="12"
Value="<%=rs("Thoi_Luong")%>"></td>
<td width="40"></td>
<td width="100">Vïng SX:</td>
<td width="80"><input type="text" name="Vung_SX" size="12"
Value="<%=rs("Vung_SX")%>" style="FONT-FAMILY:.VnTime"></td>
</tr>
<tr>
<td width="100">HS qui ®æi:</td>
<td width="80"><input type="text" name="He_So_Qui_Doi" size="12"
Value="<%=rs("He_So_Qui_Doi")%>"></td>
<td width="40"></td>
<td width="100">Thï lao BT:</td>
<td width="80"><input type="text" name="Thu_Lao_BT" size="12"
Value="<%=rs("Thu_Lao_BT")%>"></td>
</tr>
<tr>
<td width="100">Thï lao DD:</td>
<td width="80"><input type="text" name="Thu_Lao_DD" size="12"
Value="<%=rs("Thu_Lao_DD")%>"></td>
<td width="40"></td>
<td width="100">Thï lao QP:</td>
<td width="80"><input type="text" name="Thu_Lao_QP" size="12"
Value="<%=rs("Thu_Lao_QP")%>"></td>
</tr>
<tr>
<td colspan="5" width="400" align="Center"><br><a href="javascript:update()"><img
src="../images/ThucHien.gif" border="0" WIDTH="85" HEIGHT="21"></td>
</tr>
</table>
</form>
</Font>

<%
set rs=Nothing
%>

</BODY>
</HTML>
· FieldNull.inc :
<Script language="JScript" RUNAT="SERVER">
function strGioPhut(GioPhut)
{
var g= new Date(GioPhut);
return (g.getHours()+":"+g.getMinutes());
}

function strNgay(Ngay)
{
var d= new Date(Ngay);
return (d.getDate()+"/"+(d.getMonth()+1)+"/"+d.getYear());
}

function strNull(str)
{
var s= new String(str);
if ((s=="null") || (s==""))
{
return "&nbsp;";
}
return s;
}

function numNull(num)
{
var n= new Number(num);
if ((n==NaN) || (n==0))
{
return "&nbsp;";
}
return n;
}

</Script>

You might also like