public ActionResult DeleteConfirmed(string id) { PhieuKiemKeChiTiet phieuKiemKeChiTiet = db.PhieuKiemKeChiTiets.Find(id); db.PhieuKiemKeChiTiets.Remove(phieuKiemKeChiTiet); db.SaveChanges(); return(RedirectToAction("Index")); }
public ActionResult Edit([Bind(Include = "MaPKK,MaMH,SLTon")] PhieuKiemKeChiTiet phieuKiemKeChiTiet) { if (ModelState.IsValid) { db.Entry(phieuKiemKeChiTiet).State = EntityState.Modified; db.SaveChanges(); return(RedirectToAction("Index")); } ViewBag.MaPKK = new SelectList(db.MatHangs, "MaMH", "Ten", phieuKiemKeChiTiet.MaPKK); ViewBag.MaPKK = new SelectList(db.PhieuKiemKes, "MaPKK", "MaNV", phieuKiemKeChiTiet.MaPKK); return(View(phieuKiemKeChiTiet)); }
// GET: Administrator/PhieuKiemKeChiTiets/Details/5 public ActionResult Details(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuKiemKeChiTiet phieuKiemKeChiTiet = db.PhieuKiemKeChiTiets.Find(id); if (phieuKiemKeChiTiet == null) { return(HttpNotFound()); } return(View(phieuKiemKeChiTiet)); }
// GET: Administrator/PhieuKiemKeChiTiets/Edit/5 public ActionResult Edit(string id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } PhieuKiemKeChiTiet phieuKiemKeChiTiet = db.PhieuKiemKeChiTiets.Find(id); if (phieuKiemKeChiTiet == null) { return(HttpNotFound()); } ViewBag.MaPKK = new SelectList(db.MatHangs, "MaMH", "Ten", phieuKiemKeChiTiet.MaPKK); ViewBag.MaPKK = new SelectList(db.PhieuKiemKes, "MaPKK", "MaNV", phieuKiemKeChiTiet.MaPKK); return(View(phieuKiemKeChiTiet)); }
// cap nhat gia/lo/han dung cho tung thuoc o trong Phieu kiem ke public void UpdateDrugSerialNoAndExpDate(String maNhaThuoc, InventoryEditModel inventoryEditModel) { int inventoryId = inventoryEditModel.InventoryId; // return khi ma phieu kiem ke khong hop le if (inventoryId <= 0) { return; } bool canKho = inventoryEditModel.DaCanKho; decimal gia = inventoryEditModel.Gia; string soLo = inventoryEditModel.SoLo; DateTime?hanDung = inventoryEditModel.HanDung; var phieuKiemKeRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, PhieuKiemKe> >().GetAll(); var phieuKiemKeChiTietRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, PhieuKiemKeChiTiet> >(); var phieuNhapChiTietRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, PhieuNhapChiTiet> >(); var phieuXuatChiTietRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbContext, PhieuXuatChiTiet> >(); InventoryDetailModel inventoryDetailModel = GetInventoryDetailInfo(maNhaThuoc, inventoryId); var thuocId = inventoryDetailModel.MedicineList.Where(x => x.MaThuoc == inventoryEditModel.MaThuoc).FirstOrDefault().ThuocId; // lay thong tin phieu kiem ke chi tiet theo PhieuKiemKe_MaPhieuKiemKe va Thuoc_ThuocId var pkkctQuery = from pkkct in phieuKiemKeChiTietRepo.GetAll() where (pkkct.PhieuKiemKe_MaPhieuKiemKe == inventoryId && pkkct.RecordStatusID == (byte)RecordStatus.Activated && pkkct.Thuoc_ThuocId == thuocId) select pkkct; var pkkctQueryResult = pkkctQuery.FirstOrDefault(); PhieuKiemKeChiTiet phieuKiemKeChiTietEntity = pkkctQueryResult; phieuKiemKeChiTietEntity.DonGia = gia; phieuKiemKeChiTietEntity.SoLo = soLo; phieuKiemKeChiTietEntity.HanDung = hanDung; // cap nhat gia/lo/han vao bang PhieuKiemKeChiTiets phieuKiemKeChiTietRepo.Update(phieuKiemKeChiTietEntity); phieuKiemKeChiTietRepo.Commit(); // TH phieu da can kho, cap nhat gia/lo/han trong phieu Nhap/xuat chi tiet if (canKho) { inventoryDetailModel.PhieuCanKhoChiTiet.ForEach(p => { // TH Phieu Nhap thì update giá nhập/lô/hạn dùng vào phiếu nhập chi tiết if (p.LoaiPhieu == NoteInOutType.Receipt && p.SoLuong > 0) { // tim Phieu Nhap Chi Tiet theo MaPhieu va thuocId var pnctQuery = from pnct in phieuNhapChiTietRepo.GetAll() where (pnct.PhieuNhap_MaPhieuNhap == p.MaPhieu && pnct.Thuoc_ThuocId == thuocId) select pnct; var pnctQueryResult = pnctQuery.FirstOrDefault(); if (pnctQueryResult != null) { PhieuNhapChiTiet phieuNhapChiTietEntity = pnctQueryResult; phieuNhapChiTietEntity.GiaNhap = gia; phieuNhapChiTietEntity.SoLo = soLo; phieuNhapChiTietEntity.HanDung = hanDung; phieuNhapChiTietRepo.Update(phieuNhapChiTietEntity); phieuNhapChiTietRepo.Commit(); } } // TH Phieu Xuat thì update giá xuất if (p.LoaiPhieu == NoteInOutType.Delivery && p.SoLuong > 0) { // tim Phieu Xuat Chi Tiet theo MaPhieu va thuocId var pxctQuery = from pxct in phieuXuatChiTietRepo.GetAll() where (pxct.PhieuXuat_MaPhieuXuat == p.MaPhieu && pxct.Thuoc_ThuocId == thuocId) select pxct; var pxctQueryResult = pxctQuery.FirstOrDefault(); if (pxctQueryResult != null) { PhieuXuatChiTiet phieuXuatChiTietEntity = pxctQueryResult; phieuXuatChiTietEntity.GiaXuat = gia; phieuXuatChiTietRepo.Update(phieuXuatChiTietEntity); phieuXuatChiTietRepo.Commit(); } } }); } }