在上一篇说了数据回填,那么现在说说废票的提交吧,其实废票就是把改变字段的状态,就是把NULL或True都改为false的状态
//废票提交
$("#AodTicket").click( function () {
var aaa = $("#dAboTicketCause").val();
var aas = $("#DataTime").val();
var sssss=$("#sformInsertExaminee").serializeArray();
var asd = aaab;
//判断该票号是否已作废
if (asd.AbolishTicket != false) {
//废票提交
$.post("/TicketManagement/Bill/Dwwe?aas=" + aas, sssss, function (data) {
//console.log(data);
if (data.State = true) {
$("#sformInsertExaminee").resetForm();
}
layer.alert(data.Text, { icon: 0, title: '提示' });
})
} else {
$("#sformInsertExaminee").resetForm();
layer.alert("该票号已作废!");
}
})
提交过去在控制器接收
public ActionResult Dwwe(R_BillDetails aBillDetails,DateTime? aas)
{
ReturnJson retrunJson = new ReturnJson();
try{
//判断传过来的不管是空为是不为空到改为false
if (aBillDetails.AbolishTicket==null||aBillDetails.AbolishTicket!=null)
{
aBillDetails.AbolishTicket = false;
}
var dea = (from tb in myModuls.R_BillDetails
where tb.BillDetailsID==aBillDetails.BillDetailsID
select tb).Single();
dea.AbolishTicket = aBillDetails.AbolishTicket;
if (myModuls.SaveChanges()>0)
{
retrunJson.State = true;
retrunJson.Text = "废票成功";
}
else
{
retrunJson.State = false;
retrunJson.Text = "废票失败";
}
return Json(retrunJson, JsonRequestBehavior.AllowGet);
}
catch (Exception)
{
retrunJson.State = false;
retrunJson.Text = "数据异常";
//throw;
}
return Json("", JsonRequestBehavior.AllowGet);
}
输入票号点击废票,废票成功
输入同一个票号点击废票,提示票号已作废