Example #1
0
        /// <summary> RowPersisting ENGineering </summary>
        public void _(Events.RowPersisting <ENGineering> e)
        {
            var row = (ENGineering)e.Row;

            row.OppBAccountID = Base.Opportunity.Current.BAccountID;
            var _oppID = Base.Opportunity.Current.OpportunityID;

            if ((row.Opprid ?? string.Empty).ToLower().Contains("new"))
            {
                e.Row.Opprid = _oppID;
            }

            // Valid [EngrRef] + [Engineer Repeat]
            var isExixts = new PXGraph().Select <ENGineering>()
                           .Where(x => x.EngNbr == row.EngNbr &&
                                  x.Repeat == row.Repeat &&
                                  x.EngrRef != row.EngrRef).Any();

            if (isExixts && !string.IsNullOrEmpty(row.EngNbr))
            {
                e.Cache.RaiseExceptionHandling <ENGineering.engNbr>(e.Row, row.EngNbr,
                                                                    new PXSetPropertyException <ENGineering.engNbr>("[EngrNbr] + [Engineer Repeat] is not allowed duplicated"));
            }

            // Valid SalesPerson
            if (row.SalesPerson == null && row.Prjtype != "RD")
            {
                e.Cache.RaiseExceptionHandling <ENGineering.salesPerson>(e.Row, row.Repeat,
                                                                         new PXSetPropertyException <ENGineering.salesPerson>("Sales Person can not be empty"));
            }
        }
 public virtual void _(Events.RowPersisting <APInvoice> args)
 {
     if (args.Operation != PXDBOperation.Delete && IsAdjustingInProgress)
     {
         ValidateJointPayees();
     }
 }
 protected virtual void _(Events.RowPersisting <PMRegister> args)
 {
     if (args.Row?.Released == true)
     {
         args.Cancel = true;
     }
 }
 protected void _(Events.RowPersisting <PMCostCode> args)
 {
     if (args.Cache != null)
     {
         UpdateVendorsIfRequired(args.Cache.Deleted);
     }
 }
Example #5
0
 protected void _(Events.RowPersisting <InventoryItem> args)
 {
     if (args.Operation == PXDBOperation.Delete && args.Row is InventoryItem inventoryItem)
     {
         DeleteVendorDefaultInventory(inventoryItem.InventoryID);
     }
 }
Example #6
0
        protected virtual void _(Events.RowPersisting <FSGPSTrackingLocation> e)
        {
            if (e.Row == null)
            {
                return;
            }

            FSGPSTrackingLocation fsGPSTrackingLocationRow = e.Row as FSGPSTrackingLocation;

            if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update)
            {
                SetWeeklyOnDayFlag(fsGPSTrackingLocationRow);
                UpdateIntervalAndDistance(fsGPSTrackingLocationRow);

                // @TODO: This must be a configuring setting?
                if (e.Operation == PXDBOperation.Insert)
                {
                    fsGPSTrackingLocationRow.StartDate = Base.Accessinfo.BusinessDate;
                    fsGPSTrackingLocationRow.EndDate   = fsGPSTrackingLocationRow.StartDate.Value.AddYears(1000);
                }

                if (fsGPSTrackingLocationRow.TimeZoneID == null)
                {
                    Base.UserPrefs.Cache.RaiseExceptionHandling <UserPreferences.timeZone>(
                        Base.UserPrefs.Current,
                        Base.UserPrefs.Current.TimeZone,
                        new PXSetPropertyException(TX.Error.TIME_ZONE_REQUIRED_LOCATION_TRACKING_ENABLED, PXErrorLevel.Error));

                    e.Cache.RaiseExceptionHandling <FSGPSTrackingLocation.weekDay>(
                        fsGPSTrackingLocationRow,
                        fsGPSTrackingLocationRow.WeekDay,
                        new PXSetPropertyException(TX.Error.TIME_ZONE_REQUIRED_LOCATION_TRACKING_ENABLED, PXErrorLevel.RowError));
                }
            }
        }
Example #7
0
        protected void _(Events.RowPersisting <TWNManualGUIExpense> e)
        {
            if (Base.ExpenseClaimCurrent.Current == null)
            {
                return;
            }

            tWNGUIValidation.CheckCorrespondingInv(Base, e.Row.GUINbr, e.Row.VATInCode);

            if (tWNGUIValidation.errorOccurred.Equals(true))
            {
                e.Cache.RaiseExceptionHandling <TWNManualGUIExpense.gUINbr>(e.Row, e.Row.GUINbr, new PXSetPropertyException(tWNGUIValidation.errorMessage, PXErrorLevel.RowError));
            }

            decimal taxSum = 0;

            foreach (TWNManualGUIExpense row in manGUIExpense.Cache.Cached)
            {
                taxSum += row.TaxAmt.Value;
            }

            if (!taxSum.Equals(Base.ExpenseClaimCurrent.Current.CuryTaxTotal))
            {
                throw new PXException(TWMessages.ChkTotalGUIAmt);
            }
        }
