More Related Content More from Altangerel Bilguun (7) Үзвэрийн онлайн билет захиалгын систем 1. э х ы SW06D020, .Дэ э ө ө
1
ш
. ,
.
.
ё О-goЯОrnЦОnt, , О-business,
e-commerse, e-book, e-library ,
.
.
.
. ,
.
.
. 3
.
. ,
.
. Э
.
.
. 4
, ,
.
2. э х ы SW06D020, .Дэ э ө ө
2
I. ы хэ э
1.1 Э
Э
. .
.
,
. ,
, .
.
1970- ү0-
.
.
Э :
<–> (B2B)
<–> (B2C)
<–> (C2C) .
3 :
-
( )
- :
.
.
- :
, .
.
. ,
( , , ), (Ү/24,
), (
) .
3. э х ы SW06D020, .Дэ э ө ө
3
1.1.1
Э “
”, “ ”, “
”, “ ,
” ,
. ( ,
),
, ,
( ) .
,
.
1.2 ,
. .
. :
- ,
.
- .
-
.
- ,
.
.
- ,
, .
1.3
Э
,
.
. ,
,
.
4. э х ы SW06D020, .Дэ э ө ө
4
.
-
- ,
-
- - , ,
. Э , ё
.
1.3.1 SSL ?
. , .
,
. Э ,
,
SSL
SОМurО SoМФОt LКвОr . SSL
ОnМrвpt
,
.
,
. SSL
Я3
3- ,
. .
SSL ,
ё . ,
sОХf sТgnОН
. , tСКаtО
(ӨA ӨОrtТfТМКtО AutСorТtв) ,
ӨA . SОХf sТgnОН
.
. ӨA-
.
5. э х ы SW06D020, .Дэ э ө ө
5
1.3.2 ,
. Э 2 .
• : ,
. Э
.
• ё :
. :
-
-
- Paypal –
- 2 checkout
- BКnУТg.
2
.
•
•
1.4
1.4.1 Hibernate
Hibernate Java - (object-relational
mapping) (domain model)
framework- .
Hibernate
.
Hibernate GNU Lesser General Public License –
.
Hibernate- Java –
( Java- SQL ) (mapping)
. Hibernate query
. Hibernate SQL
,
SQL
.
Mapping/ /
6. э х ы SW06D020, .Дэ э ө ө
6
Java class – mapping XML
Java Annotation . XML file Hibernate
persistence(
) class- .
nnotation( )
. Hibernate XML file
annotation- .
- -
. Hibernate -
Hibernate mapping . Э
.
mapping SQL default-
Java- Enum(т )
mapping
Persistence
Hibernate Java persistence .
Persistence
public . equals() hashCode()
.
(List Set ) Java- collection object- .
Java 5 Java generics . Hibernate lazy
load – .
7. э х ы SW06D020, .Дэ э ө ө
7
II. ы хэ э
2.1
2.1.1
,
, , , ,
.
- 2001
,
, , ,
,
.
, ,
, ,
, 2003
1- , ,
, 2004 10-
, ,
.
“ ,
, ё ”
2003 4- 24- - ё
, ,
.
“ ”
, 2002
.
2.1.2 -
Э ,
-
.
:
Э
Э
Э
Э
8. э х ы SW06D020, .Дэ э ө ө
8
Э
Э
Э ,
, ,
,
, ,
, , ,
- . -
.
-
,
.
-
.
2.1.3 Э (E-commerce)
З
Э , ,
, ,
,
,
.
З
2012 , Ү0
2012
(Business-to-ЛusТnОss) 10
, (ЛusТnОss-to-МonsuЦОr)
20
Э , ,
,
1) Э
Э ,
, , ,
,
9. э х ы SW06D020, .Дэ э ө ө
9
, (ӨrОНТt
History)
2) ,
, , ,
Э
3)
,
(Мross-border)
2.1.4 :
, ,
, ,
, ,
,
. (B2B),
(B2Ө) , ,
.
2.1.5 Э :
,
, , ,
.
2.2 Э
. ,
.
.
. www.tedy.mn, www.rainbow.mn, enomin.net
, , ,
,
.
10. э х ы SW06D020, .Дэ э ө ө
10
2.2.1
.
. Э
. , ,
.
http://eticket.mtz.mn/ , eticket.mn
.
11. э х ы SW06D020, .Дэ э ө ө
11
III. ө хэ э
Нэ ү ээр үлэ
3.1
3.1.1
19үҮ -
, 19үү-19ү9 -
2 .
199ү “ ” -
200Ү 4.5
2009 04-
1Ү- .
- АКrnОr Bros. IntОrnКtТonКХ
ӨТnОЦК ANө
100
.
,
KINOTON, JBL, HARKNESS
.
1 2- 1ү0 , 3-
26Ү , 36 VIP , 4- 13ү , 20 VIP
.
VIP ,
.
,
.
KТnoton 35 - , - JBL
5.1
HКrФnОss
12. э х ы SW06D020, .Дэ э ө ө
12
. Э
.
PКnКsonТМ
.
Sonв pТМturОs, АКrnОr Bros, 20tС ӨОnturв Foб, өТsnОв pТМturОs HoХХваooН-
,
, , PОpsТ
.
3.1.2
Э , ,
, , ,
:
( ) .
.
.
: . .
: , ,
. Ш ,
.
.
3.1.3
.
. Э .
.
13. э х ы SW06D020, .Дэ э ө ө
13
3.1.4
1.
, .
.
.
рсрõ
( )
2.
, .
.
,
.
3.
, .
.
( , , )
, ,
( , ... )
,
14. э х ы SW06D020, .Дэ э ө ө
14
3.1.5
15. э х ы SW06D020, .Дэ э ө ө
15
Хоёр у р үлэ
3.2.1
. *NIБ
. ,
, *NIБ
.
.
3.2.2
My-SqХ .
storОН proМОНurО . JSP-
.
3.2.3
JКЯК JSP .
. ,
ё .
. toЦМКt,
УЛoss . ӨSS, AJAБ, JКЯКSМrТpt, СТЛОrnКtО, Struts, SprТng
JSF, jQuery .
16. э х ы SW06D020, .Дэ э ө ө
16
ур у р үлэ
3.1 Use Case
17. э х ы SW06D020, .Дэ э ө ө
17
3.2 К
18. э х ы SW06D020, .Дэ э ө ө
18
19. э х ы SW06D020, .Дэ э ө ө
19
20. э х ы SW06D020, .Дэ э ө ө
20
3.3
3.4
21. э х ы SW06D020, .Дэ э ө ө
21
-
*
*
Э
*
*
*
*
*
*
*
-
*
*
*
*
Э
3.5
22. э х ы SW06D020, .Дэ э ө ө
22
1.
Alpha 4
Alpha 40
Alpha 100
2.
Alpha 4
æчëòъû Alpha 40
æчëòъû ъýð Alpha 40
x Byte
- Alpha 40
x Alpha 14
Alpha 14
x Alpha 100
x Alpha 20
Alpha 40
Date
3.
Alpha 10
Alpha 40
Alpha 40
x Byte
Alpha 40
Alpha 40
- Alpha 40
x Alpha 14
Alpha 14
x Alpha 100
x Alpha 20
Alpha 40
Date
4. З
Alpha 10
Date
Alpha 18
Alpha 100
5. З
x Alpha 11
x Alpha 10
x Alpha 14
Alpha 6
6.
23. э х ы SW06D020, .Дэ э ө ө
23
x Alpha 10
Alpha 30
Э Date
Integer 3
Alpha 100
Integer 4
Ү.
Alpha 4
Alpha 40
Alpha 100
Alpha 100
ү.
Alpha 4
Alpha 40
Alpha 4
Alpha 100
Integer 3
9.
x Alpha 12
x Alpha 10
x Alpha 4
x Alpha 4
10.
x Alpha 14
Alpha 12
Э Integer 4
11.
x Alpha 4
Alpha 40
Alpha 100
12.
x Alpha 10
Alpha 40
Alpha 10
Alpha 4
æчëòъû шьт Alpha 4
Alpha 100
13.
x Alpha 10
Alpha 40
Integer 5
Alpha 100
14.
24. э х ы SW06D020, .Дэ э ө ө
24
x Alpha 8
Alpha 10
Alpha 4
3.6
3.6.1
25. э х ы SW06D020, .Дэ э ө ө
25
,
,
( , Paypal...)
3.6.2
26. э х ы SW06D020, .Дэ э ө ө
26
27. э х ы SW06D020, .Дэ э ө ө
27
3.7
3.7.1
Web browser
1: ,
2:
3:
4:
5:
6:
7:
8:
9:
28. э х ы SW06D020, .Дэ э ө ө
28
3.7.2
Web browser
29. э х ы SW06D020, .Дэ э ө ө
29
өрө ү ээр үлэ
4.1
30. э х ы SW06D020, .Дэ э ө ө
30
31. э х ы SW06D020, .Дэ э ө ө
31
32. э х ы SW06D020, .Дэ э ө ө
32
33. э х ы SW06D020, .Дэ э ө ө
33
Т у р үлэ
К
1. View
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-
8"%>
<%@include file="../../../include.jsp" %>
<%@ taglib uri="http://java.fckeditor.net" prefix="FCK" %>
<head>
<link type="text/css"
href="<%=cPath%>/template/scripts/jquery/ui/themes/start/ui.theme.css" rel="stylesheet" />
<script type="text/javascript">
var count = -1; var imageArray=new Array();
var maxDate=10; tblId = 'seats';
$(function() {
$("#dialog").dialog({
bgiframe: true,
autoOpen: false,
height: 300,
width: 500,
modal: true,
buttons: {
Ok: function() {
alert("ok");
$("#screen").remove();
$("#myTable").remove();
$(this).dialog('close');
},
Cancel: function() {
$("#screen").remove();
$("#myTable").remove();
$(this).dialog('close');
}
}
34. э х ы SW06D020, .Дэ э ө ө
34
});
$('#choose-seat').click(function() {
if ($("#date").val() == "") {
alert(' ');
} else {
$.getJSON("getSeatsByDateAndTimeTableId.htm",{date: $("#date").val(), id:
${timetable.id}},
function(j){
var myTable = '' ;
myTable += '<table align="center" id="myTable" cellspacing=0 cellpadding=2
border=1>' ;
var row = j[0].id; var col = j[0].type;
var n = 0;
for (var i = 1;i <= row; i++) {
myTable += '<tr>';
for (var l = 1;l <= col; l++) {
myTable += '<td>';
myTable += j[++n].id+','+ j[n].type;
myTable += '</td>';
}
myTable += '</tr>';
}
myTable += '</table>' ;
$("#dialog").append(myTable);
$("#dialog").append("<table class='ui-widget-content' id='screen'> n
<thead> <tr class='ui-widget-header'> <th> <p align='center'> </p>n
</th></tr> </thead> </table>");
$("#myTable > tbody > tr > td").each(
function(){
var name = $(this).html();
$(this).html('');
type = name.split(',')[1];
name = name.split(',')[0];
var img = new Image();
count = -1;
35. э х ы SW06D020, .Дэ э ө ө
35
do {
count = (count + 1);
}
while (imageArray[count].name != type);
attr = document.createAttribute("src");
attr.nodeValue=imageArray[count].src;
img.setAttributeNode(attr);
img.id = imageArray[count].name;
// wrap our new image in jQuery, then:
$(img) .attr({
src: imageArray[count].src,
id: imageArray[count].name,
name: name
})
.click(function(){
var imgId = $(this).attr("id");
var imgName = $(this).attr("name");
var t = '';
if ((imgId != 'ss01')&&(imgId != 'ss00')&&(imgId != 'ss02')) {
$.getJSON("chooseSeat.htm",{date: $("#date").val(), id:
${timetable.id}, seatId: imgName, type: '+'},
function(j){
if (j[0].err == 'false') {
debug('ss02');
} else {
alert(j[0].msg);
debug('ss00');
} });
} else {
if (imgId == 'ss02') {
$.getJSON("chooseSeat.htm",{date: $("#date").val(), id:
${timetable.id}, seatId: imgName, type: '-'},
function(j){
if (j[0].err == 'false') {
debug(imgName.substr(8,4));
} else {
debug(t = imgName.substr(8,4));
36. э х ы SW06D020, .Дэ э ө ө
36
alert(j[0].msg);
}
});
// Songoltoos hasaj bna. ene 2t JSON -r ajax yavuulna date,seat
}
}
function debug(idd) {
t=idd; count = -1;
length = imageArray.length;
//alert($(img).attr("name"));
do {
count = (count + 1);
}
while (imageArray[count].name != t);
$(img).attr({
"src": imageArray[count].src,
"id": imageArray[count].name
});
}
});
$(this).append(img);
})
});
$('#dialog').dialog('open');
}
})
$("#tabs").tabs();
$("#date").datepicker(
{
showOn: 'button',
buttonImage: '<%=cPath%>/template/images/calendar.gif',
minDate: 0, maxDate: maxDate,
dateFormat: 'yy-mm-dd',
buttonImageOnly: true
});
});
</script>
37. э х ы SW06D020, .Дэ э ө ө
37
</head>
<body id="bd">
<table width="100%" style="vertical-align:text-top;" border="0">
<tr>
<td style="vertical-align:text-top;">
<p> <strong> ${timetable.servicechamber.service.name} </strong> </p>
${timetable.servicechamber.service.addInfo}
</td>
<td style="vertical-align:text-top;text-align:left;" width="400px">
<p>
${timetable.servicechamber.department.name}
${timetable.servicechamber.chamber.name}
</p>
Э
${fn:substring(timetable.beginTime,0,2)}:${fn:substring(timetable.beginTime,2,5)}
<p>
: <input name="date" id="date" readonly="true"
value="${date}"/>
</p>
<button id="choose-seat" class="ui-button ui-state-default ui-corner-all">
</button>
</td>
</tr>
</table>
<div id="dialog" title=" ">
<table class="ui-widget-content" id="seatType">
<thead>
<tr class="ui-widget-header">
<th colspan="2"> </th>
</tr>
</thead>
<tbody>
<c:forEach items="${seatTypes}" var="st">
<c:url var="url" value="${cPath}/seatType/getPicture.htm" >
<c:param name="id" value="${st.id}" />
</c:url>
<tr>
38. э х ы SW06D020, .Дэ э ө ө
38
<td>
<img src="${url}" alt="Picture" name="${st.id}" />
<script type="text/javascript">
count = parseInt("${st.id}".substr(2))
imageArray[count]=new Image();
imageArray[count]=document["${st.id}"];
attr = document.createAttribute("onclick");
attr.nodeValue='changed(this)';
imageArray[count].setAttributeNode(attr);
</script>
</td>
<td>
${st.name}
</td>
</tr>
</c:forEach>
</tbody>
</table>
<table align="center" id="seats">
</table>
</div>
<br/>
</body>
2. Controller
package web;
import dao.OrderDao;
import dao.OrderStatusDao;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model.Seat;
import model.TimeTable;
import org.springframework.beans.factory.annotation.Autowired;
@Controller
public class OrderHandler {
39. э х ы SW06D020, .Дэ э ө ө
39
OrderDao oDao;
@Autowired
public void setOrderedTicketDao(OrderedTicketDao dao) {
otDao = dao;
}
@RequestMapping("/order/timetable.htm")
public String orderByTimeTable(ModelMap model, @RequestParam(value = "id", required
= false) String id, HttpServletRequest request) {
if (id != null) {
try {
createOrder(request);
Calendar calendar = Calendar.getInstance();
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
String dat = dateFormat.format(calendar.getTime());
model.put("date", dat);
model.put("seatTypes", stDao.getSeatTypes());
TimeTable tt = ttDao.getTimeTable(Long.parseLong(id));
model.put("timetable", tt);
return "order/timeTable";
} catch (NumberFormatException e) {
e.printStackTrace();
return "redirect:/index.htm";
}
} else {
return "redirect:/index.htm";
}
}
@RequestMapping("/order/getSeatsByDateAndTimeTableId.htm")
public void getSeatsByDateAndTimeTableId(HttpServletRequest request,
HttpServletResponse res) throws java.text.ParseException {
String ttId = request.getParameter("id");
String dateString = request.getParameter("date");
//System.err.println(ttId + " " + dateString);
res.setContentType("text/html; charset=UTF-8");
try {
40. э х ы SW06D020, .Дэ э ө ө
40
if ((ttId != null) && (dateString != null)) {
TimeTable tt = ttDao.getTimeTable(Long.parseLong(ttId));
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = formatter.parse(dateString);
List<OrderedTicket> ots = otDao.getOrderedTickets(tt, date);
List<Seat> seats = sDao.getSeats(tt.getServicechamber().getChamber());
int row1 = Integer.parseInt(seats.get(0).getId().substring(4, 6));
int col1 = Integer.parseInt(seats.get(0).getId().substring(6, 8));
String seatString = "[{id:'" + row1 + "', type: '" + col1 + "'}";
for (Seat s : seats) {
for (OrderedTicket ot : ots) {
if (ot.getSeat().getId().compareTo(s.getId()) == 0) {
s.setSeattype(stDao.getSeatType("ss00"));
}
}
seatString += ", {id: '" + s.getId() + "', type: '" + s.getSeattype().getId() + "'}";
}
seatString += "]";
res.getWriter().write(seatString);
res.getWriter().flush();
res.getWriter().close();
}
} catch (Exception e) {
e.printStackTrace();
}
}
@RequestMapping("/order/chooseSeat.htm")
public void chooseSeat(HttpServletRequest request, HttpServletResponse res) {
String ttId = request.getParameter("id");
String dateString = request.getParameter("date");
String seatId = request.getParameter("seatId");
String type = request.getParameter("type");
System.err.println(ttId + " " + dateString + " " + seatId + " " + type);
res.setContentType("text/html; charset=UTF-8");
try {
TimeTable tt = ttDao.getTimeTable(Long.parseLong(ttId));
41. э х ы SW06D020, .Дэ э ө ө
41
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd");
Date date = formatter.parse(dateString);
createOrder(request);
Order o = (Order) request.getSession().getAttribute("order");
if (type.compareTo("+") == 0) {
if (isNotOrderedSeat(tt, date, seatId)) {
o.addOrderedticket(new OrderedTicket(tt, sDao.getSeat(seatId), o, date));
o.setOrderstatus(oStatusDao.getOrderStatus("ss01"));
oDao.update(o);
rбs.гбрWriрбr().уriрб("[{йsг:'А э ээ',бrr:'faиsб'}]");
} else {
rбs.гбрWriрбr().уriрб("[{йsг:'У ч э э х
',бrr:'рrсб'}]");
}
} else {
for (Object obj :o.getOrderedtickets()) {
OrderedTicket ot = (OrderedTicket) obj;
if (ot.getSeat().getId().compareTo(seatId) == 0) {
System.out.println(o.getOrderedtickets().remove(obj));
otDao.deleteById(ot.getId());
}
}
rбs.гбрWriрбr().уriрб("[{йsг:'Х х',бrr:'faиsб'}]");
oDao.update(o);
}
res.getWriter().flush();
res.getWriter().close();
} catch (Exception e) {
e.printStackTrace();
}
}
@RequestMapping("/basket.htm")
public String basket(){
return "order/basket";
}
boolean isNotOrderedSeat(TimeTable tt, Date date, String seatId) {
List<OrderedTicket> ot = otDao.getOrderedTickets(tt, date);
42. э х ы SW06D020, .Дэ э ө ө
42
for (OrderedTicket o : ot) {
if (o.getSeat().getId().compareTo(seatId) == 0) {
return false;
}
}
return true;
}
public void createOrder(HttpServletRequest req) {
HttpSession ses = req.getSession(true);
if (ses.getAttribute("order") == null) {
String t = oDao.getLastId();
int n = Integer.parseInt(t.substring(8)) + 1;
t = t.substring(0, 8);
if (n < 100) {
if (n < 10) {
t = t + "00" + n; } else {
t = t + "0" + n; }
} else { t = t + n; }
Order o = new Order(t, null, null, oStatusDao.getOrderStatus("ss00"), new Date());
ses.setAttribute("order", o);
oDao.save(o);
}
}
}
3. Model
package model;
// Generated Dec 1, 2009 12:15:04 AM by Hibernate Tools 3.2.1.GA
import java.util.Date;
import java.util.HashSet;
import java.util.Set;
/**
* Order generated by hbm2java
*/
43. э х ы SW06D020, .Дэ э ө ө
43
public class Order implements java.io.Serializable {
private String id;
private Customer customer;
private OrderType ordertype;
private OrderStatus orderstatus;
private Date date;
private String addInfo;
private Set orderedtickets = new HashSet(0);
public Order() {
}
public Order(String id, Customer customer, OrderType ordertype, OrderStatus orderstatus,
Date date) {
this.id = id;
this.customer = customer;
this.ordertype = ordertype;
this.orderstatus = orderstatus;
this.date = date;
}
public Order(String id, Customer customer, OrderType ordertype, OrderStatus orderstatus,
Date date, String addInfo, Set orderedtickets) {
this.id = id;
this.customer = customer;
this.ordertype = ordertype;
this.orderstatus = orderstatus;
this.date = date;
this.addInfo = addInfo;
this.orderedtickets = orderedtickets;
}
public String getId() {
return this.id;
}
public void setId(String id) {
this.id = id;
}
public void setAddInfo(String addInfo) {
this.addInfo = addInfo;
44. э х ы SW06D020, .Дэ э ө ө
44
}
public Set getOrderedtickets() {
return this.orderedtickets;
}
public void setOrderedtickets(Set orderedtickets) {
this.orderedtickets = orderedtickets;
}
public void addOrderedticket(OrderedTicket orderedticket) {
this.orderedtickets.add(orderedticket);
}
public boolean removeOrderedTicket(String seatId) {
for (Object obj:orderedtickets) {
OrderedTicket ot = (OrderedTicket)obj;
if (ot.getSeat().getId().compareTo(seatId)==0) {
System.out.println(orderedtickets.remove(obj));
return true;//orderedtickets.remove(obj);
}
}
return false;
}
}
Д э
“
” . Э
45. э х ы SW06D020, .Дэ э ө ө
45
. Э , .
.
.
. Э
, ,
, ,
Аш ы
1. “Э ” .
2. http://csczaya.blogmn.net/
3. www.google.com
4. www.en.wiki.org
5. www.golomtbank.com
6. Beginning JSP JSF and Tomcat Web Development /Apress, 2007/
7. www.java2s.com
8. .Э “ ” (SW208)
9. http://www.netbeans.org/
10.http://www.dulmandakh.com/
11.E-ticket “System Object-Oriented Analysis & Design with Unified Modeling
Language” by Lai Chi Wa, Chung Wang Leong