public ActionResult Edit(int?id)
        {
            if (id <= 0)
            {
                return(HttpNotFound());
            }
            BackgroundJobHelper.EnqueueUpdateNewestInventories(null);
            var nhaThuoc      = this.GetNhaThuoc();
            var maNhaThuoc    = nhaThuoc.MaNhaThuoc;
            var maNhaThuocCha = nhaThuoc.MaNhaThuocCha;
            var item          = unitOfWork.PhieuKiemKeRepository.GetMany(e => e.MaPhieuKiemKe == id && e.NhaThuoc.MaNhaThuoc == maNhaThuoc).FirstOrDefault();

            if (item == null)
            {
                return(HttpNotFound());
            }
            if (item.DaCanKho)
            {
                ViewBag.Message = "Không thể sửa phiếu đã cân kho";
                return(View("Error"));
            }
            var model = new PhieuKiemKeEditModel(item);

            var list = db.NhomThuocs.Where(x => x.NhaThuoc.MaNhaThuoc == maNhaThuoc || x.NhaThuoc.MaNhaThuoc == maNhaThuocCha).OrderBy(c => c.TenNhomThuoc).ToList();

            ViewBag.MaNhomThuoc   = new SelectList(list, "MaNhomThuoc", "TenNhomThuoc");
            ViewBag.CurrentUserId = WebSecurity.GetCurrentUserId;
            ViewBag.MaNhaThuoc    = maNhaThuoc;
            return(View(model));
        }
        public ActionResult Create()
        {
            BackgroundJobHelper.EnqueueUpdateNewestInventories(null);
            var nhaThuoc      = this.GetNhaThuoc();
            var maNhaThuoc    = nhaThuoc.MaNhaThuoc;
            var maNhaThuocCha = nhaThuoc.MaNhaThuocCha;
            var list          = db.NhomThuocs.Where(x => x.NhaThuoc.MaNhaThuoc == maNhaThuoc || x.NhaThuoc.MaNhaThuoc == maNhaThuocCha).OrderBy(c => c.TenNhomThuoc).ToList();

            ViewBag.MaNhomThuoc   = new SelectList(list, "MaNhomThuoc", "TenNhomThuoc");
            ViewBag.CurrentUserId = WebSecurity.GetCurrentUserId;
            ViewBag.MaNhaThuoc    = this.GetNhaThuoc().MaNhaThuoc;
            ViewBag.SoPhieu       = _generateAvaliableSoPhieu();
            return(View());
        }
        // [Audit]
        public ActionResult DeliveryWithBarcode()
        {
            var service    = IoC.Container.Resolve <IDeliveryNoteService>();
            var noteNumber = service.GetNewDeliveryNoteNumber(WebSessionManager.Instance.CurrentDrugStoreCode);
            var dsSession  = (DrugStoreSession)WebSessionManager.Instance.CommonSessionData;
            var allowToChangeTotalAmount = dsSession.Settings.AllowToChangeTotalAmount;
            var model = new
            {
                AllowToChangeTotalAmount = allowToChangeTotalAmount,
                NoteNumber = noteNumber
            };

            ViewBag.ViewModel = JsonConvert.SerializeObject(model);
            BackgroundJobHelper.EnqueueUpdateNewestInventories(null);

            return(View("~/Areas/Production/Views/Delivery/DeliveryNoteWithBarcode.cshtml"));
        }