示例#1
0
        public ActionResult ReverseContracts(ContractReverseViewModel model)
        {
            if (ModelState.IsValid)
            {
                //创建数据
                ContractReverse data = new ContractReverse();
                data.Id = model.Id;
                data.ReverseAmount = model.ReverseAmount;
                data.WithholdAmount = model.WithholdAmount;
                data.FactpaymentAmount = model.FactpaymentAmount;
                data.CreatorId = model.CreatorId;
                data.CreatorName = model.CreatorName;

                List<ContractReverseDetail> listDetail = new List<ContractReverseDetail>();
                if (model.Details != null)
                {
                    foreach (ContractReverseDetailViewModel m in model.Details)
                    {
                        ContractReverseDetail d = new ContractReverseDetail();
                        d.Id = m.Id;
                        d.ReverseId = 0;
                        d.ContractId = m.ContractId;
                        d.ReverseAmount = m.ReverseAmount;
                        d.WithholdAmount = m.WithholdAmount;
                        d.FactpaymentAmount = m.FactpaymentAmount;
                        listDetail.Add(d);
                    }
                }

                //保存数据
                string strErrText;
                ContractSystem contract = new ContractSystem();
                if (contract.InsertContractReverse(data, listDetail, LoginAccountId, LoginStaffName, out strErrText) > 0)
                {
                    return Json(string.Empty);
                }
                else
                {
                    return Json(strErrText);
                }
            }
            return View(model);
        }