private void Btn_selectedStore_Click(object sender, RoutedEventArgs e) {//select one try { if (sender != null) { SectionData.StartAwait(grid_branchList); } branch = dg_allStores.SelectedItem as Branch; if (branch != null) { allStores.Remove(branch); if (userOrBranch == 'u') { BranchesUsers bu = new BranchesUsers(); bu.branchsUsersId = 0; bu.branchId = branch.branchId; bu.userId = Id; bu.bname = branch.name; bu.createUserId = MainWindow.userID; selectedStoresByUser.Add(bu); dg_selectedStores.ItemsSource = selectedStoresByUser; } else { BranchStore bs = new BranchStore(); bs.id = 0; bs.branchId = branch.branchId; bs.storeId = branch.branchId; bs.createUserId = MainWindow.userID; bs.sname = branch.name; bs.bname = branch.name; bs.isActive = 1; selectedStoresByBranch.Add(bs); dg_selectedStores.ItemsSource = selectedStoresByBranch; } dg_allStores.ItemsSource = allStores; dg_allStores.Items.Refresh(); dg_selectedStores.Items.Refresh(); } if (sender != null) { SectionData.EndAwait(grid_branchList); } } catch (Exception ex) { if (sender != null) { SectionData.EndAwait(grid_branchList); } SectionData.ExceptionMessage(ex, this); } }
private void Btn_unSelectedStore_Click(object sender, RoutedEventArgs e) {//unselect one try { if (sender != null) { SectionData.StartAwait(grid_branchList); } if (userOrBranch == 'u') { branchUser = dg_selectedStores.SelectedItem as BranchesUsers; if (branchUser != null) { branch = allStoresSource.Where(s => s.branchId == branchUser.branchId.Value).FirstOrDefault(); //branch = await branchModel.getBranchById(branchUser.branchId.Value); selectedStoresByUser.Remove(branchUser); dg_selectedStores.ItemsSource = selectedStoresByUser; } } else { branchStore = dg_selectedStores.SelectedItem as BranchStore; if (branchStore != null) { branch = allStoresSource.Where(s => s.branchId == branchStore.storeId.Value).FirstOrDefault(); //branch = await branchModel.getBranchById(branchStore.branchId.Value); selectedStoresByBranch.Remove(branchStore); dg_selectedStores.ItemsSource = selectedStoresByBranch; } } allStores.Add(branch); dg_allStores.ItemsSource = allStores; dg_allStores.Items.Refresh(); dg_selectedStores.Items.Refresh(); if (sender != null) { SectionData.EndAwait(grid_branchList); } } catch (Exception ex) { if (sender != null) { SectionData.EndAwait(grid_branchList); } SectionData.ExceptionMessage(ex, this); } }