You are on page 1of 99

TRƯỜNG ĐẠI HỌC TÀI NGUYÊN VÀ MÔI TRƯỜNG

THÀNH PHỐ HỒ CHÍ MINH


KHOA HỆ THỐNG THÔNG TIN VÀ VIỄN THÁM

TIỂU LUẬN
HỌC PHẦN: LẬP TRÌNH WEB

ĐỀ TÀI: ĐỀ TÀI: XÂY DỰNG PHẦN MỀM QUẢN


LÝ BÁN HÀNG BẾP GAS VÀ BÌNH GAS

Sinh viên thực hiện : Nguyễn Ngọc Tú


Lớp : 09_ĐHCNTT3
Giảng viên hướng dẫn: ThS. Ngô Tân Khai
TP. Hồ Chí Minh, tháng 08 năm 2022
MỞ ĐẦU

Thị trường bếp gas hiện nay vô cùng đa dạng về mẫu mã cũng như tính năng. Bạn có thể dễ dàng
tìm thấy sản phẩm phù hợp với giá tiền. Thế nhưng giữa rất nhiều các thương hiệu bếp gas, đâu là
hãng bếp gas tốt để lựa chọn? Nhưng trên thị trường vẫn còn tràn lan các sản phẩm bếp gas bình gas
không rõ nguồn gốc, đã qua sử dụng và tìm ẩn nhiều nguy cơ nguy hiểm cho người sử dụng, cháy
nổ, rò rỉ khí gas do sử dụng bình gas, bếp gas không đảm bảo an toàn cũng là một điều đáng quan
tâm của người tiêu dùng khi tìm mua những sản phẩm phục vụ nhu cầu hằng ngày như bình gas bếp
gas. Ai cũng muốn có một không gian bếp an toàn và ấm áp.

Phần mềm quản lý bán hàng gas bình là một trong số những giải pháp công nghệ được sử dụng
khá phổ biến hiện dành cho các cửa hàng kinh doanh Gas. Việc áp dụng phầm mềm sẽ hỗ trợ đặc
biệt cho cửa hàng trong mọi hoạt động. Từ bán hàng, giao hàng, quản lý thống kê chi phí để đưa ra
các chiến lược phát triển. Đảm bảo tiết kiệm nhiều thời gian và chi phí thuê nhân viên như cách làm
truyền thống lâu nay. Đồng thời thay đổi bộ mặt của cửa hàng, xây dựng hình ảnh chuyên nghiệp
trong mắt người tiêu dùng.

Các tính năng sẽ đảm bảo gas bình được quản lý chặt chẽ, khoa học. Chủ cửa hàng có thể không
cần vào kho đếm vẫn biết được số lượng vỏ chai còn/hết, màu nào vỏ nào giao cho ai,.. Tránh tình
trạng thất thoát bình mà không rõ lý do. Các chính sách chăm sóc khách hàng cũng được nâng lên
tầm cao mới khi áp dụng các chương trình sale, tích điểm, khuyến mại sinh nhật,.. Khi có việc đi
vắng không cần phải lo lắng với ứng dụng tích hợp sẵn trên điện thoại.

Phần mềm quản lý cửa hàng sẽ giúp bạn tối ưu nguồn lực kinh doanh. Tiết kiệm thời gian, công
sức trong quản lý kinh doanh. Tận dụng được tối đa thời gian để nghiên cứu chiến lược phát triển
tốt nhất. Chỉ cần bỏ ra một số tiền nhỏ (từ 100.000đ/tháng) nhưng lại thu về hàng tá lợi ích tăng khả
năng chốt đơn cực nhanh. Quản lý dòng tiền hợp lý, hiệu quả và khoa học.
Với sự phát triển vượt bật của nền công nghệ thông tin hiện nay thì lập trình web thật sự rất
quan trọng đối với con người nhằm cung cấp nhu cầu giải trí cho người dân. Để có thể đáp ứng
những nhu cầu ấy thì ngành công nghệ thông tin đã cải tiến rất nhiều, đáp ứng đủ nhu cầu cần thiết.
Em đã lựa chọn hệ quản trị cơ sở dữ liệu SQL Server 2014 và ngôn ngữ hỗ trợ cài đặt là Visual
Studio Code. Mặc dù em đã cố gắng nhưng vẫn có nhiều sai sót mong được thầy chỉ bảo thêm .
Cuối cùng em xin trân trọng cảm ơn thầy Ngô Tân Khai đã chỉ dạy em tận tình trong suốt môn học
này .
MÔ HÌNH DỮ LIỆU
MỤC LỤC

Contents

MỞ ĐẦU...................................................................................................................... 1
MÔ HÌNH DỮ LIỆU....................................................................................................2
PHẦN 1: Code các Form (HTML Server control)...................................................... 3
1.1 Bảng Sản Phẩm ................................................................................................. 3
1.2 Bảng Chi Tiết Phiếu Xuất..............................................................................5
1.3 Bảng Phiếu Xuất................................................................................... 7
1.4 Bảng Khách........................................................................................... 8
1.5 Bảng Hãng Sản Xuất...................................................................................................
10
1.6 Bảng Nơi Bảo Hành...............................................................................................12
PHẦN 2: Code các Form (Web Server control)........................................................14
2.1 Bảng Sản Phẩm............................................................................................... 14
2.2 Bảng Chi Tiết Phiếu Xuất............................................................................15
2.3 Bảng Phiếu Xuất................................................................................. 17
2.4 Bảng Khách......................................................................................... 19
2.5 Bảng Hãng Sản Xuất...................................................................................................
20
2.6 Bảng Nơi Bảo Hành...............................................................................................21
PHẦN 3: Code và hình ảnh xử lý phần MVC........................................................... 24
3.1 Bảng Sản Phẩm.............................................................................28
3.2 Bảng Chi Tiết Phiếu Xuất.................................................................................38
3.3 Bảng Phiếu Xuất................................................................................. 47
3.4 Bảng Khách..........................................................................................63
3.5 Bảng Hãng Sản
Xuất.....................................................................................................72
3.6 Bảng Nơi Bảo Hành................................................................................................82
TÀI LIỆU THAM KHẢO..........................................................................................93

Trang 1
PHẦN 1: Code các Form (HTML Server control)
1.1 Bảng Sản Phẩm

 Thiết kế form

 Mã lệnh
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

Trang 2
<title>Quản Lý Bán Hàng Bếp Và Gas</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<H1>SẢN PHẨM</H1>

<table >

<tr>

<td>Mã Sản Phẩm</td>

<td>:</td>

<td><input id="MaSanPham" type="text" name="txtMaSanPham"


runat="server" /></td>

</tr>

<tr>

<td>Tên Sản Phẩm</td>

<td>:</td>

<td><input id="TenSanPham" type="text" name="txtTenSanPham"


runat="server" /></td>

</tr>

<tr>

<td>Nhà Sản Xuất</td>

<td>:</td>

<td><input id="NhaSanXuat" type="text" name="txtNhaSanXuat”


runat="server" /></td>

</tr>

<tr>

<td>Thời Hạn Bảo Hành</td>

<td>:</td>

<td><input id="ThoiHanBaoHanh" type="text" name="txtThoiHanBaoHanh"


runat="server" /></td>

</tr>

<tr>

Trang 3
<td>Đơn Giá</td>

<td>:</td>

<td><input id="DonGia" type="text" name="txtDonGia" runat="server"


/></td>

</tr>

</table>

<input id="LuuLai" type="button" value="Lưu lại" runat="server" />

<input id="Dong" type="button" value="Đóng" runat="server" />

</div>

</form>

</body>

</html>

1.2 Bảng Chi Tiết Phiếu Xuất

 Thiết kế form

 Mã lệnh
<!DOCTYPE html>

Trang 4
<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>Quản Lý Bán Hàng Bếp Và Gas</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<H1>CHI TIẾT PHIẾU XUẤT</H1>

<table >

