public void DeleteMainRow() { if (SelectedMainRows != null) { var res = MessageBox.Show("Are You To Delete SelectedRecords From Database ?", "Delete", MessageBoxButton.OKCancel); if (res == MessageBoxResult.OK) { foreach (var row in SelectedMainRows) { if (row.Iserial != 0) { if (AllowDelete != true) { MessageBox.Show(strings.AllowDeleteMsg); return; } Glclient.DeleteTblCostAllocationMethodAsync((TblCostAllocationMethod) new TblCostAllocationMethod().InjectFrom(row), MainRowList.IndexOf(row), LoggedUserInfo.DatabasEname); } else { MainRowList.Remove(row); if (!MainRowList.Any()) { AddNewMainRow(false); } } } } } }