public ActionResult ChiTietSP(int id) { ViewBag.RelateProduct = new SachDao().ListRelate(id); var model = new SachDao().Details(id); return(View(model)); }
private void btSua_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Bạn có muốn sửa không?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { if (txtMasach.Text != "" && txtnamxb.Text != "" && txttentacgia.Text != "" && txtTensach.Text != "") { SachDao nv = new SachDao(txtMasach.Text.ToString().Trim(), txtTensach.Text.ToString().Trim(), txttentacgia.Text.Trim(), int.Parse(txtsoluong.Text.Trim()), txtnamxb.Text.ToString().Trim()); if (bus_nv.Sua(nv) == true) { FormatData(); ShowData(); MessageBox.Show("Sửa thành công"); } else { Exception ex = bus_nv.GetEx(); MessageBox.Show(ex.Message); MessageBox.Show("Có lỗi xảy ra"); } } else { MessageBox.Show("Bạn cần nhập đủ thông tin phòng ban"); } } }
//sách cũ public ActionResult ListOldSach() { var dao = new SachDao(); var listSach = dao.ListOldSach(); return(PartialView(listSach)); }
public ActionResult SuaGioHang(int masach, FormCollection f) { var model = new SachDao().ViewDetails(masach); var cartSession = Session[SessionCommand.SessionGioHang]; if (cartSession != null) { var List = (List <CartItem>)cartSession; if (List.Exists(n => n.Sach.MaSach == masach)) { foreach (var item in List) { if (item.Sach.MaSach == masach) { item.SoLuong = int.Parse(f["SoLuong"].ToString()); } } } else { return(RedirectToAction("Index")); } //tra lai ve Session de luu lai nhung thay doi Session[SessionCommand.SessionGioHang] = List; } else { return(RedirectToAction("Index")); } return(RedirectToAction("Index")); }
private void buttonSave_Click(object sender, EventArgs e) { // Dựa vào các cái id mà update lại cho phù hợp if (textBoxBookTitle.Text != tensach) { SachDao sDao = new SachDao(); sDao.updateBooktitle(int.Parse(textBoxBookID.Text), textBoxBookTitle.Text); } if (comboBoxAuthor.Text != hotentg) { TacGiaDao tgDao = new TacGiaDao(); tgDao.updateAuthorName(idAuthor, comboBoxAuthor.Text); } if (comboBoxPublisher.Text != tennxb) { NhaXuatBanDao nxbDao = new NhaXuatBanDao(); nxbDao.updatePublisherName(idPub, comboBoxPublisher.Text); } if (comboBoxCategory.Text != tencd) { ChuDeDao cdDao = new ChuDeDao(); cdDao.updateCategoryName(idCate, comboBoxCategory.Text); } if (textBoxPrice.Text != giaban.ToString()) { SachDao ssDao = new SachDao(); ssDao.updatePrice(int.Parse(textBoxBookID.Text), int.Parse(textBoxPrice.Text)); } MessageBox.Show("Thành công !"); }
private void btThem_Click(object sender, EventArgs e) { DialogResult dr = MessageBox.Show("Bạn có muốn thêm không ?", "Thông báo", MessageBoxButtons.OKCancel, MessageBoxIcon.Question); if (dr == DialogResult.OK) { if (txtMasach.Text != "" && txtnamxb.Text != "" && txttentacgia.Text != "" && txtTensach.Text != "") { SachDao sach = new SachDao(txtMasach.Text.ToString().Trim(), txtTensach.Text.ToString().Trim(), txtTensach.Text.Trim(), int.Parse(txtsoluong.Text.Trim()), txtnamxb.Text.ToString().Trim()); //(txtMaNV.Text.ToString().Trim(), txtTen.Text.ToString().Trim(), txtMaPhong.Text.ToString().Trim(),DateTime.Parse(dtNgaySinh.Text.ToString()),gioitinh,int.Parse(txtLuong.Text.ToString()), txtDiaChi.Text.ToString().Trim()); if (bus_nv.Them(sach) == true) { FormatData(); ShowData(); MessageBox.Show("Thêm thành công"); } else { Exception ex = bus_nv.GetEx(); MessageBox.Show(ex.Message); MessageBox.Show("Có lỗi xảy ra"); } } else { MessageBox.Show("Bạn cần nhập đủ thông tin "); } } }
public ActionResult Upload(int id) { SachDao dao = new SachDao(); var sp = dao.Detail(id); return(View(sp)); }
public ActionResult Edit(Sach collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here var dao = new SachDao(); var result = dao.Update(collection); if (result) { SetAlert("Sửa thành công", "success"); return(RedirectToAction("Index", "Sach")); } else { ModelState.AddModelError("", "Cập nhật sản phẩm không thành công"); } } return(View(collection)); } catch { return(View("Index")); } }
public ActionResult Upload(HttpPostedFileBase file, Sach obj) { try { if (file.ContentLength > 0) { string fileName = Path.GetFileNameWithoutExtension(file.FileName); fileName += "_" + obj.IDSach; fileName += Path.GetExtension(file.FileName); string folderPath = Server.MapPath("~") + @"\images\image"; if (!Directory.Exists(folderPath)) { Directory.CreateDirectory(folderPath); } string path = Path.Combine(folderPath, fileName); file.SaveAs(path); var dao = new SachDao(); dao.Upload(obj.IDSach, fileName); } return(RedirectToAction("Index")); } catch (System.Exception ex) { return(View(obj)); } }
public ActionResult Edit(Sach sach) { if (Session["User"] == null) { return(RedirectToAction("Login", "Login")); } else { ViewBag.MaChuDe = new SelectList(db.ChuDes.OrderBy(n => n.TenChuDe), "MaChuDe", "TenChuDe", sach.MaChuDe); ViewBag.MaNXB = new SelectList(db.NhaXuatBans.OrderBy(n => n.MaNXB), "MaNXB", "TenNXB", sach.MaNXB); var model = new SachDao().CheckSach(sach.TenSach); if (ModelState.IsValid) { var dao = new SachDao(); var result = dao.Update(sach); if (result) { return(RedirectToAction("Index", "SachAD")); } else { ModelState.AddModelError("", "Cập Nhật Sach Thất Bại"); return(View("Edit")); } //} } return(View("Index")); } }
public ActionResult Create(Sach collection) { try { if (ModelState.IsValid) { // TODO: Add insert logic here var dao = new SachDao(); long id = dao.Insert(collection); if (id > 0) { SetAlert("Thêm thành công", "success"); return(RedirectToAction("Index", "Sach")); } else { ModelState.AddModelError("", "Thêm sản phẩm không thành công"); } } return(View(collection)); } catch { return(View("Index")); } }
public ActionResult XoaTungSP(int masach) { //if (lstGioHang != null) //{ // iTongSoLuong = lstGioHang.Sum(n => n.iSoLuong); //} var model = new SachDao().CheckSack(masach); if (model == false) { Response.StatusCode = 404; return(null); } var sessionCart = (List <CartItem>)Session[SessionCommand.SessionGioHang]; CartItem cart = sessionCart.SingleOrDefault(n => n.Sach.MaSach == masach); if (cart != null) { sessionCart.RemoveAll(x => x.Sach.MaSach == masach); Session[SessionCommand.SessionGioHang] = sessionCart; } return(RedirectToAction("Index")); }
public ActionResult Edit(int id) { var sach = new SachDao().FindSachWithId(id); SetViewBagChuDe(sach.MaChuDe); SetViewBagNXB(sach.MaNXB); return(View(sach)); }
public UC_Book_Employee() { InitializeComponent(); SachDao dao = new SachDao(); dao.displayAllBook(dataGridViewBook); }
public PartialViewResult SachTheoTheLoaiPartial(string id) { List <ThongTinSach> thongtin = new SachDao().listSach(); var e = from a in thongtin where a.TenTL == id select a; return(PartialView(e.Take(3).ToList())); }
private void buttonSearch_Click(object sender, EventArgs e) { SachDao dao = new SachDao(); var res = dao.sellBookSearchToCombobox(textBoxSearchBookuq.Text); comboBoxBookTitleuq.DataSource = res; comboBoxBookTitleuq.DisplayMember = "TenSach"; }
public ActionResult NewProduct(int?page) { int pagecurent = (page ?? 1); int pageSize = 9; var dao = new SachDao(); List <Sach> model = dao.ListSachMoi(); return(View(model.ToPagedList(pagecurent, pageSize))); }
public ActionResult Index() { var dao = new SachDao(); ViewBag.NewProduct = dao.listNewSach(3); ViewBag.FeatureProduct = dao.listFeatureSach(3); ViewBag.SpecialProduct = dao.SpecialBook(2); return(View()); }
// GET: Admin/Sach public ActionResult Index(string timKiem, int page = 1, int pageSize = 10) { var dao = new SachDao(); ViewBag.StringTim = timKiem; var list = dao.ListAllSach(timKiem, page, pageSize); return(View(list)); }
public ActionResult Index() { List <ThongTinSach> thongtin = new SachDao().listSach(); var e = (from a in thongtin join b in db.TheLoai on a.MaTL equals b.MaTL select a.TenTL).Distinct(); return(View(e.ToList())); }
//GET: Admin/Sach //public ActionResult Index() //{ // var iplCate = new SachModel(); // var model = iplCate.ListAll(); // return View(model); //} public ActionResult Index(string searchString, int page = 1, int pagesize = 5) { //var iplCate = new SachModel(); //var model = iplCate.ListAll(); var dao = new SachDao(); var model = dao.ListAllPaging(searchString, page, pagesize); ViewBag.SearchString = searchString; return(View(model)); }
public ActionResult LocTheoTacGia(string id) { List <ThongTinSach> thongtin = new SachDao().listSach(); //var e = from a in thongtin where a.TenTL == id select a; var t = thongtin.Where(x => x.MaTG == id); ViewBag.tg = thongtin.Where(s => s.MaTG == id).Select(x => x.TenTG).First(); return(View(t.ToList())); }
public ActionResult Detail(int id) { SachDao dao = new SachDao(); var rs = dao.Detail(id); if (rs != null) { ViewBag.Detail = rs; } return(View()); }
private void bindDataToTextBox() { SachDao dao = new SachDao(); textBoxBookTitle.Text = tensach; comboBoxAuthor.Text = hotentg; comboBoxPublisher.Text = tennxb; comboBoxCategory.Text = tencd; textBoxPrice.Text = giaban.ToString(); textBoxQuantity.Text = soluongton.ToString(); textBoxBookID.Text = dao.getIdBookByName(tensach).ToString(); }
private void dataGridViewBook_CellContentClick(object sender, DataGridViewCellEventArgs e) { tensach = dataGridViewBook.SelectedRows[0].Cells[0].Value.ToString(); giaban = int.Parse(dataGridViewBook.SelectedRows[0].Cells[1].Value.ToString()); soluongton = int.Parse(dataGridViewBook.SelectedRows[0].Cells[2].Value.ToString()); hotentg = dataGridViewBook.SelectedRows[0].Cells[3].Value.ToString(); tencd = dataGridViewBook.SelectedRows[0].Cells[4].Value.ToString(); tennxb = dataGridViewBook.SelectedRows[0].Cells[5].Value.ToString(); SachDao dao = new SachDao(); idSachSelected = dao.getIdBookByName(tensach); }
public ActionResult Edit(int id) { LoaiSachDao lsp = new LoaiSachDao(); var lSp = lsp.ListOf(); ViewBag.LSP = lSp; SachDao dao = new SachDao(); var sp = dao.Detail(id); return(View(sp)); }
private void button1_Click(object sender, EventArgs e) { if (textBoxCustomerID.Text == "" || textBoxCustomerID.Text == null) { MessageBox.Show("Hãy nhập thông tin khách hàng !"); } else { GioHangDao dao = new GioHangDao(); // thêm id khách hàng vào trong bảng GioHang dao.addIdCustomerToAllRecord(int.Parse(textBoxCustomerID.Text)); // Tạo Record trong bảng DonHang DonHang d = new DonHang(); d.MaKH = int.Parse(dao.getIdCustomer()); d.TongTien = dao.netAmount(); DonHangDao donhangDao = new DonHangDao(); var idDonHang = donhangDao.insertDonHang(d); // Tạo Record trong bảng ChiTietDonHang foreach (var item in dao.listGioHang()) { var tensach = item.BookTitle; var soluong = item.Qty; var dongia = item.Price; SachDao sachDao = new SachDao(); // Tạo 1 ChiTietDonHang và thêm các thuộc tính vào ChiTietDonHang ctdh = new ChiTietDonHang(); ctdh.MaDH = int.Parse(idDonHang); ctdh.MaSach = sachDao.getIdBookByName(tensach); ctdh.SoLuong = soluong; ctdh.DonGia = dongia; // Insert record vào ChiTietDonHang ChiTietDonHangDao ctdhDao = new ChiTietDonHangDao(); ctdhDao.insertChiTietDonHang(ctdh); // Update lại số lượng tồn của Sach sachDao.updateStock(ctdh.MaSach, (int)ctdh.SoLuong); } // Clear all clearAll(); // Xóa hết bảng GioHang dao.deleteAllCartRecord(); MessageBox.Show("Thành công !"); } }
private void comboBoxBookTitle_SelectedValueChanged(object sender, EventArgs e) { textBoxSearchBook.Text = ""; SachDao dao = new SachDao(); var res = dao.bindDataFromTextBoxSearchToOthers(comboBoxBookTitle.Text); foreach (var item in res) { textBoxAuthor.Text = item.HoTenTG; textBoxPublisher.Text = item.TenNXB; textBoxStock.Text = item.SoLuongTon.ToString(); textBoxPrice.Text = item.GiaBan.ToString(); } }
// GET: Admin/SachAD public ActionResult Index(string searchString, int page = 1, int pageSize = 10) { if (Session["User"] == null) { return(RedirectToAction("Login", "Login")); } else { var dao = new SachDao(); ViewBag.SearchString = searchString; var model = dao.ListAllPaging(searchString, page, pageSize); return(View(model)); } }
public ActionResult Add(Sach sach, HttpPostedFileBase fileUpload) { if (Session["User"] == null) { return(RedirectToAction("Login", "Login")); } else { ViewBag.MaChuDe = new SelectList(db.ChuDes.OrderBy(n => n.TenChuDe), "MaChuDe", "TenChuDe"); ViewBag.MaNXB = new SelectList(db.NhaXuatBans.OrderBy(n => n.MaNXB), "MaNXB", "TenNXB"); var model = new SachDao().CheckSach(sach.TenSach); if (model == false) { ViewBag.ThongBao = "Sách Đã Tồn Tại Trong Danh Sách Sách"; return(View("Add")); } else { if (fileUpload == null) { ViewBag.ThongBao = "Nhập Hình Ảnh"; return(View()); } if (ModelState.IsValid) { var fileName = Path.GetFileName(fileUpload.FileName); var path = Path.Combine(Server.MapPath("~/HinhAnhSP/"), fileName); if (System.IO.File.Exists(path)) { ViewBag.ThongBao = "Hình Ảnh Đã Tồn Tại"; return(View("Add")); } else { fileUpload.SaveAs(path); } sach.AnhBia = fileUpload.FileName; db.Saches.Add(sach); db.SaveChanges(); return(RedirectToAction("Index", "SachAD")); } } return(View("Index")); } }