public CounterpartyContractDlg(Counterparty counterparty, PaymentType paymentType, Organization organizetion, DateTime?date) : this(counterparty, organizetion) { var orderOrganizationProviderFactory = new OrderOrganizationProviderFactory(); var orderOrganizationProvider = orderOrganizationProviderFactory.CreateOrderOrganizationProvider(); var counterpartyContractRepository = new CounterpartyContractRepository(orderOrganizationProvider); var contractType = counterpartyContractRepository.GetContractTypeForPaymentType(counterparty.PersonType, paymentType); Entity.ContractType = contractType; if (date.HasValue) { UoWGeneric.Root.IssueDate = date.Value; } }
public override bool Save() { var valid = new QSValidator <ServiceClaim> (UoWGeneric.Root); if (valid.RunDlgIfNotValid((Window)this.Toplevel)) { return(false); } CounterpartyContract contract = CounterpartyContractRepository.GetCounterpartyContractByPaymentType (UoWGeneric, UoWGeneric.Root.Counterparty, UoWGeneric.Root.Counterparty.PersonType, UoWGeneric.Root.Payment); if (contract == null) { RunContractCreateDialog(); return(false); } UoWGeneric.Session.Refresh(contract); if (!contract.RepairAgreementExists()) { RunAgreementCreateDialog(contract); return(false); } if (UoWGeneric.Root.InitialOrder != null) { UoWGeneric.Root.InitialOrder.AddServiceClaimAsInitial(UoWGeneric.Root); } if (UoWGeneric.Root.FinalOrder != null) { UoWGeneric.Root.FinalOrder.AddServiceClaimAsFinal(UoWGeneric.Root); } if (UoWGeneric.IsNew) { UoWGeneric.Root.AddHistoryRecord(UoWGeneric.Root.Status, String.IsNullOrWhiteSpace(textComment.Buffer.Text) ? "Заявка зарегистрирована" : textComment.Buffer.Text); } logger.Info("Сохраняем заявку на обслуживание..."); UoWGeneric.Save(); logger.Info("Ok"); return(true); }