public ActionResult Edit(int id) { var dao = new KhoHangDao(); var khoHang = dao.ViewDentail(id); SetViewBag(khoHang.MaKhachSan); return(View(khoHang)); }
// GET: Admin/KhoHang public ActionResult DanhSachKhoHang(string searchString, int page = 1, int pageSize = 10) { var dao = new KhoHangDao(); var model = dao.LayTatCaDS(searchString, page, pageSize); ViewBag.SearchString = searchString; return(View(model)); }
public JsonResult CreateCT_PNK(string ma_pnk, string ma_hang_s, string ma_kho_s, string so_luong_s, string don_gia_s) { bool success = true; string message = "Kết quả: Hoàn thành việc nhập kho!"; var daoCT = new ChiTietNhapDao(); var daoHH = new HangHoaDao(); var daoKho = new KhoHangDao(); string[] lst_ma_hang = ma_hang_s.Split(','); string[] lst_so_luong = so_luong_s.Split(','); string[] lst_don_gia = don_gia_s.Split(','); string[] lst_ma_kho = ma_kho_s.Split(','); try { for (int i = 0; i < lst_ma_hang.Length; i++) { ChiTietNhap obj = new ChiTietNhap(); obj.NhapID = ma_pnk; obj.MaHH = lst_ma_hang[i].ToString(); obj.SoLuong = int.Parse(lst_so_luong[i].ToString()); obj.DonGia = decimal.Parse(lst_don_gia[i].ToString()); obj.MaKho = int.Parse(lst_ma_kho[i].ToString()); obj.CreatedDate = DateTime.Now; obj.CreateBy = Session["UserName"].ToString(); obj.TongTien = decimal.Parse(lst_don_gia[i].ToString()) * int.Parse(lst_so_luong[i].ToString()); daoCT.Insert(obj); daoHH.NhapHang(lst_ma_hang[i].ToString(), int.Parse(lst_so_luong[i].ToString()), decimal.Parse(lst_don_gia[i].ToString()), Session["UserName"].ToString()); if (daoKho.CheckKho(int.Parse(lst_ma_kho[i].ToString()), lst_ma_hang[i].ToString())) { daoKho.NhapThemHang(int.Parse(lst_ma_kho[i].ToString()), lst_ma_hang[i].ToString(), int.Parse(lst_so_luong[i].ToString())); } else { KhoHang kho_hang = new KhoHang(); kho_hang.MaKho = int.Parse(lst_ma_kho[i].ToString()); kho_hang.MaHH = lst_ma_hang[i].ToString(); kho_hang.SoLuong = int.Parse(lst_so_luong[i].ToString()); daoKho.Insert(kho_hang); } } } catch (Exception ex) { success = false; message = "Kết quả: " + ex.ToString() + "."; } return(Json(new { success = success, message = message })); }
public ActionResult Edit(KhoHang qh) { if (ModelState.IsValid) { var dao = new KhoHangDao(); var result = dao.ChinhSua(qh); if (result) { SetAlert("Cập nhật thành công", "success"); return(RedirectToAction("DanhSachKhoHang", "KhoHang")); } else { ModelState.AddModelError("", "Cập nhật thất bại"); } } SetViewBag(qh.MaKhachSan); return(View("DanhSachKhoHang")); }
public ActionResult ThemMoi(KhoHang lh) { if (ModelState.IsValid) { var dao = new KhoHangDao(); int id = dao.ThemMoi(lh); if (id > 0) { SetAlert("Thêm quyền thành công", "success"); return(RedirectToAction("DanhSachKhoHang", "KhoHang")); } else { return(RedirectToAction("ThemMoi", "KhoHang")); } } SetViewBag(); return(View("DanhSachKhoHang")); }
public ActionResult GetKhoByHangId(string mahh) { var dao = new KhoHangDao(); List <KhoHang> objkho = new List <KhoHang>(); objkho = dao.GetByMaHH(mahh); List <Kho> lst_kho = new List <Kho>(); for (int i = 0; i < objkho.Count; i++) { Kho obj = new Kho(); obj.ID = objkho[i].MaKho.Value; obj.Ten = objkho[i].Kho.Ten; lst_kho.Add(obj); } SelectList obgkho = new SelectList(lst_kho, "Id", "Ten", 0); return(Json(obgkho)); }
public JsonResult GetQuantityProduct(int makho, string mahh) { bool success = true; string soluong = ""; try { var dao = new KhoHangDao(); soluong = dao.GetQuantity(makho, mahh); success = true; } catch (Exception e) { success = false; soluong = "0"; } return(Json(new { success = success, soluong = soluong })); }
public void SetViewBag(int?selectedMa = null) { var dao = new KhoHangDao(); ViewBag.MaKho = new SelectList(dao.ListAll(), "MaKho", "KhachSan.TenKhachSan", selectedMa); }