Пример #1
0
        protected virtual void INSite_RowSelected(PXCache sender, PXRowSelectedEventArgs e)
        {
            INAcctSubDefault.Required(sender, e);
            INSite row = (INSite)e.Row;

            if (row != null)
            {
                viewRestrictionGroups.SetEnabled(row.SiteCD != null);

                foreach (INLocation deletedLocation in location.Cache.Cached)
                {
                    PXEntryStatus rowStatus = location.Cache.GetStatus(deletedLocation);
                    if (rowStatus == PXEntryStatus.Deleted || rowStatus == PXEntryStatus.InsertedDeleted)
                    {
                        if (deletedLocation.LocationID == row.ReceiptLocationID)
                        {
                            sender.RaiseExceptionHandling <INSite.receiptLocationID>(row, deletedLocation.LocationCD, new PXSetPropertyException(ErrorMessages.ForeignRecordDeleted));
                        }
                        if (deletedLocation.LocationID == row.ShipLocationID)
                        {
                            sender.RaiseExceptionHandling <INSite.shipLocationID>(row, deletedLocation.LocationCD, new PXSetPropertyException(ErrorMessages.ForeignRecordDeleted));
                        }
                        if (deletedLocation.LocationID == row.ReturnLocationID)
                        {
                            sender.RaiseExceptionHandling <INSite.returnLocationID>(row, deletedLocation.LocationCD, new PXSetPropertyException(ErrorMessages.ForeignRecordDeleted));
                        }
                        if (deletedLocation.LocationID == row.DropShipLocationID)
                        {
                            sender.RaiseExceptionHandling <INSite.dropShipLocationID>(row, deletedLocation.LocationCD, new PXSetPropertyException(ErrorMessages.ForeignRecordDeleted));
                        }
                    }
                }
            }
        }
        public override void RowPersisting(PXCache sender, PXRowPersistingEventArgs e)
        {
            object key;

            if (IsTopLevel && (key = sender.GetValue(e.Row, FieldName)) != null)
            {
                PXCache      cache = sender.Graph.Caches[typeof(CurrencyInfo)];
                CurrencyInfo info  = (CurrencyInfo)cache.Locate(new CurrencyInfo {
                    CuryInfoID = Convert.ToInt64(key)
                });
                PXEntryStatus status = PXEntryStatus.Notchanged;
                if (info != null && ((status = cache.GetStatus(info)) == PXEntryStatus.Inserted))
                {
                    cache.PersistInserted(info);
                }
                else if (status == PXEntryStatus.Updated)
                {
                    cache.PersistUpdated(info);
                }
                else if (status == PXEntryStatus.Deleted)
                {
                    cache.PersistDeleted(info);
                }
            }
            base.RowPersisting(sender, e);
        }
Пример #3
0
    protected void Page_Load(object sender, EventArgs e)
    {
        T graph = (T)ds.DataGraph;

        this.gridSub         = this.tab.FindControl("gridSub") as PXGrid;
        this.gridAttachments = this.tab.FindControl("gridAttachments") as PXGrid;

        WikiPage curr = (WikiPage)graph.Caches[typeof(WikiPage)].Current;

        if (!this.hasQueryParams && curr != null && !this.Page.IsPostBack && !this.Page.IsCallback)
        {
            this.ds.DataGraph.Clear();
            this.Response.Redirect(this.Request.RawUrl + "?wiki=" + curr.WikiID.GetValueOrDefault().ToString() + "&parent=" + curr.ParentUID.GetValueOrDefault().ToString() + "&name=" + curr.Name);
            return;
        }

        WikiReader reader = PXGraph.CreateInstance <WikiReader>();

        this.edtWikiText = (PXWikiEdit)this.tab.DataControls["edtWikiText"];
        this.edtWikiText.PreviewSettings = new PXWikiSettings(this.Page, reader).Relative;
        this.edtWikiText.FileNamePrefix  = curr == null ? null : curr.Name;
        this.edtWikiText.FileUploaded   += new PXFileUploadEventHandler(editor_FileUploaded);

        graph.GetFileUrl            = Request.GetWebsiteAuthority().GetLeftPart(UriPartial.Authority) + ResolveUrl("~/Frames/GetFile.ashx");
        graph.CurrentAttachmentGuid = PX.Common.GUID.CreateGuid((string)gridAttachments.DataValues["FileID"]).GetValueOrDefault();

        PXEntryStatus recStatus = ds.DataGraph.Caches[typeof(WikiPage)].GetStatus(curr);

        if (recStatus == PXEntryStatus.Deleted || recStatus == PXEntryStatus.Inserted || recStatus == PXEntryStatus.InsertedDeleted)
        {
            edtWikiText.AttachFileEnabled = false;
        }
    }
