Ejemplo n.º 1
0
        public StationsViewModel()
        {
            DetailedOrder   = null;
            SelectedOrder   = null;
            SelectedCommand = null;

            EditEnabled = false;
            EnabledCC   = false;

            _selectedCmd = CommandType.None;
            _activeTUID  = new DatabaseWMS.TU_ID();

            RefreshSubOrder = new RelayCommand(async() => await ExecuteRefreshSubOrder());
            RefreshCommand  = new RelayCommand(async() => await ExecuteRefreshCommandWMS());
            CmdRefresh      = new RelayCommand(async() => await ExecuteRefresh());
            CmdStart        = new RelayCommand(() => ExecuteStart(), CanExecuteStart);
            CmdFinish       = new RelayCommand(async() => await ExecuteFinish(), CanExecuteFinish);
            CmdStop         = new RelayCommand(() => ExecuteStop(), CanExecuteStop);
            CmdChangeHC     = new RelayCommand(() => ExecuteChangeHC(), CanExecuteChangeHC);
            CmdStoreTray    = new RelayCommand(() => ExecuteStoreTray(), CanExecuteStoreTray);
            CmdBringTray    = new RelayCommand(() => ExecuteBringRemoveTray(CommandType.BringTray), CanExecuteBringRemoveTray);
            CmdRemoveTray   = new RelayCommand(() => ExecuteBringRemoveTray(CommandType.RemoveTray), CanExecuteBringRemoveTray);
            CmdDropBox      = new RelayCommand(() => ExecuteDropBox(), CanExecuteDropBox);
            CmdBringBox     = new RelayCommand(() => ExecuteBringPickBox(CommandType.BringBox), CanExecuteBringPickBox);
            CmdPickBox      = new RelayCommand(() => ExecuteBringPickBox(CommandType.PickBox), CanExecuteBringPickBox);
            Cancel          = new RelayCommand(() => ExecuteCancel(), CanExecuteCancel);
            Confirm         = new RelayCommand(() => ExecuteConfirm(), CanExecuteConfirm);
            KeyDown         = new RelayCommand <MessageKeyPressed>(async(k) => await ExecuteKeyPressed(k));
        }
