protected virtual void SMPrintJob_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if (e.Operation.Equals(PXDBOperation.Delete))
            {
                return;
            }

            const string fileIdParameter = "FILEID";
            bool         isFileId        = false;
            SMPrintJob   smPrintJob      = e.Row as SMPrintJob;

            if (smPrintJob != null && String.IsNullOrWhiteSpace(smPrintJob.ReportID))
            {
                foreach (SMPrintJobParameter smPrintJobParameter in Parameters.Select())
                {
                    if (smPrintJobParameter.ParameterName.Trim().ToUpperInvariant().Equals(fileIdParameter))
                    {
                        isFileId = true;
                        break;
                    }
                }

                if (!isFileId)
                {
                    throw new PXRowPersistingException(typeof(SMPrintJob.reportID).Name, null, Objects.WM.Messages.MissingFileIdError);
                }
            }
        }
Ejemplo n.º 2
0
        protected virtual void CSCalendar_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            CSCalendar row = (CSCalendar)e.Row;

            PXDefaultAttribute.SetPersistingCheck <CSCalendar.sunStartTime>(sender, e.Row, row.SunWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
            PXDefaultAttribute.SetPersistingCheck <CSCalendar.sunEndTime>(sender, e.Row, row.SunWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);

            PXDefaultAttribute.SetPersistingCheck <CSCalendar.monStartTime>(sender, e.Row, row.MonWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
            PXDefaultAttribute.SetPersistingCheck <CSCalendar.monEndTime>(sender, e.Row, row.MonWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);

            PXDefaultAttribute.SetPersistingCheck <CSCalendar.tueStartTime>(sender, e.Row, row.TueWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
            PXDefaultAttribute.SetPersistingCheck <CSCalendar.tueEndTime>(sender, e.Row, row.TueWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);

            PXDefaultAttribute.SetPersistingCheck <CSCalendar.wedStartTime>(sender, e.Row, row.WedWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
            PXDefaultAttribute.SetPersistingCheck <CSCalendar.wedEndTime>(sender, e.Row, row.WedWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);

            PXDefaultAttribute.SetPersistingCheck <CSCalendar.thuStartTime>(sender, e.Row, row.ThuWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
            PXDefaultAttribute.SetPersistingCheck <CSCalendar.thuEndTime>(sender, e.Row, row.ThuWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);

            PXDefaultAttribute.SetPersistingCheck <CSCalendar.friStartTime>(sender, e.Row, row.FriWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
            PXDefaultAttribute.SetPersistingCheck <CSCalendar.friEndTime>(sender, e.Row, row.FriWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);

            PXDefaultAttribute.SetPersistingCheck <CSCalendar.satStartTime>(sender, e.Row, row.SatWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
            PXDefaultAttribute.SetPersistingCheck <CSCalendar.satEndTime>(sender, e.Row, row.SatWorkDay == true ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing);
        }
Ejemplo n.º 3
0
        protected virtual void EPEmployee_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            EPEmployee    epEmployeeRow    = (EPEmployee)e.Row;
            FSxEPEmployee fsxEPEmployeeRow = PXCache <EPEmployee> .GetExtension <FSxEPEmployee>(epEmployeeRow);

            if (e.Operation != PXDBOperation.Delete)
            {
                LicenseHelper.CheckStaffMembersLicense(cache.Graph, epEmployeeRow.BAccountID, fsxEPEmployeeRow.SDEnabled, epEmployeeRow.Status);
            }

            fsxEPEmployeeRow.IsDriver = EmployeeDriverSkills.Select().Count > 0;

            Contact contactRow = Base.Contact.Current;

            if (contactRow != null)
            {
                if (fsxEPEmployeeRow.SendAppNotification == true && contactRow.EMail == null)
                {
                    if (Base.Contact.Cache.RaiseExceptionHandling <Contact.eMail>(contactRow, contactRow.EMail, new PXException(TX.Error.EMAIL_CANNOT_BE_NULL_IF_SENDAPPNOTIFICATION_IS_TRUE)))
                    {
                        throw new PXRowPersistingException(typeof(Contact.eMail).Name, contactRow.EMail, TX.Error.EMAIL_CANNOT_BE_NULL_IF_SENDAPPNOTIFICATION_IS_TRUE, typeof(Contact.eMail).Name);
                    }
                }
            }
        }
Ejemplo n.º 4
0
        protected virtual void FreightRate_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            FreightRate doc = (FreightRate)e.Row;

            if (doc.Weight < 0)
            {
                if (sender.RaiseExceptionHandling <FreightRate.weight>(e.Row, null, new PXSetPropertyException(Messages.FieldShouldNotBeNegative, typeof(FreightRate.weight).Name)))
                {
                    throw new PXRowPersistingException(typeof(FreightRate.weight).Name, null, Messages.FieldShouldNotBeNegative, typeof(FreightRate.weight).Name);
                }
                e.Cancel = true;
            }
            if (doc.Volume < 0)
            {
                if (sender.RaiseExceptionHandling <FreightRate.volume>(e.Row, null, new PXSetPropertyException(Messages.FieldShouldNotBeNegative, typeof(FreightRate.volume).Name)))
                {
                    throw new PXRowPersistingException(typeof(FreightRate.volume).Name, null, Messages.FieldShouldNotBeNegative, typeof(FreightRate.volume).Name);
                }
                e.Cancel = true;
            }
            if (doc.Rate < 0)
            {
                if (sender.RaiseExceptionHandling <FreightRate.rate>(e.Row, null, new PXSetPropertyException(Messages.FieldShouldNotBeNegative, typeof(FreightRate.rate).Name)))
                {
                    throw new PXRowPersistingException(typeof(FreightRate.rate).Name, null, Messages.FieldShouldNotBeNegative, typeof(FreightRate.rate).Name);
                }
                e.Cancel = true;
            }
        }
Ejemplo n.º 5
0
        protected virtual void Ledger_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            Ledger ledger = (Ledger)e.Row;

            if (ledger.DefBranchID != null && (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update))
            {
                object BranchCD = sender.GetValueExt <Ledger.defBranchID>(e.Row);
                if (BranchCD is PXFieldState)
                {
                    BranchCD = ((PXFieldState)BranchCD).Value;
                }

                IN.INSite site;
                if ((site = PXSelect <IN.INSite, Where <IN.INSite.branchID, Equal <Required <IN.INSite.branchID> > > > .SelectWindowed(this, 0, 1, ledger.DefBranchID)) != null)
                {
                    sender.RaiseExceptionHandling <Ledger.defBranchID>(e.Row, BranchCD, new PXSetPropertyException(Messages.BranchUsedWithSite, site.SiteCD));
                }

                FA.FixedAsset asset;
                if ((asset = PXSelect <FA.FixedAsset, Where <FA.FixedAsset.branchID, Equal <Required <FA.FixedAsset.branchID> > > > .SelectWindowed(this, 0, 1, ledger.DefBranchID)) != null)
                {
                    sender.RaiseExceptionHandling <Ledger.defBranchID>(e.Row, BranchCD, new PXSetPropertyException(Messages.BranchUsedWithFixedAsset, asset.AssetCD));
                }
            }
        }
Ejemplo n.º 6
0
        public virtual void IIProductLine_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            IIProductLine cfg = e.Row as IIProductLine;

            if ((cfg == null) || (cfg.ProductLineID == null))
            {
                return;
            }

            PXResultset <IIProductLineFilter> rsFilters = PXSelect <IIProductLineFilter, Where <IIProductLineFilter.productLineID, Equal <Current <IIProductLine.productLineID> > >, OrderBy <Asc <IIProductLineFilter.sortOrder> > > .Select(this, cfg.ProductLineID);

            foreach (ItemPickerMapping im in ItemPickerMappings.Select())
            {
                if (
                    (rsFilters?.Count >= 1) && (im.Column1 == "" || im.Column1 == null) ||
                    (rsFilters?.Count >= 2) && (im.Column2 == "" || im.Column2 == null) ||
                    (rsFilters?.Count >= 3) && (im.Column3 == "" || im.Column3 == null) ||
                    (rsFilters?.Count >= 4) && (im.Column4 == "" || im.Column4 == null) ||
                    (rsFilters?.Count >= 5) && (im.Column5 == "" || im.Column5 == null) ||
                    (rsFilters?.Count >= 6) && (im.Column6 == "" || im.Column6 == null) ||
                    (rsFilters?.Count >= 7) && (im.Column7 == "" || im.Column7 == null) ||
                    (rsFilters?.Count >= 8) && (im.Column8 == "" || im.Column8 == null) ||
                    (rsFilters?.Count >= 9) && (im.Column9 == "" || im.Column9 == null)
                    )
                {
                    throw new PXException("All values in mapping columns must be specified. Provide correct values for mapping and then save the form.");
                }
            }
        }
Ejemplo n.º 7
0
        public override void RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            object val;

            if (_PersistingCheck != PXPersistingCheck.Nothing &&
                ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert ||
                 (e.Operation & PXDBOperation.Command) == PXDBOperation.Update) &&
                (val = sender.GetValue(e.Row, _FieldOrdinal)) != null && (decimal)val != 1m)
            {
                val = (decimal)val * 100m;
                if (_MapErrorTo == null)
                {
                    if (sender.RaiseExceptionHandling(_FieldName, e.Row, val, new PXSetPropertyException(PXMessages.LocalizeFormat(Messages.WrongValue, _FieldName))))
                    {
                        throw new PXRowPersistingException(_FieldName, null, Messages.WrongValue, _FieldName);
                    }
                }
                else
                {
                    string name = _MapErrorTo.Name;
                    name = char.ToUpper(name[0]) + name.Substring(1);
                    val  = sender.GetValueExt(e.Row, name);
                    if (val is PXFieldState)
                    {
                        val = ((PXFieldState)val).Value;
                    }
                    if (sender.RaiseExceptionHandling(name, e.Row, val, new PXSetPropertyException(PXMessages.LocalizeFormat(Messages.WrongValue, name, _FieldName))))
                    {
                        throw new PXRowPersistingException(_FieldName, null, Messages.WrongValue, _FieldName);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        protected void Customer_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            Customer row = (Customer)e.Row;

            if (row == null)
            {
                return;
            }

            var str   = row.AcctCD.ToString().Trim();
            int value = str.Length;

            if (System.Text.RegularExpressions.Regex.IsMatch(str, @"^[a-zA-Z0-9]+$"))
            {
                if (value != 6)
                {
                    sender.RaiseExceptionHandling <Customer.acctCD>(e.Row, row.AcctCD, new PXSetPropertyException(CustomMessage.CustomerIDInvalid));
                }
            }
            else
            {
                sender.RaiseExceptionHandling <Customer.acctCD>(e.Row, row.AcctCD, new PXSetPropertyException(CustomMessage.BAccountCharInvalid));
            }
            maintainCustomer(sender, row);
        }
Ejemplo n.º 9
0
        protected virtual void Tax_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete)
            {
                if (((Tax)e.Row).TaxType == CSTaxType.Use)
                {
                    CheckFieldIsEmpty <Tax.expenseAccountID>(sender, e);
                    CheckFieldIsEmpty <Tax.expenseSubID>(sender, e);
                }

                if (((Tax)e.Row).TaxType == CSTaxType.VAT)
                {
                    CheckFieldIsEmpty <Tax.purchTaxAcctID>(sender, e);
                    CheckFieldIsEmpty <Tax.purchTaxSubID>(sender, e);
                }

                if (((Tax)e.Row).PendingTax == true)
                {
                    CheckFieldIsEmpty <Tax.pendingSalesTaxAcctID>(sender, e);
                    CheckFieldIsEmpty <Tax.pendingSalesTaxSubID>(sender, e);
                    CheckFieldIsEmpty <Tax.pendingPurchTaxAcctID>(sender, e);
                    CheckFieldIsEmpty <Tax.pendingPurchTaxSubID>(sender, e);
                }
            }
        }
Ejemplo n.º 10
0
        public virtual void VendorClass_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            VendorClass row = (VendorClass)e.Row;
            PXSelectBase <CashAccount> select = new PXSelect <CashAccount, Where <CashAccount.cashAccountID,
                                                                                  Equal <Required <VendorClass.cashAcctID> > > >(this);

            if (!String.IsNullOrEmpty(row.CuryID) && (row.AllowOverrideCury ?? false) != true)
            {
                CashAccount acct = select.Select(row.CashAcctID);
                if (acct != null)
                {
                    if (row.CuryID != acct.CuryID)
                    {
                        if (cache.RaiseExceptionHandling <VendorClass.cashAcctID>(e.Row, acct.CashAccountCD, new PXSetPropertyException(Messages.VendorCuryDifferentDefPayCury, typeof(VendorClass.cashAcctID).Name)))
                        {
                            throw new PXRowPersistingException(typeof(VendorClass.cashAcctID).Name, null, Messages.VendorCuryDifferentDefPayCury, typeof(VendorClass.cashAcctID).Name);
                        }
                    }
                }
            }
            if (VendorClassRecord.Cache.GetStatus(e.Row) == PXEntryStatus.Inserted)
            {
                EPEmployeeClass e1 = PXSelect <EPEmployeeClass, Where <EPEmployeeClass.vendorClassID, Equal <Current <VendorClass.vendorClassID> > > > .SelectSingleBound(this, new object[] { e.Row });

                if (e1 != null)
                {
                    cache.IsDirty = false;
                    e.Cancel      = true;
                    throw new PXRowPersistingException(typeof(VendorClass.vendorClassID).Name, null, Messages.EmployeeClassExists);
                }
            }
        }
