internal void GetBillOfMaterials() { var season = SeasonList.FirstOrDefault(x => x.Iserial == HeaderViewModel.TblLkpSeason); if (HeaderViewModel.TblLkpBrandSection != null) { _webService.GetEstimatedDyeingListAccAsync(HeaderViewModel.Brand, (int)HeaderViewModel.TblLkpBrandSection, season.Code, HeaderViewModel.FromDate, HeaderViewModel.ToDate); } }
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 TradeAgreementViewModel() : base(PermissionItemName.TradeAgreementFabricView) { // ده هيحتاج تعديل productionServiceClient.GetTblTradeAgreementDetailListFabricViewCompleted += (s, sv) => { foreach (var row in sv.Result) { var newrow = new TradeAgreementDetailModel(); newrow.TradeAgreementTransactionIserial = SelectedMainRow.Iserial; newrow.HeaderIserial = row.TblTradeAgreementHeader; newrow.ColorPerRow = new CRUDManagerService.TblColor(); if (row.TblColor1 != null) { newrow.ColorPerRow.InjectFrom(row.TblColor1); } newrow.ItemPerRow = new CRUDManagerService.ItemsDto(); newrow.ItemPerRow.InjectFrom(sv.itemsList.SingleOrDefault(x => x.Iserial == row.ItemCode && x.ItemGroup == row.ItemType)); newrow.ItemType = row.ItemType; newrow.VendorPerRow = new CRUDManagerService.Vendor { vendor_code = row.TblTradeAgreementHeader1.Vendor }; newrow.VendorPurchaseGroupPerRow = new CRUDManagerService.GenericTable(); newrow.VendorPerRow.InjectFrom(sv.VendorList.FirstOrDefault(x => x.vendor_code == row.TblTradeAgreementHeader1.Vendor)); if (row.TblVendorPurchaseGroup1 != null) { newrow.VendorPurchaseGroupPerRow.InjectFrom(row.TblVendorPurchaseGroup1); } newrow.TradeAgreementTransactionIserial = row.TblTradeAgreementHeader1.TblTradeAgreementTransaction.Value; newrow.HeaderIserial = row.TblTradeAgreementHeader; newrow.InjectFrom(row); SelectedMainRow.DetailsList.Insert(0, newrow); } Loading = false; if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0) { AddNewDetailRow(false); } if (Export) { Export = false; ExportGrid.ExportExcel("TradeAgreement"); } } ; calculationClient.GetGenericCompleted += (s, sv) => { VendorPurchaseGroupList = sv.Result; }; Client.GetAxCurrencyAsync("CCM"); Client.GetAxCurrencyCompleted += (s, sv) => { AxCurrencyList = sv.Result; }; Client.SearchForColorCompleted += (s, sv) => { if (sv.Error != null) { return; } SelectedDetailRow.Colors = sv.Result; }; var currentUi = Thread.CurrentThread.CurrentUICulture; productionServiceClient.GetTblTradeAgreementDetailListCompleted += (d, sv) => { foreach (var row in sv.Result) { var newrow = new TradeAgreementDetailModel(); newrow.InjectFrom(row); newrow.HeaderIserial = row.TblTradeAgreementHeader; newrow.TradeAgreementTransactionIserial = SelectedMainRow.Iserial; newrow.ColorPerRow = new CRUDManagerService.TblColor(); if (row.TblColor1 != null) { newrow.ColorPerRow.InjectFrom(row.TblColor1); } newrow.TblColor = row.TblColor; newrow.ItemPerRow = new CRUDManagerService.ItemsDto(); var itemsDto = sv.itemsList.SingleOrDefault(x => x.Iserial == row.ItemCode && x.ItemGroup == row.ItemType); if (itemsDto != null) { newrow.ItemPerRow.InjectFrom(itemsDto); } newrow.ItemCode = row.ItemCode; newrow.ItemType = row.ItemType; newrow.FromDate = row.TblTradeAgreementHeader1.FromDate; newrow.ToDate = row.TblTradeAgreementHeader1.ToDate; newrow.VendorPurchaseGroupPerRow = VendorPurchaseGroupList.FirstOrDefault(vpg => vpg.Iserial == newrow.TblVendorPurchaseGroup); newrow.VendorPerRow = new CRUDManagerService.Vendor(); newrow.VendorPerRow.InjectFrom(sv.vendorsList.FirstOrDefault(v => v.vendor_code == row.TblTradeAgreementHeader1.Vendor)); newrow.Vendor = row.TblTradeAgreementHeader1.Vendor; SelectedMainRow.DetailsList.Add(newrow); } Loading = false; DetailFullCount = sv.fullCount; if (DetailFullCount == 0 && SelectedMainRow.DetailsList.Count == 0) { AddNewDetailRow(false); } }; productionServiceClient.UpdateOrInsertTblTradeAgreementDetailCompleted += (s, x) => { var savedRow = SelectedMainRow.DetailsList.ElementAtOrDefault(x.outindex); if (savedRow != null) { savedRow.InjectFrom(x.Result); } }; productionServiceClient.GetTblTradeAgreementTransactionCompleted += (d, s) => { foreach (var variable in s.Result) { var newrow = new TradeAgreementTransaction(); newrow.InjectFrom(variable); MainRowList.Add(newrow); } Loading = false; FullCount = s.fullCount; if (SearchWindow != null) { SearchWindow.FullCount = s.fullCount; SearchWindow.Loading = false; } if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(true); } }; productionServiceClient.DeleteTblTradeAgreementDetailCompleted += (s, ev) => { Loading = false; if (ev.Error != null) { throw ev.Error; } var oldrow = SelectedMainRow.DetailsList.FirstOrDefault(x => x.Iserial == ev.Result); if (oldrow != null) { SelectedMainRow.DetailsList.Remove(oldrow); } }; productionServiceClient.SaveTradeAgreementCompleted += (s, sv) => { if (SelectedMainRow == null) { SelectedMainRow = new TradeAgreementTransaction(); } SelectedMainRow.InjectFrom(sv.savedHeader); SelectedMainRow.TblLkpSeason = sv.savedHeader.TblLkpSeason; SelectedMainRow.TblLkpSeason1 = SeasonList.FirstOrDefault(r => r.Iserial == SelectedMainRow.TblLkpSeason); //SelectedMainRow.DetailsList.Clear(); foreach (var item in SelectedMainRow.DetailsList) { var newRow = sv.Result.FirstOrDefault(d => d.ItemCode == item.ItemCode && d.TblColor == item.TblColor && d.TblTradeAgreementHeader == item.HeaderIserial && d.AccSize == item.AccSize); if (newRow != null) { item.Iserial = newRow.Iserial; item.HeaderIserial = newRow.TblTradeAgreementHeader; item.TradeAgreementTransactionIserial = newRow.TblTradeAgreementHeader1.TblTradeAgreementTransaction.Value; } } RaisePropertyChanged(nameof(IsHeaderSaved)); MessageBox.Show(strings.Saved); Loading = true; }; productionServiceClient.DeleteTradeAgreementHeaderCompleted += (d, s) => { SelectedMainRow = new TradeAgreementTransaction(); if (currentUi.DisplayName == "العربية") { MessageBox.Show("Deleted"); } else { MessageBox.Show("Deleted"); } }; // ده هيحتاج تعديل LoadingDetail = new RelayCommand <DataGridRowEventArgs>((e) => { if (SelectedMainRow.DetailsList.Count < PageSize) { return; } if (SelectedMainRow.DetailsList.Count - 2 < e.Row.GetIndex() && SelectedMainRow.DetailsList.Count < DetailFullCount && !Loading) { string size = null, vendor = null, color = null, ItemType = null, ItemCode = null; string key = "AccSize"; if (valueObjecttemp.Any(w => w.Key.StartsWith(key))) { size = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value; } key = "Vendor"; if (valueObjecttemp.Any(w => w.Key.StartsWith(key))) { vendor = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value; } key = "Color"; if (valueObjecttemp.Any(w => w.Key.StartsWith(key))) { color = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value; } key = "ItemType"; if (valueObjecttemp.Any(w => w.Key.StartsWith(key))) { ItemType = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value; } key = "ItemCode"; if (valueObjecttemp.Any(w => w.Key.StartsWith(key))) { ItemCode = Convert.ToString(valueObjecttemp.First(w => w.Key.StartsWith(key)).Value); } productionServiceClient.GetTblTradeAgreementDetailListFabricViewAsync( SelectedMainRow.DetailsList.Count, PageSize, SelectedMainRow.Iserial, ItemCode, color, size, vendor, ItemType); } }); // ده هيحتاج تعديل FilterCommand = new RelayCommand <FilterEvent>((e) => { SelectedMainRow.DetailsList.Clear(); valueObjecttemp.Clear(); foreach (var f in e.FiltersPredicate) { valueObjecttemp.Add(f.FilterColumnInfo.PropertyPath, f.FilterText); } string size = null, vendor = null, color = null, ItemType = null, ItemCode = null; string key = "AccSize"; if (valueObjecttemp.Any(w => w.Key.StartsWith(key))) { size = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value; } key = "Vendor"; if (valueObjecttemp.Any(w => w.Key.StartsWith(key))) { vendor = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value; } key = "Color"; if (valueObjecttemp.Any(w => w.Key.StartsWith(key))) { color = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value; } key = "ItemType"; if (valueObjecttemp.Any(w => w.Key.StartsWith(key))) { ItemType = (string)valueObjecttemp.First(w => w.Key.StartsWith(key)).Value; } key = "ItemCode"; if (valueObjecttemp.Any(w => w.Key.StartsWith(key))) { ItemCode = Convert.ToString(valueObjecttemp.First(w => w.Key.StartsWith(key)).Value); } productionServiceClient.GetTblTradeAgreementDetailListFabricViewAsync( 0, PageSize, SelectedMainRow.Iserial, ItemCode, color, size, vendor, ItemType); }); NewDetail = new RelayCommand <KeyEventArgs>((e) => { if (e.Key == Key.Down) { //var currentRowIndex = (SelectedMainRow.DetailsList.IndexOf(SelectedDetailRow)); //if (currentRowIndex == (SelectedMainRow.DetailsList.Count - 1)) //{ // AddNewDetailRow(true); //} } }); DeleteDetail = new RelayCommand <KeyEventArgs>((e) => { if (e.Key == Key.Delete) { var DetailGrid = e.OriginalSource as OsGrid; SelectedDetailRows.Clear(); foreach (var row in DetailGrid.SelectedItems) { SelectedDetailRows.Add(row as TradeAgreementDetailModel); } DeleteDetailRow(); } }); SaveDetail = new RelayCommand <DataGridRowEditEndedEventArgs>((e) => { SaveDetailRow(); }); Client.GetAllSeasonsCompleted += (s, e) => { SeasonList.Clear(); foreach (var row in e.Result) { TblLkpSeason temp = new TblLkpSeason(); temp.InjectFrom(row); SeasonList.Add(temp); } }; AddNewMainRow(false); GetComboData(); GetMaindata(); }
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(); }; } }