作者:老岑
如何去根据状态来显示我们所需要的数据呢?
这个东西说起来很抽象,我先放一张图片上来说
我们点击垫付的时候回弹出一个模态框,回填数据,是否垫付,这样的弹出层。
可是我们按垫付之后它又要去到哪里?去到我们的记录表里面去。
可记录表里面有已垫付和未垫付,我们是如何把垫付表格里面的全是未垫付的数据传到记录表格的呢?
这个时候不罗嗦了,看代码:
public ActionResult SelseExpect(B_WebsiteAdvances LfWebsiteAdvances)
{
ReturnJson msg = new ReturnJson();
LfWebsiteAdvances.PaymentStatus = “已垫付”;
if (!string.IsNullOrEmpty(LfWebsiteAdvances.PaymentAmount.ToString()))
{
B_WebsiteAdvances dbWebsite = (from tbWebsiteAdvances in myModel.B_WebsiteAdvances
where tbWebsiteAdvances.WebsiteAdvancesID == LfWebsiteAdvances.WebsiteAdvancesID
select tbWebsiteAdvances).Single();
dbWebsite.PaymentAmount = LfWebsiteAdvances.PaymentAmount;
dbWebsite.PaymentStatus = LfWebsiteAdvances.PaymentStatus;
myModel.Entry(dbWebsite).State = System.Data.Entity.EntityState.Modified;
if (myModel.SaveChanges() > 0)
{
msg.State = true;
msg.Text = “垫付成功”;
}
else
{
msg.Text = “垫付失败”;
}
}
else
{
msg.Text = “数据异常”;
}
return Json(msg, JsonRequestBehavior.AllowGet);
}
这样就可以根据状态来显示我们所需要的数据了,我第一个全是未垫付,就是根据这个去判断的,如果我点击垫付之后,LfWebsiteAdvances.PaymentStatus = “已垫付”;根据这个去把我的状态改变为已垫付,然后数据就会跳出我这个只存放未垫付的表格,从而进入记录表格里面去。
这样就能够根据状态来显示自己所需要的数据了。