public ActionResult Create([Bind(Include = "TreatmentsId,VoterId,Name,Address,DateOfBirht,ServiceGiven,Observation,Date,DoctorEntryId,DiseasesId,MedicineId,DoseId,MealId,QuantityGiven,Note")] Treatments treatments)
        {
            var medicines = db.Medicines;
            List<Medicine> allMedicine = new List<Medicine>();
            foreach (Medicine medicine in medicines)
            {
                Medicine aMedicine = new Medicine();
                aMedicine.Name = medicine.Name + "-" + medicine.Power + medicine.PowerUnit;
                aMedicine.MedicineId = medicine.MedicineId;
                allMedicine.Add(aMedicine);

            }
            if (ModelState.IsValid)
            {
                db.Treatmentses.Add(treatments);
                db.SaveChanges();
                return RedirectToAction("Index");
            }

            ViewBag.DiseasesId = new SelectList(db.Diseaseses, "DiseasesId", "Name", treatments.DiseasesId);
            ViewBag.DoseId = new SelectList(db.Doses, "DoseId", "Name", treatments.DoseId);
            ViewBag.MealId = new SelectList(db.Meals, "MealId", "Name", treatments.MealId);
            ViewBag.MedicineId = new SelectList(allMedicine, "MedicineId", "Name", treatments.MedicineId);
            return View(treatments);
        }
        // GET: /AllocateMedicine/Create
        public ActionResult Create()
        {
            var medicines = db.Medicines;
            List<Medicine>allMedicine=new List<Medicine>();
            foreach (Medicine medicine in medicines)
            {
                Medicine aMedicine=new Medicine();
                aMedicine.Name = medicine.Name + "-" + medicine.Power + medicine.PowerUnit;
                aMedicine.MedicineId = medicine.MedicineId;
                allMedicine.Add(aMedicine);

            }
            ViewBag.Districts = new SelectList(db.Districts, "Id", "Name");
            ViewBag.MedicineId = new SelectList(allMedicine, "MedicineId", "Name");
            ViewBag.ServiceCenterId = new SelectList(db.ServiceCenters, "Id", "Name");
            return View();
        }
 public ActionResult Chk(string Name,string Power,string PowerUnit)
 {
     Medicine aMedicine=new Medicine();
     aMedicine.Name = Name;
     aMedicine.Power = Power;
     aMedicine.PowerUnit = PowerUnit;
     string message = "";
     var check =db.Medicines.FirstOrDefault(p => p.Name == Name && p.Power == Power && p.PowerUnit == PowerUnit);
     if (check == null)
     {
         db.Medicines.Add(aMedicine);
         db.SaveChanges();
         message = "";
         return Json(message, JsonRequestBehavior.AllowGet);
     }
     else
     {
         message = "Already Exist";
     }
     return Json(message, JsonRequestBehavior.AllowGet);
 }
        public JsonResult IsAvialable(string name)
        {
            Medicine aMedicine = new Medicine();

            aMedicine.Name = name;

            var check = db.Medicines.FirstOrDefault(c => c.Name == aMedicine.Name);
            if (check != null)
            {
                db.Medicines.Add(aMedicine);
                db.SaveChanges();
                return Json(aMedicine, JsonRequestBehavior.AllowGet);
            }
            return Json(aMedicine, JsonRequestBehavior.AllowGet);
        }