Пример #4
0
        protected virtual void OrderLine_RowDeleted(PXCache sender, PXRowDeletedEventArgs e)
        {
            OrderLine     line        = (OrderLine)e.Row;
            SalesOrder    order       = Orders.Current;
            PXEntryStatus orderStatus = Orders.Cache.GetStatus(order);
            bool          isDeleted   = orderStatus == PXEntryStatus.InsertedDeleted ||
                                        orderStatus == PXEntryStatus.Deleted;

            if (isDeleted)
            {
                return;
            }
            bool isUpdated = false;

            if (line.LinePrice != null)
            {
                order.LinesTotal -= line.LinePrice;
                isUpdated         = true;
            }
            if (line.TaxAmt != null)
            {
                order.TaxTotal -= line.TaxAmt;
                isUpdated       = true;
            }
            if (isUpdated)
            {
                Orders.Update(order);
            }
        }
        public PXEntryStatus?SetStatus(T value, PXEntryStatus status)
        {
            int free;

            if (this.buckets == null)
            {
                this.Initialize(0);
            }
            int hash = _Cache.GetObjectHashCode(value) & 0x7fffffff;

            for (int i = this.buckets[hash % this.buckets.Length]; i >= 0; i = this.entries[i].next)
            {
                if ((this.entries[i].hashCode == hash) && _Cache.ObjectsEqual(this.entries[i].value, value))
                {
                    if ((status == PXEntryStatus.Deleted || status == PXEntryStatus.Inserted || status == PXEntryStatus.Modified || status == PXEntryStatus.Updated) &&
                        (this.entries[i].status == PXEntryStatus.Held || this.entries[i].status == PXEntryStatus.Notchanged))
                    {
                        this._version++;
                    }
                    PXEntryStatus ret = this.entries[i].status;
                    if (status != PXEntryStatus.Modified || this.entries[i].status == PXEntryStatus.Notchanged || this.entries[i].status == PXEntryStatus.Held)
                    {
                        this.entries[i].status = status != PXEntryStatus.Modified ? status : PXEntryStatus.Updated;
                    }
                    return(ret);
                }
            }
            if (this.freeCount > 0)
            {
                free          = this.freeList;
                this.freeList = this.entries[free].next;
                this.freeCount--;
            }
            else
            {
                if (this.count == this.entries.Length)
                {
                    this.Resize();
                }
                free = this.count;
                this.count++;
            }
            int k = hash % this.buckets.Length;

            this.entries[free].hashCode = hash;
            this.entries[free].next     = this.buckets[k];
            this.entries[free].value    = value;
            this.entries[free].status   = status;
            this.buckets[k]             = free;
            this.version++;
            if (status == PXEntryStatus.Deleted || status == PXEntryStatus.Inserted || status == PXEntryStatus.Modified || status == PXEntryStatus.Updated)
            {
                this._version++;
            }
            return(null);
        }
Пример #6
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);
        }
        protected virtual bool HasTransactions(PaymentTypeInstance aRow)
        {
            PXEntryStatus status = this.PaymentTypeInstance.Cache.GetStatus(aRow);

            if (status == PXEntryStatus.Inserted && status == PXEntryStatus.InsertedDeleted)
            {
                return(false);
            }
            PTInstTran tran = PXSelectReadonly <PTInstTran, Where <PTInstTran.pTInstanceID, Equal <Required <PTInstTran.pTInstanceID> > > > .SelectWindowed(this, 0, 1, aRow.PTInstanceID);

            return(tran != null);
        }
