public override IEnumerable MultipleDelete(PXAdapter adapter)
        {
            Survey current = base.primaryCache.Current as Survey;

            if (current == null)
            {
                return(adapter.Get());
            }
            if (current == null || current.SurveyID == null || base.primaryCache.GetStatus(current) == PXEntryStatus.Inserted)
            {
                return(adapter.Get());
            }
            List <SurveyMember> cRCampaignMembers = new List <SurveyMember>();
            PXCache             item = _Graph.Caches[typeof(SurveyMember)];

            foreach (SurveyMember cRCampaignMember in ((IEnumerable <SurveyMember>)item.Updated).Concat <SurveyMember>((IEnumerable <SurveyMember>)item.Inserted))
            {
                bool?selected = cRCampaignMember.Selected;
                if (!(selected.GetValueOrDefault() & selected.HasValue))
                {
                    continue;
                }
                cRCampaignMembers.Add(cRCampaignMember);
            }
            if (!cRCampaignMembers.Any <SurveyMember>() && item.Current != null)
            {
                cRCampaignMembers.Add((SurveyMember)item.Current);
            }
            foreach (SurveyMember cRCampaignMember1 in cRCampaignMembers)
            {
                item.Delete(cRCampaignMember1);
            }
            return(adapter.Get());
        }
Пример #2
0
        public override void RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            if (_IsIntegrityCheck == false)
            {
                if ((e.Operation & PXDBOperation.Command) != PXDBOperation.Delete)
                {
                    object  key   = sender.GetValue(e.Row, _FieldOrdinal);
                    PXCache cache = sender.Graph.Caches[typeof(CATran)];
                    CATran  info  = null;
                    if (key != null)
                    {
                        info = PXSelect <CATran, Where <CATran.tranID, Equal <Required <CATran.tranID> > > > .Select(sender.Graph, key);

                        if (info == null)
                        {
                            key = null;
                            sender.SetValue(e.Row, _FieldOrdinal, null);
                        }
                    }
                    if (info != null && !IsCreationNeeded((CADeposit)e.Row))
                    {
                        cache.Delete(info);
                        cache.PersistDeleted(info);
                    }
                }
                base.RowPersisting(sender, e);
            }
        }
        public virtual void loadTemplateColumnsSS()
        {
            PMSetup pmSetupRow = this.Base.Setup.Current;

            if (pmSetupRow == null)
            {
                throw new PXException(SmartsheetConstants.Messages.ERROR_SETUP);
            }

            PXCache <PMSSMapping> mappingCache = this.Base.Caches <PMSSMapping>();

            if (MappingSetup.Select().Count() == 0)
            {
                InsertTemplate(mappingCache);
            }
            else
            {
                WebDialogResult result = this.Base.Setup.View.Ask(this.Base.Setup.Current, SmartsheetConstants.Messages.CONFIRM_HEADER, SmartsheetConstants.Messages.CONFIRM_RELOAD_VALUES, MessageButtons.YesNoCancel, MessageIcon.Warning);

                if (result == WebDialogResult.Yes)
                {
                    foreach (PMSSMapping item in MappingSetup.Select())
                    {
                        mappingCache.Delete(item);
                    }
                    mappingCache.Persist(PXDBOperation.Delete);
                    InsertTemplate(mappingCache);
                }
            }
        }
Пример #4
0
 public static IEnumerable <object> DeleteAll(this PXCache cache, IEnumerable <object> items)
 {
     items = items.ToList();
     foreach (var item in items)
     {
         cache.Delete(item);
     }
     return(items);
 }