Ejemplo n.º 11
0
        protected virtual void DaylightShift_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            DaylightShift row = e.Row as DaylightShift;

            if (row == null || row.Year == null || row.TimeZone == null || row.IsActive == true)
            {
                return;
            }

            DaylightSavingTime dts = GetDST(row.TimeZone, (int)row.Year);

            if ((dts != null && dts.IsActive &&
                 row.FromDate == dts.Start && row.ToDate == dts.End && row.Shift == (int)dts.DaylightOffset.TotalMinutes)
                ||
                (row.FromDate == null && row.ToDate == null && row.Shift == null))
            {
                DaylightShift savedRow = PXSelectReadonly <DaylightShift,
                                                           Where <DaylightShift.year, Equal <Current <DaylightShiftFilter.year> >,
                                                                  And <DaylightShift.timeZone, Equal <Required <DaylightShift.timeZone> > > > > .SelectWindowed(this, 0, 1, row.TimeZone);

                row.FromDate = savedRow.FromDate;
                row.ToDate   = savedRow.ToDate;
                row.Shift    = savedRow.Shift;
            }
        }
Ejemplo n.º 12
0
        protected virtual void INTran_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            INTran row = (INTran)e.Row;

            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Update)
            {
                if (!string.IsNullOrEmpty(row.SOShipmentNbr))
                {
                    if (PXDBQuantityAttribute.Round((decimal)(row.Qty + row.OrigQty)) > 0m)
                    {
                        sender.RaiseExceptionHandling <INTran.qty>(row, row.Qty, new PXSetPropertyException(CS.Messages.Entry_LE, -row.OrigQty));
                    }
                    else if (PXDBQuantityAttribute.Round((decimal)(row.Qty + row.OrigQty)) < 0m)
                    {
                        sender.RaiseExceptionHandling <INTran.qty>(row, row.Qty, new PXSetPropertyException(CS.Messages.Entry_GE, -row.OrigQty));
                    }
                }
            }

            if (((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert || (e.Operation & PXDBOperation.Command) == PXDBOperation.Update))
            {
                CheckForSingleLocation(sender, row);
                CheckSplitsForSameTask(sender, row);
                CheckLocationTaskRule(sender, row);
            }
        }
        protected virtual void FSStaffSchedule_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            FSStaffSchedule fsStaffScheduleRow = (FSStaffSchedule)e.Row;

            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);
                }
            }
        }
        protected virtual void PMProject_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            PMProject project = e.Row as PMProject;

            PX.SM.RelationGroup group = Group.Current;
            if (project != null && project.GroupMask != null && group != null && group.GroupMask != null && e.Operation != PXDBOperation.Delete)
            {
                if (project.GroupMask.Length < group.GroupMask.Length)
                {
                    byte[] mask = project.GroupMask;
                    Array.Resize <byte>(ref mask, group.GroupMask.Length);
                    project.GroupMask = mask;
                }
                for (int i = 0; i < group.GroupMask.Length; i++)
                {
                    if (group.GroupMask[i] == 0x00)
                    {
                        continue;
                    }
                    if (project.Included == true)
                    {
                        project.GroupMask[i] = (byte)(project.GroupMask[i] | group.GroupMask[i]);
                    }
                    else
                    {
                        project.GroupMask[i] = (byte)(project.GroupMask[i] & ~group.GroupMask[i]);
                    }
                }
            }
        }
        protected virtual void PaymentMethodAccount_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            PaymentMethodAccount row = (PaymentMethodAccount)e.Row;

            PXDefaultAttribute.SetPersistingCheck <PaymentMethodAccount.aPLastRefNbr>(sender, e.Row, row.APAutoNextNbr == true ? PXPersistingCheck.NullOrBlank
                                                                                                                                                                                                                                                          : PXPersistingCheck.Nothing);
            if (row.APAutoNextNbr == true && row.APLastRefNbr == null)
            {
                sender.RaiseExceptionHandling <PaymentMethodAccount.aPAutoNextNbr>(row, row.APAutoNextNbr, new PXSetPropertyException(Messages.SpecifyLastRefNbr, GL.Messages.ModuleAP));
            }

            if (row.ARAutoNextNbr == true && row.ARLastRefNbr == null)
            {
                sender.RaiseExceptionHandling <PaymentMethodAccount.aRAutoNextNbr>(row, row.ARAutoNextNbr, new PXSetPropertyException(Messages.SpecifyLastRefNbr, GL.Messages.ModuleAR));
            }

            CashAccount cashAccount = PXSelectReadonly <CashAccount,
                                                        Where <CashAccount.cashAccountID, Equal <Required <CashAccount.cashAccountID> > > > .Select(this, row.CashAccountID);

            if (cashAccount != null && cashAccount.Active != true)
            {
                string errorMsg = string.Format(CA.Messages.CashAccountInactive, cashAccount.CashAccountCD.Trim());
                sender.RaiseExceptionHandling <PaymentMethodAccount.cashAccountID>(e.Row, cashAccount.CashAccountCD, new PXSetPropertyException(errorMsg, PXErrorLevel.Error));
            }
        }
        protected virtual void EPSetup_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            var row = e.Row as EPSetup;

            if (row == null || e.Operation == PXDBOperation.Delete)
            {
                return;
            }
            if (row.PostToOffBalance == true && row.OffBalanceAccountGroupID == null)
            {
                if (cache.RaiseExceptionHandling <EPSetup.offBalanceAccountGroupID>(e.Row, row.OffBalanceAccountGroupID, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName <EPSetup.offBalanceAccountGroupID>(cache))))
                {
                    throw new PXRowPersistingException(typeof(EPSetup.offBalanceAccountGroupID).Name, row.OffBalanceAccountGroupID, ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName <EPSetup.offBalanceAccountGroupID>(cache));
                }
            }
            if (row.CustomWeek == true)
            {
                DateTime?firsUsing = GetFirstUsingWeek();
                DateTime?lastUsing = GetLasttUsingWeek();

                if (firsUsing != null && lastUsing != null)
                {
                    EPCustomWeek firstWeek = (EPCustomWeek)PXSelectOrderBy <EPCustomWeek, OrderBy <Asc <EPCustomWeek.weekID> > > .SelectSingleBound(this, null);

                    EPCustomWeek lastWeek = (EPCustomWeek)PXSelectOrderBy <EPCustomWeek, OrderBy <Desc <EPCustomWeek.weekID> > > .SelectSingleBound(this, null);

                    if (firstWeek == null || firsUsing < firstWeek.StartDate || lastWeek == null || lastWeek.EndDate < lastUsing)
                    {
                        throw new PXRowPersistingException(typeof(EPSetup.customWeek).Name, row.CustomWeek, Messages.CustomWeekNotCreated, firsUsing, lastUsing);
                    }
                }
            }
        }
