public ActionResult DeleteConfirmed(int id)
        {
            Prescription_Detail prescription_Detail = db.Prescription_Detail.Find(id);

            db.Prescription_Detail.Remove(prescription_Detail);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
 public ActionResult Edit([Bind(Include = "ID,Prescription_id,Medicine_id,Quanlity,Morning,Noon,Afternoon,Night,Note")] Prescription_Detail prescription_Detail)
 {
     if (ModelState.IsValid)
     {
         db.Entry(prescription_Detail).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     ViewBag.Medicine_id     = new SelectList(db.Medicines, "Id", "Code_medicine", prescription_Detail.Medicine_id);
     ViewBag.Prescription_id = new SelectList(db.Prescriptions, "Id", "Note", prescription_Detail.Prescription_id);
     return(View(prescription_Detail));
 }
        // GET: Prescription_Detail/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Prescription_Detail prescription_Detail = db.Prescription_Detail.Find(id);

            if (prescription_Detail == null)
            {
                return(HttpNotFound());
            }
            return(View(prescription_Detail));
        }
        public ActionResult Kham([Bind(Include = "Id,Prescription_id,Medicine_id,Quanlity,Morning,Noon,Afternoon,Night,Note")] Prescription_Detail don_thuoc_chi_tiet)
        {
            if (ModelState.IsValid)
            {
                db.Prescription_Detail.Add(don_thuoc_chi_tiet);
                db.SaveChanges();
                return(RedirectToAction("Kham", new { id = don_thuoc_chi_tiet.Prescription_id }));
            }

            var thuocs = db.Medicines.Select(x => new { Id = x.Id, Name = x.Name + " (" + x.Unit_measurement + ")" });

            ViewBag.Medicine_id = new SelectList(thuocs, "Id", "Name");
            ViewBag.don_thuoc   = db.Prescriptions.Find(don_thuoc_chi_tiet.Prescription_id);
            return(View());
        }
        // GET: Prescription_Detail/Edit/5
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Prescription_Detail prescription_Detail = db.Prescription_Detail.Find(id);

            if (prescription_Detail == null)
            {
                return(HttpNotFound());
            }
            ViewBag.Medicine_id     = new SelectList(db.Medicines, "Id", "Code_medicine", prescription_Detail.Medicine_id);
            ViewBag.Prescription_id = new SelectList(db.Prescriptions, "Id", "Note", prescription_Detail.Prescription_id);
            return(View(prescription_Detail));
        }