예제 #1
0
        protected virtual void CRServiceCase_CustomerID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            if (cmSetup.Current.MCActivated == true &&
                (e.ExternalCall || sender.GetValuePending <CRServiceCase.curyID>(e.Row) == null))
            {
                var info = CurrencyInfoAttribute.SetDefaults <CRServiceCase.curyInfoID>(sender, e.Row);
                var row  = (CRServiceCase)e.Row;

                var message = PXUIFieldAttribute.GetError <CurrencyInfo.curyEffDate>(dummyCuryInfo.Cache, info);
                if (!string.IsNullOrEmpty(message))
                {
                    sender.RaiseExceptionHandling <CRServiceCase.createdDateTime>(e.Row,
                                                                                  row.CreatedDateTime,
                                                                                  new PXSetPropertyException(message, PXErrorLevel.Warning));
                }
                if (info != null)
                {
                    row.CuryID = info.CuryID;
                }
            }

            SharedRecordAttribute.DefaultRecord <CRServiceCase.destinationAddressID>(sender, e.Row);
            SharedRecordAttribute.DefaultRecord <CRServiceCase.billAddressID>(sender, e.Row);
            sender.SetDefaultExt <CRServiceCase.locationID>(e.Row);
        }
        protected virtual void TaxAdjustment_VendorID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            TaxAdjustment doc = (TaxAdjustment)e.Row;

            if (doc == null)
            {
                return;
            }

            if (PXAccess.FeatureInstalled <FeaturesSet.multicurrency>())
            {
                if (e.ExternalCall || sender.GetValuePending <TaxAdjustment.curyID>(doc) == null)
                {
                    CurrencyInfo info = CurrencyInfoAttribute.SetDefaults <TaxAdjustment.curyInfoID>(sender, doc);

                    string message = PXUIFieldAttribute.GetError <CurrencyInfo.curyEffDate>(currencyinfo.Cache, info);
                    if (string.IsNullOrEmpty(message) == false)
                    {
                        sender.RaiseExceptionHandling <TaxAdjustment.docDate>(doc, doc.DocDate, new PXSetPropertyException(message, PXErrorLevel.Warning));
                    }

                    if (info != null)
                    {
                        doc.CuryID = info.CuryID;
                    }
                }
            }

            sender.SetDefaultExt <TaxAdjustment.vendorLocationID>(e.Row);
            sender.SetDefaultExt <TaxAdjustment.taxPeriod>(e.Row);
            sender.SetDefaultExt <TaxAdjustment.adjAccountID>(e.Row);
            sender.SetDefaultExt <TaxAdjustment.adjSubID>(e.Row);
        }
예제 #3
0
        protected virtual void PTInstStatement_CashAccountID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            if (this.cashAccount.Current == null || this.cashAccount.Current.AccountID != ((PTInstStatement)e.Row).CashAccountID)
            {
                this.cashAccount.Current = (CashAccount)PXSelectorAttribute.Select <CashAccount.cashAccountID>(sender, e.Row);
            }

            //if ((bool)CMSetup.Current.MCActivated)
            {
                if (e.ExternalCall || sender.GetValuePending <PTInstStatement.curyID>(e.Row) == null)
                {
                    CurrencyInfo info = CurrencyInfoAttribute.SetDefaults <PTInstStatement.curyInfoID>(sender, e.Row);

                    string message = PXUIFieldAttribute.GetError <CurrencyInfo.curyEffDate>(currencyinfo.Cache, info);
                    if (string.IsNullOrEmpty(message) == false)
                    {
                        sender.RaiseExceptionHandling <PTInstStatement.statementDate>(e.Row, ((PTInstStatement)e.Row).StatementDate, new PXSetPropertyException(message, PXErrorLevel.Warning));
                    }

                    if (info != null)
                    {
                        ((PTInstStatement)e.Row).CuryID = info.CuryID;
                    }
                }
            }
        }
예제 #4
0
 protected virtual void TXImportZipFileData_ZipCode_FieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e)
 {
     if (e.Row != null)
     {
         _importing = sender.GetValuePending(e.Row, PXImportAttribute.ImportFlag) != null;
     }
 }
예제 #5
0
        public static object GetNewValueByIncoming(PXCache cache, object row, string fieldName, bool externalCall)
        {
            object incoming = null;

            if (externalCall)
            {
                incoming = cache.GetValuePending(row, fieldName);

                if (incoming != null)
                {
                    return(incoming);
                }
            }

            try
            {
                incoming = cache.GetValueExt(row, fieldName);

                return(PXFieldState.UnwrapValue(incoming));
            }
            catch
            {
            }

            return(cache.GetValue(row, fieldName));
        }