Example #8
0
 public virtual void _(Events.RowPersisting <JointPayeePayment> args)
 {
     if (args.Operation != PXDBOperation.Delete)
     {
         args.Row.PaymentRefNbr = Base.Document.Current.RefNbr;
     }
 }
 public virtual void _(Events.RowPersisting <APSetup> args)
 {
     if (args.Row?.RequireSingleProjectPerDocument == true)
     {
         UpdateSubcontractProjects();
     }
 }
Example #10
0
 protected virtual void _(Events.RowPersisting <PMTask> e)
 {
     if (e.Operation != PXDBOperation.Delete && e.Row.Status == ProjectTaskStatus.Active && e.Row.IsActive != true)
     {
         throw new PXException(Messages.TaskCannotBeSaved, e.Row.TaskCD);
     }
 }
        protected virtual void _(Events.RowPersisting <FSStaffSchedule> e)
        {
            if (e.Row == null)
            {
                return;
            }

            FSStaffSchedule fsStaffScheduleRow = (FSStaffSchedule)e.Row;
            PXCache         cache = e.Cache;

            if (fsStaffScheduleRow.EnableExpirationDate == false && fsStaffScheduleRow.EndDate != null)
            {
                fsStaffScheduleRow.EndDate = null;
            }

            if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update)
            {
                fsStaffScheduleRow.NextExecutionDate = SharedFunctions.GetNextExecution(cache, fsStaffScheduleRow);

                CheckDates(cache, fsStaffScheduleRow);
                CheckTimes(cache, fsStaffScheduleRow);

                if (e.Operation == PXDBOperation.Insert)
                {
                    StaffScheduleRecords.Ask(TX.ModuleName.SERVICE_DISPATCH,
                                             TX.Warning.SCHEDULE_WILL_NOT_AFFECT_SYSTEM_UNTIL_GENERATION_OCCURS,
                                             MessageButtons.OK,
                                             MessageIcon.Warning);
                }
            }
        }
Example #12
0
        protected void _(Events.RowPersisting <TWNManualGUIAPBill> e)
        {
            if (Base.Document.Current == null)
            {
                return;
            }

            tWNGUIValidation.CheckCorrespondingInv(Base, e.Row.GUINbr, e.Row.VATInCode);

            if (tWNGUIValidation.errorOccurred == true)
            {
                e.Cache.RaiseExceptionHandling <TWNManualGUIAPBill.gUINbr>(e.Row, e.Row.GUINbr, new PXSetPropertyException(tWNGUIValidation.errorMessage, PXErrorLevel.RowError));
            }

            if (Base.Document.Current.DocType == APDocType.Invoice)
            {
                decimal?taxSum = 0;

                foreach (TWNManualGUIAPBill row in ManualAPBill.Cache.Cached)
                {
                    taxSum += row.TaxAmt.Value;
                }

                if (taxSum != Base.Document.Current.TaxTotal)
                {
                    throw new PXException(TWMessages.ChkTotalGUIAmt);
                }
            }
        }
Example #13
0
        protected void _(Events.RowPersisting <APInvoice> e, PXRowPersisting baseHandler)
        {
            baseHandler?.Invoke(e.Cache, e.Args);

            if (ManualAPBill.Select().Count == 0 && Base.Taxes.Select().Count > 0)
            {
                throw new PXException(TWMessages.NoGUIWithTax);
            }

            //if (activateGUI.Equals(false) || e.Row.Status.Equals(APDocStatus.Open)) { return; }

            //APRegisterExt regisExt = PXCache<APRegister>.GetExtension<APRegisterExt>(e.Row);

            //TWNGUIValidation tWNGUIValidation = new TWNGUIValidation();

            //if (regisExt.UsrVATInCode == TWGUIFormatCode.vATInCode21 ||
            //    regisExt.UsrVATInCode == TWGUIFormatCode.vATInCode22 ||
            //    regisExt.UsrVATInCode == TWGUIFormatCode.vATInCode25)
            //{
            //    tWNGUIValidation.CheckGUINbrExisted(Base, regisExt.UsrGUINbr, regisExt.UsrVATInCode);
            //}
            //else
            //{
            //    tWNGUIValidation.CheckCorrespondingInv(Base, regisExt.UsrGUINbr, regisExt.UsrVATInCode);

            //    if (tWNGUIValidation.errorOccurred.Equals(true))
            //    {
            //        e.Cache.RaiseExceptionHandling<APRegisterExt.usrGUINbr>(e.Row, regisExt.UsrGUINbr, new PXSetPropertyException(tWNGUIValidation.errorMessage, PXErrorLevel.Error));
            //    }
            //}
        }
 protected virtual void _(Events.RowPersisting <Document> e)
 {
     if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete)
     {
         Verify(e.Cache, e.Row, e.Args);
     }
 }
