Beispiel #1
0
        public override void GenerateDefaultWorkflowInfo(string projectId)
        {
            var entity = new RebuildConsInfo();

            entity.ProjectId          = projectId;
            entity.Id                 = Guid.NewGuid();
            entity.CreateTime         = DateTime.Now;
            entity.CreateUserAccount  = ClientCookie.UserCode;
            entity.CreateUserNameENUS = ClientCookie.UserNameENUS;
            entity.CreateUserNameZHCN = ClientCookie.UserNameZHCN;
            entity.IsHistory          = false;

            var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == projectId);

            if (rbdInfo != null)
            {
                entity.ReinBasicInfo = new ReinvestmentBasicInfo
                {
                    GBDate             = rbdInfo.GBDate,
                    ReopenDate         = rbdInfo.ReopenDate,
                    ConsCompletionDate = rbdInfo.ConstCompletionDate
                };
            }
            Add(entity);
        }
Beispiel #2
0
        public static void PopulateAppUsers(GBMemo entity)
        {
            var approvedUsers = ApproveDialogUser.GetApproveDialogUser(entity.Id.ToString());

            entity.AppUsers = new ApproveUsers();
            if (approvedUsers != null)
            {
                var simp = new SimpleEmployee
                {
                    Code = approvedUsers.ConstructionManagerCode
                };
                entity.AppUsers.ConstructionManager = simp;
            }
            else
            {
                var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == entity.ProjectId);
                if (rbdInfo != null)
                {
                    var simp = new SimpleEmployee
                    {
                        Code = rbdInfo.CMAccount
                    };
                    entity.AppUsers.ConstructionManager = simp;
                }
            }
        }
Beispiel #3
0
        private int?StartProcess(TaskWork task)
        {
            CreateUserAccount = LastUpdateUserAccount;
            var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId));

            if (rbdInfo == null)
            {
                throw new Exception("Could not find the Rebuild Info, please check it!");
            }
            var processDataFields = SetWorkflowDataFields(task);

            return(K2FxContext.Current.StartProcess(WorkflowProcessCode, CreateUserAccount, processDataFields));
        }
Beispiel #4
0
        public void Save(string action = "")
        {
            using (var scope = new TransactionScope())
            {
                if (Id == Guid.Empty)
                {
                    Id                 = Guid.NewGuid();
                    CreateTime         = DateTime.Now;
                    LastUpdateTime     = DateTime.Now;
                    CreateUserAccount  = ClientCookie.UserCode;
                    CreateUserNameZHCN = ClientCookie.UserNameZHCN;
                    CreateUserNameENUS = ClientCookie.UserNameENUS;
                    IsHistory          = false;
                    Add(this);
                }
                else
                {
                    LastUpdateTime = DateTime.Now;
                    Update(this);
                }
                if (ReinBasicInfo != null)
                {
                    ReinBasicInfo.ConsInfoID = Id;
                    ReinBasicInfo.Save();
                    var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == ProjectId);
                    if (rbdInfo != null)
                    {
                        rbdInfo.GBDate              = ReinBasicInfo.GBDate;
                        rbdInfo.ReopenDate          = ReinBasicInfo.ReopenDate;
                        rbdInfo.ConstCompletionDate = ReinBasicInfo.ConsCompletionDate;
                        rbdInfo.Update();
                    }
                }

                if (ReinCost != null)
                {
                    ReinCost.ConsInfoID = Id;
                    ReinCost.SaveByRebuild();
                }

                if (WriteOff != null)
                {
                    WriteOff.ConsInfoID = Id;
                    WriteOff.SaveByRebuild();
                }

                SaveApproveUsers(action);
                SaveComments(action);
                scope.Complete();
            }
        }
