Пример #1
0
        private void PurchaseOrderReceiptAction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            try
            {
                GlobalFunction _globFunc    = new GlobalFunction();
                IObjectSpace   _objectSpace = View is ListView?Application.CreateObjectSpace() : View.ObjectSpace;

                ArrayList     _objectsToProcess = new ArrayList(e.SelectedObjects);
                DateTime      now               = DateTime.Now;
                Session       _currSession      = null;
                string        _currObjectId     = null;
                string        _locDocCode       = null;
                ProjectHeader _locProjectHeader = null;


                if (this.ObjectSpace != null)
                {
                    _currSession = ((XPObjectSpace)this.ObjectSpace).Session;
                }

                if (_objectsToProcess != null)
                {
                    foreach (Object obj in _objectsToProcess)
                    {
                        PurchaseOrder _locPurchaseOrderOS = (PurchaseOrder)_objectSpace.GetObject(obj);

                        if (_locPurchaseOrderOS != null)
                        {
                            if (_locPurchaseOrderOS.Code != null)
                            {
                                _currObjectId = _locPurchaseOrderOS.Code;

                                PurchaseOrder _locPurchaseOrderXPO = _currSession.FindObject <PurchaseOrder>
                                                                         (new GroupOperator(GroupOperatorType.And,
                                                                                            new BinaryOperator("Code", _currObjectId),
                                                                                            new BinaryOperator("Status", Status.Progress)));

                                if (_locPurchaseOrderXPO != null)
                                {
                                    if (_locPurchaseOrderXPO.ProjectHeader != null)
                                    {
                                        _locProjectHeader = _locPurchaseOrderXPO.ProjectHeader;
                                    }


                                    DocumentType _locDocumentTypeXPO = _currSession.FindObject <DocumentType>
                                                                           (new GroupOperator(GroupOperatorType.And,
                                                                                              new BinaryOperator("DirectionType", DirectionType.External),
                                                                                              new BinaryOperator("InventoryMovingType", InventoryMovingType.Receive),
                                                                                              new BinaryOperator("ObjectList", ObjectList.InventoryTransfer),
                                                                                              new BinaryOperator("DocumentRule", DocumentRule.Vendor),
                                                                                              new BinaryOperator("Active", true),
                                                                                              new BinaryOperator("Default", true)));

                                    if (_locDocumentTypeXPO != null)
                                    {
                                        _locDocCode = _globFunc.GetDocumentNumberingUnlockOptimisticRecord(_currSession.DataLayer, _locDocumentTypeXPO);

                                        if (_locDocCode != null)
                                        {
                                            InventoryTransfer _saveDataIT = new InventoryTransfer(_currSession)
                                            {
                                                DirectionType       = _locDocumentTypeXPO.DirectionType,
                                                InventoryMovingType = _locDocumentTypeXPO.InventoryMovingType,
                                                ObjectList          = _locDocumentTypeXPO.ObjectList,
                                                DocumentType        = _locDocumentTypeXPO,
                                                DocNo         = _locDocCode,
                                                EstimatedDate = _locPurchaseOrderXPO.EstimatedDate,
                                                PurchaseOrder = _locPurchaseOrderXPO,
                                                ProjectHeader = _locProjectHeader
                                            };
                                            _saveDataIT.Save();
                                            _saveDataIT.Session.CommitTransaction();

                                            InventoryTransfer _locInventoryTransfer = _currSession.FindObject <InventoryTransfer>
                                                                                          (new GroupOperator(GroupOperatorType.And,
                                                                                                             new BinaryOperator("DocNo", _locDocCode),
                                                                                                             new BinaryOperator("PurchaseOrder", _locPurchaseOrderXPO),
                                                                                                             new BinaryOperator("ProjectHeader", _locProjectHeader)));

                                            if (_locInventoryTransfer != null)
                                            {
                                                XPCollection <PurchaseOrderLine> _locPurchaseOrderLines = new XPCollection <PurchaseOrderLine>
                                                                                                              (_currSession, new GroupOperator(GroupOperatorType.And,
                                                                                                                                               new BinaryOperator("PurchaseOrder", _locPurchaseOrderXPO),
                                                                                                                                               new BinaryOperator("Status", Status.Progress)));

                                                if (_locPurchaseOrderLines != null && _locPurchaseOrderLines.Count > 0)
                                                {
                                                    foreach (PurchaseOrderLine _locPurchaseOrderLine in _locPurchaseOrderLines)
                                                    {
                                                        InventoryTransferLine _saveDataInventoryTransferLine = new InventoryTransferLine(_currSession)
                                                        {
                                                            Item              = _locPurchaseOrderLine.Item,
                                                            MxDQty            = _locPurchaseOrderLine.DQty,
                                                            MxDUOM            = _locPurchaseOrderLine.DUOM,
                                                            MxQty             = _locPurchaseOrderLine.Qty,
                                                            MxUOM             = _locPurchaseOrderLine.UOM,
                                                            MxTQty            = _locPurchaseOrderLine.TQty,
                                                            DQty              = _locPurchaseOrderLine.DQty,
                                                            DUOM              = _locPurchaseOrderLine.DUOM,
                                                            Qty               = _locPurchaseOrderLine.Qty,
                                                            UOM               = _locPurchaseOrderLine.UOM,
                                                            TQty              = _locPurchaseOrderLine.TQty,
                                                            EstimatedDate     = _locInventoryTransfer.EstimatedDate,
                                                            InventoryTransfer = _locInventoryTransfer
                                                        };
                                                        _saveDataInventoryTransferLine.Save();
                                                        _saveDataInventoryTransferLine.Session.CommitTransaction();

                                                        //Change Status POL From Progress To Posted
                                                        _locPurchaseOrderLine.Status     = Status.Posted;
                                                        _locPurchaseOrderLine.StatusDate = now;
                                                        _locPurchaseOrderLine.Save();
                                                        _locPurchaseOrderLine.Session.CommitTransaction();
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    //Change Status PO From Progress To Posted
                                    _locPurchaseOrderXPO.Status     = Status.Posted;
                                    _locPurchaseOrderXPO.StatusDate = now;
                                    _locPurchaseOrderXPO.Save();
                                    _locPurchaseOrderXPO.Session.CommitTransaction();

                                    SuccessMessageShow(_locPurchaseOrderXPO, "Inventory Transfer");
                                }
                                else
                                {
                                    ErrorMessageShow("Data Purchase Order Not Available");
                                }
                            }
                            else
                            {
                                ErrorMessageShow("Data Purchase Order Not Available");
                            }
                        }
                    }
                }

                if (View is DetailView && ((DetailView)View).ViewEditMode == ViewEditMode.View)
                {
                    _objectSpace.CommitChanges();
                    _objectSpace.Refresh();
                }
                if (View is ListView)
                {
                    _objectSpace.CommitChanges();
                    View.ObjectSpace.Refresh();
                }
            }
            catch (Exception ex)
            {
                Tracing.Tracer.LogError(" BusinessObject = PurchaseOrder " + ex.ToString());
            }
        }
Пример #2
0
        private void InventoryTransferProgressAction_Execute(object sender, SimpleActionExecuteEventArgs e)
        {
            try
            {
                GlobalFunction _globFunc    = new GlobalFunction();
                IObjectSpace   _objectSpace = View is ListView?Application.CreateObjectSpace() : View.ObjectSpace;

                ArrayList _objectsToProcess = new ArrayList(e.SelectedObjects);
                DateTime  now           = DateTime.Now;
                Session   _currSession  = null;
                string    _currObjectId = null;


                if (this.ObjectSpace != null)
                {
                    _currSession = ((XPObjectSpace)this.ObjectSpace).Session;
                }

                if (_objectsToProcess != null)
                {
                    foreach (Object obj in _objectsToProcess)
                    {
                        InventoryTransfer _locInventoryTransferOS = (InventoryTransfer)_objectSpace.GetObject(obj);

                        if (_locInventoryTransferOS != null)
                        {
                            if (_locInventoryTransferOS.Code != null)
                            {
                                _currObjectId = _locInventoryTransferOS.Code;

                                InventoryTransfer _locInventoryTransferXPO = _currSession.FindObject <InventoryTransfer>
                                                                                 (new GroupOperator(GroupOperatorType.And,
                                                                                                    new BinaryOperator("Code", _currObjectId)));

                                if (_locInventoryTransferXPO != null)
                                {
                                    if (_locInventoryTransferXPO.Status == Status.Open)
                                    {
                                        _locInventoryTransferXPO.Status     = Status.Progress;
                                        _locInventoryTransferXPO.StatusDate = now;
                                        _locInventoryTransferXPO.Save();
                                        _locInventoryTransferXPO.Session.CommitTransaction();

                                        XPCollection <InventoryTransferLine> _locInventoryTransferLines = new XPCollection <InventoryTransferLine>
                                                                                                              (_currSession, new GroupOperator(GroupOperatorType.And,
                                                                                                                                               new BinaryOperator("InventoryTransfer", _locInventoryTransferXPO)));

                                        if (_locInventoryTransferLines != null && _locInventoryTransferLines.Count > 0)
                                        {
                                            foreach (InventoryTransferLine _locInventoryTransferLine in _locInventoryTransferLines)
                                            {
                                                if (_locInventoryTransferLine.Status == Status.Open)
                                                {
                                                    _locInventoryTransferLine.Status     = Status.Progress;
                                                    _locInventoryTransferLine.StatusDate = now;
                                                    _locInventoryTransferLine.Save();
                                                    _locInventoryTransferLine.Session.CommitTransaction();
                                                }
                                            }
                                        }
                                        SuccessMessageShow(_locInventoryTransferXPO.Code + " has been change successfully to Progress");
                                    }
                                }
                                else
                                {
                                    ErrorMessageShow("Data Inventory Transfer Not Available");
                                }
                            }
                            else
                            {
                                ErrorMessageShow("Data Inventory Transfer Not Available");
                            }
                        }
                    }
                }

                if (View is DetailView && ((DetailView)View).ViewEditMode == ViewEditMode.View)
                {
                    _objectSpace.CommitChanges();
                    _objectSpace.Refresh();
                }
                if (View is ListView)
                {
                    _objectSpace.CommitChanges();
                    View.ObjectSpace.Refresh();
                }
            }
            catch (Exception ex)
            {
                Tracing.Tracer.LogError(" BusinessObject = InventoryTransfer " + ex.ToString());
            }
        }