LỜI MỞ ĐẦU
!"#$%&'()
*+,-%".&'/
01*23 #45651
7,+8+5!9/:&;<=>
++0?1 @9,
@9#&'"AB@BB5C1
5("&D &6*E:#F<5E:#F5E:#F2!
2G5E:#F2 H,I8&'9
E1*)(",
J58#&'@9: @"&'
91&7AK*@:#AL,-+9M'#)1
#4,J+5NOP#
+++@&6#)M' :
@9+,I*Q5+RE!/ @ABNOP
<A&6*ST:#F2 4U2Q@#)&'
,T<R2.#?:6<=)9VM-W65
&7G*X2:RE *,
R<:6Y
-+Y
1
MỤC LỤC
2
Chương 1: Giới thiệu
I. Ích Lợi Khi Sử Dụng XML
- NOP+8 7AZ#5[ABNOPAZ#\&'#&Z
ZQ@NOP2,
- NOP+8:1Z&'@"C@W]PE
8:E!&'
- NOPAK8^AZ#)ZQ@_2:AL8
- NOP+8AK88(AZ#Z &6
0
- NOPAK8#&ZAZ##AZ#1Z06
II. Mục tiêu
- J*85: C9CE:#F2 4
178C,
- J!!@9E:#F2 4)B&)&7[AB
E:DAL[AB5E:#F5A2==5 5AL
AH,
III. Phạm vi đề tài, yêu cầu
`9&'<A@CS-NOPU
I)RA#I#WAabcb6;AZ#ACd#RNOP,
ef9D
g 6;AZ#
g NW]h#&'ij
g NOP
g NWPJ
g k]lRm#
g J
g W[+
g n8/*A
g Q@QAZ#A2R
g o8'@#
Chương 2: Nội dung
I. Khảo Sát Nghiệp Vụ
3
1. Khảo sát và đánh giá hiện trạng
Op4@#Z:@qp2
pAC63 @"9[AB19#)@
#45+2i #C4&DV4@C*54@*
:<#F54@H
I*Q2 E:#F2 4@#2 [#F!'@ZE:#F
AB)E:#F<@,]:@q[AB6/A.5
p 5pAXA#C2_4#4@52
&' /E:#FAB452 4
"Q@!6/@5 &6*,
l Q@ D
g T:#F<[
g T:#F +62
g T:#F 4@
g T:#F:&7AK@9
f9&6*@9D
g`9@:AL[AB5ALp5CQ#'&7AK
@9[AB,
g`9@:!@ALA)&7[AB5A<0
") @9"1 0,
g`9+@<E<&7E:#F8E:#F
+8E8 ,
f9AZ#D
g ]Z#@:&'!!0 5&'!E:#F,
g N[#F&' "_,
2. Mô hình hoạt động nghiệp vụ của quản lý bán đĩa phim
-6;2 2_49@<+ 2_4R8#C5
+,Q@QA +4 05@<K 4
&2C6 AL*!8Q#'"
,
&7A@:&7!!&2 2:B#BA
45A 4iZ*5'@ !"
*!4@,
4
&7A 2 5r@( QF
2 ,nM' "4,
-J6;AZ#( !A 4@9@:2(
Q@
-o8/sA 4#&'5#&'2 &'5#&'Q@
#&6i,
-T+5<=@!@5@<#C2_4 @"C@5#CAL<
9#t&7A,IE #F2 4%+[#F5+
",I*Q5C@9T:#F2 4p9 @"&'
9@B,
5
II. Phân tích thiết kế hệ thống
1. Mô tả vấn đề
-I)@9@BBE:#F2 4@5+8QD
eOB01D+A/B2 4%&E:#F1
[,
e "_0D
T:#F<1[,
T:#F4,
T:#F:&7AK
eV&'[AB?1M&'D
1[DE:#F<5Q2
><,
-<DT:#F+62 4
2. Đặc tả yêu cầu
gT:#F<D
+8<)A 5[(+Z2!
(:+2.<2/:, <i+D
OG<5J<5VC# : ,
gT:#F4@D
V4@\&'[Q@),W\&'+
M+4@&'2 ,o<*!4@R
54@\&'Q@Q#&'\&'[M++,
J4@2iDOG455CAL5G:545
,
gT:#F+6D
OM !4\&'Q+6,J+2iD
G+65G45#&'5G<5#Q@,
gT:#F:D
6
OM<[AB@9\&'@:,J:
2iDJ:5QqEC,
7
III. Thiết kế cơ sở dữ liệu
1. Mô hình phân cấp chức năng
2. Mô hình luồng dữ liệu mức khung cảnh
3. Mô hình dữ liệu mức đỉnh
8
4. Xác định các thực thể
J8 J0
-< OG<
n
V/X
WC
J: J:
OQq
TC
V4@ OG4
J
nG:
VCAL
W4
u 4
9
n+6 OG+6
OG<
-#Q@
!+6 OG+6
OG4
W#&'
J
10
5. Mô hình dữ liệu mức quan hệ
6. Các bảng dữ liệu
l::D
WJJ J
0
o8hV
j
v2 o+0w
o+`B
h`owkoj
O:
c Jo -hxbj -## `o J:
a -hxbj -## OQq
y TR z -## TC
11
l:<D
WJJ J
0
o8hV
j
v2 o+0w
o+`B
h`owkoj
O:
c O-I -Ihxj -## `o OG<
a nJR -Ihcbb
j
-## J<
y ] -Ihcxb
j
-## V/X
{ W]J-I -Ihccj -## W]J<
l:4@D
WJJ J
0
o8hV
j
v2 o+0w
o+`B
h`owkoj
O:
c O] -Ihxj -## `o OG4
a J]R -Ihaxbj -## J
y nWN -Ihcxbj -## nGWN
{ ]]R -Ihcbbj -## VCAL
x W] z -## W4
| u ]R#hc}5b
j
-## u
l:+6D
WJJ J
0
o8hV
j
v2 o+0w
o+`B
h`owkoj
O:
c Oon -hcbj -## `o OG
a JRon -hcbbj -## Jon
y ~# -hcxbj -## ~#
{ uJ -hcbj -## u)0
x W]J -hccj -## WC
| JJ -habj -## JC
12
l:!+6D
WJJ J
0
o8hV
j
v2 o+0w
o+`B
h`owkoj
O:
c Oon -hcbj -## `o OG
a JRon -hcbbj -## Jon
y ~# -hcxbj -## ~#
{ uJ -hcbj -## u)0
IV. Thiết kế và cài đặt chương trình
1. Các module chính
#JNOPhui@&6"5[5+5*!58
CNOP5PA#]uAR•j
class TaoXML
{
string strCon = " Data Source =.; Initial Catalog = QLDiaPhim; Integrated
Security = True";
public void taoXML(string sql, string bang, string _FileXML)
{
SqlConnection con = new SqlConnection(strCon);
con.Open();
SqlDataAdapter ad = new SqlDataAdapter(sql, con);
DataTable dt = new DataTable(bang);
ad.Fill(dt);
dt.WriteXml(Application.StartupPath + _FileXML,
XmlWriteMode.WriteSchema);
}
public DataTable loadDataGridView(string _FileXML)
{
DataTable dt = new DataTable();
string FilePath = Application.StartupPath + _FileXML;
if (File.Exists(FilePath))
{
//tao luong xu ly file xml
FileStream fsReadXML = new FileStream(FilePath, FileMode.Open);
//doc file xml vao datatable
dt.ReadXml(fsReadXML);
fsReadXML.Close();
}
else
{
MessageBox.Show("File không tồn tại");
}
13
return dt;
}
public void Them(string FileXML, string xml)
{
try
{
XmlTextReader textread = new XmlTextReader(FileXML);
XmlDocument doc = new XmlDocument();
doc.Load(textread);
textread.Close();
XmlNode currNode;
XmlDocumentFragment docFrag = doc.CreateDocumentFragment();
docFrag.InnerXml = xml;
currNode = doc.DocumentElement;
currNode.InsertAfter(docFrag, currNode.LastChild);
doc.Save(FileXML);
}
catch
{
MessageBox.Show("lỗi");
}
}
public void xoa(string _FileXML, string xml)
{
try
{
string fileName = Application.StartupPath + _FileXML;
XmlDocument doc = new XmlDocument();
doc.Load(fileName);
XmlNode nodeCu= doc.SelectSingleNode(xml);
doc.DocumentElement.RemoveChild(nodeCu);
doc.Save(fileName);
}
catch
{
MessageBox.Show("lỗi");
}
}
public void sua(string FileXML, string sql, string xml, string bang)
{
XmlTextReader reader = new XmlTextReader(FileXML);
XmlDocument doc = new XmlDocument();
doc.Load(reader);
reader.Close();
XmlNode oldValue;
XmlElement root = doc.DocumentElement;
oldValue = root.SelectSingleNode(sql);
XmlElement newValue = doc.CreateElement(bang);
newValue.InnerXml = xml;
root.ReplaceChild(newValue, oldValue);
doc.Save(FileXML);
}
public void TimKiem(string _FileXML, string xml, DataGridView dgv)
{
14
XmlDocument xDoc = new XmlDocument();
xDoc.Load(Application.StartupPath + _FileXML);
string xPath = xml;
XmlNode node = xDoc.SelectSingleNode(xPath);
DataSet ds = new DataSet();
DataTable dt = new DataTable();
XmlNodeReader nr = new XmlNodeReader(node);
ds.ReadXml(nr);
dgv.DataSource = ds.Tables[0];
nr.Close();
}
public string LayGiaTri(string duongDan, string truongA, string giaTriA,
string truongB)
{
string giatriB = "";
DataTable dt = new DataTable();
dt = loadDataGridView(duongDan);
int soDongNhanVien = dt.Rows.Count;
for (int i = 0; i < soDongNhanVien; i++)
{
if (dt.Rows[i][truongA].ToString().Trim().Equals(giaTriA))
{
giatriB = dt.Rows[i][truongB].ToString();
return giatriB;
}
}
return giatriB;
}
public bool KiemTra(string _FileXML, string truongKiemTra, string
giaTriKiemTra)
{
DataTable dt = new DataTable();
dt = loadDataGridView(_FileXML);
dt.DefaultView.RowFilter = truongKiemTra + " ='" + giaTriKiemTra + "'";
if (dt.DefaultView.Count > 0)
return true;
return false;
}
public string txtMa(string tienTo, string _FileXML, string tenCot)
{
string txtMa = "";
DataTable dt = new DataTable();
dt =loadDataGridView(_FileXML);
int dem = dt.Rows.Count;
if (dem == 0)
{
txtMa = tienTo + "001";//HD001
}
else
{
int duoi = int.Parse(dt.Rows[dem - 1]
[tenCot].ToString().Substring(2, 3)) + 1;
string cuoi = "00" + duoi;
txtMa = tienTo + "" + cuoi.Substring(cuoi.Length - 3, 3);
15
}
return txtMa;
}
public bool KTMa(string _FileXML, string cotMa, string ma)
{
bool kt = true;
DataTable dt = new DataTable();
dt = loadDataGridView(_FileXML);
for (int i = 0; i < dt.Rows.Count; i++)
{
if (dt.Rows[i][cotMa].ToString().Trim().Equals(ma))
{
kt = false;
}
else
{
kt = true;
}
}
return kt;
}
public void exCuteNonQuery(string sql)
{
SqlConnection con = new SqlConnection(strCon);
con.Open();
SqlCommand com = new SqlCommand(sql, con);
com.ExecuteNonQuery();
}
public void Them_Database(string tenBang, string _FileXML) {
string duongDan = _FileXML;
DataTable table = loadDataGridView(duongDan);
int dong = table.Rows.Count - 1;
string sql = "insert into " + tenBang + " values(";
for (int j = 0; j < table.Columns.Count - 1; j++)
{
sql += "N'" + table.Rows[dong][j].ToString().Trim() + "',";
}
sql += "N'" + table.Rows[dong][table.Columns.Count -
1].ToString().Trim() + "'";
sql += ")";
exCuteNonQuery(sql);
}
public void Sua_Database(string tenBang, string _FileXML, string tenCot,
string giaTri)
{
string duongDan = _FileXML;
DataTable table = loadDataGridView(duongDan);
int dong = -1;
for (int i = 0; i < table.Rows.Count; i++)
{
if (table.Rows[i][tenCot].ToString().Trim() == giaTri)
{ dong = i; }
}
if (dong > -1)
16
{
string sql = "update " + tenBang + " set ";
for (int j = 0; j < table.Columns.Count-1; j++)
{
sql += table.Columns[j].ToString() + " = N'" + table.Rows[dong]
[j].ToString().Trim() + "', ";
}
sql += table.Columns[table.Columns.Count - 1].ToString() + " = N'" +
table.Rows[dong][table.Columns.Count - 1].ToString().Trim() + "' ";
sql += "where " + tenCot + "= '" + giaTri +"'";
exCuteNonQuery(sql);
}
}
public void Xoa_Database(string _FileXML, string tenCot, string
giaTri,string tenBang)
{
string duongDan = _FileXML;
DataTable table = loadDataGridView(duongDan);
int dong = -1;
for (int i = 0; i < table.Rows.Count; i++)
{
if (table.Rows[i][tenCot].ToString().Trim() == giaTri)
{ dong = i; }
}
if (dong > -1)
{
string sql = "delete from " + tenBang + " where ";
for (int j = 0; j < table.Columns.Count - 1; j++)
{
if (table.Rows[dong][tenCot].ToString().Trim() == giaTri)
{
sql += tenCot + " = '" + giaTri+ "'";
}
}
exCuteNonQuery(sql);
}
}
public void CapNhapTungBang(string tenBang, string _FileXML)
{
string duongDan= _FileXML;
DataTable table= loadDataGridView(duongDan);
for (int i = 0; i < table.Rows.Count; i++)
{
string sql = "insert into " + tenBang + " values(";
for (int j = 0; j < table.Columns.Count - 1; j++)
{
sql += "N'" + table.Rows[i][j].ToString().Trim() + "',";
}
sql += "N'" + table.Rows[i][table.Columns.Count -
1].ToString().Trim() + "'";
sql += ")";
exCuteNonQuery(sql);
}
17
}
public void TimKiemXSLT(string data,string tenFileXML,string tenfileXSLT)
{
XslCompiledTransform xslt = new XslCompiledTransform();
xslt.Load(""+tenfileXSLT+".xslt");
XsltArgumentList argList = new XsltArgumentList();
argList.AddParam("Data", "", data);
XmlWriter writer = XmlWriter.Create(""+tenFileXML+".html");
xslt.Transform(new XPathDocument("" + tenFileXML + ".xml"), argList,
writer);
writer.Close();
System.Diagnostics.Process.Start("" + tenFileXML + ".html");
}
}
AR*!8/#€R223NWPJ
!+6
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" /> xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:param name="Data"></xsl:param>
<xsl:template match="/NewDataSet">
<html>
<body>
<br />
<br />
<center>
<h1>DANH SÁCH CHI TIẾT HÓA ĐƠN</h1>
</center>
<br />
<br />
<table border="1" width="100%">
<tr>
<th>STT</th>
<th>Mã hóa đơn</th>
<th>Mã đĩa</th>
<th>Số lượng mua</th>
<th>Thành tiền</th>
</tr>
<xsl:for-each select="CTHoaDon">
<xsl:if test="MaHD[.=$Data]">
<tr>
<td>
<xsl:value-of select="position()"/>
</td>
<td>
<xsl:value-of select="MaHD"/>
</td>
18
<td>
<xsl:value-of select="MaDia"/>
</td>
<td>
<xsl:value-of select="SLMua"/>
</td>
<td>
<xsl:value-of select="ThanhTien"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
NWPJ]`
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl=" /> xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-
prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:param name="Data"></xsl:param>
<xsl:template match="/NewDataSet">
<html>
<body>
<br />
<br />
<center>
<h1>DANH SÁCH ĐĨA PHIM</h1>
</center>
<br />
<br />
<table border="1" width="100%">
<tr>
<th>STT</th>
<th>Mã đĩa phim</th>
<th>Tựa đề</th>
<th>Hãng sản xuất</th>
<th>Đạo điễn</th>
<th>Số đĩa</th>
<th>Giá</th>
</tr>
<xsl:for-each select="DiaPhim">
<xsl:if test="MaDia[.=$Data]">
<tr>
<td>
<xsl:value-of select="position()"/>
</td>
19
<td>
<xsl:value-of select="MaDia"/>
</td>
<td>
<xsl:value-of select="TuaDe"/>
</td>
<td>
<xsl:value-of select="HangSX"/>
</td>
<td>
<xsl:value-of select="DaoDien"/>
</td>
<td>
<xsl:value-of select="SoDia"/>
</td>
<td>
<xsl:value-of select="Gia"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
NWPJ]Wn]
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" /> xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:param name="Data"></xsl:param>
<xsl:template match="/NewDataSet">
<html>
<body>
<br />
<br />
<center>
<h1>DANH SÁCH HÓA ĐƠN</h1>
</center>
<br />
<br />
<table border="1" width="100%">
<tr>
<th>STT</th>
<th>Mã hóa đơn</th>
<th>Mã nhân viên</th>
<th>Ngày lập</th>
</tr>
<xsl:for-each select="HoaDon">
<xsl:if test="MaHD[.=$Data]">
<tr>
<td>
<xsl:value-of select="position()"/>
</td>
<td>
20
<xsl:value-of select="MaHD"/>
</td>
<td>
<xsl:value-of select="MaNV"/>
</td>
<td>
<xsl:value-of select="NgayLap"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
NWPJ-IR
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" /> xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:param name="Data"></xsl:param>
<xsl:template match="/NewDataSet">
<html>
<body>
<br />
<br />
<center>
<h1>DANH SÁCH NHÂN VIÊN</h1>
</center>
<br />
<br />
<table border="1" width="100%">
<tr>
<th>STT</th>
<th>Mã nhân viên</th>
<th>Họ và tên</th>
<th>Địa chỉ</th>
<th>số điện thoại</th>
</tr>
<xsl:for-each select="NhanVien">
<xsl:if test="MaNV[.=$Data]">
<tr>
<td>
<xsl:value-of select="position()"/>
</td>
<td>
<xsl:value-of select="MaNV"/>
</td>
<td>
<xsl:value-of select="HoTen"/>
</td>
<td>
<xsl:value-of select="DiaChi"/>
</td>
<td>
21
<xsl:value-of select="SDTNV"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
NWPJJo
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl=" /> xmlns:msxsl="urn:schemas-microsoft-com:xslt" exclude-result-prefixes="msxsl"
>
<xsl:output method="xml" indent="yes"/>
<xsl:param name="Data"></xsl:param>
<xsl:template match="/NewDataSet">
<html>
<body>
<br />
<br />
<center>
<h1>DANH SÁCH TÀI KHOẢN</h1>
</center>
<br />
<br />
<table border="1" width="100%">
<tr>
<th>STT</th>
<th>Tên tài khoản</th>
<th>Mật khẩu</th>
<th>quyền</th>
</tr>
<xsl:for-each select="TaiKhoan">
<xsl:if test="TaiKhoan[.=$Data]">
<tr>
<td>
<xsl:value-of select="position()"/>
</td>
<td>
<xsl:value-of select="TaiKhoan"/>
</td>
<td>
<xsl:value-of select="matkhau"/>
</td>
<td>
<xsl:value-of select="quyen"/>
</td>
</tr>
</xsl:if>
</xsl:for-each>
22
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
2. Giao diện chương trình
k_Q@
23
k
kE:#F4@
24
kA +6
kE:#F<
25