Ejemplo n.º 1
0
        private void UpdatePhysicalQty()
        {
            INBarCodeItem item = AddByBarCode.Current;
            INPIHeader    d    = this.PIHeader.Current;

            this.SelectTimeStamp();

            using (PXTransactionScope sc = new PXTransactionScope())
            {
                INPIDetail detail =
                    PXSelectReadonly <INPIDetail,
                                      Where <INPIDetail.pIID, Equal <Current <INPIHeader.pIID> >,
                                             And <INPIDetail.inventoryID, Equal <Current <INBarCodeItem.inventoryID> >,
                                                  And <INPIDetail.subItemID, Equal <Current <INBarCodeItem.subItemID> >,
                                                       And <INPIDetail.locationID, Equal <Current <INBarCodeItem.locationID> >,
                                                            And <Where <INPIDetail.lotSerialNbr, IsNull,
                                                                        Or <INPIDetail.lotSerialNbr, Equal <Current <INBarCodeItem.lotSerialNbr> > > > > > > > > > .SelectWindowed(this, 0, 1);

                if (detail == null)
                {
                    INPIEntry entry = PXGraph.CreateInstance <INPIEntry>();
                    entry.PIHeader.Current = entry.PIHeader.Search <INPIHeader.pIID>(d.PIID);
                    detail = PXCache <INPIDetail> .CreateCopy(entry.PIDetail.Insert(new INPIDetail()));

                    detail.InventoryID = item.InventoryID;
                    detail             = PXCache <INPIDetail> .CreateCopy(entry.PIDetail.Update(detail));

                    detail.SubItemID    = item.SubItemID;
                    detail.LocationID   = item.LocationID;
                    detail.LotSerialNbr = item.LotSerialNbr;
                    detail.PhysicalQty  = item.Qty;
                    detail.ExpireDate   = item.ExpireDate;
                    entry.PIDetail.Update(detail);
                    entry.Save.Press();
                    this.PIHeader.View.RequestRefresh();
                }
                else
                {
                    detail = PXCache <INPIDetail> .CreateCopy(detail);

                    detail.PhysicalQty = detail.PhysicalQty.GetValueOrDefault() + item.Qty.GetValueOrDefault();
                    this.PIDetail.Update(detail);
                }
                sc.Complete();

                item.Description = PXMessages.LocalizeFormatNoPrefixNLA(Messages.PILineUpdated,
                                                                        AddByBarCode.GetValueExt <INBarCodeItem.inventoryID>(item).ToString().Trim(),
                                                                        Setup.Current.UseInventorySubItem == true ? ":" + AddByBarCode.GetValueExt <INBarCodeItem.subItemID>(item) : string.Empty,
                                                                        AddByBarCode.GetValueExt <INBarCodeItem.qty>(item),
                                                                        item.UOM,
                                                                        detail.LineNbr);
            }
            AddByBarCode.Reset(true);
            this.AddByBarCode.View.RequestRefresh();
            this.SelectTimeStamp();
        }
Ejemplo n.º 2
0
        protected virtual void INBarCodeItem_ExpireDate_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
        {
            INPIDetail exists =
                PXSelectReadonly <INPIDetail,
                                  Where <INPIDetail.pIID, Equal <Current <INPIHeader.pIID> >,
                                         And <INPIDetail.inventoryID, Equal <Current <INBarCodeItem.inventoryID> >,
                                              And <INPIDetail.lotSerialNbr, Equal <Current <INBarCodeItem.lotSerialNbr> > > > > > .SelectWindowed(this, 0, 1);

            if (exists != null)
            {
                e.NewValue = exists.ExpireDate;
                e.Cancel   = true;
            }
        }
Ejemplo n.º 3
0
        protected virtual void INPIDetail_PhysicalQty_FieldUpdated(PXCache sender, PXFieldUpdatedEventArgs e)
        {
            INPIDetail d = e.Row as INPIDetail;

            if (d == null)
            {
                return;
            }

            sender.SetValue <INPIDetail.varQty>(d, d.PhysicalQty - d.BookQty);
            sender.SetValue <INPIDetail.extVarCost>(d, d.VarQty * d.UnitCost);
            sender.SetValue <INPIDetail.status>(d, d.PhysicalQty != null
                                ? INPIDetStatus.Entered
                                : INPIDetStatus.NotEntered);
        }