Example #15
0
        protected virtual void _(Events.RowPersisting <ESignAccount> args)
        {
            var account = args.Row as ESignAccount;

            if (account == null)
            {
                return;
            }

            if (account.SendReminders == true && string.IsNullOrEmpty(account.ReminderType))
            {
                args.Cache.RaiseExceptionHandling <ESignAccount.reminderType>(account, account.ReminderType,
                                                                              new PXSetPropertyException <ESignAccount.reminderType>(
                                                                                  string.Format(Messages.FieldRequired, Messages.ESignAccount.RemindersType)));
                args.Cancel = true;
            }

            if ((args.Operation & PXDBOperation.Command) != PXDBOperation.Delete &&
                (account.Type == ESignAccount.AccountTypes.Shared && !Users.Any()))
            {
                throw new PXRowPersistingException(
                          typeof(ESignAccountUserRule).Name,
                          null,
                          Messages.ESignAccountSharedNotNullUsers);
            }
        }
Example #16
0
 /// <summary>
 /// Event  will execute before commiting the data.
 /// </summary>
 /// <param name="e"></param>
 protected virtual void _(Events.RowPersisting <EWPMSetup> e)
 {
     if (e.Operation != PXDBOperation.Delete)
     {
         Validate(e.Cache, e.Row);
     }
 }
Example #17
0
        protected virtual void _(Events.RowPersisting <FSRoute> e)
        {
            if (e.Row == null)
            {
                return;
            }

            FSRoute fsRouteRow = (FSRoute)e.Row;

            if (fsRouteRow.NoAppointmentLimit == false && fsRouteRow.MaxAppointmentQty < 1)
            {
                e.Cache.RaiseExceptionHandling <FSRoute.maxAppointmentQty>(
                    fsRouteRow,
                    null,
                    new PXSetPropertyException(TX.Error.ROUTE_MAX_APPOINTMENT_QTY_GREATER_THAN_ZERO, PXErrorLevel.Error));
            }

            if (isRouteShortDuplicated(fsRouteRow))
            {
                e.Cache.RaiseExceptionHandling <FSRoute.routeShort>(
                    fsRouteRow,
                    null,
                    new PXSetPropertyException(TX.Error.ROUTE_SHORT_NOT_DUPLICATED, PXErrorLevel.Error));
            }

            ValidateWeekCode(e.Cache, fsRouteRow);
        }
Example #18
0
        protected virtual void _(Events.RowPersisting <Discount> e)
        {
            bool isExternalDiscount = e.Row.Type == DiscountType.ExternalDocument;

            PXDefaultAttribute.SetPersistingCheck <SOOrderDiscountDetail.discountID>(Discounts.Cache, e.Row, isExternalDiscount ? PXPersistingCheck.Nothing : PXPersistingCheck.NullOrBlank);
            PXDefaultAttribute.SetPersistingCheck <SOOrderDiscountDetail.discountSequenceID>(Discounts.Cache, e.Row, isExternalDiscount ? PXPersistingCheck.Nothing : PXPersistingCheck.NullOrBlank);
        }
 protected virtual void _(Events.RowPersisting <TLine> e)
 {
     if (e.Operation.Command().IsIn(PXDBOperation.Insert, PXDBOperation.Update))
     {
         SetDecimalVerifyMode(e.Cache, e.Row);
     }
 }
        protected virtual void _(Events.RowPersisting <CSAttributeGroup> eventArgs)
        {
            var row = eventArgs.Row;

            if (row == null)
            {
                return;
            }

            var command = eventArgs.Operation & PXDBOperation.Command;

            switch (command)
            {
            case PXDBOperation.Insert:
                ValidateInsert(eventArgs.Cache, _hasTemplateWithChild, row);
                break;

            case PXDBOperation.Update:
                ValidateUpdate(eventArgs.Cache, _hasTemplateWithChild, row);
                break;

            case PXDBOperation.Delete:
                ValidateDelete(eventArgs.Cache, _hasTemplateWithChild, row, true);
                break;
            }
        }
Example #21
0
        public override void _(Events.RowPersisting <EntityWithTaxCalcMode> e)
        {
            if (SkipValidation || Taxes.Count() == 0)
            {
                return;
            }

            PXSetPropertyException pex = null;

            foreach (EPExpenseClaimDetails row in Base.ExpenseClaimDetails.Select())
            {
                try
                {
                    VerifyTransactions(row.TaxCalcMode, Base.Tax_Rows.Select(row.ClaimDetailID).RowCast <Tax>());
                }
                catch (PXException ex)
                {
                    pex = new PXSetPropertyException(ex.Message);
                    Base.ExpenseClaimDetails.Cache.RaiseExceptionHandling <EPExpenseClaimDetails.curyTaxTotal>(row, row.CuryTaxTotal, pex);
                }
            }

            if (pex != null)
            {
                throw pex;
            }
        }
