Beispiel #1
0
        void sender_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            object val = sender.GetValue(e.Row, _FieldOrdinal);

            if (val == null)
            {
                Guid noteID = SequentialGuid.Generate();
                sender.SetValue(e.Row, _FieldOrdinal, noteID);
            }
        }
        public void RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            // ensure noteID is initialized on main object
            int ixNote = sender.GetFieldOrdinal(NoteID);
            var noteId = sender.GetValue(e.Row, ixNote);

            if (null == noteId)
            {
                sender.SetValue(e.Row, ixNote, SequentialGuid.Generate());
            }
        }
        public virtual void RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            object row           = e.Row;
            Type   conditionType = Condition;

            if (row == null || conditionType == null)
            {
                return;
            }

            PXPersistingCheck  persistingCheck  = GetConditionResult(sender, row, conditionType) ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing;
            PXDefaultAttribute defaultAttribute = sender.GetAttributesReadonly(_FieldName).OfType <PXDefaultAttribute>().FirstOrDefault();

            if (defaultAttribute != null)
            {
                defaultAttribute.PersistingCheck = persistingCheck;
                defaultAttribute.RowPersisting(sender, e);
                defaultAttribute.PersistingCheck = PXPersistingCheck.Nothing;
            }
        }
        public virtual void RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            object row           = e.Row;
            Type   conditionType = Condition;

            if (row == null || conditionType == null)
            {
                return;
            }

            PXDefaultAttribute defaultAttribute = GetDefaultAttribute(sender);

            if (defaultAttribute != null)
            {
                PXPersistingCheck persistingCheck = GetConditionResult(sender, row, conditionType) ? PXPersistingCheck.NullOrBlank : PXPersistingCheck.Nothing;
                defaultAttribute.PersistingCheck = persistingCheck;
                defaultAttribute.RowPersisting(sender, e);
                defaultAttribute.PersistingCheck = PXPersistingCheck.Nothing;
            }
        }
        void IPXRowPersistingSubscriber.RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if (!this.CheckOnRowPersisting)
            {
                return;
            }

            try
            {
                Verifying(sender, e.Row);
            }
            catch (PXSetPropertyException ex)
            {
                var newValue = sender.GetValueExt(e.Row, _FieldName);
                if (newValue is PXFieldState)
                {
                    newValue = ((PXFieldState)newValue).Value;
                }
                sender.RaiseExceptionHandling(_FieldName, e.Row, newValue, ex);
            }
        }
Beispiel #6
0
		protected virtual void Customer_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
		{
			Customer cust = e.Row as Customer;
			PX.SM.RelationGroup group = Group.Current;
			if (cust != null && cust.GroupMask != null && group != null && group.GroupMask != null)
			{
				if (cust.GroupMask.Length < group.GroupMask.Length)
				{
					byte[] mask = cust.GroupMask;
					Array.Resize<byte>(ref mask, group.GroupMask.Length);
					cust.GroupMask = mask;
				}
				for (int i = 0; i < group.GroupMask.Length; i++)
				{
					if (group.GroupMask[i] == 0x00)
					{
						continue;
					}
					if (cust.Included == true)
					{
						cust.GroupMask[i] = (byte)(cust.GroupMask[i] | group.GroupMask[i]);
					}
					else
					{
						cust.GroupMask[i] = (byte)(cust.GroupMask[i] & ~group.GroupMask[i]);
					}
				}
			}
		}
Beispiel #7
0
		protected virtual void InventoryItem_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
		{
			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]);
					}
				}
			}
		}
Beispiel #8
0
		protected virtual void INItemClass_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
		{
			INItemClass cLass = e.Row as INItemClass;
			PX.SM.RelationGroup group = Group.Current;
			if (cLass != null && cLass.GroupMask != null && group != null && group.GroupMask != null)
			{
				if (cLass.GroupMask.Length < group.GroupMask.Length)
				{
					byte[] mask = cLass.GroupMask;
					Array.Resize<byte>(ref mask, group.GroupMask.Length);
					cLass.GroupMask = mask;
				}
				for (int i = 0; i < group.GroupMask.Length; i++)
				{
					if (group.GroupMask[i] == 0x00)
					{
						continue;
					}
					if (cLass.Included == true)
					{
						cLass.GroupMask[i] = (byte)(cLass.GroupMask[i] | group.GroupMask[i]);
					}
					else
					{
						cLass.GroupMask[i] = (byte)(cLass.GroupMask[i] & ~group.GroupMask[i]);
					}
				}
			}
		}