Пример #8
0
 protected virtual void ClearPaymentDetails(IPaymentTypeDetailMaster account, string paymentTypeID, bool clearNewOnly)
 {
     foreach (VendorPaymentMethodDetail it in this.PaymentDetails.Select(account.BAccountID, account.LocationID, paymentTypeID))
     {
         bool doDelete = true;
         if (clearNewOnly)
         {
             PXEntryStatus status = this.PaymentDetails.Cache.GetStatus(it);
             doDelete = (status == PXEntryStatus.Inserted);
         }
         if (doDelete)
         {
             this.PaymentDetails.Delete(it);
         }
     }
 }
        protected virtual void PaymentMethodAccount_RowDeleting(PXCache cache, PXRowDeletingEventArgs e)
        {
            PaymentMethodAccount row    = (PaymentMethodAccount)e.Row;
            PXEntryStatus        status = cache.GetStatus(e.Row);

            if (row.CashAccountID != null && status != PXEntryStatus.Inserted && status != PXEntryStatus.InsertedDeleted)
            {
                CustomerPaymentMethod cpm = PXSelect <CustomerPaymentMethod, Where <CustomerPaymentMethod.paymentMethodID, Equal <Required <CustomerPaymentMethod.paymentMethodID> >,
                                                                                    And <CustomerPaymentMethod.cashAccountID, Equal <Required <CustomerPaymentMethod.cashAccountID> > > > > .SelectWindowed(this, 0, 1, row.PaymentMethodID, row.CashAccountID);

                if (cpm != null)
                {
                    throw new PXException(Messages.PaymentMethodAccountIsInUseAndCantBeDeleted);
                }
            }
        }
        protected override bool startPendingProcess(List <Table> items)
        {
            AUSchedule schedule = PX.Common.PXContext.GetSlot <AUSchedule>();

            if (schedule == null)
            {
                return(base.startPendingProcess(items));
            }

            PXCache cache = _OuterView.Cache;

            cache.IsDirty = false;
            List <Table> list = new List <Table>();

            foreach (Table item in items)
            {
                object sel = cache.GetValue(item, _SelectedField);

                if (sel != null && Convert.ToBoolean(sel))
                {
                    PXEntryStatus status = cache.GetStatus(item);

                    if (status == PXEntryStatus.Inserted ||
                        status == PXEntryStatus.Updated)
                    {
                        list.Add(item);
                    }
                }
            }

            PX.Common.PXContext.SetSlot <AUSchedule>(null);
            AUSchedule scheduleparam = schedule;

            if (_IsInstance)
            {
                ProcessSyncCC(_ProcessDelegate, list, scheduleparam);
            }
            else
            {
                PXLongOperation.StartOperation(_Graph, delegate() { ProcessSyncCC(_ProcessDelegate, list, scheduleparam); });
            }

            schedule = null;
            return(true);
        }