<tr>

<td>Số Phiếu Xuất</td>

<td>:</td>

<td><input id="Sophieuxuat" type="text" name="txtSophieuxuat"


runat="server" /></td>

</tr>

<tr>

<td>Mã Sản Phẩm</td>

<td>:</td>

<td><input id="Masanpham" type="text" name="txtMasapham"


runat="server" /></td>

</tr>

<tr>

<td>Số Lượng</td>

<td>:</td>

<td><input id="Soluong" type="text" name="txtSoluong" runat="server"


/></td>

</tr>

</table>

<input id="Dong" type="button" value="Đóng" runat="server" />

<input id="LuuLai" type="button" value="Lưu lại" runat="server" />

</div>

Trang 5
</form>

</body>

</html>

1.3 Bảng Phiếu Xuất

 Thiết kế form

 Mã lệnh
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>Quản Lý Bán Hàng Bếp Và Gas</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<H1> PHIẾU XUẤT</H1>

<table >

Trang 6
<tr>

<td>Số Phiếu Xuất</td>

<td>:</td>

<td><input id="Sophieuxuat" type="text" name="txtSophieuxuat"


runat="server" /></td>

</tr>

<tr>

<td>Mã Khách</td>

<td>:</td>

<td><input id="Makhach" type="text" name="txtMakhach" runat="server"


/></td>

</tr>

<tr>

<td>Ngày Lập Phiếu</td>

<td>:</td>

<td><input id="Ngaylapphieu" type="text" name="txtNgaylapphieu"


runat="server" /></td>

</tr>

</table>

<input id="LuuLai" type="button" value="Lưu lại" runat="server" />

<input id="Dong" type="button" value="Đóng" runat="server" />

</div>

</form>

</body>

</html>

1.4 Bảng Khách

 Thiết kế form
Trang 7
 Mã lệnh

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>Quản Lý Bán Hàng Bếp Và Gas</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<H1> KHÁCH</H1>

<table >

<tr>

<td>Mã Khách</td>

<td>:</td>

<td><input id="Makhach" type="text" name="txtMakhach" runat="server"


/></td>

</tr>

<tr>

<td>Tên Khách</td>

Trang 8
<td>:</td>

<td><input id="Tenkhach" type="text" name="txtTenkhach"


runat="server" /></td>

</tr>

<tr>

<td>Địa Chỉ</td>

<td>:</td>

<td><input id="Diachi" type="text" name="txtDiachi" runat="server"


/></td>

</tr>

<tr>

<td>Số Điện Thoại</td>

<td>:</td>

<td><input id="Sodienthoai" type="text" name="txtSodienthoai"


runat="server" /></td>

</tr>

</table>

<input id="Dong" type="button" value="Đóng" runat="server" />

<input id="LuuLai" type="button" value="Lưu lại" runat="server" />

</div>

</form>

</body>

</html>

1.5 Bảng Hãng Sản Xuất

 Thiết kế form

Trang 9
 Mã lệnh
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>Quản Lý Bán Hàng</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<H1> Hãng Sản Xuất</H1>

<table >

<tr>

<td>Mã Hãng Sản Xuất</td>

<td>:</td>

<td><input id="Mahangsanxuat" type="text" name="txtMahangsanxuat"


runat="server" /></td>

</tr>

<tr>

<td>Tên Hãng Sản Xuất</td>

<td>:</td>

Trang 10
<td><input id="Tenhangsanxuat" type="text" name="txtTenhangsanxuat"
runat="server" /></td>

</tr>

<tr>

<td>Địa Chỉ VP Chính Tại VN</td>

<td>:</td>

<td><input id="Diachivpchinhtaivn" type="text"


name="txtDiachivpchinhtaivn" runat="server" /></td>

</tr>

<tr>

<td>Số Điện Thoại</td>

<td>:</td>

<td><input id="Sodienthoai" type="text" name="txtSodienthoai"


runat="server" /></td>

</tr>

</table>

<input id="Dong" type="button" value="Đóng" runat="server" />

<input id="LuuLai" type="button" value="Lưu lại" runat="server" />

</div>

</form>

</body>

</html>

1.6 Bảng Nơi Bảo Hành

 Thiết kế form

Trang 11
 Mã lệnh
<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head id="Head1" runat="server">

<title>Quản Lý Bán Hàng</title>

</head>

<body>

<form id="form1" runat="server">

<div>

<H1> NƠI BẢO HÀNH</H1>

<table >

<tr>

<td>Mã Hãng Sản Xuất</td>

<td>:</td>

<td><input id="Mahangsanxuat" type="text" name="txtMahangsanxuat"


runat="server" /></td>

</tr>

<tr>

<td>Số TT</td>

<td>:</td>

Trang 12
<td><input id="Sott" type="text" name="txtSott" runat="server"
/></td>

</tr>

<tr>

<td>Tên Điểm Bảo Hành</td>

<td>:</td>

<td><input id="Tendiembaohanh" type="text" name="txtTendiembaohanh"


runat="server" /></td>

</tr>

<tr>

<td>Địa Chỉ</td>

<td>:</td>

<td><input id="Diachi" type="text" name="txtDiachi" runat="server"


/></td>

</tr>

<tr>

<td>Số Điện Thoại</td>

<td>:</td>

<td><input id="Sodienthoai" type="text" name="txtSodienthoai"


runat="server" /></td>

</tr>

</table>

<input id="Dong" type="button" value="Đóng" runat="server" />

<input id="LuuLai" type="button" value="Lưu lại" runat="server" />

</div>

</form>

</body>

</html>

PHẦN 2: Code các Form (Web Server control)

2.1 Bảng Sản Phẩm

Trang 13
 Thiết kế form

 Mã lệnh
1 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication4.WebForm1" %>
2
3 <!DOCTYPE html>
4
5 <html xmlns="http://www.w3.org/1999/xhtml">
6 <head runat="server">
7 <title></title>
8 </head>
9 <body>
10 <form id="form1" runat="server">
11 <div>
12 <table cellpadding="0" cellspacing="2px" border="0">
13 <caption align="center" valign="bottom"><h5>SẢN PHẨM
</h5></caption>
14
15 <tr>
16 <td> <asp:Label ID="lblMaSanPham" runat="server"> Mã sản
phẩm</asp:Label></td>
17 <td> <asp:Label ID="Label1" runat="server"> :</asp:Label></td>
18 <td> <asp:TextBox ID="txtMaSanPham"
runat="server"></asp:TextBox> </td>

Trang 14
19 </tr>
20 <tr>
21 <td> <asp:Label ID="lblTenSanPham" runat="server"> Tên sản
phẩm</asp:Label></td>
22 <td> <asp:Label ID="Label2" runat="server"> :</asp:Label></td>
23 <td> <asp:TextBox ID="txtTenSanPham"
runat="server"></asp:TextBox></td>
24 </tr>
25 <tr>
26 <td> <asp:Label ID="lblNhasanxuat" runat="server"> Nhà sản
xuất</asp:Label></td>
27 <td> <asp:Label ID="Label3" runat="server"> :</asp:Label></td>
28 <td> <asp:TextBox ID="txtNhasanxuat"
runat="server"></asp:TextBox></td>
29 </tr>
30 <tr>
31 <td> <asp:Label ID="lblThoihanbaohanh" runat="server"> Thời hạn
bảo hành</asp:Label></td>
32 <td> <asp:Label ID="Label4" runat="server"> :</asp:Label></td>
33 <td> <asp:TextBox ID="TxtThoihanbaohanh"
runat="server"></asp:TextBox></td>
34 </tr>
35 <tr>
36 <td> <asp:Label ID="lblDongia" runat="server"> Đơn
giá</asp:Label></td>
37 <td> <asp:Label ID="Label5" runat="server"> :</asp:Label></td>
38 <td> <asp:TextBox ID="TxtDongia" runat="server" type="date"
39 ></asp:TextBox></td>
40 </tr>
41 <tr>
42 <td align="center" colspan="2"> <asp:Button ID="btnTinhTien"
runat="server" Text="Lưu Lại " /></td>
43 <td align="center"> <asp:Button ID="Button1" runat="server"
Text="Đóng " /></td>
44 </tr>
45 </table>
46
47
48
49
50
51 </div>
52 </form>