Ejemplo n.º 17
0
        protected virtual void APDiscount_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            APDiscount row = e.Row as APDiscount;

            if (row != null)
            {
                if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update)
                {
                    if (PXSelectReadonly <ARDiscount, Where <ARDiscount.discountID, Equal <Required <ARDiscount.discountID> > > > .Select(this, row.DiscountID).Count != 0)
                    {
                        sender.RaiseExceptionHandling <APDiscount.discountID>(row, row.DiscountID, new PXSetPropertyException(Messages.DiscountCodeAlreadyExistAR, PXErrorLevel.Error));
                    }
                    if ((row.Type == DiscountType.Line || row.Type == DiscountType.Document) && row.SkipDocumentDiscounts == true)
                    {
                        row.SkipDocumentDiscounts = false;
                    }
                    if ((row.Type == DiscountType.Group || row.Type == DiscountType.Document) && row.ExcludeFromDiscountableAmt == true)
                    {
                        row.ExcludeFromDiscountableAmt = false;
                    }
                }
                if (e.Operation == PXDBOperation.Insert)
                {
                    if (PXSelectReadonly <APDiscount, Where <APDiscount.discountID, Equal <Required <APDiscount.discountID> > > > .Select(this, row.DiscountID).Count != 0)
                    {
                        sender.RaiseExceptionHandling <APDiscount.discountID>(row, row.DiscountID, new PXSetPropertyException(Messages.DiscountCodeAlreadyExist, PXErrorLevel.Error));
                    }
                }
            }
        }
