public static int UpdateEntity(ClosureTool entity) { if (!entity.CreateTime.HasValue) { entity.CreateTime = DateTime.Now; } if (string.IsNullOrEmpty(entity.CreateUserAccount)) { entity.CreateUserAccount = ClientCookie.UserCode; } entity.LastUpdateTime = DateTime.Now; entity.LastUpdateUserAccount = ClientCookie.UserCode; entity.LastUpdateUserNameENUS = ClientCookie.UserNameENUS; entity.LastUpdateUserNameZHCN = ClientCookie.UserNameZHCN; if (entity.IsOptionOffered.HasValue && !entity.IsOptionOffered.Value) { entity.LeaseTerm = null; entity.Investment = null; entity.NPVRestaurantCashflows = null; entity.Yr1SOI = null; entity.IRR = null; entity.CompAssumption = null; entity.CashflowGrowth = null; } var result = Update(entity); var closureInfo = ClosureInfo.GetByProjectId(entity.ProjectId); if (closureInfo != null) { closureInfo.UpdateRelocation(entity.IsOptionOffered ?? false); } var closurePackage = ClosurePackage.Get(entity.ProjectId); if (closurePackage != null) { closurePackage.UpdateRelocation(entity.IsOptionOffered ?? false); } return(result); }
public void Save(bool pushOrNot) { using (TransactionScope tranScope = new TransactionScope()) { var projectInfo = ProjectInfo.Get(Id); if (projectInfo == null) { ProjectId = ProjectInfo.CreateDLProject(Id, FlowCode.Closure, USCode, NodeCode.Start, ClientCookie.UserCode, pushOrNot); var closureInfo = new ClosureInfo(); closureInfo.Id = Guid.NewGuid(); closureInfo.ProjectId = ProjectId; closureInfo.USCode = USCode; closureInfo.ActualCloseDate = CloseDate; closureInfo.ClosureTypeCode = ClosureTypeCode; closureInfo.ClosureReasonCode = ClosureReasonCode; closureInfo.ClosureReasonRemark = ClosureReasonRemark; closureInfo.RelocationCode = RelocationCode; closureInfo.CreateDate = DateTime.Now; closureInfo.CreateUserAccount = ClientCookie.UserCode; closureInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; closureInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; closureInfo.Add(); var closurePackage = new ClosurePackage(); closurePackage.Id = Guid.NewGuid(); closurePackage.ProjectId = ProjectId; closurePackage.RelocationPipelineID = RelocatedPipelineID; closurePackage.IsHistory = false; closurePackage.CreateUserAccount = ClientCookie.UserCode; closurePackage.CreateTime = DateTime.Now; closurePackage.Add(); var closureConsInvtChecking = new ClosureConsInvtChecking(); closureConsInvtChecking.Id = Guid.NewGuid(); closureConsInvtChecking.ProjectId = ProjectId; closureConsInvtChecking.IsHistory = false; closureConsInvtChecking.CreateTime = DateTime.Now; closureConsInvtChecking.TotalActual = Closure_WO_Total_Act; closureConsInvtChecking.ClosingCostActual = Closure_ClosingCost_Act; closureConsInvtChecking.Add(); var closureMemo = new ClosureMemo(); closureMemo.Id = Guid.NewGuid(); closureMemo.ProjectId = ProjectId; closureMemo.CreateTime = DateTime.Now; closureMemo.ClosureNature = ClosureNatureType.Permanent; closureMemo.Status = true; closureMemo.Compensation = Closure_Compensation_Act; closureMemo.Add(); } else { ProjectId = projectInfo.ProjectId; projectInfo.IsPushed = pushOrNot; projectInfo.Update(); var closureInfo = ClosureInfo.FirstOrDefault(i => i.ProjectId == ProjectId); if (closureInfo != null) { closureInfo.ActualCloseDate = CloseDate; closureInfo.ClosureTypeCode = ClosureTypeCode; closureInfo.ClosureReasonCode = ClosureReasonCode; closureInfo.ClosureReasonRemark = ClosureReasonRemark; closureInfo.RelocationCode = RelocationCode; closureInfo.Update(); } else { closureInfo = new ClosureInfo(); closureInfo.Id = Guid.NewGuid(); closureInfo.ProjectId = ProjectId; closureInfo.USCode = USCode; closureInfo.ActualCloseDate = CloseDate; closureInfo.ClosureTypeCode = ClosureTypeCode; closureInfo.ClosureReasonCode = ClosureReasonCode; closureInfo.ClosureReasonRemark = ClosureReasonRemark; closureInfo.RelocationCode = RelocationCode; closureInfo.CreateDate = DateTime.Now; closureInfo.CreateUserAccount = ClientCookie.UserCode; closureInfo.CreateUserNameENUS = ClientCookie.UserNameENUS; closureInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN; closureInfo.Add(); } var closurePackage = ClosurePackage.Get(ProjectId); if (closurePackage != null) { closurePackage.RelocationPipelineID = RelocatedPipelineID; closurePackage.Update(); } else { closurePackage = new ClosurePackage(); closurePackage.Id = Guid.NewGuid(); closurePackage.ProjectId = ProjectId; closurePackage.RelocationPipelineID = RelocatedPipelineID; closurePackage.IsHistory = false; closurePackage.CreateUserAccount = ClientCookie.UserCode; closurePackage.CreateTime = DateTime.Now; closurePackage.Add(); } var closureConsInvtChecking = ClosureConsInvtChecking.Get(ProjectId); if (closureConsInvtChecking != null) { closureConsInvtChecking.TotalActual = Closure_WO_Total_Act; closureConsInvtChecking.ClosingCostActual = Closure_ClosingCost_Act; closureConsInvtChecking.Update(); } else { closureConsInvtChecking = new ClosureConsInvtChecking(); closureConsInvtChecking.Id = Guid.NewGuid(); closureConsInvtChecking.ProjectId = ProjectId; closureConsInvtChecking.IsHistory = false; closureConsInvtChecking.CreateTime = DateTime.Now; closureConsInvtChecking.TotalActual = Closure_WO_Total_Act; closureConsInvtChecking.ClosingCostActual = Closure_ClosingCost_Act; closureConsInvtChecking.Add(); } var closureMemo = ClosureMemo.FirstOrDefault(i => i.ProjectId == ProjectId); if (closureMemo != null) { closureMemo.Compensation = Closure_Compensation_Act; closureMemo.Update(); } else { closureMemo = new ClosureMemo(); closureMemo.Id = Guid.NewGuid(); closureMemo.ProjectId = ProjectId; closureMemo.CreateTime = DateTime.Now; closureMemo.ClosureNature = ClosureNatureType.Permanent; closureMemo.Status = true; closureMemo.Compensation = Closure_Compensation_Act; closureMemo.Add(); } } tranScope.Complete(); } }