Beispiel #5
0
        public override string Edit()
        {
            var taskUrl = string.Format("/Rebuild/Main#/ConsInfo?projectId={0}", ProjectId);

            using (var scope = new TransactionScope())
            {
                var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId.Equals(ProjectId));
                if (rbdInfo == null)
                {
                    throw new Exception("Could not find the Rebuild Info, please check it!");
                }
                var task = rbdInfo.GenerateTaskWork(FlowCode.Rebuild_ConsInfo, WorkflowCode, WorkflowCode, taskUrl);
                task.ActivityName = NodeCode.Start;
                task.ActionName   = SetTaskActionName(ProjectId);
                TaskWork.Add(task);

                var package = RebuildPackage.GetRebuildPackageInfo(ProjectId);
                if (package != null)
                {
                    package.ProjectId = ProjectId;
                    package.CompleteActorPackageTask(rbdInfo.AssetActorAccount);
                }

                IsHistory = true;
                Update(this);

                ProjectInfo.Reset(ProjectId, FlowCode.Rebuild_ConsInfo);

                Mapper.CreateMap <RebuildConsInfo, RebuildConsInfo>();
                var form = Mapper.Map <RebuildConsInfo>(this);
                form.Id         = Guid.Empty;
                form.ProcInstID = null;
                form.IsHistory  = false;
                form.Comments   = null;
                form.Save("Edit");

                CopyAttachment(Id.ToString(), form.Id.ToString());
                CopyAppUsers(Id.ToString(), form.Id.ToString());
                CopyReinvestmentBasicInfo(ReinBasicInfo, Id);
                CopyReinvestmentCost(ReinCost, Id);
                CopyWriteOffAmount(WriteOff, Id);
                scope.Complete();
            }

            return(taskUrl);
        }
Beispiel #6
0
        public RebuildConsInvtChecking GetConsInvtChecking(string strProjectId, string entityId = "")
        {
            ProjectId = strProjectId;
            RebuildConsInvtChecking entity = null;

            if (string.IsNullOrEmpty(entityId))
            {
                entity = Search(e => e.ProjectId.Equals(strProjectId) && !e.IsHistory).FirstOrDefault();
            }
            else
            {
                entity = Search(e => e.Id.ToString().Equals(entityId)).FirstOrDefault();
            }

            var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == strProjectId);

            UsCode = rbdInfo.USCode;
            if (entity != null)
            {
                entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId);
                entity.ApprovalType     = entity.GetApprovalType();

                entity.IsShowEdit   = ProjectInfo.IsFlowEditable(strProjectId, FlowCode.Rebuild_ConsInvtChecking);
                entity.IsShowRecall = ProjectInfo.IsFlowRecallable(strProjectId, FlowCode.Rebuild_ConsInvtChecking);
            }
            else
            {
                entity = new RebuildConsInvtChecking();
                entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId);
                entity.ProjectId        = strProjectId;
            }
            if (ClientCookie.UserCode.Equals(rbdInfo.PMAccount))
            {
                entity.IsShowSave = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.Rebuild_ConsInvtChecking);
            }
            PopulateAppUsers(entity);
            return(entity);
        }
