/// <summary> /// /// </summary> /// <param name="custID"></param> /// <returns></returns> public ActionResult ChangeDeadline(int custID) { CWICCard cwiccd = new CWICCard(); Customer cust = cwiccd.FindCust(custID); ChangeDeadlineModel deadline = new ChangeDeadlineModel { ID = cust.ID, UserCode = cust.UserName, Type = cust.Type, OldDeadline = cust.Deadline, NewDeadline = DateTime.Parse("2017-1-1") }; return(View(deadline)); }
public async Task <ActionResult> ChangeDeadline(ChangeDeadlineModel model) { if (!ModelState.IsValid) { ModelState.AddModelError("", "参数设置不正确"); return(View(model)); } Log log = LogFactory.GetLogger("ChangeDeadline"); try { CWICCard cwiccd = new CWICCard(); Customer cust = await cwiccd.FindCustAsync(model.ID); if (cust != null) { if ((int)cust.Type < 2) { ModelState.AddModelError("", "临时卡,无法设置使用期限"); return(View(model)); } string olddeadline = cust.Deadline.ToString(); cust.Deadline = model.NewDeadline; Response resp = cwiccd.UpdateCust(cust); if (resp.Code == 1) { string oprtname = User.Identity.Name; string utype = ""; if (cust.Type == EnmICCardType.FixedLocation) { utype = "固定"; } else if (cust.Type == EnmICCardType.Periodical) { utype = "定期"; } FixUserChargeLog fixlog = new FixUserChargeLog { UserName = cust.UserName, PlateNum = cust.PlateNum, UserType = utype, Proof = "手动", LastDeadline = olddeadline, CurrDeadline = cust.Deadline.ToString(), FeeType = "", FeeUnit = 0, CurrFee = 0, RecordDTime = DateTime.Now, OprtCode = oprtname }; await new CWTariffLog().AddFixLogAsync(fixlog); } } return(RedirectToAction("Index")); } catch (Exception ex) { log.Error(ex.ToString()); ModelState.AddModelError("", "系统异常,请联系厂家!"); return(View(model)); } }