110,566
社区成员
发帖
与我相关
我的任务
分享
public ActionResult Create()
{
var user = this.GetCurrentUser();
ApplyBillModel appmodel = new ApplyBillModel();
return View(appmodel);
}
[HttpPost]
public ActionResult Create(ApplyBillModel viewmodel)
{
var user = this.GetCurrentUser();
ApplyBill model = new ApplyBill();
try
{
if (viewmodel.App_referRID == null)
{
return Json(new OperationResult(OperationResultType.Error, "请选择项目批次!"));
}
else
{
var userinfo = db.UserInfo.FirstOrDefault(e=>e.UserNumber == viewmodel.UserNumber);
if (userinfo == null)
{
return Json(new OperationResult(OperationResultType.Error, "该员工不存在!"));
}
else
{
var modelcheck = db.ApplyBill.FirstOrDefault(t => t.App_referRID == viewmodel.App_referRID && t.App_referUID == userinfo.UserID);
if (modelcheck!=null)
{
return Json(new OperationResult(OperationResultType.Error, "报名单已存在!"));
}
//更新主表
model.AppCreated = DateTime.Now;
// ...
model.App_referUID = userinfo.UserID;
model.AppSureAmount = 0;
model.AppSureLoan = 0;
db.Configuration.ValidateOnSaveEnabled = false;
db.ApplyBill.Add(model);
var save = db.SaveChanges();
}
}
return Json(new OperationResult(OperationResultType.Success, "创建成功"));
}
catch (Exception ex)
{
return Json(new OperationResult(OperationResultType.Error, "创建失败"));
}
}
#endregion