Beispiel #7
0
        public RebuildConsInfo GetConsInfo(string strProjectId, string entityId = "")
        {
            RebuildConsInfo entity = null;

            if (string.IsNullOrEmpty(entityId))
            {
                entity = Search(e => e.ProjectId.Equals(strProjectId) && !e.IsHistory).FirstOrDefault();
            }
            else
            {
                entity = Search(e => e.Id.ToString().Equals(entityId)).FirstOrDefault();
            }

            if (entity != null)
            {
                entity.IsProjectFreezed = CheckIfFreezeProject(strProjectId);
                entity.ReinCost         = ReinvestmentCost.GetByConsInfoId(entity.Id);
                entity.ReinBasicInfo    = ReinvestmentBasicInfo.GetByConsInfoId(entity.Id);
                var attachmentReinCost = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "ReinCost");
                if (entity.ReinCost != null && attachmentReinCost != null)
                {
                    entity.ReinCost.ReinCostUser = attachmentReinCost.CreatorNameENUS;
                    entity.ReinCost.ReinCostTime = attachmentReinCost.CreateTime;
                }

                if (entity.ReinBasicInfo == null)
                {
                    var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == strProjectId);
                    if (rbdInfo != null)
                    {
                        entity.ReinBasicInfo = new ReinvestmentBasicInfo
                        {
                            GBDate             = rbdInfo.GBDate,
                            ReopenDate         = rbdInfo.ReopenDate,
                            ConsCompletionDate = rbdInfo.ConstCompletionDate
                        };
                    }
                }
                entity.WriteOff = WriteOffAmount.GetByConsInfoId(entity.Id);
                var attachmentWriteOff = Attachment.FirstOrDefault(e => e.RefTableID == entity.Id.ToString() && e.TypeCode == "WriteOff");
                if (entity.WriteOff != null && attachmentWriteOff != null)
                {
                    entity.WriteOff.WriteOffUser = attachmentWriteOff.CreatorNameENUS;
                    entity.WriteOff.WriteOffTime = attachmentWriteOff.CreateTime;
                }

                entity.IsShowEdit   = ProjectInfo.IsFlowEditable(strProjectId, FlowCode.Rebuild_ConsInfo);
                entity.IsShowRecall = ProjectInfo.IsFlowRecallable(strProjectId, FlowCode.Rebuild_ConsInfo);
                entity.IsShowSave   = ProjectInfo.IsFlowSavable(strProjectId, FlowCode.Rebuild_ConsInfo);
            }
            else
            {
                var rbdInfo = RebuildInfo.FirstOrDefault(e => e.ProjectId == strProjectId);
                if (rbdInfo != null)
                {
                    entity = new RebuildConsInfo
                    {
                        ReinBasicInfo =
                            new ReinvestmentBasicInfo
                        {
                            GBDate     = rbdInfo.GBDate,
                            ReopenDate = rbdInfo.ReopenDate
                        },
                        IsProjectFreezed = CheckIfFreezeProject(strProjectId),
                        ProjectId        = strProjectId
                    };
                }
            }
            PopulateAppUsers(entity);
            return(entity);
        }