예제 #6
0
        public static object GetValuePendingOrCurrent(PXCache cache, Type sourceType, object row)
        {
            object value = cache.GetValuePending(row, sourceType.Name);

            if (value != PXCache.NotSetValue)
            {
                return(value);
            }

            return(BqlHelper.GetOperandValue(cache, row ?? cache.Current, sourceType));
        }
예제 #7
0
        public static object GetValuePendingOrRow <TField>(PXCache cache, object row)
            where TField : IBqlField
        {
            object value = cache.GetValuePending(row, typeof(TField).Name);

            if (value != PXCache.NotSetValue)
            {
                cache.RaiseFieldUpdating <TField>(row, ref value);

                return(value);
            }

            return(BqlHelper.GetOperandValue(cache, row, typeof(TField)));
        }
        protected virtual void INTran_LocationID_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            INTran row = e.Row as INTran;

            if (row == null)
            {
                return;
            }

            sender.SetDefaultExt <INTran.projectID>(e.Row);            //will set pending value for TaskID to null if project is changed. This is the desired behavior for all other screens.
            if (sender.GetValuePending <INTran.taskID>(e.Row) == null) //To redefault the TaskID in currecnt screen - set the Pending value from NULL to NOTSET
            {
                sender.SetValuePending <INTran.taskID>(e.Row, PXCache.NotSetValue);
            }
            sender.SetDefaultExt <INTran.taskID>(e.Row);
        }
        private void SourceFieldUpdated(PXCache cache, PXFieldUpdatedEventArgs e)
        {
            object sourcedate = cache.GetValue(e.Row, _sourceField);

            if (sourcedate != null)
            {
                PeriodResult result     = GetPeriod(cache, _searchType, (DateTime)sourcedate, new object[] { e.Row }, true);
                string       newValue   = result;
                bool         haspending = false;
                try
                {
                    object pendingValue = cache.GetValuePending(e.Row, _FieldName);
                    if (pendingValue != null && pendingValue != PXCache.NotSetValue)
                    {
                        pendingValue = UnFormatPeriod((string)pendingValue);
                        cache.RaiseFieldVerifying(_FieldName, e.Row, ref pendingValue);
                        haspending = true;
                    }
                }
                catch (PXSetPropertyException)
                {
                    cache.SetValuePending(e.Row, _FieldName, newValue);
                }
                finally
                {
                    if (cache.HasAttributes(e.Row))
                    {
                        cache.RaiseExceptionHandling(_FieldName, e.Row, null, null);
                    }

                    //this will happen only if FirstOpenPeriod is set from OpenPeriod
                    if (!haspending && result.StartDate > (DateTime?)sourcedate)
                    {
                        cache.SetValueExt(e.Row, _sourceField, result.StartDate);
                    }
                    else
                    {
                        cache.SetValueExt(e.Row, _FieldName, newValue);
                    }
                }
            }
            else
            {
                cache.SetValue(e.Row, _FieldName, null);
            }
        }
예제 #10
0
        protected virtual void EPActivity_RowPersisted(PXCache cache, PXRowPersistedEventArgs e)
        {
            var row = e.Row as EPActivity;

            if (row == null ||
                e.TranStatus != PXTranStatus.Open ||
                cache.GetValuePending(row, PXImportAttribute.ImportFlag) != null)
            {
                return;
            }

            var operation = e.Operation & PXDBOperation.Command;

            if (operation == PXDBOperation.Insert || operation == PXDBOperation.Update)
            {
                EPViewStatusAttribute.MarkAsViewed(this, row, true);
            }
        }
예제 #11
0
        public void FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            var valuePending = sender.GetValuePending(e.Row, _FieldName);

            if (_FromAttribute == false || PXCache.NotSetValue == valuePending)
            {
                return;
            }

            _FromAttribute = false;

            DateTime?dateTimeValue = (DateTime?)valuePending;

            if (dateTimeValue != null)
            {
                sender.SetValue(e.Row, _FieldName, dateTimeValue);
            }
        }
