public ActionResult RecordAdjust(RecordAdjustModel model) { FormsAuthenticationTicket authentication = MvcApplication.GetAuthenticationTicket(); int mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); model.summary_list = summary_service.SearchByManagerID(mana_id).ToList(); List<T_Summary_Record> summary_record_list = summary_record_service.Table().ToList(); model.summary_count_list = CreateCountSummaryRecord(model.summary_list, summary_record_list); if (ModelState.IsValid) { string check_result = CheckRecordAdjust(model); if (!string.IsNullOrEmpty(check_result)) { return Content(ReturnMessageAndRedirect(check_result, "Main", "RecordAdjust")); } else { for (int i= 0; i< model.summ_id.Count();i++) { int id = model.summ_id[i]; decimal adjust_amount = model.adjust_amont[i]; SummaryCountModel summary_count = model.summary_count_list.Where(M => M.summary_id == id).FirstOrDefault(); if (summary_count != null) { //如果调整数和数据库记录数不一致,则需要插入数据 decimal diff = adjust_amount - summary_count.summary_sum_amount; if (diff != 0) { T_Summary_Record insert = new T_Summary_Record(); insert.mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); insert.summ_id = id; insert.summ_tran_id = 0; insert.loan_type_code = 0; insert.amount = diff; insert.tran_amount = 0; insert.remark = "资金调整,自动插入"; insert.add_time = DateTime.Now; insert.is_deal = true; if (diff > 0) { insert.reco_type_code = WebCont.RECORD_TYPE_INCOME; } else { insert.reco_type_code = WebCont.RECORD_TYPE_PAY; } summary_record_service.DelayInsert(insert); } } } summary_record_service.DelaySubmit(); } } else { return View(model); } return RedirectToAction("RecordAdjust", "Main"); }
private T_Summary_Record CreateSummaryRecord(RecordModel model, FormsAuthenticationTicket authentication, decimal record_amount, decimal tran_record_amount, bool is_deal ) { T_Summary_Record insert = new T_Summary_Record(); insert.mana_id = authentication == null ? 0 : Convert.ToInt32(authentication.Name); insert.reco_type_code = model.record_type_code; insert.summ_id = model.summary_id; insert.summ_tran_id = model.summary_transfer_id; insert.loan_type_code = model.loan_type_code; insert.amount = record_amount; insert.tran_amount = tran_record_amount; insert.remark = model.remark == null ? "" : model.remark.Trim(); insert.add_time = model.add_time; insert.is_deal = is_deal; return insert; }