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); } }
public void AddNewMainRow(bool checkLastRow) { var currentRowIndex = (MainRowList.IndexOf(SelectedMainRow)); if (!checkLastRow || currentRowIndex == (MainRowList.Count - 1)) { if (checkLastRow && SelectedMainRow != null) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true); if (!isvalid) { return; } } SelectedMainRow = new TblStoreCommission(); MainRowList.Insert(currentRowIndex + 1, SelectedMainRow); } }
public void SaveMainRow() { if (SelectedMainRow != null) { var valiationCollection = new List <ValidationResult>(); var isvalid = Validator.TryValidateObject(SelectedMainRow, new ValidationContext(SelectedMainRow, null, null), valiationCollection, true); if (isvalid) { var saveRow = new TblStoreCommission(); saveRow.InjectFrom(SelectedMainRow); //var mainRowIndex = MainRowList.IndexOf(SelectedMainRow); //if (mainRowIndex < 0) //{ // MainRowList.Insert(mainRowIndex + 1, SelectedMainRow); mainRowIndex++; //} BankDepositClient.UpdateOrInsertStoreCommissionAsync(MainRowList, //mainRowIndex, LoggedUserInfo.DatabasEname); Loading = true; } } }