public void GetSeason() { var seasonClient = new CRUD_ManagerServiceClient(); seasonClient.GetAllSeasonsCompleted += (s, sv) => { foreach (var row in sv.Result) { if (SeasonList.All(x => x.Iserial != row.Iserial)) { SeasonList.Add(new TblLkpSeason().InjectFrom(row) as TblLkpSeason); } } }; seasonClient.GetAllSeasonsAsync(); }
internal void InitializeCompleted() { if (!DesignerProperties.IsInDesignTool) { Types = new ObservableCollection <Transactions>(); if (LoggedUserInfo.CurrLang == 0) { Types.Add(new Transactions { TransactionId = 0, TransactionName = "أمر الشراء" }); Types.Add(new Transactions { TransactionId = 1, TransactionName = "صباغة" }); Types.Add(new Transactions { TransactionId = 2, TransactionName = "Transfer" }); } else { Types.Add(new Transactions { TransactionId = 0, TransactionName = "Purshase Order" }); Types.Add(new Transactions { TransactionId = 1, TransactionName = "Dyeing" }); Types.Add(new Transactions { TransactionId = 2, TransactionName = "Transfer" }); } Client = new CRUD_ManagerServiceClient(); GetItemPermissions(PermissionItemName.Reservation.ToString()); ObservableCollection <GetItemOnhand_Result> OnHandList = new ObservableCollection <GetItemOnhand_Result>(); Client.GetReservationMainDetailByFabricCompleted += (s, f) => { if (f.OnHandList != null) { OnHandList = f.OnHandList; } TransactionHeader = new TblReservationHeaderViewModel(); foreach (var variable in f.Result) { TransactionHeader.TransactionMainDetails.Add(ReservationMappers.MaptoViewModel(variable, f.mainFabricList, OnHandList)); } Loading = false; }; Client.GetAllSeasonsCompleted += (s, sv) => { foreach (var row in sv.Result) { if (SeasonList.All(x => x.Iserial != row.Iserial)) { SeasonList.Add(new TblLkpSeason().InjectFrom(row) as TblLkpSeason); } } }; Client.GetAllSeasonsAsync(); Client.GetAllBrandsCompleted += (s, sv) => { BrandsList.Clear(); foreach (var variable in sv.Result.OrderBy(x => x.Brand_Code)) { BrandsList.Add(variable); } }; Client.GetAllBrandsAsync(0); TransactionGuid = Guid.NewGuid().ToString(); TransactionHeader = new TblReservationHeaderViewModel { DocDate = DateTime.Now.Date }; SelectedMainDetails = new TblReservationMainDetailsViewModel(); Client.GetReservationHeaderListCompleted += (d, i) => { foreach (var item in i.Result) { TransactionHeaderList.Add(ReservationMappers.MaptoViewModel(item)); } }; lkpClient.GetTblBrandSectionLinkCompleted += (x, sv) => { BrandSectionList.Clear(); foreach (var row in sv.Result) { BrandSectionList.Add(row.TblLkpBrandSection1); } }; SalesorderList = new ObservableCollection <CRUD_ManagerServiceSalesOrderDto>(); SalesorderList.CollectionChanged += SalesorderList_CollectionChanged; Client.GetPurchaseOrderSalesOrdersCompleted += (d, s) => { foreach (var variable in s.Result) { if (!SalesorderList.Any( x => x.SalesOrder.Contains(variable.SalesOrder) && x.SalesOrderColor.Contains(variable.SalesOrderColor)) && !SelectedMainDetails.ReservationDetailsViewModelList.Any(x => x.SalesOrder.Contains(variable.SalesOrder) && x.SalesOrderColor.Contains(variable.SalesOrderColor))) { SalesorderList.Add(variable); } } }; Client.GetPurchaseOrderLinesCompleted += (s, f) => { foreach (var item in f.Result.Where(item => !OrderLineList.Contains(FabricInspectionMapper.MapToOrderLine(item)))) { OrderLineList.Add(FabricInspectionMapper.MapToOrderLine(item)); } Loading = false; }; Client.GetRecivedDyedOrdersCompleted += (s, f) => { foreach (var item in f.Result.Where(item => !OrderLineList.Contains(FabricInspectionMapper.MapToOrderLine(item)))) { OrderLineList.Add(FabricInspectionMapper.MapToOrderLine(item)); } }; Client.GetTransferInventDimLinesCompleted += (s, f) => { foreach (var item in f.Result.Where(item => !OrderLineList.Contains(FabricInspectionMapper.MapToOrderLine(item)))) { OrderLineList.Add(FabricInspectionMapper.MapToOrderLine(item)); } }; Client.GetReservationMainDetailsCompleted += (s, f) => { foreach (var variable in f.Result) { if (variable.Inspected) { Client.GetResInspectionListAsync(variable.LineNum, TransactionHeader.TransOrder); } //f.mainFabricList; TransactionHeader.TransactionMainDetails.Add(ReservationMappers.MaptoViewModel(variable, f.mainFabricList)); } }; Client.SaveReservationCompleted += (a, f) => { if (f.ErrorExists) { var visList = TransactionHeader.TransactionMainDetails.Where(x => f.Result.All(s => s.Fabric == x.Fabric && s.FabricColor == x.FabricColor)); foreach (var item in TransactionHeader.TransactionMainDetails) { item.ErrorVisbility = visList.Contains(item) ? Visibility.Visible : Visibility.Collapsed; } } else { var tblFabricInspectionDetail = f.Result.FirstOrDefault(); if (tblFabricInspectionDetail != null) { TransactionHeader.Iserial = tblFabricInspectionDetail.Tbl_ReservationHeader; } TransactionHeader.TransactionMainDetails.Clear(); foreach (var item in f.Result) { TransactionHeader.TransactionMainDetails.Add((TblReservationMainDetailsViewModel) new TblReservationMainDetailsViewModel().InjectFrom(item)); } var currentUi = Thread.CurrentThread.CurrentUICulture; if (currentUi.DisplayName == "العربية") { MessageBox.Show("Saved"); } else { MessageBox.Show("Saved"); } } }; Client.GenerateReservationFromPlanCompleted += (s, sv) => Client.GetReservationMainDetailsAsync(TransactionHeader.Iserial); Client.GetSalesOrderReservationCompleted += (s, sv) => { GenericMapper.InjectFromObCollection(SelectedMainDetails.ReservationDetailsViewModelList, sv.Result); foreach (var item in (SelectedMainDetails.ReservationDetailsViewModelList)) { item.Tbl_ReservationMainDetails = SelectedMainDetails.Iserial; } }; Client.ReservationLineNumCompleted += (s, p) => { var lines = new ObservableCollection <decimal>(p.Result); if (TransactionHeader.TransactionMainDetails.Count() != 0) { foreach (var variable in TransactionHeader.TransactionMainDetails.Select(x => x.LineNum)) { lines.Add(variable); } } if (SortBy == null) { SortBy = "it.PURCHQTY"; } if (TransactionHeader.TransactionType == 0) { Client.GetPurchaseOrderLinesAsync(OrderLineList.Count, PageSize, "ccm", TransactionHeader.TransOrder, lines, "it.PURCHQTY desc", Filter, ValuesObjects); } if (TransactionHeader.TransactionType == 1) { Client.GetRecivedDyedOrdersAsync(OrderLineList.Count, PageSize, TransactionHeader.TransOrder, lines, "it.PURCHQTY desc", Filter, ValuesObjects); } else if (TransactionHeader.TransactionType == 2) { Client.GetTransferInventDimLinesAsync(OrderLineList.Count, PageSize, "ccm", TransactionHeader.TransOrder, lines, "it.PURCHQTY desc", Filter, ValuesObjects); } }; } }
public PurchaseBudgetViewModel() { if (!DesignerProperties.IsInDesignTool) { MainRowList = new SortableCollectionView <TblPurchaseBudgetHeaderViewModel>(); SelectedMainRow = new TblPurchaseBudgetHeaderViewModel(); SelectedDetailRow = new TblPurchaseBudgetDetailViewModel(); Client.GetTblPurchaseBudgetHeaderCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblPurchaseBudgetHeaderViewModel(); newrow.InjectFrom(row); MainRowList.Add(newrow); } Loading = false; FullCount = sv.fullCount; if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(false); } }; Client.GetTblPurchaseBudgetDetailCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblPurchaseBudgetDetailViewModel(); newrow.InjectFrom(row); newrow.SectionPerRow = row.TblLkpBrandSection1; newrow.SeasonPerRow = row.TblLkpSeason1; SelectedMainRow.DetailsList.Add(newrow); } if (sv.Result.Count == 0) { AddNewDetailRow(false); } Loading = false; }; Client.UpdateOrInsertTblPurchaseBudgetHeaderCompleted += (s, x) => { var savedRow = MainRowList.ElementAt(x.outindex); if (savedRow != null) { savedRow.InjectFrom(x.Result); } }; Client.UpdateOrInsertTblPurchaseBudgetDetailCompleted += (s, x) => { var savedRow = (TblPurchaseBudgetDetailViewModel)SelectedMainRow.DetailsList.GetItemAt(x.outindex); if (savedRow != null) { savedRow.InjectFrom(x.Result); } }; Client.DeleteTblPurchaseBudgetHeaderCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { MainRowList.Remove(oldrow); } }; Client.DeleteTblPurchaseBudgetDetailCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result.Iserial); if (oldrow != null) { SelectedMainRow.DetailsList.Remove(oldrow); } }; Client.GetAllBrandsCompleted += (s, sv) => { BrandList = sv.Result; }; Client.GetAllSeasonsCompleted += (s, sv) => { foreach (var row in sv.Result.Where(w => w.IsMaster == true)) { if (SeasonList.All(x => x.Iserial != row.Iserial)) { SeasonList.Add(new TblLkpSeason().InjectFrom(row) as TblLkpSeason); } } }; Client.GetAllSeasonsAsync(); Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); GetMaindata(); } }
public SeasonCurrenciesViewModel() { if (!DesignerProperties.IsInDesignTool) { GetItemPermissions(PermissionItemName.SeasonCurrenciesForm.ToString()); MainRowList = new SortableCollectionView <TblSeasonCurrenciesViewModel>(); SelectedMainRow = new TblSeasonCurrenciesViewModel(); Client.GetTblCurrencyCompleted += (s, sv) => { CurrencyList = sv.Result; }; Client.GetTblCurrencyAsync(0, int.MaxValue, "it.Iserial", null, null); var seasonClient = new CRUD_ManagerServiceClient(); seasonClient.GetAllSeasonsCompleted += (s, sv) => { foreach (var row in sv.Result) { if (SeasonList.All(x => x.Iserial != row.Iserial)) { SeasonList.Add(new TblLkpSeason().InjectFrom(row) as TblLkpSeason); } } GetMaindata(); }; seasonClient.GetAllSeasonsAsync(); Client.GetTblSeasonCurrencyCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TblSeasonCurrenciesViewModel(); newrow.SeasonPerRow = new TblLkpSeason(); newrow.SeasonPerRow = SeasonList.FirstOrDefault(x => x.Iserial == row.TblLkpSeason); newrow.InjectFrom(row); MainRowList.Add(newrow); } Loading = false; FullCount = sv.fullCount; if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(false); } }; Client.UpdateOrInsertTblSeasonCurrencyCompleted += (s, x) => { var savedRow = (TblSeasonCurrenciesViewModel)MainRowList.GetItemAt(x.outindex); Loading = false; if (savedRow != null) { savedRow.InjectFrom(x.Result); } }; Client.DeleteTblSeasonCurrencyCompleted += (s, ev) => { if (ev.Error != null) { throw ev.Error; } Loading = false; var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { MainRowList.Remove(oldrow); } }; } }
public StandardBomViewModel() { if (!DesignerProperties.IsInDesignTool) { GetItemPermissions(PermissionItemName.StandardBomForm.ToString()); GetSeason(); var calculationClient = new CRUD_ManagerServiceClient(); calculationClient.GetGenericCompleted += (s, sv) => { BomCalcMethodList = sv.Result; }; calculationClient.GetGenericAsync("BOM_CalcMethod", "%%", "%%", "%%", "Iserial", "ASC"); //Client.GetTblPaymentScheduleCompleted += (s, sv) => //{ // PaymentScheduleList = sv.Result; //}; //Client.GetTblPaymentScheduleAsync(0, int.MaxValue, "it.Iserial", null, null); var uomClient = new CRUD_ManagerServiceClient(); uomClient.GetGenericCompleted += (s, sv) => { UomList = sv.Result; }; uomClient.GetGenericAsync("tbl_lkp_UoM", "%%", "%%", "%%", "Iserial", "ASC"); MainRowList = new SortableCollectionView <TblStandardBomHeaderViewModel>(); SelectedMainRow = new TblStandardBomHeaderViewModel(); // MainRowList.CollectionChanged += MainRowList_CollectionChanged; var factorGroupClient = new CRUD_ManagerServiceClient(); factorGroupClient.GetGenericCompleted += (s, sv) => { FactoryGroupList = sv.Result; }; factorGroupClient.GetGenericAsync("TblFactoryGroup", "%%", "%%", "%%", "Iserial", "ASC"); var complixtyGroupClient = new CRUD_ManagerServiceClient(); complixtyGroupClient.GetGenericCompleted += (s, sv) => { //complix GroupList = sv.Result; }; factorGroupClient.GetGenericAsync("TblFactoryGroup", "%%", "%%", "%%", "Iserial", "ASC"); Client.GetAllBrandsCompleted += (s, sv) => { BrandList = sv.Result; }; Client.GetAllBrandsAsync(LoggedUserInfo.Iserial); Client.GetTblStandardBOMHeaderCompleted += (s, sv) => { Loading = false; if (sv.Result != null) { foreach (var row in sv.Result) { var newrow = new TblStandardBomHeaderViewModel(); newrow.InjectFrom(row); if (!MainRowList.Contains(newrow)) { newrow.SeasonPerRow = new TblLkpSeason(); newrow.FactoryGroupPerRow = new GenericTable(); newrow.ComplexityGroupPerRow = new GenericTable(); if (BrandSectionList.All(x => x.Iserial != row.TblLkpBrandSection1.Iserial)) { BrandSectionList.Add(new LkpData.TblLkpBrandSection().InjectFrom(row.TblLkpBrandSection1) as LkpData.TblLkpBrandSection); } if (SeasonList.All(x => x.Iserial != row.TblLkpSeason)) { SeasonList.Add(new TblLkpSeason().InjectFrom(row.TblLkpSeason1) as TblLkpSeason); } newrow.FactoryGroupPerRow = new GenericTable().InjectFrom(row.TblFactoryGroup1) as GenericTable; if (row.TblComplexityGroup1 != null) { newrow.ComplexityGroupPerRow = new GenericTable().InjectFrom(row.TblComplexityGroup1) as GenericTable; } newrow.SectionPerRow = row.TblLkpBrandSection1; newrow.SeasonPerRow = SeasonList.FirstOrDefault(x => x.Iserial == newrow.TblLkpSeason); MainRowList.Add(newrow); } } } Loading = false; FullCount = sv.fullCount; if (MainRowList.Any() && (SelectedMainRow == null || SelectedMainRow.Iserial == 0)) { SelectedMainRow = MainRowList.FirstOrDefault(); } if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(false); } if (Export) { Export = false; var handler = ExportCompleted; if (handler != null) { handler(this, EventArgs.Empty); } //ExportGrid.ExportExcel("Style"); } }; GetMaindata(); Client.UpdateOrInsertTblStandardBOMHeaderCompleted += (s, sv) => { var savedRow = MainRowList.ElementAt(sv.outindex); if (savedRow != null) { savedRow.InjectFrom(sv.Result); } Loading = false; }; Client.DeleteTblStandardBOMHeaderCompleted += (s, ev) => { var oldrow = MainRowList.FirstOrDefault(x => x.Iserial == ev.Result.Iserial); if (oldrow != null) { MainRowList.Remove(oldrow); } Loading = false; if (!MainRowList.Any()) { AddNewMainRow(false); } }; Client.DeleteTblStandardBOMCompleted += (s, sv) => { Loading = false; if (sv.Error != null) { throw sv.Error; } var oldrow = SelectedMainRow.BomList.FirstOrDefault(x => x.Iserial == sv.Result); if (oldrow != null) { SelectedMainRow.BomList.Remove(oldrow); } }; Client.GetTblStandardBOMCompleted += (s, sv) => { SelectedMainRow.BomList.Clear(); foreach (var row in sv.Result) { var newrow = new BomViewModel { BOM_CalcMethodPerRow = new GenericTable().InjectFrom(row.BOM_CalcMethod) as GenericTable, BOM_FabricTypePerRow = new GenericTable().InjectFrom(row.BOM_FabricType) as GenericTable }; newrow.ColorPerRow = new TblColor(); newrow.ColorPerRow = row.TblColor1; newrow.InjectFrom(row); newrow.ItemPerRow = sv.itemsList.SingleOrDefault(x => x.Iserial == row.BOM_Fabric); SelectedMainRow.BomList.Add(newrow); } if (SelectedMainRow.BomList.Count == 0) { AddBom(false); } }; Client.UpdateOrInsertTblStandardBOMCompleted += (s, sv) => { Loading = false; if (sv.Error != null) { MessageBox.Show(sv.Error.Message); return; } GetSalesOrderBom(); }; } }