分配床位
给病人分配床位,我们怎么去实现呢?我的做法可能有点麻烦,我们先获取到选中的行,点击分配床位就会弹出一个模态框,然后输入床位号,然后点击保存就分配成功了;
//声明变量
var AdmissionFormids;
var PatientSurfaceIDs;
//分配床位
function sjfoasjfao() {
//获取选中行
var checkStatus = layuiTable.checkStatus(‘tabPatientSurface’);
var dfhshaar = checkStatus.data;
if (checkStatus.data.length == “1”) {
获取到床位的状态,初始状态是False
Stateaan = dfhshaar[0].Stateaan;
获取到床位的状态,赋值:
Stateaan = true;
AdmissionFormids = dfhshaar[0].AdmissionFormID;
PatientSurfaceIDs = dfhshaar[0].AdmissionFormID;
如果入院表和病人表的ID不一样,如果要用到病人ID,这里就不能这样写,要用到病人ID就要在这里转到控制器去查询。
//弹出修改模态框
$("#modBedNumber").modal(“show”);
} else {
layer.alert(“请选择需要分配床位的一条病人信息!”);
}
}
//保存分配床位
function fsoeshuie() {
var BedNumber = $("#formBedNumber [name=‘BedNumber’]").val();床号
var ClinicalID = $("#formUpdateExamine [name=‘ClinicalCenterName’]").val();科室
var CourtyardStateID = 2;//状态赋值
if (BedNumber != “”) {
//加载层
var load = layer.load();
//查询床号ID
$.post("/NursesStation/Bedbrowse/selectStateaan", { ClinicalID: ClinicalID, BedNumber: BedNumber }, function (data) {
var BedNumberIDa = data[0].BedNumberID;
$.post("/NursesStation/Bedbrowse/UpdateBedNumber", {
BedNumberID: BedNumberIDa,
AdmissionFormID: AdmissionFormids,
Stateaan: Stateaan,
CourtyardStateID: CourtyardStateID,
PatientSurfaceID: PatientSurfaceIDs
}, function (data) {
//关闭加载层
layer.close(load);
if (data.State) {
$("#modBedNumber").modal('hide');
layer.msg(data.Text, { icon: 1, title: "提示" });
//刷新表格
tabPatientSurface.reload();
tabPatientSurface1.reload();
} else {
layer.alert(data.Text, { icon: 0, title: "提示" });
}
});
});
} else {
layer.alert('请填写完整', { icon: 0 });
}
}
控制器跟修改是差不多的
public ActionResult UpdateBedNumber(PW_BedNumber pwBedNumber, PW_AdmissionForm pwAdmissionForm,bool Stateaan,int CourtyardStateID,PW_PatientSurface pwPatientSurface)
{
ReturnJsonVo returnJson = new ReturnJsonVo();
returnJson.State = false;
try
{
int countBedNumber = (from tbBedNumber in myModel.PW_BedNumber
where tbBedNumber.BedNumberID==pwBedNumber.BedNumberID && tbBedNumber.Stateaan == Stateaan
select tbBedNumber).Count();
if (countBedNumber == 0)
{
PW_AdmissionForm dbAdmissionForm = (from tbAdmissionForm in myModel.PW_AdmissionForm
where tbAdmissionForm.AdmissionFormID ==pwAdmissionForm.AdmissionFormID
select tbAdmissionForm).Single();
//修改PW_AdmissionForm入院表里面的床号ID
dbAdmissionForm.BedNumberID = pwAdmissionForm.BedNumberID;
myModel.Entry(dbAdmissionForm).State = EntityState.Modified;
PW_BedNumber dbBedNumber = (from tbBedNumber in myModel.PW_BedNumber
where tbBedNumber.BedNumberID == pwBedNumber.BedNumberID
select tbBedNumber).Single();
dbBedNumber.Stateaan = pwBedNumber.Stateaan;
myModel.Entry(dbBedNumber).State = EntityState.Modified;
PW_PatientSurface dbCourtyardState = (from tbPatientSurface in myModel.PW_PatientSurface
where tbPatientSurface.PatientSurfaceID == pwPatientSurface.PatientSurfaceID
select tbPatientSurface).Single();
//修改PW_PatientSurface病人表里面的在院状态ID
dbCourtyardState.CourtyardStateID = pwPatientSurface.CourtyardStateID;
myModel.Entry(dbCourtyardState).State = EntityState.Modified;
if (myModel.SaveChanges() > 0)
{
returnJson.State = true;
returnJson.Text = “分配成功-”;
}
else
{
returnJson.Text = “分配失败”;
}
}
else
{
returnJson.Text = “该床号已有病人!”;
}
}
catch (Exception)
{
returnJson.Text = “数据异常!”;
}
return Json(returnJson, JsonRequestBehavior.AllowGet);
}
上面还有很多不足的地方,还要完善