public ActionResult DsPhieuKhambn(int id) { ViewBag.phieukhambn = ur.GetAllPhieuKham().ToList(); ViewBag.bn = ur.GetAllUser().ToList(); ViewBag.bs = ur.GetAllBacSi().ToList(); ViewBag.ToaThuoc = ur.GetAllToaThuoc().ToList(); ViewBag.cttt = ur.getallchitiettoathuoc().ToList(); ViewBag.thuoc = ur.dsthuoc().ToList(); List <ServiceReference1.thuocEntity> thuoc = new List <ServiceReference1.thuocEntity>(); var pk = ur.GetAllPhieuKham().ToList(); var lstToaThuoc = ur.GetAllToaThuoc().ToList(); var lstCTToaThuoc = ur.getallchitiettoathuoc().ToList(); var lstThuoc = ur.dsthuoc().ToList(); foreach (var item in pk) { if (item.MaBenhNhan == id) { foreach (var item1 in lstToaThuoc) { if (item1.MaPhieuKham == item.MaPhieuKham) { foreach (var item3 in lstCTToaThuoc) { if (item3.MaToaThuoc == item1.MaToaThuoc) { ViewBag.cttoathuoc1 = ur.getallchitiettoathuocbytoa(item3.MaToaThuoc).ToList(); foreach (var item2 in lstThuoc) { if (item3.MaThuoc == item2.MaThuoc) { ServiceReference1.thuocEntity t = new ServiceReference1.thuocEntity(); t.maThuoc = item2.MaThuoc; t.tenThuoc = item2.TenThuoc; t.donViTinh = item2.DonVitinh; t.nhaSanXuat = item2.NhaSanXuat; t.ngaySanXuat = (DateTime)item2.NgaySanXuat; t.soLuongThuoc = (int)item2.SoLuongThuoc; t.giaThuoc = (int)item2.GiaThuoc; t.hanSuDung = item2.HanSuDung; thuoc.Add(t); } } } } } } } } ViewBag.thuocct = thuoc; var a = ur.GetAllUserById(id); return(View(a)); }
public ActionResult Edit(string id, string mathuoc, string tenthuoc, string donvitinh, int gia, string hansudung, string nhasanxuat, string ngaysanxuat, int soluong) { var ax = new ServiceReference1.thuocEntity(); ax.maThuoc = mathuoc; ax.tenThuoc = tenthuoc; ax.donViTinh = donvitinh; ax.nhaSanXuat = nhasanxuat; ax.ngaySanXuat = DateTime.Parse(ngaysanxuat); ax.soLuongThuoc = soluong; ax.giaThuoc = gia; ax.hanSuDung = hansudung; if (ModelState.IsValid) { sv.UpdateThuoc(ax); return(RedirectToAction("Index")); } return(View(ax)); }