Esempio n. 1
0
        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();
            };
        }
Esempio n. 2
0
        public DyeingOrderViewModel()
        {
            PageSize = 60;
            DyeingOrderHeaderList      = new ObservableCollection <TblDyeingOrderHeaderViewModel>();
            DyeingOrderHeader          = new TblDyeingOrderHeaderViewModel();
            SelectedMainDetails        = new TblDyeingOrdersMainDetailViewModel();
            DyeingAxServiceSummaryList = new ObservableCollection <DyeingAxService>();
            _webService.GetAxSummaryServicesAsync();

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

            _webService.FabricInventSumWithBatchesCompleted += (s, x) =>
            {
                SelectedMainDetails.FabricInventSumWithBatchList = new ObservableCollection <FabricInventSumWithBatch>();

                SelectedMainDetails.FabricInventSumWithBatchList = x.Result;
            };
            _webService.GetSavedDyeingOrderServicesCompleted += (s, sv) =>
            {
                double price = 0;

                DyeingSummaryServices = new ObservableCollection <DyeingSummaryServicesViewModel>();
                foreach (var item in DyeingAxServiceSummaryList)
                {
                    if (item.ServiceCode == "سعر صباغة اللون")
                    {
                        price = SelectedDetails.DefaultPrice ?? 0;
                    }
                    else
                    {
                        price = item.DefaultPrice ?? 0;
                    }
                    DyeingSummaryServices.Add(new DyeingSummaryServicesViewModel
                    {
                        ServiceCode = item.ServiceCode,
                        ServicEname = item.ServiceName,
                        Qty         = price
                    });
                }

                foreach (var row in sv.Result)
                {
                    var serviceRow = DyeingSummaryServices.SingleOrDefault(x => x.ServiceCode == row.ServiceCode);
                    if (serviceRow != null)
                    {
                        serviceRow.SummaryRowIserial = row.DyeingOrdersDetailsInt;
                        serviceRow.Notes             = row.Notes;
                        serviceRow.ItemChecked       = true;
                        if (row.Qty != null)
                        {
                            serviceRow.Qty = (double)row.Qty;
                        }
                    }
                }
            };
            DyeingOrderMainDetailList = new ObservableCollection <TblDyeingOrdersMainDetailViewModel>();
            TransactionList           = new ObservableCollection <Transactions>();
            DyeingOrderMainDetailList.CollectionChanged += DyeingOrderMainDetailList_CollectionChanged;

            if (CultureInfo.CurrentCulture.Name.ToLower().Contains("en"))
            {
                TransactionList.Add(new Transactions {
                    TransactionId = 0, TransactionName = "Issue Fabric"
                });
                TransactionList.Add(new Transactions {
                    TransactionId = 1, TransactionName = "Receive Dyed Fabric"
                });
                //TransactionList.Add(new Transactions { TransactionId = 2, TransactionName = "Receive Fabric" });
                //TransactionList.Add(new Transactions { TransactionId = 3, TransactionName = "Return Dyed Fabric" });
            }
            else
            {
                TransactionList.Add(new Transactions {
                    TransactionId = 0, TransactionName = "صرف"
                });
                TransactionList.Add(new Transactions {
                    TransactionId = 1, TransactionName = "إستلام قماش  مصبوغ"
                });
                //TransactionList.Add(new Transactions { TransactionId = 2, TransactionName = "إضافة" });
                //TransactionList.Add(new Transactions { TransactionId = 3, TransactionName = "إرجاع قماش  مصبوغ" });
            }

            _webService.DyeingOrderHeaderSearchListCompleted += (s, e) =>
            {
                DyeingOrderHeaderList = new ObservableCollection <TblDyeingOrderHeaderViewModel>();
                foreach (var item in e.Result)
                {
                    DyeingOrderHeaderList.Add(DyeingMapper.VwMapToDyeingorderHeader(item));
                }
            };

            _webService.GetDyeingOrdersMainDetailsCompleted += (s, e) =>
            {
                DyeingOrderMainDetailList = new ObservableCollection <TblDyeingOrdersMainDetailViewModel>();
                foreach (var item in e.Result)
                {
                    DyeingOrderMainDetailList.Add(DyeingMapper.VwMapToDyeingorderMainDetail(item, e.ColorPrices));
                }
                int maxTransId;
                try
                {
                    maxTransId = DyeingOrderMainDetailList.Where(x => x.TransactionType == SelectedMainDetails.TransactionType & x != SelectedMainDetails).Select(x => x.TransId).Max();
                    SelectedMainDetails.GotTransid = true;
                }
                catch (Exception)
                {
                    maxTransId = 0;
                }

                if (SelectedMainDetails != null)
                {
                    SelectedMainDetails.TransId = maxTransId + 1;
                }

                DyeingOrderMainDetailList.CollectionChanged += DyeingOrderMainDetailList_CollectionChanged;
            };
        }