Ejemplo n.º 1
0
        public async Task<ActionResult> Edit(EM_ExpenseAccount model, string FileIds, string DetailIds)
        {
            var entity = expenseAccountRepo.GetById(model.Id);
            if (model == null)
            {
                return Json(new { code = 0, message = "报销单不存在!" }, JsonRequestBehavior.AllowGet);
            }
            var IsRepeat = expenseAccountRepo.GetMany(o => o.EANumber == model.EANumber&&o.Id!=model.Id).Any();
            if (IsRepeat)
            {
                return Json(new { code = 0, message = "报销单号已存在,请修改报销单号" }, JsonRequestBehavior.AllowGet);
            }
            if (string.IsNullOrEmpty(DetailIds))
            {
                return Json(new { code = 0, message = "报销单明细上传失败,请重试" }, JsonRequestBehavior.AllowGet);
            }

            entity = Mapper.Map<EM_ExpenseAccount, EM_ExpenseAccount>(model, entity);
            entity.ApproveStatus = entity.ApproveStatus == 0 ? (int)ExpenseAccountApproveStatus.Created : entity.ApproveStatus;
            entity.ModifyDate = DateTime.Now;
            entity.Modifier = ViewHelp.GetUserName();
            var result = expenseAccountRepo.SaveChanges();
            //添加状态变更记录
            expenseAccountRepo.AddApproveHistory(model.Id, model.ApproveStatus, "", ViewHelp.GetUserName(),"");
            if (result > 0)
            {
                //更新单身
                await expenseAccountDetailRepo.UpdateDetailExpenseAccountId(model.Id, DetailIds);
                await expenseAccountFileRepo.UpdateFileExpenseAccountId(model.Id, FileIds);
                Log(model);
                return Json(new { code = 1, model = model });
            }
            else
                return Json(new { code = 0, message = "保存失败,请重试" });
        }
Ejemplo n.º 2
0
 public async Task<ActionResult> Add()
 {
     var model = new EM_ExpenseAccount();
     InitBodys();
     model.OccurDate = DateTime.Now;
     model.ApplyDate = DateTime.Now;
     model.Name = ViewHelp.GetUserName();
     return View("AddOrEdit",model);
 }