Пример #1
0
 private void SetSelectedFromFields(TblItemDim itemDimFrom, ItemDimensionSearchModel itemTo)
 {
     itemTo.ItemDimFromIserial = itemDimFrom.Iserial;
     itemTo.ColorFromId        = itemDimFrom.TblColor;
     itemTo.SizeFrom           = itemDimFrom.Size;
     itemTo.BatchNoFrom        = itemDimFrom.BatchNo;
     itemTo.SiteFromIserial    = itemDimFrom.TblSite;
 }
Пример #2
0
 private void SetSelectedToFields(TblItemDim itemDimFrom, ItemDimensionSearchModel itemTo)
 {
     itemTo.ItemDimToIserial = itemDimFrom.Iserial;
     itemTo.ColorToId        = itemDimFrom.TblColor;
     itemTo.SizeTo           = itemDimFrom.Size;
     itemTo.BatchNoTo        = itemDimFrom.BatchNo;
     itemTo.SiteToIserial    = itemDimFrom.TblSite;
 }
Пример #3
0
        public ItemDimensionSearchViewModel()
        {
            Client.AccWithConfigAndSizeCompleted += (s, sv) =>
            {
                bool isSearchItem    = false;
                var  itemSearchModel = SearchResultList.FirstOrDefault(i => i.ItemId == sv.Result.Iserial && i.ItemType == sv.Result.ItemGroup);
                CRUDManagerService.ItemsDto item;
                if (itemSearchModel != null)
                {
                    item         = itemSearchModel.ItemPerRow ?? (itemSearchModel.ItemPerRow = new CRUDManagerService.ItemsDto());
                    isSearchItem = true;
                }
                else
                {
                    item = ItemPerRow;
                }

                item.AccConfigList   = sv.Result.AccConfigList;
                item.SizesList       = new ObservableCollection <string>();
                item.CombinationList = sv.Result.CombinationList;

                var tblAccessoryAttributesDetails = sv.Result.CombinationList.FirstOrDefault();
                if (tblAccessoryAttributesDetails != null)
                {
                    item.SizesList.Add(tblAccessoryAttributesDetails.Size);
                }
                if (item.CombinationList != null)
                {
                    item.SizesList = new ObservableCollection <string>();
                }
                if (isSearchItem)
                {
                    if (item.AccConfigList == null)
                    {
                        item.AccConfigList = new ObservableCollection <CRUDManagerService.TblColor>();
                    }
                    itemSearchModel.ColorPerRow = item.AccConfigList.FirstOrDefault(c => c.Iserial == itemSearchModel.ColorToId);
                }
            };
            Client.InspectionRouteCompleted += (o, e) =>
            {
                foreach (var batchNo in e.Result.Select(x => x.RollBatch))
                {
                    if (!BatchNoList.Contains(batchNo))
                    {
                        BatchNoList.Add(batchNo);
                    }
                }
            };
            // Client.SearchF
            WarehouseClient.GetAccWarehouseRowsCompleted += (s, e) =>
            {
                if (e.Result.Count <= 0)
                {
                    MessageBox.Show(strings.NoDataFound);
                }
                foreach (var iR in e.Result)
                {
                    // هشوف لو موجود مش هحطه
                    if (!SearchResultList.Any(sr => sr.ItemDimFromIserial == iR.ItemDimFromIserial))
                    {
                        var qtemp = iR.AvailableQuantity;
                        iR.AvailableQuantity = 0;
                        // iR.CountedQuantity = 0;
                        iR.AvailableQuantity = qtemp;
                        if (iR.PendingQuantity > 0)
                        {
                            iR.TransferredQuantity = iR.AvailableQuantity;
                        }
                        else
                        {
                            iR.TransferredQuantity = iR.AvailableQuantity + iR.PendingQuantity;
                        }
                        ItemDimensionSearchModel item = new ItemDimensionSearchModel();
                        item.InjectFrom(iR);
                        if (item.ItemPerRow == null)
                        {
                            item.ItemPerRow = new CRUDManagerService.ItemsDto();
                        }
                        if (ItemPerRow.Iserial > 0)
                        {
                            item.ItemPerRow.InjectFrom(ItemPerRow);
                        }
                        //else
                        //    Client.AccWithConfigAndSizeAsync(new CRUDManagerService.ItemsDto()
                        //    {
                        //        Iserial = item.ItemId,
                        //        ItemGroup = item.ItemType,
                        //        Code=item.ItemCode,
                        //    });
                        if (item.ItemPerRow.AccConfigList == null)
                        {
                            item.ItemPerRow.AccConfigList = new ObservableCollection <CRUDManagerService.TblColor>();
                        }
                        var colorRow = item.ItemPerRow.AccConfigList.FirstOrDefault(c => c.Iserial == iR.ColorPerRow.Iserial);
                        if (colorRow == null)
                        {
                            colorRow = new CRUDManagerService.TblColor()
                            {
                                Iserial = item.ColorFromId,
                                Code    = item.ColorFromCode
                            };
                        }
                        item.ColorPerRow = colorRow;

                        SearchResultList.Add(item);
                    }
                }
                Loading = false;
            };
            WarehouseClient.GetItemDimensionsOrCreteForTransferCompleted += (s, e) =>
            {
                SelectedSearchResultList.Clear();
                foreach (var item in e.Result)
                {
                    ItemDimensionSearchModel temp = new ItemDimensionSearchModel();
                    temp.InjectFrom(item);
                    temp.ItemPerRow = ItemPerRow;
                    temp.ColorPerRow.InjectFrom(item.ColorPerRow);
                    SelectedSearchResultList.Add(temp);
                }
                IsWorking = false;
            };
            CancelCommand = new RelayCommand((o) => // هقفل وارجع فولس يعرف انه كنسل
            {
                var view = (o as ChildWindowsOverride);
                if (view != null)
                {
                    view.DialogResult = false;
                    view.Close();
                }
            });
            ApplyCommand = new RelayCommand((o) =>
            {
                var view = (o as ItemDimensionSearchChildWindow);
                if (view != null)
                {
                    //هنا هاخد الى مختاره فى الجريد للشاشة الاصلية
                    ApplySelectedItem(view);
                }
            });
            OkCommand = new RelayCommand((o) =>
            {
                var view = (o as ItemDimensionSearchChildWindow);
                if (view != null)
                {
                    //هنا هاخد الى مختاره فى الجريد للشاشة الاصلية لو مكانش راح
                    //وهقفل الشاشة فى الاخر
                    ApplySelectedItem(view);
                    view.DialogResult = true;
                    view.Close();
                }
            });
            LoadingRow = new GalaSoft.MvvmLight.Command.RelayCommand <object>((o) =>
            {
                var e = o as System.Windows.Controls.DataGridRowEventArgs;
                if (SearchResultList.Count < PageSize)
                {
                    return;
                }
                if (SearchResultList.Count - 2 < e.Row.GetIndex() && !Loading)
                {
                    GetInspectionWarehouseRows();
                }
            });
            DetailSelectionChanged = new GalaSoft.MvvmLight.Command.RelayCommand <object>(
                (o) => {
                var e    = o as System.Windows.Controls.SelectionChangedEventArgs;
                var temp = new Web.DataLayer.ItemDimensionSearchModel();
                if (e.AddedItems != null && e.AddedItems.Count > 0)
                {
                    temp.InjectFrom(e.AddedItems[0]);
                    WarehouseClient.GetItemToQuantitiesAsync(temp, WarehouseToCode);
                }
            });
            WarehouseClient.GetItemToQuantitiesCompleted += (s, e) =>
            {
                var item = SearchResultList.FirstOrDefault(rl =>
                                                           rl.ItemId == e.Result.ItemId && rl.ItemType == e.Result.ItemType &&
                                                           rl.ItemDimFromIserial == e.Result.ItemDimFromIserial &&
                                                           rl.ColorFromId == e.Result.ColorFromId &&
                                                           rl.SizeFrom == e.Result.SizeFrom && rl.BatchNoFrom == e.Result.BatchNoFrom &&
                                                           rl.ColorToId == e.Result.ColorToId && rl.SizeTo == e.Result.SizeTo &&
                                                           rl.BatchNoTo == e.Result.BatchNoTo);
                if (item != null)
                {
                    item.ItemDimToIserial    = e.Result.ItemDimToIserial;
                    item.AvailableToQuantity = e.Result.AvailableToQuantity;
                    item.PendingToQuantity   = e.Result.PendingToQuantity;
                }
                else
                {
                    //item.AvailableToQuantity = 0;
                    //item.PendingToQuantity = 0;
                }
            };

            WarehouseClient.GetItemGroupCompleted += (s, e) =>
            {
                foreach (var item in e.Result)
                {
                    ItemTypes.Add(item);
                }
            };
            WarehouseClient.GetItemGroupAsync();
        }