Exemplo n.º 1
0
        protected virtual void CurrencyRate_RowUpdating(PXCache cache, PXRowUpdatingEventArgs e)
        {
            CurrencyRate cr = e.NewRow as CurrencyRate;

            if (cr.CuryEffDate == null)
            {
                cr.CuryEffDate = DateTime.Now;
            }

            if (cr.FromCuryID != null && cr.ToCuryID != null && String.Compare(cr.FromCuryID, cr.ToCuryID, true) == 0)
            {
                throw new PXException(Messages.DestShouldDifferFromOrig);
            }
            if (cr.CuryRate != null)
            {
                if (Math.Round((decimal)(cr.CuryRate), 8) == 0)
                {
                    throw new PXException(Messages.CuryRateCantBeZero);
                }
                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.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> > > > > >,
                                                           OrderBy <Desc <CurrencyRate.curyEffDate> > > .Select(cache.Graph, cr.ToCuryID, cr.FromCuryID, cr.CuryRateType, cr.CuryEffDate);


                if (existRate != null)
                {
                    if (CuryRateRecordsEntry.Locate(existRate) == null)
                    {
                        CurrencyRate newExistRate = (CurrencyRate)CuryRateRecordsEntry.Cache.CreateCopy(existRate);
                        newExistRate.CuryRate       = cr.CuryRate;
                        newExistRate.CuryMultDiv    = cr.CuryMultDiv;
                        newExistRate.RateReciprocal = cr.RateReciprocal;
                        CuryRateRecordsEntry.Delete(cr);
                        CuryRateRecordsEntry.Update(newExistRate);
                    }
                    cache.RaiseExceptionHandling <CurrencyRate.curyRate>(cr, cr.CuryRate, new PXSetPropertyException(Messages.SuchRateTypeAlreadyExist, PXErrorLevel.Warning));
                }
            }
        }
        public virtual void clearLogs()
        {
            if (LogMessage.AskExt() == WebDialogResult.Yes)
            {
                var logs = Logs.Select();
                if (logs != null && logs.Count > 0)
                {
                    foreach (var log in logs)
                    {
                        Logs.Delete(log);
                    }

                    Actions.PressSave();
                }
            }
        }
Exemplo n.º 3
0
        public virtual void InitializeAction()
        {
            bool msgExist = MessagesExist();

            if (!msgExist || (msgExist && DeleteExistedMessages.AskExt() == WebDialogResult.Yes))
            {
                KCMSMQueueReader price    = null;
                KCMSMQueueReader quantity = null;
                KCMSMQueueReader vendor   = null;
                try
                {
                    Initializations.Select().RowCast <KCMSMQInitializationProperty>().ForEach(x => Initializations.Delete(x));
                    CreatePN(SyncType.InventoryQuantity);
                    CreatePN(SyncType.InventoryPrice);
                    CreatePN(SyncType.VendorQuantity);
                    price    = CreateQueue(SyncType.InventoryPrice);
                    quantity = CreateQueue(SyncType.InventoryQuantity);
                    vendor   = CreateQueue(SyncType.VendorQuantity);
                }
                finally
                {
                    MSMQServiceStatus(price, quantity, vendor);

                    price?.Dispose();
                    quantity?.Dispose();
                    vendor?.Dispose();
                }
            }
            else
            {
                InsertInitializationActivity(KCMSMQConstants.MSMQServiceStatus, KCMSMQConstants.MSMQServiceInterrupted);
                Persist();
            }
        }