Пример #11
0
        protected virtual void _(Events.RowDeleted <Detail> e)
        {
            Detail        line        = e.Row;
            Document      order       = Documents.Current;
            PXEntryStatus orderStatus = Documents.Cache.GetStatus(order);
            bool          isDeleted   = orderStatus == PXEntryStatus.InsertedDeleted ||
                                        orderStatus == PXEntryStatus.Deleted;

            if (isDeleted)
            {
                return;
            }

            if (line.LinePrice != null)
            {
                var newTotal = order.LinesTotal - line.LinePrice;
                Documents.Cache.SetValue <Document.linesTotal>(order, newTotal);
            }
        }
 internal void Normalize(T item, PXEntryStatus status)
 {
     if (this.count > 0)
     {
         int itemHashCode = -1;
         for (int i = 0; i < this.buckets.Length; i++)
         {
             this.buckets[i] = -1;
         }
         for (int i = 0; i < this.count; i++)
         {
             if (this.entries[i].hashCode >= 0)
             {
                 if (item != null && object.ReferenceEquals(item, this.entries[i].value))
                 {
                     this.entries[i].hashCode = itemHashCode = _Cache.GetObjectHashCode(this.entries[i].value) & 0x7fffffff;
                 }
                 else if (this.entries[i].status == status)
                 {
                     this.entries[i].hashCode = _Cache.GetObjectHashCode(this.entries[i].value) & 0x7fffffff;
                 }
             }
             int j = this.entries[i].hashCode % this.buckets.Length;
             if (j == -1)
             {
                 continue;
             }
             this.entries[i].next = this.buckets[j];
             this.buckets[j]      = i;
         }
         if (item != null && itemHashCode >= 0)
         {
             for (int i = this.buckets[itemHashCode % this.buckets.Length]; i >= 0; i = this.entries[i].next)
             {
                 if ((this.entries[i].hashCode == itemHashCode) && !object.ReferenceEquals(this.entries[i].value, item) && _Cache.ObjectsEqual(this.entries[i].value, item))
                 {
                     throw new PXBadDictinaryException();
                 }
             }
         }
     }
 }
Пример #13
0
        protected virtual void CheckDocumentUpdatedInDb(TPrimary doc)
        {
            PXEntryStatus status = Base.Caches[typeof(TPrimary)].GetStatus(doc);

            if (status == PXEntryStatus.Notchanged)
            {
                EntityHelper entityHelper = new EntityHelper(this.Base);
                object[]     keys         = entityHelper.GetEntityKey(typeof(TPrimary), doc);
                object       storedRow    = entityHelper.GetEntityRow(typeof(TPrimary), keys);
                if (storedRow != null)
                {
                    byte[] ts       = Base.Caches[typeof(TPrimary)].GetValue(doc, "tstamp") as byte[];
                    byte[] storedTs = Base.Caches[typeof(TPrimary)].GetValue(storedRow, "tstamp") as byte[];
                    if (PXDBTimestampAttribute.compareTimestamps(ts, storedTs) < 0)
                    {
                        throw new PXException(ErrorMessages.RecordUpdatedByAnotherProcess, typeof(TPrimary).Name);
                    }
                }
            }
        }
Пример #14
0
        public IEnumerable accounts()
        {
            Dictionary <int, AccountPtr> inCache = new Dictionary <int, AccountPtr>();

            foreach (AccountPtr item in Accounts.Cache.Cached)
            {
                PXEntryStatus status = Accounts.Cache.GetStatus(item);
                inCache.Add(item.AccountID.Value, item);
                if (status == PXEntryStatus.Inserted || status == PXEntryStatus.Updated || status == PXEntryStatus.Notchanged)
                {
                    yield return(item);
                }
            }

            PXSelectBase <Account> select = new PXSelect <Account,
                                                          Where <Account.accountGroupID, Equal <Current <PMAccountGroup.groupID> > > >(this);

            bool isDirty = Accounts.Cache.IsDirty;

            foreach (Account acct in select.Select())
            {
                if (!inCache.ContainsKey(acct.AccountID.Value))
                {
                    AccountPtr ptr = new AccountPtr();
                    ptr.AccountID      = acct.AccountID;
                    ptr.AccountClassID = acct.AccountClassID;
                    ptr.CuryID         = acct.CuryID;
                    ptr.Description    = acct.Description;
                    ptr.Type           = acct.Type;
                    ptr.IsDefault      = AccountGroup.Current.AccountID == acct.AccountID;

                    ptr = Accounts.Insert(ptr);
                    Accounts.Cache.SetStatus(ptr, PXEntryStatus.Notchanged);

                    yield return(ptr);
                }
            }


            Accounts.Cache.IsDirty = isDirty;
        }
