Professional Documents
Culture Documents
36 - 09ĐHCNTT1 - 0950080003 - Nguyễn Văn Tú - LẬP TRÌNH WED
36 - 09ĐHCNTT1 - 0950080003 - Nguyễn Văn Tú - LẬP TRÌNH WED
TIỂU LUẬN
HỌC PHẦN: LẬP TRÌNH WED
1
2.6.1.Giao diện chức năng chỉnh sửa:.......................................................................................28
2.6.2. Mã lệnh Controller chức năng chỉnh sửa:.......................................................................28
2.6.3 Mã lệnh Edit chức năng chỉnh sửa:..................................................................................28
2.7.Chức năng thêm:..............................................................................................................................30
2.7.1.Giao diện chức năng thêm:...............................................................................................30
2.7.2.Mã lệnh Controller chức năng thêm:...............................................................................30
2.7.3.Mã lệnh Create chức năng chỉnh sửa:..............................................................................31
2.8.Chức năng xóa:.................................................................................................................................32
2.8.1. Giao diện chức năng xóa:................................................................................................32
2.8.2.Mã lệnh Controller chức năng xóa:..................................................................................33
2.9.Chức năng hiển thị chi tiết:...........................................................................................................33
2.9.1.Giao diện chức năng hiển thị chi tiết:...............................................................................33
2.9.2.Mã lệnh Controller chức năng hiển thị chi tiết:................................................................33
2.9.3.Mã lệnh Details Chức năng hiển thị chị tiết:....................................................................33
3.Bảng Công ty:...................................................................................................34
3.1.Thiết kế Form:...................................................................................................................................35
3.2. Mã lệnh theo HTML Server Control (Cách 1):.......................................................................35
3.3. Mã lệnh Web server control:........................................................................................................36
3.4.Mã lệnh Controller:.........................................................................................................................37
3.5.Chức năng hiển thị:.........................................................................................................................39
3.5.1.Giao diện chức năng hiển thị:...........................................................................................39
3.5.2.Mã lệnh Controller chức năng hiển thị:............................................................................39
3.5.3.Mã lệnh Index chức năng hiển thị:....................................................................................39
3.6.Chức năng chỉnh sửa:.....................................................................................................................41
3.6.1.Giao diện chức năng chỉnh sửa:.......................................................................................41
3.6.2. Mã lệnh Controller chức năng chỉnh sửa:.......................................................................41
3.6.3 Mã lệnh Edit chức năng chỉnh sửa:..................................................................................41
3.7.Chức năng thêm:..............................................................................................................................44
3.7.1.Giao diện chức năng thêm:...............................................................................................44
3.7.2.Mã lệnh Controller chức năng thêm:...............................................................................44
3.7.3.Mã lệnh Create chức năng thêm :.....................................................................................44
3.8.Chức năng xóa:.................................................................................................................................46
3.8.1. Giao diện chức năng xóa:................................................................................................46
3.8.2.Mã lệnh Controller chức năng xóa:..................................................................................46
2
3.9.Chức năng hiển thị chi tiết:...........................................................................................................47
3.9.1.Giao diện chức năng hiển thị chi tiết:...............................................................................47
3.9.2.Mã lệnh Controller chức năng hiển thị chi tiết:................................................................47
3.9.3.Mã lệnh Details Chức năng hiển thị chị tiết:....................................................................47
4.Bảng Diễn biến giá:..........................................................................................48
4.1.Thiết kế Form:...................................................................................................................................49
4.2. Mã lệnh theo HTML Server Control (Cách 1):.......................................................................49
4.3. Mã lệnh Web server control:........................................................................................................50
4.4.Mã lệnh Controller:.........................................................................................................................51
4.5.Chức năng hiển thị:.........................................................................................................................52
4.5.1.Giao diện chức năng hiển thị:...........................................................................................52
4.5.2.Mã lệnh Controller:..........................................................................................................52
4.5.3.Mã lệnh Index chức năng hiển thị:....................................................................................53
4.6.Chức năng chỉnh sửa:.....................................................................................................................54
4.6.1.Giao diện chức năng chỉnh sửa:.......................................................................................54
4.6.2. Mã lệnh Controller chức năng chỉnh sửa:.......................................................................54
4.6.3 Mã lệnh Edit chức năng chỉnh sửa:..................................................................................54
4.7.Chức năng thêm:..............................................................................................................................56
4.7.1.Giao diện chức năng thêm:...............................................................................................56
4.7.2.Mã lệnh Controller chức năng thêm:...............................................................................56
4.7.3.Mã lệnh Create chức năng thêm:......................................................................................56
4.8.Chức năng xóa:.................................................................................................................................58
4.8.1. Giao diện chức năng xóa:................................................................................................58
4.8.2.Mã lệnh Controller chức năng xóa:..................................................................................58
4.9.Chức năng hiển thị chi tiết:...........................................................................................................58
4.9.1.Giao diện chức năng hiển thị chi tiết:...............................................................................58
4.9.2.Mã lệnh Controller chức năng hiển thị chi tiết:................................................................58
4.9.3.Mã lệnh Details Chức năng hiển thị chị tiết:....................................................................59
5.Bảng Giao dịch:...............................................................................................59
5.1.Thiết Kế form:...................................................................................................................................60
5.2. Mã lệnh theo HTML Server Control (Cách 1):.......................................................................60
5.3. Mã lệnh Web server control:........................................................................................................62
5.4.Mã lệnh Controller:.........................................................................................................................63
5.5.Chức năng hiển thị:.........................................................................................................................65
3
5.5.1.Giao diện chức năng hiển thị:...........................................................................................65
5.5.2.Mã lệnh Controller:..........................................................................................................65
5.5.3.Mã lệnh Index chức năng hiển thị:....................................................................................65
5.6.Chức năng chỉnh sửa:.....................................................................................................................67
5.6.1.Giao diện chức năng chỉnh sửa:...............................................................................................67
5.6.2. Mã lệnh Controller chức năng chỉnh sửa:.......................................................................67
5.6.3 Mã lệnh Edit chức năng chỉnh sửa:..................................................................................68
5.7.Chức năng thêm:..............................................................................................................................70
5.7.1.Giao diện chức năng thêm:...............................................................................................70
5.7.2.Mã lệnh Controller chức năng thêm:...............................................................................70
5.7.3.Mã lệnh Create chức năng thêm:......................................................................................71
5.8.Chức năng xóa:.................................................................................................................................73
5.8.1. Giao diện chức năng xóa:................................................................................................73
5.8.2.Mã lệnh Controller chức năng xóa:..................................................................................73
5.9.Chức năng hiển thị chi tiết:...........................................................................................................73
5.9.1.Giao diện chức năng hiển thị chi tiết:...............................................................................73
5.9.2.Mã lệnh Controller chức năng hiển thị chi tiết:................................................................74
5.9.3.Mã lệnh Details Chức năng hiển thị chị tiết:....................................................................74
6. Bảng Khách hàng mua...................................................................................75
6.1. Thiết kế form:...................................................................................................................................75
6.2. Mã lệnh theo HTML Server Control (Cách 1):.......................................................................75
6.3. Mã lệnh Web server control:........................................................................................................77
6.4.Mã lệnh Controller:.........................................................................................................................78
6.5.Chức năng hiển thị:.........................................................................................................................79
6.5.1.Giao diện chức năng hiển thị:...........................................................................................79
6.5.2.Mã lệnh Controller:..........................................................................................................79
6.5.3.Mã lệnh Index chức năng hiển thị:....................................................................................80
2.6.Chức năng chỉnh sửa:.....................................................................................................................81
2.6.1.Giao diện chức năng chỉnh sửa:.......................................................................................81
2.6.2. Mã lệnh Controller chức năng chỉnh sửa:.......................................................................81
2.6.3 Mã lệnh Edit chức năng chỉnh sửa:..................................................................................82
2.7.Chức năng thêm:..............................................................................................................................84
2.7.1.Giao diện chức năng thêm:...............................................................................................84
2.7.2.Mã lệnh Controller chức năng thêm:...............................................................................84
4
2.7.3.Mã lệnh Create chức năng thêm:......................................................................................84
2.8.Chức năng xóa:.................................................................................................................................86
2.8.1. Giao diện chức năng xóa:................................................................................................86
2.8.2.Mã lệnh Controller chức năng xóa:..................................................................................86
2.9.Chức năng hiển thị chi tiết:...........................................................................................................87
2.9.1.Giao diện chức năng hiển thị chi tiết:.................................................................................................87
2.9.2.Mã lệnh Controller chức năng hiển thị chi tiết:................................................................87
2.9.3.Mã lệnh Details Chức năng hiển thị chị tiết:....................................................................87
5
LỜI MỞ ĐẦU
Thị trường chứng khoán Việt Nam mới chào đời đầu năm 2000. Thuật ngữ “Thị trường chứng
khoán” còn tương đối mới lạ so với công chúng Việt Nam. Trong lúc đó ở nhiều nước trên toàn cầu,
thị trường chứng khoán đã tiến triển rất nhộn nhịp. Đầu tư vào thị trường chứng khoán đã trở nên
trọng yếu so với mọi người.
Để gia nhập vào thị trường chứng khoán, mọi người đều cần phải có các tri thức khẳng định về thị
trường chứng khoán. Thị trường chứng khoán chỉ có thể tiến triển được nếu có sự gia nhập ngày
càng đông của những người có đầy đủ tri thức về thị trường chứng khoán. Cho nên, tri thức của mọi
người dân về thị trường chứng khoán ở Việt Nam cần được chuyên sâu. Thị trường chứng khoán có
sự cuốn hút vốn có của nó. Nó chẳng những trọng yếu so với nền kinh tế của một nước mà nó còn
trọng yếu so với mỗi người bởi vì khả năng đầu tư sinh lợi của nó. Chính vì như vậy, mỗi người tuỳ
theo điều kiện, khả năng của mình mà cần phải tiếp cận thật nhanh để gia nhập đầu tư có hiệu quả
vào thị trường chứng khoán. Chính các hoạt động đó sẽ góp thêm phần mang thị trường chứng
khoán Việt Nam tiến triển.Do đó em muốn chọn đề tài “Quản lý thị trường chứng khoán ” nhằm tạo
ra trang wed để cho mọi người tin dùng cũng như là để dễ hơn trong việc quản lý về chứng khoán
6
MÔ HÌNH DỮ LIỆU
Models
7
MÔ TẢ CHI TIẾT CHO CÁC BẢNG DỮ LIỆU
1.Bảng Khách hàng:
STT TÊN CỘT KIỂU DỮ ĐỘ DÀI
LIỆU
1 Makh int 10
2 Tenkh nchar 50
3 Diachi nchar 50
4 Dienthoai int 20
5 Thunhap int 10
1.1.Thiết kế Form:
<html lang="en-US">
<head>
<title>
TIỂU LUẬN KẾT THÚC MÔN
</title>
</head>
<body>
<br>
<CENTER>
<form >
<table>
<tr><th colspan="3">THÔNG TIN KHÁCH HÀNG</th></tr>
<tr>
<td>Mã khách hàng</td>
<td>:</td>
<td> <input type="text"/></td>
</tr>
8
<tr>
<td>Tên khách hàng</td>
<td>:</td>
<td> <input type="text"/></td>
</tr>
<tr>
<td>Địa chỉ </td>
<td>:</td>
<td> <input type="text"/></td>
</tr>
<tr>
<td>Điện thoại </td>
<td>:</td>
<td> <input type="text"/></td>
</tr>
<tr>
<td>Thu nhập </td>
<td>:</td>
<td> <input type="text"/></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" value="Lưu lại" />
<input type="submit" value="Đóng" />
</td>
</tr>
</table>
</form>
</CENTER>
</br>
</body>
</html>
</table>
<br>
<div style="text-align: center;">
<button type="">Đóng</button>
<button type="submit" runat=”server”>Lưu lại</button>
</div>
</form>
</div>
10
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TIEULUAN36.Models;
namespace TIEULUAN36.Controllers
{
public class KHACHHANGController : Controller
{
QUANLYTHITRUONGCHUNGKHOANEntities db = new
QUANLYTHITRUONGCHUNGKHOANEntities();
// GET: Default
public ActionResult Index()
{
var lstkh = from kh in db.KHACHHANGs select kh;
return View(lstkh);
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(KHACHHANG kh)
{
db.KHACHHANGs.Add(kh);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
KHACHHANG kh = db.KHACHHANGs.Find(id);
db.KHACHHANGs.Remove(kh);
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(String id)
{
var kh = db.KHACHHANGs.Find(id);
return View(kh);
}
[HttpPost]
public ActionResult Edit(KHACHHANG kh)
{
var updatekh= db.KHACHHANGs.Find(kh.MAKH);
updatekh.MAKH = kh.MAKH;
updatekh.TENKH = kh.TENKH;
updatekh.DIACHI = kh.DIACHI;
updatekh.DIENTHOAI = kh.DIENTHOAI;
updatekh.THUNHAP = kh.THUNHAP;
11
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Details(String id)
{
var lstkh= db.KHACHHANGs.Select(p => p).Where(p => p.MAKH ==
id).FirstOrDefault();
return View(lstkh);
}
}
}
@model IEnumerable<TIEULUAN36.Models.KHACHHANG>
@{
12
ViewBag.Title = "Index";
}
<p>
@Html.ActionLink("Tạo mới ", "Create")
</p>
<table class="table">
<tr>
<th>
Mã khách hàng
</th>
<th>
Tên khách hàng
</th>
<th>
Địa chỉ
</th>
<th>
Điện thoại
</th>
<th>
Thu nhập
</th>
<th></th>
</tr>
db.SaveChanges();
return RedirectToAction("Index");
}
@{
ViewBag.Title = "Edit";
14
}
<h2>Chỉnh sửa</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Khách hàng</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.MAKH)
<div class="form-group">
<div class="col-md-10">
Mã khách hàng
@Html.EditorFor(model => model.MAKH, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MAKH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Tên khách hàng
@Html.EditorFor(model => model.TENKH, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TENKH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Địa chỉ
@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">
<div class="col-md-10">
Điện thoại
15
@Html.EditorFor(model => model.DIENTHOAI, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DIENTHOAI, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Thu nhập
@Html.EditorFor(model => model.THUNHAP, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.THUNHAP, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Lưu" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
16
1.7.Chức năng thêm:
1.7.1.Giao diện chức năng thêm:
@{
ViewBag.Title = "Create";
}
<h2>Tạo Mới</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Khách hàng</h4>
<hr />
17
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<div class="col-md-10">
Mã khách hàng
@Html.EditorFor(model => model.MAKH, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MAKH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Tên khách hàng
@Html.EditorFor(model => model.TENKH, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TENKH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Địa chỉ
@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">
<div class="col-md-10">
Điện thoại
@Html.EditorFor(model => model.DIENTHOAI, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DIENTHOAI, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Thu nhập
@Html.EditorFor(model => model.THUNHAP, new { htmlAttributes =
new { @class = "form-control" } })
18
@Html.ValidationMessageFor(model => model.THUNHAP, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Tạo mới" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
19
1.9. Chức năng hiển thị chi tiết:
1.9.1. Giao diện chức năng chi tiết:
@{
ViewBag.Title = "Details";
}
<div>
<h4>Khách hàng</h4>
<hr />
<dl class="dl-horizontal">
<dt>
Mã khách hàng
</dt>
<dd>
@Html.DisplayFor(model => model.MAKH)
</dd>
<dt>
Tên khách hàng
</dt>
<dd>
@Html.DisplayFor(model => model.TENKH)
20
</dd>
<dt>
Địa chỉ
</dt>
<dd>
@Html.DisplayFor(model => model.DIACHI)
</dd>
<dt>
Điện thoại
</dt>
<dd>
@Html.DisplayFor(model => model.DIENTHOAI)
</dd>
<dt>
Thu nhập
</dt>
<dd>
@Html.DisplayFor(model => model.THUNHAP)
</dd>
</dl>
</div>
<p>
@Html.ActionLink("Chỉnh sửa", "Edit", new { id = Model.MAKH }) |
@Html.ActionLink("Back to List", "Index")
</p>
21
2.1.Thiết kế form:
<html lang="en-US">
<head>
<title>
TIỂU LUẬN KẾT THÚC MÔN
</title>
</head>
<body>
<br>
<CENTER>
<table>
<form>
<tr><th colspan="3">THÔNG TIN NHÀ MÔ GIỚI</th></tr>
<tr>
<td>Mã nhà mô giới</td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td>Tên nhà mô giới</td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td>Địa chỉ </td>
<td>:</td>
<td>
<input type="text"/>
22
</td>
</tr>
<tr>
<td>Điện thoại </td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" value="Lưu lại" />
<input type="submit" value="Đóng" />
</td>
</tr>
</form>
</table>
</CENTER>
</br>
</body>
</html>
</table>
<br>
<div style="text-align: center;">
<button type="">Đóng</button>
<button type="submit" runat=”server”>Lưu lại</button>
</div>
</form>
</div>
namespace TIEULUAN36.Controllers
{
public class NAHMOIGIOIController : Controller
{
QUANLYTHITRUONGCHUNGKHOANEntities db = new
QUANLYTHITRUONGCHUNGKHOANEntities();
// GET: Default
public ActionResult Index()
24
{
var lstdt = from dt in db.NHAMOIGIOIs select dt;
return View(lstdt);
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(NHAMOIGIOI dt)
{
db.NHAMOIGIOIs.Add(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
NHAMOIGIOI dt = db.NHAMOIGIOIs.Find(id);
db.NHAMOIGIOIs.Remove(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(String id)
{
var dt = db.NHAMOIGIOIs.Find(id);
return View(dt);
}
[HttpPost]
public ActionResult Edit(NHAMOIGIOI dt)
{
var updatedt = db.NHAMOIGIOIs.Find(dt.MANHAMOIGIOI);
updatedt.MANHAMOIGIOI = dt.MANHAMOIGIOI;
updatedt.TENNHAMOIGIOI = dt.TENNHAMOIGIOI;
updatedt.DIACHI = dt.DIACHI;
updatedt.DIENTHOAI = dt.DIENTHOAI;
db.SaveChanges();
return RedirectToAction("Index");
}
25
2.5.Chức năng hiển thị:
2.5.1.Giao diện chức năng hiển thị:
@{
ViewBag.Title = "Index";
}
<p>
@Html.ActionLink("Tạo mới ", "Create")
</p>
<table class="table">
<tr>
<th>
Mã nhà môi giới
</th>
26
<th>
Tên nhà môi giới
</th>
<th>
Địa chỉ
</th>
<th>
Điện thoại
</th>
<th></th>
</tr>
</table>
27
2.6.Chức năng chỉnh sửa:
2.6.1.Giao diện chức năng chỉnh sửa:
db.SaveChanges();
return RedirectToAction("Index");
}
2.6.3 Mã lệnh Edit chức năng chỉnh sửa:
@model TIEULUAN36.Models.NHAMOIGIOI
@{
ViewBag.Title = "Edit";
}
28
<h2>Chỉnh sửa</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Nhà môi giới</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.MANHAMOIGIOI)
<div class="form-group">
<div class="col-md-10">
Mã nhà môi giới
@Html.EditorFor(model => model.MANHAMOIGIOI, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MANHAMOIGIOI, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Tên nhà môi giới
@Html.EditorFor(model => model.TENNHAMOIGIOI, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TENNHAMOIGIOI, "",
new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Địa chỉ
@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">
<div class="col-md-10">
Điện thoại
@Html.EditorFor(model => model.DIENTHOAI, new { htmlAttributes
= new { @class = "form-control" } })
29
@Html.ValidationMessageFor(model => model.DIENTHOAI, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Lưu" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
30
db.SaveChanges();
return RedirectToAction("Index");
}
2.7.3.Mã lệnh Create chức năng chỉnh sửa:
@model TIEULUAN36.Models.NHAMOIGIOI
@{
ViewBag.Title = "Create";
}
<h2>Tạo mới</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Nhà môi giới </h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<div class="col-md-10">
Mã nhà môi giới
@Html.EditorFor(model => model.MANHAMOIGIOI, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MANHAMOIGIOI, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Tên nhà môi giới
@Html.EditorFor(model => model.TENNHAMOIGIOI, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TENNHAMOIGIOI, "",
new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Địa chỉ
@Html.EditorFor(model => model.DIACHI, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DIACHI, "", new
{ @class = "text-danger" })
31
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Điện thoại
@Html.EditorFor(model => model.DIENTHOAI, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DIENTHOAI, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Tạo mới " class="btn btn-default"
/>
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
2.8.Chức năng xóa:
2.8.1. Giao diện chức năng xóa:
32
2.8.2.Mã lệnh Controller chức năng xóa:
public ActionResult Delete(String id)
{
NHAMOIGIOI dt = db.NHAMOIGIOIs.Find(id);
db.NHAMOIGIOIs.Remove(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
@{
ViewBag.Title = "Details";
}
<h2>Chi tiết</h2>
<div>
<h4>Nhà môi giới </h4>
<hr />
<dl class="dl-horizontal">
<dt>
33
Mã nhà môi giới
</dt>
<dd>
@Html.DisplayFor(model => model.MANHAMOIGIOI)
</dd>
<dt>
Tên nhà môi giới
</dt>
<dd>
@Html.DisplayFor(model => model.TENNHAMOIGIOI)
</dd>
<dt>
Địa chỉ
</dt>
<dd>
@Html.DisplayFor(model => model.DIACHI)
</dd>
<dt>
Điện thoại
</dt>
<dd>
@Html.DisplayFor(model => model.DIENTHOAI)
</dd>
</dl>
</div>
<p>
@Html.ActionLink("Chỉnh sửa", "Edit", new { id = Model.MANHAMOIGIOI }) |
@Html.ActionLink("Trở lại danh sách", "Index")
</p>
34
3.1.Thiết kế Form:
<html lang="en-US">
<head>
<title>
TIỂU LUẬN KẾT THÚC MÔN
</title>
</head>
<body>
<br>
<CENTER>
<table>
<form>
<tr><th colspan="3">THÔNG TIN NHÀ CÔNG TY</th></tr>
<tr>
<td>Mã công ty</td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td>Tên công ty</td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td>Địa chỉ </td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
35
<tr>
<td>Số lượng cổ phiếu </td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td>Số lượng nhân viên </td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" value="Lưu lại" />
<input type="submit" value="Đóng" />
</td>
</tr>
</form>
</table>
</CENTER>
</br>
</body>
36
<td><asp:TextBox type="text" name="txtMacongty"></td>
</tr>
<tr>
<th>Tên công ty</th>
<td>:</td>
<td><asp:TextBox type="text" name="txtTencongty"></td>
</tr>
<tr>
<th>Địa chỉ</th>
<td>:</td>
<td><asp:TextBox type="text" name="txtDiaChi"></td>
</tr>
<tr>
<th>Số lượng cổ phiếu</th>
<td>:</td>
<td><asp:TextBox type="text" name="txtslcophieu"></td>
</tr>
<tr>
<th>Số lượng nhân viên</th>
<td>:</td>
<td><asp:TextBox type="text" name="txtslnhanvien"></td>
</tr>
</table>
<br>
<div style="text-align: center;">
<button type="">Đóng</button>
<button type="submit" runat=”server”>Lưu lại</button>
</div>
</form>
</div>
37
using System.Linq;
using System.Web;
using System.Web.Mvc;
using TIEULUAN36.Models;
namespace TIEULUAN36.Controllers
{
public class CONGTYController : Controller
{
QUANLYTHITRUONGCHUNGKHOANEntities db = new
QUANLYTHITRUONGCHUNGKHOANEntities();
// GET: Default
public ActionResult Index()
{
var lstct = from ct in db.CONGTies select ct;
return View(lstct);
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(CONGTY ct)
{
db.CONGTies.Add(ct);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
CONGTY ct = db.CONGTies.Find(id);
db.CONGTies.Remove(ct);
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(String id)
{
var ct = db.CONGTies.Find(id);
return View(ct);
}
[HttpPost]
public ActionResult Edit(CONGTY ct)
{
var updatect = db.CONGTies.Find(ct.MACONGTY);
updatect.MACONGTY = ct.MACONGTY;
updatect.TENCONGTY = ct.TENCONGTY;
updatect.DIACHI = ct.DIACHI;
updatect.SLCOPHIEU = ct.SLCOPHIEU;
updatect.SLNHANVIEN = ct.SLNHANVIEN;
38
db.SaveChanges();
return RedirectToAction("Index");
}
@{
ViewBag.Title = "Index";
}
<p>
@Html.ActionLink("Tạo mới", "Create")
</p>
<table class="table">
39
<tr>
<th>
Mã công ty
</th>
<th>
Tên công ty
</th>
<th>
Địa chỉ
</th>
<th>
Số lượng cổ phiếu
</th>
<th>
Số lượng nhân viên
</th>
<th></th>
</tr>
</table>
40
3.6.Chức năng chỉnh sửa:
3.6.1.Giao diện chức năng chỉnh sửa:
db.SaveChanges();
return RedirectToAction("Index");
}
3.6.3 Mã lệnh Edit chức năng chỉnh sửa:
@model TIEULUAN36.Models.CONGTY
@{
ViewBag.Title = "Edit";
41
}
<h2>Chỉnh sửa</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Công ty</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.MACONGTY)
<div class="form-group">
<div class="col-md-10">
Mã công ty
@Html.EditorFor(model => model.MACONGTY, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MACONGTY, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Tên công ty
@Html.EditorFor(model => model.TENCONGTY, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TENCONGTY, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Địa chỉ
@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">
<div class="col-md-10">
42
Số lượng cổ phiếu
@Html.EditorFor(model => model.SLCOPHIEU, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SLCOPHIEU, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Số lượng nhân viên
@Html.EditorFor(model => model.SLNHANVIEN, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SLNHANVIEN, "", new {
@class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Lưu" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
43
3.7.Chức năng thêm:
3.7.1.Giao diện chức năng thêm:
@{
ViewBag.Title = "Create";
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
44
<div class="form-horizontal">
<h4>Công ty</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<div class="col-md-10">
Mã công ty
@Html.EditorFor(model => model.MACONGTY, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MACONGTY, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Tên công ty
@Html.EditorFor(model => model.TENCONGTY, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TENCONGTY, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Địa chỉ
@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">
<div class="col-md-10">
Số lượng cổ phiếu
@Html.EditorFor(model => model.SLCOPHIEU, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SLCOPHIEU, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
45
Số lượng nhân viên
@Html.EditorFor(model => model.SLNHANVIEN, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.SLNHANVIEN, "", new {
@class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Tạo mới " class="btn btn-default"
/>
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
46
}
@{
ViewBag.Title = "Details";
}
<div>
<h4>Công ty</h4>
<hr />
<dl class="dl-horizontal">
<dt>
Mã công ty
</dt>
<dd>
@Html.DisplayFor(model => model.MACONGTY)
</dd>
<dt>
Tên công ty
</dt>
47
<dd>
@Html.DisplayFor(model => model.TENCONGTY)
</dd>
<dt>
Địa chỉ
</dt>
<dd>
@Html.DisplayFor(model => model.DIACHI)
</dd>
<dt>
Số lượng cổ phiếu
</dt>
<dd>
@Html.DisplayFor(model => model.SLCOPHIEU)
</dd>
<dt>
Số lượng nhân viên
</dt>
<dd>
@Html.DisplayFor(model => model.SLNHANVIEN)
</dd>
</dl>
</div>
<p>
@Html.ActionLink("Chỉnh sửa", "Edit", new { id = Model.MACONGTY }) |
@Html.ActionLink("Trở về danh sách", "Index")
</p>
48
4.1.Thiết kế Form:
49
<tr>
<td></td>
<td></td>
<td><input type="submit" value="Lưu lại" />
<input type="submit" value="Đóng" />
</td>
</tr>
</form>
</table>
</CENTER>
</br>
</body>
50
</table>
<br>
<div style="text-align: center;">
<button type="">Đóng</button>
<button type="submit" runat=”server”>Lưu lại</button>
</div>
</form>
</div>
namespace TIEULUAN36.Controllers
{
public class DIENBIENGIAController : Controller
{
QUANLYTHITRUONGCHUNGKHOANEntities db = new
QUANLYTHITRUONGCHUNGKHOANEntities();
// GET: Default
public ActionResult Index()
{
var lstdt = from dt in db.DIENBIENGIAs select dt;
return View(lstdt);
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(DIENBIENGIA dt)
{
db.DIENBIENGIAs.Add(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
DIENBIENGIA dt = db.DIENBIENGIAs.Find(id);
db.DIENBIENGIAs.Remove(dt);
db.SaveChanges();
return RedirectToAction("Index");
}
51
[HttpGet]
public ActionResult Edit(String id)
{
var dt = db.DIENBIENGIAs.Find(id);
return View(dt);
}
[HttpPost]
public ActionResult Edit(DIENBIENGIA dt)
{
var updatedt = db.DIENBIENGIAs.Find(dt.MACONGTY);
updatedt.MACONGTY = dt.MACONGTY;
updatedt.NGAY = dt.NGAY;
updatedt.GIA1COPHIEU = dt.GIA1COPHIEU;
db.SaveChanges();
return RedirectToAction("Index");
}
52
{
var lstdt = from dt in db.DIENBIENGIAs select dt;
return View(lstdt);
}
4.5.3.Mã lệnh Index chức năng hiển thị:
@model IEnumerable<TIEULUAN36.Models.DIENBIENGIA>
@{
ViewBag.Title = "Index";
}
<p>
@Html.ActionLink("Tạo mới ", "Create")
</p>
<table class="table">
<tr>
<th>
Mã công ty
</th>
<th>
Ngày
</th>
<th>
Giá của 1 cổ phiếu
</th>
<th></th>
</tr>
</table>
53
4.6.Chức năng chỉnh sửa:
4.6.1.Giao diện chức năng chỉnh sửa:
db.SaveChanges();
return RedirectToAction("Index");
}
4.6.3 Mã lệnh Edit chức năng chỉnh sửa:
@model TIEULUAN36.Models.DIENBIENGIA
@{
ViewBag.Title = "Edit";
}
<h2>chỉnh sửa</h2>
54
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Diễn biến giá</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.MACONGTY)
<div class="form-group">
<div class="col-md-10">
Mã công ty
@Html.EditorFor(model => model.MACONGTY, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MACONGTY, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Ngày
@Html.EditorFor(model => model.NGAY, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NGAY, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Giá của 1 cổ phiếu
@Html.EditorFor(model => model.GIA1COPHIEU, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.GIA1COPHIEU, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Lưu" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
55
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
4.7.Chức năng thêm:
4.7.1.Giao diện chức năng thêm:
@{
ViewBag.Title = "Create";
}
<div class="form-horizontal">
<h4>Diễn biến giá</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<div class="col-md-10">
Mã công ty
@Html.EditorFor(model => model.MACONGTY, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MACONGTY, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Ngày
@Html.EditorFor(model => model.NGAY, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NGAY, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Giá của 1 cổ phiếu
@Html.EditorFor(model => model.GIA1COPHIEU, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.GIA1COPHIEU, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Tạo mới " class="btn btn-default"
/>
</div>
</div>
</div>
}
57
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
58
var lstdt = db.DIENBIENGIAs.Select(p => p).Where(p => p.MACONGTY ==
id).FirstOrDefault();
return View(lstdt);
}
4.9.3.Mã lệnh Details Chức năng hiển thị chị tiết:
@model TIEULUAN36.Models.DIENBIENGIA
@{
ViewBag.Title = "Details";
}
<h2>chi tiết</h2>
<div>
<h4>Diễn biến giá</h4>
<hr />
<dl class="dl-horizontal">
<dt>
Mã công ty
</dt>
<dd>
@Html.DisplayFor(model => model.MACONGTY)
</dd>
<dt>
Ngày
</dt>
<dd>
@Html.DisplayFor(model => model.NGAY)
</dd>
<dt>
Giá của 1 cổ phiếu
</dt>
<dd>
@Html.DisplayFor(model => model.GIA1COPHIEU)
</dd>
</dl>
</div>
<p>
@Html.ActionLink("Chỉnh sửa", "Edit", new { id = Model.MACONGTY }) |
@Html.ActionLink("Back to List", "Index")
</p>
59
1 Sothutugiaodich Int 20
2 Ngaygiaodich Int 10
3 Macongty Int 20
4 Manhamoigioi Int 20
5 Makhban Int 20
6 Makhmua int 20
7 Soluong int 20
5.1.Thiết Kế form:
<html lang="en-US">
<head>
<title>
TIỂU LUẬN KẾT THÚC MÔN
</title>
</head>
<body>
<br>
<CENTER>
<table>
<form>
<tr><th colspan="3">THÔNG TIN GIAO DỊCH</th></tr>
<tr>
<td>Số thứ tự giao dịch</td>
<td>:</td>
<td>
<input type="text"/>
60
</td>
</tr>
<tr>
<td>Ngày giao dịch</td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td> Mã công ty </td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td> Mã nhà môi giới </td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td> Mã khách hàng bán</td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td> Mã khách hàng mua </td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td> Số lượng </td>
<td>:</td>
<td>
<input type="text"/>
</td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" value="Lưu lại" />
<input type="submit" value="Đóng" />
</td>
61
</tr>
</form>
</table>
</CENTER>
</br>
</body>
5.3. Mã lệnh Web server control:
<div style="display: inline-block;
border: 1px solid blue;
padding: 15px">
<h2 style="text-align: center;">THÔNG TIN GIAO DỊCH</h2>
<form id=”formGiaodich” runat=”server”>
<table cellpadding=10 cellspacing=20>
<tr>
<th>Số thứ tự giao dịch</th>
<td>:</td>
<td><asp:TextBox type="text" name="txtSttgiaodich"></td>
</tr>
<tr>
<th>Ngày giao dịch</th>
<td>:</td>
<td><asp:TextBox type="text" name="txtNgaygd"></td>
</tr>
<tr>
<th>Mã công ty</th>
<td>:</td>
<td><asp:TextBox type="text" name="txtCongty"></td>
</tr>
<tr>
<th>Mã nhà môi giơi</th>
<td>:</td>
<td><asp:TextBox type="text" name="txtManhamoigioi"></td>
</tr>
62
<tr>
<th>Mã khách hàng bán</th>
<td>:</td>
<td><asp:TextBox type="text" name="txtMakhban"></td>
</tr>
<tr>
<th>Mã khách hàng mua</th>
<td>:</td>
<td><asp:TextBox type="text" name="txtMakhmua"></td>
</tr>
<tr>
<th>Số lượng </th>
<td>:</td>
<td><asp:TextBox type="text" name="txtSoluong"></td>
</tr>
</table>
<br>
<div style="text-align: center;">
<button type="">Đóng</button>
<button type="submit" runat=”server”>Lưu lại</button>
</div>
</form>
</div>
namespace TIEULUAN36.Controllers
{
public class GIAODICHController : Controller
{
63
QUANLYTHITRUONGCHUNGKHOANEntities db = new
QUANLYTHITRUONGCHUNGKHOANEntities();
// GET: Default
public ActionResult Index()
{
var lstgd = from gd in db.GIAODICHes select gd;
return View(lstgd);
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(GIAODICH gd)
{
db.GIAODICHes.Add(gd);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
GIAODICH gd = db.GIAODICHes.Find(id);
db.GIAODICHes.Remove(gd);
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpGet]
public ActionResult Edit(String id)
{
var gd = db.GIAODICHes.Find(id);
return View(gd);
}
[HttpPost]
public ActionResult Edit(GIAODICH gd)
{
var updategd = db.GIAODICHes.Find(gd.STTGIAODICH);
updategd.STTGIAODICH = gd.STTGIAODICH;
updategd.NGAYGIAODICH = gd.NGAYGIAODICH;
updategd.MANHAMOIGIOI = gd.MANHAMOIGIOI;
updategd.MAKHMUA = gd.MAKHMUA;
updategd.MAKHBAN = gd.MAKHBAN;
updategd.SOLUONG = gd.SOLUONG;
updategd.MACONGTY = gd.MACONGTY;
db.SaveChanges();
return RedirectToAction("Index");
}
@{
ViewBag.Title = "Index";
}
<p>
@Html.ActionLink("Tạo mới", "Create")
</p>
<table class="table">
<tr>
<th>
Số thứ tự giao dịch
</th>
<th>
65
Ngày giao dịch
</th>
<th>
Mã nhà môi giới
</th>
<th>
Mã khách hàng mua
</th>
<th>
Mã khách hàng bán
</th>
<th>
Số lượng
</th>
<th>
Mã công ty
</th>
<th></th>
</tr>
@{
ViewBag.Title = "Edit";
}
<h2>Chỉnh sửa</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Giao dịch</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.STTGIAODICH)
<div class="form-group">
<div class="col-md-10">
Số thứ tự giao dịch
@Html.EditorFor(model => model.STTGIAODICH, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.STTGIAODICH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Ngày giao dịch
@Html.EditorFor(model => model.NGAYGIAODICH, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NGAYGIAODICH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Mã nhà môi giới
@Html.EditorFor(model => model.MANHAMOIGIOI, new
{ htmlAttributes = new { @class = "form-control" } })
68
@Html.ValidationMessageFor(model => model.MANHAMOIGIOI, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Mã khách hàng mua
@Html.EditorFor(model => model.MAKHMUA, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MAKHMUA, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Mã khách hàng bán
@Html.EditorFor(model => model.MAKHBAN, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MAKHBAN, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Số lượng
@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-10">
Mã công ty
@Html.EditorFor(model => model.MACONGTY, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MACONGTY, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Lưu" class="btn btn-default" />
69
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
5.7.Chức năng thêm:
5.7.1.Giao diện chức năng thêm:
@{
ViewBag.Title = "Create";
}
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Giao dịch</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<div class="col-md-10">
Số thứ tự giao dịch
@Html.EditorFor(model => model.STTGIAODICH, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.STTGIAODICH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Ngày giao dịch
@Html.EditorFor(model => model.NGAYGIAODICH, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.NGAYGIAODICH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Mã nhà môi giới
@Html.EditorFor(model => model.MANHAMOIGIOI, new
{ htmlAttributes = new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MANHAMOIGIOI, "", new
{ @class = "text-danger" })
71
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Mã khách hàng mua
@Html.EditorFor(model => model.MAKHMUA, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MAKHMUA, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Mã khách hàng bán
@Html.EditorFor(model => model.MAKHBAN, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MAKHBAN, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Số lượng
@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-10">
Mã công ty
@Html.EditorFor(model => model.MACONGTY, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MACONGTY, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Tạo mới" class="btn btn-default" />
</div>
</div>
72
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
5.8.Chức năng xóa:
5.8.1. Giao diện chức năng xóa:
73
5.9.Chức năng hiển thị chi tiết:
5.9.1.Giao diện chức năng hiển thị chi tiết:
@{
ViewBag.Title = "Details";
}
<h2>Chi tiét</h2>
<div>
<h4>Giao dịch</h4>
<hr />
<dl class="dl-horizontal">
<dt>
Số thứ tự giao dịch
</dt>
<dd>
@Html.DisplayFor(model => model.STTGIAODICH)
</dd>
<dt>
Ngày giao dịch
</dt>
74
<dd>
@Html.DisplayFor(model => model.NGAYGIAODICH)
</dd>
<dt>
Mã nhà môi giới
</dt>
<dd>
@Html.DisplayFor(model => model.MANHAMOIGIOI)
</dd>
<dt>
Mã khách hàng mua
</dt>
<dd>
@Html.DisplayFor(model => model.MAKHMUA)
</dd>
<dt>
Mã khách hàng bán
</dt>
<dd>
@Html.DisplayFor(model => model.MAKHBAN)
</dd>
<dt>
Số lượng
</dt>
<dd>
@Html.DisplayFor(model => model.SOLUONG)
</dd>
<dt>
Mã công ty
</dt>
<dd>
@Html.DisplayFor(model => model.MACONGTY)
</dd>
</dl>
</div>
<p>
@Html.ActionLink("Chỉnh sửa", "Edit", new { id = Model.STTGIAODICH }) |
@Html.ActionLink("Back to List", "Index")
</p>
75
6. Bảng Khách hàng mua
6.1. Thiết kế form:
<html lang="en-US">
<head>
<title>
TIỂU LUẬN KẾT THÚC MÔN
</title>
</head>
<body>
<br>
<CENTER>
<form >
<table>
<tr><th colspan="3">THÔNG TIN KHÁCH HÀNG</th></tr>
<tr>
<td>Mã khách hàng</td>
<td>:</td>
<td> <input type="text"/></td>
</tr>
<tr>
<td>Tên khách hàng</td>
<td>:</td>
<td> <input type="text"/></td>
</tr>
<tr>
<td>Địa chỉ </td>
<td>:</td>
<td> <input type="text"/></td>
</tr>
<tr>
<td>Điện thoại </td>
<td>:</td>
<td> <input type="text"/></td>
76
</tr>
<tr>
<td>Thu nhập </td>
<td>:</td>
<td> <input type="text"/></td>
</tr>
<tr>
<td></td>
<td></td>
<td><input type="submit" value="Lưu lại" />
<input type="submit" value="Đóng" />
</td>
</tr>
</table>
</form>
</CENTER>
</br>
</body>
</html>
</table>
<br>
<div style="text-align: center;">
<button type="">Đóng</button>
<button type="submit" runat=”server”>Lưu lại</button>
</div>
</form>
</div>
namespace TIEULUAN36.Controllers
{
public class KHACHHANGMUAtController : Controller
{
QUANLYTHITRUONGCHUNGKHOANEntities db = new
QUANLYTHITRUONGCHUNGKHOANEntities ();
// GET: Default
public ActionResult Index()
{
var lstkhm = from khm in db.KHACHHANGMUAs select khm;
return View(lstkhm);
78
}
[HttpGet]
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(KHACHHANGMUA khm)
{
db.KHACHHANGMUAs.Add(khm);
db.SaveChanges();
return RedirectToAction("Index");
}
public ActionResult Delete(String id)
{
KHACHHANGMUA khm = db.KHACHHANGMUAs.Find(id);
db.KHACHHANGMUAs.Remove(khm);
db.SaveChanges();
return RedirectToAction("Index");
}
[HttpGet]
[HttpPost]
public ActionResult Edit(KHACHHANGMUA khm)
{
var updatekhm = db.KHACHHANGMUAs.Find(khm.MAKH);
updatekhm.MAKH = khm.MAKH;
updatekhm.TENKH = khm.TENKH;
updatekhm.DIACHI = khm.DIACHI;
updatekhm.DIENTHOAI = khm.DIENTHOAI;
updatekhm.THUNHAP= khm.THUNHAP;
db.SaveChanges();
return RedirectToAction("Index");
}
79
6.5.Chức năng hiển thị:
6.5.1.Giao diện chức năng hiển thị:
@{
ViewBag.Title = "Index";
}
<p>
@Html.ActionLink("Tạo mới ", "Create")
</p>
<table class="table">
<tr>
<th>
Mã khách hàng mua
</th>
<th>
Tên khách hàng mua
</th>
<th>
Địa chỉ
80
</th>
<th>
Điện thoại
</th>
<th>
Thu nhập
</th>
<th></th>
</tr>
</table>
81
2.6.Chức năng chỉnh sửa:
2.6.1.Giao diện chức năng chỉnh sửa:
[HttpPost]
public ActionResult Edit(KHACHHANGMUA khm)
{
var updatekhm = db.KHACHHANGMUAs.Find(khm.MAKH);
updatekhm.MAKH = khm.MAKH;
updatekhm.TENKH = khm.TENKH;
updatekhm.DIACHI = khm.DIACHI;
updatekhm.DIENTHOAI = khm.DIENTHOAI;
updatekhm.THUNHAP= khm.THUNHAP;
db.SaveChanges();
return RedirectToAction("Index");
}
2.6.3 Mã lệnh Edit chức năng chỉnh sửa:
@model TIEULUAN36.Models.KHACHHANGMUA
@{
82
ViewBag.Title = "Edit";
}
<h2>Chỉnh sửa</h2>
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Khách hàng mua</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
@Html.HiddenFor(model => model.MAKH)
<div class="form-group">
<div class="col-md-10">
Mã Khách hàng mua
@Html.EditorFor(model => model.MAKH, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MAKH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Tên khách hàng mua
@Html.EditorFor(model => model.TENKH, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TENKH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Địa chỉ
@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">
<div class="col-md-10">
83
Điện thoại
@Html.EditorFor(model => model.DIENTHOAI, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DIENTHOAI, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Thu nhập
@Html.EditorFor(model => model.THUNHAP, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.THUNHAP, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Lưu" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
84
2.7.Chức năng thêm:
2.7.1.Giao diện chức năng thêm:
@{
ViewBag.Title = "Create";
}
<h2>Tạo mới</h2>
85
@using (Html.BeginForm())
{
@Html.AntiForgeryToken()
<div class="form-horizontal">
<h4>Khách hàng mua</h4>
<hr />
@Html.ValidationSummary(true, "", new { @class = "text-danger" })
<div class="form-group">
<div class="col-md-10">
Mã khách hàng mua
@Html.EditorFor(model => model.MAKH, new { htmlAttributes = new
{ @class = "form-control" } })
@Html.ValidationMessageFor(model => model.MAKH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Tên khách hàng mua
@Html.EditorFor(model => model.TENKH, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.TENKH, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-10">
Địa chỉ
@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">
<div class="col-md-10">
Điện thoại
@Html.EditorFor(model => model.DIENTHOAI, new { htmlAttributes
= new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.DIENTHOAI, "", new
{ @class = "text-danger" })
</div>
</div>
86
<div class="form-group">
<div class="col-md-10">
Thu nhập
@Html.EditorFor(model => model.THUNHAP, new { htmlAttributes =
new { @class = "form-control" } })
@Html.ValidationMessageFor(model => model.THUNHAP, "", new
{ @class = "text-danger" })
</div>
</div>
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<input type="submit" value="Tạo mới" class="btn btn-default" />
</div>
</div>
</div>
}
<div>
@Html.ActionLink("Back to List", "Index")
</div>
@section Scripts {
@Scripts.Render("~/bundles/jqueryval")
}
2.8.Chức năng xóa:
2.8.1. Giao diện chức năng xóa:
@{
ViewBag.Title = "Details";
}
<h2>Chi tiết</h2>
<div>
<h4>Khách hàng mua</h4>
<hr />
<dl class="dl-horizontal">
<dt>
Mã khách hàng mua
</dt>
<dd>
@Html.DisplayFor(model => model.MAKH)
</dd>
<dt>
Tên khách hàng mua
</dt>
<dd>
88
@Html.DisplayFor(model => model.TENKH)
</dd>
<dt>
Địa chỉ
</dt>
<dd>
@Html.DisplayFor(model => model.DIACHI)
</dd>
<dt>
Điện thoại
</dt>
<dd>
@Html.DisplayFor(model => model.DIENTHOAI)
</dd>
<dt>
Thu nhập
</dt>
<dd>
@Html.DisplayFor(model => model.THUNHAP)
</dd>
</dl>
</div>
<p>
@Html.ActionLink("chỉnh sửa", "Edit", new { id = Model.MAKH }) |
@Html.ActionLink("Back to List", "Index")
</p>
89
90
91