Пример #5
0
        public static object StrictDelete(this PXCache cache, object item)
        {
            object        res        = cache.Delete(item);
            PXEntryStatus itemStatus = cache.GetStatus(item);

            if (itemStatus != PXEntryStatus.Deleted && itemStatus != PXEntryStatus.InsertedDeleted)
            {
                throw new Exception(string.Format("Cant delete item {0} from cache", item.GetType()));
            }
            return(res);
        }
        public static bool TryAggregateToFirstSuitableTran(PXCache sender, GLTran tran, IEnumerable <GLTran> summaryTrans)
        {
            foreach (GLTran summ_tran in summaryTrans)
            {
                PXParentAttribute.SetParent(sender, summ_tran, typeof(Batch), sender.Graph.Caches[typeof(Batch)].Current);

                GLTran copy_tran = PXCache <GLTran> .CreateCopy(summ_tran);

                copy_tran.CuryCreditAmt += tran.CuryCreditAmt;
                copy_tran.CreditAmt     += tran.CreditAmt;
                copy_tran.CuryDebitAmt  += tran.CuryDebitAmt;
                copy_tran.DebitAmt      += tran.DebitAmt;

                if (tran.ZeroPost == false)
                {
                    copy_tran.ZeroPost = false;
                }

                if ((copy_tran.CuryDebitAmt - copy_tran.CuryCreditAmt) > 0m && (copy_tran.DebitAmt - copy_tran.CreditAmt) < 0m ||
                    (copy_tran.CuryDebitAmt - copy_tran.CuryCreditAmt) < 0m && (copy_tran.DebitAmt - copy_tran.CreditAmt) > 0m)
                {
                    continue;
                }

                PostGraph.NormalizeAmounts(copy_tran);

                if (copy_tran.CuryDebitAmt == 0m &&
                    copy_tran.CuryCreditAmt == 0m &&
                    copy_tran.DebitAmt == 0m &&
                    copy_tran.CreditAmt == 0m &&
                    copy_tran.ZeroPost != true)
                {
                    sender.Delete(copy_tran);
                }
                else
                {
                    if (!object.Equals(copy_tran.TranDesc, tran.TranDesc))
                    {
                        copy_tran.TranDesc = Messages.SummaryTranDesc;
                    }

                    copy_tran.Qty         = 0m;
                    copy_tran.UOM         = null;
                    copy_tran.InventoryID = null;
                    copy_tran.TranLineNbr = null;

                    sender.Update(copy_tran);
                }
                return(true);
            }
            return(false);
        }
Пример #7
0
 private void UpdateCacheRecord(PXCache sender, CSAttributeGroup cSAttributeGroup, PXDBOperation operation)
 {
     if (operation == PXDBOperation.Insert)
     {
         sender.Insert(cSAttributeGroup);
     }
     else if (operation == PXDBOperation.Update)
     {
         sender.Update(cSAttributeGroup);
     }
     else if (operation == PXDBOperation.Delete)
     {
         sender.Delete(cSAttributeGroup);
     }
 }
        public void Correct(TInstance leaveInstance, ICollection <TInstance> deletingInstances)
        {
            PXCache cache = Graph.Caches[typeof(TRefItem)];

            // Move
            foreach (TRefItem item in RefItemsForAction(leaveInstance, deletingInstances, false))
            {
                UpdateItem(cache, leaveInstance, item);
                cache.Update(item);
            }
            // Delete
            foreach (TRefItem item in RefItemsForAction(leaveInstance, deletingInstances, true))
            {
                cache.Delete(item);
            }
        }
Пример #9
0
        public virtual void RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            if (sender.Graph.Views.Caches.Contains(typeof(CATran)))
            {
                object  key   = sender.GetValue(e.Row, _FieldOrdinal);
                PXCache cache = sender.Graph.Caches[typeof(CATran)];
                if (key != null)
                {
                    CATran info = new CATran {
                        TranID = (long?)key
                    };
                    cache.Delete(info);

                    sender.SetValue(e.Row, _FieldOrdinal, null);
                }
            }
        }
        protected virtual void Vendor_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            if (e.Row != null)
            {
                Vendor vend = PXSelectorAttribute.Select <Vendor.acctCD>(sender, e.Row) as Vendor;
                if (vend != null)
                {
                    vend.Included = true;
                    PXCache <Vendor> .RestoreCopy((Vendor)e.Row, vend);

                    sender.SetStatus(e.Row, PXEntryStatus.Updated);
                }
                else
                {
                    sender.Delete(e.Row);
                }
            }
        }
Пример #11
0
        protected virtual void Customer_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            if (e.Row != null)
            {
                Customer cust = PXSelectorAttribute.Select <Customer.acctCD>(sender, e.Row) as Customer;
                if (cust != null)
                {
                    cust.Included = true;
                    PXCache <Customer> .RestoreCopy((Customer)e.Row, cust);

                    sender.SetStatus(e.Row, PXEntryStatus.Updated);
                }
                else
                {
                    sender.Delete(e.Row);
                }
            }
        }