Ejemplo n.º 18
0
        protected virtual void Person_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            var person = (Person)e.Row;

            if (string.IsNullOrEmpty(person?.Name) == false)
            {
                if (string.IsNullOrEmpty(person?.GroupName) == false)
                {
                    switch (e.Operation)
                    {
                    case PXDBOperation.Delete:
                        Api.DeletePerson(person);
                        this.Clear();
                        break;

                    case PXDBOperation.Insert:
                        Api.CreatePerson(person);
                        this.Clear();
                        break;

                    case PXDBOperation.Update:
                        Api.UpdatePerson(person);
                        break;
                    }

                    e.Cancel = true;
                }
            }
        }
        protected virtual void Contact_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            Contact row = e.Row as Contact;

            if (row != null && IsImport && !IsExport)
            {
                bool needupdate = false;
                foreach (var field in Caches[typeof(Contact)].Fields)
                {
                    PXFieldState newfieldstate  = Caches[typeof(Contact)].GetStateExt(row, field) as PXFieldState;
                    var          fieldattribues = Caches[typeof(Contact)].GetAttributes(row, field);
                    bool         needcheck      = fieldattribues.Any(x => x is PXDBFieldAttribute) &&
                                                  fieldattribues.Any(x => x is PXUIFieldAttribute) && newfieldstate != null &&
                                                  newfieldstate.Enabled;
                    if (!needcheck)
                    {
                        continue;
                    }

                    object oldfieldvalue = Caches[typeof(Contact)].GetValueOriginal(row, field);
                    object newfieldvalue = Caches[typeof(Contact)].GetValue(row, field);
                    if (!Equals(oldfieldvalue, newfieldvalue))
                    {
                        needupdate = true;
                        break;
                    }
                }
                if (!needupdate)
                {
                    e.Cancel = true;
                }
            }
        }
        protected virtual void KCImagePlacement_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if (e == null || e.Row == null)
            {
                return;
            }
            KCImagePlacement row = e.Row as KCImagePlacement;

            if (ImagePlacements.Cache.GetStatus(row) != PXEntryStatus.Deleted)
            {
                if (IsAttributeEmpty(row))
                {
                    sender.RaiseExceptionHandling <KCImagePlacement.attributeID>(e.Row, null, new Exception(KCMessages.AttributeCanNotBeNull));
                    throw new PXException(KCMessages.AttributeCanNotBeNull);
                }

                if (IsImagePlacementEmpty(row))
                {
                    sender.RaiseExceptionHandling <KCImagePlacement.imagePlacement>(e.Row, null, new Exception(KCMessages.ImagePlacementShouldBeFilled));
                    throw new PXException(KCMessages.ImagePlacementShouldBeFilled);
                }
            }

            ClearAttributesMapping(row);
        }
        protected virtual void INKitSpecNonStkDet_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            INKitSpecNonStkDet row = e.Row as INKitSpecNonStkDet;

            if (row == null)
            {
                return;
            }
            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete)
            {
                return;
            }

            PXSelectBase <INKitSpecNonStkDet> select = new PXSelect <INKitSpecNonStkDet,
                                                                     Where <INKitSpecNonStkDet.kitInventoryID, Equal <Current <INKitSpecHdr.kitInventoryID> >,
                                                                            And <INKitSpecNonStkDet.revisionID, Equal <Current <INKitSpecHdr.revisionID> >,
                                                                                 And <INKitSpecNonStkDet.compInventoryID, Equal <Required <INKitSpecStkDet.compInventoryID> > > > > >(this);

            PXResultset <INKitSpecNonStkDet> res = select.Select(row.CompInventoryID);

            if (res.Count > 1)
            {
                InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(this, row.CompInventoryID);

                if (sender.RaiseExceptionHandling <INKitSpecNonStkDet.compInventoryID>(e.Row, item.InventoryCD, new PXException(Messages.KitItemMustBeUnique)))
                {
                    throw new PXRowPersistingException(typeof(INKitSpecNonStkDet.compInventoryID).Name, item.InventoryCD, Messages.KitItemMustBeUnique);
                }
            }
        }
        protected virtual void ARInvoice_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            if (e.Row == null || SharedFunctions.isFSSetupSet(Base) == false)
            {
                return;
            }

            ARInvoice arInvoiceRow = (ARInvoice)e.Row;

            if (e.Operation == PXDBOperation.Update &&
                (Base.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.INVOICE_BY_APPOINTMENT) &&
                 Base.Accessinfo.ScreenID != SharedFunctions.SetScreenIDToDotFormat(ID.ScreenID.INVOICE_BY_SERVICE_ORDER)))
            {
                FSCreatedDoc fsCreatedDocRow = PXSelectJoin <FSCreatedDoc,
                                                             InnerJoin <FSPostBatch, On <FSCreatedDoc.batchID, Equal <FSPostBatch.batchID> > >,
                                                             Where <
                                                                 FSPostBatch.status, Equal <FSPostBatch.status.temporary>,
                                                                 And <FSPostBatch.postTo, Equal <FSPostBatch.postTo.AR>,
                                                                      And <FSCreatedDoc.createdRefNbr, Equal <Required <FSCreatedDoc.createdRefNbr> >,
                                                                           And <FSCreatedDoc.createdDocType, Equal <Required <FSCreatedDoc.createdDocType> > > > > > >
                                               .Select(Base, arInvoiceRow.RefNbr, arInvoiceRow.DocType);

                if (fsCreatedDocRow != null)
                {
                    throw new PXException(TX.Error.CANNOT_UPDATE_DOCUMENT_BECAUSE_BATCH_STATUS_IS_TEMPORARY);
                }
            }
        }
