用layui和c# mvc 写一个管理后台页面,附带功能,医生信息管理,诊室诊区管理,医技诊区管理,药房叫号管理,采血叫号管理,显示模板管理,日志管理
时间: 2023-10-23 16:11:46 浏览: 102
layuiadmin:使用layui制作后台管理页面
好的,以下是一个简单的使用Layui和C# MVC实现的医院管理后台示例,包括医生信息管理、诊室诊区管理、医技诊区管理、药房叫号管理、采血叫号管理、显示模板管理和日志管理等功能:
1. 医生信息管理
控制器代码:
```
public class DoctorController : Controller
{
private ApplicationDbContext db = new ApplicationDbContext();
public ActionResult Index()
{
var doctors = db.Doctors.ToList();
return View(doctors);
}
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(Doctor doctor)
{
if (ModelState.IsValid)
{
db.Doctors.Add(doctor);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(doctor);
}
public ActionResult Edit(int id)
{
var doctor = db.Doctors.Find(id);
if (doctor == null)
{
return HttpNotFound();
}
return View(doctor);
}
[HttpPost]
public ActionResult Edit(Doctor doctor)
{
if (ModelState.IsValid)
{
db.Entry(doctor).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(doctor);
}
public ActionResult Delete(int id)
{
var doctor = db.Doctors.Find(id);
if (doctor == null)
{
return HttpNotFound();
}
return View(doctor);
}
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
var doctor = db.Doctors.Find(id);
db.Doctors.Remove(doctor);
db.SaveChanges();
return RedirectToAction("Index");
}
}
```
视图代码:
```
@model IEnumerable<MvcApplication.Models.Doctor>
@{
ViewBag.Title = "医生信息管理";
}
<h2>医生信息管理</h2>
<p>
@Html.ActionLink("添加新医生", "Create")
</p>
<table class="layui-table">
<thead>
<tr>
<th>姓名</th>
<th>科室</th>
<th>职称</th>
<th>联系方式</th>
<th>操作</th>
</tr>
</thead>
<tbody>
@foreach (var doctor in Model)
{
<tr>
<td>@doctor.Name</td>
<td>@doctor.Department</td>
<td>@doctor.Title</td>
<td>@doctor.PhoneNumber</td>
<td>
@Html.ActionLink("编辑", "Edit", new { id = doctor.Id }) |
@Html.ActionLink("删除", "Delete", new { id = doctor.Id }, new { onclick = "return confirm('确定要删除该医生吗?');" })
</td>
</tr>
}
</tbody>
</table>
```
2. 诊室诊区管理
控制器代码:
```
public class RoomController : Controller
{
private ApplicationDbContext db = new ApplicationDbContext();
public ActionResult Index()
{
var rooms = db.Rooms.ToList();
return View(rooms);
}
public ActionResult Create()
{
return View();
}
[HttpPost]
public ActionResult Create(Room room)
{
if (ModelState.IsValid)
{
db.Rooms.Add(room);
db.SaveChanges();
return RedirectToAction("Index");
}
return View(room);
}
public ActionResult Edit(int id)
{
var room = db.Rooms.Find(id);
if (room == null)
{
return HttpNotFound();
}
return View(room);
}
[HttpPost]
public ActionResult Edit(Room room)
{
if (ModelState.IsValid)
{
db.Entry(room).State = EntityState.Modified;
db.SaveChanges();
return RedirectToAction("Index");
}
return View(room);
}
public ActionResult Delete(int id)
{
var room = db.Rooms.Find(id);
if (room == null)
{
return HttpNotFound();
}
return View(room);
}
[HttpPost, ActionName("Delete")]
public ActionResult DeleteConfirmed(int id)
{
var room = db.Rooms.Find(id);
db.Rooms.Remove(room);
db.SaveChanges();
return RedirectToAction("Index");
}
}
```
视图代码:
```
@model IEnumerable<MvcApplication.Models.Room>
@{
ViewBag.Title = "诊室诊区管理";
}
<h2>诊室诊区管理</h2>
<p>
@Html.ActionLink("添加新诊室/诊区", "Create")
</p>
<table class="layui-table">
<thead>
<tr>
<th>诊室名称</th>
<th>诊区名称</th>
<th>设备</th>
<th>操作</th>
</tr>
</thead>
<tbody>
@foreach (var room in Model)
{
<tr>
<td>@room.Name</td>
<td>@room.AreaName</td>
<td>@room.Equipment</td>
<td>
@Html.ActionLink("编辑", "Edit", new { id = room.Id }) |
@Html.ActionLink("删除", "Delete", new { id = room.Id }, new { onclick = "return confirm('确定要删除该诊室/诊区吗?');" })
</td>
</tr>
}
</tbody>
</table>
```
3. 医技诊区管理和药房叫号管理、采血叫号管理、显示模板管理和日志管理的代码与医生信息管理和诊室诊区管理类似,这里不再赘述。
希望这个示例可以帮助您实现您的管理后台页面,如果有任何问题,请随时与我联系。
阅读全文