Пример #12
0
        protected virtual void InventoryItem_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
        {
            if (e.Row != null)
            {
                InventoryItem item = PXSelectorAttribute.Select <InventoryItem.inventoryCD>(sender, e.Row) as InventoryItem;
                if (item != null)
                {
                    item.Included = true;
                    PXCache <InventoryItem> .RestoreCopy((InventoryItem)e.Row, item);

                    sender.SetStatus(e.Row, PXEntryStatus.Updated);
                }
                else
                {
                    sender.Delete(e.Row);
                }
            }
        }
        public override void Parent_RowUpdated(PXCache sender, PXRowUpdatedEventArgs e)
        {
            base.Parent_RowUpdated(sender, e);

            if (!sender.ObjectsEqual <POOrder.status, POOrder.cancelled>(e.Row, e.OldRow) ||
                //There are two graphs when automation step with notification is getting applied. One of them (the one made by automation) will be
                //persisted, while another one is only displayed on the screen. Due to cache sharing and because of automatic screen refresh
                //we will get the same Status in e.Row and e.OldRow while in fact they are different (example - transition from NL Pending Email to NL Open step)
                (sender.Graph.UnattendedMode && (sender.Graph.AutomationStep != sender.Graph.AutomationStepOriginal)))
            {
                POOrder order     = (POOrder)e.Row;
                PXCache plancache = sender.Graph.Caches[typeof(INItemPlan)];
                bool    Cancelled = (bool?)sender.GetValue <POOrder.cancelled>(e.Row) == true;

                foreach (INItemPlan plan in PXSelect <INItemPlan, Where <INItemPlan.refNoteID, Equal <Current <POOrder.noteID> > > > .Select(sender.Graph))
                {
                    if (Cancelled)
                    {
                        plancache.Delete(plan);
                    }
                    else
                    {
                        INItemPlan copy = PXCache <INItemPlan> .CreateCopy(plan);

                        bool   IsOnHold = IsOrderOnHold(order);
                        string newPlanType;
                        if (TryCalcPlanType(plan, IsOnHold, out newPlanType))
                        {
                            plan.PlanType = newPlanType;
                        }

                        plan.Hold = IsOnHold;

                        if (!string.Equals(copy.PlanType, plan.PlanType))
                        {
                            plancache.RaiseRowUpdated(plan, copy);
                        }

                        plancache.MarkUpdated(plan);
                    }
                }
            }
        }
Пример #14
0
            protected virtual void UpdateUnassigned(PXCache cache, SOPickerListEntry assigned, decimal?deltaQty)
            {
                SOPickerListEntry unassigned = deltaQty > 0 && GetLotSerClass(cache.Graph, assigned.InventoryID).LotSerTrack == INLotSerTrack.SerialNumbered
                                        ? null
                                        :       SelectFrom <SOPickerListEntry> .
                                               Where <
                    isUnassigned.IsEqual <True> .
                    And <worksheetNbr.IsEqual <worksheetNbr.FromCurrent> > .
                    And <pickerNbr.IsEqual <pickerNbr.FromCurrent> > .
                    And <inventoryID.IsEqual <inventoryID.FromCurrent> > .
                    And <subItemID.IsEqual <subItemID.FromCurrent> > .
                    And <locationID.IsEqual <locationID.FromCurrent> > .
                    And <orderLineUOM.IsEqual <orderLineUOM.FromCurrent> > > .
                                               View.SelectSingleBound(cache.Graph, new[] { assigned }).TopFirst;

                if (unassigned == null)
                {
                    unassigned = PXCache <SOPickerListEntry> .CreateCopy(assigned);

                    unassigned.EntryNbr      = null;
                    unassigned.LotSerialNbr  = "";
                    unassigned.ExpireDate    = null;
                    unassigned.Qty           = 0;
                    unassigned.BaseQty       = 0;
                    unassigned.PickedQty     = 0;
                    unassigned.BasePickedQty = 0;
                    unassigned.IsUnassigned  = true;

                    unassigned = (SOPickerListEntry)cache.Insert(unassigned);
                }

                unassigned.Qty += deltaQty;
                if (unassigned.Qty == 0)
                {
                    unassigned = (SOPickerListEntry)cache.Delete(unassigned);
                }
                else
                {
                    unassigned = (SOPickerListEntry)cache.Update(unassigned);
                }
            }
        public virtual void loadTemplateSS()
        {
            PMSetup pmSetupRow = this.Base.Setup.Current;
            Dictionary <string, string> templateSS          = GetTemplateSS();
            PXCache <PMTemplateListSS>  pmtemplateListCache = this.Base.Caches <PMTemplateListSS>();

            foreach (PMTemplateListSS item in TemplateSetup.Select())
            {
                pmtemplateListCache.Delete(item);
            }

            foreach (var templateRow in templateSS)
            {
                PMTemplateListSS ci = (PMTemplateListSS)pmtemplateListCache.Insert(new PMTemplateListSS
                {
                    TemplateSS      = templateRow.Key.ToString(),
                    TemplateName    = templateRow.Value.ToString(),
                    TemplateDefault = false
                });
            }
        }
        private static CurrencyInfo GetCurrencyInfo(PXGraph graph, string curyRateTypeID, string curyID)
        {
            if (curyID == null)
            {
                curyID = new PXSetup <Company>(graph).Current.BaseCuryID;
            }
            if (curyRateTypeID == null)
            {
                curyRateTypeID = new CMSetupSelect(graph).Current.APRateTypeDflt;
            }

            CurrencyInfo info = new CurrencyInfo();

            info.ModuleCode     = BatchModule.AP;
            info.CuryID         = curyID;
            info.CuryRateTypeID = curyRateTypeID;
            info.CuryInfoID     = null;
            PXCache cache = graph.Caches[typeof(CurrencyInfo)];

            info = (CurrencyInfo)cache.Insert(info);
            cache.Delete(info);
            return(info);
        }