Ejemplo n.º 23
0
        protected virtual void Carrier_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            Carrier doc = (Carrier)e.Row;

            if (doc.BaseRate < 0)
            {
                if (sender.RaiseExceptionHandling <Carrier.baseRate>(e.Row, null, new PXSetPropertyException(Messages.FieldShouldNotBeNegative, typeof(Carrier.baseRate).Name)))
                {
                    throw new PXRowPersistingException(typeof(Carrier.baseRate).Name, null, Messages.FieldShouldNotBeNegative, typeof(Carrier.baseRate).Name);
                }
                e.Cancel = true;
            }

            if (doc.IsExternal == true)
            {
                if (string.IsNullOrEmpty(doc.CarrierPluginID))
                {
                    if (sender.RaiseExceptionHandling <Carrier.carrierPluginID>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(Carrier.carrierPluginID).Name)))
                    {
                        throw new PXRowPersistingException(typeof(Carrier.carrierPluginID).Name, null, ErrorMessages.FieldIsEmpty, typeof(Carrier.carrierPluginID).Name);
                    }
                    e.Cancel = true;
                }

                if (string.IsNullOrEmpty(doc.PluginMethod))
                {
                    if (sender.RaiseExceptionHandling <Carrier.pluginMethod>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(Carrier.pluginMethod).Name)))
                    {
                        throw new PXRowPersistingException(typeof(Carrier.pluginMethod).Name, null, ErrorMessages.FieldIsEmpty, typeof(Carrier.pluginMethod).Name);
                    }
                    e.Cancel = true;
                }
            }
        }