예제 #12
0
        protected virtual void CuryFieldUpdating(PXCache sender, PXFieldUpdatingEventArgs e, string curyField, string baseField)
        {
            if (!FormatValue(e, sender.Graph.Culture))
            {
                return;
            }

            if (Base.Accessinfo.CuryViewState &&
                e.Row != null && e.NewValue != null && object.ReferenceEquals(sender.GetValuePending(e.Row, curyField), e.NewValue))
            {
                e.NewValue = sender.GetValue(e.Row, curyField);
            }
            else
            {
                CurrencyInfo info = GetCurrencyInfo(Documents.Current);

                if (info != null)
                {
                    PopulatePrecision(currencyinfo.Cache, info);
                    var value = Convert.ToDecimal(e.NewValue);
                    e.NewValue = Math.Round(value, info.CuryPrecision ?? 2, MidpointRounding.AwayFromZero);
                }
            }
        }
        protected object GetNewValueByIncomig(PXCache cache, object row, string fieldName, bool externalCall)
        {
            object incoming = null;

            if (externalCall)
            {
                incoming = cache.GetValuePending(row, fieldName);

                if (incoming != null)
                {
                    return(incoming);
                }
            }

            try
            {
                incoming = cache.GetValueExt(row, fieldName);

                var state = incoming as PXFieldState;

                if (state != null)
                {
                    return(state.Value);
                }

                if (incoming != null)
                {
                    return(incoming);
                }
            }
            catch
            {
            }

            return(cache.GetValue(row, fieldName));
        }
        protected virtual void GetRecords()
        {
            PXCache cache   = this._Graph.Caches[BqlCommand.GetItemType(this.BatchModule)];
            object  current = null;

            foreach (object item in PXView.Currents)
            {
                if (item != null && (item.GetType() == BqlCommand.GetItemType(this.BatchModule) || item.GetType().IsSubclassOf(BqlCommand.GetItemType(this.BatchModule))))
                {
                    current = item;
                    break;
                }
            }

            if (current == null)
            {
                current = cache.Current;
            }

            PXView view = PXView.View;

            if (view != null)
            {
                if (_CuryID != null)
                {
                    object curyID = cache.GetValue(current, this._CuryID.Name) ?? cache.GetValuePending(current, _CuryID.Name);
                    PX.Common.PXContext.SetSlot(this._CuryID.FullName, curyID);
                }
                switch ((string)(cache.GetValue(current, this.BatchModule.Name) ?? cache.GetValuePending(current, this.BatchModule.Name)))
                {
                case GL.BatchModule.AP:
                    view.WhereNew <Where2 <Match <VendorR, Current <AccessInfo.userName> >, And <Where <BAccountR.type, Equal <BAccountType.vendorType>, Or <BAccountR.type, Equal <BAccountType.employeeType>, Or <BAccountR.type, Equal <BAccountType.combinedType>, Or <BAccountR.type, Equal <BAccountType.empCombinedType> > > > > > > >();

                    if (_CuryID != null)
                    {
                        Type join = BqlCommand.Compose(
                            typeof(InnerJoin <,>),
                            typeof(VendorR),
                            typeof(On <, ,>),
                            typeof(VendorR.bAccountID),
                            typeof(Equal <>),
                            typeof(BAccountR.bAccountID),
                            typeof(And <>),
                            typeof(Where <, ,>),
                            typeof(VendorR.curyID),
                            typeof(Equal <>),
                            typeof(SavedStringValue <>),
                            _CuryID,
                            typeof(Or <, ,>),
                            typeof(VendorR.allowOverrideCury),
                            typeof(Equal <>),
                            typeof(True),
                            typeof(Or <,>),
                            typeof(VendorR.curyID),
                            typeof(IsNull));

                        view.JoinNew(join);
                    }
                    else
                    {
                        Type join = BqlCommand.Compose(
                            typeof(InnerJoin <,>),
                            typeof(VendorR),
                            typeof(On <,>),
                            typeof(VendorR.bAccountID),
                            typeof(Equal <>),
                            typeof(BAccountR.bAccountID));

                        view.JoinNew(join);
                    }

                    break;

                case GL.BatchModule.AR:
                    view.WhereNew <Where2 <Match <CustomerR, Current <AccessInfo.userName> >, And <Where <BAccountR.type, Equal <BAccountType.customerType>, Or <BAccountR.type, Equal <BAccountType.combinedType>, Or <BAccountR.type, Equal <BAccountType.empCombinedType> > > > > > >();

                    if (_CuryID != null)
                    {
                        Type join = BqlCommand.Compose(
                            typeof(InnerJoin <,>),
                            typeof(CustomerR),
                            typeof(On <, ,>),
                            typeof(CustomerR.bAccountID),
                            typeof(Equal <>),
                            typeof(BAccountR.bAccountID),
                            typeof(And <>),
                            typeof(Where <, ,>),
                            typeof(CustomerR.curyID),
                            typeof(Equal <>),
                            typeof(SavedStringValue <>),
                            _CuryID,
                            typeof(Or <, ,>),
                            typeof(CustomerR.allowOverrideCury),
                            typeof(Equal <>),
                            typeof(True),
                            typeof(Or <,>),
                            typeof(CustomerR.curyID),
                            typeof(IsNull));

                        view.JoinNew(join);
                    }
                    else
                    {
                        Type join = BqlCommand.Compose(
                            typeof(InnerJoin <,>),
                            typeof(CustomerR),
                            typeof(On <,>),
                            typeof(CustomerR.bAccountID),
                            typeof(Equal <>),
                            typeof(BAccountR.bAccountID));

                        view.JoinNew(join);
                    }
                    break;
                }
            }
            //return null;
        }