Trang 15
53 </body>
54 </html>

2.2 Bảng Chi Tiết Phiếu Xuất

 Thiết kế form

 Mã lệnh
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication4.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

<form id="form1" runat="server">

<div>

<table cellpadding="0" cellspacing="2px" border="0">

Trang 16
<caption align="center" valign="bottom"><h5>CHI TIẾT PHIẾU
XUẤT</h5></caption>

<tr>

<td> <asp:Label ID="lblSophieu" runat="server"> Số phiếu


xuất</asp:Label></td>

<td> <asp:Label ID="Label1" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtSophieu" runat="server"></asp:TextBox>


</td>

</tr>

<tr>

<td> <asp:Label ID="lblMasanpham" runat="server"> Mã sản


phẩm</asp:Label></td>

<td> <asp:Label ID="Label2" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtMasanpham"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td> <asp:Label ID="lblSoluong" runat="server"> Số


lượng</asp:Label></td>

<td> <asp:Label ID="Label3" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtSoluong"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td align="center" colspan="2"> <asp:Button ID="btnTinhTien"


runat="server" Text="Lưu Lại " /></td>

<td align="center"> <asp:Button ID="Button1" runat="server"


Text="Đóng " /></td>

</tr>

</table>

Trang 17
</div>

</form>

</body>

</html>

3.3 Bảng Phiếu Xuất

 Thiết kế form

 Mã lệnh
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication4.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

Trang 18
<head runat="server">

<title></title>

</head>

<body>

<form id="form1" runat="server">

<div>

<table cellpadding="0" cellspacing="2px" border="0">

<caption align="center" valign="bottom"><h5> PHIẾU


XUẤT</h5></caption>

<tr>

<td> <asp:Label ID="lblSophieu" runat="server"> Số phiếu


xuất</asp:Label></td>

<td> <asp:Label ID="Label1" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtSophieu" runat="server"></asp:TextBox>


</td>

</tr>

<tr>

<td> <asp:Label ID="lblMakhach" runat="server"> Mã


khách</asp:Label></td>

<td> <asp:Label ID="Label2" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtMakhach"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td> <asp:Label ID="lblNgaylapphieu" runat="server"> Ngày lập


phiếu</asp:Label></td>

<td> <asp:Label ID="Label3" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtNgaylapphieu"


runat="server"></asp:TextBox></td>

</tr>

<tr>

Trang 19
<td align="center" colspan="2"> <asp:Button ID="Button1"
runat="server" Text="Lưu Lại " /></td>

<td align="center"> <asp:Button ID="Button2" runat="server"


Text="Đóng " /></td>

</tr>

</table>

</div>

</form>

</body>

</html>

3.4 Bảng Khách

 Thiết kế form

Trang 20
 Mã lệnh

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"


Inherits="WebApplication4.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

<form id="form1" runat="server">

<div>

<table cellpadding="0" cellspacing="2px" border="0">

<caption align="center" valign="bottom"><h5> KHÁCH</h5></caption>

<tr>

<td> <asp:Label ID="lblMakhach" runat="server"> Mã


khách</asp:Label></td>

<td> <asp:Label ID="Label1" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtMakhach" runat="server"></asp:TextBox>


</td>

Trang 21
</tr>

<tr>

<td> <asp:Label ID="lblTenkhach" runat="server"> Tên


khách</asp:Label></td>

<td> <asp:Label ID="Label2" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtTenkhach"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td> <asp:Label ID="lblDiachi" runat="server"> Địa


chỉ</asp:Label></td>

<td> <asp:Label ID="Label3" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtDiachi"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td> <asp:Label ID="lblSodienthoai" runat="server"> Số điện


thoại</asp:Label></td>

<td> <asp:Label ID="Label5" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtSodienthoai"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td align="center" colspan="2"> <asp:Button ID="Button1"


runat="server" Text="Lưu Lại " /></td>

<td align="center"> <asp:Button ID="Button2" runat="server"


Text="Đóng " /></td>

</tr>

</table>

Trang 22
</div>

</form>

</body>

</html>

3.5 Bảng Hãng Sản Xuất

 Thiết kế form

 Mã lệnh
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication4.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

Trang 23
<body>

<form id="form1" runat="server">

<div>

<table cellpadding="0" cellspacing="2px" border="0">

<caption align="center" valign="bottom"><h5> HÃNG SẢN


XUẤT</h5></caption>

<tr>

<td> <asp:Label ID="lblMahangsx" runat="server"> Mã hãng


sx</asp:Label></td>

<td> <asp:Label ID="Label1" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtMahangsx" runat="server"></asp:TextBox>


</td>

</tr>

<tr>

<td> <asp:Label ID="lblTenhangsx" runat="server"> Tên hãng


sx</asp:Label></td>

<td> <asp:Label ID="Label2" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtTenhangsx"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td> <asp:Label ID="lblDiachivpchinhtaivn" runat="server"> Địa


chỉ vp chính tại vn</asp:Label></td>

<td> <asp:Label ID="Label3" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtDiachivpchinhtaivn"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td> <asp:Label ID="Sodienthoai" runat="server"> Số điện


thoại</asp:Label></td>

<td> <asp:Label ID="Label5" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtSodienthoai"


runat="server"></asp:TextBox></td>

Trang 24
</tr>

<tr>

<td align="center" colspan="2"> <asp:Button ID="Button1"


runat="server" Text="Lưu Lại " /></td>

<td align="center"> <asp:Button ID="Button2" runat="server"


Text="Đóng " /></td>

</tr>

</table>

</div>

</form>

</body>

</html>

3.6 Bảng Nơi Bảo Hành

 Thiết kế form

Trang 25
 Mã lệnh
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs"
Inherits="WebApplication4.WebForm1" %>

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">

<head runat="server">

<title></title>

</head>

<body>

<form id="form1" runat="server">

<div>

<table cellpadding="0" cellspacing="2px" border="0">

<caption align="center" valign="bottom"><h5> NƠI BẢO


HÀNH</h5></caption>

<tr>

<td> <asp:Label ID="lblMahangsx" runat="server"> Mã hãng


sx</asp:Label></td>

<td> <asp:Label ID="Label1" runat="server"> :</asp:Label></td>

Trang 26
<td> <asp:TextBox ID="txtMahangsx" runat="server"></asp:TextBox>
</td>

</tr>

<tr>

<td> <asp:Label ID="lblSott" runat="server"> Số


tt</asp:Label></td>

<td> <asp:Label ID="Label2" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtSott"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td> <asp:Label ID="lblTendiembaohanh" runat="server"> Tên điểm


bảo hành</asp:Label></td>

<td> <asp:Label ID="Label3" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtTendiembaohanh"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td> <asp:Label ID="Diachi" runat="server"> Địa


chỉ</asp:Label></td>

<td> <asp:Label ID="Label7" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtDiachi"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td> <asp:Label ID="Sodienthoai" runat="server"> Số điện


thoại</asp:Label></td>

<td> <asp:Label ID="Label5" runat="server"> :</asp:Label></td>

<td> <asp:TextBox ID="txtSodienthoai"


runat="server"></asp:TextBox></td>

</tr>

<tr>

<td align="center" colspan="2"> <asp:Button ID="Button1"


runat="server" Text="Lưu Lại " /></td>

Trang 27
<td align="center"> <asp:Button ID="Button2" runat="server"
Text="Đóng " /></td>

</tr>

</table>

</div>

</form>

</body>

</html>

Trang 28
PHẦN 3: Code và hình ảnh xử lý phần MVC
 Model