Ejemplo n.º 24
0
        public void OnRowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            GLTran tran = (GLTran)e.Row;

            if (tran != null && ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete))
            {
                PXCache batchCache = sender.Graph.Caches[typeof(Batch)];
                Batch   batch      = (Batch)batchCache.Current;
                if (batch != null && string.IsNullOrEmpty(batch.BatchNbr) == false)
                {
                    string batchNbr = batch.BatchNbr;
                    if (string.IsNullOrEmpty(tran.RefNbr))
                    {
                        string extRefNbr;
                        if (!_batchKeys.TryGetValue(batchNbr, out extRefNbr))
                        {
                            extRefNbr = AutoNumberAttribute.GetNextNumber(sender, tran, extRefNbrNumbering, tran.TranDate);
                            _batchKeys.Add(batchNbr, extRefNbr);
                        }
                        tran.RefNbr = extRefNbr;

                        PXDBLiteDefaultAttribute.SetDefaultForInsert <GLTran.refNbr>(sender, tran, false);
                    }
                }
            }
        }
        protected virtual void Account_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            Account row = (Account)e.Row;

            if (!string.IsNullOrEmpty(row.CuryID))
            {
                CASetup casetup = PXSelect <CASetup> .Select(this);

                if (casetup != null && casetup.TransitAcctId != null && casetup.TransitAcctId == row.AccountID)
                {
                    PXException exception = new PXException(CA.Messages.CashInTransitAccountCanNotBeDenominated);
                    sender.RaiseExceptionHandling <Account.curyID>(row, row.CuryID, exception);
                    throw exception;
                }

                string newCuryid;
                if (e.Operation == PXDBOperation.Update)
                {
                    newCuryid = row.CuryID;
                    byte[] timestamp = PXDatabase.SelectTimeStamp();

                    PXDatabase.Update <GLHistory>(new PXDataFieldAssign("CuryID", newCuryid),
                                                  new PXDataFieldRestrict("AccountID", ((Account)e.Row).AccountID),
                                                  new PXDataFieldRestrict("CuryID", PXDbType.VarChar, 5, null, PXComp.ISNULL),
                                                  new PXDataFieldRestrict("tstamp", PXDbType.Timestamp, 8, timestamp, PXComp.LE));
                }
            }
        }