Ejemplo n.º 4
0
        private object GetImportedValue <Field>(IDictionary values, bool isRequired)
            where Field : IBqlField
        {
            INPIDetail item        = (INPIDetail)PIDetail.Cache.CreateInstance();
            string     displayName = PXUIFieldAttribute.GetDisplayName <Field>(PIDetail.Cache);

            if (!values.Contains(typeof(Field).Name))
            {
                throw new PXException(Messages.CollumnIsMandatory, displayName);
            }
            object value = values[typeof(Field).Name];

            PIDetail.Cache.RaiseFieldUpdating <Field>(item, ref value);
            if (isRequired && value == null)
            {
                throw new PXException(ErrorMessages.FieldIsEmpty, displayName);
            }
            return(value);
        }
Ejemplo n.º 5
0
        protected virtual void INPIDetail_RowUpdating(PXCache sender, PXRowUpdatingEventArgs e)
        {
            INPIDetail d = e.NewRow as INPIDetail;
            INPIDetail o = e.Row as INPIDetail;

            if (d == null || o == null)
            {
                return;
            }
            using (PXTransactionScope sc = new PXTransactionScope())
            {
                if (!PXDatabase.Update <INPIDetail>(
                        new PXDataFieldAssign(typeof(INPIDetail.status).Name, PXDbType.VarChar, d.Status),
                        new PXDataFieldAssign(typeof(INPIDetail.physicalQty).Name, PXDbType.Decimal, d.PhysicalQty),
                        new PXDataFieldAssign(typeof(INPIDetail.varQty).Name, PXDbType.Decimal, d.VarQty),
                        new PXDataFieldAssign(typeof(INPIDetail.extVarCost).Name, PXDbType.Decimal, d.ExtVarCost),
                        new PXDataFieldRestrict(typeof(INPIDetail.pIID).Name, PXDbType.VarChar, d.PIID),
                        new PXDataFieldRestrict(typeof(INPIDetail.lineNbr).Name, PXDbType.Int, d.LineNbr),
                        new PXDataFieldRestrict(typeof(INPIDetail.Tstamp).Name, PXDbType.Timestamp, 8, this.TimeStamp, PXComp.LE)
                        ))
                {
                    throw new PXException(ErrorMessages.RecordUpdatedByAnotherProcess, typeof(INPIDetail).Name);
                }

                PXDatabase.Update <INPIHeader>(
                    new PXDataFieldAssign(typeof(INPIHeader.totalPhysicalQty).Name, PXDbType.Decimal, (d.PhysicalQty ?? 0) - (o.PhysicalQty ?? 0))
                {
                    Behavior = PXDataFieldAssign.AssignBehavior.Summarize
                },
                    new PXDataFieldAssign(typeof(INPIHeader.totalVarQty).Name, PXDbType.Decimal, (d.VarQty ?? 0) - (o.VarQty ?? 0))
                {
                    Behavior = PXDataFieldAssign.AssignBehavior.Summarize
                },
                    new PXDataFieldAssign(typeof(INPIHeader.totalVarCost).Name, PXDbType.Decimal, (d.ExtVarCost ?? 0) - (o.ExtVarCost ?? 0))
                {
                    Behavior = PXDataFieldAssign.AssignBehavior.Summarize
                },
                    new PXDataFieldRestrict(typeof(INPIHeader.pIID).Name, PXDbType.VarChar, d.PIID));

                sc.Complete();
            }
        }
Ejemplo n.º 6
0
        protected virtual void INPIDetail_PhysicalQty_FieldVerifying(PXCache sender, PXFieldVerifyingEventArgs e)
        {
            if (e.NewValue == null)
            {
                return;
            }

            decimal       value   = (decimal)e.NewValue;
            INPIDetail    d       = (INPIDetail)e.Row;
            INLotSerClass inclass = SelectLotSerClass(d.InventoryID);

            if ((decimal?)e.NewValue < 0m)
            {
                throw new PXSetPropertyException(CS.Messages.Entry_GE, PXErrorLevel.Error, (int)0);
            }

            if (inclass != null &&
                LSRequired(inclass) &&
                inclass.LotSerTrack == INLotSerTrack.SerialNumbered &&
                value != 0m && value != 1m)
            {
                throw new PXSetPropertyException(Messages.PIPhysicalQty);
            }
        }