Пример #17
0
        private void UpdateZones(PXCache sender, object OldRow, object NewRow)
        {
            if (OldRow != null && (NewRow == null || (bool)((TaxReportLine)NewRow).TempLine == false))
            {
                foreach (TaxReportLine child in PXSelect <TaxReportLine, Where <TaxReportLine.vendorID, Equal <Required <TaxReportLine.vendorID> >, And <TaxReportLine.tempLineNbr, Equal <Required <TaxReportLine.tempLineNbr> > > > > .Select(this, ((TaxReportLine)OldRow).VendorID, ((TaxReportLine)OldRow).LineNbr))
                {
                    sender.Delete(child);
                }
            }

            if (NewRow != null && (bool)((TaxReportLine)NewRow).TempLine == true && (OldRow == null || ((TaxReportLine)NewRow).TempLine != ((TaxReportLine)OldRow).TempLine))
            {
                ((TaxReportLine)NewRow).TaxZoneID = null;

                if (string.IsNullOrEmpty(((TaxReportLine)NewRow).Descr) || ((TaxReportLine)NewRow).Descr.IndexOf(TAG_TAXZONE, StringComparison.OrdinalIgnoreCase) < 0)
                {
                    ((TaxReportLine)NewRow).Descr += ' ' + TAG_TAXZONE;
                }

                foreach (TaxZone zone in PXSelect <TaxZone> .Select(this))
                {
                    TaxReportLine child = PXCache <TaxReportLine> .CreateCopy((TaxReportLine)NewRow);

                    child.TempLineNbr = child.LineNbr;
                    child.TaxZoneID   = zone.TaxZoneID;

                    if (string.IsNullOrEmpty(child.Descr) == false)
                    {
                        int fid;
                        if ((fid = child.Descr.IndexOf(TAG_TAXZONE, StringComparison.OrdinalIgnoreCase)) >= 0)
                        {
                            child.Descr = child.Descr.Remove(fid, TAG_TAXZONE.Length).Insert(fid, child.TaxZoneID);
                        }
                    }

                    child.LineNbr  = null;
                    child.TempLine = false;
                    sender.Insert(child);
                }
            }

            if (NewRow != null && OldRow != null && ((TaxReportLine)NewRow).TempLine == ((TaxReportLine)OldRow).TempLine == true)
            {
                foreach (TaxReportLine child in PXSelect <TaxReportLine, Where <TaxReportLine.vendorID, Equal <Required <TaxReportLine.vendorID> >, And <TaxReportLine.tempLineNbr, Equal <Required <TaxReportLine.tempLineNbr> > > > > .Select(this, ((TaxReportLine)OldRow).VendorID, ((TaxReportLine)OldRow).LineNbr))
                {
                    child.Descr = ((TaxReportLine)NewRow).Descr;

                    if (string.IsNullOrEmpty(child.Descr) == false)
                    {
                        int fid;
                        if ((fid = child.Descr.IndexOf(TAG_TAXZONE, StringComparison.OrdinalIgnoreCase)) >= 0)
                        {
                            child.Descr = child.Descr.Remove(fid, TAG_TAXZONE.Length).Insert(fid, child.TaxZoneID);
                        }
                    }

                    child.NetTax   = ((TaxReportLine)NewRow).NetTax;
                    child.LineType = ((TaxReportLine)NewRow).LineType;
                    child.LineMult = ((TaxReportLine)NewRow).LineMult;
                    sender.Update(child);
                }
            }
        }
