protected virtual void CRCaseClass_DefaultContractID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { if (e.NewValue == null) { return; } Contract contract = PXSelectReadonly <Contract, Where <Contract.contractID, Equal <Required <CRCase.contractID> > > > . Select(this, e.NewValue); if (contract != null) { int daysLeft; if (ContractMaint.IsExpired(contract, (DateTime)Accessinfo.BusinessDate)) { e.NewValue = null; throw new PXSetPropertyException(Messages.ContractExpired, PXErrorLevel.Error); } if (ContractMaint.IsInGracePeriod(contract, (DateTime)Accessinfo.BusinessDate, out daysLeft)) { e.NewValue = contract.ContractCD; throw new PXSetPropertyException(Messages.ContractInGracePeriod, PXErrorLevel.Warning, daysLeft); } } }
protected virtual void UsageFilter_ContractID_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e) { if (e.NewValue != null) { Contract contract = PXSelectReadonly <Contract, Where <Contract.contractID, Equal <Required <CRCase.contractID> > > > .Select(this, e.NewValue); if (contract != null) { #region Set Warnings for expired and 'In Grace Period' contracts int daysLeft; if (ContractMaint.IsExpired(contract, Accessinfo.BusinessDate.Value)) { sender.RaiseExceptionHandling <UsageFilter.contractID>(e.Row, contract.ContractCD, new PXSetPropertyException(CR.Messages.ContractExpired, PXErrorLevel.Warning)); } else if (ContractMaint.IsInGracePeriod(contract, Accessinfo.BusinessDate.Value, out daysLeft)) { sender.RaiseExceptionHandling <UsageFilter.contractID>(e.Row, contract.ContractCD, new PXSetPropertyException(CR.Messages.ContractInGracePeriod, PXErrorLevel.Warning, daysLeft)); } #endregion } } }