Example #22
0
        protected void _(Events.RowPersisting <ARInvoice> e, PXRowPersisting InvokeBaseHandler)
        {
            InvokeBaseHandler?.Invoke(e.Cache, e.Args);

            if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update)
            {
                ARRegisterExt regisExt = PXCache <ARRegister> .GetExtension <ARRegisterExt>(e.Row);

                //if (e.Row.CuryDocBal == decimal.Zero && string.IsNullOrEmpty(regisExt.UsrGUINbr))
                //{
                //    regisExt.UsrVATOutCode = string.Empty;
                //}
                //else
                if (string.IsNullOrEmpty(regisExt.UsrGUINbr) && (regisExt.UsrVATOutCode == TWGUIFormatCode.vATOutCode31 ||
                                                                 regisExt.UsrVATOutCode == TWGUIFormatCode.vATOutCode32 ||
                                                                 regisExt.UsrVATOutCode == TWGUIFormatCode.vATOutCode35))
                {
                    TWNGUIPreferences gUIPreferences = SelectFrom <TWNGUIPreferences> .View.Select(Base);

                    regisExt.UsrGUINbr = ARGUINbrAutoNumAttribute.GetNextNumber(e.Cache, e.Row, regisExt.UsrVATOutCode == TWGUIFormatCode.vATOutCode32 ? gUIPreferences.GUI2CopiesNumbering : gUIPreferences.GUI3CopiesNumbering,
                                                                                regisExt.UsrGUIDate);

                    tWNGUIValidation.CheckGUINbrExisted(Base, regisExt.UsrGUINbr, regisExt.UsrVATOutCode);
                }
            }
        }
Example #23
0
 protected virtual void _(Events.RowPersisting <CSAttributeGroup> args)
 {
     if (args.Operation == PXDBOperation.Insert && args.Row != null && !DoesAttributeExist(args.Row.AttributeID))
     {
         args.Cancel = true;
         MappingCommon.Cache.Clear();
     }
 }
Example #24
0
 protected virtual void _(Events.RowPersisting <InventoryItem> eventArgs)
 {
     if (eventArgs.Row?.IsTemplate == true)
     {
         ValidateChangeStkItemFlag();
         ValidateMainFieldsAreNotChanged(eventArgs.Cache, eventArgs.Row);
     }
 }
 protected virtual void _(Events.RowPersisting <APPayment> args)
 {
     if (args.Row is APPayment payment)
     {
         StopPaymentIfOutstandingLienWaiversExist(args.Cache, payment);
         DeleteAutomaticallyGeneratedLienWaiversIfRequired(args.Cache, payment);
     }
 }
        protected virtual void _(Events.RowPersisting <EPActivityApprove> e)
        {
            if (e.Row == null)
            {
                return;
            }

            TimeCardHelper.PMTimeActivity_RowPersisting_Handler(e.Cache, Base, (PMTimeActivity)e.Row, e.Args);
        }
        protected virtual void _(Events.RowPersisting <PMRegister> e)
        {
            if (e.Row == null || SharedFunctions.isFSSetupSet(Base) == false)
            {
                return;
            }

            ValidatePostBatchStatus(e.Operation, ID.Batch_PostTo.PM, e.Row.Module, e.Row.RefNbr);
        }
Example #28
0
        protected virtual void _(Events.RowPersisting <TimeCardMaint.EPTimecardDetail> e)
        {
            if (e.Row == null)
            {
                return;
            }

            TimeCardHelper.PMTimeActivity_RowPersisting_Handler(e.Cache, Base, (PMTimeActivity)e.Row, e.Args);
        }
Example #29
0
 protected virtual void _(Events.RowPersisting <CRActivity> e)
 {
     if (e.Operation != PXDBOperation.Delete &&
         Base.TimeActivity.Current != null &&
         PXAccess.FeatureInstalled <FeaturesSet.timeReportingModule>())
     {
         UpdateSubject(Base.TimeActivity.Cache, Base.TimeActivity.Current, (CRActivity)e.Row);
     }
 }
Example #30
0
        private void ValidateInventoryItem(Events.RowPersisting <PMChangeOrderLine> args, PMChangeOrderLine line)
        {
            var inventoryItem = GetInventoryItem(line.InventoryID);

            if (inventoryItem != null && (inventoryItem.StkItem == true || inventoryItem.NonStockReceipt == true))
            {
                args.Cache.RaiseExceptionHandling <PMChangeOrderLine.inventoryID>(line, inventoryItem.InventoryCD,
                                                                                  new PXSetPropertyException(ScMessages.InvalidInventoryItemMessage, PXErrorLevel.Error));
            }
        }