Пример #18
0
        public virtual void RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            object  key   = sender.GetValue(e.Row, _FieldOrdinal);
            PXCache cache = sender.Graph.Caches[typeof(CATran)];
            CATran  info  = null;

            if (key != null)
            {
                //do not read cached record in release processes
                if ((info = PXSelectReadonly <CATran, Where <CATran.tranID, Equal <Required <CATran.tranID> > > > .Select(sender.Graph, key)) != null)
                {
                    CATran cached = (CATran)cache.Locate(info);
                    if (cached != null)
                    {
                        if ((cached.OrigModule != null && info.OrigModule != null && cached.OrigModule != info.OrigModule) ||
                            (cached.OrigRefNbr != null && info.OrigRefNbr != null && cached.OrigRefNbr != info.OrigRefNbr) ||
                            (cached.OrigTranType != null && info.OrigTranType != null && cached.OrigTranType != info.OrigTranType))
                        {
                            // TO Be removed after solving CATran issue (check JIRA item AC-57875 for details)
                            throw new PXException(Messages.CouldNotInsertCATran);
                        }
                        if (cache.GetStatus(cached) == PXEntryStatus.Notchanged)
                        {
                            PXCache <CATran> .RestoreCopy(cached, info);
                        }
                        info = cached;
                    }
                    else
                    {
                        cache.SetStatus(info, PXEntryStatus.Notchanged);
                    }
                }

                if ((long)key < 0L && info == null)
                {
                    info        = new CATran();
                    info.TranID = (long)key;
                    info        = (CATran)cache.Locate(info);
                }

                if (info == null)
                {
                    key = null;
                    sender.SetValue(e.Row, _FieldOrdinal, null);
                }
            }

            if ((e.Operation & PXDBOperation.Command) == PXDBOperation.Delete)
            {
                if (info != null)
                {
                    cache.Delete(info);
                    cache.PersistDeleted(info);
                }
            }
            else if (info == null)
            {
                if (!this.NeedPreventCashTransactionCreation(sender, e.Row))
                {
                    info = DefaultValues(sender, new CATran(), e.Row);

                    if (info != null)
                    {
                        info = (CATran)cache.Insert(info);
                        if (!(info.TranID < 0L))
                        {
                            throw new PXException(Messages.CouldNotInsertCATran);
                        }

                        // TO Be removed after solving CATran issue (check JIRA item AC-57875 for details)
                        sender.SetValue(e.Row, _FieldOrdinal, info.TranID);
                        _KeyToAbort = info.TranID;
                        cache.PersistInserted(info);
                        long id = info.TranID ?? 0;
                        if (id == 0 || id < 0)
                        {
                            throw new PXException(Messages.CATranNotSaved, sender.GetItemType().Name);
                        }
                        sender.SetValue(e.Row, _FieldOrdinal, id);
                        info.TranID = id;
                        cache.Normalize();
                    }
                }
            }
            else if (info.TranID < 0L)
            {
                info = DefaultValues(sender, PXCache <CATran> .CreateCopy(info), e.Row);
                if (info != null)
                {
                    info = (CATran)cache.Update(info);

                    sender.SetValue(e.Row, _FieldOrdinal, info.TranID);
                    _KeyToAbort = info.TranID;
                    cache.PersistInserted(info);
                    long id = info.TranID ?? 0;
                    if (id == 0 || id < 0)
                    {
                        throw new PXException(Messages.CATranNotSaved, sender.GetItemType().Name);
                    }
                    sender.SetValue(e.Row, _FieldOrdinal, id);
                    info.TranID = id;
                    cache.Normalize();
                }
            }
            else
            {
                CATran copy = PXCache <CATran> .CreateCopy(info);

                copy = DefaultValues(sender, copy, e.Row);
                if (copy != null)
                {
                    if ((copy.OrigModule != null && info.OrigModule != null && copy.OrigModule != info.OrigModule) ||
                        (copy.OrigRefNbr != null && info.OrigRefNbr != null && copy.OrigRefNbr != info.OrigRefNbr) ||
                        (copy.OrigTranType != null && info.OrigTranType != null && copy.OrigTranType != info.OrigTranType))
                    {
                        // TO Be removed after solving CATran issue (check JIRA item AC-57875 for details)
                        throw new PXException(Messages.CouldNotInsertCATran);
                    }
                    info = (CATran)cache.Update(copy);
                    //to avoid another process updated DefaultValues will return null for Released docs, except for GLTran
                    cache.PersistUpdated(info);
                }
                //JournalEntry is usually persisted prior to ReleaseGraph to obtain BatchNbr reference, read info should contain set Released flag
                else if (info.Released == false)
                {
                    key = null;
                    sender.SetValue(e.Row, _FieldOrdinal, null);

                    cache.Delete(info);
                }
            }
            foreach (CATran toDelete in cache.Deleted)
            {
                cache.PersistDeleted(toDelete);
            }
        }