Beispiel #9
0
		protected virtual void Vendor_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
		{
			Vendor vend = e.Row as Vendor;
			PX.SM.RelationGroup group = Group.Current;
			if (vend != null && vend.GroupMask != null && group != null && group.GroupMask != null)
			{
				if (vend.GroupMask.Length < group.GroupMask.Length)
				{
					byte[] mask = vend.GroupMask;
					Array.Resize<byte>(ref mask, group.GroupMask.Length);
					vend.GroupMask = mask;
				}
				for (int i = 0; i < group.GroupMask.Length; i++)
				{
					if (group.GroupMask[i] == 0x00)
					{
						continue;
					}
					if (vend.Included == true)
					{
						vend.GroupMask[i] = (byte)(vend.GroupMask[i] | group.GroupMask[i]);
					}
					else
					{
						vend.GroupMask[i] = (byte)(vend.GroupMask[i] & ~group.GroupMask[i]);
					}
				}
			}
		}
		protected override void ARInvoice_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
		{
			if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Insert)
			{
				PXResult<SOOrderShipment, SOOrderType> sotype =
					(PXResult<SOOrderShipment, SOOrderType>)
					PXSelectJoin<SOOrderShipment, 
					InnerJoin<SOOrderType, 
								 On<SOOrderType.orderType, Equal<SOOrderShipment.orderType>>>, 
					Where<SOOrderShipment.invoiceType, Equal<Current<ARInvoice.docType>>, 
						And<SOOrderShipment.invoiceNbr, Equal<Current<ARInvoice.refNbr>>>>>
						.SelectSingleBound(this, new object[] { e.Row });

				if (sotype != null)
				{
					if (string.IsNullOrEmpty(((ARInvoice)e.Row).RefNbr) && ((SOOrderType)sotype).UserInvoiceNumbering == true)
					{
						throw new PXException(ErrorMessages.FieldIsEmpty, PXUIFieldAttribute.GetDisplayName<SOOrder.invoiceNbr>(soorder.Cache));
					}

					if (((SOOrderType)sotype).MarkInvoicePrinted == true)
					{
						((ARInvoice)e.Row).Printed = true;
					}

					if (((SOOrderType)sotype).MarkInvoiceEmailed == true)
					{
						((ARInvoice)e.Row).Emailed = true;
					}

					AutoNumberAttribute.SetNumberingId<ARInvoice.refNbr>(Document.Cache, ((SOOrderType)sotype).ARDocType, ((SOOrderType)sotype).InvoiceNumberingID);
				}
			}

			base.ARInvoice_RowPersisting(sender, e);
		}
		protected virtual void SOInvoice_RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
		{
			if (e.Operation == PXDBOperation.Insert || e.Operation == PXDBOperation.Update)
			{
				SOInvoice doc = (SOInvoice)e.Row;

				if ((doc.DocType == ARDocType.CashSale || doc.DocType == ARDocType.CashReturn))
				{
                    if (String.IsNullOrEmpty(doc.PaymentMethodID) == true)
                    {
                        if (sender.RaiseExceptionHandling<SOInvoice.pMInstanceID>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(SOInvoice.pMInstanceID).Name)))
                        {
                            throw new PXRowPersistingException(typeof(SOInvoice.pMInstanceID).Name, null, ErrorMessages.FieldIsEmpty, typeof(SOInvoice.pMInstanceID).Name);
                        }
                    }
                    else
                    {
                        
                        CA.PaymentMethod pm = PXSelect<CA.PaymentMethod, Where<CA.PaymentMethod.paymentMethodID, Equal<Required<CA.PaymentMethod.paymentMethodID>>>>.Select(this, doc.PaymentMethodID);
                        bool pmInstanceRequired = (pm.IsAccountNumberRequired == true);
                        if (pmInstanceRequired && doc.PMInstanceID == null)
                        {
                            if (sender.RaiseExceptionHandling<SOInvoice.pMInstanceID>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(SOInvoice.pMInstanceID).Name)))
                            {
                                throw new PXRowPersistingException(typeof(SOInvoice.pMInstanceID).Name, null, ErrorMessages.FieldIsEmpty, typeof(SOInvoice.pMInstanceID).Name);
                            }
                        }
                    }
				}

				bool isCashSale = (doc.DocType == AR.ARDocType.CashSale) || (doc.DocType == AR.ARDocType.CashReturn);
                if (isCashSale && SODocument.GetValueExt<SOInvoice.cashAccountID>((SOInvoice)e.Row) == null)
				{
					if (sender.RaiseExceptionHandling<SOInvoice.cashAccountID>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(SOInvoice.cashAccountID).Name)))
					{
						throw new PXRowPersistingException(typeof(SOInvoice.cashAccountID).Name, null, ErrorMessages.FieldIsEmpty, typeof(SOInvoice.cashAccountID).Name);
					}
				}

				object acctcd;

				if ((acctcd = SODocument.GetValueExt<SOInvoice.cashAccountID>((SOInvoice)e.Row)) != null && sender.GetValue<SOInvoice.cashAccountID>(e.Row) == null)
				{
					sender.RaiseExceptionHandling<SOInvoice.cashAccountID>(e.Row, null, null);
					sender.SetValueExt<SOInvoice.cashAccountID>(e.Row, acctcd is PXFieldState ? ((PXFieldState)acctcd).Value : acctcd);
				}

				//if (doc.PMInstanceID != null && string.IsNullOrEmpty(doc.ExtRefNbr))
				//{
				//    if (sender.RaiseExceptionHandling<SOInvoice.extRefNbr>(e.Row, null, new PXSetPropertyException(ErrorMessages.FieldIsEmpty, typeof(SOInvoice.extRefNbr).Name)))
				//    {
				//        throw new PXRowPersistingException(typeof(SOInvoice.extRefNbr).Name, null, ErrorMessages.FieldIsEmpty, typeof(SOInvoice.extRefNbr).Name);
				//    }
				//}
			}
		}