public virtual IEnumerable ConverToCustomer(PXAdapter adapter)
        {
            BAccount bacct = BAccount.Current;

            if (bacct != null && (bacct.Type == BAccountType.ProspectType || bacct.Type == BAccountType.VendorType))
            {
                Save.Press();

                AR.CustomerMaint editingBO = PXGraph.CreateInstance <PX.Objects.AR.CustomerMaint>();
                AR.Customer      customer  = (AR.Customer)editingBO.BAccount.Cache.Extend <BAccount>(bacct);
                editingBO.BAccount.Current = customer;
                customer.Type = (bacct.Type == BAccountType.ProspectType) ? BAccountType.CustomerType : BAccountType.CombinedType;
                LocationExtAddress defLocation = editingBO.DefLocation.Select();
                editingBO.DefLocation.Cache.RaiseRowSelected(defLocation);
                string locationType = (bacct.Type == BAccountType.ProspectType) ? LocTypeList.CustomerLoc : LocTypeList.CombinedLoc;
                editingBO.InitCustomerLocation(defLocation, locationType);
                defLocation = editingBO.DefLocation.Update(defLocation);
                foreach (Location iLoc in editingBO.IntLocations.Select())
                {
                    if (iLoc.LocationID != defLocation.LocationID)
                    {
                        editingBO.InitCustomerLocation(iLoc, locationType);
                        editingBO.IntLocations.Update(iLoc);
                    }
                }
                throw new PXRedirectRequiredException(editingBO, "Edit Customer");
            }
            return(adapter.Get());
        }
        protected virtual void OnPMDetailInventoryIDFieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            PMDetail row = (PMDetail)e.Row;

            if (row == null)
            {
                return;
            }

            InventoryItem item = PXSelect <InventoryItem, Where <InventoryItem.inventoryID, Equal <Required <InventoryItem.inventoryID> > > > .Select(this, row.InventoryID);

            if (item != null)
            {
                row.UOM         = item.SalesUnit;
                row.ItemFee     = item.BasePrice;
                row.Description = item.Descr;
                PMProject project = PXSelectorAttribute.Select <PMTran.projectID>(sender, e.Row) as PMProject;

                if (project != null && project.CustomerID != null)
                {
                    AR.Customer customer = PXSelectReadonly <AR.Customer, Where <AR.Customer.bAccountID, Equal <Required <AR.Customer.bAccountID> > > > .Select(this, project.CustomerID);

                    if (!string.IsNullOrEmpty(customer?.LocaleName))
                    {
                        row.Description = PXDBLocalizableStringAttribute.GetTranslation(Caches[typeof(InventoryItem)], item, nameof(InventoryItem.Descr), customer.LocaleName);
                    }
                }
                sender.SetDefaultExt <PMDetail.curyItemFee>(e.Row);
            }
        }
Ejemplo n.º 3
0
        public void NavigateToResult(int bacctId)
        {
            BAccount acct = SWSelect <BAccount, Where <BAccount.bAccountID, Equal <Required <BAccount.bAccountID> > > > .SelectWindowed(graph, 0, 1, bacctId);

            if (acct == null)
            {
                return;
            }

            if (acct.Type == "CU")
            {
                AR.Customer cust = SWSelect <AR.Customer, Where <AR.Customer.bAccountID, Equal <Required <BAccount.bAccountID> > > > .SelectWindowed(this.graph, 0, 1, acct.BAccountID);

                SWRedirectHelper.TryRedirect(graph.Caches[typeof(SW.Objects.AR.Customer)], cust, "");
            }
            else
            {
                AP.Vendor vend = SWSelect <AP.Vendor, Where <AP.Vendor.bAccountID, Equal <Required <BAccount.bAccountID> > > > .SelectWindowed(this.graph, 0, 1, acct.BAccountID);

                SWRedirectHelper.TryRedirect(graph.Caches[typeof(SW.Objects.AP.Vendor)], vend, "");
            }
        }