Beispiel #8
0
        public void Save(bool pushOrNot)
        {
            using (TransactionScope tranScope = new TransactionScope())
            {
                var projectInfo = ProjectInfo.Get(Id);
                if (projectInfo == null)
                {
                    ProjectId = ProjectInfo.CreateDLProject(Id, FlowCode.Rebuild, USCode, NodeCode.Start, ClientCookie.UserCode, pushOrNot);

                    var rebuildInfo = new RebuildInfo();
                    rebuildInfo.Id                 = Guid.NewGuid();
                    rebuildInfo.ProjectId          = ProjectId;
                    rebuildInfo.USCode             = USCode;
                    rebuildInfo.CreateTime         = DateTime.Now;
                    rebuildInfo.CreateUserAccount  = ClientCookie.UserCode;
                    rebuildInfo.CreateUserNameENUS = ClientCookie.UserNameENUS;
                    rebuildInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN;
                    rebuildInfo.GBDate             = GBDate;
                    rebuildInfo.ReopenDate         = ReopenDate;
                    rebuildInfo.Add();

                    var rebuildPackage = new RebuildPackage();
                    rebuildPackage.Id                    = Guid.NewGuid();
                    rebuildPackage.ProjectId             = ProjectId;
                    rebuildPackage.IsHistory             = false;
                    rebuildPackage.ChangeLandlordType    = ChangeLandlordType;
                    rebuildPackage.NewLandlord           = ChangeLandLordDESC;
                    rebuildPackage.ChangeRentalType      = ChangeRentalType;
                    rebuildPackage.ChangeRentalTypeDESC  = ChangeRentalTypeDESC;
                    rebuildPackage.ChangeLeaseTermType   = ChangeLeaseTermType;
                    rebuildPackage.ChangeLeaseTermDESC   = ChangeLeaseTermDESC;
                    rebuildPackage.ChangeRedLineType     = ChangeRedLineType;
                    rebuildPackage.ChangeRedLineTypeDESC = ChangeRedLineTypeDESC;
                    //rebuildPackage.NewRentalStructure = NewRentalStructure;
                    rebuildPackage.Add();

                    var projectContractInfo = new ProjectContractInfo();
                    projectContractInfo.Id                           = Guid.NewGuid();
                    projectContractInfo.ProjectId                    = ProjectId;
                    projectContractInfo.ContractInfoId               = Guid.Empty;
                    projectContractInfo.CreatedTime                  = DateTime.Now;
                    projectContractInfo.WriteBack                    = false;
                    projectContractInfo.EditMode                     = EditMode;
                    projectContractInfo.PartyAFullName               = PartyAFullName;
                    projectContractInfo.McDLegalEntity               = ContractEntityName;
                    projectContractInfo.McDOwnership                 = McdOwnership;
                    projectContractInfo.ContactPerson                = ContactPerson;
                    projectContractInfo.ContactMode                  = ContactMode;
                    projectContractInfo.RentType                     = RentType;
                    projectContractInfo.TotalLeasedArea              = RentSize;
                    projectContractInfo.LeasePurchaseTerm            = ContractTerm;
                    projectContractInfo.LeasePurchase                = ContractType;
                    projectContractInfo.StartDate                    = ContractStartDate;
                    projectContractInfo.EndDate                      = ContraceEndDate;
                    projectContractInfo.StartYear                    = ContractStartYear;
                    projectContractInfo.EndYear                      = ContraceEndYear;
                    projectContractInfo.RentCommencementDate         = RentPaymentStartDate;
                    projectContractInfo.DeadlineToNotice             = DeadlineToNoticeLL;
                    projectContractInfo.Changedafter2010             = ChangedAfter2010;
                    projectContractInfo.RentStructure                = RentStructure;
                    projectContractInfo.WithEarlyTerminationClause   = EarlyTerminationClause;
                    projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription;
                    projectContractInfo.RentPaymentArrangement       = RentPaymentArrangement;
                    projectContractInfo.HasDeposit                   = Deposit;
                    projectContractInfo.DepositAmount                = DepositAmount;
                    projectContractInfo.RefundableDate               = WhenRefund;
                    projectContractInfo.WithPenaltyClause            = withPenaltyClause;
                    projectContractInfo.HasBankGuarantee             = BankGuarantee;
                    projectContractInfo.BGNumber                     = BankGuaranteeNumber;
                    projectContractInfo.BGAmount                     = BankGuaranteeAmount;
                    projectContractInfo.BGCommencementDate           = BGCommencementDate;
                    projectContractInfo.BGEndDate                    = BGEndDate;
                    projectContractInfo.Add();

                    var rebuildConsInfo = new RebuildConsInfo();
                    rebuildConsInfo.Id                = Guid.NewGuid();
                    rebuildConsInfo.ProjectId         = ProjectId;
                    rebuildConsInfo.IsHistory         = false;
                    rebuildConsInfo.CreateTime        = DateTime.Now;
                    rebuildConsInfo.CreateUserAccount = ClientCookie.UserCode;
                    rebuildConsInfo.Add();

                    var reinvestmentBasicInfo = new ReinvestmentBasicInfo();
                    reinvestmentBasicInfo.ConsInfoID        = rebuildConsInfo.Id;
                    reinvestmentBasicInfo.EstimatedSeatNo   = OriginalSeatNO;
                    reinvestmentBasicInfo.RightSizingSeatNo = AfterRebuildSeatNO;
                    reinvestmentBasicInfo.NewDesignType     = AfterRebuildDesignType;
                    reinvestmentBasicInfo.NewOperationSize  = AfterRebuildOperationArea;
                    reinvestmentBasicInfo.Add();

                    var rebuildConsInvtChecking = new RebuildConsInvtChecking();
                    rebuildConsInvtChecking.Id        = Guid.NewGuid();
                    rebuildConsInvtChecking.ProjectId = ProjectId;
                    rebuildConsInvtChecking.IsHistory = false;
                    rebuildConsInvtChecking.Add();

                    var writeOffAmount = new WriteOffAmount();
                    writeOffAmount.Id          = Guid.NewGuid();
                    writeOffAmount.ConsInfoID  = rebuildConsInvtChecking.Id;
                    writeOffAmount.TotalActual = Rebuild_TotalWO_Act;
                    writeOffAmount.Add();

                    var reinvestmentCost = new ReinvestmentCost();
                    reinvestmentCost.Id                     = Guid.NewGuid();
                    reinvestmentCost.ConsInfoID             = rebuildConsInvtChecking.Id;
                    reinvestmentCost.TotalReinvestmentFAAct = Rebuild_TotalReinvestment_Act;
                    reinvestmentCost.Add();
                }
                else
                {
                    ProjectId            = projectInfo.ProjectId;
                    projectInfo.IsPushed = pushOrNot;
                    projectInfo.Update();

                    var rebuildInfo = RebuildInfo.FirstOrDefault(i => i.ProjectId == ProjectId);
                    if (rebuildInfo != null)
                    {
                        rebuildInfo.GBDate     = GBDate;
                        rebuildInfo.ReopenDate = ReopenDate;
                        rebuildInfo.Update();
                    }
                    else
                    {
                        rebuildInfo                    = new RebuildInfo();
                        rebuildInfo.Id                 = Guid.NewGuid();
                        rebuildInfo.ProjectId          = ProjectId;
                        rebuildInfo.USCode             = USCode;
                        rebuildInfo.CreateTime         = DateTime.Now;
                        rebuildInfo.CreateUserAccount  = ClientCookie.UserCode;
                        rebuildInfo.CreateUserNameENUS = ClientCookie.UserNameENUS;
                        rebuildInfo.CreateUserNameZHCN = ClientCookie.UserNameZHCN;
                        rebuildInfo.GBDate             = GBDate;
                        rebuildInfo.ReopenDate         = ReopenDate;
                        rebuildInfo.Add();
                    }

                    var rebuildPackage = RebuildPackage.FirstOrDefault(i => i.ProjectId == ProjectId && !i.IsHistory);
                    if (rebuildPackage != null)
                    {
                        rebuildPackage.ChangeLandlordType    = ChangeLandlordType;
                        rebuildPackage.NewLandlord           = ChangeLandLordDESC;
                        rebuildPackage.ChangeRentalType      = ChangeRentalType;
                        rebuildPackage.ChangeRentalTypeDESC  = ChangeRentalTypeDESC;
                        rebuildPackage.ChangeLeaseTermType   = ChangeLeaseTermType;
                        rebuildPackage.ChangeLeaseTermDESC   = ChangeLeaseTermDESC;
                        rebuildPackage.ChangeRedLineType     = ChangeRedLineType;
                        rebuildPackage.ChangeRedLineTypeDESC = ChangeRedLineTypeDESC;
                        //rebuildPackage.NewRentalStructure = NewRentalStructure;
                        rebuildPackage.Update();
                    }
                    else
                    {
                        rebuildPackage                       = new RebuildPackage();
                        rebuildPackage.Id                    = Guid.NewGuid();
                        rebuildPackage.ProjectId             = ProjectId;
                        rebuildPackage.IsHistory             = false;
                        rebuildPackage.ChangeLandlordType    = ChangeLandlordType;
                        rebuildPackage.NewLandlord           = ChangeLandLordDESC;
                        rebuildPackage.ChangeRentalType      = ChangeRentalType;
                        rebuildPackage.ChangeRentalTypeDESC  = ChangeRentalTypeDESC;
                        rebuildPackage.ChangeLeaseTermType   = ChangeLeaseTermType;
                        rebuildPackage.ChangeLeaseTermDESC   = ChangeLeaseTermDESC;
                        rebuildPackage.ChangeRedLineType     = ChangeRedLineType;
                        rebuildPackage.ChangeRedLineTypeDESC = ChangeRedLineTypeDESC;
                        //rebuildPackage.NewRentalStructure = NewRentalStructure;
                        rebuildPackage.Add();
                    }

                    var projectContractInfo = ProjectContractInfo.FirstOrDefault(i => i.ProjectId == ProjectId);
                    if (projectContractInfo != null)
                    {
                        projectContractInfo.EditMode                     = EditMode;
                        projectContractInfo.PartyAFullName               = PartyAFullName;
                        projectContractInfo.McDLegalEntity               = ContractEntityName;
                        projectContractInfo.McDOwnership                 = McdOwnership;
                        projectContractInfo.ContactPerson                = ContactPerson;
                        projectContractInfo.ContactMode                  = ContactMode;
                        projectContractInfo.RentType                     = RentType;
                        projectContractInfo.TotalLeasedArea              = RentSize;
                        projectContractInfo.LeasePurchaseTerm            = ContractTerm;
                        projectContractInfo.LeasePurchase                = ContractType;
                        projectContractInfo.StartDate                    = ContractStartDate;
                        projectContractInfo.EndDate                      = ContraceEndDate;
                        projectContractInfo.StartYear                    = ContractStartYear;
                        projectContractInfo.EndYear                      = ContraceEndYear;
                        projectContractInfo.RentCommencementDate         = RentPaymentStartDate;
                        projectContractInfo.DeadlineToNotice             = DeadlineToNoticeLL;
                        projectContractInfo.Changedafter2010             = ChangedAfter2010;
                        projectContractInfo.RentStructure                = RentStructure;
                        projectContractInfo.WithEarlyTerminationClause   = EarlyTerminationClause;
                        projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription;
                        projectContractInfo.RentPaymentArrangement       = RentPaymentArrangement;
                        projectContractInfo.HasDeposit                   = Deposit;
                        projectContractInfo.DepositAmount                = DepositAmount;
                        projectContractInfo.RefundableDate               = WhenRefund;
                        projectContractInfo.WithPenaltyClause            = withPenaltyClause;
                        projectContractInfo.HasBankGuarantee             = BankGuarantee;
                        projectContractInfo.BGNumber                     = BankGuaranteeNumber;
                        projectContractInfo.BGAmount                     = BankGuaranteeAmount;
                        projectContractInfo.BGCommencementDate           = BGCommencementDate;
                        projectContractInfo.BGEndDate                    = BGEndDate;
                        projectContractInfo.Update();
                    }
                    else
                    {
                        projectContractInfo                              = new ProjectContractInfo();
                        projectContractInfo.Id                           = Guid.NewGuid();
                        projectContractInfo.ProjectId                    = ProjectId;
                        projectContractInfo.ContractInfoId               = Guid.Empty;
                        projectContractInfo.CreatedTime                  = DateTime.Now;
                        projectContractInfo.WriteBack                    = false;
                        projectContractInfo.EditMode                     = EditMode;
                        projectContractInfo.PartyAFullName               = PartyAFullName;
                        projectContractInfo.McDLegalEntity               = ContractEntityName;
                        projectContractInfo.McDOwnership                 = McdOwnership;
                        projectContractInfo.ContactPerson                = ContactPerson;
                        projectContractInfo.ContactMode                  = ContactMode;
                        projectContractInfo.RentType                     = RentType;
                        projectContractInfo.TotalLeasedArea              = RentSize;
                        projectContractInfo.LeasePurchaseTerm            = ContractTerm;
                        projectContractInfo.LeasePurchase                = ContractType;
                        projectContractInfo.StartDate                    = ContractStartDate;
                        projectContractInfo.EndDate                      = ContraceEndDate;
                        projectContractInfo.StartYear                    = ContractStartYear;
                        projectContractInfo.EndYear                      = ContraceEndYear;
                        projectContractInfo.RentCommencementDate         = RentPaymentStartDate;
                        projectContractInfo.DeadlineToNotice             = DeadlineToNoticeLL;
                        projectContractInfo.Changedafter2010             = ChangedAfter2010;
                        projectContractInfo.RentStructure                = RentStructure;
                        projectContractInfo.WithEarlyTerminationClause   = EarlyTerminationClause;
                        projectContractInfo.EarlyTerminationClauseDetail = EarlyTerminationClauseDescription;
                        projectContractInfo.RentPaymentArrangement       = RentPaymentArrangement;
                        projectContractInfo.HasDeposit                   = Deposit;
                        projectContractInfo.DepositAmount                = DepositAmount;
                        projectContractInfo.RefundableDate               = WhenRefund;
                        projectContractInfo.WithPenaltyClause            = withPenaltyClause;
                        projectContractInfo.HasBankGuarantee             = BankGuarantee;
                        projectContractInfo.BGNumber                     = BankGuaranteeNumber;
                        projectContractInfo.BGAmount                     = BankGuaranteeAmount;
                        projectContractInfo.BGCommencementDate           = BGCommencementDate;
                        projectContractInfo.BGEndDate                    = BGEndDate;
                        projectContractInfo.Add();
                    }

                    var rebuildConsInfo = RebuildConsInfo.FirstOrDefault(i => i.ProjectId == ProjectId && !i.IsHistory);
                    if (rebuildConsInfo == null)
                    {
                        rebuildConsInfo                   = new RebuildConsInfo();
                        rebuildConsInfo.Id                = Guid.NewGuid();
                        rebuildConsInfo.ProjectId         = ProjectId;
                        rebuildConsInfo.IsHistory         = false;
                        rebuildConsInfo.CreateTime        = DateTime.Now;
                        rebuildConsInfo.CreateUserAccount = ClientCookie.UserCode;
                        rebuildConsInfo.Add();
                    }

                    var reinvestmentBasicInfo = ReinvestmentBasicInfo.FirstOrDefault(i => i.ConsInfoID == rebuildConsInfo.Id);
                    if (reinvestmentBasicInfo != null)
                    {
                        reinvestmentBasicInfo.EstimatedSeatNo   = OriginalSeatNO;
                        reinvestmentBasicInfo.RightSizingSeatNo = AfterRebuildSeatNO;
                        reinvestmentBasicInfo.NewDesignType     = AfterRebuildDesignType;
                        reinvestmentBasicInfo.NewOperationSize  = AfterRebuildOperationArea;
                        reinvestmentBasicInfo.Update();
                    }
                    else
                    {
                        reinvestmentBasicInfo                   = new ReinvestmentBasicInfo();
                        reinvestmentBasicInfo.ConsInfoID        = rebuildConsInfo.Id;
                        reinvestmentBasicInfo.EstimatedSeatNo   = OriginalSeatNO;
                        reinvestmentBasicInfo.RightSizingSeatNo = AfterRebuildSeatNO;
                        reinvestmentBasicInfo.NewDesignType     = AfterRebuildDesignType;
                        reinvestmentBasicInfo.NewOperationSize  = AfterRebuildOperationArea;
                        reinvestmentBasicInfo.Add();
                    }

                    var rebuildConsInvtChecking = RebuildConsInvtChecking.FirstOrDefault(i => i.ProjectId == ProjectId && !i.IsHistory);
                    if (rebuildConsInvtChecking == null)
                    {
                        rebuildConsInvtChecking           = new RebuildConsInvtChecking();
                        rebuildConsInvtChecking.Id        = Guid.NewGuid();
                        rebuildConsInvtChecking.ProjectId = ProjectId;
                        rebuildConsInvtChecking.IsHistory = false;
                        rebuildConsInvtChecking.Add();
                    }

                    var writeOffAmount = WriteOffAmount.FirstOrDefault(i => i.ConsInfoID == rebuildConsInvtChecking.Id);
                    if (writeOffAmount != null)
                    {
                        writeOffAmount.TotalActual = Rebuild_TotalWO_Act;
                        writeOffAmount.Update();
                    }
                    else
                    {
                        writeOffAmount             = new WriteOffAmount();
                        writeOffAmount.Id          = Guid.NewGuid();
                        writeOffAmount.ConsInfoID  = rebuildConsInvtChecking.Id;
                        writeOffAmount.TotalActual = Rebuild_TotalWO_Act;
                        writeOffAmount.Add();
                    }

                    var reinvestmentCost = ReinvestmentCost.FirstOrDefault(i => i.ConsInfoID == rebuildConsInvtChecking.Id);
                    if (reinvestmentCost != null)
                    {
                        reinvestmentCost.TotalReinvestmentFAAct = Rebuild_TotalReinvestment_Act;
                        reinvestmentCost.Update();
                    }
                    else
                    {
                        reinvestmentCost                        = new ReinvestmentCost();
                        reinvestmentCost.Id                     = Guid.NewGuid();
                        reinvestmentCost.ConsInfoID             = rebuildConsInvtChecking.Id;
                        reinvestmentCost.TotalReinvestmentFAAct = Rebuild_TotalReinvestment_Act;
                        reinvestmentCost.Add();
                    }
                }
                tranScope.Complete();
            }
        }