Skip to content

Commit

Permalink
v1.3
Browse files Browse the repository at this point in the history
  • Loading branch information
DoHue97 committed Apr 8, 2019
1 parent 3e9b798 commit e1324d5
Show file tree
Hide file tree
Showing 155 changed files with 7,460 additions and 696 deletions.
Binary file modified BookStore2019/.vs/BookStore2019/v15/.suo
Binary file not shown.
Binary file modified BookStore2019/.vs/BookStore2019/v15/Server/sqlite3/storage.ide
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion BookStore2019/.vs/config/applicationhost.config
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@
</site>
<site name="BookStore2019" id="2">
<application path="/" applicationPool="Clr4IntegratedAppPool">
<virtualDirectory path="/" physicalPath="F:\DATN\BookStore2019\BookStore2019" />
<virtualDirectory path="/" physicalPath="E:\DoAn\BookStore2019\BookStore2019" />
</application>
<bindings>
<binding protocol="http" bindingInformation="*:52191:localhost" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ namespace BookStore2019.Areas.Area.Controllers
public class DefaultController : Controller
{
// GET: Area/Default
[Authorize]
public ActionResult Index()
{
return View();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,96 @@
using System.Linq;
using System.Web;
using System.Web.Mvc;

using BookStore2019.Models;
using ValuesObject;
using BookStore2019.Services;
namespace BookStore2019.Areas.Area.Controllers
{
public class QuanLyNXBController : Controller
{
NhaXuatBanService nxbService = new NhaXuatBanService();
// GET: Area/QuanLyNXB
public ActionResult Index()
public ActionResult Search()
{
var list = nxbService.GetAll();
return View(list);
}
[HttpGet]
public ActionResult Create()
{
ONhaXuatBan data = new ONhaXuatBan();
data.IsActive = false;

return View("Update", data);
}
[HttpPost, ValidateInput(false)]
[ValidateAntiForgeryToken]
public ActionResult Create(ONhaXuatBan model)
{
if (ModelState.IsValid)
{

try
{

nxbService.Add(model);
return RedirectToAction("Search", "QuanLyNXB");
}
catch (Exception e)
{

}
}

ViewBag.IsEdit = true;
return View("Update", model);
}

[HttpGet]
public ActionResult Update(int? id)
{
if (id.HasValue)
{
var obj = nxbService.Get((int)id);

ViewBag.IsEdit = true;
return View(obj);
}


return View();
}
[HttpPost, ValidateInput(false)]
[ValidateAntiForgeryToken]
public ActionResult Update(ONhaXuatBan model)
{
if (ModelState.IsValid)
{
var pro = nxbService.Get(model.MaNXB);
if (pro != null)
{
try
{

nxbService.Update(model);
return RedirectToAction("Search", "QuanLyNXB");
}
catch (Exception e)
{

}
}
}

ViewBag.IsEdit = true;
return View(model);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id)
{
nxbService.Delete(id);
return RedirectToAction("Search", "QuanLyNXB");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ValuesObject;
using BookStore2019.Services;
namespace BookStore2019.Areas.Area.Controllers
{
public class QuanLyNguoiDungController : Controller
{
AccountService accountService = new AccountService();
// GET: Area/QuanLyNguoiDung
public ActionResult Search()
{
var list = accountService.GetAll();
return View(list);
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,11 @@ namespace BookStore2019.Areas.Area.Controllers
public class QuanLySanPhamController : Controller
{
ChuDeService chuDeService = new ChuDeService();
SachService sachService = new SachService();
SanPhamService sachService = new SanPhamService();
NhaXuatBanService nxbService = new NhaXuatBanService();
TacGiaService tacGiaService = new TacGiaService();
Sach_TacGiaService sach_TacGiaService = new Sach_TacGiaService();
NhaCungCapService nccService = new NhaCungCapService();
#region admin
// GET: Default

Expand All @@ -30,7 +33,7 @@ public ActionResult CreateCate()
data.IsActive = false;

List<OChuDe> listCate = chuDeService.GetByParentId();

ViewBag.ListTacGia = new SelectList(tacGiaService.GetAll(), "MaTacGia", "Ten");
ViewBag.ListCate = new SelectList(listCate, "ParentId", "Ten"); ;

return View("UpdateCate", data);
Expand All @@ -43,14 +46,17 @@ public ActionResult CreateCate(OChuDe model)
try
{
chuDeService.Add(model);
var idSach = sachService.GetLastId();

return RedirectToAction("SearchCate", "QuanLySanPham");
}
catch (Exception e)
{

}
List<OChuDe> listCate = chuDeService.GetByParentId();
ViewBag.ListCate = new SelectList(listCate, "ParentId", "Ten"); ;
ViewBag.ListCate = new SelectList(listCate, "ParentId", "Ten");

ViewBag.IsEdit = true;
return View("UpdateCate", model);
}
Expand All @@ -64,6 +70,7 @@ public ActionResult UpdateCate(int? id)
var categories = chuDeService.GetByParentId();
var listCate = new SelectList(categories, "ParentId", "Ten");
ViewBag.ListCate = listCate;

ViewBag.IsEdit = true;
return View(obj);
}
Expand Down Expand Up @@ -111,34 +118,49 @@ public ActionResult DeleteCate(int id)
public ActionResult Search(bool isSach)
{
var listSach = sachService.GetAll(isSach);
ViewBag.IsSach = isSach;
return View(listSach);
}

[HttpGet]
public ActionResult Create()
public ActionResult Create(bool isSach)
{
OSach data = new OSach();
OSanPham data = new OSanPham();
data.IsActive = false;

data.IsHot = false;
data.IsSach = false;
data.IsSach = isSach;
List<OChuDe> listCate = chuDeService.GetAll();
ViewBag.ListCate = new SelectList(listCate, "MaChuDe", "Ten"); ;
List<ONhaXuatBan> listNXB = nxbService.GetAll();
ViewBag.ListNXB = new SelectList(listNXB, "MaNXB", "TenNXB");
ViewBag.ListTacGia = new SelectList(tacGiaService.GetAll(), "MaTacGia", "Ten");
ViewBag.ListNCC = new SelectList(nccService.GetAllActive(), "MaNCC", "TenNCC");
return View("Update", data);
}
[HttpPost, ValidateInput(false)]
[ValidateAntiForgeryToken]
public ActionResult Create(OSach model)
public ActionResult Create(OSanPham model)
{
if (ModelState.IsValid)
{
// var pro = ServiceFactory.NewsgoryManager.Get(new Newsgories { NewsgoryId = model.NewsgoryId });
try
{
model.TenVanTat = Help.Helper.convertToUnSign3(model.TenSach);
model.TenVanTat = Help.Helper.convertToUnSign3(model.TenSanPham);
sachService.Add(model);
var idSach = sachService.GetLastId();
if(model.MaTacGia.ToList() !=null && model.MaTacGia.ToList().Count > 0)
{
foreach (int item in model.MaTacGia)
{
sach_TacGiaService.Add(new OSach_TacGia
{
MaTacGia = item,
MaSanPham = idSach,
});
}
}
return RedirectToAction("Search", "QuanLySanPham", new { isSach = model.IsSach });
}
catch (Exception e)
Expand All @@ -150,6 +172,8 @@ public ActionResult Create(OSach model)
ViewBag.ListCate = new SelectList(listCate, "MaChuDe", "Ten");
List<ONhaXuatBan> listNXB = nxbService.GetAll();
ViewBag.ListNXB = new SelectList(listNXB, "MaNXB", "TenNXB");
ViewBag.ListTacGia = new SelectList(tacGiaService.GetAll(), "MaTacGia", "Ten");
ViewBag.ListNCC = new SelectList(nccService.GetAllActive(), "MaNCC", "TenNCC");
ViewBag.IsEdit = true;
return View("Update", model);
}
Expand All @@ -159,11 +183,16 @@ public ActionResult Update(int? id)
{
if (id.HasValue)
{
var obj = sachService.Get(new OSach { MaSach = (int)id });
var obj = sachService.Get(new OSanPham { MaSanPham = (int)id });
List<OChuDe> listCate = chuDeService.GetAll();
ViewBag.ListCate = new SelectList(listCate, "MaChuDe", "Ten");
List<ONhaXuatBan> listNXB = nxbService.GetAll();
ViewBag.ListNXB = new SelectList(listNXB, "MaNXB", "TenNXB");

ViewBag.ListSelected = tacGiaService.GetByMaSanPham((int)id);

ViewBag.ListTacGia = tacGiaService.GetAll();
ViewBag.ListNCC = new SelectList(nccService.GetAllActive(), "MaNCC", "TenNCC");
ViewBag.IsEdit = true;
return View(obj);
}
Expand All @@ -172,18 +201,32 @@ public ActionResult Update(int? id)
}
[HttpPost, ValidateInput(false)]
[ValidateAntiForgeryToken]
public ActionResult Update(OSach model)
public ActionResult Update(OSanPham model)
{
if (ModelState.IsValid)
{
var pro = sachService.Get(new OSach { MaSach = model.MaSach });
var pro = sachService.Get(new OSanPham { MaSanPham = model.MaSanPham });
if (pro != null)
{
try
{
model.TenVanTat = Help.Helper.convertToUnSign3(model.TenSach);
model.TenVanTat = Help.Helper.convertToUnSign3(model.TenSanPham);
//model.CreateBy = CurrentUser.Name;
sachService.Update(model);
sach_TacGiaService.Delete(model.MaSanPham);
if(model.MaTacGia!=null && model.MaTacGia.ToList().Count > 0)
{
foreach (int item in model.MaTacGia)
{
sach_TacGiaService.Add(new OSach_TacGia
{
MaTacGia = item,
MaSanPham = model.MaSanPham,
});
}

}

return RedirectToAction("Search", "QuanLySanPham", new { isSach = model.IsSach });
}
catch (Exception e)
Expand All @@ -196,18 +239,48 @@ public ActionResult Update(OSach model)
ViewBag.ListCate = new SelectList(listCate, "MaChuDe", "Ten");
List<ONhaXuatBan> listNXB = nxbService.GetAll();
ViewBag.ListNXB = new SelectList(listNXB, "MaNXB", "TenNXB");
ViewBag.ListTacGia = tacGiaService.GetAllActive();
ViewBag.ListNCC = new SelectList(nccService.GetAllActive(), "MaNCC", "TenNCC");
ViewBag.IsEdit = true;
return View(model);
}
[HttpPost]
[ValidateAntiForgeryToken]
public ActionResult Delete(int id)
{
var pro = sachService.Get(new OSach { MaSach = id });
var pro = sachService.Get(new OSanPham { MaSanPham = id });
bool isSach = (bool)pro.IsSach;
sachService.Delete(new OSach { MaSach = id });
sachService.Delete(new OSanPham { MaSanPham = id });
return RedirectToAction("Search", "QuanLySanPham", new { isSach = isSach });
}


[HttpPost]
public ActionResult AddAuthor(string tacgia)
{
try
{
var item = tacGiaService.GetByShortName(Help.Helper.convertToUnSign3(tacgia));
if (item!=null)
{
return Json(new { Success = false, Flag = 1, Message = "Tác giả này đã tồn tại!" });
}
else
{
tacGiaService.Add(new OTacGia
{
Ten = tacgia,
TenVanTat = Help.Helper.convertToUnSign3(tacgia),
});
return Json(new { Success = true });
}
}
catch (Exception e)
{

}
return Json(new { Success = false,Flag=0, Error="Thêm thất bại" });
}
#endregion
#endregion
}
Expand Down
Loading

0 comments on commit e1324d5

Please sign in to comment.