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.DeleteTblCostDimSetupHeaderAsync((TblCostDimSetupHeader) new TblCostDimSetupHeader().InjectFrom(row), LoggedUserInfo.DatabasEname); } else { MainRowList.Remove(row); if (!MainRowList.Any()) { AddNewMainRow(false); } } } } } }