BO CIAO DVC VA DAD T30
TRIIING D31 HQC THANG LONG
ar-aaans-----
KHOA LUAN TOT NGHIEP
XAY DING WEBSITE DU LICH TR!J'C TUYEN
SIT DUNG ASP.NET MVC 4
Ciao vien hinting din : ThS. Trin Quang Duy
Sinh vien thut hien : Phan' Vinh An — A16788
Chuyen ngInh : Khoa hos nuty ILA
HA NOI - 2014
all NO! DAU
Tnrac day viec lcinh doanh bin tour du ljch chi don than cic ding viec nhu
quip 19 tour, at tour, thong ke doanh thu th8ng qua fay tb vi bang tinh excel... Tuy
nhien, den khi
97 trang |
Chia sẻ: huong20 | Ngày: 07/01/2022 | Lượt xem: 359 | Lượt tải: 0
Tóm tắt tài liệu Khóa luận Xây dựng website du lịch trực tuyến sử dụng Asp.net MVC 4, để xem tài liệu hoàn chỉnh bạn click vào nút DOWNLOAD ở trên
nhu au di du ljch theo tour cult Mulch hang ngiy cing tang thi viec
quitn 19 bang giey Os khang can hieu qua, viec quin 19 dot tour, doanh thu se rat nhieu
thin gian vi thieu slit.
Ctng von viec ang dung CNTT duqc phit then moth trong nfrang nim vita qua,
vi de dip *rig nhu ciu di du ljch ngiy cing tang tins kith hang vi riling cao hieu qui
tong viec quin 19 tour, at tour hay tinh toin doanh thu... He thong lcinh doanh quin
19 bin tour true tuyen di duqc ra dbi.
He thong bin tour trim tuyen: la mOt phin he dinh cho khich !Ling Public c6 the
book tour gift ch6 vi thanh toil) trot tuyen thong qua cic hinh thirc thanh town: Visa,
ATM, vi dien term Nth do, tint hem rat nhieu Uri gian vi cong sac cho khich hing
mei khi co nhu cAu di du ljch. Website du ljch Inc tuyen ii mOt the hien clut he Sang
bin tour du ljch trot tuyen.
Sr ra din dm he thong bin tour trim tuyen di giup giim thieu lion the ye khang
gian vi thin gian rat nhilu gills viec lien kit ban tour, tang khi Ming quin tri mOt cich
hieu qui, &at thieu thOi gian cho than vien ding nhu ban quin tri, tang them doanh
thu bin hing, gap phiin to citu nei gin ket khich ling vai cang ty du ljch, th8ng qua
cic kenn thong tin da chi& WA nhieu lien ich, klvich hang c6 the tra cau cic thong tin
du ljch trong vi ngoii nuOc ten website moi hit moi nai.
NO1 dung bio cio dirge chic 1km 5 chums chink:
1. TONG QUAN VE ASP.NET MVC FRAMEWORK
Giai thieu ye MVC vi qui trInh hoot dOng cult ASP.NET MVC Framework
2. D4C TA YEU CAU 111 THONG
Cic ac diem co bin cita he thong bin tour trot toy& vi ac ti yeu au he thong.
3. PHAN TECH THIET ICE HI THONG
Chuang nay bao gem tic giai (top ctia phlin phis) tich nhu: phan tich thiet ice CSDL,
thiet Ice chat Wing...
4. lay DUNG CHtt NANG
Chuang nay di vao viec xiy dung co the tfmng chic ning cM he thong theo m8 hinh
MVC bao gem cic: Model, View , Controller.
5. TRIEN KHAI iiNG DUNG
Chuang nay huOng din each milt bitn vi trien khai mOt img dung ASP.NET MVC.
2/971 HI thong bin tour du Ijch trvc to+
LEI CAM UN
Em xin chin thanh cam an bO men tin Toin - Tin twang Dai hoc Thing Long di
to dieu Iden cho em thvc hien di tai nay.
Em xin cam an they TAW Quang Duy, ngueri di ten tinh gitlp do chi be° em
trong suot qua trinh thvc hien kh6a luon nay. Trong thbi gian dugs they hiding din,
chi bao em de hoc hei duqc nit nhieu kien thtic bet ich ciin thief.
Mac do di co ging holm thin de di kh6a lualn vei tit al nii hrc cult ban than
niumg chic chin khong thiku khei nheng thieu sot. Kith mong gut they c6 ten filth
chi bao.
Mt t len nu e, em xin chin thinh cam on sv giip der cis gut they c6 va In&
mong duqc sv d6ng Op qujr Mu dui tit ca moi ngutri de em c6 the lien b0 hon. Kirsh
chile gut they co lute Won mph kh6e, g#t hai duqc nhieu thanh Ong trong sv nghiep.
Ha NOi, very 4 Acing 12 ndm 2014
Sinh vien Myr hien
PHAM VINH AN
3/97 I HI thong bin tour du Itch Inc tuyin
MVC LUC
DANH MUC CAC THU4T NGU VA it WET TAT 8
DANH MIJC BINH ANH 9
CHUONG 1. TONG QUAN VE ASKNET MVC FRAMEWORK 11
1.1. Gi61 &leo ve ma hinh MVC 11
1.1.1. Cac thanh phan mia MVC 11
1.1.2. Hoot dang cia ma hinh MVC 12
1.1.1 UY dam va nhitac diim cia MVC 12
1.2. G161 Mau vi ASP.NET 13
1.3. ASP.NET WebForm truyin thong 13
1.4. ASP.NET MVC Framework 15
1.4.1. Nguan gic 15
1.4.2. Clic thanh pion ca ban mia ASP.NET MVC 15
1.4.3. Qua trinh hoot (fang cia mat ang dyng ASP.NET MVC 16
1.4.4. Mot so` &A rthng not bat caa ASP.NET MVC Framework 17
1.4.5. Liu dilm 17
1.4.6. Nhuvc diem 17
1.4.7. So sank gift ASP.NET webforn: va ASP.NET MVC 18
1.4.8. Khai km mai sing dyng ASP.NET MVC Framework 20
CHUC1NG 2. D4C Ti YEU CAU He THONG 28
2.1. TO sao con hi thong bin tour du Itch trwc tuyin 28
2.2. Cie dlic diem cc bin cia hi thong bin tour du itch trwc tuyin 29
2.3. Dec ti yeu au 29
2.3.1. Quan tc: Tour 29
2.3.2. Hart Tow 32
2.3.3. Qua 1, don dat Tour 34
2.3.4. Danh mite dia dam du lich 36
2.3.1 Quanoi tin ttic 38
2.3.6. Thong led 40
2.3.7. Quin li: tai khocin 42
4/971 Hi thong bin tour du gch1rwc tuyin
CHUONG 3. PHAN TECH TH1ET ICE HS THONG 44
3.1. PHAN TICH THEET Kg CO Sti Dtr LIP 44
3.1.1. M6 hinh quan he at lieu 44
3.1.2. Danh sach being va mo to 45
3.1.3. Bang Country 46
3.1.4. Bang ProvinceCity 46
3.1.1 Bang Location 47
3.1.6. Bang TourType 47
3.1.7. Bang TemplateTour 48
3.1.8. Bang TemplateTourDetail 48
3.1.9. Bang Tour 49
3.1.10. Bang TourDetail 49
3.1.11. Bang TourHotelDetail 50
3.1.12. Bang BookTour 50
3.1.13. Bang BookTourDetail 51
3.1.14. Being Account 51
3.1.15. Bang Customer 52
3.1.16. Bang News 52
3.1.17. Bang Hotel 53
3.1.18. Bang HotelRoomType 53
3.1.19. Bang BookRoom 54
3.1.20. Bang BookRoomDetail 54
3.2. THAT Kt CHfIC NANG 55
3.2.1. Trang cini. 55
12.2. Trang quan tri 60
CHIIONG 4. XAY MING CHOt NANG 65
4.1. CLu tric mil nguIn then 'den Ink MVC 65
4.1.1. Models 65
4.1.2. Controllers 67
4.1.3. Views 68
5/97 I HI thong bin tour du Ijch bye tuyin
4.2. Quin if Tour 69
4.2.1. Ca so. dit lieu 69
4.2.2. Models 71
4.2.3. Controller 73
4.2.4. Views 74
4.2.5. Javascript 75
4.3. Nit tour 76
4.3.1. Ca set dri lieu 76
4.3.2. Model 77
4.3.3. Controller 78
4.3.4. View 78
4.4. Quin ty don Chit tour 79
4.4.1. Ca sa de lieu 79
4.4.2. Model 79
4.4.3. Controller 80
4.4.4. View 80
4.5. Danh myc dja diim du Ijch 81
4.5.1. Ca so da lieu 81
4.5.2. Model 82
4.5.3. Controller 83
4.5.4. View 84
4.6. Quin If tin bit 85
4.6.1. Ca so at lieu 85
4.6.2. Model 85
4.6.3. Controller 86
4.6.4. View 86
4.7. Thong ke 87
4.7.1. Model 87
4.7.2. Controller 87
4.7.3. View 88
4.8. Quin If tii khoin 88
6/97 I HI th6ng bin tour du Ijch bye tuyin
4.8.1. Ca so. da lieu 88
4.8.2. Model 89
4.8.3. Controller 89
4.8.4. View 89
MIXING 5. MIEN KHAI (NG DVNG 91
5.1. Cic buoy trim khai 91
5.2. Trail khai VnTravel site 91
5.3. Clu Mph HS cho Framework MVC sdr dung microsoft web platform
installer 92
5.4. Them VnTravel site vio HS 94
'CET LU3N 96
TAI LI$U THAM KiiA0 97
7/97 I HI thong bin tour du Lich tryc tuyin
DANH MIX CAC THU4T NGtY VA Tir WET TAT
I 1111,11 11"11 I II ICI 1;11 (I.:\ ilu
Framework
Nen tang
HTML
HyperText Markup Language
URL Uniform Resource Locator
Platform Nen tang
8/971 lif thong bin tour du lich tryc toy&
DANH MVC HINH ANH
Hinh 1.1 M6 hinh MVC 11
Hinh 1.2 Quy trinh hopt dOng cua mo hinh MVC 12
Hinh 1.3 Gong nghe ASP.NET WebForm 13
MA 1.4 Ccic think phdn co. ban cues ASP.NET MVC 15
!link 1.5 ASP.NET WebForm vi ASP.NET MVC 18
Hinh 1.6 Kheti 4w :Mg dim ASP.NET MVC 20
Hinh 1.7 HOp thogi New ASP.NET MVC3 21
Hinh 1.8 Minh hpa mot Solution Explorer cilia ASP.NET MVC3 22
Hinh 1.9 Giao dien ca ban khi chgy sing dim ASP.NET MVC c6 san 23
HIM 1.10 Kit nil ca so dit lieu bdng Entity Framework — Mak 1 24
Hinh 1.11 Kit not ca so da lieu bang Entity Framework — buck 2 25
Hinh 1.12 Kit nil ca ser da lieu ding Entity Framework — bulk 3 25
Hinh 1.13 Kit ndi ca sit da lieu bang Entity Framework — buck 4 26
Hinh 1.14 Kit ntli ca sb dit lieu bdng Entity Framework — bu6c 5 27
Rink 1.15 Kit not ca sit dd. lieu bang Entity Framework — but 6 27
Hinh 2.1 Quy trinh quern if; tour 30
Hinh 2.2 Quy trinh dOt tour 32
Hinh 23 Quy trinh pan lir don dOt tow 34
Hinh 2.4 Quy trinh gucin lf) dank mgc dja diim du lick 36
Hinh 2.5 Quy trinh quern OS tin tar 38
Hinh 2.6 Bao ctio thong ke 40
Hinh 2.7 Quy trinh quern ly tai khocin 42
Hinh 3.1 Ca so (Milieu wean he thing 44
'fink 12 Trang quern trj 60
Hinh 3.3 Danh sack tour 61
Ifinh 3.4 Them tour mbi 61
Hinh 3.5 Danh MIX dam du ljch 62
Hinh 3.6 Them meti diim du ljch 62
Hinh 3.7. Quern ly tin tic 63
Hinh 3.8. Them m61 tin tic 63
9/97 HI thong bin tour du Lich trim tuyin
Hinh 3.9 Chic ruing thong ke 64
Hinh 3.10 Form tham so 64
Hinh 3.11 Hein 114 kit qua 64
Hinh 4.1. du trac ma' nguan theo kiln trac MVC 65
Hinh 4.2 Thu myc Models 65
Hinh 4.3 Thu myc controllers
67
Hinh 4.4 Thu myc Views 68
Hinh 5.1 Man hinh Publish Web 91
Hinh 5.2 Man hinh Iva chon platform de chi 114t. 92
Hinh 5.3 Man hinh kilm tra thi eldt .NET Framework viz ASP.NET 93
Hinh 5.4 Kiim tra cai &ft SQL server
94
Hinh 5.5 Internet Information Services (IIS) Manager 94
Hinh 5.6 Add Website Dialog 95
10/97 I HI th6ng bin tour du lich tryt tuyEn
Ting quan in ASP.NET MVC Framework
CHISCING 1. TONG QUAN VE ASP.NET MVC FRAMEWORK
1.1. Gild thilu ve m8 hit& MVC
Khi cac phan mem ing dung ngly cing phat trim lin manh vi da dang thi vin
41 thilt Ice kiln tnic cho plain mem cans trb non phis tap han. Nhftng ling dung web
gib day cuing di phat then den mOt tam cao mei, ching khang con la nhOng img cb,mg
web thong thuirng vii chic riling hien thi thong tin mi la thong he thong thong tin h6
trq nhftng tang web tuong tic v6i ngutri ding. Nhieu giii phap thiet ke kik tnic he
thong duqc dui ra vii muc Bich lam cho he thong linh hoot, mem deo, de phat trien vi
ten tai lAu dal. Trong do, giai phip thiet Ice theo m8 hInh kiln tic MVC dtrqc Trygve
Reenskaug de xuAt vao nhftng niim 70 curt the ky 20 to ra rat hieu quit.
M8 hInh MVC (Model - View - Controller, Hirsh 1.1) la mOt kiln frac phial mem
hay m8 hinh thiet ke duqc sir dung tong ky thuit phan mem. N6 ginp cho cac nha
phat trier tack *rig dung cis hp ra thanh 3 phan khic nhau Model, View vit Controller.
Mil thinh phin co mOt nhiem vu rieng bier va dOc yeti cac thimh phan khic.
LLL Ctic thank phlin cia MVC
View
S
Controller
Model
!link 1.1 Me hinh MVC
Model
Day 11 thanh phan chive tit ca cac nghiep vu logic, phuong thftc xir ly, truy xuat
database, ded ft:mg m8 to dft lieu nhu cac Class, him xir1y...
View
Dim nhan vier hien °tilting tin, Wong tic veri nguM ding.
Controller
Gift nhiem vu nh$n diet' huing cac you cau tft nguiri ding vi goi ding nhftng
phuang thirc xi lt chimg.
11/971 HI thong bin tour du Lich tryt tuyin
I Yaw I ICI I Mad
Ars
I
I
Tang quan vi ASP.NET MVC Framework
LL2. Hoot Ong cdo m6 hind MVC
Diy 1>1 mOt each dun giro (HInh 1.2) di m6 tit lai luhng sq lden duqc xfr trong
MVC:
-
User ttumg tic v6i View, bing citch click vio button, user girl yeu au di.
-
Controller thin vi (lieu huang chtmg den dung pinning thirc xir lt 6 Model.
- Model nh$n thong tin vi thqc thi cic you au.
-
Khi Model hoin tit vi.c xir it, View se nh$n ket qui M Model vi hien thi lei
cho ngubi dung.
Ifinh 1.2 Quy trinh how dOng aia m6 hinh MVC
L L3. Os memo& taupe ttlim cola MVC
4, has Sm:
The hichi tinh chuyen nghiep trong lip trinh, phis tick thiet ke. Do duqc chin
thbh cic thanh phin doc lop nen gulp phis trier img dor% nhanh, don gitin, de fling
cep, bio
12/97 I Elf thong bin tour du lfch trim tuyin
Tang quan vi ASP.NET MVC Framework
49 Nktnyc tam:
Doi veal dg an nh6 v.** ap dung m8 hinh MVC gay ding kenh, tan thin gian
trong qua trinh phitt trier. Tan thbi gian trung chuyin di lieu glut clic thanh phin.
1.2. GM tbilu vi ASP.NET
ASP.NET la mOt nin tang ph& then img dung web (web application framework)
dugs phat tan va cung cep WA Microsoft, cho phis') nhftng ngubi lop trInh too ra
nheng trang web Ong, nheng img dung web va nhing djch vu web Lin diu den
dugc dua ra thi trubng vac* thing 2 Mtn 2002 can vgi phi& ban 1.0 ctla .NET
framework, la gong nghe n6i tiep ciut Microsoft Active Server Pages(ASP). ASP.NET
dugc bier djch duel ding Common Language Runtime (CLR), cho phep nheng ngubi
11p trinh viet ma ASP.NET yen bit 10 nem net Mo duct ha trg bgi .NET language.
1.3. ASP.NET WebForm truyin thong
ASP.NET la mOt buck nhity vqt khi lin diu xuit hien, nhim thu hgp khoang
catch gift phitt trier Window Form huOng dai tugng (c6 trang thai) Ara phat tan web
huOng HTML (khong tang Hirsh 1.3 dual diy minh boa c8ng nghe ASP.NET
Webform
ASP.NET Web Forms
A MANI mom ponsats (poen, butons. a.) plus a
'OSA objutothensd pregansins model
ASP.NET
A way to hoe .NET **Mambas la NI web sew
product), MS you Inflict sib IMP mats ard response
MET
A codapYtlarm (bnandasw at die time-o Yet Irk In lb own right)
Ilink 1.3 Con nghe ASP.NET WebForm
Vgi Web Forms, Microsoft di c6 in di HTTP va HTML bang cach m8 phgng
giao dien ngubi dung nhulti mOt d6i tugng dilo khan (Control) c6 ciu trac hoot dOng
phis Server.
Mai &Si tugng diiu lchien (Control) theo doi trang thiti cite no th8ng qua cac you
au (sir dung tinh nAng ViewState), bieu then bing chc ml HTML khi can thiet. Ninth
ra, ng con to dOng lc& ntai citc sty kien phis Client (nhtr sit kien bim button) ten cac sly
kien phis Server dugs xt1 15, Mang (mg. Thuc te, Web Forms lit mOt 16p trUu tugng
lcheng 16 dugc thiet key de cung cep giao dien co xir sit kien th6ng qua Web.
13/97 I HI thong bin tour du lids traps tuyin
Ting quan vi ASP.NET MVC Framework
Nheng aim ban chi cilia ASP.NET Web Forms
—ASP.NET Web Forms truyen thong tong lit mOt tutng rit t6t, nhung thvc to
lai phit sink nheng dieu phirc tap khic. Theo thin gian, vile se dung
ASP.NET Web Forms di neu bet 16n mOt se thieu set;
—ViewState: Co the duy tri bang thii thing qua cic yeu ciu (request) thubng
mang lai ket qui la nhftng kh6i Ku:mg km de lieu duqc chuyen giao gift client
va server. De lieu nay c6 the len den hang trim Kbs 6 mOt irng dung web yea
phii, va n6 di qua loi yeti bit kir yeu ciu nio. Dieu nay lam chi= di then gian
chit phin h6i va lim tang nhu ciu Wing thong ctia server;
—Page life cycle (Chu irk ten Au cea mOt tang web): Li cc the kit n6i sv kiln
phis client yeti mi xu 19 sv kiln phis server. N6 phirc top va a bi phi ver,
—Y thec sal ye vile tich bilt cic thimh phin: Me hinh code-behind clot
ASP.NET cung clip meat giiti phip cho phep itng dtmg dua code ra khei cic
clang HTML vao thinh mOt 16p code-behind rieng bolt. Dieu nay duqc hoan
nghenh rOng ran yeti vile tech bill giao dien yeti xir 1St. Nhtmg thvc te,
nheng nha phit trien duqc khuyen khfch pha trOn mi giao dien yeti mi xb ljr
1mg dung (nhu la xi: 15f CSDL) tong nheng 16p code-behind khing 16. Neu
lcheng c6 sv tech biet gift cic thimh phin, ket qui culi cimg c6 the rot kh6
hieu;
—
Limited control over HTML (giiri han hem soit HTML): Server control tv tao
ra cic ml HTML, nhung khong phii la mi HTML ma ta mong dqi. Ngoai vile
mi HTML ctia thing thubng kh8ng twin theo lieu chuim web hole lcheng sir
dung t6t CSS ma he thong cic server control can too ra cic gii tri ID phirc tap
vi kh8ng doin three duqc, lim lch6 khin tong vile sir dung JavaScript;
—Khi fling Idem the thlip: Cic nbi thiet ke cis ASP.NET kheng the dv doin
ring kiem the tv dOng se to dulnh mOt phin tit yeu cea ?CU huong phat trien
phin mem. Kheng ngoc nhien khi lden true chit chi ma hp thiet ke la kheng
phe hqp yeti vile tick hqp ldem the.
ASP.NET vlin tip tµc pith tan. Phi& bin 2.0 them mOt thanh phin chuin di
giam bat se lucmg code ma chting ta cin phil tv viet. Vol phien bin gin Whit
ASP.NET 4.5, mqi the di duqc ning cop ding ke. Phien bin ASP.NET 4.5 di ip dung
mOt s6 tinh Kiang dui ASP.NET MVC vao Web Forms. Tuy v$y, van con mOt han chi
ten ton ben trong no.
14/97 1 HI thong bin tour du lfch tryc tuyin
Tong quan vi ASP.NET MVC Framework
1.4. ASP.NET MVC Framework
Nhu di giei thieu 6 plain truck, mo5 hinh MVC v6i tru diem ctla minh dit duqc
(rug ding trong met so the framework. Trong d6 phii ki den ASP.NET MVC, met
framework ma ngu6n me mei, ay ding tren ASP.NET .
ASP.NET MVC Framework duqc thvc thi tren m6 hinh model—view—controller
(MVC). N6 gqn nap, de clang him di* phin giao dien, tich hop cac tinh :tang elm
ASP.NET. MVC Framework duqc djnh nghla trong namespace System.Web.Mvc vat
lit met phitn cua Wiling gian ten System.Web.
1.4.1. Ngudn gic
Tuy cling nghe ASP.NET MVC mai duqc phis thin nhung n6 c6 ljch sir lk dot
Nen tang MVC duqc pith minh bin Trygve Renskaug, Ong di vitt trang giiy diu tien
nOi ve MVC vio Mm 1978. Ban diu ne dirge Eli 11 Thing Model View Editor pattern,
nhung sau de n6 duqc dot ten lai 11 Model View Controller pattern.
ASP.NET MVC llin diu lien suit hien d6 1:1 trong dtr in mil ngu6n me
MonoRail.
Ngu6n geoc th$t sv de cho ra din cling nghe Microsoft ASP.NET MVC 11 do
Scott Guthrie (mOt trong nhttng nhit sang too ra ASP.NET ) tren chuyen bay den
Austin, Texas de nOi vi hOi thito Alt.NET vio thing 10-2007.
Phien bin ASP.NET MVC 1.0 dirge ra d6i vio nilm 2009.
1.4.2. Cdc thank pun cc ban caa ASP.NET MVC
IP
ASP.NET MVC Framework
Rink 1.4 Ccic thank pidm co bin ctia ASP.NET MVC
Models: Cac d6i tuqng Models lit met phlin ctla img dung, cac d6i tuqng My
thiet lOp logic cita phin de lieu cUa itng ding. Thong thutmg, the d6i tuqng model liy
vi ltm tang thii mkt model trong CSDL. VI dv nhu, met d61 tuqng Product (sin
ph1m) se lAy dit lieu ttY CSDL, thao tic ton de lieu vit se cep nhet da lieu tit lai vie
bang Products 6 SQL Server.
15/971 HO thong bin tour du ljch trot tuyin
Tang quan vi ASP.NET MVC Framework
Views: Views la cic thinh phin ding de hien thj giao dien ngutri ding (UI).
ThBng thutmg, view dupe to dtra vao th8ng tin de lieu Models. Vi du nhu, view ding
de cep nh#t bing Products se hien thi cic hOp von ban, drop-down list, vi cic check
box dua ten tang thii hien tai cis mOt d6i taco% Product.
Controllers: Controller lit cic thimh plain dung de quin 19 tuang tic ngutri dung,
lam viec yell model vi chon view de hien thi giao dien ngutri ding. Trong mOt irng
dung MVC, view chi duce ding di hien th1 thong tin, controller chiu trich nhiem quan
19 vit dip tri nOi dung do ngutri ding nhip vtl Wong tic vei ngutri ding. Vi du,
controller se quip 19 cic de lieu ngutri ding gel len (query-sting values) vit gfri cic
gii tri d6 don model, model se lity de lieu ttl CSDL nhe via cic gii tri thy.
M8 hlnh MVC gifip chins to to duqc cic (mg dung ml ching phitn tich rach rdi
cic lchfa canh elm ling dung (logic ve nhop lieu, logic xis 19 tic vu vit logic ve giao
dien). M8 hinh MVC chi ra mOi loth logic ke ten nen dirge thiep 1#p b diu tren irng
dung. Logic giao dien (UI logic) thuOc ve views. Logic nh#p lieu (input logic) thuOc
ye controller. VI logic tic vu (Business logic —11 logic xi 19 thong tin, muc dich chinh
coo ling dung) thuOc ye model. Su phin chia nay giUp ching to giitm bet ducm str phirc
top cis tug dung vit chi t#p trung vio m6i !this cosh cin duce cii Olt 6 moi thbi diem.
Vi du nhu citing to chi cin tip trung vim giao dien (views) ma kh8ng phii quan tam
den logic xt119 thong tin dm img dung.
St: phin tich rach rbi ba thitnh phis mkt (mg dung MVC con &it cho viec 1#p
trInh dien ra song song. Vi du nhu met lttp trinh visa Run viec vei view, lop trinh vien
thin hth lo th dat logic cis controller vi l‘tp trinh vien this ba co the trung vao logic
tic vu cia model tth cling mOt thbi diem.
1.4.3. Qud Dinh hog! qng cia mQt kw Ong ASP.NET MVC
Cie giai down thuc hien cia mOt (mg dung ASP.NET MVC duqc trhrh bity duei My:
—
Nh#n yeu citu diu lien: Trong file Global.asax, the d6i Wong Route duqc them
vie RouteTable;
—Thyme hien viec djnh tuyen: Module UrlRoutingTable se dung d6i tuqng Route
diu lien thich hop hung tip RouteTable de to d6i tucmg RouteData. D6i
him nay sau de lei to ra d6i tutyng RequestContext (IHttpContext);
—Tao ra trinh xis 19 yeu cow ling dung: D6i Wong MvcRouteHandler too ra mOt
the hien dm lop MvcHandler vI truyin vac, no the hien RequestContext;
16/97 I HI thong bin tour du Ijch try tit+
T6ng quan vi ASP.NET MVC Framework
-
Too ra controller: Cic d6i ttrqng MvcHandler sir dung the hien cis
RequestContext a xic djnh dei tuqng IcontrollerFactory qua de to ra the
hien controller;
-
Thuc hien vai trb cis controller. The hien MvcHandler goi phucrng tit
Execute ctia controller;
-
Goi action method: D61 tucmg ControllerActionlnvoker se xic djnh action
method cos mOt lap controller de gqi ra.
L4.4. Mft sti tusk ming nii b91 cda ASP.NET MVC Framework
- Tich bitch cic tic At cita tang dung.
- Co khi ning ma rOng (extensible) & khi ning !thing (pluggable). Cic thinh
phin cis ASP.NET MVC duqc thiet ke de ching c6 the ductc thay the hoic
thy chinh mOt cich di ding.
- ASP.NET MVC c6 thinh pit inh xo URL mph me, cho phep cluing to xiy
dtmg nheng ang dung c6 cic dill chi URL xfic Lich vi di dm kiem. Cic dia chi
URL Icheing clin phii c6 pan ma rOng cis ten tip tin vi duqc thiet ke de h8
trq cic mitt djnh dung ten phi hop vii viec t•Si tm Ma tim lam (URL).
- H8 trq the fifth Jiang c6 sin cis ASP.NET nhu ea chi xic that ngubi clung,
quin 1St thinh vier, quyin, output caching vi data caching, seession vi profile,
quin ljr tinh nag img dung, he th6ng ceu birth_
- Ta ASP.NET MVC 3 con be sung mOt view engine mai lit Razor View
Engine cho phep thiet lip cic view nhanh chOng, di ding vi ton it ding sue
hart so vai viec su dung Web Forms View Engine.
L4.5. Liu dlim
- Di ding quin It su phirc top cia ang dung bing cich chia img dung thinh ba
thinh phial model, view, controller.
- H8 trq tot hon cho m6 With phit men bug dung huffing kiem thin.
- He th6ng djnh tuyin munh me.
- H8 trq tot cho cic ting dung ducyc ay dung bai nhang dOi cd nhieu lip trinh
vier vi thiet ke mi yin quart ljr &Km tinh rang cis (ling dung.
- H8 trq nhiang tinh fling tot nhet di c6 a ASP.NET .
1.4.6. Arbirpc diEm
- KhOng huang den su lden lint cho cic nlul phit tan ASP.NET webform kh6
khan.
17/971 H, thing bin tour du itch trim tuyin
Tong quan ye ASP.NET MVC Framework
— Yeu c.Au c6 hieu biet ve HTTP, HTML, CSS vi JavaScript.
L4.7. So sdnh gilts ASP.NET webfonn vb ASP.NET MVC
Hinh 1.5 ASP.NET WebForm va ASP.NET MVC
.Net Framework: ha trq cac loui img dung nhu desktop, web vi the img dung console.
ASP.NET framework lit mOt plan ctia .NET framework (Hinh 1.5), duqc xi)/ dung
nh&m ha trq cic img dung Web (caching, authentication va authorization).
Trong do, Microsoft c6 2 huong phis trios web tren n3 n ASP.NET la ASP.NET
Webforms vi ASP.NET MVC. Muc dlch ra dbi cint ASP.NET MVC chi 11 str they d6i
ve mat to duy, n6 'thong hotin Won thay the cho c6 img dung ASP.NET Web Forms,
vi vies chqn htrang silo de xay dung mOt website 11 thy thuOc vio cfc nha pith then.
Su kilo biet gifts 2 huOng pilot trim nay duce the hien du6i bang sau.
I In!' n inn
I \ I I \I I \ I \
phip St) dung cu phip cart Cic str kiOn duqc dieu khiEn bei
tong trinh
webform, tit tic su kien controllers, clic controls lch6ng
va controls do server quart do server quan
It
Debug Debug chuong trinh phii Debug c6 the sir dung cat unit
18/971M Meng bin tour du Itch twc tuytn
Tong quan vi ASP.NET MVC Framework
I
N I I (
thcc hien ci bao g c m
cic 16rp truy cep dli lieu,
sc hien thi, dieu Ichien cic
controls/
test ld tra cac phuung thirc
tong controller
Twang tic vol
KM kW) khan Thuen lqi
javascript
19/97111e th6ng bin tour du ljch trce tuyin
Tong quan vi ASP.NET MVC Framework
1.4.8. ladi mo mdi ung dpng ASP.NET MVC Framework
KW tao mOt itng dyng MVC
Trong bO phin mom Visual Studio 2010 dil c6 sin ASP.NET MVC Framework, to to
mOt do an mei theo dubng din sau: File > New Project > Visual C# > Web >
ASP.NET MVC Web Application (Mull 1.6).
Hirsh 1.6 Kltui tgo ring dyng ASP.NET MVC
20/97 HO thang bin tour du 46 Inrc tuyin
Project Temkin
5dect a template
M
Empty Basic Intranet
Application
ti
Mobile W API Singk Page Facebook
Application Application Application
Is engine
Rex
q peak a unit test project
Test project name
MvcAppicationt.Tests
Test framework
Yowl Stud* Mit Test Additional Into
Desaiptiove
A default ASP.NET INC 4 project wilt an A
account cornets thd usestome
authentication.
V
Cancel
4
Tong cinan vi ASP.NET MVC Framework
Sau khi him OK, hOp thoai New ASP.NET MVC3 hien ra (Binh 1.7).
Hinh 1.7 HO thogi New ASP.NET MVC3
Chung ta ce the chon kieu template la Empty, Internet Application hoc Intranet
Application.
- Empty se nto ra nhang thu muc va tip tin tdi thieu cho ling dung MVC3.
- Internet Application se nto ra met ling dung c6 s6 trang mac djnh, cluing ta co the mkt
d6i va xay dung tren no.
- Toy chqn Intranet Application cling tuong ar nhu Internet Application, niumg duqc
coca hinh sin de stl dung trang mei tilting Vic thqc ngtrbi dan,g thong qua ha tang
Domain/ Active Directory.
Chang ta cOng c6 the too project test cling vol ling dung MVC tir cling met cart s6.
Ben canh d6, ta cling ce the chqn the dO ViewEngine lh ASPX hoic Razor.
21/971 11f thong bin tour du ljch trite tuyin
properties
0 oil References
APP-Data
0 la App_Strt
0 a comet
a Controllers
S Akers
0 a Images
0 la Models
S Saipts
Views
▪ favicon.ico
GlobeLaux
• Padcart‘corlfig
I. Web.config
Search Solution Explorer (Ctrl.;)
I; Solution 'Mvapprocationt (1 project)
1)11'6 II"
/Content La thu muc thubng chtia nhftng dft lieu tibh, nhu la hinh
imh, tep tin css,...
Visual Web Developer tu dung them thu muc Themes vac.
trong Content. Thu attic themes la thu muc chira cac tep
Jquery va hinh anh. Trong du an nay ta co the mkt thu
themes.
Visual Web Developer et-mg them 1 file CSS cat vio du
an ten hi Site.css trong thu muc Content. File CSS la file a
Oa 'chi ta mu& thay tthi style ciut (mg dung.
Tong quan vi ASP.NET MVC Framework
(3 day, ta chip Internet Application, Razor ViewEngine Ara Ichang chin unit test
project. Bern OK de holm tit.
Solution Explorer se hien ra nhu hinh 1.8:
Rink 1.8 Minh boa mat Solution Explorer coo ASP.NET MI7C3
Bang duel day ma to nOi dung throng din ctla met du in MVC Internet Apllication.
22/97 I H. thong bin tour du 106 type tuyin
Home Page_ 14,1 ;i 'UT MVC acpleal.on
Noe we
err. tent,' ”ntal
ansepeaelhambp
• ereeftwed teememenenswesprersienil flat illitalleUeleelle1 es es
4.0•1•Anateinhak 41•01thinIM. hisCleasnIM1IIIM1114004041Inillp 0.11.111a Ws.
Weems Isms. we atone ens ay
410 adialindolleM100111.11•ineedle
•
pyis yam oft le ~ay wise ing UMW *SIN& MIMS.
emovemase
veentom neb bleyeamselenllineeVe lene•seee "nee epees a.m.
sembanwasuina.
quan vi ASP.NET MVC Framework
1)111111" , I,111
/Models G• m cac lep d china cac me hInh di i tuqng cua ling
dung. Models quin lt vi than tic vOi din lieu.
/Scripts Thu muc Script luu trit clic file Jan Script caa img dung.
Mac djnh Visual Web Developer se dot thu muc nay lam
char' de chira cac file Jquery. File "modernize la file
Javascript a h6 trq HTML5 vil CSS3.
Bien (itch vi chgy
Val viec lqa chon Internet Application tut dO, ling dung cim chang to d>i c6 dA chat
Wing ea ban. Hinh 1.9 la ket qui khi chang to chay the bing each bim F5:
<- 6 * ** no*
01 Os *ma 411.1 0 Man la Ohs.- •06.1•Sane- • 2,4 6.10 Cr% Or CO M.,. • • • m• • n WO n Wes.ati • a Illibragiala
IBM 1.9 Giao then co ban khi chgy sing Ming ASP.NET MVC cd siin
23/971 111 th6ng bin tour du ljch trgc twin
IS 5 7 asp
lic ActionResult About()
Tong quan vi ASP.NET MVC Framework
De dfmg chuang trinh, ta t6 hqp phim Shift + F5 hoec chqn Debug Menu vi churl Stop
Debugging.
Kit nii ea se de lieu SQL Server bing Entity Framework
ADO.NET Entity Framework lit mat non tang thgtc 611 dung de lam vies WA CSDL.
Chtng ta c6 the truy van, thao tic v6i database gian nap thong qua cic d6i trqng LSp
trinh.
Chiang ta se kit n6i CSDL bing Entity Framework Database First. N6 se to Ong too
ra data model vit the 16p cho chfing ta tO mat CSDL c6 sin. Day 11 mat cich tiep can
ph6 Win vi no thuc hien don gian, nhanh ch6ng.
Trong cira si Solution click chuOt pith chun Add > New Item...
]fink 1.10 Kit di co. ser de lieu being Entity Framework - buoy 1
24/971140 thing bin tour du lich tnrc tuyin
'ding quan in ASP.NET MVC Framework
Tiep then, clam AD0.1VET Entity Data Model, bim Add
Hirsh 1.11 Kit nil cast di) lieu bang Entity Framework— Mak 2
Giao dien Bien m nhu ben duel, bim Next
Hinh 1.12 Kit nil ca st dl? lieu bibtg Entity Framework - buck 3
25/97 I H. thong bin tour du Ifeh true MAI
bets information to cane to the selected data source or crock 'Change to
choose a different data source and/or pods
Des source:
Hama SCIL Sava (SgiChent)
Sever time
localhost V
Log on to the saver
Eases& 11101101110
Elan rw/ Possivad
Comte to a database
0 Select or area database name
I HQTND V
0 Attach a di abase file
Logical name:
Adoncei-
Lest Connection I
OK
Caned
Chine-
0 Use Windows Authentication
Use SQL Saver Authentication
Lisa name fa
Tong quan vi ASP.NET MVC Framework
ara so mei hien ra, to chbn New Connection vit toy clum csic thong so. Sau db bim
OK
Hinh 1.13 Kit nit co sh rift life bring Entity Framework - buoy 4
26/971111 thong bin tour du gch trwc tuyln
anew Vour Dolidiesealeldebal Salop
NOSY delelmoodliocesdo pow awl to lied•do gour eat
I,Vie
Del Stored Procedures end Funaons
10 'eureka or singulamin govieeted object neneoe
Indudeforsiin kw columns into mood
10 breed soleclod shoed pocedures and fondions imbibe way model
Model Plernoepocs
imarramas
Canal
Tong quan ve ASP.NET MVC Framework
Tiep then, ta chop Next
1
lil
:P
Geese Ye Da Game aft
1111doletecesclft sheeldpeurapplkaleneneumneecellelliedeleS
141110.1CRINft v I Nay Connection—
Of le
mut is This COMISCti011 Ilbing apemen to caftan senlitft ...heo doarh thu theo thy' gian
Thong ke tour theo ;hut gian
Hinh 3.9 Chair ndng thong ki
Thong lee tour theo theti gian
TO ngiy: dd/s/ yyyy
Din NOY:
dd /../yyyy
Lon
Tour in khich
Hinh 3.10 Form therm so
Thong ke tour an Mich IV 01/09/2014 din 31/10/2014
11103
Tao atle• Li• Cat NI MPS 1.41 lam Sig SIOSC•la •100604•• Cat
11•11.111116•1•I• Towed, 11•1100.101•0111•1111
•
110N1311 IOL •Ai MO. Nos ISO TussiVal• Ism Fild•Ams sr *Mesons to TS arm aco. nit a Woo
1110101:47 N110111160ila•TI•Mie111esientip•IIIV•1•60•11111111111001
TETONION NI soli AY to Ms 01.0•• 1.44111.44•1CmOsliiamia 011141I V•811K0•11.
nil!.
11•SIMINS1418•MadielIMItlY•vemelloiliestlilli
itioataen Wye all PM Savo* 4441,08 aCo teleas* WS • 01. CIS
Hinh 3.11 Hiin th1 kit gut)
64/971111 th6ng bin tour du lich trvc tuyin
Xily dun chit ning
CHIAING 4. xAY MING CHIYC NANG
4.1. Ciiu tree mi flan then kiln tree MVC
• 4 IhsTrarallirli lliniliMill
0 a F Properties
► am References
P S App_
0 la &editor
► &finder
Class
► Content
P 5 Controllers
Filters
Image
P la Models
P la Scripts
► lia Views
an faviconico
P as GlobaLasas
▪la packages.config
► ICI Web.config
Hinh 4.1. Chu talc and ngudn theo kiln triic MVC
(3 day chi de cap den 3 phen chinh: Models, Controllers, Views
4. /. /. Models
Models (Binh 4.2) china Mc class del tucmg ducc VS tu sink m khi lien luinh kat nisi
v6i CSDL ADO.NET Entity Data Model (TravelModel.edmx). Moi bang trong CSDL
tucmg (mg WA met class trong ADO.NET Entity Data Model (Account, Country,
Tour,...). Ngoai m can c6 clic model do LTV tu tao ra nhiim muc dich truyen nhan dit
lieu duce nhanh chong (BookingModel,...).
• fia Models
► •c* Booking/AS.1n
► •c• DatelimeltangeModeLcs
► a Co LoginAllodeLcs
• ••jil Trevelkiodeladmx
► ela TravelModel.Costeast
► el) Travallodel.Designerx
41:1 TravelModeladroLdiag
eb TramilModelit
► it Account.cs
► sib lioeldtoom.cs
► at BookRoomOstaiLcs
► at BookTour.cs
►
at BookTourDebil.cs
► eb Country.cs
►
at Custom/tors
Hirsh 4.2 Thu mix Models
65/97 I He thong bin tour du Lich trim tuyin
fly dyng chit ning
Vidviclassditucnig;AumountduipcsidivradmotgingikccounttrorgeSUL:
namespace VnTravel.Models
{
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
public partial class Account
{
public Account()
{
this.News = new HashSet();
this.TemplateTours = new HashSet();
this.Tours at new HashSet();
}
public string AccountlD { get; set; }
//Validate trading Username
[Required(ErrorMessage = "Username kiting duvc b6 trong.")]
[MinLength(5,ErrorMessage ="Tdi thidu 5 ki tu")]
[MaxLength(30, ErrorMessage = "T6i da 30 ki tor)]
public string Username { get; set;
//Validate trubng Password
[Required(ErrorMessage a "Password khong duct b6 trong.")]
[MinLength(5, ErrorMessage = "Tdi thidu 5 ki tor)]
[MaxLength(30, ErrorMessage = "Tdi da 30 ki tV"))
public string Password { get; set;
//Validate trubng Firstname
[Required(ErrorMessage = "Ten khOng duct b6 trong.")]
public string Firstname { get; set;
//Validate trubng Lastname
[Required(ErrorMessage = "H9 khong duqc b6 trdng.")]
public string Lastname { get; set;
public string Address { get; set;
public string PhoneNo { get; set;
//Validate trubng Email
[Required(ErrorMessage . n "Email khong duqc b6 trong.")]
[EmailAddress(ErrorMessage -"Email kh6ng dune)]
public string Email { get; set;
public Nullable Level { get; set;
public virtual ICollection News { get; set;
public virtual ICollection TemplateTours { get; set; }
public virtual ICollection Tours { get; set; }
}
}
66/97 I HI thong bin tour du Lich bye tuyin
fly dying chit Mug
4.1.2. Controllers
• a Controllers
a CP AdminConboller.cs
0 • c• Bookiiigratrallerscs
0 +Cu CustomeControkr.cs
0c ct HameControllerecs
0 a c• HotelController.cs
NewsConbolltr.cs
0 co RegionController.cs
0 • col StaticsControllern
4' Cu TourController.cs
kink 4.3 Thu mix controllers
Controllers chits cat Controller duqc pink theo dai ttrog hoc chet rang quail 15 ,
Minh 4.3) - la cic thinh phan dthg de quim lt Mang tic ngueri dung, lam vies vbi
model va chqn view di hien thi giao Bien ngubi dung (xis lt de lieu de hien thi tren
View hoac lay de lieu to View de
Vi du AccountController c6 cac Action de ail ly clang nhap, dang xuat:
public ActionResult Login()
{
if (SessionrCustomerl -- null IA Session["Admin"] -a null)
return View();
if (SessionrCustomerl Is null)
return RedirectToAction("Index", "Home");
if (Session["Admin"] I. null)
return RedirectToAction("Index", "Admin");
return View();
}
[HttpPost]
public ActionResult Login(LoginModel u)
{
string strError "";
if (ModelState.IsValid)
{
string strPass • CommonFunction.MDS(u.Password);
var testc (from m in db.Customers where (m.Username -- u.Username Si
m.Password -- strPass) select m).ToList();
var testa (from a in db.Accounts where (a.Username -a u.Username AA
a.Password am strPass) select a).ToList();
if (testc.Count > 9)
{
Session["Customer] • u.Username;
return RedirectToAction("Index", "Home");
}
if (testa.Count > 9)
{
SessionrAdmin") • u.Username;
return RedirectToAction("Index", "Admin");
}
else
{
strError a limml.validationSummary()';
ModelState.AddModelError("", "Sal ten (Sang nhap ho9c mot khiu");
67/97 I lif thong bin tour du Ijch trim tuyin
Xiy dying chic ning
}
}
ViewBag.ErrorLogin strError;
return View();
}
public ActionResult Logout()
{
Session.RemoveAll();
return RedirectIoAction("Index", "Home");
}
4.L3. Views
• al Account
BOW] AddAccountahtml
area Ceate.cshbni
IOW EditAcanant.cshbvtl
oDIVI ListAccount.cshbnl
a003 Login.cshtml
IS Admin
le Booking
Hinh 4.4 Thu mix Views
Views Chita clic View tuang (mg v6i cac ActionResult, ViewResult,... trong
controller (Hinh 4.4), hien thj der lieu dugs truyen len, tucmg tic vei ngubi dimg qua
giao dien vi truyen de lieu cho controllers xis ljr.
Vi du View them m6i 1 Account:
1111111VnTravel.Models.Account
I
ViewBag.Title 'Create";
Layout • " -/Views/Shared/_AdminLayout.cshtml";
Create
lusing (Html.BeginForm()) {
IHtml.ValidationSummary(true)
clegend>Accountglegend>
IHtml.LabelFor(model a> model.Username)
rml.EditorFor(model a> model.Username) ml.ValidationMessageFor(model -> model.Username)
10tml.LabelFor(model a> model.Password)
rml.EditorFor(model model.Password) ml.ValidationMessageFor(model a> model. Password)
68/971111 thong bin tour du lich tryt tuyin
fly chmg chttc tiling
IHtml.LabelFor(model a> model.Firstname)
<div class="editor-field"›
rml.EditorFor(model => model.Firstname) ml.ValidationMessageFor(model se> model.Firstname)
10tml.LabelFor(model => model.Lastname)
rml.EditorFor(model => model.Lastname) ml.ValidationMessageFor(model a> model.Lastname)
IHtml.LabelFor(model a> model.Email)
<div classeeditor-field",
=1.EditorFor(model a> model.Email) 1.ValidationMessageFor(model .> model.Email)
}
IHtml.ActionLink("Back to List", "Index")
4.2. Quin lt Tour
4.2.1. CO' Si dart lifu
Tenii)lateTetir
Column Name Data Type Length Allow Nulls DdhultValue Description
t TempWOOMMD varchar(2- 20 q P1(_Mi tour mlu
TourName nvarchar(- 128 q Ten tour
TourTypelD verchar(2- 20 q RLThueic MP tour So
TourDuration ill 4 21 Thdi gian do Si tour (tfrth theo n9 16)
Description ntst 16 El Dien gill
Image nvarchar(- 128 10 Ann clei Pier
(Image 1] nvarchar(- 1 28 0 Ann 1
(Image 2] nverchad- 1 28 0 Ann 2
(Image 3] nvmdmd- 128 IA Anh 3
[Image 4] nverchar(- 128
a Ann 4
CreatorlD vardur(2- 20 q FL-149M teo
El
69/97 I Ht thong bin tour du Ijch trim tuyin
TernplateTourDetail
Data Type Length Now Nuk Default Va-
varrhar(2— 20 q
varchar(2— 20 q
varther(2— 20 q
int 4
ant 4
0
Description
PK_MII chi tilt tour
FlUhugc tour mlu Mo
FK,Thugc diem du lich Mo
1:061 vao ugly the may dra tour
The te
Column Name
V TemptaterourDetaUlD
TemplateTourlD
LoationlD
Duration
(Order)
Tour
Column Name
TourlD
TemplateTour1D
DepartureDaW
NumberSeats
AdultPrice
Childerice
Sabra
InfantPrice
Status
Sale011
CreatodD
Tag
On Type
varcar(20)
varchar(20)
date
int
money
money
money
money
nvarchar(20)
bit
varchar(20)
nvarchar(128)
Length
20
20
3
Allow Nulls
q
q
q
Debit Value Dercription
PIUM tour
FILlhugc tow miu Mo
Ns* khdi birth
4 q 56 Wdr t6 da
8 0 (ND GA bin ngiS k1n >=13 tub
8 g (COD Gf tre ere to 9 68112 tub
8 2 VD GA ern but ter 3 Mil 8 to&
8 g son GS tM ad sink di 0 gn 2 tub
20 Q (Ntipen.) TIM Pang tow (Open.ActiveCanadacied
1 Gem gii hay ko? 118 giim giL 0 le ►hdog giim 96
20 q FIC_Nged tao tow
128 2
TourDetail
Column Name Data Type Length Mow Nub Default Value Description
TourDetaND vardwd2— 20 q
PIC_Ma chi tilt tour
TourlD varchar(2— 20 q
FIc_ThuOc tour neio
LocationlD varchar(2— 20 q
Flt_Tai 61dm du lich nao
Shippinglnfo rwarchad— 20
Di bang phddng hen gi
ShippingFee money 8
Chi phi di lei
0
Xiy dung chic ning
70/97 I HI thong bin tour du Itch trwc tuyin
Xiy dying chic ning
To u rHotelDetail
Column Name Data Type Length Mow Nub
f TourHotelDetailID varchar(2- 20 q
TouriD varcharg- 20 q
LocationID varcharg- 20 q
HotelRoonsTypelD varcharg- 20 q
NumberRooms int 4 q
0
DebuttValue Desaiption
140411 chi tart ichhch sen theo tour
FlUhugc tour nao
FILTai elfin du lich nao
FKLoai phang tai khkdi son nao
S6 Mpg phOng
4.2.2. Models
Tuang irng vol bing TemplateTour, TemplateTourDetail, Tour, TourDeail,
TourHotelDetail duqc sir dung, Entity Framework Ur sink ra 16p TemplateTour,
TemplateTourDetail, Tour, TourDeail, TourHotelDetail ttumg (mg de Wong tfc voi co
s6 dit
public partial class TemplateTour
{
public TemplateTour()
{
this.TemplateTourDetails • new HashSet();
this.Tours • new HashSet();
}
public string TemplateTourID { get; set; }
public string TourName { get; set; }
public string TourlypelD { get; set; }
public Nullable TourDuration get; set;
public string Description { get; set; }
public string Image get; set;
public string Image_i { get; set; }
public string Image_2 { get; set; }
public string Image_3 { get; set; }
public string Image 4 get; set; )
public string CreatorlD { get; set; }
public virtual Account Account { get; set; }
public virtual TourType TourType { get; set; }
public virtual ICollection TemplateTourDetails get; set;
}
public virtual ICollection Tours ( get; set;
}
public partial class TemplateTourDetail
{
public string TemplateTourDetaillD { get; set; }
public string TemplateTourID { get; set; }
public string LocationlD { get; set;
public Nullable Duration { get; set; }
public Nullable Order { get; set;
public virtual Location Location { get; set; }
public virtual TemplateTour TemplateTour get; set; }
}
71/97 I HI thong bin tour du Itch tryc tuyin
fly dying chfirc nAng
public partial class Tour
{
public Tour()
{
this.BookTours new HashSet();
this.TourDetails - new HashSet();
this. TourHotelDetails • new HashSet();
}
public string TourID { get; set;
public string TemplateTourID { get; set;
public System.DateTime DepartureDate { get; set; }
public int NumberSeats { get; set; }
public Nullable AdultPrice { get; set; }
public Nullable ChildPrice { get; set; }
public Nullable BabyPrice { get; set; }
public Nullable InfantPrice { get; set; }
public string Status { get; set; }
public Nullable SaleOff { get; set; }
public string CreatorlD { get; set; }
public string Tag { get; set;
public virtual Account Account { get; set;
public virtual ICollection BookTours { get; set; }
public virtual TemplateTour TemplateTour { get; set;
public virtual ICollection TourDetails { get; set; }
public virtual ICollection TourHotelDetails { get; set; }
}
public partial class TourDetail
public string TourDetaillD { get; set; }
public string TourID { get; set;
public string LocationlD { get; set;
public string Shippinglnfo { get; set; }
public Nullable ShippingFee { get; set;
public virtual Location Location { get; set;
public virtual Tour Tour { get; set;
}
public partial class TourHotelDetail
{
public string TourHotelDetaillD { get; set;
public string TourID { get; set; }
public string LocationID { get; set;
public string HotelRoomTypeID { get; set;
public int NumberRooms { get; set;
public virtual HotelRoomType HotelRoomType { get; set;
public virtual Location Location { get; set;
public virtual Tour Tour { get; set;
}
72/97111I thong bin tour du Itch fly tuyin
fly dung chit Wing
413. Controller
Tucmg Ping vai tic chtic nAng to ed cac ctic phucmg thirc nhu sau:
ListTemplateTour() TourController Admin int page •1, int
idMessage • a, string
Message - "", string
link • ""
AddTemplateTour() TourController Admin int idMessage • 0,
string Message - ""
[HttpPost]
AddTemplateTour()
TourController Admin TemplateTour t
EditTemplateTour() TourController Admin string id, int
idMessage • 0, string
Message - ""
[HttpPost]
EditTemplateTour()
TourController Admin string id,
TemplateTour temp
DeleteTemplateTour() TourController Admin string id
[HttpPost]
DeleteTemplateTourSelected()
TourController Admin FormCollection cl
ListTemplateTourDetail() TourController Admin string id, int page •
1, int idMessage • 9,
string Message - "",
string link • ""
AddTemplateTourDetail () TourController Admin string id, int
idMessage • 9, string
Message • ""
[HttpPost]
AddTemplateTourDetail ()
TourController Admin TemplateTourDetail t
EditTemplateTourDetail () TourController Admin string id, int
idMessage • 0, string
Message - ""
[HttpPost]
EditTemplateTourDetail ()
TourController Admin string id,
FormCollection cl
DeleteTemplateTourDetail () TourController Admin string id
[HttpPost]
DeleteTemplateTourDetailSelected()
TourController Admin FormCollection cl
_ListTour() TourController Adjnin int page • 1, int
idMessage = 9, string
73/97 I Ile thong bin tour du Ijch trim tuyin
Trang thy hien thj dash sich Tour/ ListTour
tour
_ListTour.cshtml
_AddTour.cshtml Trang illy sir dung de them
mai mOt tour
Tour/ AddTour
_EditTour.cshtml Trang nay duqc si dung di Tour/ EditTour
fly dvng chic sing
Message la "", string
link - a
_AddTour() TourController Admin int idMessage • 0,
string Message = ""
[ittpPost]
_AddTour()
TourController Admin Tour t, FormCollection
cl
_EditTour() TourController Admin string id, int
idMessage n 0, string
Message mg ""
[ittpPost]
_EditTour()
TourController Admin string id, Tour temp,
FormCollection cl
_Deletelour() TourController Admin string id
[HttpPost]
_DeleteTourSelected()
TourController Admin FormCollection cl
_ListTourDetail() TourController Admin string id, int
idMessage n 0, string
Message • "", string
link = ""
_EditTourDetail() TourController Admin FormCollection cl
Detail() TourController — string id
4.24 Views
Chit 'ding gbm nhieu view lchic nhau ces nhing view ding chung cho ca nprei
doc, thinh vier tang nlur quAn tri vien can xem vi c6 nhing view dimg rieng cho
ting cep bac thimh vien shim muc Bich bio mat he thong. Doi yeti cic view dinh
rieng cho quin tri vien tai trang gam tq duqc sir dung chung layout
AdminLayout.cshtml con lei cic view lchich ding layout _ HomeLayout.cshtml.
Dual dAy la Mc view cis chic nAng nay:
74/97 I HI thong bin tour du qch Ulm tuyfil
Xiy dying cher ning
4.2.5. Javascript
Trong the view sir dung de them men cling nhu chink sira c6 tich hyp javascript
de sir dung mOt s8 cong cu h8 trq c8ng viec soon thio, quhn lt hinh anh cling nhu h8
trq viec dien ngay thing nhu: CKEditor, CKFinder...
NOi dung doan lenh sir dung CKEditor:
<script type="text/javascript" language="javascript"›
CKEDITOR.replace('txtNoiDung');
NOi dung down lenh sa dung CKFinder:
$(function () {
$("#btnImage").click(function () {
var ck = new CKFinder();
ck.selectActionFunction = function (fileUrl) {
$("#txtImages").val(fileUr1);
};
ck.popup();
));
});
Cac View hien thi danh sich sir dung javascript cho viec Lich chon cac item trong
danh sich de thyc hien x6a nhieu:
$(document).ready(function () {
$('#toggle-all').click(function (event) { //on click
$('#toggle-all').toggleClass('toggle-checked');
if (this.checked) { // check select status
$('#mainform input[typescheckbox]').each(function () { //loop
through each checkbox
this.checked . true; //select all checkboxes with class
"checkboxl"
});
} else {
$('#mainform input[typeecheckbox]').each(function () { //loop
through each checkbox
this.checked . false; //deselect all checkboxes with class
"checkboxl"
});
}
});
});
75/97 I HI thong bin tour du Itch tryr tuyin
Xiy dying &Cm ning
Doan javascript chi cho phep nhAp s6 vio textbox:
<
function isNumberKey(evt) {
var charCode (evt.which) ? evt.which : event.keyCode
if (charCode > 31 KA (charCode 57))
return false;
return true;
}
//-->
4.3. BO tour
4.11. Or 0 At Iiipm
Booldour
Column Name Data Type Length Mow Nub Default Value Desaiption
♦ BookTourlD varchar(2— 20 q PIL_Mi tat tour
TourlD vardwr(2— 20 q F1C_Det tour nao
CustomerlD vardur(2— 20 q ENJOlich hang Mt tour
DateBook datetime 8 (yeMate()) Ngly sit tour
AdultNumben int 4 56 nokil Idn
ChildNumbers int 4 56 tre em
BabyNumbers int 4 56 em be
IntantNumbers int 4 56 tie sd sinh
Payment bit 1 1: di thanh thine chtia thanh twin
PaymentMet— nvardwv(— 128 PhUdng thOs thanh ken
Memo nvardser(— 255 Ghi dui
76/971 HI thong bin tour du lich Int thy&
fly dyng chttc ning
Customer
ColtannName Data Type Length Almwhaulls Default Value Description
I CustomerlD authart_ 20 q PlciallihAdhhi-
ContactName marcher— 128 66 TinlitnhO
BirthDate date 3 Ea Nigaysah
Address nvaNhar— 255 66 Dachl
IdkntilyNo 30 60 S6 did ng milt t-
PhoneNo marcher— 30 66 56 &On Mali
Email marcher— 128 Ea Dja di email
Usemame nawdhar— 30 66 Ten Mpg nhip
Password asmhaN• 50 66 fat Ichgu
CePhone marcher— 30 66 Di dOng
0
43.2. Model
Tucmg (mg yeti bin BookTour, Customer duqc sir dung, Entity Framework hr
sinh m lop BookTour, Customer won tin de Wong tic vai cc/ sb dift
public partial class BookTour
{
public BookTour()
{
this. BookTourDetails • new HashSet();
}
public string BookTourlD get; set; }
public string TourID { get; set;
public string CustomerID { get; set;
public Nullable DateBook { get; set; }
public Nullable AdultNumbers { get; set;
public Nullable ChildNumbers { get; set;
public Nullable BabyNumbers ( get; set; }
public Nullable InfantNumbers { get; set; }
public Nullable Payment { get; set;
public string PaymentMethod { get; set;
public string Memo get; set;
public virtual Customer Customer { get; set; }
public virtual Tour Tour { get; set;
public virtual ICollection BookTourDetails { get; set;
}
public partial class Customer
{
public Customer()
{
this.BookRooms • new HashSet();
this.BookTours • new HashSet();
77/97 I HO th6ng bin tour du Lich trut tuyin
fly dvng chirc ning
}
public string CustomerlD { get; set;
public string ContactName { get; set;
public Nullable BirthDate { get; set; }
public string Address { get; set;
public string IdentityNo get; set;
public string PhoneNo get; set; }
public string Email get; set; }
public string Username get; set; }
public string Password { get; set; }
public string CellPhone { get; set; }
public virtual ICollection BookRooms { get; set;
public virtual ICollection BookTours { get; set;
}
4.3.3. Controller
Tuong (mg v6i cac chterc !ding to c6 tic cac phucrng thirc nhu sau:
BookingTN() BookingController —_ string id
[HttpPost]
ReviewBookTour()
BookingController -- BookingModel bt,
FormCollection fcl
CommitBooking() BookingController --- BookingModel bt
4.3.4. View
Cac view trong chirc nAng nay duqc su dung cho Ichich hang dtit tour truc tuyEn
Duoi day 11 cu the cac view dui chUc fling thy:
BookingTN.cshtml View nay hien thj thong tin
ye tour va lay thong tin dat
tour do khich hang Slap
vio
Booking/ BookingTN
ReviewBookTour.cshtml View nay hien thj thong tin
Qat tour a khich hang c6
the him tra lai truo'c khi
d$t tour
Booking/
ReviewBookTour
CommitBooking.cshtml View nay hien thj thong tin
sau khi Ichich hang dl Vic
nhan diit tour
Booking/CommitBooking
78/97 1 Ht thong bin tour du Itch tryc tuyin
fly dying chit ning
4.4. Quin It don Alt tour
4.4.1. Cot sdi dft Ulu
Book I our
Column Name Data Type Length Allow Nub Default Value Description
V BookTourlD varchar(2- 20 PK_Ma tilt tour
TotirlD vardlar(2- 20 FILES tour nio
CustomerlD vardur(2- 20 FILIthich king dot tour
DateBook datetime 8 (getdate0) Ngiy at tour
AdultNumbers WA 4 56 ngtrii ICn
ChildNumbers Wft 4 56 trl em
BabyNumbers WA 4 Sif em be
InfantNumbers int 4 56 tri sd sinh
Payment bit 1 a 1: di thanh to4n, 0: club that than
Psymenthlet- mardialt- 128 a Phildng thik thanh twin
Memo marchar(- 255 Ghi ch0
q
4.4.2. Model
Tucmg fing vsfri bing BookTour duqc sir dung, Entity Framework to sinh ra lap
BookTour Mang (mg de ft:mg tic veri cu sti dtt
public partial class BookTour
{
public BookTour()
{
this.BookTourDetails - new HashSet();
}
public string BookTourlD { get; set;
public string TourID { get; set;
public string CustomerlD { get; set; }
public Nullable DateBook get; set; }
public Nullable AdultNumbers get; set;
public Nullable ChildNumbers get; set;
public Nullable BabyNumbers f get; set;
public Nullable InfantNumbers f get; set;
public Nullable Payment get; set; }
public string PaymentMethod { get; set;
public string Memo get; set;
public virtual Customer Customer { get; set;
public virtual Tour Tour get; set;
public virtual ICollection BookTourDetails { get; set;
}
79/97 I He thong bin tour du Lich trvc tuyin
fly ding chit thing
443. Controller
Tucmg img yen cite chirc nang to co cic clic phuang thirc nhu sau:
ListBookTour() BookingController Admin int page n 1, int
idMessage = 0,
string Message n
"", string link
..
EditBookingTour() BookingController Admin string id, int
idMessage = 0,
string Message n ""
[HttpPost]
EditBookingTour()
BookingController Admin string id,
BookingModel temp,
FormCollection cl
DeleteBookTour BookingController Admin string id
DeleteBookTourSelected BookingController Admin FormCollection cl
444 View
Cac view trong cluic riling My &gm sil dung cho quail trj vien quip lt thong tin
at tour
Du& day la cu the cac view ciui chirc Wing My:
ListBookTour.cshtml View My hien thj danh Booking/ListBookTour
such don dat tour
EditBoolcingTour.cshtml View My cho phep wan
tri vien sirs thong tin dirt
tour ctia khich hang
Boolcing/EditBookingTour
80/97 I HI thing bin tour du Lich trim tuyEn
Country
Column Name
T CountrylD
CountryName
Description
Image
[Image 1]
[Image 2]
[image 3]
[image 4]
Tag
Data Type
varchar(20)
nvarthar(128)
rtext
nvarchar(1 28)
nvarchar(128)
nvarchar(128)
nvarchar(128)
nvarthar(128)
nvarchar(128)
Length Mow Nulls Default Value Description
20 PC Ma qudc gia
128 Tin qudc gia
16 a Dign gal
128 a Anh damn
128 Ana
128 a Anh 2
128 a Anh 3
128 a As 4
128 a
ProyinceCity
fly chntg chttc ning
4.5. Danh mac dia dam du Lich
4.11. Cu se de lieu
Column Name Data Type Length Allow Nit Default Value Description
♦ ProvinceCitylD varchart.. 20 0 coftMA tinh thanh
ProvinceCityName nvarchar- 128 0 Tin Si thin*
CourdrylD varcharc.. 20 0 FK_Thuoc qudc gia So
Description nteid 16 a giii
Image nvarchar._ 128 Anh dai difn
[Image 1] rwarchar._ 128 Ana
[image 2] nvardsar.- 128 a Anh 2
[Image 3] nvarthar- 128 a Ana 3
[Image 4] nvarchar... 128 a Anh 4
IsStartPlace bit a ((0)) li not kWh hinh?
Tag marcher... 128 a
0
81/97 111I thing bin tour du Lich tryc tuyin
Location
Column Name
LociliwW)
LocationName
emainorOkOD
Address
Description
Image
Nmmge 1]
Drage 2]
(image 3]
(Image 4]
Tag
Data Type
varchar(20)
nvarchar(128)
varchar(20)
nvarchar(128)
nte:d
nvarthar(128)
nvarcar(128)
nvarchar(128)
nvarchar(128)
nvarchar(128)
nvardwar(128)
Length Mow tents Defauk Value Description
20 q NUM 6&n du fide
128 q Ten &&n du lid
20 q R(Thugc Nehltlinh IONS mao
128 Dek di
16 2 Dian clik
128 Anh C8i thin
128 Annt
128 Anh 2
128 Anh 3
128 Anh 4
128
0
My dung chit ning
452 Model
Than *nig vii Wing Country, ProvinceCity, Location &lux sCr dung, Entity
Framework to sinh ra lip Country, ProvinceCity, Location tuong img de tuong tdc vii
ccrsdrftliO:
public partial class Country
{
public Country()
{
this.ProvinceCities • new HashSet();
}
public string CountrylD { get; set;
public string CountryName { get; set;
public string Description ( get; set; )
public string Image { get; set;
public string Image_i { get; set;
public string Image_2 { get; set;
public string Image_3 { get; set; }
public string Image_4 { get; set;
public string Tag { get; set;
public virtual ICollection ProvinceCities { get; set;
}
public partial class ProvinceCity
{
public ProvinceCity()
{
this.Hotels • new HashSet();
this.Locations new HashSet();
}
public string ProvinceCitylD { get; set; }
public string ProvinceCityName { get; set;
public string CountrylD { get; set; }
public string Description { get; set; }
public string Image ( get; set; )
82/971114 thong bin tour du Itch tryc tuyin
fly dying chic thing
public string Image_l. { get; set; }
. public string Image_2 { get; set; }
public string Image_3 { get; set; }
public string Image_4 { get; set; }
public string Tag { get; set; }
public Nullable IsStartPlace { get; set;
public virtual Country Country { get; set; }
public virtual ICollection Hotels { get; set; }
public virtual ICollection Locations { get; set;
}
public partial class Location
{
public Location()
{
this.TemplateTourDetails a new HashSet();
this.TourDetails = new HashSet();
this.TourHotelDetails a new HashSet();
}
public string LocationlD { get; set;
public string LocationName { get; set;
public string ProvinceCitylD { get; set; }
public string Address { get; set; }
public string Description { get; set;
public string Image { get; set; }
public string Image_l { get; set;
public string Image_2 { get; set; }
public string Image_3 { get; set;
public string Image_4 { get; set;
public string Tag { get; set;
public virtual ProvinceCity ProvinceCity { get; set;
public virtual ICollection TemplateTourDetails { get; set;
}
public virtual ICollection TourDetails get; set;
public virtual ICollection TourHotelDetails { get; set; }
45.3. Controller
Tucmg ung v6i chtic nAng to c6 phucvng thirc thus sau:
ListLocation () RegionController Admin int idMessage a 9,
string Message =
"", string link a
..
AddLocation() RegionController Admin int idMessage a 0,
string Message a ""
[HttpPost]
AddLocation()
RegionController Admin FormCollection cl,
Location t
EditLocation() RegionController Admin string id, int
idMessage a e,
string Message a
83/971 lif thong bin tour du lich tryt tuyin
My dyng chit tiling
RegionController
[HttpPost]
EditLocation()
RegionController Admin string id,
FormCollection cl
DeleteLocation RegionController Admin string id
[HttpPost]
DeleteLocationSelected()
RegionController Admin FonnCollection cl
Cac action yeti bang Country vi ProvinceCity Wang to nhu bin Locaiton.
4.5.4. View
Ck view trong chirc 'tang nay duqc su dung cho quitn tri vien quart lfr thong tin
S diem du ljch
Dudi day la cu the cac view ctia chirc tiling nay:
BookingTN.cshtml View nay hien thj th8ng tin
ve tour vi lay thong tin dat
tour do kite& hang nh$p
vio
Booking/ BookingTN
ReviewBookTour.cshtml View nay hien thi th8ng tin
dat tour de kith hang co
the kiem tra lai trtroc khi
dat tour
Booking/
ReviewBookTour
CommitBooking.cshtml View nay hien thj th8ng tin
sau !chi khich hang dii xic
nh$n at tour
Booking/CommitBooking
84/971111 thong bin tour du Ijch bye tuyan
News
Column Name Data Type Length Mow Nulls Default Value Description
11 NewsID varchar(2— 20 q PK_Mi tin Vat
NewsType nvarchad— 128 q Loai tin
Title maraud— 128 q Ti4u di tin
Image nvarchar(— 128 2 Anh dai then
[Content] ntext 16 q NOi dung At tit
Detail ntext 16 q NOl dung chi tit
DatePosted datetime 8 2 (getdate0) Ngiy ding tin
CreatorlD varchar(2— 20 q Ngtfdl ding tin
Tag • nvarchad— 128 2
0
lay dpug chit ning
4.6. Quin Ifr tin tit
Cosidltlifu
4.6.2. Model
Ttrcmg (mg veri bang News dkrcic s* dung, Entity Framework to sinh ra lop News
ttrcmg (mg de tuang tic veri CO So (111 lieu:
public partial class News
{
public string NewsID get; set; }
public string NewsType { get; set;
public string Title { get; set;
public string Content { get; set; )
public string Detail { get; set;
public Nullable DatePosted { get; set;
public string CreatorlD { get; set;
public string Tag { get; set; }
public string Image { get; set;
public virtual Account Account get; set;
}
85/97 I HI th8ng bin tour du lich trite twin
Xfiy dung chit sing
4.6.3. Controller
Tucmg ung v6i cac ch
Các file đính kèm theo tài liệu này:
- khoa_luan_xay_dung_website_du_lich_truc_tuyen_su_dung_asp_ne.pdf