Exemple #1
0
        private void btnSearchOrderPlan_Click(object sender, RoutedEventArgs e)
        {
            var childWindowSeach = new DyeingPlanSearchResults(_dyedPlanViewModel);

            childWindowSeach.Show();

            _dyedPlanViewModel.SearchHeader();

            FormPlanMode = FormMode.Read;
            SwitchPlanFormMode(FormPlanMode);
        }
        public DyeingPlanAccViewModel()
        {
            DyeingSummeryViewModelList = new ObservableCollection <DyeingSummeryViewModel>();
            FabricStorageList          = new ObservableCollection <FabricStorage_Result>();

            lkpClient.GetTblBrandSectionLinkCompleted += (s, sv) =>
            {
                BrandSectionList.Clear();
                foreach (var row in sv.Result)
                {
                    BrandSectionList.Add(row.TblLkpBrandSection1);
                    if (row.TblLkpBrandSection == HeaderViewModel.TblLkpBrandSection)
                    {
                        HeaderViewModel.BrandSectionPerRow = row.TblLkpBrandSection1;
                    }
                }
                //HeaderViewModel.BrandSectionPerRow =
                //    BrandSectionList.Where(
                //        x =>
                //            x.TblLkpBrandSectionLinks.FirstOrDefault(
                //                w => w.TblLkpBrandSection == HeaderViewModel.TblLkpBrandSection)).;
            };

            Client.GetBomfabricDyeingServiceCompleted += (s, sv) =>
            {
            };
            _webService.GetFabricWithUnitAndDyeingClassCompleted += (d, sv) =>
            {
                FabricAttList = sv.Result;
            };
            ChaingSetupMethod.GetSettings("Dyeing Order acc", _webService);

            _webService.GetChainSetupCompleted += (a, s) =>
            {
                foreach (var item in s.Result)
                {
                    if (item.sGlobalSettingCode == "DefaultDyeingVendorCode")
                    {
                        DefaultDyeingVendor = item.sSetupValue;
                    }
                    else if (item.sGlobalSettingCode == "DefaultFinishedFabricWarehouse")
                    {
                        DefaultFinishedFabricWarehouse = item.sSetupValue;
                    }
                }
            };

            WareHouseList = new ObservableCollection <TblWarehouse>();
            _webService.GetTblWarehouseAsync(0, int.MaxValue, "it.Iserial", null, null);
            _webService.GetTblWarehouseCompleted += (s, w) =>
            {
                foreach (var item in w.Result)
                {
                    WareHouseList.Add(item);
                }
            };

            _webService.GetLocationDetailsCompleted += (s, sv) =>
            {
                FabricStorageList = sv.Result;
            };

            BrandsList      = new ObservableCollection <Brand>();
            SeasonList      = new ObservableCollection <TblLkpSeason>();
            FabricList      = new ObservableCollection <FabricsDyedGroup>();
            VendorList      = new ObservableCollection <Vendor>();
            HeaderViewModel = new TblDyeingPlanHeaderViewModel();

            SelectedRow = new TblDyeingPlanViewModel();
            DyeingAxServiceSummaryList      = new ObservableCollection <DyeingAxService>();
            HeaderViewModel.FromDate        = null;
            HeaderViewModel.ToDate          = null;
            HeaderViewModel.TransactionDate = DateTime.Now;
            _webService.GetAllBrandsAsync(LoggedUserInfo.Iserial);
            _webService.SeasonsAsync();
            _webService.GetWarehouseswithOnHandAsync();
            _webService.GetAxSummaryServicesAsync();

            _webService.GetAxSummaryServicesCompleted += (d, s) =>
            {
                foreach (var item in s.Result)
                {
                    DyeingAxServiceSummaryList.Add(item);
                }
            };

            //_webService.GetSavedSummaryServicesCompleted += (d, e) =>
            //{
            //    DyeingSummaryServices = new ObservableCollection<DyeingSummaryServicesViewModel>();
            //    foreach (var item in DyeingAxServiceSummaryList)
            //    {
            //        DyeingSummaryServices.Add(new DyeingSummaryServicesViewModel
            //        {
            //            ServiceCode = item.ServiceCode,
            //            ServicEname = item.ServiceName
            //        });
            //    }

            //    foreach (var row in e.Result)
            //    {
            //        var serviceRow = DyeingSummaryServices.SingleOrDefault(x => x.ServiceCode == row.ServiceCode);
            //        if (serviceRow != null)
            //        {
            //            serviceRow.SummaryRowIserial = row.SummaryRowIserial;
            //            serviceRow.Notes = row.Notes;
            //            serviceRow.ItemChecked = true;
            //        }
            //    }
            //};

            _webService.GetEstimatedDyeingListAccCompleted += (s, sv) =>
            {
                HeaderViewModel.DyeingViewModelList = new ObservableCollection <TblDyeingPlanViewModel>();
                ColorHeader = new ObservableCollection <ColorHeader>();

                foreach (var item in sv.ColorsValues.Distinct())
                {
                    var test = new ColorHeader
                    {
                        ColorName = item.FabricColor
                    };

                    if (ColorHeader.All(x => x.ColorName != test.ColorName))
                    {
                        test.BatchNo = test.BatchNo;
                        ColorHeader.Add(test);
                    }
                }

                foreach (var item in sv.Result)
                {
                    HeaderViewModel.DyeingViewModelList.Add(DyeingPlanMapper.VmMapToDyeingPLanEstimated(item, sv.ColorsValues.Where(x => x.Fabric_Code == item.FabricCode && x.SalesOrderID == item.SalesOrderID).ToList(), 0, ColorHeader));
                }

                foreach (var variable in HeaderViewModel.DyeingViewModelList)
                {
                    variable.DyedFabric = variable.FabricCode + "Dy";
                }
            };
            _webService.GetVendorsCompleted += (d, s) =>
            {
                foreach (var item in s.Result)
                {
                    VendorList.Add(item);
                }
            };
            _webService.SeasonsCompleted += (d, s) =>
            {
                SeasonList = s.Result;
            };
            _webService.GetAllBrandsCompleted += (a, b) =>
            {
                foreach (var item in b.Result)
                {
                    BrandsList.Add(item);
                }
            };

            //_webService.GetFabricDyedListCompleted += (r, f) =>
            //{
            //    foreach (var item in f.Result)
            //    {
            //        FabricList.Add(item);
            //    }
            //};

            _webService.GetWarehouseswithOnHandCompleted += (l, c) =>
            {
                WarehouseWithOnHandList = c.Result;
            };

            _webService.GetDyeingSummaryAccCompleted += (l, s) =>
            {
                DyeingSummeryViewModelList.Clear();
                foreach (var item in s.Result)
                {
                    DyeingSummeryViewModelList.Add(DyeingPlanMapper.VmMapToDyeingSummary(new TblDyeingSummary().InjectFrom(item) as TblDyeingSummary));
                }
                SummaryPagedCollection = new PagedCollectionView(DyeingSummeryViewModelList);
                SummaryPagedCollection.GroupDescriptions.Add(new PropertyGroupDescription("FabricCode"));
            };
            HeaderViewModel.PropertyChanged += DyeingHeaderViewModel_PropertyChanged;

            _webService.GetDyeingListAccCompleted += webService_GetDyeingListCompleted;

            _webService.GetDyeingHeaderListAccCompleted += (h, ho) =>
            {
                HeaderViewModel.DyeingViewModelList = new ObservableCollection <TblDyeingPlanViewModel>();
                ColorHeader = new ObservableCollection <ColorHeader>();

                var childWindowSeach = new DyeingPlanSearchResults(this);
                foreach (var row in ho.Result)
                {
                    var newrow = new TblDyeingPlanHeaderViewModel();
                    newrow.InjectFrom(row);
                    newrow.BrandSectionPerRow = new LkpData.TblLkpBrandSection().InjectFrom(row.TblLkpBrandSection1) as LkpData.TblLkpBrandSection;
                    newrow.SeasonPerRow       = row.TblLkpSeason1;
                    DyeingPlanHeaderViewModelList.Add(newrow);
                }

                childWindowSeach.Show();

                DyeingSummeryViewModelList.Clear();
            };
        }