private void SaveCompleted(ObservableCollection <TblStoreCommission> Result, Exception Error) { if (Error != null) { MessageBox.Show(Helper.GetInnerExceptionMessage(Error)); Loading = false; return; } else { MessageBox.Show(strings.SavedMessage); } foreach (var item in Result) { TblStoreCommission savedRow = new TblStoreCommission(); //if (outindex >= 0 && MainRowList.Count > outindex) // savedRow = MainRowList.ElementAt(outindex); savedRow = MainRowList.FirstOrDefault(s => s.Tblstore == item.Tblstore); if (savedRow != null) { savedRow.InjectFrom(Result); savedRow.TblStore1 = StoreList.FirstOrDefault(b => b.iserial == savedRow.Tblstore); } } DeleteCommand.RaiseCanExecuteChanged(); IsNewChanged(); Loading = false; }
public StoreCommissionViewModel() : base(PermissionItemName.StoreCommission) { if (!DesignerProperties.IsInDesignTool) { MainRowList = new ObservableCollection <TblStoreCommission>(); BankDepositClient.GetLookUpStoreCompleted += (s, e) => { StoreList = e.Result; foreach (var item in MainRowList) { item.TblStore1 = StoreList.FirstOrDefault(st => st.iserial == item.Tblstore); } }; GetComboData(); BankDepositClient.GetStoreCommissionCompleted += (s, sv) => { MainRowList.Clear(); foreach (var row in sv.Result) { var newrow = new TblStoreCommission(); newrow.InjectFrom(row); newrow.TblStore1 = StoreList.FirstOrDefault(st => st.iserial == row.Tblstore); MainRowList.Add(newrow); } Loading = false; if (SearchWindow != null) { SearchWindow.Loading = false; } if (FullCount == 0 && MainRowList.Count == 0) { AddNewMainRow(false); } }; BankDepositClient.UpdateOrInsertStoreCommissionCompleted += (s, x) => SaveCompleted(x.Result, x.Error); FilterCommand = new RelayCommand <FilterEvent>((e) => { string filter; Dictionary <string, object> valueObjecttemp; GeneralFilter.GeneralFilterMethod(out filter, out valueObjecttemp, e); Filter = filter; ValuesObjects = valueObjecttemp; GetMaindata(); }); GetMaindata(); //AddNewMainRow(false); } }
private void LoadSelectedAccountFA() { if (SelectedAccountFA == null) { return; } SelectedFAInfoList = new ObservableCollection <FAInfo>(); foreach (var item in FullFAList) { if (item.AccountEquipmentName == SelectedFA.FAName && item.CapexSet.CapexName == SelectedAccountFA.Capex) { //SelectedAccountFAList.Add(item.AccountsMainSet); SelectedFAInfoList.Add(new FAInfo { Company = item.AccountsMainSet.AccountCompany, DateAccount = item.AccountsMainSet.AccountDate, FAPrice = item.AccountEquipmentPrice, Store = item.AccountStoreNumber.ToString() + " " + StoreList.FirstOrDefault(s => s.StoreNumber == item.AccountStoreNumber).StoreName, Accounts = new ObservableCollection <AccountsMainSet> { item.AccountsMainSet }, Quantity = item.AccountEquipmentQuantity, FAName = item.AccountEquipmentName }); } } }