예제 #15
0
        protected virtual void CurrencyRate_RowInserting(PXCache cache, PXRowInsertingEventArgs e)
        {
            CurrencyRate   cr  = e.Row as CurrencyRate;
            CuryRateFilter crf = Filter.Current as CuryRateFilter;

            if (cr.FromCuryID != null && crf.ToCurrency != null && String.Compare(cr.FromCuryID, crf.ToCurrency, true) == 0)
            {
                throw new PXException(Messages.DestShouldDifferFromOrig);
            }

            bool importing = e.Row != null && cache.GetValuePending(e.Row, PXImportAttribute.ImportFlag) != null;

            if (e.ExternalCall && !importing)
            {
                if (cr.CuryEffDate == null)
                {
                    if (crf.EffDate == null)
                    {
                        cr.CuryEffDate = DateTime.Now;
                    }
                    else
                    {
                        cr.CuryEffDate = crf.EffDate;
                    }
                }

                if (cr.CuryRate != null)
                {
                    cr.RateReciprocal = Math.Round((decimal)(1 / cr.CuryRate), 8);
                    if (((CurrencyInfo)cr).CheckRateVariance(cache))
                    {
                        cache.RaiseExceptionHandling <CurrencyRate.curyRate>(cr, cr.CuryRate, new PXSetPropertyException(Messages.RateVarianceExceeded, PXErrorLevel.Warning));
                    }
                }

                if (cr.CuryMultDiv == " " &&
                    cr.FromCuryID != null &&
                    cr.ToCuryID != null &&
                    cr.CuryRateType != null &&
                    cr.CuryEffDate != null)
                {
                    CurrencyRate existRateMultDiv = PXSelectReadonly <CurrencyRate,
                                                                      Where <CurrencyRate.fromCuryID, Equal <Required <CurrencyRate.fromCuryID> >,
                                                                             And <CurrencyRate.toCuryID, Equal <Required <CurrencyRate.toCuryID> >,
                                                                                  And <CurrencyRate.curyRateType, Equal <Required <CurrencyRate.curyRateType> >,
                                                                                       And <CurrencyRate.curyEffDate, LessEqual <Required <CurrencyRate.curyEffDate> > > > > >,
                                                                      OrderBy <Desc <CurrencyRate.curyEffDate> > > .Select(cache.Graph, cr.FromCuryID, cr.ToCuryID, cr.CuryRateType, cr.CuryEffDate);

                    if (existRateMultDiv != null)
                    {
                        cr.CuryMultDiv = existRateMultDiv.CuryMultDiv;
                    }
                }
            }
            if (cr.FromCuryID != null &&
                cr.CuryRateType != null &&
                cr.CuryRateType != null &&
                cr.CuryEffDate != null &&
                cr.CuryRate != null)
            {
                CurrencyRate existRate = PXSelectReadonly <CurrencyRate,
                                                           Where <CurrencyRate.toCuryID, Equal <Required <CurrencyRate.toCuryID> >,
                                                                  And <CurrencyRate.fromCuryID, Equal <Required <CurrencyRate.fromCuryID> >,
                                                                       And <CurrencyRate.curyRateType, Equal <Required <CurrencyRate.curyRateType> >,
                                                                            And <CurrencyRate.curyEffDate, Equal <Required <CurrencyRate.curyEffDate> > > > > > > .Select(cache.Graph, cr.ToCuryID, cr.FromCuryID, cr.CuryRateType, cr.CuryEffDate);

                if (existRate != null)
                {
                    e.Cancel = true;
                    CurrencyRate newExistRate = (CurrencyRate)CuryRateRecordsEntry.Cache.CreateCopy(existRate);
                    newExistRate.CuryRate       = cr.CuryRate;
                    newExistRate.CuryMultDiv    = cr.CuryMultDiv;
                    newExistRate.RateReciprocal = cr.RateReciprocal;
                    CuryRateRecordsEntry.Update(newExistRate);
                    cache.RaiseExceptionHandling <CurrencyRate.curyRate>(cr, cr.CuryRate, new PXSetPropertyException(Messages.SuchRateTypeAlreadyExist, PXErrorLevel.Warning));
                }
            }
        }
 public override object Evaluate(PXCache cache, object item, Dictionary <Type, object> pars)
 {
     return(cache.GetValuePending <Field>(item));
 }