Пример #15
0
        protected virtual void SalesPerson_RowSelected(PXCache cache, PXRowSelectedEventArgs e)
        {
            SalesPerson row = e.Row as SalesPerson;
            bool        allowChangeContact = false;

            if (row != null)
            {
                if (row.HasContact == null)
                {
                    row.HasContact = row.ContactID.HasValue;
                }
                allowChangeContact = !(row.HasContact.Value);
                bool          isNewRecord = this.isNewRecord(row);
                PXEntryStatus status      = this.Salesperson.Cache.GetStatus(row);
                bool          isInserted  = (status == PXEntryStatus.Inserted);
                if (!allowChangeContact)
                {
                    row.CreateNewContact = false;
                }
                if (row.ContactID == null && (row.CreateNewContact ?? false))
                {
                    SelectedContact contact = new SelectedContact();
                    contact.BAccountID = row.BAccountID;
                    Contact cnt = (Contact)this.Contact.Cache.Insert(contact);
                    if (cnt != null)
                    {
                        row.ContactID = cnt.ContactID;
                    }
                    if (allowChangeContact)
                    {
                        this.Contact.Cache.IsDirty     = false;
                        this.Salesperson.Cache.IsDirty = false;
                    }
                }
                PXUIFieldAttribute.SetVisible <SalesPerson.contactID>(cache, row, (allowChangeContact));
                PXUIFieldAttribute.SetVisible <SalesPerson.createNewContact>(cache, row, (allowChangeContact));
                PXUIFieldAttribute.SetEnabled <SalesPerson.contactID>(cache, row, (allowChangeContact && (!(row.CreateNewContact ?? false))));
                PXUIFieldAttribute.SetEnabled(this.Contact.Cache, this.Contact.Current, (row.CreateNewContact ?? false) || (row.ContactID != null));
                PXUIFieldAttribute.SetEnabled(this.Address.Cache, null, (row.CreateNewContact ?? false) || (row.ContactID != null));
            }
        }
        public void FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            CADepositCharge charge   = e.Row as CADepositCharge;
            string          newValue = e.NewValue?.ToString();

            if (charge is null)
            {
                return;
            }

            CADepositCharge dublicate = null;

            if (_FieldName == nameof(CADepositCharge.EntryTypeID))
            {
                dublicate = PXSelect <CADepositCharge,
                                      Where <CADepositCharge.tranType, Equal <Required <CADepositCharge.tranType> >,
                                             And <CADepositCharge.refNbr, Equal <Required <CADepositCharge.refNbr> >,
                                                  And <CADepositCharge.entryTypeID, Equal <Required <CADepositCharge.entryTypeID> >,
                                                       And <CADepositCharge.paymentMethodID, Equal <Required <CADepositCharge.paymentMethodID> > > > > > >
                            .Select(sender.Graph, charge?.TranType, charge?.RefNbr, newValue, charge?.PaymentMethodID);
            }
            else if (_FieldName == nameof(CADepositCharge.PaymentMethodID))
            {
                dublicate = PXSelect <CADepositCharge,
                                      Where <CADepositCharge.tranType, Equal <Required <CADepositCharge.tranType> >,
                                             And <CADepositCharge.refNbr, Equal <Required <CADepositCharge.refNbr> >,
                                                  And <CADepositCharge.entryTypeID, Equal <Required <CADepositCharge.entryTypeID> >,
                                                       And <CADepositCharge.paymentMethodID, Equal <Required <CADepositCharge.paymentMethodID> > > > > > >
                            .Select(sender.Graph, charge?.TranType, charge?.RefNbr, charge?.EntryTypeID, newValue);
            }

            PXEntryStatus status = sender.GetStatus(charge);

            if (dublicate != null &&
                (status == PXEntryStatus.Inserted || status == PXEntryStatus.Updated))
            {
                sender.RaiseExceptionHandling <CADepositCharge.entryTypeID>(charge, charge.EntryTypeID, new PXSetPropertyException(Messages.ChargeAlreadyExists, PXErrorLevel.Error));
                sender.RaiseExceptionHandling <CADepositCharge.paymentMethodID>(charge, charge.PaymentMethodID, new PXSetPropertyException(Messages.ChargeAlreadyExists, PXErrorLevel.Error));
                throw new PXSetPropertyException(Messages.ChargeAlreadyExists, PXErrorLevel.Error);
            }
        }
        protected virtual void VerifyIsAlreadyPosted <Field>(PXCache cache, FSAppointmentDet fsAppointmentDetRow, FSAppointmentInventoryItem fsAppointmentInventoryItemRow, FSBillingCycle billingCycleRow)
            where Field : class, IBqlField
        {
            if ((fsAppointmentDetRow == null && fsAppointmentInventoryItemRow == null) || ServiceOrderRelated.Current == null || billingCycleRow == null)
            {
                return;
            }

            IFSSODetBase row   = null;
            int?         pivot = -1;

            if (fsAppointmentDetRow != null)
            {
                row   = fsAppointmentDetRow;
                pivot = fsAppointmentDetRow.SODetID;
            }
            else if (fsAppointmentInventoryItemRow != null)
            {
                row   = fsAppointmentInventoryItemRow;
                pivot = fsAppointmentInventoryItemRow.AppDetID > 0 ? fsAppointmentInventoryItemRow.AppDetID : null;
            }

            PXEntryStatus status            = ServiceOrderRelated.Cache.GetStatus(ServiceOrderRelated.Current);
            bool          needsVerify       = status == PXEntryStatus.Updated || status == PXEntryStatus.Notchanged;
            bool          isSOAlreadyPosted = ServiceOrderPostedIn.Select().Count > 0;

            if (needsVerify == true &&
                pivot == null &&
                IsInstructionOrComment(row) == false &&
                billingCycleRow.BillingBy == ID.Billing_By.SERVICE_ORDER &&
                isSOAlreadyPosted == true)
            {
                cache.RaiseExceptionHandling <Field>(row,
                                                     row.InventoryID,
                                                     new PXSetPropertyException(
                                                         PXMessages.LocalizeFormat(TX.Error.CANNOT_ADD_INVENTORY_TYPE_LINES_BECAUSE_SO_POSTED, GetLineType(row.LineType)),
                                                         PXErrorLevel.RowError));
            }
        }
        protected virtual IEnumerable Process(PXAdapter adapter)
        {
            var list = new List <Contact>();

            foreach (Contact item in FilteredItems.Cache.Cached)
            {
                bool?sel = (bool?)FilteredItems.Cache.GetValue <Contact.selected>(item);
                if (sel == true)
                {
                    PXEntryStatus status = FilteredItems.Cache.GetStatus(item);
                    if (status == PXEntryStatus.Inserted ||
                        status == PXEntryStatus.Updated)
                    {
                        list.Add(item);
                    }
                }
            }
            if (list.Count > 0)
            {
                PerformAction(list);
            }
            return(adapter.Get());
        }
        protected virtual void OrganizationLedgerLink_RowDeleted(PXCache cache, PXRowDeletedEventArgs e)
        {
            var link = e.Row as OrganizationLedgerLink;

            if (link == null)
            {
                return;
            }

            Ledger        ledger                  = GeneralLedgerMaint.FindLedgerByID(Base, link.LedgerID, isReadonly: false);
            Organization  organization            = GetUpdatingOrganization(link.OrganizationID);
            PXEntryStatus organizationEntryStatus = OrganizationViewBase.Cache.GetStatus(organization);

            if (ledger.BalanceType == LedgerBalanceType.Actual &&
                organizationEntryStatus != PXEntryStatus.Deleted &&
                organizationEntryStatus != PXEntryStatus.InsertedDeleted)
            {
                Organization organizationCopy = PXCache <Organization> .CreateCopy(organization);

                organizationCopy.ActualLedgerID = null;

                OrganizationViewBase.Update(organizationCopy);
            }
        }
Пример #20
0
		public ObjectEntry(PXEntryStatus status, object o)
		{
			Status = status;
			Object = o;
		}
Пример #21
0
 public virtual bool ShouldInvokeOrganizationBranchSync(PXEntryStatus status, Func <PXEntryStatus, bool> baseMethod)
 {
     return(status == PXEntryStatus.Updated | baseMethod(status));
 }
Пример #22
0
 public ObjectEntry(PXEntryStatus status, object o)
 {
     Status = status;
     Object = o;
 }