Ejemplo n.º 26
0
        protected virtual void APInvoice_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            APInvoice doc = (APInvoice)e.Row;

            if (doc.PaySel == true && doc.PayDate == null)
            {
                sender.RaiseExceptionHandling <APInvoice.payDate>(doc, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(APInvoice.payDate).Name));
            }

            if (doc.PaySel == true && doc.DocDate != null && doc.PayDate != null &&
                ((DateTime)doc.DocDate).CompareTo((DateTime)doc.PayDate) > 0)
            {
                sender.RaiseExceptionHandling <APInvoice.payDate>(e.Row, doc.PayDate, new PXSetPropertyException(Messages.ApplDate_Less_DocDate, PXErrorLevel.RowError, typeof(APInvoice.payDate).Name));
            }

            if (doc.PaySel == true && doc.PayLocationID == null)
            {
                sender.RaiseExceptionHandling <APInvoice.payLocationID>(doc, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(APInvoice.payLocationID).Name));
            }

            if (doc.PaySel == true && doc.PayAccountID == null)
            {
                sender.RaiseExceptionHandling <APInvoice.payAccountID>(doc, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(APInvoice.payAccountID).Name));
            }

            if (doc.PaySel == true && doc.PayTypeID == null)
            {
                sender.RaiseExceptionHandling <APInvoice.payTypeID>(doc, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(APInvoice.payTypeID).Name));
            }
        }
        protected virtual void PaymentTypeInstance_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete)
            {
                PaymentTypeInstance row = (PaymentTypeInstance)e.Row;
                PaymentMethod       def = this.PaymentTypeDef.Select();
                //bool singleInstance = def.ARIsOnePerCustomer ?? false;
                bool singleInstance = false;
                if (singleInstance)
                {
                    PaymentTypeInstance existing = PXSelect <PaymentTypeInstance,
                                                             Where <PaymentTypeInstance.bAccountID, Equal <Required <PaymentTypeInstance.bAccountID> >,
                                                                    And <PaymentTypeInstance.paymentMethodID, Equal <Required <PaymentTypeInstance.paymentMethodID> >,
                                                                         And <PaymentTypeInstance.pTInstanceID, NotEqual <Required <PaymentTypeInstance.pTInstanceID> > > > > > .Select(this, row.BAccountID, row.PaymentMethodID, row.PTInstanceID);

                    if (existing != null)
                    {
                        //throw new PXException(Messages.PaymentTypeIsAlreadyDefined);
                    }
                }
                foreach (PaymentTypeInstanceDetail iDet in this.Details.Select())
                {
                    if (!ValidateDetail(iDet))
                    {
                        e.Cancel = true;
                    }
                }
            }
        }
