Ejemplo n.º 1
0
        protected virtual void BatchSelection_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            BatchSelection batch = (BatchSelection)e.Row;

            if (batch != null && !String.IsNullOrWhiteSpace(batch.Module) && !String.IsNullOrWhiteSpace(batch.BatchNbr))
            {
                batch = PXSelectReadonly <BatchSelection,
                                          Where <BatchSelection.module, Equal <Required <BatchSelection.module> >,
                                                 And <BatchSelection.batchNbr, Equal <Required <BatchSelection.batchNbr> > > > >
                        .Select(this, batch.Module, batch.BatchNbr);

                PXSelectorAttribute selectorAttr = (PXSelectorAttribute)sender.GetAttributesReadonly <BatchSelection.batchNbr>(batch).Find(
                    (PXEventSubscriberAttribute attr) => { return(attr is PXSelectorAttribute); });

                BqlCommand selectorSearch = selectorAttr.GetSelect();

                if (batch != null && selectorSearch.Meet(sender, batch))
                {
                    Batch_Detail.Delete(batch);
                    Batch_Detail.Update(batch);
                }
                else
                {
                    batch = (BatchSelection)e.Row;
                    sender.RaiseExceptionHandling <BatchSelection.batchNbr>(batch, batch.BatchNbr, new PXSetPropertyException(Messages.BatchNbrNotValid));
                    Batch_Detail.Delete(batch);
                }
            }
        }