public void AddNewMainRow(bool checkLastRow) { if (AllowAdd != true) { MessageBox.Show(strings.AllowAddMsg); return; } var currentRowIndex = (MainRowList.IndexOf(SelectedMainRow)); if (checkLastRow) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true); if (!isvalid) { return; } } var sizeRatioList = new ObservableCollection <TblSeasonalMasterListDetail>(); foreach (var sizeCode in SelectedStyleViewModel.Sizes.OrderBy(x => x.Id)) { sizeRatioList.Add(new TblSeasonalMasterListDetail { Size = sizeCode.SizeCode, }); } var style = new TblStyle(); style.InjectFrom(SelectedStyleViewModel.SelectedMainRow); var prevRow = new TblSeasonalMasterListViewModel(); if (currentRowIndex != -1) { prevRow = MainRowList.ElementAt(currentRowIndex); } var newrow = new TblSeasonalMasterListViewModel { TblStyle = SelectedStyleViewModel.SelectedMainRow.Iserial, StylePerRow = style, }; GenericMapper.InjectFromObCollection(newrow.SeasonalMasterListDetail, prevRow.SeasonalMasterListDetail.Count() != 0 ? prevRow.SeasonalMasterListDetail : sizeRatioList); newrow.ThemePerRow = prevRow.ThemePerRow; foreach (var size in newrow.SeasonalMasterListDetail) { size.ProductionPerSize = 0; } MainRowList.Insert(currentRowIndex + 1, newrow); SelectedMainRow = newrow; }
public UserJobsViewModel() { if (!DesignerProperties.IsInDesignTool) { AuthClient = Helpers.Services.Instance.GetAuthServiceClient(); Jobs = new ObservableCollection <TblAuthJob>(); BarcodeList = new ObservableCollection <BarCodeSettingsList>(); DetailList = new ObservableCollection <EmployeesView>(); AuthClient.GetBarcodeDisplaySettingsHeaderCompleted += (s, sv) => { foreach (var item in sv.Result) { BarcodeList.Add(MapToBarcode(item)); } }; AuthClient.GetBarcodeDisplaySettingsHeaderAsync(); Client.GetGenericAsync("TblCompany", "%%", "%%", "%%", "Iserial", "ASC"); Client.GetGenericCompleted += (s, sv) => { CompanyList = sv.Result; }; AuthClient.SaveUserCompleted += (s, sv) => { var savedRow = MainRowList.ElementAt(sv.outindex); if (savedRow != null) { savedRow.Iserial = sv.Result.Iserial; MessageBox.Show("Saved Successfully"); } else if (sv.Result.Ename == "ERROR_OCCURED") { MessageBox.Show("Error Occured, User NOT saved"); } }; _axUsers = new ObservableCollection <AuthService.User>(); Language = new List <Language> { new Language { CurrLan = 0, Lang = "Arabic" }, new Language { CurrLan = 1, Lang = "English" } }; AuthClient.GetEmpTableCompleted += (s, sv) => { foreach (var row in sv.Result) { DetailList.Add(row); } DetailFullCount = sv.fullCount; Loading = false; }; MainRowList = new ObservableCollection <TblUserViewModel>(); AuthClient.GetAllJobsAsync(); AuthClient.GetAllJobsCompleted += (s, j) => { foreach (var item in j.Result) { Jobs.Add(item); } }; AuthClient.GetAxUserAsync(); AuthClient.GetAxUserCompleted += (s, j) => { foreach (var item in j.Result) { AxUsers.Add(item); } }; AuthClient.GetAllUsersCompleted += (s, ds) => { foreach (var item in ds.Result) { var newRow = new TblUserViewModel(); newRow.InjectFrom(item); newRow.CompanyPerRow = new CRUDManagerService.GenericTable(); newRow.SecondaryCompanyPerRow = new CRUDManagerService.GenericTable(); newRow.PositionPerRow = new CRUDManagerService.GenericTable(); newRow.BarcodePerRow = new BarCodeSettingsList(); if (item.TblCompany1 != null) { newRow.CompanyPerRow.InjectFrom(item.TblCompany1); } if (item.TblCompany2 != null) { newRow.SecondaryCompanyPerRow.InjectFrom(item.TblCompany2); } if (item.TblPosition1 != null) { newRow.PositionPerRow.InjectFrom(item.TblPosition1); } newRow.BarcodePerRow = BarcodeList.FirstOrDefault(x => x.Iserial == newRow.PrintingCode); MainRowList.Add(newRow); newRow.JobPerRow = item.TblAuthJob; } Loading = false; }; GetMaindata(); AuthClient.GetLookUpAuthWarehouseTypesCompleted += (s, e) => { PermissionTypes = e.Result; }; AuthClient.GetLookUpAuthWarehouseTypesAsync(); AuthClient.GetAuthWarehousesCompleted += (s, e) => { WarehouseAuths = e.Result; }; AuthClient.GetAuthJournalSettingCompleted += (s, e) => { JournalAuth = e.Result; }; SavePermissions = new RelayCommand(() => { if (SelectedPermissionType != null && SelectedMainRow != null) { AuthClient.SaveAuthWarehousesAsync(SelectedMainRow.Iserial, SelectedPermissionType.Iserial, WarehouseAuths); } }); SaveJournalAuth = new RelayCommand(() => { if (SelectedMainRow != null) { string comp = ""; if (SelectedMainRow.SecondaryCompanyPerRow != null) { comp = SelectedMainRow.SecondaryCompanyPerRow.Code; } if (comp == "") { if (SelectedMainRow.CompanyPerRow != null) { comp = SelectedMainRow.CompanyPerRow.Code; } } AuthClient.SaveAuthJournalSettingAsync(SelectedMainRow.Iserial, comp, JournalAuth); } }); } }