Ejemplo n.º 2
0
        private void ExecuteConfirm()
        {
            try
            {
                EditEnabled = false;
                EnabledCC   = false;
                try
                {
                    switch (_selectedCommand)
                    {
                    case CommandType.Edit:
                        DatabaseWMS.TU_ID tuid = new DatabaseWMS.TU_ID {
                            ID = Detailed.TUID, DimensionClass = Detailed.DimensionClass, Blocked = (int)Detailed.Blocked
                        };
                        List <TUs> tulist = new List <TUs>();
                        foreach (var l in Detailed.DetailList)
                        {
                            tulist.Add(new TUs {
                                TU_ID    = Detailed.TUID,
                                Box_ID   = l.BoxID,
                                Qty      = 1,
                                ProdDate = l.ProdDate,
                                ExpDate  = l.ExpDate
                            });
                        }
                        _dbservicewms.UpdateTUID(tuid);
                        _dbservicewms.UpdateTUs(tuid, tulist);
                        _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Edit TUID: {tuid.ToString()}");
                        Selected.TUID           = Detailed.TUID;
                        Selected.PlaceID        = Detailed.PlaceID;
                        Selected.DimensionClass = Detailed.DimensionClass;
                        Selected.Blocked        = Detailed.Blocked;
                        break;

                    case CommandType.Book:
                        using (WMSToUIClient client = new WMSToUIClient())
                        {
                            var pd = new ProxyWMS_UI.PlaceDiff[] { new ProxyWMS_UI.PlaceDiff {
                                                                       TUID = Detailed.TUID, PlaceWMS = Selected.PlaceID, PlaceMFCS = Detailed.PlaceID
                                                                   } };
                            client.UpdatePlace(pd, _accessUser);
                            _dbservicewms.UpdatePlaceMFCS(new Database.Place {
                                Material = Detailed.TUID, Place1 = Detailed.PlaceID
                            });
                        }
                        _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Rebook TUID: {Detailed.TUID} {Detailed.PlaceID}");
                        Selected.TUID           = Detailed.TUID;
                        Selected.PlaceID        = Detailed.PlaceID;
                        Selected.DimensionClass = Detailed.DimensionClass;
                        Selected.Blocked        = Detailed.Blocked;
                        break;

                    case CommandType.Block:
                        using (WMSToUIClient client = new WMSToUIClient())
                        {
                            client.BlockTU(Detailed.TUID, Detailed.BlockedQC, (int)EnumBlockedWMS.Quality);
                            _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Request block TUID: |{Detailed.TUID:d5}|{Detailed.BlockedQC}|{(int)EnumBlockedWMS.Quality}|");
                            Selected.TUID           = Detailed.TUID;
                            Selected.PlaceID        = Detailed.PlaceID;
                            Selected.DimensionClass = Detailed.DimensionClass;
                            Selected.Blocked        = Detailed.Blocked;
                        }
                        break;

                    case CommandType.Delete:
                        _dbservicewms.DeleteTUs(Detailed.TUID);
                        using (WMSToUIClient client = new WMSToUIClient())
                        {
                            var pd = new ProxyWMS_UI.PlaceDiff[] { new ProxyWMS_UI.PlaceDiff {
                                                                       TUID = Detailed.TUID, PlaceWMS = Detailed.PlaceID, PlaceMFCS = null
                                                                   } };
                            client.UpdatePlace(pd, _accessUser);
                            _dbservicewms.UpdatePlaceMFCS(new Database.Place {
                                Material = Detailed.TUID, Place1 = Detailed.PlaceID
                            });
                        }
                        _dbservicewms.DeletePlaceMFCS(new Database.Place {
                            Material = Detailed.TUID, Place1 = Detailed.PlaceID
                        });
                        _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Delete Place: {Detailed.TUID}, {Detailed.PlaceID}");
                        Selected.TUID           = Detailed.TUID;
                        Selected.PlaceID        = Detailed.PlaceID;
                        Selected.DimensionClass = Detailed.DimensionClass;
                        Selected.Blocked        = Detailed.Blocked;
                        break;

                    case CommandType.Add:
                        List <TUs> tul = new List <TUs>();
                        foreach (var l in Detailed.DetailList)
                        {
                            tul.Add(new TUs {
                                TU_ID    = Detailed.TUID,
                                Box_ID   = l.BoxID,
                                Qty      = 1,
                                ProdDate = l.ProdDate,
                                ExpDate  = l.ExpDate
                            });
                        }
                        using (WMSToUIClient client = new WMSToUIClient())
                        {
                            var pd = new ProxyWMS_UI.PlaceDiff[] {
                                new ProxyWMS_UI.PlaceDiff {
                                    TUID          = Detailed.TUID,
                                    PlaceWMS      = null,
                                    PlaceMFCS     = Detailed.PlaceID,
                                    DimensionMFCS = Detailed.DimensionClass
                                }
                            };
                            client.UpdatePlace(pd, _accessUser);
                            _dbservicewms.UpdatePlaceMFCS(new Database.Place {
                                Material = Detailed.TUID, Place1 = Detailed.PlaceID
                            });
                        }
                        _dbservicewms.AddTUs(tul);
                        _dbservicewms.AddLog(_accessUser, EnumLogWMS.Event, "UI", $"Add Place: {Detailed.TUID}, {Detailed.PlaceID}");
                        break;

                    default:
                        break;
                    }
                    if (Detailed != null)
                    {
                        Detailed.ValidationEnabled = false;
                    }
                }
                catch (Exception e)
                {
                    _warehouse.AddEvent(Event.EnumSeverity.Error, Event.EnumType.Exception, e.Message);
                }
            }
            catch (Exception e)
            {
                _warehouse.AddEvent(Database.Event.EnumSeverity.Error, Database.Event.EnumType.Exception,
                                    string.Format("{0}.{1}: {2}", this.GetType().Name, (new StackTrace()).GetFrame(0).GetMethod().Name, e.Message));
            }
        }