Пример #19
0
		protected virtual void Vendor_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
		{
			if (e.Row != null)
			{
				Vendor vend = PXSelectorAttribute.Select<Vendor.acctCD>(sender, e.Row) as Vendor;
				if (vend != null)
				{
					vend.Included = true;
					PXCache<Vendor>.RestoreCopy((Vendor)e.Row, vend);
					sender.SetStatus(e.Row, PXEntryStatus.Updated);
				}
				else
				{
					sender.Delete(e.Row);
				}
			}
		}
        private void UpdateZones(PXCache sender, object OldRow, object NewRow)
        {
            TaxReportLine oldRow = OldRow as TaxReportLine;
            TaxReportLine newRow = NewRow as TaxReportLine;

            if (oldRow != null && (newRow == null || newRow.TempLine == false))
            {
                if (string.IsNullOrEmpty(newRow?.Descr) == false)
                {
                    int fid;
                    if ((fid = newRow.Descr.IndexOf(TAG_TAXZONE, StringComparison.OrdinalIgnoreCase)) >= 0)
                    {
                        newRow.Descr = newRow.Descr.Remove(fid, TAG_TAXZONE.Length).TrimEnd(' ');
                    }
                }

                foreach (TaxReportLine child in PXSelect <TaxReportLine,
                                                          Where <TaxReportLine.vendorID, Equal <Required <TaxReportLine.vendorID> >,
                                                                 And <TaxReportLine.tempLineNbr, Equal <Required <TaxReportLine.tempLineNbr> > > > >
                         .Select(this, oldRow.VendorID, oldRow.LineNbr))
                {
                    sender.Delete(child);
                }
            }

            if (newRow?.TempLine == true && newRow.TempLine != oldRow?.TempLine)
            {
                newRow.TaxZoneID = null;

                if (string.IsNullOrEmpty(newRow.Descr) ||
                    (newRow.Descr.IndexOf(TAG_TAXZONE, StringComparison.OrdinalIgnoreCase) < 0))
                {
                    newRow.Descr += ' ' + TAG_TAXZONE;
                }

                foreach (TaxZone zone in PXSelect <TaxZone> .Select(this))
                {
                    TaxReportLine child = CreateChildLine(newRow, zone);
                    sender.Insert(child);
                }
            }

            if (newRow?.TempLine == true && oldRow?.TempLine == true)
            {
                foreach (TaxReportLine child in PXSelect <TaxReportLine,
                                                          Where <TaxReportLine.vendorID, Equal <Required <TaxReportLine.vendorID> >,
                                                                 And <TaxReportLine.tempLineNbr, Equal <Required <TaxReportLine.tempLineNbr> > > > >
                         .Select(this, oldRow.VendorID, oldRow.LineNbr))
                {
                    child.Descr = newRow.Descr;

                    if (string.IsNullOrEmpty(child.Descr) == false)
                    {
                        int fid;
                        if ((fid = child.Descr.IndexOf(TAG_TAXZONE, StringComparison.OrdinalIgnoreCase)) >= 0)
                        {
                            child.Descr = child.Descr.Remove(fid, TAG_TAXZONE.Length).Insert(fid, child.TaxZoneID);
                        }
                    }

                    child.NetTax   = newRow.NetTax;
                    child.LineType = newRow.LineType;
                    child.LineMult = newRow.LineMult;
                    sender.Update(child);
                }
            }
        }
        protected virtual decimal ConvertAmt(string from, string to, string rateType, DateTime effectiveDate, decimal amount)
        {
            if (from == to)
            {
                return(amount);
            }

            decimal result = amount;

            PXCache curyCache = CarrierRatesDummyCuryInfo.Cache;

            using (var rs = new ReadOnlyScope(curyCache))
            {
                if (from == Base.Accessinfo.BaseCuryID)
                {
                    CurrencyInfo ci = new CurrencyInfo();
                    ci.CuryRateTypeID = rateType;
                    ci.CuryID         = to;
                    ci = (CurrencyInfo)curyCache.Insert(ci);
                    ci.SetCuryEffDate(curyCache, effectiveDate);
                    curyCache.Update(ci);
                    PXCurrencyAttribute.CuryConvCury(curyCache, ci, amount, out result);
                    curyCache.Delete(ci);
                }
                else if (to == Base.Accessinfo.BaseCuryID)
                {
                    CurrencyInfo ci = new CurrencyInfo();
                    ci.CuryRateTypeID = rateType;
                    ci.CuryID         = from;
                    ci = (CurrencyInfo)curyCache.Insert(ci);
                    ci.SetCuryEffDate(curyCache, effectiveDate);
                    curyCache.Update(ci);
                    PXCurrencyAttribute.CuryConvBase(curyCache, ci, amount, out result);
                    curyCache.Delete(ci);
                }
                else
                {
                    CurrencyInfo ciFrom = new CurrencyInfo();
                    ciFrom.CuryRateTypeID = rateType;
                    ciFrom.CuryID         = from;
                    ciFrom = (CurrencyInfo)curyCache.Insert(ciFrom);
                    ciFrom.SetCuryEffDate(curyCache, effectiveDate);
                    curyCache.Update(ciFrom);
                    decimal inBase;
                    PXCurrencyAttribute.CuryConvBase(curyCache, ciFrom, amount, out inBase, true);

                    CurrencyInfo ciTo = new CurrencyInfo();
                    ciTo.CuryRateTypeID = rateType;
                    ciTo.CuryID         = to;
                    ciTo = (CurrencyInfo)curyCache.Insert(ciTo);
                    ciTo.SetCuryEffDate(curyCache, effectiveDate);
                    curyCache.Update(ciFrom);
                    PXCurrencyAttribute.CuryConvCury(curyCache, ciTo, inBase, out result, true);

                    curyCache.Delete(ciFrom);
                    curyCache.Delete(ciTo);
                }
            }

            return(result);
        }
Пример #22
0
		protected virtual void Customer_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
		{
			if (e.Row != null)
			{
				Customer cust = PXSelectorAttribute.Select<Customer.acctCD>(sender, e.Row) as Customer;
				if (cust != null)
				{
					cust.Included = true;
					PXCache<Customer>.RestoreCopy((Customer)e.Row, cust);
					sender.SetStatus(e.Row, PXEntryStatus.Updated);
				}
				else
				{
					sender.Delete(e.Row);
				}
			}
		}
Пример #23
0
		protected virtual void InventoryItem_RowInserted(PXCache sender, PXRowInsertedEventArgs e)
		{
			if (e.Row != null)
			{
				InventoryItem item = PXSelectorAttribute.Select<InventoryItem.inventoryCD>(sender, e.Row) as InventoryItem;
				if (item != null)
				{
					item.Included = true;
					PXCache<InventoryItem>.RestoreCopy((InventoryItem)e.Row, item);
					sender.SetStatus(e.Row, PXEntryStatus.Updated);
				}
				else
				{
					sender.Delete(e.Row);
				}
			}
		}