public ActionResult AddForm(string keyValue, ContractModel model) { ContractEntity entity = new ContractEntity(); entity.ContractId = model.ContractId; entity.ContractMoney = model.ContractMoney; entity.ContractType = model.ContractType; entity.CustomerId = model.CustomerId; entity.CustomerName = model.CustomerName; entity.Deadline = model.Deadline; entity.Description = model.Description; entity.EffectiveDate = model.EffectiveDate; entity.PaymentMethod = model.PaymentMethod; entity.PhoneNumber = model.PhoneNumber; entity.ProjectLeader = model.ProjectLeader; entity.ServiceType = model.ServiceType.TrimEnd(new char[] { ',', ';' }); entity.SignSubject = model.SignSubject; entity.SignSubjectId = model.SignSubjectId; entity.SignType = model.SignType; entity.ContractCode = model.ContractCode; List <ContractServiceEntity> serviceEntityList = new List <ContractServiceEntity>(); if (!string.IsNullOrWhiteSpace(model.ServiceTypeId)) { var arrIds = model.ServiceTypeId.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); var arrNames = model.ServiceType.Split(new char[] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < arrIds.Length; i++) { ContractServiceEntity serviceEntity = new ContractServiceEntity(); serviceEntity.ServiceTypeId = arrIds[i]; serviceEntity.ServiceType = arrNames[i]; serviceEntity.ContractId = model.ContractId; serviceEntity.Create(); serviceEntityList.Add(serviceEntity); //合同编码的前置 if (string.IsNullOrWhiteSpace(entity.ContractCode)) { var dataItem = itemCache.GetDataItem(serviceEntity.ServiceTypeId); if (dataItem != null) { entity.ContractCode = dataItem.ItemValue; } } } } contractbll.AddForm(entity, serviceEntityList); return(Success("操作成功。")); }