Ejemplo n.º 28
0
        protected virtual void InventoryItem_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete)
            {
                return;
            }
            InventoryItem item = e.Row as InventoryItem;

            PX.SM.RelationGroup group = Group.Current;
            if (item != null && item.GroupMask != null && group != null && group.GroupMask != null)
            {
                if (item.GroupMask.Length < group.GroupMask.Length)
                {
                    byte[] mask = item.GroupMask;
                    Array.Resize <byte>(ref mask, group.GroupMask.Length);
                    item.GroupMask = mask;
                }
                for (int i = 0; i < group.GroupMask.Length; i++)
                {
                    if (group.GroupMask[i] == 0x00)
                    {
                        continue;
                    }
                    if (item.Included == true)
                    {
                        item.GroupMask[i] = (byte)(item.GroupMask[i] | group.GroupMask[i]);
                    }
                    else
                    {
                        item.GroupMask[i] = (byte)(item.GroupMask[i] & ~group.GroupMask[i]);
                    }
                }
            }
        }
Ejemplo n.º 29
0
        public virtual void Contact_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            if (e.Row == null)
            {
                return;
            }

            Contact contactRow = (Contact)e.Row;

            EPEmployee epEmployeeRow = Base.Employee.Current;

            FSxEPEmployee fsxEPEmployeeRow;

            if (epEmployeeRow != null)
            {
                fsxEPEmployeeRow = PXCache <EPEmployee> .GetExtension <FSxEPEmployee>(epEmployeeRow);

                if (fsxEPEmployeeRow.SendAppNotification == true && contactRow.EMail == null)
                {
                    if (cache.RaiseExceptionHandling <Contact.eMail>(contactRow, contactRow.EMail, new PXException(TX.Error.EMAIL_CANNOT_BE_NULL_IF_SENDAPPNOTIFICATION_IS_TRUE)))
                    {
                        throw new PXRowPersistingException(typeof(Contact.eMail).Name, contactRow.EMail, TX.Error.EMAIL_CANNOT_BE_NULL_IF_SENDAPPNOTIFICATION_IS_TRUE, typeof(Contact.eMail).Name);
                    }
                }
            }
        }
Ejemplo n.º 30
0
        protected virtual void CRCampaign_RowPersisting(PXCache cache, PXRowPersistingEventArgs e)
        {
            CRCampaign row = (CRCampaign)e.Row;

            if (row != null)
            {
                if (row.StartDate.HasValue == false)
                {
                    if (cache.RaiseExceptionHandling <CRCampaign.startDate>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(CRCampaign.startDate).Name)))
                    {
                        throw new PXRowPersistingException(typeof(CRCampaign.startDate).Name, null, ErrorMessages.FieldIsEmpty, typeof(CRCampaign.startDate).Name);
                    }
                }

                if (row.ProjectID.HasValue && !row.ProjectTaskID.HasValue)
                {
                    if (cache.RaiseExceptionHandling <CRCampaign.projectTaskID>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(CRCampaign.projectTaskID).Name)))
                    {
                        throw new PXRowPersistingException(typeof(CRCampaign.projectTaskID).Name, null, ErrorMessages.FieldIsEmpty, typeof(CRCampaign.projectTaskID).Name);
                    }
                }

                if (row.ProjectTaskID.HasValue)
                {
                    if (PXSelectGroupBy <CRCampaign,
                                         Where <CRCampaign.projectID, Equal <Required <CRCampaign.projectID> >,
                                                And <CRCampaign.projectTaskID, Equal <Required <CRCampaign.projectTaskID> >,
                                                     And <CRCampaign.campaignID, NotEqual <Required <CRCampaign.campaignID> > > > >,
                                         Aggregate <Count> > .Select(this, new object[] { row.ProjectID, row.ProjectTaskID, row.CampaignID }).RowCount > 0)
                    {
                        throw new PXRowPersistingException(typeof(CRCampaign.projectTaskID).Name, row.ProjectTaskID, Messages.TaskIsAlreadyLinkedToCampaign, typeof(CRCampaign.projectTaskID).Name);
                    }
                }
            }
        }