3.1 Bảng Sản Phẩm

Mã Lệnh
SanPhamControllers
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

Trang 29
using System.Web.Mvc;
using QuanLyBanHang.Models;

namespace QuanLyBanHang.Controllers
{
public class DefaultController : Controller
{
SanPhamEntities db = new SanPhamEntities();
// GET: Default
public ActionResult Index()
{
var lstdt = from dt in db.SanPhams select dt;
return View(lstdt);
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(SanPham dt)
{
db.SanPhams.Add(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
SanPham dt = db.SanPhams.Find(id);
db.SanPhams.Remove(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(String id)
{
SanPham dt = db.SanPhams.Find(id);
return View(dt);
}
[HttpPost]
public ActionResult Edit(FormCollection f)
{
String MaSanPham = f.Get("MaSanPham");
SanPham dt = db.SanPhams.Find(MaSanPham);
dt.TenSanPham = f.Get("TenSanPham");
dt.NhaSanXuat = f.Get("NhaSanXuat");
dt.ThoiHanBaoHanh = f.Get("ThoiHanBaoHanh");
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Details(String id)
{
var lstdt = db.SanPhams.Select(p => p).Where(p => p.MaSanPham
== id).FirstOrDefault();
return View(lstdt);

Trang 30
}
}
}

SanPhamIdex

@model IEnumerable<QuanLyBanHang.Models.SanPham>

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<style>
html,
body {
height: 100%;
}

body {
margin: 0;
background: linear-gradient(45deg, #49a09d, #5f2c82);
font-family: sans-serif;
font-weight: 100;
}

.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

table {
width: 800px;
border-collapse: collapse;
overflow: hidden;
box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

th,
td {
padding: 15px;
background-color: rgba(255,255,255,0.2);
color: #fff;
}

th {
text-align: left;

Trang 31
}

thead {
th;

{
background-color: #55608f;
}

tbody {
tr;

{
&:hover;

{
background-color: rgba(255,255,255,0.3);
}

td {
position: relative;
&:hover;

{
&:before;

{
content: "";
position: absolute;
left: 0;
right: 0;
top: -9999px;
bottom: -9999px;
background-color: rgba(255,255,255,0.2);
z-index: -1;
}

}
}
}
</style>
</head>
<body>
<div class="container">
<h1>
Bảng sản phẩm
</h1>
<table>
<thead>
<tr>
<th>

Trang 32
@Html.DisplayNameFor(model => model.MaSanPham)
</th>
<th>
@Html.DisplayNameFor(model => model.TenSanPham)
</th>
<th>
@Html.DisplayNameFor(model => model.NhaSanXuat)
</th>
<th>
@Html.DisplayNameFor(model =>
model.ThoiHanBaoHanh)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.MaSanPham)
</td>
<td>
@Html.DisplayFor(modelItem => item.TenSanPham)
</td>
<td>
@Html.DisplayFor(modelItem => item.NhaSanXuat)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.ThoiHanBaoHanh)
</td>

<td>
@Html.ActionLink("Create New", "Create") |
@Html.ActionLink("Edit", "Edit", new { id =
item.MaSanPham }) |
@Html.ActionLink("Details", "Details", new
{ id = item.MaSanPham }) |
@Html.ActionLink("Delete", "Delete", new { id
= item.MaSanPham })
</td>
</tr>
}
</tbody>

</table>
</div>
</body>
</html>

Creat

Trang 33
Mã Lệnh

AddView Creat

@model QuanLyBanHang.Models.SanPham

@{
ViewBag.Title = "Create";
}

<h2>Create</h2>

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>SanPham</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MaSanPham, htmlAttributes: new {
@class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MaSanPham, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MaSanPham, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.TenSanPham, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">

Trang 34
@Html.EditorFor(model => model.TenSanPham, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TenSanPham, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.NhaSanXuat, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NhaSanXuat, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NhaSanXuat, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.ThoiHanBaoHanh, htmlAttributes:
new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ThoiHanBaoHanh, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ThoiHanBaoHanh,
"", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-
default" />
</div>
</div>
</div>
}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Edit

Trang 35
Mã Lệnh
@model QuanLyBanHang.Models.SanPham

@{
ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>SanPham</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MaSanPham, htmlAttributes: new {
@class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MaSanPham, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MaSanPham, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.TenSanPham, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.TenSanPham, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TenSanPham, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">

Trang 36
@Html.LabelFor(model => model.NhaSanXuat, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.NhaSanXuat, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NhaSanXuat, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.ThoiHanBaoHanh, htmlAttributes:
new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ThoiHanBaoHanh, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ThoiHanBaoHanh,
"", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default"
/>
</div>
</div>
</div>
}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Details

Trang 37
Mã Lệnh
@model QuanLyBanHang.Models.SanPham

@{
ViewBag.Title = "Details";
}

<h2>Details</h2>

<div>
<h4>SanPham</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.MaSanPham)
</dt>

<dd>
@Html.DisplayFor(model => model.MaSanPham)
</dd>

<dt>
@Html.DisplayNameFor(model => model.TenSanPham)
</dt>

<dd>
@Html.DisplayFor(model => model.TenSanPham)
</dd>

<dt>
@Html.DisplayNameFor(model => model.NhaSanXuat)
</dt>

<dd>
@Html.DisplayFor(model => model.NhaSanXuat)
</dd>

<dt>
@Html.DisplayNameFor(model => model.ThoiHanBaoHanh)
</dt>

<dd>
@Html.DisplayFor(model => model.ThoiHanBaoHanh)
</dd>

</dl>
</div>
<p>
@Html.ActionLink("Edit", "Edit", new { id = Model.MaSanPham }) |
@Html.ActionLink("Back to List", "Index")
</p>

Delete

Trang 38
3.2 Bảng Chi Tiết Phiếu Xuất

Mã Lệnh

ChiTietPhieuXuatConTrollers

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QuanLyBanHang.Models;

namespace QuanLyBanHang.Controllers
{
public class ChiTietPhieuXuatController : Controller
{
ChiTietPhieuXuatEntities db = new ChiTietPhieuXuatEntities();
// GET: Default
public ActionResult Index()
{
var lstdt = from dt in db.ChiTietPhieuXuats select dt;
return View(lstdt);
}
[HttpGet]

Trang 39
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(ChiTietPhieuXuat dt)
{
db.ChiTietPhieuXuats.Add(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
ChiTietPhieuXuat dt = db.ChiTietPhieuXuats.Find(id);
db.ChiTietPhieuXuats.Remove(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(String id)
{
ChiTietPhieuXuat dt = db.ChiTietPhieuXuats.Find(id);
return View(dt);
}
[HttpPost]
public ActionResult Edit(FormCollection f)
{
String SoPhieuXuat = f.Get("SoPhieuXuat");
ChiTietPhieuXuat dt = db.ChiTietPhieuXuats.Find(SoPhieuXuat);
dt.ManSanPham = f.Get("MaSanPham");
dt.SoLuong = f.Get("SoLuong");
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Details(String id)
{
var lstdt = db.ChiTietPhieuXuats.Select(p => p).Where(p =>
p.SoPhieuXuat == id).FirstOrDefault();
return View(lstdt);
}
}
}

ChiTietPhieuXuatIdex

@model IEnumerable<QuanLyBanHang.Models.ChiTietPhieuXuat>

@{
Layout = null;
}

<!DOCTYPE html>

Trang 40
<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<style>
html,
body {
height: 100%;
}

body {
margin: 0;
background: linear-gradient(45deg, #49a09d, #5f2c82);
font-family: sans-serif;
font-weight: 100;
}

.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

table {
width: 800px;
border-collapse: collapse;
overflow: hidden;
box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

th,
td {
padding: 15px;
background-color: rgba(255,255,255,0.2);
color: #fff;
}

th {
text-align: left;
}

thead {
th;

{
background-color: #55608f;
}

tbody {
tr;

Trang 41
&:hover;

{
background-color: rgba(255,255,255,0.3);
}

td {
position: relative;
&:hover;

{
&:before;

{
content: "";
position: absolute;
left: 0;
right: 0;
top: -9999px;
bottom: -9999px;
background-color: rgba(255,255,255,0.2);
z-index: -1;
}

}
}
}
</style>
</head>
<body>
<div class="container">
<h1>
Chi Tiết Phiếu Xuất
</h1>
<table>
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.SoPhieuXuat)
</th>
<th>
@Html.DisplayNameFor(model => model.ManSanPham)
</th>
<th>
@Html.DisplayNameFor(model => model.SoLuong)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>

Trang 42
<td>
@Html.DisplayFor(modelItem =>
item.SoPhieuXuat)
</td>
<td>
@Html.DisplayFor(modelItem => item.ManSanPham)
</td>
<td>
@Html.DisplayFor(modelItem => item.SoLuong)
</td>

<td>
@Html.ActionLink("Create New", "Create") |
@Html.ActionLink("Edit", "Edit", new { id =
item.SoPhieuXuat }) |
@Html.ActionLink("Details", "Details", new
{ id = item.SoPhieuXuat }) |
@Html.ActionLink("Delete", "Delete", new { id
= item.SoPhieuXuat })
</td>
</tr>
}
</tbody>

</table>
</div>
</body>
</html>

Creat

Mã Lệnh
@model QuanLyBanHang.Models.ChiTietPhieuXuat

@{
ViewBag.Title = "Create";
}

Trang 43
<h2>Create</h2>

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>ChiTietPhieuXuat</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.SoPhieuXuat, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoPhieuXuat, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoPhieuXuat, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.ManSanPham, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.ManSanPham, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ManSanPham, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.SoLuong, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoLuong, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoLuong, "", new
{ @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-
default" />
</div>
</div>
</div>
}

<div>

Trang 44
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Edit

Mã Lệnh
@model QuanLyBanHang.Models.ChiTietPhieuXuat

@{
ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>ChiTietPhieuXuat</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.SoPhieuXuat, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoPhieuXuat, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoPhieuXuat, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.ManSanPham, htmlAttributes: new
{ @class = "control-label col-md-2" })

Trang 45
<div class="col-md-10">
@Html.EditorFor(model => model.ManSanPham, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.ManSanPham, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.SoLuong, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoLuong, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoLuong, "", new
{ @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default"
/>
</div>
</div>
</div>
}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Details

Mã Lệnh
@model QuanLyBanHang.Models.ChiTietPhieuXuat

Trang 46
@{
ViewBag.Title = "Details";
}

<h2>Details</h2>

<div>
<h4>ChiTietPhieuXuat</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.SoPhieuXuat)
</dt>

<dd>
@Html.DisplayFor(model => model.SoPhieuXuat)
</dd>

<dt>
@Html.DisplayNameFor(model => model.ManSanPham)
</dt>

<dd>
@Html.DisplayFor(model => model.ManSanPham)
</dd>

<dt>
@Html.DisplayNameFor(model => model.SoLuong)
</dt>

<dd>
@Html.DisplayFor(model => model.SoLuong)
</dd>

</dl>
</div>
<p>
@Html.ActionLink("Edit", "Edit", new { id = Model.SoPhieuXuat}) |
@Html.ActionLink("Back to List", "Index")
</p>

Delete

Trang 47
3.3 Bảng Phiếu Xuất

Mã Lệnh

PhieuXuatControllers

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;

using QuanLyBanHang.Models;

namespace QuanLyBanHang.Controllers

public class PhieuXuatController : Controller

PhieuXuatEntities db = new PhieuXuatEntities();

// GET: Default

Trang 48
public ActionResult Index()

var lstdt = from dt in db.PhieuXuats select dt;

return View(lstdt);

[HttpGet]

public ActionResult Create()

return View();

[HttpPost]

public ActionResult Create(PhieuXuat dt)

db.PhieuXuats.Add(dt);

db.SaveChanges();

return RedirectToAction("Index");

public ActionResult Delete(String id)

PhieuXuat dt = db.PhieuXuats.Find(id);

db.PhieuXuats.Remove(dt);

db.SaveChanges();

return RedirectToAction("Index");

[HttpGet]

public ActionResult Edit(String id)

PhieuXuat dt = db.PhieuXuats.Find(id);

Trang 49
return View(dt);

[HttpPost]

public ActionResult Edit(FormCollection f)

String SoPhieuXuat = f.Get("SoPhieuXuat");

PhieuXuat dt = db.PhieuXuats.Find(SoPhieuXuat);

dt.MaKhach = f.Get("MaKhach");

dt.NgayLapPhieu = f.Get("NgayLapPhieu");

db.SaveChanges();

return RedirectToAction("Index");

public ActionResult Details(String id)

var lstdt = db.PhieuXuats.Select(p => p).Where(p =>


p.SoPhieuXuat == id).FirstOrDefault();

return View(lstdt);

PhieuXuatIndex

@model IEnumerable<QuanLyBanHang.Models.PhieuXuat>

@{

Layout = null;

Trang 50
<!DOCTYPE html>

<html>

<head>

<meta name="viewport" content="width=device-width" />

<title>Index</title>

<style>

html,

body {

height: 100%;

body {

margin: 0;

background: linear-gradient(45deg, #49a09d, #5f2c82);

font-family: sans-serif;

font-weight: 100;

.container {

position: absolute;

top: 50%;

left: 50%;

transform: translate(-50%, -50%);

table {

Trang 51
width: 800px;

border-collapse: collapse;

overflow: hidden;

box-shadow: 0 0 20px rgba(0,0,0,0.1);

th,

td {

padding: 15px;

background-color: rgba(255,255,255,0.2);

color: #fff;

th {

text-align: left;

thead {

th;

background-color: #55608f;

tbody {

tr;

Trang 52
{

&:hover;

background-color: rgba(255,255,255,0.3);

td {

position: relative;

&:hover;

&:before;

content: "";

position: absolute;

left: 0;

right: 0;

top: -9999px;

bottom: -9999px;

background-color: rgba(255,255,255,0.2);

z-index: -1;

Trang 53
}

</style>

</head>

<body>

<div class="container">

<h1>

Bảng Phiếu Xuất

</h1>

<table>

<thead>

<tr>

<th>

@Html.DisplayNameFor(model => model.SoPhieuXuat)

</th>

<th>

@Html.DisplayNameFor(model => model.MaKhach)

</th>

<th>

@Html.DisplayNameFor(model =>
model.NgayLapPhieu)

</th>

<th></th>

</tr>

</thead>

<tbody>

@foreach (var item in Model)

Trang 54
<tr>

<td>

@Html.DisplayFor(modelItem =>
item.SoPhieuXuat)

</td>

<td>

@Html.DisplayFor(modelItem => item.MaKhach)

</td>

<td>

@Html.DisplayFor(modelItem =>
item.NgayLapPhieu)

</td>

<td>

@Html.ActionLink("Create New", "Create") |

@Html.ActionLink("Edit", "Edit", new { id =


item.SoPhieuXuat }) |

@Html.ActionLink("Details", "Details", new {


id = item.SoPhieuXuat }) |

@Html.ActionLink("Delete", "Delete", new


{ id = item.SoPhieuXuat })

</td>

</tr>

</tbody>

</table>

</div>

</body>

</html>

Trang 55
Creat

Mã Lệnh

@model QuanLyBanHang.Models.PhieuXuat

@{

ViewBag.Title = "Create";

<h2>Create</h2>

@using (Html.BeginForm())

@Html.AntiForgeryToken()

<div class="form-horizontal">

<h4>PhieuXuat</h4>

<hr />

Trang 56
@Html.ValidationSummary(true, "", new { @class = "text-
danger" })

<div class="form-group">

@Html.LabelFor(model => model.SoPhieuXuat, htmlAttributes:


new { @class = "control-label col-md-2" })

<div class="col-md-10">

@Html.EditorFor(model => model.SoPhieuXuat, new


{ htmlAttributes = new { @class = "form-control" } })

@Html.ValidationMessageFor(model => model.SoPhieuXuat,


"", new { @class = "text-danger" })

</div>

</div>

<div class="form-group">

@Html.LabelFor(model => model.MaKhach, htmlAttributes: new {


@class = "control-label col-md-2" })

<div class="col-md-10">

@Html.EditorFor(model => model.MaKhach, new


{ htmlAttributes = new { @class = "form-control" } })

@Html.ValidationMessageFor(model => model.MaKhach, "",


new { @class = "text-danger" })

</div>

</div>

<div class="form-group">

@Html.LabelFor(model => model.NgayLapPhieu, htmlAttributes:


new { @class = "control-label col-md-2" })

<div class="col-md-10">

@Html.EditorFor(model => model.NgayLapPhieu, new


{ htmlAttributes = new { @class = "form-control" } })

Trang 57
@Html.ValidationMessageFor(model => model.NgayLapPhieu,
"", new { @class = "text-danger" })

</div>

</div>

<div class="form-group">

<div class="col-md-offset-2 col-md-10">

<input type="submit" value="Create" class="btn btn-


default" />

</div>

</div>

</div>

<div>

@Html.ActionLink("Back to List", "Index")

</div>

@section Scripts {

@Scripts.Render("~/bundles/jqueryval")

Trang 58
Edit

Mã lệnh

@model QuanLyBanHang.Models.PhieuXuat

@{

ViewBag.Title = "Edit";

<h2>Edit</h2>

@using (Html.BeginForm())

@Html.AntiForgeryToken()

Trang 59
<div class="form-horizontal">

<h4>PhieuXuat</h4>

<hr />

@Html.ValidationSummary(true, "", new { @class = "text-


danger" })

<div class="form-group">

@Html.LabelFor(model => model.SoPhieuXuat, htmlAttributes:


new { @class = "control-label col-md-2" })

<div class="col-md-10">

@Html.EditorFor(model => model.SoPhieuXuat, new


{ htmlAttributes = new { @class = "form-control" } })

@Html.ValidationMessageFor(model => model.SoPhieuXuat,


"", new { @class = "text-danger" })

</div>

</div>

<div class="form-group">

@Html.LabelFor(model => model.MaKhach, htmlAttributes: new {


@class = "control-label col-md-2" })

<div class="col-md-10">

@Html.EditorFor(model => model.MaKhach, new


{ htmlAttributes = new { @class = "form-control" } })

@Html.ValidationMessageFor(model => model.MaKhach, "",


new { @class = "text-danger" })

</div>

</div>

<div class="form-group">

@Html.LabelFor(model => model.NgayLapPhieu, htmlAttributes:


new { @class = "control-label col-md-2" })

Trang 60
<div class="col-md-10">

@Html.EditorFor(model => model.NgayLapPhieu, new


{ htmlAttributes = new { @class = "form-control" } })

@Html.ValidationMessageFor(model => model.NgayLapPhieu,


"", new { @class = "text-danger" })

</div>

</div>

<div class="form-group">

<div class="col-md-offset-2 col-md-10">

<input type="submit" value="Save" class="btn btn-


default" />

</div>

</div>

</div>

<div>

@Html.ActionLink("Back to List", "Index")

</div>

@section Scripts {

@Scripts.Render("~/bundles/jqueryval")

Details

Trang 61
Mã Lệnh

@model QuanLyBanHang.Models.PhieuXuat

@{

ViewBag.Title = "Details";

<h2>Details</h2>

<div>

<h4>PhieuXuat</h4>

<hr />

<dl class="dl-horizontal">

<dt>

@Html.DisplayNameFor(model => model.SoPhieuXuat)

</dt>

<dd>

Trang 62
@Html.DisplayFor(model => model.SoPhieuXuat)

</dd>

<dt>

@Html.DisplayNameFor(model => model.MaKhach)

</dt>

<dd>

@Html.DisplayFor(model => model.MaKhach)

</dd>

<dt>

@Html.DisplayNameFor(model => model.NgayLapPhieu)

</dt>

<dd>

@Html.DisplayFor(model => model.NgayLapPhieu)

</dd>

</dl>

</div>

<p>

@Html.ActionLink("Edit", "Edit", new { id = Model.SoPhieuXuat }) |

@Html.ActionLink("Back to List", "Index")

</p>

Delete

Trang 63
3.4 Bảng Khách

Mã Lệnh

KhachControllers

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QuanLyBanHang.Models;

namespace QuanLyBanHang.Controllers
{
public class KhachController : Controller
{
KhachEntities db = new KhachEntities();
// GET: Default
public ActionResult Index()
{
var lstdt = from dt in db.Khaches select dt;
return View(lstdt);
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(Khach dt)

Trang 64
{
db.Khaches.Add(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
Khach dt = db.Khaches.Find(id);
db.Khaches.Remove(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(String id)
{
Khach dt = db.Khaches.Find(id);
return View(dt);
}
[HttpPost]
public ActionResult Edit(FormCollection f)
{
String MaKhach = f.Get("MaKhach");
Khach dt = db.Khaches.Find(MaKhach);
dt.TenKhach = f.Get("TenKhach");
dt.DiaChi = f.Get("DiaChi");
dt.SoDienThoai = f.Get("SoDienThoai");
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Details(String id)
{
var lstdt = db.Khaches.Select(p => p).Where(p => p.MaKhach ==
id).FirstOrDefault();
return View(lstdt);
}
}
}

KhachIndex
@model IEnumerable<QuanLyBanHang.Models.Khach>

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<style>
html,
body {
height: 100%;
}

body {
margin: 0;
background: linear-gradient(45deg, #49a09d, #5f2c82);
font-family: sans-serif;
font-weight: 100;

Trang 65
}

.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

table {
width: 800px;
border-collapse: collapse;
overflow: hidden;
box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

th,
td {
padding: 15px;
background-color: rgba(255,255,255,0.2);
color: #fff;
}

th {
text-align: left;
}

thead {
th;

{
background-color: #55608f;
}

tbody {
tr;

{
&:hover;

{
background-color: rgba(255,255,255,0.3);
}

td {
position: relative;
&:hover;

{
&:before;

{
content: "";
position: absolute;
left: 0;
right: 0;
top: -9999px;
bottom: -9999px;
background-color: rgba(255,255,255,0.2);
z-index: -1;

Trang 66
}

}
}
}
</style>
</head>
<body>
<div class="container">
<h1>
Bảng Khách
</h1>
<table>
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.MaKhach)
</th>
<th>
@Html.DisplayNameFor(model => model.TenKhach)
</th>
<th>
@Html.DisplayNameFor(model => model.DiaChi)
</th>
<th>
@Html.DisplayNameFor(model => model.SoDienThoai)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.MaKhach)
</td>
<td>
@Html.DisplayFor(modelItem => item.TenKhach)
</td>
<td>
@Html.DisplayFor(modelItem => item.DiaChi)
</td>
<td>
@Html.DisplayFor(modelItem => item.SoDienThoai)
</td>

<td>
@Html.ActionLink("Create New", "Create") |
@Html.ActionLink("Edit", "Edit", new { id =
item.MaKhach }) |
@Html.ActionLink("Details", "Details", new { id =
item.MaKhach }) |
@Html.ActionLink("Delete", "Delete", new { id =
item.MaKhach })
</td>
</tr>
}
</tbody>

</table>
</div>
</body>
</html>

Trang 67
Creat

Mã Lệnh
@model QuanLyBanHang.Models.Khach

@{
ViewBag.Title = "Create";
}

<h2>Create</h2>

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>Khach</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MaKhach, htmlAttributes: new { @class =
"control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MaKhach, new { htmlAttributes = new
{ @class = "form-control" } })

Trang 68
@Html.ValidationMessageFor(model => model.MaKhach, "", new { @class =
"text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.TenKhach, htmlAttributes: new { @class =
"control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.TenKhach, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TenKhach, "", new { @class =
"text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.DiaChi, htmlAttributes: new { @class =
"control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DiaChi, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DiaChi, "", new { @class =
"text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.SoDienThoai, htmlAttributes: new { @class =
"control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoDienThoai, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoDienThoai, "", new
{ @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-default" />
</div>
</div>
</div>
}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Edit

Trang 69
Mã Lệnh

@model QuanLyBanHang.Models.Khach

@{
ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>Khach</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MaKhach, htmlAttributes: new { @class =
"control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MaKhach, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MaKhach, "", new { @class =
"text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.TenKhach, htmlAttributes: new { @class =
"control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.TenKhach, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TenKhach, "", new { @class =
"text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.DiaChi, htmlAttributes: new { @class =
"control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DiaChi, new { htmlAttributes = new
{ @class = "form-control" } })

Trang 70
@Html.ValidationMessageFor(model => model.DiaChi, "", new { @class =
"text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.SoDienThoai, htmlAttributes: new { @class =
"control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoDienThoai, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoDienThoai, "", new
{ @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default" />
</div>
</div>
</div>
}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Details

Mã Lệnh
@model QuanLyBanHang.Models.Khach

@{
ViewBag.Title = "Details";
}

<h2>Details</h2>

Trang 71
<div>
<h4>Khach</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.MaKhach)
</dt>

<dd>
@Html.DisplayFor(model => model.MaKhach)
</dd>

<dt>
@Html.DisplayNameFor(model => model.TenKhach)
</dt>

<dd>
@Html.DisplayFor(model => model.TenKhach)
</dd>

<dt>
@Html.DisplayNameFor(model => model.DiaChi)
</dt>

<dd>
@Html.DisplayFor(model => model.DiaChi)
</dd>

<dt>
@Html.DisplayNameFor(model => model.SoDienThoai)
</dt>

<dd>
@Html.DisplayFor(model => model.SoDienThoai)
</dd>

</dl>
</div>
<p>
@Html.ActionLink("Edit", "Edit", new { id = Model.MaKhach }) |
@Html.ActionLink("Back to List", "Index")
</p>

Delete

Trang 72
3.5 Bảng Hãng Sản Xuất

Mã Lệnh

HangSanXuatControllers

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QuanLyBanHang.Models;

namespace QuanLyBanHang.Controllers
{
public class HangSanXuatController : Controller
{
HangSanXuatEntities db = new HangSanXuatEntities();
// GET: Default
public ActionResult Index()
{
var lstdt = from dt in db.HangSanXuats select dt;
return View(lstdt);
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(HangSanXuat dt)
{
db.HangSanXuats.Add(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
HangSanXuat dt = db.HangSanXuats.Find(id);
db.HangSanXuats.Remove(dt);
db.SaveChanges();

Trang 73
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(String id)
{
HangSanXuat dt = db.HangSanXuats.Find(id);
return View(dt);
}
[HttpPost]
public ActionResult Edit(FormCollection f)
{
String MaHangSX = f.Get("MaHangSX");
HangSanXuat dt = db.HangSanXuats.Find(MaHangSX);
dt.TenHangSX = f.Get("TenHangSX");
dt.DiaChiVPChinhTaiVN = f.Get("DiaChiVPChinhTaiVN");
dt.SoDienThoai = f.Get("SoDienThoai");
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Details(String id)
{
var lstdt = db.HangSanXuats.Select(p => p).Where(p =>
p.MaHangSX == id).FirstOrDefault();
return View(lstdt);
}
}
}

HangSanXuatIdex
@model IEnumerable<QuanLyBanHang.Models.HangSanXuat>

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<style>
html,
body {
height: 100%;
}

body {
margin: 0;
background: linear-gradient(45deg, #49a09d, #5f2c82);

Trang 74
font-family: sans-serif;
font-weight: 100;
}

.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

table {
width: 800px;
border-collapse: collapse;
overflow: hidden;
box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

th,
td {
padding: 15px;
background-color: rgba(255,255,255,0.2);
color: #fff;
}

th {
text-align: left;
}

thead {
th;

{
background-color: #55608f;
}

tbody {
tr;

{
&:hover;

{
background-color: rgba(255,255,255,0.3);
}

td {
position: relative;
&:hover;

Trang 75
&:before;

{
content: "";
position: absolute;
left: 0;
right: 0;
top: -9999px;
bottom: -9999px;
background-color: rgba(255,255,255,0.2);
z-index: -1;
}

}
}
}
</style>
</head>
<body>
<div class="container">
<h1>
Bảng Hãng Sản Xuất
</h1>
<table>
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.MaHangSX)
</th>
<th>
@Html.DisplayNameFor(model => model.TenHangSX)
</th>
<th>
@Html.DisplayNameFor(model =>
model.DiaChiVPChinhTaiVN)
</th>
<th>
@Html.DisplayNameFor(model => model.SoDienThoai)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.MaHangSX)
</td>
<td>
@Html.DisplayFor(modelItem => item.TenHangSX)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.DiaChiVPChinhTaiVN)

Trang 76
</td>
<td>
@Html.DisplayFor(modelItem =>
item.SoDienThoai)
</td>

<td>
@Html.ActionLink("Create New", "Create") |
@Html.ActionLink("Edit", "Edit", new { id =
item.MaHangSX }) |
@Html.ActionLink("Details", "Details", new
{ id = item.MaHangSX }) |
@Html.ActionLink("Delete", "Delete", new { id
= item.MaHangSX })
</td>
</tr>
}
</tbody>

</table>
</div>
</body>
</html>

Creat

Mã Lệnh

Trang 77
@model QuanLyBanHang.Models.HangSanXuat

@{
ViewBag.Title = "Create";
}

<h2>Create</h2>

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>HangSanXuat</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MaHangSX, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MaHangSX, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MaHangSX, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.TenHangSX, htmlAttributes: new {
@class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.TenHangSX, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TenHangSX, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.DiaChiVPChinhTaiVN,
htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DiaChiVPChinhTaiVN, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model =>
model.DiaChiVPChinhTaiVN, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.SoDienThoai, htmlAttributes: new
{ @class = "control-label col-md-2" })

Trang 78
<div class="col-md-10">
@Html.EditorFor(model => model.SoDienThoai, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoDienThoai, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-
default" />
</div>
</div>
</div>
}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Edit

Mã Lệnh
@model QuanLyBanHang.Models.HangSanXuat

@{
ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm())

Trang 79
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>HangSanXuat</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MaHangSX, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MaHangSX, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MaHangSX, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.TenHangSX, htmlAttributes: new {
@class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.TenHangSX, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TenHangSX, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.DiaChiVPChinhTaiVN,
htmlAttributes: new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DiaChiVPChinhTaiVN, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model =>
model.DiaChiVPChinhTaiVN, "", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.SoDienThoai, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoDienThoai, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoDienThoai, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default"
/>

Trang 80
</div>
</div>
</div>
}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Details

Mã Lệnh
@model QuanLyBanHang.Models.HangSanXuat

@{
ViewBag.Title = "Details";
}

<h2>Details</h2>

<div>
<h4>HangSanXuat</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.MaHangSX)
</dt>

<dd>
@Html.DisplayFor(model => model.MaHangSX)

Trang 81
</dd>

<dt>
@Html.DisplayNameFor(model => model.TenHangSX)
</dt>

<dd>
@Html.DisplayFor(model => model.TenHangSX)
</dd>

<dt>
@Html.DisplayNameFor(model => model.DiaChiVPChinhTaiVN)
</dt>

<dd>
@Html.DisplayFor(model => model.DiaChiVPChinhTaiVN)
</dd>

<dt>
@Html.DisplayNameFor(model => model.SoDienThoai)
</dt>

<dd>
@Html.DisplayFor(model => model.SoDienThoai)
</dd>

</dl>
</div>
<p>
@Html.ActionLink("Edit", "Edit", new { id = Model.MaHangSX }) |
@Html.ActionLink("Back to List", "Index")
</p>

Delete

Trang 82
3.6 Bảng Nơi Bảo Hành

Mã Lệnh

NoiBaoHangControllers

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using QuanLyBanHang.Models;

namespace QuanLyBanHang.Controllers
{
public class NoiBaoHanhController : Controller
{
NoiBaoHanhEntities db = new NoiBaoHanhEntities();
// GET: Default
public ActionResult Index()
{
var lstdt = from dt in db.NoiBaoHanhs select dt;
return View(lstdt);
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(NoiBaoHanh dt)
{
db.NoiBaoHanhs.Add(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
NoiBaoHanh dt = db.NoiBaoHanhs.Find(id);
db.NoiBaoHanhs.Remove(dt);

Trang 83
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(String id)
{
NoiBaoHanh dt = db.NoiBaoHanhs.Find(id);
return View(dt);
}
[HttpPost]
public ActionResult Edit(FormCollection f)
{
String MaHangSX = f.Get("MaHangSX");
NoiBaoHanh dt = db.NoiBaoHanhs.Find(MaHangSX);
dt.SoTT = f.Get("SoTT");
dt.TenDiemBaoHanh = f.Get("TenDiemBaoHanh");
dt.DiaChi = f.Get("DiaChi");
dt.SoDienThoai = f.Get("SoDienThoai");
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Details(String id)
{
var lstdt = db.NoiBaoHanhs.Select(p => p).Where(p =>
p.MaHangSX == id).FirstOrDefault();
return View(lstdt);
}
}
}

NoiBaoHanhIdex

@model IEnumerable<QuanLyBanHang.Models.NoiBaoHanh>

@{
Layout = null;
}

<!DOCTYPE html>

<html>
<head>
<meta name="viewport" content="width=device-width" />
<title>Index</title>
<style>
html,
body {
height: 100%;
}

body {
margin: 0;

Trang 84
background: linear-gradient(45deg, #49a09d, #5f2c82);
font-family: sans-serif;
font-weight: 100;
}

.container {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
}

table {
width: 800px;
border-collapse: collapse;
overflow: hidden;
box-shadow: 0 0 20px rgba(0,0,0,0.1);
}

th,
td {
padding: 15px;
background-color: rgba(255,255,255,0.2);
color: #fff;
}

th {
text-align: left;
}

thead {
th;

{
background-color: #55608f;
}

tbody {
tr;

{
&:hover;

{
background-color: rgba(255,255,255,0.3);
}

td {
position: relative;
&:hover;

Trang 85
{
&:before;

{
content: "";
position: absolute;
left: 0;
right: 0;
top: -9999px;
bottom: -9999px;
background-color: rgba(255,255,255,0.2);
z-index: -1;
}

}
}
}
</style>
</head>
<body>
<div class="container">
<h1>
Bảng Nơi Bảo Hành
</h1>
<table>
<thead>
<tr>
<th>
@Html.DisplayNameFor(model => model.MaHangSX)
</th>
<th>
@Html.DisplayNameFor(model => model.SoTT)
</th>
<th>
@Html.DisplayNameFor(model =>
model.TenDiemBaoHanh)
</th>
<th>
@Html.DisplayNameFor(model => model.DiaChi)
</th>
<th>
@Html.DisplayNameFor(model => model.SoDienThoai)
</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var item in Model)
{
<tr>
<td>
@Html.DisplayFor(modelItem => item.MaHangSX)
</td>
<td>
@Html.DisplayFor(modelItem => item.SoTT)

Trang 86
</td>
<td>
@Html.DisplayFor(modelItem =>
item.TenDiemBaoHanh)
</td>
<td>
@Html.DisplayFor(modelItem => item.DiaChi)
</td>
<td>
@Html.DisplayFor(modelItem =>
item.SoDienThoai)
</td>

<td>
@Html.ActionLink("Create New", "Create") |
@Html.ActionLink("Edit", "Edit", new { id =
item.MaHangSX }) |
@Html.ActionLink("Details", "Details", new
{ id = item.MaHangSX }) |
@Html.ActionLink("Delete", "Delete", new { id
= item.MaHangSX })
</td>
</tr>
}
</tbody>

</table>
</div>
</body>
</html>

Creat

Mã Lệnh
@model QuanLyBanHang.Models.NoiBaoHanh

@{

Trang 87
ViewBag.Title = "Create";
}

<h2>Create</h2>

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>NoiBaoHanh</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MaHangSX, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MaHangSX, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MaHangSX, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.SoTT, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoTT, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoTT, "", new
{ @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.TenDiemBaoHanh, htmlAttributes:
new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.TenDiemBaoHanh, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TenDiemBaoHanh,
"", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.DiaChi, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.DiaChi, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DiaChi, "", new
{ @class = "text-danger" })

Trang 88
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.SoDienThoai, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoDienThoai, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoDienThoai, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Create" class="btn btn-
default" />
</div>
</div>
</div>
}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Edit

Trang 89
Mã Lệnh
@model QuanLyBanHang.Models.NoiBaoHanh

@{
ViewBag.Title = "Edit";
}

<h2>Edit</h2>

@using (Html.BeginForm())
{
@Html.AntiForgeryToken()

<div class="form-horizontal">
<h4>NoiBaoHanh</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
@Html.LabelFor(model => model.MaHangSX, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.MaHangSX, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MaHangSX, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.SoTT, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoTT, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoTT, "", new
{ @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.TenDiemBaoHanh, htmlAttributes:
new { @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.TenDiemBaoHanh, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TenDiemBaoHanh,
"", new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.DiaChi, htmlAttributes: new
{ @class = "control-label col-md-2" })

Trang 90
<div class="col-md-10">
@Html.EditorFor(model => model.DiaChi, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DiaChi, "", new
{ @class = "text-danger" })
</div>
</div>

<div class="form-group">
@Html.LabelFor(model => model.SoDienThoai, htmlAttributes: new
{ @class = "control-label col-md-2" })
<div class="col-md-10">
@Html.EditorFor(model => model.SoDienThoai, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SoDienThoai, "",
new { @class = "text-danger" })
</div>
</div>

<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Save" class="btn btn-default"
/>
</div>
</div>
</div>
}

<div>
@Html.ActionLink("Back to List", "Index")
</div>

@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}

Details

Trang 91
Mã Lệnh
@model QuanLyBanHang.Models.NoiBaoHanh

@{
ViewBag.Title = "Details";
}

<h2>Details</h2>

<div>
<h4>NoiBaoHanh</h4>
<hr />
<dl class="dl-horizontal">
<dt>
@Html.DisplayNameFor(model => model.MaHangSX)
</dt>

<dd>
@Html.DisplayFor(model => model.MaHangSX)
</dd>

<dt>
@Html.DisplayNameFor(model => model.SoTT)
</dt>

<dd>
@Html.DisplayFor(model => model.SoTT)
</dd>

<dt>
@Html.DisplayNameFor(model => model.TenDiemBaoHanh)
</dt>

<dd>
@Html.DisplayFor(model => model.TenDiemBaoHanh)
</dd>

Trang 92
<dt>
@Html.DisplayNameFor(model => model.DiaChi)
</dt>

<dd>
@Html.DisplayFor(model => model.DiaChi)
</dd>

<dt>
@Html.DisplayNameFor(model => model.SoDienThoai)
</dt>

<dd>
@Html.DisplayFor(model => model.SoDienThoai)
</dd>

</dl>
</div>
<p>
@Html.ActionLink("Edit", "Edit", new { id = Model.MaHangSX }) |
@Html.ActionLink("Back to List", "Index")
</p>

Delete

Trang 93
TÀI LIỆU THAM KHẢO

Trang 94

You might also like