private void Strata_CuttingUnitsGridView_SelectionChanging(object sender, FMSC.Controls.SelectionChangingEventArgs e) { try { //stratum is being removed from cutting unit StratumDO st = this.StrataBindingSource.Current as StratumDO; if (e.IsRemoving == false) { return; } // we don't care if they are adding if (st == null) { e.Cancel = true; return; } //see if that stratum can be edited if (!ViewPresenter.CanEditStratumField(st, null)) { throw new UserFacingException("Stratum Can Not Be Removed", null); } } catch (Exception ex) { this.ExceptionHandler.Handel(ex); e.Cancel = true; } }
private void StrataDataGridView_CellEnter(object sender, DataGridViewCellEventArgs e) { if (e.RowIndex < 0 || e.RowIndex > StrataBindingSource.Count) { return; } try { var stratum = StrataBindingSource[e.RowIndex] as StratumDO; if (stratum == null) { return; } var cell = StrataDataGridView.Rows[e.RowIndex].Cells[e.ColumnIndex]; String field = StrataDataGridView.Columns[e.ColumnIndex].DataPropertyName; cell.ReadOnly = !ViewPresenter.CanEditStratumField(stratum, field); } catch (IndexOutOfRangeException) { } catch (Exception ex) { this.ExceptionHandler.Handel(ex); } }